From: Rodolfo García Peñas (kix) Date: Tue, 23 Oct 2012 21:59:57 +0000 (+0200) Subject: Better default icon management X-Git-Tag: wmaker-0.95.4~88 X-Git-Url: https://repo.or.cz/w/wmaker-crm.git/commitdiff_plain/ff9f942c477fca301ab5347b0de0451a41796400 Better default icon management This patch replaces the Pixmap icons from screen.h with only one RImage. This image is not processed yet, therefore could be used for icons with title or without it (replacing def_ticon_pixmap and def_icon_pixmap variables). Now the code is better because the Pixmap is generated and saved in the icon structure. See that before this patch, the icon->pixmap was set to None!! With this patch, the icon->pixmap is saved, using the common method used in the other functions to create Pixmaps, the function icon_update_pixmap(). --- diff --git a/src/defaults.c b/src/defaults.c index 4bf9affe..458093c5 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -2381,18 +2381,14 @@ static int setIconTile(WScreen * scr, WDefaultEntry * entry, WTexture ** texture scr->icon_tile_pixmap = pixmap; - if (scr->def_icon_pixmap) { - XFreePixmap(dpy, scr->def_icon_pixmap); - scr->def_icon_pixmap = None; - } - if (scr->def_ticon_pixmap) { - XFreePixmap(dpy, scr->def_ticon_pixmap); - scr->def_ticon_pixmap = None; + if (scr->def_icon_rimage) { + RReleaseImage(scr->def_icon_rimage); + scr->def_icon_rimage = NULL; } - if (scr->icon_back_texture) { + if (scr->icon_back_texture) wTextureDestroy(scr, (WTexture *) scr->icon_back_texture); - } + scr->icon_back_texture = wTextureMakeSolid(scr, &((*texture)->any.color)); if (scr->clip_balloon) diff --git a/src/icon.c b/src/icon.c index 2739ca19..b0da0d8d 100644 --- a/src/icon.c +++ b/src/icon.c @@ -628,28 +628,20 @@ void wIconUpdate(WIcon *icon) static void get_pixmap_icon_from_user_icon(WIcon *icon) { - RImage *image = NULL; WScreen *scr = icon->core->screen_ptr; + /* If the icon has image, update it and continue */ if (icon->file_image) { icon_update_pixmap(icon, icon->file_image); - } else { - /* make default icons */ - if (!scr->def_icon_pixmap) { - image = get_default_image(scr); - scr->def_icon_pixmap = makeIcon(scr, image, False, False, icon->tile_type, icon->highlighted); - scr->def_ticon_pixmap = makeIcon(scr, image, True, False, icon->tile_type, icon->highlighted); - if (image) - RReleaseImage(image); - } + return; + } - if (icon->show_title) - XSetWindowBackgroundPixmap(dpy, icon->core->window, scr->def_ticon_pixmap); - else - XSetWindowBackgroundPixmap(dpy, icon->core->window, scr->def_icon_pixmap); + /* If the icon don't have image, we should use the default image. */ + if (!scr->def_icon_rimage) + scr->def_icon_rimage = get_default_image(scr); - icon->pixmap = None; - } + /* Now, create the pixmap using the default (saved) image */ + icon_update_pixmap(icon, scr->def_icon_rimage); } /* This function creates the RImage using the default icon */ diff --git a/src/screen.h b/src/screen.h index f0210963..dfdbd636 100644 --- a/src/screen.h +++ b/src/screen.h @@ -229,13 +229,12 @@ typedef struct _WScreen { struct RImage *icon_tile; struct RImage *clip_tile; - Pixmap icon_tile_pixmap; /* for app supplied icons */ - Pixmap def_icon_pixmap; /* default icons */ - Pixmap def_ticon_pixmap; + Pixmap icon_tile_pixmap; /* For app supplied icons */ - struct WDialogData *dialog_data; + struct RImage *def_icon_rimage; /* Default RImage icon */ + struct WDialogData *dialog_data; struct W_GeometryView *gview; /* size/position view */