int image_render_imlib2(Drawable drawable, struct R_image *image, int w, int h) { Window dummyw; Imlib_Image img; Imlib_Border *border; Imlib_Color_Modifier colormod; Pixmap pixmap; Pixmap mask; int origw, origh; int neww, newh; int dummyi; unsigned int drawablew, drawableh; unsigned int dummyui; if (image == NULL) { return -1; } if (image->im2img == NULL) { image_load_data_imlib2(image); } pixmap = None; mask = None; img = image->im2img; if (img) { imlib_context_set_drawable(drawable); imlib_context_set_image(img); imlib_context_set_mask(image->maskpixmap); imlib_context_set_blend(0); border = &image->im2border; imlib_image_set_border(border); if (w == -1 || h == -1) { XGetGeometry(Rglobals.app->display, drawable, &dummyw, &dummyi, &dummyi, &drawablew, &drawableh, &dummyui, &dummyui); } origw = imlib_image_get_width(); image->origw = origw; if (w == 0) { neww = origw; } else if (w == -1) { neww = drawablew; } else { neww = w; } origh = imlib_image_get_height(); image->origh = origh; if (h == 0) { newh = origh; } else if (h == -1) { newh = drawableh; } else { newh = h; } colormod = image->im2colormods[IMAGE_COLOR_MODIFIER]; if (colormod == NULL) { colormod = imlib_create_color_modifier(); image->im2colormods[IMAGE_COLOR_MODIFIER] = colormod; } imlib_context_set_color_modifier(colormod); imlib_render_pixmaps_for_whole_image_at_size(&pixmap, &mask, neww, newh); if (image->pixmap) { imlib_free_pixmap_and_mask(image->pixmap); image->pixmap = None; image->maskpixmap = None; } image->pixmap = pixmap; image->maskpixmap = mask; #if 0 image->flags |= IMAGE_KEEP_PIXMAP; image_destroy_data_imlib2(image); #endif } return 0; }
feh_menu *feh_menu_new(void) { feh_menu *m; XSetWindowAttributes attr; feh_menu_list *l; static Imlib_Image bg = NULL; static Imlib_Border border; m = (feh_menu *) emalloc(sizeof(feh_menu)); attr.backing_store = NotUseful; attr.override_redirect = True; attr.colormap = cm; attr.border_pixel = 0; attr.background_pixmap = None; attr.save_under = False; attr.do_not_propagate_mask = True; m->win = XCreateWindow( disp, root, 1, 1, 1, 1, 0, depth, InputOutput, vis, CWOverrideRedirect | CWSaveUnder | CWBackingStore | CWColormap | CWBackPixmap | CWBorderPixel | CWDontPropagate, &attr); XSelectInput(disp, m->win, ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | ButtonMotionMask); m->name = NULL; m->fehwin = NULL; m->pmap = 0; m->x = 0; m->y = 0; m->w = 0; m->h = 0; m->visible = 0; m->items = NULL; m->next = NULL; m->prev = NULL; m->updates = NULL; m->needs_redraw = 1; m->func_free = NULL; m->data = NULL; m->calc = 0; m->bg = NULL; l = emalloc(sizeof(feh_menu_list)); l->menu = m; l->next = menus; menus = l; if (!bg) { feh_load_image_char(&bg, opt.menu_bg); if (bg) { border.left = border.right = border.top = border.bottom = 4; imlib_context_set_image(bg); imlib_image_set_border(&border); } } if (bg) m->bg = gib_imlib_clone_image(bg); return(m); }