Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        E.h actions.c areas.c borders.c comms.c desktops.c events.c 
        evhandlers.c focus.c icccm.c iconify.c pager.c warp.c 


Log Message:
Attempt to fix some focus problems.
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/E.h,v
retrieving revision 1.189
retrieving revision 1.190
diff -u -3 -r1.189 -r1.190
--- E.h 28 Jan 2004 20:09:06 -0000      1.189
+++ E.h 1 Feb 2004 11:28:05 -0000       1.190
@@ -1289,9 +1289,7 @@
    char                justclicked;
    char                click_focus_grabbed;
    EWin               *focuswin;
-   EWin               *realfocuswin;
    EWin               *mouse_over_win;
-   EWin               *context_ewin;
    int                 px, py, x, y;
    char                firstlast;
    int                 swapmovemode;
@@ -1308,7 +1306,6 @@
    Menu               *cur_menu[256];
    Window              menu_cover_win;
    Window              menu_win_covered;
-   char                windowdestroy;
    int                 context_w, context_h;
    Pager              *context_pager;
    char                constrained;
@@ -1316,6 +1313,7 @@
    char                keybinds_changed;
    char                firsttime;
    Window              button_proxy_win;
+   const XEvent       *current_event;
 }
 EMode;
 
@@ -1732,12 +1730,13 @@
 void                EventDebugInit(const char *s);
 void                EventShow(const XEvent * ev);
 
+/* borders.c */
 void                DetermineEwinFloat(EWin * ewin, int dx, int dy);
 void                SetEInfoOnAll(void);
 EWin               *GetEwinPointerInClient(void);
+EWin               *GetEwinByCurrentPointer(void);
 EWin               *GetFocusEwin(void);
 EWin               *GetContextEwin(void);
-void                SetContextEwin(EWin * ewin);
 void                SlideEwinTo(EWin * ewin, int fx, int fy, int tx, int ty,
                                int speed);
 void                SlideEwinsTo(EWin ** ewin, int *fx, int *fy, int *tx,
@@ -1860,7 +1859,7 @@
 #define FOCUS_EWIN_GONE  5
 #define FOCUS_DESK_ENTER 6
 #define FOCUS_DESK_LEAVE 7
-#define FOCUS_WARP       8
+#define FOCUS_WARP_DONE  8
 #define FOCUS_CLICK      9
 
 void                FocusGetNextEwin(void);
@@ -1868,8 +1867,6 @@
 void                FocusEwinSetGrabs(EWin * ewin);
 void                FocusFix(void);
 void                FocusToEWin(EWin * ewin, int why);
-void                FocusHandleFocusIn(Window win);
-void                FocusHandleFocusOut(Window win);
 void                FocusHandleEnter(XEvent * ev);
 void                FocusHandleLeave(XEvent * ev);
 void                FocusHandleClick(Window win);
@@ -2001,9 +1998,8 @@
                                int active, int sticky, int state, char expose,
                                TextClass * tclass, char *text);
 
+/* evhandlers.c */
 void                HandleClientMessage(XEvent * ev);
-void                HandleFocusWindowIn(Window win);
-void                HandleFocusWindow(Window win);
 void                HandleFocusIn(XEvent * ev);
 void                HandleFocusOut(XEvent * ev);
 void                HandleChildShapeChange(XEvent * ev);
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/actions.c,v
retrieving revision 1.135
retrieving revision 1.136
diff -u -3 -r1.135 -r1.136
--- actions.c   28 Jan 2004 16:11:03 -0000      1.135
+++ actions.c   1 Feb 2004 11:28:05 -0000       1.136
@@ -421,25 +421,19 @@
    KeyCode             key;
    int                 i, type, button, modifiers, ok, mouse, mask, val = 0;
    Action             *act;
-   char                reset_ewin;
 
    EDBUG(5, "EventAclass");
 
    if (mode.action_inhibit)
       EDBUG_RETURN(0);
 
-   reset_ewin = key = type = button = modifiers = mouse = 0;
-   if (!ewin)
-     {
-       ewin = mode.focuswin;
-       if (!ewin)
-          ewin = mode.mouse_over_win;
-       reset_ewin = 1;
-     }
+   key = type = button = modifiers = mouse = 0;
 
+#if 0                          /* FIXME - Do we use this? */
    if ((conf.movemode == 0) && (ewin) &&
        ((mode.mode == MODE_MOVE) || (mode.mode == MODE_MOVE_PENDING)))
       DetermineEwinFloat(ewin, 0, 0);
+#endif
 
    mask =
       (ShiftMask | ControlMask | Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask |
@@ -2520,7 +2514,10 @@
 doFocusNext(EWin * edummy, void *params)
 {
    EDBUG(6, "doFocusNext");
-   FocusGetNextEwin();
+   if (conf.warplist.enable && mode.current_event->type == KeyPress)
+      WarpFocus(1);
+   else
+      FocusGetNextEwin();
    EDBUG_RETURN(0);
 }
 
@@ -2546,10 +2543,6 @@
       DeIconifyEwin(ewin);
    if (ewin->shaded)
       UnShadeEwin(ewin);
-   if (conf.focus.raise_on_next_focus || conf.focus.raise_after_next_focus)
-      RaiseEwin(ewin);
-   if (conf.focus.warp_on_next_focus)
-      XWarpPointer(disp, None, ewin->win, 0, 0, 0, 0, ewin->w / 2, ewin->h / 2);
    FocusToEWin(ewin, FOCUS_SET);
 
    EDBUG_RETURN(0);
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/areas.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -3 -r1.58 -r1.59
--- areas.c     21 Jan 2004 23:32:44 -0000      1.58
+++ areas.c     1 Feb 2004 11:28:05 -0000       1.59
@@ -272,9 +272,6 @@
 
    /* remove lots of event masks from windows.. we dont want to bother */
    /* handling events as a result of our playing wiht windows */
-#if 0                          /* Clean up if not causing trouble */
-   FocusToEWin(NULL);
-#endif
    FocusNewDeskBegin();
 
    /* move all the windows around */
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/borders.c,v
retrieving revision 1.128
retrieving revision 1.129
diff -u -3 -r1.128 -r1.129
--- borders.c   28 Jan 2004 20:09:06 -0000      1.128
+++ borders.c   1 Feb 2004 11:28:05 -0000       1.129
@@ -141,6 +141,21 @@
 }
 
 EWin               *
