1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-22 14:08:06 +01:00

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.
This commit is contained in:
Daniel Déchelotte
2009-09-02 00:05:46 +02:00
committed by Carlos R. Mafra
parent b37e065252
commit 7857f297ea

View File

@@ -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];
int k;
if (aicon && aicon->omnipresent) {
aicon->omnipresent = 0;
wClipMakeIconOmnipresent(aicon, True);
XMapWindow(dpy, aicon->icon->core->window);
}
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);