Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        E.h Makefile.am borders.c buttons.c config.c desktops.c eobj.h 
        events.c ewins.c ewins.h iconify.c menus.c pager.c tooltips.c 
        warp.c x.c xwin.h 
Added Files:
        tooltips.h 


Log Message:
Move tooltip handling to source. Eliminate WindowAtXY().
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/E.h,v
retrieving revision 1.483
retrieving revision 1.484
diff -u -3 -r1.483 -r1.484
--- E.h 20 Aug 2005 08:17:22 -0000      1.483
+++ E.h 20 Aug 2005 13:55:50 -0000      1.484
@@ -1069,8 +1069,6 @@
 int                 ButtonEmbedWindow(Button * ButtonToUse,
                                      Window WindowToEmbed);
 
-int                 ButtonsCheckAclass(Window win, ActionClass ** pac);
-
 /* cmclass.c */
 #if ENABLE_COLOR_MODIFIERS
 void                CreateCurve(ModCurve * c);
@@ -1160,7 +1158,6 @@
 int                 DesksGetNumber(void);
 int                 DesksGetCurrent(void);
 void                DesksSetCurrent(int desk);
-int                 DesksCheckAclass(Window win, ActionClass ** pac);
 void                DesksClear(void);
 void                DesksResize(int w, int h);
 void                DesksEventsConfigure(int mode);
@@ -1815,18 +1812,6 @@
 void                HandleTimerEvent(void);
 int                 RemoveTimerEvent(const char *name);
 
-/* tooltips.c */
-typedef struct _tooltip ToolTip;
-
-int                 TooltipConfigLoad(FILE * fs);
-void                TooltipShow(ToolTip * tt, const char *text,
-                               ActionClass * ac, int x, int y);
-void                TooltipHide(ToolTip * tt);
-
-void                TooltipsHandleEvent(void);
-void                TooltipsHide(void);
-void                TooltipsEnable(int enable);
-
 /* ttfont.c */
 void                Efont_extents(Efont * f, const char *text,
                                  int *font_ascent_return,
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/Makefile.am,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -3 -r1.51 -r1.52
--- Makefile.am 31 Jul 2005 15:34:06 -0000      1.51
+++ Makefile.am 20 Aug 2005 13:55:50 -0000      1.52
@@ -99,6 +99,7 @@
        timers.c                \
        timestamp.h             \
        tooltips.c              \
+       tooltips.h              \
        ttfont.c                \
        warp.c                  \
        windowmatch.c           \
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/borders.c,v
retrieving revision 1.272
retrieving revision 1.273
diff -u -3 -r1.272 -r1.273
--- borders.c   15 Aug 2005 16:57:13 -0000      1.272
+++ borders.c   20 Aug 2005 13:55:50 -0000      1.273
@@ -24,6 +24,7 @@
 #include "E.h"
 #include "ewins.h"
 #include "snaps.h"
+#include "tooltips.h"
 #include "xwin.h"
 #include <sys/time.h>
 
@@ -950,11 +951,55 @@
      }
 }
 
+static ActionClass *
+BorderWinpartGetAclass(void *data)
+{
+   EWinBit            *wbit = (EWinBit *) data;
+   EWin               *ewin;
+   int                 part;
+
+   /* Validate border part */
+   ewin = Mode.mouse_over_ewin;
+   if (!ewin)
+      return NULL;
+
+   part = wbit - ewin->bits;
+   if (part < 0 || part >= ewin->border->num_winparts)
+      return NULL;
+
+   return ewin->border->part[part].aclass;
+}
+
+static void
+BorderWinpartHandleTooltip(EWinBit * wbit, int event)
+{
+   EWin               *ewin = wbit->ewin;
+   int                 part = wbit - ewin->bits;
+
+   switch (event)
+     {
+     case ButtonPress:
+     case LeaveNotify:
+       TooltipsSetPending(0, NULL, NULL);
+       break;
+     case ButtonRelease:
+     case EnterNotify:
+     case MotionNotify:
+       if (!ewin->border->part[part].aclass)
+          return;
+       TooltipsSetPending(0, BorderWinpartGetAclass, wbit);
+       break;
+     }
+}
+
 static void
 BorderWinpartHandleEvents(XEvent * ev, void *prm)
 {
    EWinBit            *wbit = (EWinBit *) prm;
 
+   /* Beware! Actions may destroy the current border */
+   BorderWinpartHandleTooltip(wbit, ev->type);
+
    switch (ev->type)
      {
      case ButtonPress:
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/buttons.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -3 -r1.71 -r1.72
--- buttons.c   20 Aug 2005 08:17:22 -0000      1.71
+++ buttons.c   20 Aug 2005 13:55:50 -0000      1.72
@@ -23,11 +23,13 @@
  */
 #include "E.h"
 #include "emodule.h"
+#include "tooltips.h"
 #include "xwin.h"
 
 #define BUTTON_EVENT_MASK \
   (KeyPressMask | KeyReleaseMask | \
-   ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask)
+   ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | \
+   PointerMotionMask)
 
 typedef struct _bgeometry
 {
@@ -641,6 +643,35 @@
      }
 }
 
