mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-23 14:42:29 +01:00
WindowMaker: New function get_pixmap_icon_from_wm_hints
The new function get_pixmap_icon_from_wm_hints() splits the function wIconUpdate().
This commit is contained in:
committed by
Carlos R. Mafra
parent
3adc058421
commit
cf9f0ec67e
112
src/icon.c
112
src/icon.c
@@ -57,6 +57,7 @@ static void miniwindowMouseDown(WObjDescriptor * desc, XEvent * event);
|
|||||||
static void miniwindowDblClick(WObjDescriptor * desc, XEvent * event);
|
static void miniwindowDblClick(WObjDescriptor * desc, XEvent * event);
|
||||||
|
|
||||||
void get_pixmap_icon_from_icon_win(WIcon *icon);
|
void get_pixmap_icon_from_icon_win(WIcon *icon);
|
||||||
|
int get_pixmap_icon_from_wm_hints(WScreen *scr, WWindow *wwin, WIcon *icon);
|
||||||
/****** Notification Observers ******/
|
/****** Notification Observers ******/
|
||||||
|
|
||||||
static void appearanceObserver(void *self, WMNotification * notif)
|
static void appearanceObserver(void *self, WMNotification * notif)
|
||||||
@@ -553,7 +554,6 @@ void wIconSelect(WIcon * icon)
|
|||||||
void wIconUpdate(WIcon * icon)
|
void wIconUpdate(WIcon * icon)
|
||||||
{
|
{
|
||||||
WScreen *scr = icon->core->screen_ptr;
|
WScreen *scr = icon->core->screen_ptr;
|
||||||
int title_height = WMFontHeight(scr->icon_title_font);
|
|
||||||
WWindow *wwin = icon->owner;
|
WWindow *wwin = icon->owner;
|
||||||
|
|
||||||
assert(scr->icon_tile != NULL);
|
assert(scr->icon_tile != NULL);
|
||||||
@@ -573,59 +573,8 @@ void wIconUpdate(WIcon * icon)
|
|||||||
icon->pixmap = makeIcon(scr, wwin->net_icon_image, icon->show_title,
|
icon->pixmap = makeIcon(scr, wwin->net_icon_image, icon->show_title,
|
||||||
icon->shadowed, icon->tile_type, icon->highlighted);
|
icon->shadowed, icon->tile_type, icon->highlighted);
|
||||||
} else if (wwin && wwin->wm_hints && (wwin->wm_hints->flags & IconPixmapHint)) {
|
} else if (wwin && wwin->wm_hints && (wwin->wm_hints->flags & IconPixmapHint)) {
|
||||||
int x, y;
|
if (get_pixmap_icon_from_wm_hints(scr, wwin, icon))
|
||||||
unsigned int w, h;
|
|
||||||
Window jw;
|
|
||||||
int ji;
|
|
||||||
unsigned int ju, d;
|
|
||||||
Pixmap pixmap;
|
|
||||||
|
|
||||||
if (!XGetGeometry(dpy, wwin->wm_hints->icon_pixmap, &jw, &ji, &ji, &w, &h, &ju, &d)) {
|
|
||||||
icon->owner->wm_hints->flags &= ~IconPixmapHint;
|
|
||||||
goto user_icon;
|
goto user_icon;
|
||||||
}
|
|
||||||
|
|
||||||
pixmap = XCreatePixmap(dpy, icon->core->window, 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);
|
|
||||||
|
|
||||||
if (w > wPreferences.icon_size)
|
|
||||||
w = wPreferences.icon_size;
|
|
||||||
x = (wPreferences.icon_size - w) / 2;
|
|
||||||
|
|
||||||
if (icon->show_title && (title_height < wPreferences.icon_size)) {
|
|
||||||
drawIconTitle(scr, pixmap, title_height);
|
|
||||||
|
|
||||||
if (h > wPreferences.icon_size - title_height - 2) {
|
|
||||||
h = wPreferences.icon_size - title_height - 2;
|
|
||||||
y = title_height + 1;
|
|
||||||
} else {
|
|
||||||
y = (wPreferences.icon_size - h - title_height) / 2 + title_height + 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (w > wPreferences.icon_size)
|
|
||||||
w = wPreferences.icon_size;
|
|
||||||
y = (wPreferences.icon_size - h) / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wwin->wm_hints->flags & IconMaskHint)
|
|
||||||
XSetClipMask(dpy, scr->copy_gc, wwin->wm_hints->icon_mask);
|
|
||||||
|
|
||||||
XSetClipOrigin(dpy, scr->copy_gc, x, y);
|
|
||||||
|
|
||||||
if (d != scr->w_depth) {
|
|
||||||
XSetForeground(dpy, scr->copy_gc, scr->black_pixel);
|
|
||||||
XSetBackground(dpy, scr->copy_gc, scr->white_pixel);
|
|
||||||
XCopyPlane(dpy, wwin->wm_hints->icon_pixmap, pixmap, scr->copy_gc, 0, 0, w, h, x, y, 1);
|
|
||||||
} else {
|
|
||||||
XCopyArea(dpy, wwin->wm_hints->icon_pixmap, pixmap, scr->copy_gc, 0, 0, w, h, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
XSetClipOrigin(dpy, scr->copy_gc, 0, 0);
|
|
||||||
|
|
||||||
icon->pixmap = pixmap;
|
|
||||||
} else {
|
} else {
|
||||||
user_icon:
|
user_icon:
|
||||||
if (icon->file_image) {
|
if (icon->file_image) {
|
||||||
@@ -733,6 +682,63 @@ void get_pixmap_icon_from_icon_win(WIcon * icon)
|
|||||||
None, wCursor[WCUR_ARROW]);
|
None, wCursor[WCUR_ARROW]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Get the Pixmap from the XWindow wm_hints */
|
||||||
|
int get_pixmap_icon_from_wm_hints(WScreen *scr, WWindow *wwin, WIcon *icon)
|
||||||
|
{
|
||||||
|
Window jw;
|
||||||
|
Pixmap pixmap;
|
||||||
|
unsigned int w, h, ju, d;
|
||||||
|
int ji, x, y;
|
||||||
|
int title_height = WMFontHeight(scr->icon_title_font);
|
||||||
|
|
||||||
|
if (!XGetGeometry(dpy, wwin->wm_hints->icon_pixmap, &jw, &ji, &ji, &w, &h, &ju, &d)) {
|
||||||
|
icon->owner->wm_hints->flags &= ~IconPixmapHint;
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
pixmap = XCreatePixmap(dpy, icon->core->window, 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);
|
||||||
|
|
||||||
|
if (w > wPreferences.icon_size)
|
||||||
|
w = wPreferences.icon_size;
|
||||||
|
x = (wPreferences.icon_size - w) / 2;
|
||||||
|
|
||||||
|
if (icon->show_title && (title_height < wPreferences.icon_size)) {
|
||||||
|
drawIconTitle(scr, pixmap, title_height);
|
||||||
|
|
||||||
|
if (h > wPreferences.icon_size - title_height - 2) {
|
||||||
|
h = wPreferences.icon_size - title_height - 2;
|
||||||
|
y = title_height + 1;
|
||||||
|
} else {
|
||||||
|
y = (wPreferences.icon_size - h - title_height) / 2 + title_height + 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (w > wPreferences.icon_size)
|
||||||
|
w = wPreferences.icon_size;
|
||||||
|
y = (wPreferences.icon_size - h) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wwin->wm_hints->flags & IconMaskHint)
|
||||||
|
XSetClipMask(dpy, scr->copy_gc, wwin->wm_hints->icon_mask);
|
||||||
|
|
||||||
|
XSetClipOrigin(dpy, scr->copy_gc, x, y);
|
||||||
|
|
||||||
|
if (d != scr->w_depth) {
|
||||||
|
XSetForeground(dpy, scr->copy_gc, scr->black_pixel);
|
||||||
|
XSetBackground(dpy, scr->copy_gc, scr->white_pixel);
|
||||||
|
XCopyPlane(dpy, wwin->wm_hints->icon_pixmap, pixmap, scr->copy_gc, 0, 0, w, h, x, y, 1);
|
||||||
|
} else {
|
||||||
|
XCopyArea(dpy, wwin->wm_hints->icon_pixmap, pixmap, scr->copy_gc, 0, 0, w, h, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
XSetClipOrigin(dpy, scr->copy_gc, 0, 0);
|
||||||
|
|
||||||
|
icon->pixmap = pixmap;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
void wIconPaint(WIcon * icon)
|
void wIconPaint(WIcon * icon)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user