Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        focus.c 


Log Message:
Attempt to improve focus switching when not using focus list.

===================================================================
RCS file: /cvs/e/e16/e/src/focus.c,v
retrieving revision 1.177
retrieving revision 1.178
diff -u -3 -r1.177 -r1.178
--- focus.c     7 Aug 2008 23:23:39 -0000       1.177
+++ focus.c     7 Aug 2008 23:31:36 -0000       1.178
@@ -42,8 +42,8 @@
 static int          focus_pending_why = 0;
 static EWin        *focus_pending_ewin = NULL;
 static EWin        *focus_pending_new = NULL;
+static EWin        *focus_pending_raise = NULL;
 static Timer       *focus_timer_autoraise = NULL;
-static Timer       *focus_timer_reverse = NULL;
 
 void
 FocusEnable(int on)
@@ -153,64 +153,50 @@
    return 0;
 }
 
-static int
-ReverseTimeout(void *data)
+static void
+FocusRaisePending(void)
 {
-   EWin               *ewin = (EWin *) data;
+   EWin               *ewin = focus_pending_raise;
+   unsigned int        mask;
+
+   /* The focusing cycle ends when no more modifiers are depressed */
+   mask = 0;
+   EQueryPointer(NULL, NULL, NULL, NULL, &mask);
+   if ((mask & Mode.masks.mod_key_mask) != 0)
+      return;
 
    if (EwinFindByPtr(ewin))    /* May be gone */
       EwinListFocusRaise(ewin);
 
-   focus_timer_reverse = NULL;
-   return 0;
+   GrabKeyboardRelease();
+
+   focus_pending_raise = NULL;
 }
 
 static void
-FocusGetNextEwin(void)
+FocusPrevEwin(void)
 {
    EWin               *const *lst;
    EWin               *ewin;
-   int                 i, num;
+   int                 i, j, num;
 
    lst = EwinListFocusGet(&num);
    if (num <= 1)
       return;
 
-   ewin = NULL;
-   for (i = num - 1; i >= 0; i--)
+   for (j = 0; j < num; j++)
      {
-       if (!FocusEwinValid(lst[i], 1, 0, 0) || lst[i]->props.skip_focuslist)
-          continue;
-       ewin = lst[i];
-       break;
+       if (lst[j] == Mode.focuswin)
+          break;
      }
-
-   if (ewin)
-      FocusToEWin(ewin, FOCUS_NEXT);
-}
-
-static void
-FocusGetPrevEwin(void)
-{
-   EWin               *const *lst;
-   EWin               *ewin;
-   int                 i, num;
-
-   lst = EwinListFocusGet(&num);
-   if (num <= 1)
-      return;
-
-   ewin = NULL;
    for (i = 1; i < num; i++)
      {
-       if (!FocusEwinValid(lst[i], 1, 0, 0) || lst[i]->props.skip_focuslist)
+       ewin = lst[(j + i) % num];
+       if (!FocusEwinValid(ewin, 1, 0, 0) || ewin->props.skip_focuslist)
           continue;
-       ewin = lst[i];
+       FocusToEWin(ewin, FOCUS_PREV);
        break;
      }
-
-   if (ewin)
-      FocusToEWin(ewin, FOCUS_PREV);
 }
 
 static void
@@ -408,18 +394,18 @@
    if (do_warp)
       EwinWarpTo(ewin);
 
-   TIMER_DEL(focus_timer_reverse);
    switch (why)
      {
      case FOCUS_PREV:
-       TIMER_ADD(focus_timer_reverse, 0.5, ReverseTimeout, ewin);
+     case FOCUS_NEXT:
+       GrabKeyboardSet(VROOT); /* Causes idler to be called on KeyRelease */
+       focus_pending_raise = ewin;
        break;
      case FOCUS_DESK_ENTER:
        if (Conf.focus.mode == MODE_FOCUS_CLICK)
           break;
      default:
      case FOCUS_INIT:
-     case FOCUS_NEXT:
        EwinListFocusRaise(ewin);
        break;
      }
@@ -531,8 +517,6 @@
    /* Start focusing windows */
    FocusEnable(1);
 
-   focus_pending_why = 0;
-   focus_pending_ewin = focus_pending_new = NULL;
    FocusToEWin(NULL, FOCUS_INIT);
    FocusSet();
 
@@ -873,6 +857,8 @@
       FocusSet();
    if (click_pending_update_grabs)
       doClickGrabsUpdate();
+   if (focus_pending_raise)
+      FocusRaisePending();
 }
 
 static void
@@ -979,14 +965,14 @@
        if (Conf.warplist.enable)
           WarpFocus(1);
        else
-          FocusGetNextEwin();
+          FocusPrevEwin();
      }
    else if (!strncmp(cmd, "prev", 2))
      {
        if (Conf.warplist.enable)
           WarpFocus(-1);
        else
-          FocusGetPrevEwin();
+          FocusPrevEwin();
      }
 }
 



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to