get_pixmap_icon_from_wm_hints rewritten
authorRodolfo García Peñas (kix) <kix@kix.es>
Wed, 31 Oct 2012 21:44:24 +0000 (31 22:44 +0100)
committerCarlos R. Mafra <crmafra@gmail.com>
Wed, 31 Oct 2012 22:57:31 +0000 (31 22:57 +0000)
The function get_pixmap_icon_from_wm_hints() is now rewritten using
the functions get_wwindow_image_from_wmhints() and icon_update_pixmap().

Now, the function creates a new RImage using get_wwindow_image_from_wmhints()
and then updates the Pixmap using the function icon_update_pixmap().

src/icon.c

index 2f1f07c..018333b 100644 (file)
@@ -728,60 +728,22 @@ static void get_pixmap_icon_from_icon_win(WIcon * icon)
 /* Get the Pixmap from the XWindow wm_hints */
 static int get_pixmap_icon_from_wm_hints(WIcon *icon)
 {
-       Pixmap pixmap;
+       RImage *image = NULL;
        unsigned int w, h, d;
-       int x, y;
        WWindow *wwin = icon->owner;
-       WScreen *scr = icon->core->screen_ptr;
-       int title_height = WMFontHeight(scr->icon_title_font);
 
        if (!getSize(wwin->wm_hints->icon_pixmap, &w, &h, &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);
-       }
+       image = get_wwindow_image_from_wmhints(wwin, icon);
+       if (!image)
+               return 1;
 
-       XSetClipOrigin(dpy, scr->copy_gc, 0, 0);
+       icon_update_pixmap(icon, image);
 
-       icon->pixmap = pixmap;
-       return (0);
+       return  0;
 }
 
 void wIconPaint(WIcon * icon)