+static ActionClass *
+ButtonGetAclass(void *data)
+{
+   Button             *b = data;
+
+   /* Validate button */
+   if (!FindItem(b, 0, LIST_FINDBY_POINTER, LIST_TYPE_BUTTON))
+      return NULL;
+
+   return b->aclass;
+}
+
+static void
+ButtonHandleTooltip(Button * b, int event)
+{
+   switch (event)
+     {
+     case ButtonPress:
+     case LeaveNotify:
+       TooltipsSetPending(0, NULL, NULL);
+       break;
+     case ButtonRelease:
+     case EnterNotify:
+     case MotionNotify:
+       TooltipsSetPending(0, ButtonGetAclass, b);
+       break;
+     }
+}
+
 static void
 ButtonHandleEvents(XEvent * ev, void *prm)
 {
@@ -664,35 +695,9 @@
        ButtonEventMouseOut(b, ev);
        break;
      }
-}
-
-/*
- * Functions operating on all buttons
- */
-
-int
-ButtonsCheckAclass(Window win, ActionClass ** pac)
-{
-   ActionClass        *ac;
-   Button             *b, **lst;
-   int                 i, num;
-
-   ac = NULL;
-   lst = (Button **) ListItemType(&num, LIST_TYPE_BUTTON);
-   for (i = 0; i < num; i++)
-     {
-       b = lst[i];
-       if (win == EoGetWin(b) || win == b->inside_win || win == b->event_win)
-         {
-            ac = b->aclass;
-            break;
-         }
-     }
-   if (lst)
-      Efree(lst);
 
-   *pac = ac;
-   return ac != NULL;
+   if (b->aclass)
+      ButtonHandleTooltip(b, ev->type);
 }
 
 /*
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/config.c,v
retrieving revision 1.134
retrieving revision 1.135
diff -u -3 -r1.134 -r1.135
--- config.c    17 Jul 2005 12:55:11 -0000      1.134
+++ config.c    20 Aug 2005 13:55:50 -0000      1.135
@@ -23,6 +23,7 @@
  */
 #include "E.h"
 #include "conf.h"
+#include "tooltips.h"
 #include <ctype.h>
 
 #define SKIP_If_EXISTS(name, type) \
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/desktops.c,v
retrieving revision 1.168
retrieving revision 1.169
diff -u -3 -r1.168 -r1.169
--- desktops.c  20 Aug 2005 08:17:22 -0000      1.168
+++ desktops.c  20 Aug 2005 13:55:50 -0000      1.169
@@ -25,6 +25,7 @@
 #include <time.h>
 #include "emodule.h"
 #include "ewins.h"
+#include "tooltips.h"
 #include "xwin.h"
 
 #define EDESK_EVENT_MASK \
@@ -615,24 +616,6 @@
    desks.current = desk;
 }
 
