Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        E.h focus.c warp.c 


Log Message:
Focus handling tweaks.
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/E.h,v
retrieving revision 1.456
retrieving revision 1.457
diff -u -3 -r1.456 -r1.457
--- E.h 30 Jun 2005 11:52:01 -0000      1.456
+++ E.h 30 Jun 2005 12:03:26 -0000      1.457
@@ -206,7 +206,6 @@
 #define LIST_TYPE_FONT          26
 #define LIST_TYPE_PAGER         27
 #define LIST_TYPE_ICONBOX       28
-#define LIST_TYPE_WARP_RING     29
 #define LIST_TYPE_XID           30
 #define LIST_TYPE_GROUP         32
 
@@ -1733,17 +1732,18 @@
 
 /* focus.c */
 #define FOCUS_NOP         0
-#define FOCUS_SET         1
-#define FOCUS_NONE        2
-#define FOCUS_ENTER       3
-#define FOCUS_LEAVE       4
-#define FOCUS_EWIN_NEW    5
-#define FOCUS_EWIN_GONE   6
-#define FOCUS_DESK_ENTER  7
-#define FOCUS_DESK_LEAVE  8
-#define FOCUS_NEXT        9
-#define FOCUS_PREV       10
-#define FOCUS_CLICK      11
+#define FOCUS_INIT        1
+#define FOCUS_SET         2
+#define FOCUS_NONE        3
+#define FOCUS_ENTER       4
+#define FOCUS_LEAVE       5
+#define FOCUS_EWIN_NEW    6
+#define FOCUS_EWIN_GONE   7
+#define FOCUS_DESK_ENTER  8
+#define FOCUS_DESK_LEAVE  9
+#define FOCUS_NEXT       10
+#define FOCUS_PREV       11
+#define FOCUS_CLICK      12
 
 void                FocusEnable(int on);
 void                FocusGetNextEwin(void);
@@ -2132,8 +2132,6 @@
 EWin               *EwinListStackGetTop(void);
 
 #define EwinListGetAll EwinListStackGet
-#define EwinListFocusRaise(ewin) EobjListFocusRaise(EoObj(ewin))
-#define EwinListFocusLower(ewin) EobjListFocusLower(EoObj(ewin))
 
 /* startup.c */
 void                StartupWindowsCreate(void);
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/focus.c,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -3 -r1.103 -r1.104
--- focus.c     17 Jun 2005 23:34:13 -0000      1.103
+++ focus.c     30 Jun 2005 12:03:38 -0000      1.104
@@ -23,6 +23,9 @@
  */
 #include "E.h"
 
+#define EwinListFocusRaise(ewin) EobjListFocusRaise(EoObj(ewin))
+#define EwinListFocusLower(ewin) EobjListFocusLower(EoObj(ewin))
+
 static int          focus_inhibit = 1;
 static int          focus_pending_why = 0;
 static EWin        *focus_pending_ewin = NULL;
@@ -282,10 +285,9 @@
           return;
        break;
 
+     case FOCUS_INIT:
      case FOCUS_DESK_ENTER:
        ewin = FocusEwinSelect();
-       if (!ewin)
-          goto done;
        break;
 
      case FOCUS_NONE:
@@ -296,7 +298,7 @@
        break;
 
      case FOCUS_EWIN_GONE:
-       if (ewin != Mode.focuswin)
+       if (Mode.focuswin)
           return;
        ewin = FocusEwinSelect();
        if (ewin == Mode.focuswin)
@@ -381,6 +383,7 @@
        break;
      case FOCUS_DESK_ENTER:
        break;
+     case FOCUS_INIT:
      case FOCUS_NEXT:
        EwinListFocusRaise(ewin);
        break;
@@ -428,11 +431,10 @@
        break;
 
      case FOCUS_EWIN_GONE:
-       focus_pending_why = FOCUS_DESK_ENTER;
+       focus_pending_why = why;
+       focus_pending_ewin = NULL;
        if (ewin == Mode.focuswin)
           Mode.focuswin = NULL;
-       if (ewin == focus_pending_ewin)
-          focus_pending_ewin = NULL;
        if (ewin == focus_pending_new)
           focus_pending_new = NULL;
        break;
@@ -499,7 +501,7 @@
 
    focus_pending_why = 0;
    focus_pending_ewin = focus_pending_new = NULL;
-   FocusToEWin(NULL, FOCUS_DESK_ENTER);
+   FocusToEWin(NULL, FOCUS_INIT);
    FocusSet();
 
    /* Enable window placement features */
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/warp.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -3 -r1.66 -r1.67
--- warp.c      30 Jun 2005 11:52:03 -0000      1.66
+++ warp.c      30 Jun 2005 12:03:38 -0000      1.67
@@ -30,11 +30,6 @@
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- *  TODO: The Warp Focus Title Window could list all windows in the
- *  warp ring with pretty window icons, and display which one is
- *  currently selected instead of just the title of the currently
- *  selected one.
  */
 #include "E.h"
 #include "icons.h"
