Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        E.h areas.c borders.c desktops.c finders.c iconify.c 


Log Message:
Attempt to fix stacking and other problems with transients.
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/E.h,v
retrieving revision 1.285
retrieving revision 1.286
diff -u -3 -r1.285 -r1.286
--- E.h 18 Jun 2004 20:12:06 -0000      1.285
+++ E.h 19 Jun 2004 01:31:19 -0000      1.286
@@ -868,7 +868,7 @@
    Window              group;
    Window              client_leader;
    char                need_input;
-   char                transient;
+   signed char         transient;
    Window              transient_for;
    char                is_group_leader;
    char                no_resize_h;
@@ -2177,7 +2177,8 @@
 Group             **ListWinGroups(EWin * ewin, char group_select, int *num);
 EWin              **ListWinGroupMembersForEwin(EWin * ewin, int action,
                                               char nogroup, int *num);
-EWin              **ListTransientsFor(Window win, int *num);
+EWin              **EwinListTransients(EWin * ewin, int *num, int group);
+EWin              **EwinListTransientFor(EWin * ewin, int *num);
 EWin              **ListGroupMembers(Window win, int *num);
 EWin               *FindEwinByDialog(Dialog * d);
 Dialog             *FindDialogButton(Window win, int *bnum);
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/areas.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -3 -r1.69 -r1.70
--- areas.c     30 May 2004 15:17:44 -0000      1.69
+++ areas.c     19 Jun 2004 01:31:20 -0000      1.70
@@ -320,7 +320,7 @@
        ewin = lst[i];
        if (ewin->sticky)
           continue;