-int
-DesksCheckAclass(Window win, ActionClass ** pac)
-{
-   Desk               *d;
-   int                 i;
-
-   for (i = 0; i < Conf.desks.num; i++)
-     {
-       d = _DeskGet(i);
-       if (win != EoGetWin(d))
-          continue;
-       *pac = FindItem("DESKBINDINGS", 0, LIST_FINDBY_NAME, LIST_TYPE_ACLASS);
-       return 1;
-     }
-
-   return 0;
-}
-
 void
 DesksClear(void)
 {
@@ -1440,6 +1423,29 @@
    DesktopCheckAction(d, ev);
 }
 
+static ActionClass *
+DeskGetAclass(void *data __UNUSED__)
+{
+   return FindItem("DESKBINDINGS", 0, LIST_FINDBY_NAME, LIST_TYPE_ACLASS);
+}
+
+static void
+DesktopHandleTooltip(Desk * d, int event)
+{
+   switch (event)
+     {
+     case ButtonPress:
+     case LeaveNotify:
+       TooltipsSetPending(1, NULL, NULL);
+       break;
+     case ButtonRelease:
+     case EnterNotify:
+     case MotionNotify:
+       TooltipsSetPending(1, DeskGetAclass, d);
+       break;
+     }
+}
+
 static void
 DesktopHandleEvents(XEvent * ev, void *prm)
 {
@@ -1461,6 +1467,8 @@
        FocusHandleLeave(NULL, ev);
        break;
      }
+
+   DesktopHandleTooltip(d, ev->type);
 }
 
 /* Settings */
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/eobj.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- eobj.h      14 Aug 2005 19:34:20 -0000      1.4
+++ eobj.h      20 Aug 2005 13:55:50 -0000      1.5
@@ -157,4 +157,7 @@
 void                EobjListOrderAdd(EObj * eo);
 void                EobjListOrderDel(EObj * eo);
 
+/* Hmmm. */
+unsigned int        OpacityExt(int op);
+
 #endif /* _EOBJ_H_ */
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/events.c,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -3 -r1.98 -r1.99
--- events.c    15 Aug 2005 17:15:19 -0000      1.98
+++ events.c    20 Aug 2005 13:55:50 -0000      1.99
@@ -221,7 +221,6 @@
        break;
 
       do_stuff:
-       TooltipsHandleEvent();  /* TBD */
        ActionclassesEvent(ev, GetFocusEwin());
        break;
      }
@@ -254,8 +253,6 @@
        break;
 
      case MotionNotify:        /*  6 */
-       TooltipsHandleEvent();  /* TBD */
-
        Mode.events.px = Mode.events.x;
        Mode.events.py = Mode.events.y;
        ModeGetXY(ev->xmotion.root, ev->xmotion.x_root, ev->xmotion.y_root);
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/ewins.c,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -3 -r1.97 -r1.98
--- ewins.c     20 Aug 2005 08:17:22 -0000      1.97
+++ ewins.c     20 Aug 2005 13:55:50 -0000      1.98
@@ -1581,28 +1581,6 @@
    EWinChanges.flags = 0;
 }
 