@@ -63,11 +58,15 @@
 {
    TextClass          *tc;
    ImageClass         *ic;
-   int                 i, x, y, w, h, num, ww, hh;
+   int                 i, x, y, w, h, ww, hh;
    static int          mw, mh, tw, th;
    char                s[1024];
+   const char         *fmt;
    WarplistItem       *wl;
 
+   if (!warplist)
+      return;
+
    tc = TextclassFind("WARPFOCUS", 0);
    if (!tc)
       tc = TextclassFind("COORDS", 1);
@@ -90,39 +89,33 @@
        warpFocusWindow = eo;
 
        EventCallbackRegister(eo->win, 0, WarpFocusHandleEvent, NULL);
+       ESelectInput(eo->win, ButtonReleaseMask);
 
        TooltipsEnable(0);
      }
 
    if (!warpFocusWindow->shown)
      {
-       EWin              **lst;
-
        w = 0;
        h = 0;
-       lst = (EWin **) ListItemType(&num, LIST_TYPE_WARP_RING);
-       if (lst)
+       for (i = 0; i < warplist_num; i++)
          {
-            for (i = 0; i < num; i++)
-              {
-                 warplist_num++;
-                 warplist = Erealloc(warplist,
-                                     warplist_num * sizeof(WarplistItem));
-                 wl = warplist + warplist_num - 1;
-                 wl->win = ECreateWindow(warpFocusWindow->win, 0, 0, 1, 1, 0);
-                 EMapWindow(wl->win);
-                 wl->ewin = lst[i];
-                 Esnprintf(s, sizeof(s), (lst[i]->iconified) ? "[%s]" : "%s",
-                           EwinGetName(lst[i]));
-                 wl->txt = strdup(s);
-                 TextSize(tc, 0, 0, 0, warplist[warplist_num - 1].txt, &ww,
-                          &hh, 17);
-                 if (ww > w)
-                    w = ww;
-                 if (hh > h)
-                    h = hh;
-              }
-            Efree(lst);
+            wl = warplist + i;
+            wl->win = ECreateWindow(warpFocusWindow->win, 0, 0, 1, 1, 0);
+            EMapWindow(wl->win);
+            if (wl->ewin->iconified)
+               fmt = "[%s]";
+            else if (wl->ewin->shaded)
+               fmt = "=%s=";
+            else
+               fmt = "%s";
+            Esnprintf(s, sizeof(s), fmt, EwinGetName(wl->ewin));
+            wl->txt = strdup(s);
+            TextSize(tc, 0, 0, 0, wl->txt, &ww, &hh, 17);
+            if (ww > w)
+               w = ww;
+            if (hh > h)
+               h = hh;
          }
 
        tw = w;                 /* Text size */
@@ -142,15 +135,8 @@
        for (i = 0; i < warplist_num; i++)
          {
             EMoveResizeWindow(warplist[i].win, 0, (h * i), mw, mh);
-            if (ewin == warplist[i].ewin)
-               ImageclassApply(ic, warplist[i].win, mw, mh, 0, 0,
-                               STATE_CLICKED, 0, ST_WARPLIST);
-            else
-               ImageclassApply(ic, warplist[i].win, mw, mh, 0, 0, STATE_NORMAL,
-                               0, ST_WARPLIST);
          }
 
-       EShapePropagate(warpFocusWindow->win);
        EobjMap(warpFocusWindow, 0);
 
        /*
@@ -243,23 +229,21 @@
 void
 WarpFocus(int delta)
 {
-   EWin               *const *lst0;
-   EWin              **lst, *ewin;
-   int                 i, num0, num;
+   EWin               *const *lst;
+   EWin               *ewin;
+   int                 i, num;
+   WarplistItem       *wl;
 
    /* Remember invoking keycode (ugly hack) */
    if (!warpFocusWindow || !warpFocusWindow->shown)
       warpFocusKey = Mode.last_keycode;
 
-   lst = (EWin **) ListItemType(&num, LIST_TYPE_WARP_RING);
-   if (!lst)
+   if (!warplist)
      {
-       lst0 = EwinListFocusGet(&num0);
-       num = 0;
-       lst = NULL;
-       for (i = num0 - 1; i >= 0; --i)
+       lst = EwinListFocusGet(&num);
+       for (i = 0; i < num; i++)
          {
-            ewin = lst0[i];
+            ewin = lst[i];
             if (               /* Either visible or iconified */
                   ((EwinIsOnScreen(ewin)) || (ewin->iconified)) &&
                   /* Exclude windows that explicitely say so */
@@ -270,65 +254,87 @@
                   ((!EoIsSticky(ewin)) || (Conf.warplist.showsticky)) &&
                   /* Keep iconified windows if conf say so */
                   ((!ewin->iconified) || (Conf.warplist.showiconified)))
-               AddItem(ewin, "", 0, LIST_TYPE_WARP_RING);
+              {
+                 warplist_num++;
+                 warplist = Erealloc(warplist,
+                                     warplist_num * sizeof(WarplistItem));
+                 wl = warplist + warplist_num - 1;
+                 wl->ewin = ewin;
+              }
          }
-       MoveItemToListBottom(GetFocusEwin(), LIST_TYPE_WARP_RING);
-       lst = (EWin **) ListItemType(&num, LIST_TYPE_WARP_RING);
-       warpFocusIndex = num - 1;
-     }
 
-   if (lst)
-     {
-       warpFocusIndex = (warpFocusIndex + num + delta) % num;
-       ewin = lst[warpFocusIndex];
-       if (!FindItem((char *)ewin, 0, LIST_FINDBY_POINTER, LIST_TYPE_EWIN))
-          ewin = NULL;
-       if (ewin)
+       /* Hmmm. Hack... */
+       if (warplist_num >= 2 && warplist[1].ewin == GetFocusEwin())
          {
-            if (Conf.focus.raise_on_next)
-               RaiseEwin(ewin);
-            if (Conf.focus.warp_on_next)
-               if (ewin != Mode.mouse_over_ewin && !ewin->iconified)
-                  XWarpPointer(disp, None, EoGetWin(ewin), 0, 0, 0, 0,
-                               EoGetW(ewin) / 2, EoGetH(ewin) / 2);
-            if (Conf.warplist.warpfocused)
-               FocusToEWin(ewin, FOCUS_SET);
-            WarpFocusShow(ewin);
+            warplist[1].ewin = warplist[0].ewin;
+            warplist[0].ewin = GetFocusEwin();
          }
-       Efree(lst);
+
+       warpFocusIndex = 0;
      }
+
+   if (!warplist)
+      return;
+
+   warpFocusIndex = (warpFocusIndex + warplist_num + delta) % warplist_num;
+   ewin = warplist[warpFocusIndex].ewin;
+   if (!FindItem((char *)ewin, 0, LIST_FINDBY_POINTER, LIST_TYPE_EWIN))
+      ewin = NULL;
+   if (!ewin)
+      return;
+
+   if (Conf.focus.raise_on_next)
+      RaiseEwin(ewin);
+   if (Conf.focus.warp_on_next)
+      if (ewin != Mode.mouse_over_ewin && !ewin->iconified)
+        XWarpPointer(disp, None, EoGetWin(ewin), 0, 0, 0, 0,
+                     EoGetW(ewin) / 2, EoGetH(ewin) / 2);
+   if (Conf.warplist.warpfocused)
+      FocusToEWin(ewin, FOCUS_SET);
+   WarpFocusShow(ewin);
 }
 
 static void
