/*************************************************************************** * * * Looks for an application supplied icon window * *************************************************************************** */ void GetIconWindow(struct icon_info *item) { int x, y; unsigned int bw; Window Junkroot; if(!XGetGeometry(dpy, item->wmhints->icon_window, &Junkroot, &x, &y, (unsigned int *)&item->icon_w, (unsigned int *)&item->icon_h, &bw, (unsigned int *)&item->icon_depth)) { /* disable the icon window hint */ item->wmhints->icon_window = None; item->wmhints->flags &= ~IconWindowHint; return; } item->icon_pixmap_w = item->wmhints->icon_window; if (FShapesSupported && (item->wmhints->flags & IconMaskHint)) { SET_ICON_SHAPED(item, True); item->icon_maskPixmap = item->wmhints->icon_mask; } item->icon_w = min(max_icon_width + icon_relief, item->icon_w); item->icon_h = min(max_icon_height + icon_relief, item->icon_h); XReparentWindow(dpy, item->icon_pixmap_w, icon_win, 0, 0); XSetWindowBorderWidth(dpy, item->icon_pixmap_w, 0); SET_ICON_OURS(item, False); SET_PIXMAP_OURS(item, False); }
/* * * Looks for icon from a file * */ void GetIconFromFile(struct icon_info *item) { char *path = PictureFindImageFile(item->icon_file, imagePath, R_OK); FvwmPictureAttributes fpa; if (NULL == path) { fprintf(stderr, "[FvwmIconBox] cannot find %s on ImagePath %s\n", item->icon_file, imagePath); return; } fpa.mask = 0; if (Iconcolorset >= 0 && Colorset[Iconcolorset].do_dither_icon) { fpa.mask |= FPAM_DITHER; } item->icon_w = 0; item->icon_h = 0; if (!PImageLoadPixmapFromFile( dpy, main_win, path, &item->iconPixmap, &item->icon_maskPixmap, &item->icon_alphaPixmap, &item->icon_w, &item->icon_h, &item->icon_depth, &item->icon_nalloc_pixels, &item->icon_alloc_pixels, &item->icon_no_limit, fpa)) { fprintf(stderr, "[FvwmIconBox] cannot load pixmap from " "file '%s'\n",path); item->icon_w = 0; item->icon_h = 0; return; } item->icon_w = min(max_icon_width, item->icon_w); item->icon_h = min(max_icon_height, item->icon_h); SET_ICON_OURS(item, True); SET_PIXMAP_OURS(item, True); free(path); return; }
/* * * Looks for an application supplied bitmap or pixmap * */ void GetIconBitmap(struct icon_info *item) { int x, y; unsigned int bw, depth; Window Junkroot; GC gc; item->icon_file = NULL; item->icon_maskPixmap = None; item->icon_alphaPixmap = None; item->iconPixmap = None; item->icon_w = 0; item->icon_h = 0; if (!XGetGeometry( dpy, item->wmhints->icon_pixmap, &Junkroot, &x, &y, (unsigned int *)&item->icon_w, (unsigned int *)&item->icon_h, &bw, &depth)) { /* disable icon pixmap hint */ item->icon_w = 0; item->icon_h = 0; item->wmhints->icon_pixmap = None; item->wmhints->flags &= ~IconPixmapHint; return; } /* sanity check the pixmap depth, it must be the same as the root or 1 */ if (depth != 1 && depth != Pdepth) { /* disable icon pixmap hint */ item->icon_w = 0; item->icon_h = 0; item->wmhints->icon_pixmap = None; item->wmhints->flags &= ~IconPixmapHint; return; } item->icon_depth = depth; if (FShapesSupported && (item->wmhints->flags & IconMaskHint)) { SET_ICON_SHAPED(item, True); item->icon_maskPixmap = item->wmhints->icon_mask; } item->icon_w = min(max_icon_width, item->icon_w); item->icon_h = min(max_icon_height, item->icon_h); if (item->icon_w <= 0 || item->icon_h <= 0) { item->icon_w = 0; item->icon_h = 0; return; } item->iconPixmap = XCreatePixmap(dpy, Root, item->icon_w, item->icon_h, depth); gc = fvwmlib_XCreateGC(dpy, item->iconPixmap, 0, NULL); XCopyArea(dpy, item->wmhints->icon_pixmap, item->iconPixmap, gc, 0, 0, item->icon_w, item->icon_h, 0, 0); XFreeGC(dpy, gc); SET_PIXMAP_OURS(item, False); SET_ICON_OURS(item, True); }
/* * * Looks for an application supplied icon window * */ void GetIconWindow(struct icon_info *item) { int x, y; unsigned int bw; Window Junkroot; if (!XGetGeometry( dpy, item->wmhints->icon_window, &Junkroot, &x, &y, (unsigned int *)&item->icon_w, (unsigned int *)&item->icon_h, &bw, (unsigned int *)&item->icon_depth)) { #if 0 fprintf(stderr, "[%s][GetIconWindow] WARN -- '%s' has an " "invalid icon window hint\n", MyName, item->name); #endif /* disable the icon window hint */ item->icon_w = 0; item->icon_h = 0; item->wmhints->icon_window = None; item->wmhints->flags &= ~IconWindowHint; return; } item->icon_pixmap_w = item->wmhints->icon_window; if (FShapesSupported && (item->wmhints->flags & IconMaskHint)) { SET_ICON_SHAPED(item, True); item->icon_maskPixmap = item->wmhints->icon_mask; } item->icon_w = min(max_icon_width + icon_relief, item->icon_w); item->icon_h = min(max_icon_height + icon_relief, item->icon_h); MyXGrabServer(dpy); do_allow_bad_access = True; XReparentWindow(dpy, item->icon_pixmap_w, icon_win, 0, 0); XSetWindowBorderWidth(dpy, item->icon_pixmap_w, 0); XSelectInput(dpy, item->icon_pixmap_w, ICON_EVENTS); XSync(dpy, 0); do_allow_bad_access = False; if (was_bad_access) { /* give up */ #if 0 fprintf(stderr, "[%s][GetIconWindow] WARN -- BadAcces when " "reparenting %s icon window\n", MyName, item->name); #endif XSelectInput(dpy, item->icon_pixmap_w, NoEventMask); XUnmapWindow(dpy, item->icon_pixmap_w); XReparentWindow(dpy, item->icon_pixmap_w, Root, 0, 0); XUnmapWindow(dpy, item->icon_pixmap_w); MyXUngrabServer(dpy); item->icon_pixmap_w = item->wmhints->icon_window = None; item->wmhints->flags &= ~IconWindowHint; item->icon_maskPixmap = None; item->icon_w = 0; item->icon_h = 0; was_bad_access = False; return; } MyXUngrabServer(dpy); SET_ICON_OURS(item, False); SET_PIXMAP_OURS(item, False); }