mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 12:28:22 +01:00
WindowMaker: New get_wwindow_image_from_x11 function
A new function is created to get the image from the X11 window. The function updateIconImage is splitted in two blocks, one is moved to get_wwindow_image_from_x11 with the X11 code, and other is used to update the Application and Window icons (kept in the same function).
This commit is contained in:
committed by
Carlos R. Mafra
parent
9079b904d6
commit
6cbdebb84b
33
src/wmspec.c
33
src/wmspec.c
@@ -413,40 +413,47 @@ static RImage *makeRImageFromARGBData(unsigned long *data)
|
||||
return image;
|
||||
}
|
||||
|
||||
static void updateIconImage(WWindow * wwin)
|
||||
static RImage *get_wwindow_image_from_x11(WWindow *wwin)
|
||||
{
|
||||
unsigned long *property, *data;
|
||||
unsigned long items, rest;
|
||||
RImage *image;
|
||||
Atom type;
|
||||
int format;
|
||||
unsigned long items, rest;
|
||||
unsigned long *property, *data;
|
||||
|
||||
/* Refresh icon image from X11 */
|
||||
if (wwin->net_icon_image)
|
||||
RReleaseImage(wwin->net_icon_image);
|
||||
|
||||
wwin->net_icon_image = NULL;
|
||||
|
||||
/* Get the icon from X11 Window */
|
||||
if (XGetWindowProperty(dpy, wwin->client_win, net_wm_icon, 0L, LONG_MAX,
|
||||
False, XA_CARDINAL, &type, &format, &items, &rest,
|
||||
(unsigned char **)&property) != Success || !property)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
if (type != XA_CARDINAL || format != 32 || items < 2) {
|
||||
XFree(property);
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Find the best icon */
|
||||
data = findBestIcon(property, items);
|
||||
if (!data) {
|
||||
XFree(property);
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Save the best icon in the X11 icon */
|
||||
wwin->net_icon_image = makeRImageFromARGBData(data);
|
||||
image = makeRImageFromARGBData(data);
|
||||
|
||||
XFree(property);
|
||||
return image;
|
||||
}
|
||||
|
||||
static void updateIconImage(WWindow *wwin)
|
||||
{
|
||||
/* Remove the icon image from X11 */
|
||||
if (wwin->net_icon_image)
|
||||
RReleaseImage(wwin->net_icon_image);
|
||||
|
||||
/* Save the icon in the X11 icon */
|
||||
wwin->net_icon_image = get_wwindow_image_from_x11(wwin);
|
||||
|
||||
/* Refresh the Window Icon */
|
||||
if (wwin->icon)
|
||||
|
||||
Reference in New Issue
Block a user