-WarpFocusFinish(void)
+WarpFocusClick(int ix)
 {
-   EWin              **lst, *ewin;
-   int                 num;
+   EWin               *ewin;
+
+   if (!warplist)
+      return;
 
-   lst = (EWin **) ListItemType(&num, LIST_TYPE_WARP_RING);
-   if (!lst)
+   ewin = warplist[ix].ewin;
+   if (!FindItem((char *)ewin, 0, LIST_FINDBY_POINTER, LIST_TYPE_EWIN))
       return;
 
-   ewin = lst[warpFocusIndex];
+   RaiseEwin(ewin);
+   if (ewin->iconified)
+      EwinDeIconify(ewin);
+   FocusToEWin(ewin, FOCUS_SET);
+}
+
+static void
+WarpFocusFinish(void)
+{
+   EWin               *ewin;
+
+   ewin = warplist[warpFocusIndex].ewin;
 
    WarpFocusHide();
+
    if (!FindItem((char *)ewin, 0, LIST_FINDBY_POINTER, LIST_TYPE_EWIN))
-      ewin = NULL;
-   if (ewin)
-     {
-       if (Conf.warplist.showiconified && ewin->iconified)
-          EwinDeIconify(ewin);
-       if (Conf.warplist.raise_on_select)
-          RaiseEwin(ewin);
-       if (Conf.warplist.warp_on_select)
-          if (ewin != Mode.mouse_over_ewin)
-             XWarpPointer(disp, None, EoGetWin(ewin), 0, 0, 0, 0,
-                          EoGetW(ewin) / 2, EoGetH(ewin) / 2);
-       FocusToEWin(ewin, FOCUS_SET);
-     }
-   Efree(lst);
+      return;
 
-   while (RemoveItem("", 0, LIST_FINDBY_NONE, LIST_TYPE_WARP_RING));
+   if (ewin->iconified)
+      EwinDeIconify(ewin);
+   if (ewin->shaded)
+      EwinUnShade(ewin);
+   if (Conf.warplist.raise_on_select)
+      RaiseEwin(ewin);
+   if (Conf.warplist.warp_on_select)
+      if (ewin != Mode.mouse_over_ewin)
+        XWarpPointer(disp, None, EoGetWin(ewin), 0, 0, 0, 0,
+                     EoGetW(ewin) / 2, EoGetH(ewin) / 2);
+   FocusToEWin(ewin, FOCUS_SET);
 }
 
 static void
@@ -346,6 +352,10 @@
        if (warpFocusWindow->shown && ev->xkey.keycode != warpFocusKey)
           WarpFocusFinish();
        break;
+
+     case ButtonRelease:
+       WarpFocusClick((ev->xbutton.y * warplist_num) / warpFocusWindow->h);
+       break;
      }
 }
 




-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to