+GetEwinByCurrentPointer(void)
+{
+   Window              rt, ch;
+   int                 dum, x, y;
+   unsigned int        mr;
+
+   EDBUG(5, "GetEwinByCurrentPointer");
+
+   XQueryPointer(disp, desks.desk[desks.current].win, &rt, &ch, &x, &y, &dum,
+                &dum, &mr);
+
+   EDBUG_RETURN(FindEwinByBase(ch));
+}
+
+EWin               *
 GetEwinPointerInClient(void)
 {
    Window              rt, ch;
@@ -172,34 +187,21 @@
 GetFocusEwin(void)
 {
    EDBUG(4, "GetFocusEwin");
-
-   if (mode.cur_menu_mode)
-     {
-       if (mode.context_ewin)
-          EDBUG_RETURN(mode.context_ewin);
-       EDBUG_RETURN(mode.realfocuswin);
-     }
-
-   if (mode.focuswin)
-      EDBUG_RETURN(mode.focuswin);
-
-   EDBUG_RETURN(NULL);
+   EDBUG_RETURN(mode.focuswin);
 }
 
 EWin               *
 GetContextEwin(void)
 {
    EDBUG(4, "GetContextEwin");
-   EDBUG_RETURN(GetFocusEwin());
-}
 
-void
-SetContextEwin(EWin * ewin)
-{
-   EDBUG(4, "SetContextEwin");
-   if (!ewin || (!ewin->menu && !mode.cur_menu_mode))
-      mode.context_ewin = ewin;
-   EDBUG_RETURN_;
+   if (mode.focuswin)
+      EDBUG_RETURN(mode.focuswin);
+
+   if (mode.mouse_over_win);
+   EDBUG_RETURN(mode.mouse_over_win);
+
+   return NULL;
 }
 
 void
@@ -703,47 +705,14 @@
        ShowEwin(ewin);
        StackDesktops();
      }
+
    /* send synthetic configure notifies and configure the window */
    ICCCM_Configure(ewin);
 
    DetermineEwinArea(ewin);
-   if (conf.focus.all_new_windows_get_focus)
-     {
-       FocusToEWin(ewin, FOCUS_EWIN_NEW);
-       if ((ewin->desktop != desks.current) && (!ewin->iconified))
-         {
-            GotoDesktop(ewin->desktop);
-            SetCurrentArea(ewin->area_x, ewin->area_y);
-         }
-     }
-   else if (conf.focus.new_transients_get_focus)
-     {
-       if (ewin->client.transient)
-         {
-            FocusToEWin(ewin, FOCUS_EWIN_NEW);
-            if ((ewin->desktop != desks.current) && (!ewin->iconified))
-              {
-                 GotoDesktop(ewin->desktop);
-                 SetCurrentArea(ewin->area_x, ewin->area_y);
-              }
-         }
-     }
-   else if (conf.focus.new_transients_get_focus_if_group_focused)
-     {
-       ewin2 =
-          FindItem(NULL, ewin->client.transient_for, LIST_FINDBY_ID,
-                   LIST_TYPE_EWIN);
-       if ((ewin2) && (mode.focuswin == ewin2))
-         {
-            FocusToEWin(ewin, FOCUS_EWIN_NEW);
-            if ((ewin->desktop != desks.current) && (!ewin->iconified))
-              {
-                 GotoDesktop(ewin->desktop);
-                 SetCurrentArea(ewin->area_x, ewin->area_y);
-              }
-         }
-     }
+   FocusToEWin(ewin, FOCUS_EWIN_NEW);
    UngrabX();
+
    EDBUG_RETURN_;
 }
 
@@ -1381,16 +1350,13 @@
    XChangeWindowAttributes(disp, ewin->win_container,
                           CWEventMask | CWDontPropagate, &att);
    EMapWindow(disp, ewin->win_container);
-   if ((conf.focus.clickraises) || (conf.focus.mode == MODE_FOCUS_CLICK))
-      XGrabButton(disp, AnyButton, 0, ewin->win_container, False,
-                 ButtonPressMask, GrabModeSync, GrabModeAsync, None, None);
    att.event_mask =
       StructureNotifyMask | PointerMotionMask | ButtonPressMask |
       ButtonReleaseMask | EnterWindowMask | LeaveWindowMask;
    att.do_not_propagate_mask = ButtonPressMask | ButtonReleaseMask;
    XChangeWindowAttributes(disp, ewin->win, CWEventMask | CWDontPropagate,
                           &att);
-   GrabButtonGrabs(ewin);
+   FocusEwinSetGrabs(ewin);
    EDBUG_RETURN(ewin);
 }
 
@@ -1430,20 +1396,12 @@
        mode.doingslide = 0;
      }
 
