void draw(Area *a) { if (a->pix) { XFreePixmap(server.display, a->pix); if (a->pix_by_state[a->has_mouse_over_effect ? a->mouse_state : 0] != a->pix) XFreePixmap(server.display, a->pix_by_state[a->has_mouse_over_effect ? a->mouse_state : 0]); } a->pix = XCreatePixmap(server.display, server.root_win, a->width, a->height, server.depth); a->pix_by_state[a->has_mouse_over_effect ? a->mouse_state : 0] = a->pix; if (!a->_clear) { // Add layer of root pixmap (or clear pixmap if real_transparency==true) if (server.real_transparency) clear_pixmap(a->pix, 0, 0, a->width, a->height); XCopyArea(server.display, ((Panel *)a->panel)->temp_pmap, a->pix, server.gc, a->posx, a->posy, a->width, a->height, 0, 0); } else { a->_clear(a); } cairo_surface_t *cs = cairo_xlib_surface_create(server.display, a->pix, server.visual, a->width, a->height); cairo_t *c = cairo_create(cs); draw_background(a, c); if (a->_draw_foreground) a->_draw_foreground(a, c); cairo_destroy(c); cairo_surface_destroy(cs); }
void set_panel_background(Panel *p) { if (p->area.pix) XFreePixmap (server.dsp, p->area.pix); p->area.pix = XCreatePixmap (server.dsp, server.root_win, p->area.width, p->area.height, server.depth); int xoff=0, yoff=0; if (panel_horizontal && panel_position & BOTTOM) yoff = p->area.height-p->hidden_height; else if (!panel_horizontal && panel_position & RIGHT) xoff = p->area.width-p->hidden_width; if (server.real_transparency) { clear_pixmap(p->area.pix, 0, 0, p->area.width, p->area.height); } else { get_root_pixmap(); // copy background (server.root_pmap) in panel.area.pix Window dummy; int x, y; XTranslateCoordinates(server.dsp, p->main_win, server.root_win, 0, 0, &x, &y, &dummy); if (panel_autohide && p->is_hidden) { x -= xoff; y -= yoff; } XSetTSOrigin(server.dsp, server.gc, -x, -y); XFillRectangle(server.dsp, p->area.pix, server.gc, 0, 0, p->area.width, p->area.height); } // draw background panel cairo_surface_t *cs; cairo_t *c; cs = cairo_xlib_surface_create (server.dsp, p->area.pix, server.visual, p->area.width, p->area.height); c = cairo_create (cs); draw_background(&p->area, c); cairo_destroy (c); cairo_surface_destroy (cs); if (panel_autohide) { if (p->hidden_pixmap) XFreePixmap(server.dsp, p->hidden_pixmap); p->hidden_pixmap = XCreatePixmap(server.dsp, server.root_win, p->hidden_width, p->hidden_height, server.depth); XCopyArea(server.dsp, p->area.pix, p->hidden_pixmap, server.gc, xoff, yoff, p->hidden_width, p->hidden_height, 0, 0); } // redraw panel's object GSList *l0; Area *a; for (l0 = p->area.list; l0 ; l0 = l0->next) { a = l0->data; set_redraw(a); } // reset task 'state_pix' int i; Taskbar *tskbar; for (i=0 ; i < p->nb_desktop ; i++) { tskbar = &p->taskbar[i]; for (l0 = tskbar->area.list; l0 ; l0 = l0->next) { set_task_redraw((Task *)l0->data); } } }
void tooltip_update() { if (!g_tooltip.tooltip_text) { tooltip_hide(0); return; } tooltip_update_geometry(); if (just_shown) { if (!panel_horizontal) y -= height / 2; // center vertically just_shown = FALSE; } tooltip_adjust_geometry(); XMoveResizeWindow(server.display, g_tooltip.window, x, y, width, height); // Stuff for drawing the tooltip cairo_surface_t *cs = cairo_xlib_surface_create(server.display, g_tooltip.window, server.visual, width, height); cairo_t *c = cairo_create(cs); Color bc = g_tooltip.bg->fill_color; Border b = g_tooltip.bg->border; if (server.real_transparency) { clear_pixmap(g_tooltip.window, 0, 0, width, height); draw_rect(c, b.width, b.width, width - 2 * b.width, height - 2 * b.width, b.radius - b.width / 1.571); cairo_set_source_rgba(c, bc.rgb[0], bc.rgb[1], bc.rgb[2], bc.alpha); } else { cairo_rectangle(c, 0., 0, width, height); cairo_set_source_rgb(c, bc.rgb[0], bc.rgb[1], bc.rgb[2]); } cairo_fill(c); cairo_set_line_width(c, b.width); if (server.real_transparency) draw_rect(c, b.width / 2.0, b.width / 2.0, width - b.width, height - b.width, b.radius); else cairo_rectangle(c, b.width / 2.0, b.width / 2.0, width - b.width, height - b.width); cairo_set_source_rgba(c, b.color.rgb[0], b.color.rgb[1], b.color.rgb[2], b.color.alpha); cairo_stroke(c); Color fc = g_tooltip.font_color; cairo_set_source_rgba(c, fc.rgb[0], fc.rgb[1], fc.rgb[2], fc.alpha); PangoLayout *layout = pango_cairo_create_layout(c); pango_layout_set_font_description(layout, g_tooltip.font_desc); pango_layout_set_wrap(layout, PANGO_WRAP_WORD); pango_layout_set_text(layout, g_tooltip.tooltip_text, -1); PangoRectangle r1, r2; pango_layout_get_pixel_extents(layout, &r1, &r2); pango_layout_set_width(layout, width * PANGO_SCALE); pango_layout_set_height(layout, height * PANGO_SCALE); pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END); // I do not know why this is the right way, but with the below cairo_move_to it seems to be centered (horiz. and // vert.) cairo_move_to(c, -r1.x / 2 + g_tooltip.bg->border.width + g_tooltip.paddingx, -r1.y / 2 + 1 + g_tooltip.bg->border.width + g_tooltip.paddingy); pango_cairo_show_layout(c, layout); g_object_unref(layout); cairo_destroy(c); cairo_surface_destroy(cs); }
void panel_clear_background(void *obj) { Panel *p = obj; clear_pixmap(p->area.pix, 0, 0, p->area.width, p->area.height); if (!server.real_transparency) { get_root_pixmap(); // copy background (server.root_pmap) in panel.area.pix Window dummy; int x, y; XTranslateCoordinates(server.display, p->main_win, server.root_win, 0, 0, &x, &y, &dummy); if (panel_autohide && p->is_hidden) { int xoff = 0, yoff = 0; if (panel_horizontal && panel_position & BOTTOM) yoff = p->area.height - p->hidden_height; else if (!panel_horizontal && panel_position & RIGHT) xoff = p->area.width - p->hidden_width; x -= xoff; y -= yoff; } XSetTSOrigin(server.display, server.gc, -x, -y); XFillRectangle(server.display, p->area.pix, server.gc, 0, 0, p->area.width, p->area.height); } }
void draw (Area *a) { if (a->pix) XFreePixmap (server.dsp, a->pix); a->pix = XCreatePixmap (server.dsp, server.root_win, a->width, a->height, server.depth); // add layer of root pixmap (or clear pixmap if real_transparency==true) if (server.real_transparency) clear_pixmap(a->pix, 0 ,0, a->width, a->height); XCopyArea (server.dsp, ((Panel *)a->panel)->temp_pmap, a->pix, server.gc, a->posx, a->posy, a->width, a->height, 0, 0); cairo_surface_t *cs; cairo_t *c; cs = cairo_xlib_surface_create (server.dsp, a->pix, server.visual, a->width, a->height); c = cairo_create (cs); draw_background (a, c); if (a->_draw_foreground) a->_draw_foreground(a, c); cairo_destroy (c); cairo_surface_destroy (cs); }