diff --git a/src/appicon.c b/src/appicon.c index 9f51daca..c70d4df7 100644 --- a/src/appicon.c +++ b/src/appicon.c @@ -240,8 +240,6 @@ void paint_app_icon(WApplication *wapp) void removeAppIconFor(WApplication *wapp) { - char *file = NULL; - if (!wapp->app_icon) return; @@ -257,16 +255,9 @@ void removeAppIconFor(WApplication *wapp) wapp->app_icon->icon->owner = NULL; wapp->app_icon->icon->icon_win = None; - /* Update the icon images */ - /* Search the icon using instance and class, without default icon */ - file = get_icon_filename(wapp->app_icon->icon->core->screen_ptr, wapp->app_icon->wm_instance, wapp->app_icon->wm_class, wapp->app_icon->command, False); - if (file) { - wapp->app_icon->icon->file = wstrdup(file); - wapp->app_icon->icon->file_image = get_rimage_from_file(wapp->app_icon->icon->core->screen_ptr, wapp->app_icon->icon->file, wPreferences.icon_size); - wfree(file); - } - - wIconUpdate(wapp->app_icon->icon, NULL); + /* Set the icon image */ + set_icon_image_from_database(wapp->app_icon->icon, wapp->app_icon->wm_instance, + wapp->app_icon->wm_class, wapp->app_icon->command); /* Paint it */ wAppIconPaint(wapp->app_icon); diff --git a/src/icon.c b/src/icon.c index 13a0c948..e88ec30d 100644 --- a/src/icon.c +++ b/src/icon.c @@ -113,7 +113,6 @@ WIcon *icon_create_for_wwindow(WWindow *wwin) { WScreen *scr = wwin->screen_ptr; WIcon *icon; - char *file; icon = icon_create_core(scr, wwin->icon_x, wwin->icon_y); @@ -141,17 +140,9 @@ WIcon *icon_create_for_wwindow(WWindow *wwin) else wGetIconName(dpy, wwin->client_win, &icon->icon_name); - /* Get the application icon, default included */ - file = get_icon_filename(scr, wwin->wm_instance, wwin->wm_class, NULL, True); - if (file) { - icon->file = wstrdup(file); - icon->file_image = get_rimage_from_file(scr, icon->file, wPreferences.icon_size); - wfree(file); - } - icon->tile_type = TILE_NORMAL; - wIconUpdate(icon, NULL); + set_icon_image_from_database(icon, wwin->wm_instance, wwin->wm_class, NULL); WMAddNotificationObserver(appearanceObserver, icon, WNIconAppearanceSettingsChanged, icon); WMAddNotificationObserver(tileObserver, icon, WNIconTileSettingsChanged, icon); @@ -162,21 +153,11 @@ WIcon *icon_create_for_wwindow(WWindow *wwin) WIcon *icon_create_for_dock(WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile) { WIcon *icon; - char *file = NULL; icon = icon_create_core(scr, 0, 0); - - /* Search the icon using instance and class, without default icon */ - file = get_icon_filename(scr, wm_instance, wm_class, command, False); - if (file) { - icon->file = wstrdup(file); - icon->file_image = get_rimage_from_file(scr, icon->file, wPreferences.icon_size); - wfree(file); - } - icon->tile_type = tile; - wIconUpdate(icon, NULL); + set_icon_image_from_database(icon, wm_instance, wm_class, command); WMAddNotificationObserver(appearanceObserver, icon, WNIconAppearanceSettingsChanged, icon); WMAddNotificationObserver(tileObserver, icon, WNIconTileSettingsChanged, icon); @@ -908,3 +889,17 @@ static void miniwindowMouseDown(WObjDescriptor * desc, XEvent * event) } } } + +void set_icon_image_from_database(WIcon *icon, char *wm_instance, char *wm_class, char *command) +{ + char *file = NULL; + + file = get_icon_filename(icon->core->screen_ptr, wm_instance, wm_class, command, False); + if (file) { + icon->file = wstrdup(file); + icon->file_image = get_rimage_from_file(icon->core->screen_ptr, icon->file, wPreferences.icon_size); + wfree(file); + } + + wIconUpdate(icon, NULL); +} diff --git a/src/icon.h b/src/icon.h index c2a6b098..4e030a87 100644 --- a/src/icon.h +++ b/src/icon.h @@ -56,6 +56,7 @@ typedef struct WIcon { WIcon *icon_create_for_dock(WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile); WIcon *icon_create_for_wwindow(WWindow *wwin); +void set_icon_image_from_database(WIcon *icon, char *wm_instance, char *wm_class, char *command); void wIconDestroy(WIcon *icon); void wIconPaint(WIcon *icon); void wIconUpdate(WIcon *icon, RImage *image);