-   mode.windowdestroy = 1;
    /* hide any menus this ewin has brought up if they are still up when we */
    /* destroy this ewin */
    if (ewin->shownmenu)
       MenusHideByWindow(ewin->shownmenu);
 
-   if (ewin == mode.focuswin)
-     {
-#if 0                          /* Clean up if OK -- Remove FocusToNone */
-       FocusToNone();
-#else
-       FocusToEWin(NULL, FOCUS_EWIN_GONE);
-#endif
-     }
+   FocusToEWin(ewin, FOCUS_EWIN_GONE);
 
    if (ewin->docked)
       DockDestroy(ewin);
@@ -1453,10 +1411,7 @@
       IconboxDestroy(ewin->ibox);
 
    /* May be an overkill but cannot hurt... */
-   DELETE_EWIN_REFERENCE(ewin, mode.focuswin);
-   DELETE_EWIN_REFERENCE(ewin, mode.realfocuswin);
    DELETE_EWIN_REFERENCE(ewin, mode.mouse_over_win);
-   DELETE_EWIN_REFERENCE(ewin, mode.context_ewin);
 
    HintsDelWindowHints(ewin);
 
@@ -3103,7 +3058,6 @@
 static void
 BorderWinpartEventEnter(XEvent * ev, EWin * ewin, int j)
 {
-   SetContextEwin(ewin);
    if (ewin->bits[j].state == STATE_CLICKED)
       ewin->bits[j].left = 0;
    else
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/comms.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -3 -r1.44 -r1.45
--- comms.c     21 Jan 2004 23:32:44 -0000      1.44
+++ comms.c     1 Feb 2004 11:28:05 -0000       1.45
@@ -1799,8 +1799,6 @@
 
        char                buf[FILEPATH_LEN_MAX];
        char                buf3[FILEPATH_LEN_MAX];
-       char                buf4[FILEPATH_LEN_MAX];
-       char                buf5[FILEPATH_LEN_MAX];
 
        Esnprintf(buf, sizeof(buf), "stuff:\n");
        if (mode.focuswin)
@@ -1809,22 +1807,10 @@
                       (unsigned)mode.focuswin->client.win);
             strcat(buf, buf3);
          }
-       if (mode.realfocuswin)
-         {
-            Esnprintf(buf4, sizeof(buf4), "mode.realfocuswin - %8x\n",
-                      (unsigned)mode.realfocuswin->client.win);
-            strcat(buf, buf4);
-         }
        if (mode.cur_menu_mode)
          {
             strcat(buf, "cur_menu_mode is set\n");
          }
-       if (mode.context_ewin)
-         {
-            Esnprintf(buf5, sizeof(buf5), "context_ewin - %8x\n",
-                      (unsigned)mode.context_ewin->client.win);
-            strcat(buf, buf5);
-         }
        CommsSend(c, buf);
      }
    else if (!strcmp(w, "list_clients"))
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/desktops.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -3 -r1.57 -r1.58
--- desktops.c  21 Jan 2004 23:32:44 -0000      1.57
+++ desktops.c  1 Feb 2004 11:28:05 -0000       1.58
@@ -1253,7 +1253,6 @@
 
    ActionsSuspend();
 
-   FocusToEWin(NULL, FOCUS_DESK_LEAVE);
    FocusNewDeskBegin();
 
    if (mode.mode == MODE_NONE)
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/events.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -3 -r1.48 -r1.49
--- events.c    28 Jan 2004 20:09:07 -0000      1.48
+++ events.c    1 Feb 2004 11:28:05 -0000       1.49
@@ -499,6 +499,7 @@
    if (EventDebug(ev->type))
       EventShow(ev);
 #endif
+   mode.current_event = ev;
 
    if (ev->type == event_base_shape + ShapeNotify)
       HandleChildShapeChange(ev);
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/evhandlers.c,v
retrieving revision 1.144
retrieving revision 1.145
diff -u -3 -r1.144 -r1.145
--- evhandlers.c        28 Jan 2004 20:09:07 -0000      1.144
+++ evhandlers.c        1 Feb 2004 11:28:05 -0000       1.145
@@ -116,26 +116,41 @@
 void
 HandleFocusIn(XEvent * ev)
 {
-   if (ev->xfocus.detail != NotifyPointer)
-      HandleFocusWindowIn(ev->xfocus.window);
+   Window              win = ev->xfocus.window;
+   EWin               *ewin;
+
+   EDBUG(5, "HandleFocusIn");
+
+   ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN);
+   if (ewin && !ewin->active)
+     {
+       ewin->active = 1;
+       DrawEwin(ewin);
+
+       FocusEwinSetGrabs(ewin);
+     }
+
+   EDBUG_RETURN_;
 }
 
 void
 HandleFocusOut(XEvent * ev)
 {
-   if (ev->xfocus.detail == NotifyNonlinear)
+   Window              win = ev->xfocus.window;
+   EWin               *ewin;
+
+   EDBUG(5, "HandleFocusOut");
+
+   ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN);
+   if (ewin && ewin->active)
      {
-       Window              rt, ch;
-       int                 d;
-       unsigned int        ud;
+       ewin->active = 0;
+       DrawEwin(ewin);
 
-       XQueryPointer(disp, root.win, &rt, &ch, &d, &d, &d, &d, &ud);
-       if (rt != root.win)
-         {
-/*           fprintf(stderr, "HandleFocusWindowIn\n"); */
-            HandleFocusWindowIn(0);
-         }
+       FocusEwinSetGrabs(ewin);
      }
+
+   EDBUG_RETURN_;
 }
 
 void
@@ -618,7 +633,7 @@
           SlideoutsHide();
 
        if (ewin == mode.focuswin)
