1
0
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:
Rodolfo García Peñas (kix)
2012-03-04 12:45:34 +01:00
committed by Carlos R. Mafra
parent 9079b904d6
commit 6cbdebb84b

View File

@@ -413,40 +413,47 @@ static RImage *makeRImageFromARGBData(unsigned long *data)
return image; return image;
} }
static void updateIconImage(WWindow * wwin) static RImage *get_wwindow_image_from_x11(WWindow *wwin)
{ {
unsigned long *property, *data; RImage *image;
unsigned long items, rest;
Atom type; Atom type;
int format; int format;
unsigned long items, rest;
unsigned long *property, *data;
/* Refresh icon image from X11 */ /* Get the icon from X11 Window */
if (wwin->net_icon_image)
RReleaseImage(wwin->net_icon_image);
wwin->net_icon_image = NULL;
if (XGetWindowProperty(dpy, wwin->client_win, net_wm_icon, 0L, LONG_MAX, if (XGetWindowProperty(dpy, wwin->client_win, net_wm_icon, 0L, LONG_MAX,
False, XA_CARDINAL, &type, &format, &items, &rest, False, XA_CARDINAL, &type, &format, &items, &rest,
(unsigned char **)&property) != Success || !property) (unsigned char **)&property) != Success || !property)
return; return NULL;
if (type != XA_CARDINAL || format != 32 || items < 2) { if (type != XA_CARDINAL || format != 32 || items < 2) {
XFree(property); XFree(property);
return; return NULL;
} }
/* Find the best icon */ /* Find the best icon */
data = findBestIcon(property, items); data = findBestIcon(property, items);
if (!data) { if (!data) {
XFree(property); XFree(property);
return; return NULL;
} }
/* Save the best icon in the X11 icon */ /* Save the best icon in the X11 icon */
wwin->net_icon_image = makeRImageFromARGBData(data); image = makeRImageFromARGBData(data);
XFree(property); 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 */ /* Refresh the Window Icon */
if (wwin->icon) if (wwin->icon)