On Wed 28 May 2014 at 19:13:17 -0500, Matthew D. Fuller wrote:
> 
> On Wed, May 28, 2014 at 11:44:03PM +0200 I heard the voice of
> Rhialto, and lo! it spake thus:
> > 
> > With rev 264 or higher this fixes what I saw.
> 
> With r265 merged into my branch[0], it now acts like trunk; restarting
> shows the icon managers for the first workspace rather than the one
> I'm in, but _only_ those, and all the windows are correct for where I
> am.  And changing workspaces resets the icon managers correctly.

Okay.

The reason why you get the icon manager for the wrong workspace is due
to the initialisation order. When the icon manager windows are created,
the workspace manager is not there yet, so it isn't known which
workspace is current.

I found a way around it by slightly changing the initialisation order,
but that has a side-effect in GrabKeys() that I don't quite grasp.

At the end of that function, it looks at key mappings with the C_ICONMGR
context.  I don't really see why keys are *ungrabbed* there in the first
place...  But it looks at icon manager windows there, and by the changed
order that isn't set up then.

That whole paragraph is independent from tmp_win so it looks more like a
one-time action. So I tend to think that it doesn't matter if it is
first executed only when some later. I think it could just as well be
run just after GrabKeys() is run inside CreateIconManagers(), after all
that is where such keys are potentially being grabbed.

Similar code is still present in current twm versions:
http://cvsweb.netbsd.org/bsdweb.cgi/xsrc/external/mit/twm/dist/src/add_window.c?rev=1.1.1.4&content-type=text/x-cvsweb-markup

I attached a diff (for my cleanup branch), I haven't committed it yet. I
haven't convinced myself quite yet it is ok. You're the icon manager
expert now :-)

=== modified file 'ctwm.c'
--- ctwm.c      2014-05-18 22:45:10 +0000
+++ ctwm.c      2014-05-29 09:27:49 +0000
@@ -785,8 +785,8 @@
 
        CreateWindowRegions ();
        AllocateOthersIconManagers ();
+       CreateWorkSpaceManager ();
        CreateIconManagers();
-       CreateWorkSpaceManager ();
        MakeWorkspacesMenu ();
        createWindowBoxes ();
 #ifdef GNOME

=== modified file 'iconmgr.c'
--- iconmgr.c   2014-05-28 21:21:12 +0000
+++ iconmgr.c   2014-05-29 09:49:24 +0000
@@ -188,7 +188,8 @@
         */
        if (ws) {
            p->twm_win->occupation = 1 << ws->number;
-           if (ws->number > 0) {
+           /* if (ws->number > 0) { */
+           if (ws != Scr->currentvs->wsw->currentwspc) {
                p->twm_win->vs = NULL;
            }
        } else {
@@ -269,6 +270,7 @@
     p->first = NULL;
     p->last = NULL;
     p->active = NULL;
+    p->twm_win = NULL;
     p->scr = Scr;
     p->count = 0;
     p->x = 0;

=== modified file 'add_window.c'
--- add_window.c        2014-05-26 21:05:05 +0000
+++ add_window.c        2014-05-29 10:09:44 +0000
@@ -1567,7 +1567,6 @@
 void GrabKeys(TwmWindow *tmp_win)
 {
     FuncKey *tmp;
-    IconMgr *p;
     int i;
     unsigned int ModifierMask[8] = { ShiftMask, ControlMask, LockMask,
                                     Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask,
@@ -1648,17 +1647,20 @@
        */
        }
     }
-    for (tmp = Scr->FuncKeyRoot.next; tmp != NULL; tmp = tmp->next)
-    {
-       if (tmp->cont == C_ICONMGR && !Scr->NoIconManagers)
+    /* Check if icon manager windows have been set up already */
+    if (!Scr->NoIconManagers && Scr->iconmgr->twm_win) {
+       for (tmp = Scr->FuncKeyRoot.next; tmp != NULL; tmp = tmp->next)
        {
-           for (p = Scr->iconmgr; p != NULL; p = p->next) {
-               ungrabkey (tmp, 0, p->twm_win->w);
+           if (tmp->cont == C_ICONMGR) {
+               IconMgr *p;
+               for (p = Scr->iconmgr; p != NULL; p = p->next) {
+                   ungrabkey (tmp, 0, p->twm_win->w);
 
-               for (i = 0 ; i < 8 ; i++) {
-                   if ((Scr->IgnoreModifier & ModifierMask [i]) &&
-                       !(tmp->mods & ModifierMask [i]))
-                       ungrabkey (tmp, ModifierMask [i], p->twm_win->w);
+                   for (i = 0 ; i < 8 ; i++) {
+                       if ((Scr->IgnoreModifier & ModifierMask [i]) &&
+                           !(tmp->mods & ModifierMask [i]))
+                           ungrabkey (tmp, ModifierMask [i], p->twm_win->w);
+                   }
                }
            }
        }


-Olaf.
-- 
___ Olaf 'Rhialto' Seibert  -- The Doctor: No, 'eureka' is Greek for
\X/ rhialto/at/xs4all.nl    -- 'this bath is too hot.'

Attachment: pgpmZg9LkirQq.pgp
Description: PGP signature

Reply via email to