Hi, I am writing a patch to do the following.
- The WApplication structure has a WWindow struct. - The WWindow struct has aa RImage struct (net_icon_image) - The WApplication structure has a WAppIcon struct. - The WAppIcon struct has WIcon struct. - The WIcon struct has a RImage struct (file_image). Why need two different images in the same struct? Ok, I have a problem with this situation, because one wine application show the correct icon in the appicon, but shows a different (the default) icon when I hit Alt+Tab (cycling). This is because net_icon_image is used in switchpanel.c, when the panel is created. And the appicon.c uses the file_image. Then, I try to remove net_icon_image. Is not difficult, because is used in a few files. But I have problems. I wrote two patches, the first can be applied without problems, because are comments and one memset remove (is not needed IMO). The second patch is more insteresting. It removes the net_icon_image. The problem... the correct image is not showed :-? And I don't know why. I check the pointers, and all is correct. The "image" variable is poiting to the correct "file_image" variable. Help? Thanks a lot. kix >From 693b3ad7ea4e0dfe44c08bc2891c54ae58171c4a Mon Sep 17 00:00:00 2001 From: Rodolfo García Peñas (kix) <[email protected]> Date: Mon, 20 Feb 2012 01:44:37 +0100 Subject: [PATCH 1/2] WindowMaker: Add comments to switchpanel init Some comments are added to the switchpanel initialization function. memset to zero is removed because is done in wmalloc. --- src/switchpanel.c | 32 +++++++++++++++++++++----------- 1 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/switchpanel.c b/src/switchpanel.c index aac3a22..27e9d21 100644 --- a/src/switchpanel.c +++ b/src/switchpanel.c @@ -421,10 +421,11 @@ static WMArray *makeWindowListArray(WWindow *curwin, int include_unmapped, Bool return windows; } +/* SwitchPanel creation */ WSwitchPanel *wInitSwitchPanel(WScreen * scr, WWindow * curwin, Bool class_only) { WWindow *wwin; - WSwitchPanel *panel = wmalloc(sizeof(WSwitchPanel)); + WSwitchPanel *panel; WMFrame *viewport; int i; int width, height; @@ -433,22 +434,24 @@ WSwitchPanel *wInitSwitchPanel(WScreen * scr, WWindow * curwin, Bool class_only) WMRect rect; rect = wGetRectForHead(scr, wGetHeadForPointerLocation(scr)); - memset(panel, 0, sizeof(WSwitchPanel)); - + /* SwitchPanel creation */ + panel = wmalloc(sizeof(WSwitchPanel)); panel->scr = scr; - panel->windows = makeWindowListArray(curwin, wPreferences.swtileImage != NULL, class_only); - count = WMGetArrayItemCount(panel->windows); + /* Count the number of items, if is zero, returns without switchpanel */ + count = WMGetArrayItemCount(panel->windows); if (count == 0) { WMFreeArray(panel->windows); wfree(panel); return NULL; } + /* Set the width of the panel, usint the number of items */ width = ICON_TILE_SIZE * count; iconsThatFitCount = count; + /* If the item size is > switchpanel width, "resize" */ if (width > rect.size.width) { iconsThatFitCount = (rect.size.width - SCREEN_BORDER_SPACING) / ICON_TILE_SIZE; width = iconsThatFitCount * ICON_TILE_SIZE; @@ -456,16 +459,23 @@ WSwitchPanel *wInitSwitchPanel(WScreen * scr, WWindow * curwin, Bool class_only) panel->visibleCount = iconsThatFitCount; + /* If not swtileImage, don't load images. The work is done */ if (!wPreferences.swtileImage) return panel; + /* SwitchPanel heigth */ height = LABEL_HEIGHT + ICON_TILE_SIZE; + /* Create the tileTmp and getTile from sPreferences.swtileImage */ panel->tileTmp = RCreateImage(ICON_TILE_SIZE, ICON_TILE_SIZE, 1); panel->tile = getTile(); - if (panel->tile && wPreferences.swbackImage[8]) { + + /* panel->tile must exists, because we check wPreferences.swtileImage + * before and getTile returns it in the worst case */ + if (panel->tile && wPreferences.swbackImage[8]) panel->bg = createBackImage(width + 2 * BORDER_SPACE, height + 2 * BORDER_SPACE); - } + + /* If tile or tileTmp don't exists, clean */ if (!panel->tileTmp || !panel->tile) { if (panel->bg) RReleaseImage(panel->bg); @@ -478,11 +488,11 @@ WSwitchPanel *wInitSwitchPanel(WScreen * scr, WWindow * curwin, Bool class_only) panel->tileTmp = NULL; } + /* Fill the structure */ panel->white = WMWhiteColor(scr->wmscreen); panel->font = WMBoldSystemFontOfSize(scr->wmscreen, 12); panel->icons = WMCreateArray(count); panel->images = WMCreateArray(count); - panel->win = WMCreateWindow(scr->wmscreen, ""); if (!panel->bg) { @@ -515,6 +525,7 @@ WSwitchPanel *wInitSwitchPanel(WScreen * scr, WWindow * curwin, Bool class_only) WMResizeWidget(panel->iconBox, ICON_TILE_SIZE * count, ICON_TILE_SIZE); WMSetFrameRelief(panel->iconBox, WRFlat); + /* Add the items to the array */ WM_ITERATE_ARRAY(panel->windows, wwin, i) { addIconForWindow(panel, panel->iconBox, wwin, i * ICON_TILE_SIZE, 0); } @@ -530,20 +541,18 @@ WSwitchPanel *wInitSwitchPanel(WScreen * scr, WWindow * curwin, Bool class_only) Pixmap pixmap, mask; RConvertImageMask(scr->rcontext, panel->bg, &pixmap, &mask, 250); - XSetWindowBackgroundPixmap(dpy, WMWidgetXID(panel->win), pixmap); - #ifdef SHAPE if (mask && wShapeSupported) XShapeCombineMask(dpy, WMWidgetXID(panel->win), ShapeBounding, 0, 0, mask, ShapeSet); #endif - if (pixmap) XFreePixmap(dpy, pixmap); if (mask) XFreePixmap(dpy, mask); } + /* Move the panel to the screen center */ { WMPoint center; center = wGetPointToCenterRectInHead(scr, wGetHeadForPointerLocation(scr), @@ -551,6 +560,7 @@ WSwitchPanel *wInitSwitchPanel(WScreen * scr, WWindow * curwin, Bool class_only) WMMoveWidget(panel->win, center.x, center.y); } + /* Set the selected item */ panel->current = WMGetFirstInArray(panel->windows, curwin); if (panel->current >= 0) changeImage(panel, panel->current, 1); -- 1.7.7.3 >From dd2b5780447c416779c187a1d7a1ae58fbad2f13 Mon Sep 17 00:00:00 2001 From: Rodolfo García Peñas (kix) <[email protected]> Date: Mon, 20 Feb 2012 03:07:00 +0100 Subject: [PATCH 2/2] WindowMaker: addIconForWindow don't use net_icon_image Now, get the icon of the application's dock using this icon we have the same in the switchpanel and in the appdock. Is better than net_icon_image. --- src/switchpanel.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/switchpanel.c b/src/switchpanel.c index 27e9d21..9d82000 100644 --- a/src/switchpanel.c +++ b/src/switchpanel.c @@ -32,6 +32,7 @@ #include "switchpanel.h" #include "funcs.h" #include "xinerama.h" +#include "dock.h" extern Atom _XA_WM_IGNORE_FOCUS_EVENTS; @@ -161,6 +162,7 @@ static RImage *scaleDownIfNeeded(RImage * image) return image; } +/* Add icon to the switchpanel */ static void addIconForWindow(WSwitchPanel * panel, WMWidget * parent, WWindow * wwin, int x, int y) { WMFrame *icon = WMCreateFrame(parent); @@ -170,8 +172,14 @@ static void addIconForWindow(WSwitchPanel * panel, WMWidget * parent, WWindow * WMResizeWidget(icon, ICON_TILE_SIZE, ICON_TILE_SIZE); WMMoveWidget(icon, x, y); - if (!WFLAGP(wwin, always_user_icon) && wwin->net_icon_image) - image = RRetainImage(wwin->net_icon_image); + /* Now, get the icon of the application's dock + * using this icon we have the same in the switchpanel and + * in the appdock. Is better than net_icon_image. */ + WApplication *app = wApplicationOf(wwin->main_window); + + if (!WFLAGP(wwin, always_user_icon) && app && app->app_icon && + app->app_icon->icon && app->app_icon->icon->file_image) + image = RRetainImage(app->app_icon->icon->file_image); // Make this use a caching thing. When there are many windows, // it's very likely that most of them are instances of the same thing, -- 1.7.7.3 -- ||// //\\// Rodolfo "kix" Garcia ||\\// //\\ http://www.kix.es/ -- To unsubscribe, send mail to [email protected].