-       if (ewin->client.transient_for)
+       if (ewin->client.transient > 0)
           continue;
        if (ewin->desktop != desks.current && !ewin->floating)
           continue;
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/borders.c,v
retrieving revision 1.194
retrieving revision 1.195
diff -u -3 -r1.194 -r1.195
--- borders.c   18 Jun 2004 20:12:07 -0000      1.194
+++ borders.c   19 Jun 2004 01:31:20 -0000      1.195
@@ -328,7 +328,7 @@
 AddToFamily(Window win)
 {
    EWin               *ewin, *ewin2;
-   EWin               *const *lst;
+   EWin              **lst;
    int                 i, k, num, speed, fx, fy, x, y;
    char                doslide, manplace;
    char                cangrab = 0;
@@ -365,7 +365,7 @@
    /* adopt the new baby */
    ewin = Adopt(win);
 
-   /* if is an afterstep/windowmaker dock app 0- dock it */
+   /* if is an afterstep/windowmaker dock app - dock it */
    if (Conf.dockapp_support && ewin->docked)
      {
        DockIt(ewin);
@@ -376,47 +376,86 @@
    if ((!ewin->client.mwm_decor_title) && (!ewin->client.mwm_decor_border))
       doslide = 0;
 
-   ResizeEwin(ewin, ewin->client.w, ewin->client.h);
-
+   ewin2 = NULL;
    if (ewin->client.transient)
      {
-       /* tag the parent window if this is a transient */
-       ewin2 = FindItem(NULL, ewin->client.transient_for, LIST_FINDBY_ID,
-                        LIST_TYPE_EWIN);
-
-       /* Don't count a self-reference as a valid transient */
-       if (ewin2 && ewin2 != ewin)
-          ewin2->has_transients++;
-
-       if (Conf.focus.transientsfollowleader)
+       if (ewin->client.transient_for == None ||
+           ewin->client.transient_for == VRoot.win)
          {
-            if (!ewin2)
-               ewin2 = FindItem(NULL, ewin->client.group, LIST_FINDBY_ID,
-                                LIST_TYPE_EWIN);
+            /* Group transient */
+            ewin->client.transient_for = VRoot.win;
+#if 0                          /* Maybe? */
+            ewin->layer++;
+#endif
+            /* Don't treat this as a normal transient */
+            ewin->client.transient = -1;
+         }
+       else if (ewin->client.transient_for == ewin->client.win)
+         {
+            /* Some apps actually do this. Why? */
+            ewin->client.transient = 0;
+         }
+       else
+         {
+            /* Regular transient */
+         }
 
-            if (!ewin2)
+       if (ewin->client.transient)
+         {
+            /* Tag the parent window if this is a transient */
+            lst = EwinListTransientFor(ewin, &num);
+            for (i = 0; i < num; i++)
               {
-                 lst = EwinListGetAll(&num);
-                 for (i = 0; i < num; i++)
-                   {
-                      if ((lst[i]->iconified) ||
-                          (ewin->client.group != lst[i]->client.group))
-                         continue;
-
-                      ewin2 = lst[i];
-                      break;
-                   }
+                 lst[i]->has_transients++;
+                 if (ewin->layer < lst[i]->layer)
+                    ewin->layer = lst[i]->layer;
+              }
+            if (lst)
+              {
+                 ewin2 = lst[0];
+                 ewin->sticky = lst[0]->sticky;
+                 Efree(lst);
               }
+            else
+              {
+                 /* No parents? - not a transient */
+                 ewin->client.transient = 0;
+              }
+         }
+     }
 
-            if (ewin2)
+   if (ewin->client.transient && Conf.focus.transientsfollowleader)
+     {
+       EWin               *const *lst2;
+
+       if (!ewin2)
+          ewin2 = FindItem(NULL, ewin->client.group, LIST_FINDBY_ID,
+                           LIST_TYPE_EWIN);
+
+       if (!ewin2)
+         {
+            lst2 = EwinListGetAll(&num);
+            for (i = 0; i < num; i++)
               {
-                 ewin->desktop = ewin2->desktop;
-                 if ((Conf.focus.switchfortransientmap) && (!ewin->iconified))
-                    GotoDesktopByEwin(ewin2);
+                 if ((lst2[i]->iconified) ||
+                     (ewin->client.group != lst2[i]->client.group))
+                    continue;
+
+                 ewin2 = lst2[i];
+                 break;
               }
          }
+
+       if (ewin2)
+         {
+            ewin->desktop = ewin2->desktop;
+            if ((Conf.focus.switchfortransientmap) && (!ewin->iconified))
+               GotoDesktopByEwin(ewin2);
+         }
      }
 
+   ResizeEwin(ewin, ewin->client.w, ewin->client.h);
+
    /* if it hasn't been planted on a desktop - assign it the current desktop */
    if (ewin->desktop < 0)
      {
@@ -1335,7 +1374,8 @@
 static void
 EwinDestroy(EWin * ewin)
 {
-   EWin               *ewin2;
+   EWin              **lst;
+   int                 i, num;
 
    EDBUG(5, "FreeEwin");
    if (!ewin)
@@ -1357,17 +1397,16 @@
 
    HintsDelWindowHints(ewin);
 
-   if (ewin->client.transient)
+   lst = EwinListTransientFor(ewin, &num);
+   for (i = 0; i < num; i++)
      {
-       ewin2 = FindItem(NULL, ewin->client.transient_for, LIST_FINDBY_ID,
-                        LIST_TYPE_EWIN);
-       if (ewin2)
-         {
-            ewin2->has_transients--;
-            if (ewin2->has_transients < 0)
-               ewin2->has_transients = 0;
-         }
+       lst[i]->has_transients--;
+       if (lst[i]->has_transients < 0) /* Paranoia? */
+          lst[i]->has_transients = 0;
      }
+   if (lst)
+      Efree(lst);
+
    if (ewin->border)
       ewin->border->ref_count--;
    if (ewin->icccm.wm_name)
@@ -1772,6 +1811,8 @@
    static int          call_depth = 0;
    int                 dx = 0, dy = 0, sw, sh, x0, y0;
    char                move = 0, resize = 0;
+   EWin              **lst;
+   int                 i, num;
 
    EDBUG(3, "doMoveResizeEwin");
    if (call_depth > 256)
@@ -1856,12 +1897,10 @@
 
    CalcEwinSizes(ewin);
 
-   if (move && ewin->has_transients)
+   if (move)
      {
-       EWin              **lst;
-       int                 i, num;
 
-       lst = ListTransientsFor(ewin->client.win, &num);
+       lst = EwinListTransients(ewin, &num, 0);
        for (i = 0; i < num; i++)
          {
 #if 0                          /* Why? */
@@ -1913,6 +1952,8 @@
 FloatEwin(EWin * ewin)
 {
    static int          call_depth = 0;
+   EWin              **lst;
+   int                 i, num;
 
    EDBUG(3, "FloatEwin");
    call_depth++;
@@ -1922,19 +1963,13 @@
    ewin->desktop = 0;
    ConformEwinToDesktop(ewin);
    RaiseEwin(ewin);
-   if (ewin->has_transients)
-     {
-       EWin              **lst;
-       int                 i, num;
 
-       lst = ListTransientsFor(ewin->client.win, &num);
-       if (lst)
-         {
-            for (i = 0; i < num; i++)
-               FloatEwin(lst[i]);
-            Efree(lst);
-         }
-     }
+   lst = EwinListTransients(ewin, &num, 0);
+   for (i = 0; i < num; i++)
+      FloatEwin(lst[i]);
+   if (lst)
+      Efree(lst);
+
    call_depth--;
    EDBUG_RETURN_;
 }
@@ -1943,8 +1978,10 @@
 void
 FloatEwinAt(EWin * ewin, int x, int y)
 {
-   int                 dx, dy;
    static int          call_depth = 0;
+   int                 dx, dy;
+   EWin              **lst;
+   int                 i, num;
 
    EDBUG(3, "FloatEwinAt");
    call_depth++;
@@ -1959,19 +1996,13 @@
    ewin->x = x;
    ewin->y = y;
    ConformEwinToDesktop(ewin);
-   if (ewin->has_transients)
-     {
-       EWin              **lst;
-       int                 i, num;
 
-       lst = ListTransientsFor(ewin->client.win, &num);
-       if (lst)
-         {
-            for (i = 0; i < num; i++)
-               FloatEwinAt(lst[i], lst[i]->x + dx, lst[i]->y + dy);
-            Efree(lst);
-         }
-     }
+   lst = EwinListTransients(ewin, &num, 0);
+   for (i = 0; i < num; i++)
+      FloatEwinAt(lst[i], lst[i]->x + dx, lst[i]->y + dy);
+   if (lst)
+      Efree(lst);
+
    call_depth--;
    EDBUG_RETURN_;
 }
@@ -2060,18 +2091,15 @@
        if (num == 0)           /* Quit if stacking is unchanged */
           goto done;
 
-       if (ewin->has_transients)
-         {
-            lst = ListTransientsFor(ewin->client.win, &num);
-            for (i = 0; i < num; i++)
-               RaiseEwin(lst[i]);
-            if (lst)
-               Efree(lst);
-         }
+       lst = EwinListTransients(ewin, &num, 1);
+       for (i = 0; i < num; i++)
+          RaiseEwin(lst[i]);
+       if (lst)
+          Efree(lst);
 
        if (call_depth == 1)
          {
-            if (ewin->has_transients)
+            if (num > 0)
                StackDesktop(ewin->desktop);    /* Do the full stacking */
             else
                RestackEwin(ewin);      /* Restack this one only */
@@ -2087,8 +2115,8 @@
 LowerEwin(EWin * ewin)
 {
    static int          call_depth = 0;
-   EWin               *ewin2;
-   int                 num;
+   EWin              **lst;
+   int                 i, num;
 
    EDBUG(3, "LowerEwin");
    if (call_depth > 256)
@@ -2105,18 +2133,15 @@
        if (num == 0)           /* Quit if stacking is unchanged */
           goto done;
 
-       if (ewin->client.transient_for)
-         {
-            ewin2 = FindItem(NULL, ewin->client.transient_for, LIST_FINDBY_ID,
-                             LIST_TYPE_EWIN);
-            if (ewin2 == NULL) /* Should never happen */
-               goto done;
-            LowerEwin(ewin2);
-         }
+       lst = EwinListTransientFor(ewin, &num);
+       for (i = 0; i < num; i++)
+          LowerEwin(lst[i]);
+       if (lst)
+          Efree(lst);
 
        if (call_depth == 1)
          {
-            if (ewin->client.transient_for)
+            if (num > 0)
                StackDesktop(ewin->desktop);    /* Do the full stacking */
             else
                RestackEwin(ewin);      /* Restack this one only */
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/desktops.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -3 -r1.90 -r1.91
--- desktops.c  30 May 2004 13:09:15 -0000      1.90
+++ desktops.c  19 Jun 2004 01:31:20 -0000      1.91
@@ -1204,8 +1204,9 @@
 void
 MoveEwinToDesktopAt(EWin * ewin, int desk, int x, int y)
 {
-   int                 pdesk;
-   int                 dx, dy;
+   EWin              **lst;
+   int                 i, num;
+   int                 pdesk, dx, dy;
 
    EDBUG(3, "MoveEwinToDesktopAt");
 
@@ -1225,22 +1226,11 @@
    ewin->y = y;
    ConformEwinToDesktop(ewin);
 
-   if (ewin->has_transients)
-     {
-       EWin              **lst;
-       int                 i, nn;
-
-       lst = ListTransientsFor(ewin->client.win, &nn);
-       if (lst)
-         {
-            for (i = 0; i < nn; i++)
-              {
-                 MoveEwinToDesktopAt(lst[i], desk, lst[i]->x + dx,
-                                     lst[i]->y + dy);
-              }
-            Efree(lst);
-         }
-     }
+   lst = EwinListTransients(ewin, &num, 0);
+   for (i = 0; i < num; i++)
+      MoveEwinToDesktopAt(lst[i], desk, lst[i]->x + dx, lst[i]->y + dy);
+   if (lst)
+      Efree(lst);
 
    ForceUpdatePagersForDesktop(desk);
 
@@ -1261,6 +1251,8 @@
 void
 FloatEwinAboveDesktops(EWin * ewin)
 {
+   EWin              **lst;
+   int                 i, num;
    int                 xo, yo;
 
    EDBUG(2, "FloatEwinAboveDesktops");
@@ -1269,19 +1261,13 @@
    ewin->desktop = 0;
    ewin->floating = 1;
    ConformEwinToDesktop(ewin);
-   if (ewin->has_transients)
-     {
-       EWin              **lst;
-       int                 i, num;
 
-       lst = ListTransientsFor(ewin->client.win, &num);
-       if (lst)
-         {
-            for (i = 0; i < num; i++)
-               FloatEwinAboveDesktops(lst[i]);
-            Efree(lst);
-         }
-     }
+   lst = EwinListTransients(ewin, &num, 0);
+   for (i = 0; i < num; i++)
+      FloatEwinAboveDesktops(lst[i]);
+   if (lst)
+      Efree(lst);
+
    EDBUG_RETURN_;
 }
 #endif
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/finders.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -3 -r1.30 -r1.31
--- finders.c   29 May 2004 20:42:06 -0000      1.30
+++ finders.c   19 Jun 2004 01:31:21 -0000      1.31
@@ -338,31 +338,105 @@
 }
 
 EWin              **
-ListTransientsFor(Window win, int *num)
+EwinListTransients(EWin * ewin, int *num, int group)
 {
-   EWin               *const *ewins, **lst = NULL;
+   EWin               *const *ewins, **lst, *ew;
    int                 i, j, n;
 
-   EDBUG(6, "ListTransientsFor");
+   EDBUG(6, "EwinListTransients");
 
-   ewins = EwinListGetAll(&n);
    j = 0;
+   lst = NULL;
+
+   if (!ewin->has_transients)
+      goto done;
+
+   ewins = EwinListGetAll(&n);
+
+   /* Find regular transients */
    for (i = 0; i < n; i++)
      {
-       if (win != ewins[i]->client.transient_for)
+       ew = ewins[i];
+
+       /* Skip self-reference */
+       if (ew == ewin)
           continue;
-       /* A self-reference is not a valid transient */
-       if (win == ewins[i]->client.win)
+
+       if (ew->client.transient_for == ewin->client.win)
+         {
+            lst = Erealloc(lst, (j + 1) * sizeof(EWin *));
+            lst[j++] = ew;
+         }
+     }
+
+   if (!group)
+      goto done;
+
+   /* Group transients (if ewin is not a transient) */
+   if (ewin->client.transient)
+      goto done;
+
+   for (i = 0; i < n; i++)
+     {
+       ew = ewins[i];
+
+       /* Skip self-reference */
+       if (ew == ewin)
+          continue;
+
+       if (ew->client.transient_for == VRoot.win &&
+           ew->client.group == ewin->client.group)
+         {
+            lst = Erealloc(lst, (j + 1) * sizeof(EWin *));
+            lst[j++] = ew;
+         }
+     }
+
+ done:
+   *num = j;
+   EDBUG_RETURN(lst);
+}
+
+EWin              **
+EwinListTransientFor(EWin * ewin, int *num)
+{
+   EWin               *const *ewins, **lst, *ew;
+   int                 i, j, n;
+
+   EDBUG(6, "EwinListTransientFor");
+
+   j = 0;
+   lst = NULL;
+
+   if (!ewin->client.transient)
+      goto done;
+
+   ewins = EwinListGetAll(&n);
+   for (i = 0; i < n; i++)
+     {
+       ew = ewins[i];
+
+       /* Skip self-reference */
+       if (ew == ewin)
           continue;
 
-       j++;
-       lst = Erealloc(lst, sizeof(EWin *) * j);
-       lst[j - 1] = ewins[i];
+       /* Regular parent or if root trans, top level group members */
+       if ((ewin->client.transient_for == ew->client.win) ||
+           (!ew->client.transient &&
+            ewin->client.transient_for == VRoot.win &&
+            ew->client.group == ewin->client.group))
+         {
+            lst = Erealloc(lst, (j + 1) * sizeof(EWin *));
+            lst[j++] = ew;
+         }
      }
+
+ done:
    *num = j;
    EDBUG_RETURN(lst);
 }
 
+#if 0                          /* Not used */
 EWin              **
 ListGroupMembers(Window win, int *num)
 {
@@ -385,6 +459,7 @@
    *num = j;
    EDBUG_RETURN(lst);
 }
+#endif
 
 EWin               *
 FindEwinByDialog(Dialog * d)
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/iconify.c,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -3 -r1.113 -r1.114
--- iconify.c   18 Jun 2004 20:12:09 -0000      1.113
+++ iconify.c   19 Jun 2004 01:31:21 -0000      1.114
@@ -203,6 +203,8 @@
 IconboxIconifyEwin(Iconbox * ib, EWin * ewin)
 {
    static int          call_depth = 0;
+   EWin              **lst, *e;
+   int                 i, num;
    char                was_shaded;
 
    EDBUG(6, "IconboxIconifyEwin");
@@ -242,29 +244,24 @@
    ewin->iconified = 3;
    ICCCM_Iconify(ewin);
 
-   if (ewin->has_transients)
+   lst = EwinListTransients(ewin, &num, 0);
+   for (i = 0; i < num; i++)
      {
-       EWin              **lst, *e;
-       int                 i, num;
+       e = lst[i];
+       if (e->iconified)
+          continue;
 
-       lst = ListTransientsFor(ewin->client.win, &num);
-       for (i = 0; i < num; i++)
-         {
-            e = lst[i];
-            if (e->iconified)
-               continue;
-
-            HideEwin(e);
-            e->iconified = 4;
-            e->req_x = e->x;
-            e->req_y = e->y;
-         }
-       if (lst)
-          Efree(lst);
+       HideEwin(e);
+       e->iconified = 4;
+       e->req_x = e->x;
+       e->req_y = e->y;
+     }
+   if (lst)
+      Efree(lst);
 #if ENABLE_GNOME
-       GNOME_SetClientList();
+   if (lst)
+      GNOME_SetClientList();
 #endif
-     }
 
    HintsSetWindowState(ewin);
 
@@ -282,6 +279,8 @@
 DeIconifyEwin(EWin * ewin)
 {
    static int          call_depth = 0;
+   EWin              **lst, *e;
+   int                 i, num;
    Iconbox            *ib;
    int                 x, y, dx, dy;
 
@@ -335,34 +334,28 @@
    ICCCM_DeIconify(ewin);
    FocusToEWin(ewin, FOCUS_SET);
 
-   if (ewin->has_transients)
+   lst = EwinListTransients(ewin, &num, 0);
+   for (i = 0; i < num; i++)
      {
-       EWin              **lst, *e;
-       int                 i, num;
-
-       lst = ListTransientsFor(ewin->client.win, &num);
-       for (i = 0; i < num; i++)
-         {
-            e = lst[i];
-            if (e->iconified != 4)
-               continue;
+       e = lst[i];
+       if (e->iconified != 4)
+          continue;
 
-            if (e->sticky)
-               MoveEwin(e, e->req_x + dx, e->req_y + dy);
-            else
-               MoveEwinToDesktopAt(e, desks.current,
-                                   e->req_x + dx, e->req_y + dy);
+       if (e->sticky)
+          MoveEwin(e, e->req_x + dx, e->req_y + dy);
+       else
+          MoveEwinToDesktopAt(e, desks.current, e->req_x + dx, e->req_y + dy);
 
-            RaiseEwin(e);
-            ShowEwin(e);
-            e->iconified = 0;
-         }
-       if (lst)
-          Efree(lst);
+       RaiseEwin(e);
+       ShowEwin(e);
+       e->iconified = 0;
+     }
+   if (lst)
+      Efree(lst);
 #if ENABLE_GNOME
-       GNOME_SetClientList();
+   if (lst)
+      GNOME_SetClientList();
 #endif
-     }
 
    HintsSetWindowState(ewin);
 




-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to