-          FocusToEWin(NULL, FOCUS_SET);
+          FocusToEWin(NULL, FOCUS_EWIN_GONE);
        if (ewin == mode.mouse_over_win)
           mode.mouse_over_win = NULL;
 
@@ -765,8 +780,6 @@
    mode.x = ev->xbutton.x_root;
    mode.y = ev->xbutton.y_root;
 
-   mode.context_win = win;
-
    desk_click = -1;
    for (i = 0; i < conf.desks.numdesktops; i++)
      {
@@ -794,24 +807,7 @@
    if (MenusEventMouseDown(ev))
       goto exit;
 
-   if ((conf.focus.clickraises) || (conf.focus.mode == MODE_FOCUS_CLICK))
-     {
-       ewin = FindEwinByChildren(win);
-       if (!ewin)
-          ewin = FindEwinByBase(win);
-       if (ewin)
-          FocusToEWin(ewin, FOCUS_CLICK);
-       if (ewin)
-          RaiseEwin(ewin);
-       /* allow click to pass thorugh */
-       if ((ewin) && (ewin->win_container == win))
-         {
-            XSync(disp, False);
-            XAllowEvents(disp, ReplayPointer, CurrentTime);
-            XSync(disp, False);
-         }
-       /* done */
-     }
+   FocusHandleClick(win);
 
    if (double_click)
       ev->xbutton.time = 0;
@@ -1011,8 +1007,6 @@
    if (MenusEventMouseOut(ev))
       goto exit;
 
-   ICCCM_Cmap(NULL);
-
    if ( /*!clickmenu && */ BordersEventMouseOut(ev))
       goto exit;
 
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/focus.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -3 -r1.42 -r1.43
--- focus.c     28 Jan 2004 20:09:07 -0000      1.42
+++ focus.c     1 Feb 2004 11:28:05 -0000       1.43
@@ -56,12 +56,6 @@
 
    EDBUG(5, "FocusCycle");
 
-   if (conf.warplist.enable)
-     {
-       WarpFocus(inc);
-       EDBUG_RETURN_;
-     }
-
    /* On previous only ? */
    RemoveTimerEvent("REVERSE_FOCUS_TIMEOUT");
    DoIn("REVERSE_FOCUS_TIMEOUT", 1.0, ReverseTimeout, 0, NULL);
@@ -77,7 +71,7 @@
    for (i = 0; i < num0; i++)
      {
        ewin = lst0[i];
-       DetermineEwinArea(ewin);        // ???
+       DetermineEwinArea(ewin);
        if (((ewin->sticky) || (ewin->desktop == desks.current)) &&
            ((ewin->area_x == ax) && (ewin->area_y == ay)) &&
            (!ewin->skipfocus) && (!ewin->neverfocus) &&
@@ -122,170 +116,167 @@
 }
 
 void
+FocusEwinSetGrabs(EWin * ewin)
+{
+   if (conf.focus.clickraises || conf.focus.mode == MODE_FOCUS_CLICK)
+     {
+       XGrabButton(disp, AnyButton, AnyModifier, ewin->win_container,
+                   False, ButtonPressMask, GrabModeSync, GrabModeAsync,
+                   None, None);
+     }
+   else
+     {
+       XUngrabButton(disp, AnyButton, AnyModifier, ewin->win_container);
+     }
+   GrabButtonGrabs(ewin);
+}
+
+void
 FocusFix(void)
 {
    EWin              **lst, *ewin;
    int                 i, num;
 
    EDBUG(5, "FocusFix");
+
    num = 0;
    lst = (EWin **) ListItemType(&num, LIST_TYPE_EWIN);
-   if (lst)
+   if (lst == NULL)
+      EDBUG_RETURN_;
+
+   for (i = 0; i < num; i++)
      {
-       for (i = 0; i < num; i++)
-         {
-            ewin = lst[i];
-            if (conf.focus.mode == MODE_FOCUS_CLICK)
-              {
-                 if (!(ewin->active))
-                    XGrabButton(disp, AnyButton, AnyModifier,
-                                ewin->win_container, False, ButtonPressMask,
-                                GrabModeSync, GrabModeAsync, None, None);
-              }
-            else
-              {
-                 XUngrabButton(disp, AnyButton, AnyModifier,
-                               ewin->win_container);
-                 GrabButtonGrabs(ewin);
-              }
-         }
-       Efree(lst);
+       ewin = lst[i];
+       FocusEwinSetGrabs(ewin);
      }
+   Efree(lst);
+
+   EDBUG_RETURN_;
 }
 
 void
 FocusToEWin(EWin * ewin, int why)
 {
    int                 ax, ay;
+   int                 do_set = 0;
 
    EDBUG(4, "FocusToEWin");
+#if 0
+   if (ewin)
+      printf("FocusToEWin %#lx %s why=%d\n", ewin->client.win,
+            ewin->client.name, why);
+   else
+      printf("FocusToEWin None why=%d\n", why);
+#endif
 
-   if (mode.slideout)
-      EDBUG_RETURN_;
+   switch (why)
+     {
+     default:
+       if (ewin == mode.focuswin)
+          EDBUG_RETURN_;
+       break;
 
-   if (clickmenu)
-      EDBUG_RETURN_;
+     case FOCUS_EWIN_GONE:
+       if (ewin != mode.focuswin)
+          EDBUG_RETURN_;
+       ewin = NULL;
+       goto exit;
 
-   ICCCM_Cmap(ewin);
-   if ((!ewin) && (conf.focus.mode != MODE_FOCUS_POINTER))
-     {
-       ewin = FindItem("", 0, LIST_FINDBY_NONE, LIST_TYPE_EWIN);
-       if (conf.focus.mode == MODE_FOCUS_CLICK)
+     case FOCUS_EWIN_NEW:
+
+       if (conf.focus.all_new_windows_get_focus)
          {
-            if ((mode.focuswin) && (ewin))
-              {
-                 if (!
-                     (((ewin->desktop
-                        == mode.focuswin->desktop) || (ewin->sticky))
-                      && (ewin->area_x == mode.focuswin->area_x)
-                      && (ewin->area_y == mode.focuswin->area_y)))
-                    ewin = NULL;
-              }
-            else if (!mode.focuswin)
-               ewin = NULL;
+            do_set = 2;
          }
-     }
-   if (ewin == mode.focuswin)
-     {
-       if (!mode.cur_menu_mode)
-          mode.context_ewin = ewin;
-       EDBUG_RETURN_;
-     }
-   /* Never focus a window that's not on the current desktop.  That's just dumb. -- 
mej */
-   if ((ewin) && (ewin->desktop != desks.current && !(ewin->sticky)))
-      ewin = NULL;
-   if ((ewin) && (ewin->neverfocus))
-     {
-       EDBUG_RETURN_;
-     }
-   if ((ewin) && (!ewin->client.need_input))
-     {
-       if (mode.windowdestroy == 1)
+       else if (conf.focus.new_transients_get_focus)
          {
-            mode.focuswin = NULL;
-            mode.realfocuswin = NULL;
-            mode.windowdestroy = 0;
+            if (ewin->client.transient)
+               do_set = 2;
          }
-       if (!mode.cur_menu_mode)
-          mode.context_ewin = ewin;
-       EDBUG_RETURN_;
-     }
-   mode.windowdestroy = 0;
-   if (mode.focuswin)
-     {
-       if (conf.autoraise)
-          RemoveTimerEvent("AUTORAISE_TIMEOUT");
-       mode.focuswin->active = 0;
-       /* losing the focus may cause the titlebar to be resized */
-       CalcEwinSizes(mode.focuswin);
-       DrawEwin(mode.focuswin);
-       if ((conf.focus.clickraises) || (conf.focus.mode == MODE_FOCUS_CLICK))
-          XGrabButton(disp, AnyButton, AnyModifier,
-                      mode.focuswin->win_container, False, ButtonPressMask,
-                      GrabModeSync, GrabModeAsync, None, None);
+       else if (conf.focus.new_transients_get_focus_if_group_focused)
+         {
+            EWin               *ewin2;
+
+            ewin2 = FindItem(NULL, ewin->client.transient_for,
+                             LIST_FINDBY_ID, LIST_TYPE_EWIN);
+            if ((ewin2) && (mode.focuswin == ewin2))
+               do_set = 2;
+         }
+       else if (mode.place)
+         {
+            do_set = 1;
+         }
+
+       if (!do_set)
+          EDBUG_RETURN_;
+       break;
+
+     case FOCUS_WARP_DONE:
+       break;
      }
+
    if (!ewin)
+      goto exit;
+
+   /* NB! ewin != NULL */
+
+   if (ewin->iconified || ewin->neverfocus)
+      EDBUG_RETURN_;
+
+   if (!ewin->client.need_input)
+      EDBUG_RETURN_;
+
+   /* Don't focus menus (use client.need_input?) */
+   if (ewin->menu)
+      EDBUG_RETURN_;
+
+   if (conf.autoraise)
      {
-       mode.focuswin = NULL;
-       mode.realfocuswin = NULL;
-       mode.context_ewin = NULL;
-       ICCCM_Focus(NULL);
-       EDBUG_RETURN_;
+       RemoveTimerEvent("AUTORAISE_TIMEOUT");
+
+       if (conf.focus.mode != MODE_FOCUS_CLICK)
+          DoIn("AUTORAISE_TIMEOUT", conf.autoraisetime, AutoraiseTimeout,
+               ewin->client.win, NULL);
      }
-   else if (!ewin->menu)
-      mode.realfocuswin = ewin;
-   if (ewin)
+
+   if (EwinGetDesk(ewin) != desks.current)
      {
-       if (!mode.cur_menu_mode)
-          mode.context_ewin = ewin;
-       mode.focuswin = ewin;
-       mode.focuswin->active = 1;
-     }
-   /* gaining the focus may cause the titlebar to be resized */
-   if ((conf.focus.mode == MODE_FOCUS_CLICK) && (mode.focuswin))
-     {
-       XUngrabButton(disp, AnyButton, AnyModifier,
-                     mode.focuswin->win_container);
-       GrabButtonGrabs(mode.focuswin);
-     }
-   if (mode.focuswin)
-     {
-       CalcEwinSizes(mode.focuswin);
-       DrawEwin(mode.focuswin);
-       SoundPlay("SOUND_FOCUS_SET");
-       ICCCM_Focus(mode.focuswin);
-     }
-/*   ReZoom(mode.focuswin); */
-   if ((conf.autoraise) && (mode.focuswin) && (!mode.focuswin->menu)
-       && (conf.focus.mode != MODE_FOCUS_CLICK))
-      DoIn("AUTORAISE_TIMEOUT", conf.autoraisetime, AutoraiseTimeout,
-          mode.focuswin->client.win, NULL);
-   if (conf.focus.mode == MODE_FOCUS_CLICK)
+       GotoDesktop(ewin->desktop);
+     }
+
+   if ((!ewin->fixedpos) && (!ewin->sticky))
      {
-       if (ewin)
+       GetCurrentArea(&ax, &ay);
+       if ((ax != ewin->area_x) || (ay != ewin->area_y))
          {
-            if (!ewin->sticky)
-              {
-                 if ((ewin->desktop != desks.current) && (!ewin->iconified))
-                    GotoDesktop(ewin->desktop);
-              }
-            if ((!ewin->fixedpos) && (!ewin->sticky))
-              {
-                 GetCurrentArea(&ax, &ay);
-                 if ((ax != ewin->area_x) || (ay != ewin->area_y))
-                   {
-                      if ((ewin->x >= root.w) || (ewin->y >= root.h)
-                          || ((ewin->x + ewin->w) < 0)
-                          || ((ewin->y + ewin->h) < 0))
-                         SetCurrentArea(ewin->area_x, ewin->area_y);
-                   }
-              }
+            if ((ewin->x >= root.w) || (ewin->y >= root.h)
+                || ((ewin->x + ewin->w) < 0) || ((ewin->y + ewin->h) < 0))
+               SetCurrentArea(ewin->area_x, ewin->area_y);
          }
      }
+
+   if (conf.focus.raise_on_next_focus ||
+       (conf.focus.raise_after_next_focus && (why == FOCUS_WARP_DONE)))
+      RaiseEwin(ewin);
+
+   if ((conf.focus.warp_on_next_focus && why != FOCUS_ENTER &&
+       why != FOCUS_CLICK && why != FOCUS_DESK_ENTER) ||
+       (conf.focus.warp_after_next_focus && (why == FOCUS_WARP_DONE)))
+     {
+       if (ewin != mode.mouse_over_win)
+          XWarpPointer(disp, None, ewin->win, 0, 0, 0, 0, ewin->w / 2,
+                       ewin->h / 2);
+     }
+
    RemoveTimerEvent("REVERSE_FOCUS_TIMEOUT");
-   if (mode.focuswin)
-      DoIn("REVERSE_FOCUS_TIMEOUT", 0.5, ReverseTimeout,
-          mode.focuswin->client.win, NULL);
+   DoIn("REVERSE_FOCUS_TIMEOUT", 0.5, ReverseTimeout, ewin->client.win, NULL);
+
+   SoundPlay("SOUND_FOCUS_SET");
+ exit:
+   ICCCM_Cmap(ewin);
+   ICCCM_Focus(ewin);
+   mode.focuswin = ewin;
+
    EDBUG_RETURN_;
 }
 
@@ -298,6 +289,8 @@
    if (new_desk_focus_nesting++)
       return;
 
+   FocusToEWin(NULL, FOCUS_DESK_LEAVE);
+
    /* we are about to flip desktops or areas - disable enter and leave events
     * temporarily */
 
@@ -425,7 +418,7 @@
        (conf.focus.mode == MODE_FOCUS_SLOPPY))
      {
        ewin = GetEwinPointerInClient();
-       ICCCM_Focus(ewin);
+       FocusToEWin(ewin, FOCUS_DESK_ENTER);
      }
    else
      {
@@ -442,7 +435,7 @@
                      ((((ewin->area_x == ax) && (ewin->area_y == ay)) ||
                        (ewin->fixedpos)) && (ewin->desktop == desks.current)))
                    {
-                      ICCCM_Focus(ewin);
+                      FocusToEWin(ewin, FOCUS_DESK_ENTER);
                       break;
                    }
               }