-int
-EwinsCheckAclass(Window win, ActionClass ** pac)
-{
-   EWin               *ewin, *const *lst;
-   int                 i, j, num;
-
-   lst = EwinListGetAll(&num);
-   for (i = 0; i < num; i++)
-     {
-       ewin = lst[i];
-       for (j = 0; j < ewin->border->num_winparts; j++)
-         {
-            if (win != ewin->bits[j].win)
-               continue;
-            *pac = ewin->border->part[j].aclass;
-            return 1;
-         }
-     }
-
-   return 0;
-}
-
 void
 EwinsEventsConfigure(int mode)
 {
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/ewins.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- ewins.h     20 Aug 2005 08:17:22 -0000      1.7
+++ ewins.h     20 Aug 2005 13:55:50 -0000      1.8
@@ -260,7 +260,6 @@
 
 void                EwinChange(EWin * ewin, unsigned int flag);
 
-int                 EwinsCheckAclass(Window win, ActionClass ** pac);
 void                EwinsEventsConfigure(int mode);
 void                EwinsSetFree(void);
 void                EwinsShowDesktop(int on);
@@ -289,7 +288,6 @@
 void                EwinMoveToDesktop(EWin * ewin, int num);
 void                EwinMoveToDesktopAt(EWin * ewin, int num, int x, int y);
 
-unsigned int        OpacityExt(int op);
 void                EwinOpClose(EWin * ewin);
 void                EwinOpKill(EWin * ewin);
 void                EwinOpRaise(EWin * ewin);
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/iconify.c,v
retrieving revision 1.172
retrieving revision 1.173
diff -u -3 -r1.172 -r1.173
--- iconify.c   15 Aug 2005 16:57:13 -0000      1.172
+++ iconify.c   20 Aug 2005 13:55:50 -0000      1.173
@@ -26,6 +26,7 @@
 #include "emodule.h"
 #include "ewins.h"
 #include "icons.h"
+#include "tooltips.h"
 #include "xwin.h"
 #include <math.h>
 
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/menus.c,v
retrieving revision 1.209
retrieving revision 1.210
diff -u -3 -r1.209 -r1.210
--- menus.c     15 Aug 2005 16:57:13 -0000      1.209
+++ menus.c     20 Aug 2005 13:55:51 -0000      1.210
@@ -24,6 +24,7 @@
 #include "E.h"
 #include "emodule.h"
 #include "ewins.h"
+#include "tooltips.h"
 #include "xwin.h"
 #include <X11/keysym.h>
 
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/pager.c,v
retrieving revision 1.174
retrieving revision 1.175
diff -u -3 -r1.174 -r1.175
--- pager.c     15 Aug 2005 16:57:13 -0000      1.174
+++ pager.c     20 Aug 2005 13:55:51 -0000      1.175
@@ -25,6 +25,7 @@
 #include "emodule.h"
 #include "ewins.h"
 #include "hiwin.h"
+#include "tooltips.h"
 #include "xwin.h"
 
 #define DEBUG_PAGER 0
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/tooltips.c,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -3 -r1.83 -r1.84
--- tooltips.c  20 Aug 2005 08:17:22 -0000      1.83
+++ tooltips.c  20 Aug 2005 13:55:51 -0000      1.84
@@ -24,7 +24,7 @@
 #include "E.h"
 #include "conf.h"
 #include "emodule.h"
-#include "ewins.h"             /* FIXME - Should not be here */
+#include "tooltips.h"
 #include "xwin.h"
 
 static struct
@@ -38,6 +38,8 @@
 static struct
 {
    int                 inhibit;
+   CB_GetAclass       *ac_func;
+   void               *ac_data;
 } Mode_tooltips;
 
 struct _tooltip
@@ -710,36 +712,11 @@
 
 static ToolTip     *ttip = NULL;
 
-static ActionClass *
-FindActionClass(Window win, int root_ok)
-{
-   ActionClass        *ac;
-   int                 found;
-
-   found = ButtonsCheckAclass(win, &ac);
-   if (found)
-      return ac;
-
-   found = EwinsCheckAclass(win, &ac);
-   if (found)
-      return ac;
-
-   if (!root_ok)
-      return NULL;
-
-   found = DesksCheckAclass(win, &ac);
-   if (found)
-      return ac;
-
-   return NULL;
-}
-
 static void
 ToolTipTimeout(int val __UNUSED__, void *data __UNUSED__)
 {
    int                 x, y;
    unsigned int        mask;
-   Window              win;
    ActionClass        *ac;
    const char         *tts;
 
@@ -762,8 +739,9 @@
        (Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask))
       return;
 
-   win = WindowAtXY(x, y);
-   ac = FindActionClass(win, Conf_tooltips.showroottooltip);
+   if (!Mode_tooltips.ac_func)
+      return;
+   ac = Mode_tooltips.ac_func(Mode_tooltips.ac_data);
    if (!ac)
       return;
 
@@ -779,15 +757,22 @@
  * ButtonPress, ButtonRelease, MotionNotify, EnterNotify, LeaveNotify
  */
 void
-TooltipsHandleEvent(void)
+TooltipsSetPending(int type, CB_GetAclass * func, void *data)
 {
+   Mode_tooltips.ac_func = func;
+   Mode_tooltips.ac_data = data;
+
    if (ttip)
       TooltipHide(ttip);
 
    RemoveTimerEvent("TOOLTIP_TIMEOUT");
 
+   if (!func)
+      return;
    if (Mode_tooltips.inhibit || !Conf_tooltips.enable)
       return;
+   if (type && !Conf_tooltips.showroottooltip)
+      return;
 
    DoIn("TOOLTIP_TIMEOUT", 0.001 * Conf_tooltips.delay, ToolTipTimeout, 0,
        NULL);
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/warp.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -3 -r1.77 -r1.78
--- warp.c      15 Aug 2005 16:57:13 -0000      1.77
+++ warp.c      20 Aug 2005 13:55:51 -0000      1.78
@@ -35,6 +35,7 @@
 #include "emodule.h"
 #include "ewins.h"
 #include "icons.h"
+#include "tooltips.h"
 #include "xwin.h"
 #include <X11/keysym.h>
 
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/x.c,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -3 -r1.106 -r1.107
--- x.c 15 Aug 2005 16:57:13 -0000      1.106
+++ x.c 20 Aug 2005 13:55:51 -0000      1.107
@@ -1401,92 +1401,6 @@
    XSync(disp, False);
 }
 
-static              Window
-WindowAtXY_0(Window base, int bx, int by, int x, int y)
-{
-   Window             *list = NULL;
-   XWindowAttributes   att;
-   Window              child = 0, parent_win = 0, root_win = 0;
-   int                 i;
-   unsigned int        ww, wh, num;
-   int                 wx, wy;
-
-   if (!XGetWindowAttributes(disp, base, &att))
-      return 0;
-   if (att.class == InputOnly)
-      return 0;
-   if (att.map_state != IsViewable)
-      return 0;
-   wx = att.x;
-   wy = att.y;
-   ww = att.width;
-   wh = att.height;
-
-   wx += bx;
-   wy += by;
-
-   if (!((x >= wx) && (y >= wy) && (x < (int)(wx + ww))
-        && (y < (int)(wy + wh))))
-      return 0;
-
-   if (!XQueryTree(disp, base, &root_win, &parent_win, &list, &num))
-      return base;
-   if (list)
-     {
-       for (i = num - 1;; i--)
-         {
-            if ((child = WindowAtXY_0(list[i], wx, wy, x, y)) != 0)
-              {
-                 XFree(list);
-                 return child;
-              }
-            if (!i)
-               break;
-         }
-       XFree(list);
-     }
-   return base;
-}
-
-Window
-WindowAtXY(int x, int y)
-{
-   Window             *list = NULL;
-   Window              child = 0, parent_win = 0, root_win = 0;
-   unsigned int        num;
-   int                 i;
-
-   EGrabServer();
-   if (!XQueryTree(disp, VRoot.win, &root_win, &parent_win, &list, &num))
-     {
-       EUngrabServer();
-       return VRoot.win;
-     }
-   if (list)
-     {
-       i = num - 1;
-       do
-         {
-            XWindowAttributes   xwa;
-
-            XGetWindowAttributes(disp, list[i], &xwa);
-            if (xwa.map_state != IsViewable)
-               continue;
-
-            if ((child = WindowAtXY_0(list[i], 0, 0, x, y)) == 0)
-               continue;
-
-            XFree(list);
-            EUngrabServer();
-            return child;
-         }
-       while (--i > 0);
-       XFree(list);
-     }
-   EUngrabServer();
-   return VRoot.win;
-}
-
 Display            *
 EDisplayOpen(const char *dstr, int scr)
 {
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/xwin.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- xwin.h      7 Aug 2005 22:59:27 -0000       1.3
+++ xwin.h      20 Aug 2005 13:55:51 -0000      1.4
@@ -115,8 +115,6 @@
 void                ESetColor(XColor * pxc, int r, int g, int b);
 void                EGetColor(const XColor * pxc, int *pr, int *pg, int *pb);
 
-Window              WindowAtXY(int x, int y);
-
 void                EDrawableDumpImage(Drawable draw, const char *txt);
 
 #endif /* _XWIN_H_ */




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to