all repos — tint2 @ 8f2a28f56d463d62e3ac95349d4f2e582a73b668

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

launcher: Redraw icons properly on icon theme change
o9000 mrovi9000@gmail.com
commit

8f2a28f56d463d62e3ac95349d4f2e582a73b668

parent

17beb4028318dd009e36ae8ce8c5f7a1f23cbe44

2 files changed, 30 insertions(+), 17 deletions(-)

jump to
M src/launcher/launcher.csrc/launcher/launcher.c

@@ -107,6 +107,9 @@ // check consistency

if (launcher->list_apps == NULL) return; + // This will be recomputed on resize, we just initialize to a non-zero value + launcher->icon_size = launcher_max_icon_size > 0 ? launcher_max_icon_size : 24; + launcher->area.on_screen = TRUE; panel_refresh = TRUE; instantiate_area_gradients(&launcher->area);

@@ -230,14 +233,14 @@ gboolean resize_launcher(void *obj)

{ Launcher *launcher = (Launcher *)obj; - int size, icon_size, icons_per_column, icons_per_row, margin; - launcher_compute_geometry(launcher, &size, &icon_size, &icons_per_column, &icons_per_row, &margin); + int size, icons_per_column, icons_per_row, margin; + launcher_compute_geometry(launcher, &size, &launcher->icon_size, &icons_per_column, &icons_per_row, &margin); // Resize icons if necessary for (GSList *l = launcher->list_icons; l; l = l->next) { LauncherIcon *launcherIcon = (LauncherIcon *)l->data; - if (launcherIcon->icon_size != icon_size || !launcherIcon->image) { - launcherIcon->icon_size = icon_size; + if (launcherIcon->icon_size != launcher->icon_size || !launcherIcon->image) { + launcherIcon->icon_size = launcher->icon_size; launcherIcon->area.width = launcherIcon->icon_size; launcherIcon->area.height = launcherIcon->icon_size; launcher_reload_icon_image(launcher, launcherIcon);

@@ -246,20 +249,26 @@ }

save_icon_cache(launcher->icon_theme_wrapper); int count = 0; + gboolean needs_repositioning = FALSE; for (GSList *l = launcher->list_icons; l; l = l->next) { LauncherIcon *launcherIcon = (LauncherIcon *)l->data; - if (launcherIcon->area.on_screen) + if (launcherIcon->area.on_screen) { count++; + if (launcherIcon->area.posx < 0 || launcherIcon->area.posy < 0) + needs_repositioning = TRUE; + } } - if (panel_horizontal) { - if (launcher->area.width == size) - return FALSE; - launcher->area.width = size; - } else { - if (launcher->area.height == size) - return FALSE; - launcher->area.height = size; + if (!needs_repositioning) { + if (panel_horizontal) { + if (launcher->area.width == size) + return FALSE; + launcher->area.width = size; + } else { + if (launcher->area.height == size) + return FALSE; + launcher->area.height = size; + } } int posx, posy;

@@ -284,17 +293,17 @@ launcher_icon_on_change_layout(launcherIcon);

// printf("launcher %d : %d,%d\n", i, posx, posy); if (panel_horizontal) { if (i % icons_per_column) { - posy += icon_size + launcher->area.paddingx; + posy += launcher->icon_size + launcher->area.paddingx; } else { posy = start; - posx += (icon_size + launcher->area.paddingx); + posx += (launcher->icon_size + launcher->area.paddingx); } } else { if (i % icons_per_row) { - posx += icon_size + launcher->area.paddingx; + posx += launcher->icon_size + launcher->area.paddingx; } else { posx = start; - posy += (icon_size + launcher->area.paddingx); + posy += (launcher->icon_size + launcher->area.paddingx); } } }

@@ -485,6 +494,7 @@ launcherIcon->area.has_mouse_press_effect = launcherIcon->area.has_mouse_over_effect;

launcherIcon->area.bg = launcher_icon_bg; launcherIcon->area.gradients = launcher_icon_gradients; launcherIcon->area.on_screen = TRUE; + launcherIcon->area.posx = -1; launcherIcon->area._on_change_layout = launcher_icon_on_change_layout; launcherIcon->area._dump_geometry = launcher_icon_dump_geometry; if (launcher_tooltip_enabled) {

@@ -495,6 +505,7 @@ }

launcherIcon->config_path = strdup(app->data); add_area(&launcherIcon->area, (Area *)launcher); launcher->list_icons = g_slist_append(launcher->list_icons, launcherIcon); + launcherIcon->icon_size = launcher->icon_size; launcher_reload_icon(launcher, launcherIcon); instantiate_area_gradients(&launcherIcon->area); app = g_slist_next(app);

@@ -582,6 +593,7 @@ panel_config.mouse_pressed_alpha,

panel_config.mouse_pressed_saturation, panel_config.mouse_pressed_brightness); } + schedule_redraw(&launcherIcon->area); } // Populates the icon_theme_wrapper list
M src/launcher/launcher.hsrc/launcher/launcher.h

@@ -18,6 +18,7 @@ Area area;

GSList *list_apps; // List of char*, each is a path to a app.desktop file GSList *list_icons; // List of LauncherIcon* IconThemeWrapper *icon_theme_wrapper; + int icon_size; } Launcher; typedef struct LauncherIcon {