From: "Rodolfo García Peñas (kix)" <k...@kix.es> The window image (net_icon_image) now includes the image from net_wm_icon atom and the wm_hints image (if net_wm_icon was not found). This is because updateIconImage() now calls get_window_image():
@@ -497,7 +498,7 @@ static void updateIconImage(WWindow *wwin) RReleaseImage(wwin->net_icon_image); /* Save the icon in the X11 icon */ - wwin->net_icon_image = get_window_image_from_net_wm_icon(wwin->client_win); + wwin->net_icon_image = get_window_image(wwin); Because net_icon_image includes both images, the code at wIconStore about call "get_wwindow_image_from_wm_hints" to get the wm_hints image can be removed: @@ -505,8 +504,6 @@ char *wIconStore(WIcon * icon) if (wwin->net_icon_image) image = RRetainImage(wwin->net_icon_image); - else - image = get_wwindow_image_from_wm_hints(wwin); if (!image) { This happends in wIconImage too: @@ -598,12 +595,9 @@ void wIconUpdate(WIcon *icon, RImage *image) /* Get the Pixmap from the WIcon */ get_rimage_icon_from_icon_win(icon); } else if (wwin && wwin->net_icon_image) { - /* Use _NET_WM_ICON icon */ - get_rimage_icon_from_x11(icon); - } else if (wwin && wwin->wm_hints && (wwin->wm_hints->flags & IconPixmapHint)) { - /* Get the Pixmap from the wm_hints, else, from the user */ + /* Use the client image (net_wm_icon or wm_hints pixmap) */ unset_icon_image(icon); - icon->file_image = get_rimage_icon_from_wm_hints(icon->owner); + icon->file_image = RRetainImage(wwin->net_icon_image); if (!icon->file_image) get_rimage_icon_from_user_icon(icon); } else { Therefore, we can join those "else if". Now we need unset the previous image, check if the image is at net_icon_image and use it. If is NULL, then we can use the image provided by the user. Because the function "get_rimage_icon_from_x11()" is only used here, can be removed too. The function "get_rimage_icon_from_wm_hints" could be removed, but is used in "winspector.c". But the code in winspector.c must be changed to use wwin->net_icon_image, because the image is there! Then, can be removed, and the winspector.c is updated. If net_icon_image is NULL, there is no problem (wIconUpdate can handle it). Finally, get_wwindow_image_from_wm_hints" can be static: -RImage *get_wwindow_image_from_wm_hints(WWindow *wwin) +static RImage *get_wwindow_image_from_wm_hints(WWindow *wwin) --- src/icon.c | 40 ++-------------------------------------- src/winspector.c | 4 ++-- src/wmspec.c | 5 +++-- src/wmspec.h | 2 +- 4 files changed, 8 insertions(+), 43 deletions(-) diff --git a/src/icon.c b/src/icon.c index 358fdae..51dd1e0 100644 --- a/src/icon.c +++ b/src/icon.c @@ -64,7 +64,6 @@ static void set_dockapp_in_icon(WIcon *icon); static void get_rimage_icon_from_icon_win(WIcon *icon); static void get_rimage_icon_from_user_icon(WIcon *icon); static RImage *get_default_icon_rimage(WScreen *scr); -static void get_rimage_icon_from_x11(WIcon *icon); static void icon_update_pixmap(WIcon *icon, RImage *image); static void unset_icon_image(WIcon *icon); @@ -505,8 +504,6 @@ char *wIconStore(WIcon * icon) if (wwin->net_icon_image) image = RRetainImage(wwin->net_icon_image); - else - image = get_wwindow_image_from_wm_hints(wwin); if (!image) { wfree(path); @@ -598,12 +595,9 @@ void wIconUpdate(WIcon *icon, RImage *image) /* Get the Pixmap from the WIcon */ get_rimage_icon_from_icon_win(icon); } else if (wwin && wwin->net_icon_image) { - /* Use _NET_WM_ICON icon */ - get_rimage_icon_from_x11(icon); - } else if (wwin && wwin->wm_hints && (wwin->wm_hints->flags & IconPixmapHint)) { - /* Get the Pixmap from the wm_hints, else, from the user */ + /* Use the client image (net_wm_icon or wm_hints pixmap) */ unset_icon_image(icon); - icon->file_image = get_rimage_icon_from_wm_hints(icon->owner); + icon->file_image = RRetainImage(wwin->net_icon_image); if (!icon->file_image) get_rimage_icon_from_user_icon(icon); } else { @@ -642,15 +636,6 @@ void update_icon_pixmap(WIcon *icon) wIconPaint(icon); } -static void get_rimage_icon_from_x11(WIcon *icon) -{ - /* Remove the icon image */ - unset_icon_image(icon); - - /* Set the new icon image */ - icon->file_image = RRetainImage(icon->owner->net_icon_image); -} - static void get_rimage_icon_from_user_icon(WIcon *icon) { if (icon->file_image) @@ -728,27 +713,6 @@ static void set_dockapp_in_icon(WIcon *icon) None, wCursor[WCUR_ARROW]); } -/* Get the RImage from the XWindow wm_hints */ -RImage *get_rimage_icon_from_wm_hints(WWindow *wwin) -{ - RImage *image = NULL; - unsigned int w, h, d; - - if (!getSize(wwin->wm_hints->icon_pixmap, &w, &h, &d)) { - wwin->wm_hints->flags &= ~IconPixmapHint; - return NULL; - } - - image = get_wwindow_image_from_wm_hints(wwin); - if (!image) - return NULL; - - /* Resize the icon to the wPreferences.icon_size size */ - image = wIconValidateIconSize(image, wPreferences.icon_size); - - return image; -} - void wIconPaint(WIcon *icon) { WScreen *scr = icon->core->screen_ptr; diff --git a/src/winspector.c b/src/winspector.c index 90ae2c9..9e688b6 100644 --- a/src/winspector.c +++ b/src/winspector.c @@ -759,11 +759,11 @@ static void applySettings(WMButton *button, InspectorPanel *panel) } else { /* Change App Icon image */ if (wapp->app_icon) - wIconUpdate(wapp->app_icon->icon, get_rimage_icon_from_wm_hints(wwin)); + wIconUpdate(wapp->app_icon->icon, wwin->net_icon_image); /* Change icon image if the app is minimized */ if (wwin->icon) - wIconUpdate(wwin->icon, get_rimage_icon_from_wm_hints(wwin)); + wIconUpdate(wwin->icon, wwin->net_icon_image); } if (file) diff --git a/src/wmspec.c b/src/wmspec.c index 41f1284..ef72ed8 100644 --- a/src/wmspec.c +++ b/src/wmspec.c @@ -230,6 +230,7 @@ static void updateWorkspaceNames(WScreen *scr); static void updateCurrentWorkspace(WScreen *scr); static void updateWorkspaceCount(WScreen *scr); static void wNETWMShowingDesktop(WScreen *scr, Bool show); +static RImage *get_wwindow_image_from_wm_hints(WWindow *wwin); typedef struct NetData { WScreen *scr; @@ -439,7 +440,7 @@ RImage *get_window_image(WWindow *wwin) return image; } -RImage *get_wwindow_image_from_wm_hints(WWindow *wwin) +static RImage *get_wwindow_image_from_wm_hints(WWindow *wwin) { RImage *image = NULL; XWMHints *hints = wwin->wm_hints; @@ -497,7 +498,7 @@ static void updateIconImage(WWindow *wwin) RReleaseImage(wwin->net_icon_image); /* Save the icon in the X11 icon */ - wwin->net_icon_image = get_window_image_from_net_wm_icon(wwin->client_win); + wwin->net_icon_image = get_window_image(wwin); /* Refresh the Window Icon */ if (wwin->icon) diff --git a/src/wmspec.h b/src/wmspec.h index 1630774..9db5f35 100644 --- a/src/wmspec.h +++ b/src/wmspec.h @@ -45,6 +45,6 @@ char *wNETWMGetIconName(Window window); char *wNETWMGetWindowName(Window window); void wNETFrameExtents(WWindow *wwin); void wNETCleanupFrameExtents(WWindow *wwin); -RImage *get_wwindow_image_from_wm_hints(WWindow *wwin); RImage *get_window_image_from_net_wm_icon(Window window); +RImage *get_window_image(WWindow *wwin); #endif -- 1.7.10.4 -- To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.