@@ -453,117 +446,50 @@
    EDBUG_RETURN_;
 }
 
-#if 0                          /* Clean up if OK -- Remove FocusToNone */
+/*
+ * Focus event handlers
+ */
+
 void
-FocusToNone(void)
+FocusHandleEnter(XEvent * ev)
 {
+#if 0
+   Window              win = ev->xcrossing.window;
+#endif
+   EWin               *ewin;
 
-   EDBUG(4, "FocusToNone");
+   EDBUG(5, "FocusHandleEnter");
 
-   if ((mode.focuswin) && (mode.focuswin->floating))
-      EDBUG_RETURN_;
-   ICCCM_Cmap(NULL);
-   if (mode.focuswin)
-     {
-       if (conf.autoraise)
-          RemoveTimerEvent("AUTORAISE_TIMEOUT");
-       mode.focuswin->active = 0;
-       /* losing the focus may cause the titlebar to be resized */
-       CalcEwinSizes(mode.focuswin);
-       DrawEwin(mode.focuswin);
-       if (conf.focus.mode == MODE_FOCUS_CLICK)
-          XGrabButton(disp, AnyButton, AnyModifier,
-                      mode.focuswin->win_container, False, ButtonPressMask,
-                      GrabModeSync, GrabModeAsync, None, None);
-     }
-   XSetInputFocus(disp, root.win, RevertToPointerRoot, CurrentTime);
-   mode.focuswin = NULL;
-   mode.realfocuswin = NULL;
-   EDBUG_RETURN_;
-}
-#endif
+   ewin = GetEwinByCurrentPointer();
 
