launcher: Redraw icons properly on icon theme change
This commit is contained in:
parent
17beb40283
commit
8f2a28f56d
2 changed files with 30 additions and 17 deletions
|
@ -107,6 +107,9 @@ void init_launcher_panel(void *p)
|
||||||
if (launcher->list_apps == NULL)
|
if (launcher->list_apps == NULL)
|
||||||
return;
|
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;
|
launcher->area.on_screen = TRUE;
|
||||||
panel_refresh = TRUE;
|
panel_refresh = TRUE;
|
||||||
instantiate_area_gradients(&launcher->area);
|
instantiate_area_gradients(&launcher->area);
|
||||||
|
@ -230,14 +233,14 @@ gboolean resize_launcher(void *obj)
|
||||||
{
|
{
|
||||||
Launcher *launcher = (Launcher *)obj;
|
Launcher *launcher = (Launcher *)obj;
|
||||||
|
|
||||||
int size, icon_size, icons_per_column, icons_per_row, margin;
|
int size, icons_per_column, icons_per_row, margin;
|
||||||
launcher_compute_geometry(launcher, &size, &icon_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
|
// Resize icons if necessary
|
||||||
for (GSList *l = launcher->list_icons; l; l = l->next) {
|
for (GSList *l = launcher->list_icons; l; l = l->next) {
|
||||||
LauncherIcon *launcherIcon = (LauncherIcon *)l->data;
|
LauncherIcon *launcherIcon = (LauncherIcon *)l->data;
|
||||||
if (launcherIcon->icon_size != icon_size || !launcherIcon->image) {
|
if (launcherIcon->icon_size != launcher->icon_size || !launcherIcon->image) {
|
||||||
launcherIcon->icon_size = icon_size;
|
launcherIcon->icon_size = launcher->icon_size;
|
||||||
launcherIcon->area.width = launcherIcon->icon_size;
|
launcherIcon->area.width = launcherIcon->icon_size;
|
||||||
launcherIcon->area.height = launcherIcon->icon_size;
|
launcherIcon->area.height = launcherIcon->icon_size;
|
||||||
launcher_reload_icon_image(launcher, launcherIcon);
|
launcher_reload_icon_image(launcher, launcherIcon);
|
||||||
|
@ -246,12 +249,17 @@ gboolean resize_launcher(void *obj)
|
||||||
save_icon_cache(launcher->icon_theme_wrapper);
|
save_icon_cache(launcher->icon_theme_wrapper);
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
gboolean needs_repositioning = FALSE;
|
||||||
for (GSList *l = launcher->list_icons; l; l = l->next) {
|
for (GSList *l = launcher->list_icons; l; l = l->next) {
|
||||||
LauncherIcon *launcherIcon = (LauncherIcon *)l->data;
|
LauncherIcon *launcherIcon = (LauncherIcon *)l->data;
|
||||||
if (launcherIcon->area.on_screen)
|
if (launcherIcon->area.on_screen) {
|
||||||
count++;
|
count++;
|
||||||
|
if (launcherIcon->area.posx < 0 || launcherIcon->area.posy < 0)
|
||||||
|
needs_repositioning = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!needs_repositioning) {
|
||||||
if (panel_horizontal) {
|
if (panel_horizontal) {
|
||||||
if (launcher->area.width == size)
|
if (launcher->area.width == size)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -261,6 +269,7 @@ gboolean resize_launcher(void *obj)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
launcher->area.height = size;
|
launcher->area.height = size;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int posx, posy;
|
int posx, posy;
|
||||||
int start;
|
int start;
|
||||||
|
@ -284,17 +293,17 @@ gboolean resize_launcher(void *obj)
|
||||||
// printf("launcher %d : %d,%d\n", i, posx, posy);
|
// printf("launcher %d : %d,%d\n", i, posx, posy);
|
||||||
if (panel_horizontal) {
|
if (panel_horizontal) {
|
||||||
if (i % icons_per_column) {
|
if (i % icons_per_column) {
|
||||||
posy += icon_size + launcher->area.paddingx;
|
posy += launcher->icon_size + launcher->area.paddingx;
|
||||||
} else {
|
} else {
|
||||||
posy = start;
|
posy = start;
|
||||||
posx += (icon_size + launcher->area.paddingx);
|
posx += (launcher->icon_size + launcher->area.paddingx);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (i % icons_per_row) {
|
if (i % icons_per_row) {
|
||||||
posx += icon_size + launcher->area.paddingx;
|
posx += launcher->icon_size + launcher->area.paddingx;
|
||||||
} else {
|
} else {
|
||||||
posx = start;
|
posx = start;
|
||||||
posy += (icon_size + launcher->area.paddingx);
|
posy += (launcher->icon_size + launcher->area.paddingx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -485,6 +494,7 @@ void launcher_load_icons(Launcher *launcher)
|
||||||
launcherIcon->area.bg = launcher_icon_bg;
|
launcherIcon->area.bg = launcher_icon_bg;
|
||||||
launcherIcon->area.gradients = launcher_icon_gradients;
|
launcherIcon->area.gradients = launcher_icon_gradients;
|
||||||
launcherIcon->area.on_screen = TRUE;
|
launcherIcon->area.on_screen = TRUE;
|
||||||
|
launcherIcon->area.posx = -1;
|
||||||
launcherIcon->area._on_change_layout = launcher_icon_on_change_layout;
|
launcherIcon->area._on_change_layout = launcher_icon_on_change_layout;
|
||||||
launcherIcon->area._dump_geometry = launcher_icon_dump_geometry;
|
launcherIcon->area._dump_geometry = launcher_icon_dump_geometry;
|
||||||
if (launcher_tooltip_enabled) {
|
if (launcher_tooltip_enabled) {
|
||||||
|
@ -495,6 +505,7 @@ void launcher_load_icons(Launcher *launcher)
|
||||||
launcherIcon->config_path = strdup(app->data);
|
launcherIcon->config_path = strdup(app->data);
|
||||||
add_area(&launcherIcon->area, (Area *)launcher);
|
add_area(&launcherIcon->area, (Area *)launcher);
|
||||||
launcher->list_icons = g_slist_append(launcher->list_icons, launcherIcon);
|
launcher->list_icons = g_slist_append(launcher->list_icons, launcherIcon);
|
||||||
|
launcherIcon->icon_size = launcher->icon_size;
|
||||||
launcher_reload_icon(launcher, launcherIcon);
|
launcher_reload_icon(launcher, launcherIcon);
|
||||||
instantiate_area_gradients(&launcherIcon->area);
|
instantiate_area_gradients(&launcherIcon->area);
|
||||||
app = g_slist_next(app);
|
app = g_slist_next(app);
|
||||||
|
@ -582,6 +593,7 @@ void launcher_reload_icon_image(Launcher *launcher, LauncherIcon *launcherIcon)
|
||||||
panel_config.mouse_pressed_saturation,
|
panel_config.mouse_pressed_saturation,
|
||||||
panel_config.mouse_pressed_brightness);
|
panel_config.mouse_pressed_brightness);
|
||||||
}
|
}
|
||||||
|
schedule_redraw(&launcherIcon->area);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populates the icon_theme_wrapper list
|
// Populates the icon_theme_wrapper list
|
||||||
|
|
|
@ -18,6 +18,7 @@ typedef struct Launcher {
|
||||||
GSList *list_apps; // List of char*, each is a path to a app.desktop file
|
GSList *list_apps; // List of char*, each is a path to a app.desktop file
|
||||||
GSList *list_icons; // List of LauncherIcon*
|
GSList *list_icons; // List of LauncherIcon*
|
||||||
IconThemeWrapper *icon_theme_wrapper;
|
IconThemeWrapper *icon_theme_wrapper;
|
||||||
|
int icon_size;
|
||||||
} Launcher;
|
} Launcher;
|
||||||
|
|
||||||
typedef struct LauncherIcon {
|
typedef struct LauncherIcon {
|
||||||
|
|
Loading…
Reference in a new issue