mirror of
https://github.com/gryf/wmaker.git
synced 2026-01-07 22:34:18 +01:00
get_pixmap_icon_from_icon_win rewritten
The function get_pixmap_icon_from_icon_win() is now rewritten. This function now creates the icon using the function get_window_image_from_x11(), using itself as Window and updates the icon using icon_update_pixmap(). At this point the Pixmap is only the icon background. Now we must put inside the dockapp, in the correct position. Then the funcion get the dock application size, (the max size is wPreferences.icon_size, because get_window_image_from_x11() checks the valid size), checks if the icon has title and then reparents the dockapp to put it inside the icon. This patch includes a lot of comments to better understand the code.
This commit is contained in:
committed by
Carlos R. Mafra
parent
19326554cc
commit
314f1dc907
60
src/icon.c
60
src/icon.c
@@ -718,52 +718,52 @@ static RImage *get_default_image(WScreen *scr)
|
|||||||
static void get_pixmap_icon_from_icon_win(WIcon *icon)
|
static void get_pixmap_icon_from_icon_win(WIcon *icon)
|
||||||
{
|
{
|
||||||
XWindowAttributes attr;
|
XWindowAttributes attr;
|
||||||
|
RImage *image;
|
||||||
WScreen *scr = icon->core->screen_ptr;
|
WScreen *scr = icon->core->screen_ptr;
|
||||||
int title_height = WMFontHeight(scr->icon_title_font);
|
int title_height = WMFontHeight(scr->icon_title_font);
|
||||||
unsigned int width, height, depth;
|
unsigned int w, h, d;
|
||||||
int theight;
|
int theight = 0;
|
||||||
int resize = 0;
|
|
||||||
Pixmap pixmap;
|
|
||||||
|
|
||||||
getSize(icon->icon_win, &width, &height, &depth);
|
/* Create the new RImage */
|
||||||
|
image = get_window_image_from_x11(icon->icon_win);
|
||||||
|
|
||||||
if (width > wPreferences.icon_size) {
|
/* Free the icon info */
|
||||||
resize = 1;
|
unset_icon_image(icon);
|
||||||
width = wPreferences.icon_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (height > wPreferences.icon_size) {
|
/* Set the new info */
|
||||||
resize = 1;
|
icon->file = NULL;
|
||||||
height = wPreferences.icon_size;
|
icon->file_image = image;
|
||||||
}
|
|
||||||
|
|
||||||
if (icon->show_title && (height + title_height < wPreferences.icon_size)) {
|
/* Paint the image at the icon */
|
||||||
pixmap = XCreatePixmap(dpy, scr->w_win, wPreferences.icon_size,
|
icon_update_pixmap(icon, image);
|
||||||
wPreferences.icon_size, scr->w_depth);
|
|
||||||
XSetClipMask(dpy, scr->copy_gc, None);
|
/* Reparent the dock application to the icon */
|
||||||
XCopyArea(dpy, scr->icon_tile_pixmap, pixmap, scr->copy_gc, 0, 0,
|
|
||||||
wPreferences.icon_size, wPreferences.icon_size, 0, 0);
|
/* We need the application size to center it
|
||||||
drawIconTitle(scr, pixmap, title_height);
|
* and show in the correct position */
|
||||||
|
getSize(icon->icon_win, &w, &h, &d);
|
||||||
|
|
||||||
|
/* Set extra space for title */
|
||||||
|
if (icon->show_title && (h + title_height < wPreferences.icon_size)) {
|
||||||
theight = title_height;
|
theight = title_height;
|
||||||
|
drawIconTitle(scr, icon->pixmap, theight);
|
||||||
} else {
|
} else {
|
||||||
pixmap = None;
|
|
||||||
theight = 0;
|
|
||||||
XSetWindowBackgroundPixmap(dpy, icon->core->window, scr->icon_tile_pixmap);
|
XSetWindowBackgroundPixmap(dpy, icon->core->window, scr->icon_tile_pixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set the icon border */
|
||||||
XSetWindowBorderWidth(dpy, icon->icon_win, 0);
|
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);
|
|
||||||
|
|
||||||
|
/* Put the dock application in the icon */
|
||||||
|
XReparentWindow(dpy, icon->icon_win, icon->core->window,
|
||||||
|
(wPreferences.icon_size - w) / 2,
|
||||||
|
theight + (wPreferences.icon_size - h - theight) / 2);
|
||||||
|
|
||||||
|
/* Show it and save */
|
||||||
XMapWindow(dpy, icon->icon_win);
|
XMapWindow(dpy, icon->icon_win);
|
||||||
XAddToSaveSet(dpy, icon->icon_win);
|
XAddToSaveSet(dpy, icon->icon_win);
|
||||||
|
|
||||||
/* Save it */
|
/* Needed to move the icon clicking on the application part */
|
||||||
icon->pixmap = pixmap;
|
|
||||||
|
|
||||||
if ((XGetWindowAttributes(dpy, icon->icon_win, &attr)) &&
|
if ((XGetWindowAttributes(dpy, icon->icon_win, &attr)) &&
|
||||||
(attr.all_event_masks & ButtonPressMask))
|
(attr.all_event_masks & ButtonPressMask))
|
||||||
wHackedGrabButton(Button1, MOD_MASK, icon->core->window, True,
|
wHackedGrabButton(Button1, MOD_MASK, icon->core->window, True,
|
||||||
|
|||||||
Reference in New Issue
Block a user