-void
-HandleFocusWindowIn(Window win)
-{
-   EWin               *ewin;
+   mode.mouse_over_win = ewin;
 
-   EDBUG(5, "HandleFocusWindowIn");
-   ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN);
-   if (!ewin)
-      ewin = FindEwinByBase(win);
-   if (ewin != mode.focuswin)
+   switch (conf.focus.mode)
      {
-       if (mode.focuswin)
-         {
-            mode.focuswin->active = 0;
-            DrawEwin(mode.focuswin);
-            if (conf.focus.mode == MODE_FOCUS_CLICK)
-               XGrabButton(disp, AnyButton, AnyModifier,
-                           mode.focuswin->win_container, False,
-                           ButtonPressMask, GrabModeSync, GrabModeAsync, None,
-                           None);
-         }
-       mode.focuswin = ewin;
-       if ((ewin) && (!ewin->menu))
-         {
-            mode.realfocuswin = ewin;
-            if (!mode.cur_menu_mode)
-               mode.context_ewin = ewin;
-         }
-       if (mode.focuswin)
-         {
-            mode.focuswin->active = 1;
-            DrawEwin(mode.focuswin);
-            if (conf.focus.mode == MODE_FOCUS_CLICK)
-              {
-                 XUngrabButton(disp, AnyButton, AnyModifier,
-                               mode.focuswin->win_container);
-                 GrabButtonGrabs(mode.focuswin);
-              }
-         }
+     default:
+     case MODE_FOCUS_CLICK:
+       break;
+     case MODE_FOCUS_SLOPPY:
+       if (!ewin || ewin->focusclick)
+          break;
+       FocusToEWin(ewin, FOCUS_ENTER);
+       break;
+     case MODE_FOCUS_POINTER:
+       if (ewin && ewin->focusclick)
+          break;
+       FocusToEWin(ewin, FOCUS_ENTER);
+       break;
      }
