X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Ftooltip%2Ftooltip.c;h=58169fd3eafe56793ccd05212bbd753e9df42e92;hb=d58d40cf86b22fb1339afb8ce9775182462162e5;hp=e63c1eb1ce9e3cfbd681dd197ad8f6ba971f0181;hpb=9becd8bd3b513a0bbfe778b2ef88f6d598fdf03a;p=chaz%2Ftint2 diff --git a/src/tooltip/tooltip.c b/src/tooltip/tooltip.c index e63c1eb..58169fd 100644 --- a/src/tooltip/tooltip.c +++ b/src/tooltip/tooltip.c @@ -48,8 +48,7 @@ Tooltip g_tooltip = { .paddingx = 0, .paddingy = 0, .font_color = { .color={1, 1, 1}, .alpha=1 }, - .background_color = { .color={0.5, 0.4, 0.5}, .alpha=1 }, - .border = { .color={0, 0, 0}, .alpha=1, .width=1, .rounded=0 }, + .bg = 0, .font_desc = 0, .timeout = 0 }; @@ -74,7 +73,7 @@ void init_tooltip() void cleanup_tooltip() { stop_tooltip_timeout(); - tooltip_hide(); + tooltip_hide(0); g_tooltip.enabled = False; tooltip_copy_text(0); if (g_tooltip.window) { @@ -104,7 +103,7 @@ void tooltip_trigger_show(Area* area, Panel* p, int x_root, int y_root) } -void tooltip_show() +void tooltip_show(void* arg) { int mx, my; Window w; @@ -132,8 +131,8 @@ void tooltip_update_geometry() pango_layout_set_text(layout, g_tooltip.tooltip_text, -1); PangoRectangle r1, r2; pango_layout_get_pixel_extents(layout, &r1, &r2); - width = 2*g_tooltip.border.width + 2*g_tooltip.paddingx + r2.width; - height = 2*g_tooltip.border.width + 2*g_tooltip.paddingy + r2.height; + width = 2*g_tooltip.bg->border.width + 2*g_tooltip.paddingx + r2.width; + height = 2*g_tooltip.bg->border.width + 2*g_tooltip.paddingy + r2.height; Panel* panel = g_tooltip.panel; if (panel_horizontal && panel_position & BOTTOM) @@ -200,7 +199,7 @@ void tooltip_adjust_geometry() void tooltip_update() { if (!g_tooltip.tooltip_text) { - tooltip_hide(); + tooltip_hide(0); return; } @@ -214,17 +213,25 @@ void tooltip_update() PangoLayout* layout; cs = cairo_xlib_surface_create(server.dsp, g_tooltip.window, server.visual, width, height); c = cairo_create(cs); - Color bc = g_tooltip.background_color; - cairo_rectangle(c, 0, 0, width, height); - cairo_set_source_rgba(c, bc.color[0], bc.color[1], bc.color[2], bc.alpha); + Color bc = g_tooltip.bg->back; + Border b = g_tooltip.bg->border; + if (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.rounded-b.width/1.571); + cairo_set_source_rgba(c, bc.color[0], bc.color[1], bc.color[2], bc.alpha); + } + else { + cairo_rectangle(c, 0., 0, width, height); + cairo_set_source_rgb(c, bc.color[0], bc.color[1], bc.color[2]); + } cairo_fill(c); - Border b = g_tooltip.border; - cairo_set_source_rgba(c, b.color[0], b.color[1], b.color[2], b.alpha); cairo_set_line_width(c, b.width); - cairo_rectangle(c, b.width/2.0, b.width/2.0, width-b.width, height-b.width); + if (real_transparency) draw_rect(c, b.width/2.0, b.width/2.0, width - b.width, height - b.width, b.rounded); + 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[0], b.color[1], b.color[2], b.alpha); cairo_stroke(c); - config_color fc = g_tooltip.font_color; + Color fc = g_tooltip.font_color; cairo_set_source_rgba(c, fc.color[0], fc.color[1], fc.color[2], fc.alpha); layout = pango_cairo_create_layout(c); pango_layout_set_font_description(layout, g_tooltip.font_desc); @@ -235,7 +242,7 @@ void tooltip_update() 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.border.width+g_tooltip.paddingx, -r1.y/2+g_tooltip.border.width+g_tooltip.paddingy); + cairo_move_to(c, -r1.x/2+g_tooltip.bg->border.width+g_tooltip.paddingx, -r1.y/2+g_tooltip.bg->border.width+g_tooltip.paddingy); pango_cairo_show_layout (c, layout); g_object_unref (layout); @@ -257,7 +264,7 @@ void tooltip_trigger_hide(Tooltip* tooltip) } -void tooltip_hide() +void tooltip_hide(void* arg) { stop_tooltip_timeout(); if (g_tooltip.mapped) { @@ -271,18 +278,18 @@ void tooltip_hide() void start_show_timeout() { if (g_tooltip.timeout) - change_timeout(g_tooltip.timeout, g_tooltip.show_timeout_msec, 0, tooltip_show); + change_timeout(g_tooltip.timeout, g_tooltip.show_timeout_msec, 0, tooltip_show, 0); else - g_tooltip.timeout = add_timeout(g_tooltip.show_timeout_msec, 0, tooltip_show); + g_tooltip.timeout = add_timeout(g_tooltip.show_timeout_msec, 0, tooltip_show, 0); } void start_hide_timeout() { if (g_tooltip.timeout) - change_timeout(g_tooltip.timeout, g_tooltip.hide_timeout_msec, 0, tooltip_hide); + change_timeout(g_tooltip.timeout, g_tooltip.hide_timeout_msec, 0, tooltip_hide, 0); else - g_tooltip.timeout = add_timeout(g_tooltip.hide_timeout_msec, 0, tooltip_hide); + g_tooltip.timeout = add_timeout(g_tooltip.hide_timeout_msec, 0, tooltip_hide, 0); }