Bool GetBackPixmap(void) { Pixmap maskPixmap; char *path = NULL; Pixmap tmp_pixmap; int w=0, h=0; int icon_depth = 0; FvwmPictureAttributes fpa; fpa.mask = FPAM_NO_ALLOC_PIXELS | FPAM_NO_ALPHA; if (Pdepth <= 8) { fpa.mask |= FPAM_DITHER; } if (IconwinPixmapFile == NULL) return False; path = PictureFindImageFile(IconwinPixmapFile, imagePath, R_OK); if (path == NULL) { return False; } if (!PImageLoadPixmapFromFile( dpy, main_win, path, &tmp_pixmap, &maskPixmap, NULL, &w, &h, &icon_depth, 0, NULL, 0, fpa)) { w = 0; h = 0; fprintf(stderr, "[FvwmIconBox] Problem creating pixmap from " "file: %s\n", path); free(path); return False; } if (icon_depth == 1) { IconwinPixmap = XCreatePixmap(dpy, main_win, w, h, Pdepth); XCopyPlane(dpy, tmp_pixmap, IconwinPixmap, NormalGC, 0, 0, w, h, 0, 0, 1); XFreePixmap(dpy, tmp_pixmap); } else { IconwinPixmap = tmp_pixmap; } free(path); if (w != 0 && h != 0) return True; return 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; }
int SetRootWindow(char *tline) { Pixmap shapeMask = None, temp_pix = None, alpha = None; int w, h; int depth; int nalloc_pixels = 0; Pixel *alloc_pixels = NULL; char *file_path; FvwmPictureAttributes fpa; if (use_our_color_limit) { PictureColorLimitOption colorLimitop = {-1, -1, -1, -1, -1}; colorLimitop.color_limit = opt_color_limit; PictureInitCMapRoot( dpy, !NoColorLimit, &colorLimitop, True, True); } else { /* this use the default visual (not the fvwm one) as * getenv("FVWM_VISUALID") is NULL in any case. But this use * the same color limit than fvwm. * This is "broken" when fvwm use depth <= 8 and a private * color map (i.e., fvwm is started with the -visual{ID} * option), because when fvwm use a private color map the * default color limit is 244. There is no way to know here if * getenv("FVWM_VISUALID") !=NULL. * So, in this unfortunate case the user should use the * --color-limit option */ PictureInitCMap(dpy); } flib_init_graphics(dpy); /* try built-in image path first, but not before pwd */ PictureSetImagePath(".:+"); file_path = PictureFindImageFile(tline, NULL, R_OK); if (file_path == NULL) { file_path = tline; } fpa.mask = FPAM_NO_ALLOC_PIXELS | FPAM_NO_ALPHA; if (Pdepth <= 8 && !NoDither) { fpa.mask |= FPAM_DITHER; } else if (Pdepth <= 16 && Dither) { fpa.mask |= FPAM_DITHER; } if (NoColorLimit) { fpa.mask |= FPAM_NO_COLOR_LIMIT; } if (!PImageLoadPixmapFromFile( dpy, root, file_path, &temp_pix, &shapeMask, &alpha, &w, &h, &depth, &nalloc_pixels, &alloc_pixels, 0, fpa)) { fprintf( stderr, "[fvwm-root] failed to load image file '%s'\n", tline); return -1; } if (depth == Pdepth) { rootImage = temp_pix; } else { XGCValues gcv; GC gc; gcv.background= WhitePixel(dpy, screen); gcv.foreground= BlackPixel(dpy, screen); gc = fvwmlib_XCreateGC( dpy, root, GCForeground | GCBackground, &gcv); rootImage = XCreatePixmap(dpy, root, w, h, Pdepth); XCopyPlane(dpy, temp_pix, rootImage, gc, 0, 0, w, h, 0, 0, 1); XFreePixmap(dpy, temp_pix); XFreeGC(dpy, gc); } XSetWindowBackgroundPixmap(dpy, root, rootImage); save_colors = 1; XClearWindow(dpy, root); return 0; }