Hi, Here is a fix for a bug that those who have an autocollapse clip with omnipresent appicons surely have experienced: sometimes, on start-up, those appicons are displayed but non-functional. See the attached patch for more details.
Best, -- Daniel
commit 31f768e856daaab3191af27bf81bffe9296b3b05 Author: Daniel Déchelotte <[email protected]> Date: Tue Sep 1 23:45:59 2009 +0200 Fix for omnipresent AppIcon bug at startup Bug overview: right after start up, omnipresent AppIcons (living in the Clip) are displayed but non-functionnal. How to reproduce it: place two AppIcons in the Clip, make the first one (A) omnipresent and leave the second one (B) as is. Make the Clip "autocollapse". Switch to the second workspace and restart wmaker. Wmaker starts in the first workspace; the Clip is closed (its text color corresponds to the closed state, AppIcon B is not shown). However, AppIcon A is displayed. Moreover, A does not react when the Clip expands or collapses. Finally, a click on A makes it disappear. Fortunately, changing to another workspace fixes the problem definitively. Explanation and correction: internally, wmaker maintains as many clips as workspaces. When the user switches to another workspace, the omnipresent AppIcons are moved to the new "current" clip. In the situation above (trying to reproduce the bug), when wmaker restarts, the omnipresent AppIcons are restored in the second workspace, whereas the first workspace is active. In the previous code, a "hack" (calling XMapWindow()) unconditionally displayed the omnipresent AppIcons. The proposed patch makes sure the omnipresent AppIcons are moved to the first workspace on wmaker startup. --- src/workspace.c | 32 ++++++++++++++++++++++++++------ 1 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/workspace.c b/src/workspace.c index 6bac7bd..2114ff4 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -1387,6 +1387,7 @@ void wWorkspaceRestoreState(WScreen * scr) wfree(scr->workspaces[i]->name); scr->workspaces[i]->name = wstrdup(WMGetFromPLString(pstr)); if (!wPreferences.flags.noclip) { + int added_omnipresent_icons = 0; clip_state = WMGetFromPLDictionary(wks_state, dClip); if (scr->workspaces[i]->clip) wDockDestroy(scr->workspaces[i]->clip); @@ -1401,13 +1402,32 @@ void wWorkspaceRestoreState(WScreen * scr) */ for (j = 0; j < scr->workspaces[i]->clip->max_icons; j++) { WAppIcon *aicon = scr->workspaces[i]->clip->icon_array[j]; - - if (aicon && aicon->omnipresent) { - aicon->omnipresent = 0; - wClipMakeIconOmnipresent(aicon, True); - XMapWindow(dpy, aicon->icon->core->window); - } + int k; + + if (!aicon || !aicon->omnipresent) + continue; + aicon->omnipresent = 0; + if (wClipMakeIconOmnipresent(aicon, True) != WO_SUCCESS) + continue; + if (i == 0) + continue; + + /* Move this appicon from workspace i to workspace 0 */ + scr->workspaces[i]->clip->icon_array[j] = NULL; + scr->workspaces[i]->clip->icon_count--; + + added_omnipresent_icons++; + /* If there are too many omnipresent appicons, we are in trouble */ + assert(scr->workspaces[0]->clip->icon_count + added_omnipresent_icons + <= scr->workspaces[0]->clip->max_icons); + /* Find first free spot on workspace 0 */ + for (k = 0; k < scr->workspaces[0]->clip->max_icons; k++) + if (scr->workspaces[0]->clip->icon_array[k] == NULL) + break; + scr->workspaces[0]->clip->icon_array[k] = aicon; + aicon->dock = scr->workspaces[0]->clip; } + scr->workspaces[0]->clip->icon_count += added_omnipresent_icons; } WMPostNotificationName(WMNWorkspaceNameChanged, scr, (void *)(uintptr_t) i);
