>From 3e9f430220702142f5e98725943b57fcf766541a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Sun, 4 Mar 2012 13:15:27 +0100
Subject: [PATCH 4/8] WindowMaker: New function get_pixmap_icon_from_icon_win
The new function get_pixmap_icon_from_icon_win split the function wIconUpdate.
---
src/icon.c | 111 +++++++++++++++++++++++++++++++++---------------------------
1 files changed, 61 insertions(+), 50 deletions(-)
diff --git a/src/icon.c b/src/icon.c
index 92c390a..a990be9 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -56,6 +56,7 @@ static void miniwindowExpose(WObjDescriptor * desc, XEvent *
event);
static void miniwindowMouseDown(WObjDescriptor * desc, XEvent * event);
static void miniwindowDblClick(WObjDescriptor * desc, XEvent * event);
+void get_pixmap_icon_from_icon_win(WIcon *icon);
/****** Notification Observers ******/
static void appearanceObserver(void *self, WMNotification * notif)
@@ -565,56 +566,8 @@ void wIconUpdate(WIcon * icon)
goto user_icon;
if (icon->icon_win != None) {
- /* use client specified icon window */
- XWindowAttributes attr;
- int resize = 0;
- unsigned int width, height, depth;
- int theight;
- Pixmap pixmap;
-
- getSize(icon->icon_win, &width, &height, &depth);
-
- if (width > wPreferences.icon_size) {
- resize = 1;
- width = wPreferences.icon_size;
- }
- if (height > wPreferences.icon_size) {
- resize = 1;
- height = wPreferences.icon_size;
- }
- if (icon->show_title && (height + title_height <
wPreferences.icon_size)) {
- pixmap = XCreatePixmap(dpy, scr->w_win,
wPreferences.icon_size,
- wPreferences.icon_size,
scr->w_depth);
- XSetClipMask(dpy, scr->copy_gc, None);
- XCopyArea(dpy, scr->icon_tile_pixmap, pixmap,
scr->copy_gc, 0, 0,
- wPreferences.icon_size,
wPreferences.icon_size, 0, 0);
- drawIconTitle(scr, pixmap, title_height);
- theight = title_height;
- } else {
- pixmap = None;
- theight = 0;
- XSetWindowBackgroundPixmap(dpy, icon->core->window,
scr->icon_tile_pixmap);
- }
-
- XSetWindowBorderWidth(dpy, icon->icon_win, 0);
- XReparentWindow(dpy, icon->icon_win, icon->core->window,
- (wPreferences.icon_size - width) / 2,
- theight + (wPreferences.icon_size - height -
theight) / 2);
- if (resize)
- XResizeWindow(dpy, icon->icon_win, width, height);
-
- XMapWindow(dpy, icon->icon_win);
-
- XAddToSaveSet(dpy, icon->icon_win);
-
- icon->pixmap = pixmap;
-
- if (XGetWindowAttributes(dpy, icon->icon_win, &attr)) {
- if (attr.all_event_masks & ButtonPressMask)
- wHackedGrabButton(Button1, MOD_MASK,
icon->core->window, True,
- ButtonPressMask,
GrabModeSync, GrabModeAsync,
- None, wCursor[WCUR_ARROW]);
- }
+ /* Get the Pixmap from the WIcon */
+ get_pixmap_icon_from_icon_win(icon);
} else if (wwin && wwin->net_icon_image) {
/* Use _NET_WM_ICON icon */
icon->pixmap = makeIcon(scr, wwin->net_icon_image,
icon->show_title,
@@ -723,6 +676,64 @@ void wIconUpdate(WIcon * icon)
wIconPaint(icon);
}
+/* Get the Pixmap from the WIcon of the WWindow */
+void get_pixmap_icon_from_icon_win(WIcon * icon)
+{
+ XWindowAttributes attr;
+ WScreen *scr = icon->core->screen_ptr;
+ int title_height = WMFontHeight(scr->icon_title_font);
+ unsigned int width, height, depth;
+ int theight;
+ int resize = 0;
+ Pixmap pixmap;
+
+ getSize(icon->icon_win, &width, &height, &depth);
+
+ if (width > wPreferences.icon_size) {
+ resize = 1;
+ width = wPreferences.icon_size;
+ }
+
+ if (height > wPreferences.icon_size) {
+ resize = 1;
+ height = wPreferences.icon_size;
+ }
+
+ if (icon->show_title && (height + title_height <
wPreferences.icon_size)) {
+ pixmap = XCreatePixmap(dpy, scr->w_win, wPreferences.icon_size,
+ wPreferences.icon_size, scr->w_depth);
+ XSetClipMask(dpy, scr->copy_gc, None);
+ XCopyArea(dpy, scr->icon_tile_pixmap, pixmap, scr->copy_gc, 0,
0,
+ wPreferences.icon_size, wPreferences.icon_size, 0, 0);
+ drawIconTitle(scr, pixmap, title_height);
+ theight = title_height;
+ } else {
+ pixmap = None;
+ theight = 0;
+ XSetWindowBackgroundPixmap(dpy, icon->core->window,
scr->icon_tile_pixmap);
+ }
+
+ XSetWindowBorderWidth(dpy, icon->icon_win, 0);
+ XReparentWindow(dpy, icon->icon_win, icon->core->window,
+ (wPreferences.icon_size - width) / 2,
+ theight + (wPreferences.icon_size - height - theight) /
2);
+ if (resize)
+ XResizeWindow(dpy, icon->icon_win, width, height);
+
+ XMapWindow(dpy, icon->icon_win);
+ XAddToSaveSet(dpy, icon->icon_win);
+
+ /* Save it */
+ icon->pixmap = pixmap;
+
+ if ((XGetWindowAttributes(dpy, icon->icon_win, &attr)) &&
+ (attr.all_event_masks & ButtonPressMask))
+ wHackedGrabButton(Button1, MOD_MASK,
icon->core->window, True,
+ ButtonPressMask, GrabModeSync,
GrabModeAsync,
+ None, wCursor[WCUR_ARROW]);
+}
+
+
void wIconPaint(WIcon * icon)
{
WScreen *scr = icon->core->screen_ptr;
--
1.7.7.3
--
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/
>From 3e9f430220702142f5e98725943b57fcf766541a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Sun, 4 Mar 2012 13:15:27 +0100
Subject: [PATCH 4/8] WindowMaker: New function get_pixmap_icon_from_icon_win
The new function get_pixmap_icon_from_icon_win split the function wIconUpdate.
---
src/icon.c | 111 +++++++++++++++++++++++++++++++++---------------------------
1 files changed, 61 insertions(+), 50 deletions(-)
diff --git a/src/icon.c b/src/icon.c
index 92c390a..a990be9 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -56,6 +56,7 @@ static void miniwindowExpose(WObjDescriptor * desc, XEvent * event);
static void miniwindowMouseDown(WObjDescriptor * desc, XEvent * event);
static void miniwindowDblClick(WObjDescriptor * desc, XEvent * event);
+void get_pixmap_icon_from_icon_win(WIcon *icon);
/****** Notification Observers ******/
static void appearanceObserver(void *self, WMNotification * notif)
@@ -565,56 +566,8 @@ void wIconUpdate(WIcon * icon)
goto user_icon;
if (icon->icon_win != None) {
- /* use client specified icon window */
- XWindowAttributes attr;
- int resize = 0;
- unsigned int width, height, depth;
- int theight;
- Pixmap pixmap;
-
- getSize(icon->icon_win, &width, &height, &depth);
-
- if (width > wPreferences.icon_size) {
- resize = 1;
- width = wPreferences.icon_size;
- }
- if (height > wPreferences.icon_size) {
- resize = 1;
- height = wPreferences.icon_size;
- }
- if (icon->show_title && (height + title_height < wPreferences.icon_size)) {
- pixmap = XCreatePixmap(dpy, scr->w_win, wPreferences.icon_size,
- wPreferences.icon_size, scr->w_depth);
- XSetClipMask(dpy, scr->copy_gc, None);
- XCopyArea(dpy, scr->icon_tile_pixmap, pixmap, scr->copy_gc, 0, 0,
- wPreferences.icon_size, wPreferences.icon_size, 0, 0);
- drawIconTitle(scr, pixmap, title_height);
- theight = title_height;
- } else {
- pixmap = None;
- theight = 0;
- XSetWindowBackgroundPixmap(dpy, icon->core->window, scr->icon_tile_pixmap);
- }
-
- XSetWindowBorderWidth(dpy, icon->icon_win, 0);
- XReparentWindow(dpy, icon->icon_win, icon->core->window,
- (wPreferences.icon_size - width) / 2,
- theight + (wPreferences.icon_size - height - theight) / 2);
- if (resize)
- XResizeWindow(dpy, icon->icon_win, width, height);
-
- XMapWindow(dpy, icon->icon_win);
-
- XAddToSaveSet(dpy, icon->icon_win);
-
- icon->pixmap = pixmap;
-
- if (XGetWindowAttributes(dpy, icon->icon_win, &attr)) {
- if (attr.all_event_masks & ButtonPressMask)
- wHackedGrabButton(Button1, MOD_MASK, icon->core->window, True,
- ButtonPressMask, GrabModeSync, GrabModeAsync,
- None, wCursor[WCUR_ARROW]);
- }
+ /* Get the Pixmap from the WIcon */
+ get_pixmap_icon_from_icon_win(icon);
} else if (wwin && wwin->net_icon_image) {
/* Use _NET_WM_ICON icon */
icon->pixmap = makeIcon(scr, wwin->net_icon_image, icon->show_title,
@@ -723,6 +676,64 @@ void wIconUpdate(WIcon * icon)
wIconPaint(icon);
}
+/* Get the Pixmap from the WIcon of the WWindow */
+void get_pixmap_icon_from_icon_win(WIcon * icon)
+{
+ XWindowAttributes attr;
+ WScreen *scr = icon->core->screen_ptr;
+ int title_height = WMFontHeight(scr->icon_title_font);
+ unsigned int width, height, depth;
+ int theight;
+ int resize = 0;
+ Pixmap pixmap;
+
+ getSize(icon->icon_win, &width, &height, &depth);
+
+ if (width > wPreferences.icon_size) {
+ resize = 1;
+ width = wPreferences.icon_size;
+ }
+
+ if (height > wPreferences.icon_size) {
+ resize = 1;
+ height = wPreferences.icon_size;
+ }
+
+ if (icon->show_title && (height + title_height < wPreferences.icon_size)) {
+ pixmap = XCreatePixmap(dpy, scr->w_win, wPreferences.icon_size,
+ wPreferences.icon_size, scr->w_depth);
+ XSetClipMask(dpy, scr->copy_gc, None);
+ XCopyArea(dpy, scr->icon_tile_pixmap, pixmap, scr->copy_gc, 0, 0,
+ wPreferences.icon_size, wPreferences.icon_size, 0, 0);
+ drawIconTitle(scr, pixmap, title_height);
+ theight = title_height;
+ } else {
+ pixmap = None;
+ theight = 0;
+ XSetWindowBackgroundPixmap(dpy, icon->core->window, scr->icon_tile_pixmap);
+ }
+
+ XSetWindowBorderWidth(dpy, icon->icon_win, 0);
+ XReparentWindow(dpy, icon->icon_win, icon->core->window,
+ (wPreferences.icon_size - width) / 2,
+ theight + (wPreferences.icon_size - height - theight) / 2);
+ if (resize)
+ XResizeWindow(dpy, icon->icon_win, width, height);
+
+ XMapWindow(dpy, icon->icon_win);
+ XAddToSaveSet(dpy, icon->icon_win);
+
+ /* Save it */
+ icon->pixmap = pixmap;
+
+ if ((XGetWindowAttributes(dpy, icon->icon_win, &attr)) &&
+ (attr.all_event_masks & ButtonPressMask))
+ wHackedGrabButton(Button1, MOD_MASK, icon->core->window, True,
+ ButtonPressMask, GrabModeSync, GrabModeAsync,
+ None, wCursor[WCUR_ARROW]);
+}
+
+
void wIconPaint(WIcon * icon)
{
WScreen *scr = icon->core->screen_ptr;
--
1.7.7.3