1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 20:38:08 +01:00

AppIcon list moved out of WScreen

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) <kix@kix.es>
This commit is contained in:
Rodolfo García Peñas (kix)
2013-10-08 00:56:37 +02:00
committed by Carlos R. Mafra
parent 074092f319
commit 4a7daf2322
6 changed files with 21 additions and 22 deletions

View File

@@ -558,6 +558,9 @@ extern struct wmaker_global_variables {
XContext stack; XContext stack;
} context; } context;
/* Application related */
struct WAppIcon *app_icon_list; /* list of all aplication icons */
} w_global; } w_global;
extern unsigned int ValidModMask; extern unsigned int ValidModMask;

View File

@@ -1766,7 +1766,7 @@ void wArrangeIcons(WScreen *scr, Bool arrangeAll)
: vars[head].yo + vars[head].ys*(vars[head].si*isize)) : vars[head].yo + vars[head].ys*(vars[head].si*isize))
/* arrange application icons */ /* arrange application icons */
aicon = scr->app_icon_list; aicon = w_global.app_icon_list;
/* reverse them to avoid unnecessarily sliding of icons */ /* reverse them to avoid unnecessarily sliding of icons */
while (aicon && aicon->next) while (aicon && aicon->next)
aicon = aicon->next; aicon = aicon->next;

View File

@@ -70,8 +70,8 @@ static void iconDblClick(WObjDescriptor * desc, XEvent * event);
static void iconExpose(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 void wApplicationSaveIconPathFor(const char *iconPath, const char *wm_instance, const char *wm_class);
static WAppIcon *wAppIconCreate(WWindow * leader_win); static WAppIcon *wAppIconCreate(WWindow * leader_win);
static void add_to_appicon_list(WScreen *scr, WAppIcon *appicon); static void add_to_appicon_list(WAppIcon *appicon);
static void remove_from_appicon_list(WScreen *scr, WAppIcon *appicon); static void remove_from_appicon_list(WAppIcon *appicon);
static void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, Window main_window); 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 /* 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->yindex = -1;
aicon->xindex = -1; aicon->xindex = -1;
add_to_appicon_list(scr, aicon); add_to_appicon_list(aicon);
if (command) if (command)
aicon->command = wstrdup(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 /* We want to avoid having it on the list because otherwise
* there will be a hole when the icons are arranged with * there will be a hole when the icons are arranged with
* wArrangeIcons() */ * wArrangeIcons() */
remove_from_appicon_list(scr, aicon); remove_from_appicon_list(aicon);
if (wPreferences.auto_arrange_icons && !aicon->attracted) if (wPreferences.auto_arrange_icons && !aicon->attracted)
wArrangeIcons(scr, True); wArrangeIcons(scr, True);
@@ -242,7 +242,7 @@ void paint_app_icon(WApplication *wapp)
* having it on the list */ * having it on the list */
if (!WFLAGP(wapp->main_window_desc, no_appicon) && if (!WFLAGP(wapp->main_window_desc, no_appicon) &&
wapp->app_icon->next == NULL && wapp->app_icon->prev == NULL) 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) if (!attracting_dock || !wapp->app_icon->attracted || !attracting_dock->collapsed)
XMapWindow(dpy, icon->core->window); XMapWindow(dpy, icon->core->window);
@@ -326,10 +326,8 @@ static WAppIcon *wAppIconCreate(WWindow *leader_win)
return aicon; return aicon;
} }
void wAppIconDestroy(WAppIcon * aicon) void wAppIconDestroy(WAppIcon *aicon)
{ {
WScreen *scr = aicon->icon->core->screen_ptr;
RemoveFromStackList(aicon->icon->core); RemoveFromStackList(aicon->icon->core);
wIconDestroy(aicon->icon); wIconDestroy(aicon->icon);
if (aicon->command) if (aicon->command)
@@ -344,7 +342,7 @@ void wAppIconDestroy(WAppIcon * aicon)
if (aicon->wm_class) if (aicon->wm_class)
wfree(aicon->wm_class); wfree(aicon->wm_class);
remove_from_appicon_list(scr, aicon); remove_from_appicon_list(aicon);
aicon->destroyed = 1; aicon->destroyed = 1;
wrelease(aicon); wrelease(aicon);
@@ -1190,23 +1188,23 @@ static void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, Window m
} }
/* Add the appicon to the appiconlist */ /* 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->prev = NULL;
appicon->next = scr->app_icon_list; appicon->next = w_global.app_icon_list;
if (scr->app_icon_list) if (w_global.app_icon_list)
scr->app_icon_list->prev = appicon; w_global.app_icon_list->prev = appicon;
scr->app_icon_list = appicon; w_global.app_icon_list = appicon;
} }
/* Remove the appicon from the appiconlist */ /* 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) if (appicon->next)
appicon->next->prev = NULL; appicon->next->prev = NULL;
scr->app_icon_list = appicon->next; w_global.app_icon_list = appicon->next;
} else { } else {
if (appicon->next) if (appicon->next)
appicon->next->prev = appicon->prev; appicon->next->prev = appicon->prev;

View File

@@ -1216,7 +1216,7 @@ void wReadDefaults(WScreen * scr, WMPropList * new_dict)
void wDefaultUpdateIcons(WScreen *scr) void wDefaultUpdateIcons(WScreen *scr)
{ {
WAppIcon *aicon = scr->app_icon_list; WAppIcon *aicon = w_global.app_icon_list;
WDrawerChain *dc; WDrawerChain *dc;
WWindow *wwin = scr->focused_window; WWindow *wwin = scr->focused_window;

View File

@@ -661,7 +661,7 @@ static void colectIconsCallback(WMenu *menu, WMenuEntry *entry)
assert(entry->clientdata != NULL); assert(entry->clientdata != NULL);
clip = clickedIcon->dock; clip = clickedIcon->dock;
aicon = clip->screen_ptr->app_icon_list; aicon = w_global.app_icon_list;
while (aicon) { while (aicon) {
if (!aicon->docked && wDockFindFreeSlot(clip, &x, &y)) { if (!aicon->docked && wDockFindFreeSlot(clip, &x, &y)) {

View File

@@ -107,8 +107,6 @@ typedef struct _WScreen {
WMArray *fakeGroupLeaders; /* list of fake window group ids */ 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 */ struct WApplication *wapp_list; /* list of all aplications */
WMBag *stacking_list; /* bag of lists of windows WMBag *stacking_list; /* bag of lists of windows