+
    EDBUG_RETURN_;
 }
 
 void
-HandleFocusWindow(Window win)
+FocusHandleLeave(XEvent * ev)
 {
-   EWin               *found_ewin;
-
-   EDBUG(5, "HandleFocusWindow");
-   if (win == 0)
-      FocusToEWin(NULL, FOCUS_SET);
-   else
-     {
-       found_ewin = FindEwinByChildren(win);
-       if (!found_ewin)
-          found_ewin = FindEwinByBase(win);
-       if (conf.focus.mode == MODE_FOCUS_CLICK)
-          mode.mouse_over_win = found_ewin;
-       else if (conf.focus.mode == MODE_FOCUS_SLOPPY)
-         {
-            if (!found_ewin)
-               ICCCM_Cmap(NULL);
-            else if (!(found_ewin->focusclick))
-               FocusToEWin(found_ewin, FOCUS_SET);
-            mode.mouse_over_win = found_ewin;
-         }
-       else if (conf.focus.mode == MODE_FOCUS_POINTER)
-         {
-            if (!found_ewin)
-               found_ewin = GetEwinPointerInClient();
-            FocusToEWin(found_ewin, FOCUS_SET);
-            mode.mouse_over_win = found_ewin;
-         }
-     }
-   EDBUG_RETURN_;
 }
 
-/*
- * Focus event handlers
- */
-
+#if 0
 void
 FocusHandleEnter(XEvent * ev)
 {
@@ -602,3 +528,32 @@
 /*      else */
 /*      HandleFocusWindow(ev->xcrossing.window); */
 }
+#endif
+
+void
+FocusHandleClick(Window win)
+{
+   EWin               *ewin;
+
+   ewin = GetEwinByCurrentPointer();
+   if (!ewin)
+      return;
+
+   if ((conf.focus.clickraises) || (conf.focus.mode == MODE_FOCUS_CLICK))
+     {
+       RaiseEwin(ewin);
+       FocusToEWin(ewin, FOCUS_CLICK);
+
+       /* allow click to pass thorugh */
+       if (win == ewin->win_container)
+         {
+            XSync(disp, False);
+            XAllowEvents(disp, ReplayPointer, CurrentTime);
+            XSync(disp, False);
+         }
+     }
+   else if (ewin->focusclick)
+     {
+       FocusToEWin(ewin, FOCUS_CLICK);
+     }
+}
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/icccm.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -3 -r1.48 -r1.49
--- icccm.c     19 Jan 2004 22:30:30 -0000      1.48
+++ icccm.c     1 Feb 2004 11:28:05 -0000       1.49
@@ -529,16 +529,6 @@
        EDBUG_RETURN_;
      }
 
-   if (ewin->menu)
-      EDBUG_RETURN_;
-
-   if (!ewin->client.need_input)
-     {
-       if (!mode.cur_menu_mode)
-          mode.context_ewin = ewin;
-       EDBUG_RETURN_;
-     }
-
    foc = 0;
    if (XGetWMProtocols(disp, ewin->client.win, &prop, &num))
      {
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/iconify.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -3 -r1.84 -r1.85
--- iconify.c   21 Jan 2004 23:32:44 -0000      1.84
+++ iconify.c   1 Feb 2004 11:28:05 -0000       1.85
@@ -208,12 +208,11 @@
       Zoom(NULL);
    if (ewin->ibox)
       EDBUG_RETURN_;
-   call_depth++;
+
    if (call_depth > 256)
-     {
-       call_depth--;
-       return;
-     }
+      EDBUG_RETURN_;
+   call_depth++;
+
    if (!ewin->iconified)
      {
        was_shaded = ewin->shaded;
@@ -226,19 +225,14 @@
             UpdateAppIcon(ewin, ib->icon_mode);
             IconboxAddEwin(ib, ewin);
          }
+
        HideEwin(ewin);
+
        if (was_shaded != ewin->shaded)
           InstantShadeEwin(ewin, 0);
+
        ICCCM_Iconify(ewin);
-       if (ewin == mode.focuswin)
-         {
-            char                prev_warp;
 
-            prev_warp = conf.warplist.enable;
-            conf.warplist.enable = 0;
-            FocusGetPrevEwin();
-            conf.warplist.enable = prev_warp;
-         }
        if (ewin->has_transients)
          {
             EWin              **lst;
@@ -253,14 +247,17 @@
                         {
                            HideEwin(lst[i]);
                            lst[i]->iconified = 4;
-                           if (lst[i] == mode.focuswin)
-                              FocusToEWin(NULL, FOCUS_EWIN_GONE);
                         }
                    }
+#if ENABLE_GNOME
                  HintsSetClientList();
+#endif
                  Efree(lst);
               }
          }
