From 4c60717430896e520cf7255dbc9874a7990dd531 Mon Sep 17 00:00:00 2001 From: Thierry Lorthiois Date: Sat, 7 Aug 2010 12:17:56 +0000 Subject: [PATCH] adjust tooltip position (mrovi) --- src/panel.c | 1 + src/tint.c | 2 +- src/tooltip/tooltip.c | 15 ++++++++------- src/tooltip/tooltip.h | 2 +- src/util/area.c | 37 ++++++++++++++++++++++++------------- src/util/area.h | 9 ++++++++- 6 files changed, 43 insertions(+), 23 deletions(-) diff --git a/src/panel.c b/src/panel.c index 662c6c5..5ca3afc 100644 --- a/src/panel.c +++ b/src/panel.c @@ -303,6 +303,7 @@ void init_panel_size_and_position(Panel *panel) void resize_panel(void *obj) { Panel *panel = (Panel*)obj; +//printf("resize_panel : taskbar\n"); if (panel_horizontal) { int taskbar_width, modulo_width = 0; diff --git a/src/tint.c b/src/tint.c index 67cb81c..6d65ea3 100644 --- a/src/tint.c +++ b/src/tint.c @@ -845,7 +845,7 @@ start: Panel* panel = get_panel(e.xmotion.window); Area* area = click_area(panel, e.xmotion.x, e.xmotion.y); if (area->_get_tooltip_text) - tooltip_trigger_show(area, panel, e.xmotion.x_root, e.xmotion.y_root); + tooltip_trigger_show(area, panel, &e); else tooltip_trigger_hide(); break; diff --git a/src/tooltip/tooltip.c b/src/tooltip/tooltip.c index a724473..eb880dd 100644 --- a/src/tooltip/tooltip.c +++ b/src/tooltip/tooltip.c @@ -75,10 +75,11 @@ void init_tooltip() } -void tooltip_trigger_show(Area* area, Panel* p, int x_root, int y_root) +void tooltip_trigger_show(Area* area, Panel* p, XEvent *e) { - x = x_root; - y = y_root; + // Position the tooltip in the center of the area + x = area->posx + area->width / 2 + e->xmotion.x_root - e->xmotion.x; + y = area->posy + area->height / 2 + e->xmotion.y_root - e->xmotion.y; g_tooltip.panel = p; if (g_tooltip.mapped && g_tooltip.area != area) { tooltip_copy_text(area); @@ -93,10 +94,10 @@ void tooltip_trigger_show(Area* area, Panel* p, int x_root, int y_root) void tooltip_show(void* arg) { - int mx, my; - Window w; - XTranslateCoordinates( server.dsp, server.root_win, g_tooltip.panel->main_win, x, y, &mx, &my, &w); - Area* area = click_area(g_tooltip.panel, mx, my); + int mx, my; + Window w; + XTranslateCoordinates( server.dsp, server.root_win, g_tooltip.panel->main_win, x, y, &mx, &my, &w); + Area* area = click_area(g_tooltip.panel, mx, my); stop_tooltip_timeout(); if (!g_tooltip.mapped && area->_get_tooltip_text) { tooltip_copy_text(area); diff --git a/src/tooltip/tooltip.h b/src/tooltip/tooltip.h index fbf71b5..d575773 100644 --- a/src/tooltip/tooltip.h +++ b/src/tooltip/tooltip.h @@ -50,7 +50,7 @@ void default_tooltip(); void cleanup_tooltip(); void init_tooltip(); -void tooltip_trigger_show(Area* area, Panel* p, int x, int y); +void tooltip_trigger_show(Area* area, Panel* p, XEvent *e); void tooltip_show(void* /*arg*/); void tooltip_update(); void tooltip_trigger_hide(); diff --git a/src/util/area.c b/src/util/area.c index 61bf4fc..498df86 100644 --- a/src/util/area.c +++ b/src/util/area.c @@ -31,10 +31,21 @@ #include "panel.h" -// 1) resize child -// 2) resize parent -// 3) redraw parent -// 4) redraw child +/* +// TODO : layering & drawing loop +1) browse tree and calculate 'size' for SIZE_BY_CONTENT + - SIZE_BY_CONTENT loop calculate child first + - if 'size' changed then 'resize = 1' on the parent (tester resize aprés la boucle) + - size == width on horizontal panel and == height on vertical panel +2) browse tree and calculate 'size' for SIZE_BY_LAYOUT + - SIZE_BY_LAYOUT loop calculate parent first + - if 'size' changed then 'resize = 1' on childs with SIZE_BY_LAYOUT + - calculate width = size - somme(child_with_of_SIZE_BY_CONTENT) modulo(number of child_SIZE_BY_LAYOUT) + - calculate modulo = +3) calculate posx of all objects +4) redraw needed objects +*/ + void refresh (Area *a) { // don't draw and resize hide objects @@ -137,9 +148,9 @@ void draw_background (Area *a, cairo_t *c) draw_rect(c, a->bg->border.width/2.0, a->bg->border.width/2.0, a->width - a->bg->border.width, a->height - a->bg->border.width, a->bg->border.rounded); /* // convert : radian = degre * M_PI/180 - // définir le dégradé dans un carré de (0,0) (100,100) - // ensuite ce dégradé est extrapolé selon le ratio width/height - // dans repère (0, 0) (100, 100) + // définir le dégradé dans un carré de (0,0) (100,100) + // ensuite ce dégradé est extrapolé selon le ratio width/height + // dans repère (0, 0) (100, 100) double X0, Y0, X1, Y1, degre; // x = X * (a->width / 100), y = Y * (a->height / 100) double x0, y0, x1, y1; @@ -148,13 +159,13 @@ void draw_background (Area *a, cairo_t *c) X1 = 100; Y1 = 0; degre = 45; - // et ensuite faire la changement d'unité du repère - // car ce qui doit resté inchangée est les traits et pas la direction + // et ensuite faire la changement d'unité du repère + // car ce qui doit resté inchangée est les traits et pas la direction - // il faut d'abord appliquer une rotation de 90° (et -180° si l'angle est supérieur à 180°) - // ceci peut être appliqué une fois pour toute au départ - // ensuite calculer l'angle dans le nouveau repère - // puis faire une rotation de 90° + // il faut d'abord appliquer une rotation de 90° (et -180° si l'angle est supérieur à 180°) + // ceci peut être appliqué une fois pour toute au départ + // ensuite calculer l'angle dans le nouveau repère + // puis faire une rotation de 90° x0 = X0 * ((double)a->width / 100); x1 = X1 * ((double)a->width / 100); y0 = Y0 * ((double)a->height / 100); diff --git a/src/util/area.h b/src/util/area.h index fc294f3..be81b79 100644 --- a/src/util/area.h +++ b/src/util/area.h @@ -47,6 +47,10 @@ typedef struct } Background; +// way to calculate the size +// SIZE_BY_LAYOUT objects : taskbar and task +// SIZE_BY_CONTENT objects : clock, battery, launcher, systray +enum { SIZE_BY_LAYOUT, SIZE_BY_CONTENT }; typedef struct { // coordinate relative to panel window @@ -59,8 +63,11 @@ typedef struct { // list of child : Area object GSList *list; + // object visible on screen int on_screen; - // need compute position and width + // way to calculate the size (SIZE_BY_CONTENT or SIZE_BY_LAYOUT) + int size_mode; + // need to calculate position and width int resize; // need redraw Pixmap int redraw; -- 2.44.0