From 4a7daf2322901ca43b5cea2cab26015394db5b95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20=28kix=29?= Date: Tue, 8 Oct 2013 00:56:37 +0200 Subject: [PATCH] AppIcon list moved out of WScreen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The appicon list is moved out of WScreen. The reason is because the appicon list is used to create and remove icons (appicons, dock, clip,...) on the screen, but these icons are not associated with the WScreen. These icons are associated with the Workspace. If we check the WWorkspace struct we can see that the Clip is inside this struct. The dock, the background, the workspace name are other items related to the Workspace, not with the screen. So, we should take out the appicon from the WScreen. But, what is the better place to hold it? The workspace? NO!, because the icon list is common to the all workspaces. Probably the better place is hold as independent list in the global namespace, so this is my option. In the next patches we can see that this is the better option, because we can create the icons, without think where we should paint them. Signed-off-by: Rodolfo García Peñas (kix) --- src/WindowMaker.h | 3 +++ src/actions.c | 2 +- src/appicon.c | 32 +++++++++++++++----------------- src/defaults.c | 2 +- src/dock.c | 2 +- src/screen.h | 2 -- 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/WindowMaker.h b/src/WindowMaker.h index 24a3806e..dd5f4805 100644 --- a/src/WindowMaker.h +++ b/src/WindowMaker.h @@ -558,6 +558,9 @@ extern struct wmaker_global_variables { XContext stack; } context; + /* Application related */ + struct WAppIcon *app_icon_list; /* list of all aplication icons */ + } w_global; extern unsigned int ValidModMask; diff --git a/src/actions.c b/src/actions.c index 47461a9d..1b351f41 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1766,7 +1766,7 @@ void wArrangeIcons(WScreen *scr, Bool arrangeAll) : vars[head].yo + vars[head].ys*(vars[head].si*isize)) /* arrange application icons */ - aicon = scr->app_icon_list; + aicon = w_global.app_icon_list; /* reverse them to avoid unnecessarily sliding of icons */ while (aicon && aicon->next) aicon = aicon->next; diff --git a/src/appicon.c b/src/appicon.c index 17ac8e35..0a5d6e6d 100644 --- a/src/appicon.c +++ b/src/appicon.c @@ -70,8 +70,8 @@ static void iconDblClick(WObjDescriptor * desc, XEvent * event); static void iconExpose(WObjDescriptor * desc, XEvent * event); static void wApplicationSaveIconPathFor(const char *iconPath, const char *wm_instance, const char *wm_class); static WAppIcon *wAppIconCreate(WWindow * leader_win); -static void add_to_appicon_list(WScreen *scr, WAppIcon *appicon); -static void remove_from_appicon_list(WScreen *scr, WAppIcon *appicon); +static void add_to_appicon_list(WAppIcon *appicon); +static void remove_from_appicon_list(WAppIcon *appicon); static void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, Window main_window); /* This function is used if the application is a .app. It checks if it has an icon in it @@ -118,7 +118,7 @@ WAppIcon *wAppIconCreateForDock(WScreen *scr, const char *command, const char *w aicon->yindex = -1; aicon->xindex = -1; - add_to_appicon_list(scr, aicon); + add_to_appicon_list(aicon); if (command) aicon->command = wstrdup(command); @@ -191,7 +191,7 @@ void unpaint_app_icon(WApplication *wapp) /* We want to avoid having it on the list because otherwise * there will be a hole when the icons are arranged with * wArrangeIcons() */ - remove_from_appicon_list(scr, aicon); + remove_from_appicon_list(aicon); if (wPreferences.auto_arrange_icons && !aicon->attracted) wArrangeIcons(scr, True); @@ -242,7 +242,7 @@ void paint_app_icon(WApplication *wapp) * having it on the list */ if (!WFLAGP(wapp->main_window_desc, no_appicon) && wapp->app_icon->next == NULL && wapp->app_icon->prev == NULL) - add_to_appicon_list(scr, wapp->app_icon); + add_to_appicon_list(wapp->app_icon); if (!attracting_dock || !wapp->app_icon->attracted || !attracting_dock->collapsed) XMapWindow(dpy, icon->core->window); @@ -326,10 +326,8 @@ static WAppIcon *wAppIconCreate(WWindow *leader_win) return aicon; } -void wAppIconDestroy(WAppIcon * aicon) +void wAppIconDestroy(WAppIcon *aicon) { - WScreen *scr = aicon->icon->core->screen_ptr; - RemoveFromStackList(aicon->icon->core); wIconDestroy(aicon->icon); if (aicon->command) @@ -344,7 +342,7 @@ void wAppIconDestroy(WAppIcon * aicon) if (aicon->wm_class) wfree(aicon->wm_class); - remove_from_appicon_list(scr, aicon); + remove_from_appicon_list(aicon); aicon->destroyed = 1; wrelease(aicon); @@ -1190,23 +1188,23 @@ static void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, Window m } /* Add the appicon to the appiconlist */ -static void add_to_appicon_list(WScreen *scr, WAppIcon *appicon) +static void add_to_appicon_list(WAppIcon *appicon) { appicon->prev = NULL; - appicon->next = scr->app_icon_list; - if (scr->app_icon_list) - scr->app_icon_list->prev = appicon; + appicon->next = w_global.app_icon_list; + if (w_global.app_icon_list) + w_global.app_icon_list->prev = appicon; - scr->app_icon_list = appicon; + w_global.app_icon_list = appicon; } /* Remove the appicon from the appiconlist */ -static void remove_from_appicon_list(WScreen *scr, WAppIcon *appicon) +static void remove_from_appicon_list(WAppIcon *appicon) { - if (appicon == scr->app_icon_list) { + if (appicon == w_global.app_icon_list) { if (appicon->next) appicon->next->prev = NULL; - scr->app_icon_list = appicon->next; + w_global.app_icon_list = appicon->next; } else { if (appicon->next) appicon->next->prev = appicon->prev; diff --git a/src/defaults.c b/src/defaults.c index 2b2a1edf..7d20908d 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -1216,7 +1216,7 @@ void wReadDefaults(WScreen * scr, WMPropList * new_dict) void wDefaultUpdateIcons(WScreen *scr) { - WAppIcon *aicon = scr->app_icon_list; + WAppIcon *aicon = w_global.app_icon_list; WDrawerChain *dc; WWindow *wwin = scr->focused_window; diff --git a/src/dock.c b/src/dock.c index 3606e82b..48b240c9 100644 --- a/src/dock.c +++ b/src/dock.c @@ -661,7 +661,7 @@ static void colectIconsCallback(WMenu *menu, WMenuEntry *entry) assert(entry->clientdata != NULL); clip = clickedIcon->dock; - aicon = clip->screen_ptr->app_icon_list; + aicon = w_global.app_icon_list; while (aicon) { if (!aicon->docked && wDockFindFreeSlot(clip, &x, &y)) { diff --git a/src/screen.h b/src/screen.h index a8540026..0d667a5c 100644 --- a/src/screen.h +++ b/src/screen.h @@ -107,8 +107,6 @@ typedef struct _WScreen { WMArray *fakeGroupLeaders; /* list of fake window group ids */ - struct WAppIcon *app_icon_list; /* list of all app-icons on screen */ - struct WApplication *wapp_list; /* list of all aplications */ WMBag *stacking_list; /* bag of lists of windows