From: "Rodolfo García Peñas (kix)" <[email protected]>
The function icon_create_for_wwindow() don't need call wIconUpdate,
because the flow is always the same:
1. icon_create_for_wwindow() set the icon
2. icon_create_for_wwindow calls wIconUpdate.
3. wIconUpdate always call get_rimage_icon_from_user_icon(). This is because
the icon doesn't have window, therefore the if always select this function
as the first option in the if (if (wwin && WFLAGP(wwin, always_user_icon)))
or using the "else".
This patch also changes the Boolean value for default icon, as is explained as
comment in the source:
+ /* Docks have two cases:
+ * 1. If the dock is a application launcher, the WDomain database is used
+ * to find the icon in the CachePixmap. The stored image is painted in
+ * the dock. Therefore default icon is not recommended.
+ * 2. If the dock is a docked application (appdock), then the dock
+ * painted doesn't need icon, because icon_create_for_wwindow() will be
+ * called later. So we can think that we don't need icon here.
+ * The problem is if the dock is a application launcher, but the icon is
+ * not found (removed, configuration error,...) then the dock doesn't have
+ * icon and is transparent.
+ * Therefore, the best option is use the default icon for the dock.
+ * icon_create_for_wwindow will override the image with the application. */
This change doesn't change the behavior, because before the change, with the
value set to False, when wIconUpdate was called, it calls
get_rimage_icon_from_user_icon() (see the flow above):
static void get_rimage_icon_from_user_icon(WIcon *icon)
{
if (icon->file_image)
return;
/* Remove the icon image */
unset_icon_image(icon);
icon->file_image = get_rimage_from_default(icon->core->screen_ptr);
}
Because is NULL, the icon->file_image is set to the default icon.
With this patch, icon->file_image has set already the default icon, therefore
wIconUpdate doesn't do nothing (multiple function calls without changes),
except call update_icon_pixmap(icon);
Therefore, wIconUpdate can be removed and replaced by update_icon_pixmap(icon)
at icon_create_for_dock().
---
src/icon.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/src/icon.c b/src/icon.c
index abb2056..ec1db7f 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -163,18 +163,29 @@ WIcon *icon_create_for_dock(WScreen *scr, char *command,
char *wm_instance, char
char *file = NULL;
icon = icon_create_core(scr, 0, 0);
+ icon->tile_type = tile;
- /* Search the icon using instance and class, without default icon */
- file = get_icon_filename(scr, wm_instance, wm_class, command, False);
+ /* Docks have two cases:
+ * 1. If the dock is a application launcher, the WDomain database is
used
+ * to find the icon in the CachePixmap. The stored image is painted
in
+ * the dock. Therefore default icon is not recommended.
+ * 2. If the dock is a docked application (appdock), then the dock
+ * painted doesn't need icon, because icon_create_for_wwindow() will
be
+ * called later. So we can think that we don't need icon here.
+ * The problem is if the dock is a application launcher, but the icon is
+ * not found (removed, configuration error,...) then the dock doesn't
have
+ * icon and is transparent.
+ * Therefore, the best option is use the default icon for the dock.
+ * icon_create_for_wwindow will override the image with the
application. */
+ file = get_icon_filename(scr, wm_instance, wm_class, command, 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;
-
- wIconUpdate(icon, NULL);
+ /* Create the pixmap using icon->file_image */
+ update_icon_pixmap(icon);
WMAddNotificationObserver(appearanceObserver, icon,
WNIconAppearanceSettingsChanged, icon);
WMAddNotificationObserver(tileObserver, icon,
WNIconTileSettingsChanged, icon);
--
1.7.10.4
--
To unsubscribe, send mail to [email protected].