+
+       if (ewin == GetFocusEwin())
+          FocusGetPrevEwin();
      }
    call_depth--;
 
@@ -321,7 +318,7 @@
        RaiseEwin(ewin);
        ShowEwin(ewin);
        ICCCM_DeIconify(ewin);
-       FocusToEWin(ewin, FOCUS_EWIN_NEW);
+       FocusToEWin(ewin, FOCUS_SET);
        if (ewin->has_transients)
          {
             EWin              **lst, *e;
@@ -346,7 +343,9 @@
                       ShowEwin(e);
                       e->iconified = 0;
                    }
+#if ENABLE_GNOME
                  HintsSetClientList();
+#endif
                  Efree(lst);
               }
          }
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/pager.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -3 -r1.60 -r1.61
--- pager.c     21 Jan 2004 23:32:44 -0000      1.60
+++ pager.c     1 Feb 2004 11:28:05 -0000       1.61
@@ -874,6 +874,7 @@
    static Menu        *p_menu = NULL, *pw_menu = NULL;
    MenuItem           *mi;
    EWin               *ewin;
+   char                s[1024];
    int                 ax, ay;
 
    if (!conf.pagers.enable)
@@ -885,24 +886,21 @@
        if (pw_menu)
           MenuDestroy(pw_menu);
 
-       SetContextEwin(ewin);
-
        pw_menu = MenuCreate("__DESK_WIN_MENU");
        MenuAddTitle(pw_menu, _("Window Options"));
        MenuAddStyle(pw_menu, "DEFAULT");
 
-       mi = MenuItemCreate(_("Iconify"), NULL, ACTION_ICONIFY, NULL, NULL);
+       Esnprintf(s, sizeof(s), "%i", (unsigned)ewin->client.win);
+       mi = MenuItemCreate(_("Iconify"), NULL, ACTION_ICONIFY, s, NULL);
        MenuAddItem(pw_menu, mi);
 
-       mi = MenuItemCreate(_("Close"), NULL, ACTION_KILL, NULL, NULL);
+       mi = MenuItemCreate(_("Close"), NULL, ACTION_KILL, s, NULL);
        MenuAddItem(pw_menu, mi);
 
-       mi =
-          MenuItemCreate(_("Annihilate"), NULL, ACTION_KILL_NASTY, NULL, NULL);
+       mi = MenuItemCreate(_("Annihilate"), NULL, ACTION_KILL_NASTY, s, NULL);
        MenuAddItem(pw_menu, mi);
 
-       mi =
-          MenuItemCreate(_("Stick / Unstick"), NULL, ACTION_STICK, NULL, NULL);
+       mi = MenuItemCreate(_("Stick / Unstick"), NULL, ACTION_STICK, s, NULL);
        MenuAddItem(pw_menu, mi);
 
        ActionsCall(ACTION_SHOW_MENU, NULL, "named __DESK_WIN_MENU");
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/warp.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -3 -r1.31 -r1.32
--- warp.c      21 Jan 2004 23:32:45 -0000      1.31
+++ warp.c      1 Feb 2004 11:28:06 -0000       1.32
@@ -116,7 +116,7 @@
                     AddItem(ewin, "", 0, LIST_TYPE_WARP_RING);
               }
          }
-       MoveItemToListBottom(mode.focuswin, LIST_TYPE_WARP_RING);
+       MoveItemToListBottom(GetFocusEwin(), LIST_TYPE_WARP_RING);
        lst = (EWin **) ListItemType(&num, LIST_TYPE_WARP_RING);
        warpFocusIndex = num - 1;
      }
@@ -130,17 +130,7 @@
        if (!FindItem((char *)ewin, 0, LIST_FINDBY_POINTER, LIST_TYPE_EWIN))
           ewin = NULL;
        if (ewin)
-         {
-            if (conf.focus.raise_on_next_focus)
-               RaiseEwin(ewin);
-            if (conf.focus.warp_on_next_focus && !ewin->iconified)
-               XWarpPointer(disp, None, ewin->win, 0, 0, 0, 0, ewin->w / 2,
-                            ewin->h / 2);
-            /* if (conf.focus.mode == MODE_FOCUS_CLICK) */
-            /* FocusToEWin(ewin); */
-            if (conf.warplist.warpfocused && !ewin->iconified)
-               FocusToEWin(ewin, FOCUS_WARP);
-         }
+          FocusToEWin(ewin, FOCUS_SET);
        WarpFocusShowTitle(ewin);
        Efree(lst);
      }
@@ -168,18 +158,10 @@
          {
             if (conf.warplist.warpiconified && ewin->iconified)
                DeIconifyEwin(ewin);
-            FocusToEWin(ewin, FOCUS_SET);
-            if (conf.focus.warp_after_next_focus
-                || conf.focus.warp_on_next_focus)
-              {
-                 XWarpPointer(disp, None, ewin->win, 0, 0, 0, 0, ewin->w / 2,
-                              ewin->h / 2);
-              }
-            if (conf.focus.raise_after_next_focus)
-               RaiseEwin(ewin);
+            FocusToEWin(ewin, FOCUS_WARP_DONE);
          }
-       /*printf ("Raise: %s\n", ewin->client.title); */
        Efree(lst);
+
        while (RemoveItem("", 0, LIST_FINDBY_NONE, LIST_TYPE_WARP_RING));
      }
 




-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to