Enlightenment CVS committal

Author  : raster
Project : e17
Module  : libs/ecore

Dir     : e17/libs/ecore/src/lib/ecore_x


Modified Files:
      Tag: SPLIT
        Ecore_X.h ecore_x.c ecore_x_events.c ecore_x_private.h 


Log Message:


add event filter susbsystem and make the x module use it to filter out
excess mouse motion events. just a start

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/Attic/Ecore_X.h,v
retrieving revision 1.1.2.12
retrieving revision 1.1.2.13
diff -u -3 -r1.1.2.12 -r1.1.2.13
--- Ecore_X.h   4 Feb 2003 22:35:43 -0000       1.1.2.12
+++ Ecore_X.h   5 Feb 2003 00:10:19 -0000       1.1.2.13
@@ -100,7 +100,7 @@
    char   *key_compose;
    int     modifiers;
    Window  win;
-   Window  subwin;
+   Window  event_win;
    Time    time;
 };
 
@@ -110,7 +110,7 @@
    char   *key_compose;
    int     modifiers;
    Window  win;
-   Window  subwin;
+   Window  event_win;
    Time    time;
 };
 
@@ -123,7 +123,7 @@
       int  x, y;
    } root;
    Window  win;
-   Window  subwin;
+   Window  event_win;
    Time    time;
    int     double_click : 1;
    int     triple_click : 1;
@@ -138,7 +138,7 @@
       int  x, y;
    } root;
    Window  win;
-   Window  subwin;
+   Window  event_win;
    Time    time;
 };
 
@@ -150,7 +150,7 @@
       int  x, y;
    } root;
    Window  win;
-   Window  subwin;
+   Window  event_win;
    Time    time;
 };
 
@@ -162,7 +162,7 @@
       int  x, y;
    } root;
    Window               win;
-   Window               subwin;
+   Window               event_win;
    Ecore_X_Event_Mode   mode;
    Ecore_X_Event_Detail detail;
    Time                 time;
@@ -176,7 +176,7 @@
       int  x, y;
    } root;
    Window               win;
-   Window               subwin;
+   Window               event_win;
    Ecore_X_Event_Mode   mode;
    Ecore_X_Event_Detail detail;
    Time                 time;
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/Attic/ecore_x.c,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -u -3 -r1.1.2.9 -r1.1.2.10
--- ecore_x.c   4 Feb 2003 22:35:43 -0000       1.1.2.9
+++ ecore_x.c   5 Feb 2003 00:10:19 -0000       1.1.2.10
@@ -5,8 +5,12 @@
 static int _ecore_x_fd_handler(Ecore_Fd_Handler *fd_handler, void *data);
 static int _ecore_x_fd_handler_buf(Ecore_Fd_Handler *fd_handler, void *data);
 static int _ecore_x_key_mask_get(KeySym sym);
+static void *_ecore_x_event_filter_start(void *data);
+static int   _ecore_x_event_filter_filter(int type, void *event, void *loop_data, 
+void *data);
+static void  _ecore_x_event_filter_end(void *loop_data, void *data);
 
 static Ecore_Fd_Handler *_ecore_x_fd_handler_handle = NULL;
+static Ecore_Event_Filter *_ecore_x_filter_handler = NULL;
 static int _ecore_x_event_shape_id = 0;
 static int _ecore_x_event_handlers_num = 0;
 static void (**_ecore_x_event_handlers) (XEvent * event) = NULL;
@@ -14,6 +18,9 @@
 Display *_ecore_x_disp = NULL;
 double   _ecore_x_double_click_time = 0.25;
 Time     _ecore_x_event_last_time = 0;
+Window   _ecore_x_event_last_win = 0;
+int      _ecore_x_event_last_root_x = 0;
+int      _ecore_x_event_last_root_y = 0;
 
 Atom     _ecore_x_atom_wm_delete_window = 0;
 Atom     _ecore_x_atom_wm_protocols = 0;
@@ -189,6 +196,7 @@
        _ecore_x_event_handlers = NULL;
        return 0;
      }
+   _ecore_x_filter_handler = ecore_event_filter_add(_ecore_x_event_filter_start, 
+_ecore_x_event_filter_filter, _ecore_x_event_filter_end, NULL);
    _ecore_x_atom_wm_delete_window = XInternAtom(_ecore_x_disp, "WM_DELETE_WINDOW", 
False);
    _ecore_x_atom_wm_protocols     = XInternAtom(_ecore_x_disp, "WM_PROTOCOLS", False);
    return 1;
@@ -206,7 +214,9 @@
    XCloseDisplay(_ecore_x_disp);
    free(_ecore_x_event_handlers);
    ecore_main_fd_handler_del(_ecore_x_fd_handler_handle);
+   ecore_event_filter_del(_ecore_x_filter_handler);
    _ecore_x_fd_handler_handle = NULL;
+   _ecore_x_filter_handler = NULL;
    _ecore_x_disp = NULL;
    _ecore_x_event_handlers = NULL;
 }
@@ -337,4 +347,40 @@
        XFree(mod);
      }
   return 0;
+}
+
+static void *
+_ecore_x_event_filter_start(void *data)
+{
+   static int last_event_type;
+   
+   last_event_type = 0;
+   return &last_event_type;
+}
+
+static int
+_ecore_x_event_filter_filter(int type, void *event, void *loop_data, void *data)
+{
+   int *last_event_type;
+   
+   last_event_type = loop_data;
+   if (type == ECORE_EVENT_X_MOUSE_MOVE)
+     {
+       if ((*last_event_type) == ECORE_EVENT_X_MOUSE_MOVE) 
+         {
+            *last_event_type = type;
+            return 0;
+         }
+     }
+   *last_event_type = type;
+   return 1;
+}
+
+static void
+_ecore_x_event_filter_end(void *loop_data, void *data)
+{
+   int *last_event_type;
+   
+   last_event_type = loop_data;   
+   *last_event_type = 0;
 }
===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/Attic/ecore_x_events.c,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -u -3 -r1.1.2.7 -r1.1.2.8
--- ecore_x_events.c    4 Feb 2003 22:35:43 -0000       1.1.2.7
+++ ecore_x_events.c    5 Feb 2003 00:10:19 -0000       1.1.2.8
@@ -62,8 +62,9 @@
        e->key_compose = strdup(buf);
      }
    else e->key_compose = NULL;
-   e->win = xevent->xkey.window;
-   e->subwin = xevent->xkey.subwindow;
+   if (xevent->xkey.subwindow) e->win = xevent->xkey.subwindow;
+   else e->win = xevent->xkey.window;
+   e->event_win = xevent->xkey.window;
    e->time = xevent->xkey.time;
    e->modifiers = xevent->xkey.state;
    _ecore_x_event_last_time = e->time;
@@ -98,8 +99,9 @@
        e->key_compose = strdup(buf);
      }
    else e->key_compose = NULL;
-   e->win = xevent->xkey.window;
-   e->subwin = xevent->xkey.subwindow;
+   if (xevent->xkey.subwindow) e->win = xevent->xkey.subwindow;
+   else e->win = xevent->xkey.window;
+   e->event_win = xevent->xkey.window;
    e->time = xevent->xkey.time;
    e->modifiers = xevent->xkey.state;
    _ecore_x_event_last_time = e->time;
@@ -111,8 +113,8 @@
 {
    static Window last_win = 0;
    static Window last_last_win = 0;
-   static Window last_subwin = 0;
-   static Window last_last_subwin = 0;
+   static Window last_event_win = 0;
+   static Window last_last_event_win = 0;
    static Time last_time = 0;
    static Time last_last_time = 0;
    int did_triple = 0;
@@ -133,10 +135,14 @@
             e->y = xevent->xbutton.y;
             e->root.x = xevent->xbutton.x_root;
             e->root.y = xevent->xbutton.y_root;
-            e->win = xevent->xbutton.window;
-            e->subwin = xevent->xbutton.subwindow;
+            if (xevent->xbutton.subwindow) e->win = xevent->xbutton.subwindow;
+            else e->win = xevent->xbutton.window;
+            e->event_win = xevent->xbutton.window;
             e->time = xevent->xbutton.time;
             _ecore_x_event_last_time = e->time;
+            _ecore_x_event_last_win = e->win;
+            _ecore_x_event_last_root_x = e->root.x;
+            _ecore_x_event_last_root_y = e->root.y;
             ecore_event_add(ECORE_EVENT_X_MOUSE_MOVE, e, _ecore_x_event_free_generic, 
NULL);
          }
          {
@@ -150,40 +156,47 @@
             e->y = xevent->xbutton.y;
             e->root.x = xevent->xbutton.x_root;
             e->root.y = xevent->xbutton.y_root;
-            e->win = xevent->xbutton.window;
-            e->subwin = xevent->xbutton.subwindow;
+            if (xevent->xbutton.subwindow) e->win = xevent->xbutton.subwindow;
+            else e->win = xevent->xbutton.window;
+            e->event_win = xevent->xbutton.window;
             e->time = xevent->xbutton.time;
             if (((e->time - last_time) <= 
                  (int)(1000 * _ecore_x_double_click_time)) &&
                 (e->win == last_win) &&
-                (e->subwin == last_subwin))
+                (e->event_win == last_event_win))
               e->double_click = 1;
             if (((e->time - last_last_time) <= 
                  (int)(2 * 1000 * _ecore_x_double_click_time)) &&
                 (e->win == last_win) && (e->win == last_last_win) &&
-                (e->subwin == last_subwin) && (e->subwin == last_last_subwin))
+                (e->event_win == last_event_win) && (e->event_win == 
+last_last_event_win))
               {
                  did_triple = 1;
                  e->triple_click = 1;
               }
             _ecore_x_event_last_time = e->time;
+            _ecore_x_event_last_win = e->win;
+            _ecore_x_event_last_root_x = e->root.x;
+            _ecore_x_event_last_root_y = e->root.y;
             ecore_event_add(ECORE_EVENT_X_MOUSE_BUTTON_DOWN, e, 
_ecore_x_event_free_generic, NULL);
          }
        if (did_triple)
          {
             last_win = 0;
             last_last_win = 0;
-            last_subwin = 0;
-            last_last_subwin = 0;
+            last_event_win = 0;
+            last_last_event_win = 0;
             last_time = 0;
             last_last_time = 0;
          }
        else
          {
             last_last_win = last_win;
-            last_win = xevent->xbutton.window;
-            last_last_subwin = last_subwin;
-            last_subwin = xevent->xbutton.subwindow;
+            if (xevent->xbutton.subwindow)
+              last_win = xevent->xbutton.subwindow;
+            else
+              last_win = xevent->xbutton.window;
+            last_last_event_win = last_event_win;
+            last_event_win = xevent->xbutton.window;
             last_last_time = last_time;
             last_time = xevent->xbutton.time;
          }
@@ -206,10 +219,14 @@
             e->y = xevent->xbutton.y;
             e->root.x = xevent->xbutton.x_root;
             e->root.y = xevent->xbutton.y_root;
-            e->win = xevent->xbutton.window;
-            e->subwin = xevent->xbutton.subwindow;
+            if (xevent->xbutton.subwindow) e->win = xevent->xbutton.subwindow;
+            else e->win = xevent->xbutton.window;
+            e->event_win = xevent->xbutton.window;
             e->time = xevent->xbutton.time;
             _ecore_x_event_last_time = e->time;
+            _ecore_x_event_last_win = e->win;
+            _ecore_x_event_last_root_x = e->root.x;
+            _ecore_x_event_last_root_y = e->root.y;
             ecore_event_add(ECORE_EVENT_X_MOUSE_MOVE, e, _ecore_x_event_free_generic, 
NULL);
          }
          {
@@ -223,10 +240,14 @@
             e->y = xevent->xbutton.y;
             e->root.x = xevent->xbutton.x_root;
             e->root.y = xevent->xbutton.y_root;
-            e->win = xevent->xbutton.window;
-            e->subwin = xevent->xbutton.subwindow;
+            if (xevent->xbutton.subwindow) e->win = xevent->xbutton.subwindow;
+            else e->win = xevent->xbutton.window;
+            e->event_win = xevent->xbutton.window;
             e->time = xevent->xbutton.time;
             _ecore_x_event_last_time = e->time;
+            _ecore_x_event_last_win = e->win;
+            _ecore_x_event_last_root_x = e->root.x;
+            _ecore_x_event_last_root_y = e->root.y;
             ecore_event_add(ECORE_EVENT_X_MOUSE_BUTTON_UP, e, 
_ecore_x_event_free_generic, NULL);
          }
      }
@@ -236,7 +257,7 @@
 _ecore_x_event_handle_motion_notify(XEvent *xevent)
 {
    Ecore_X_Event_Mouse_Move *e;
-   
+
    e = calloc(1, sizeof(Ecore_X_Event_Mouse_Move));
    if (!e) return;
    e->modifiers = xevent->xmotion.state;
@@ -244,10 +265,14 @@
    e->y = xevent->xmotion.y;
    e->root.x = xevent->xmotion.x_root;
    e->root.y = xevent->xmotion.y_root;
-   e->win = xevent->xmotion.window;
-   e->subwin = xevent->xmotion.subwindow;
+   if (xevent->xmotion.subwindow) e->win = xevent->xmotion.subwindow;
+   else e->win = xevent->xmotion.window;
+   e->event_win = xevent->xmotion.window;
    e->time = xevent->xmotion.time;
    _ecore_x_event_last_time = e->time;
+   _ecore_x_event_last_win = e->win;
+   _ecore_x_event_last_root_x = e->root.x;
+   _ecore_x_event_last_root_y = e->root.y;
    ecore_event_add(ECORE_EVENT_X_MOUSE_MOVE, e, _ecore_x_event_free_generic, NULL);
 }
 
@@ -264,10 +289,14 @@
        e->y = xevent->xcrossing.y;
        e->root.x = xevent->xcrossing.x_root;
        e->root.y = xevent->xcrossing.y_root;
-       e->win = xevent->xcrossing.window;
-       e->subwin = xevent->xcrossing.subwindow;
+       if (xevent->xcrossing.subwindow) e->win = xevent->xcrossing.subwindow;
+       else e->win = xevent->xcrossing.window;
+       e->event_win = xevent->xcrossing.window;
        e->time = xevent->xcrossing.time;
        _ecore_x_event_last_time = e->time;
+       _ecore_x_event_last_win = e->win;
+       _ecore_x_event_last_root_x = e->root.x;
+       _ecore_x_event_last_root_y = e->root.y;
        ecore_event_add(ECORE_EVENT_X_MOUSE_MOVE, e, _ecore_x_event_free_generic, 
NULL);
      }
      {
@@ -280,8 +309,9 @@
        e->y = xevent->xcrossing.y;
        e->root.x = xevent->xcrossing.x_root;
        e->root.y = xevent->xcrossing.y_root;
-       e->win = xevent->xcrossing.window;
-       e->subwin = xevent->xcrossing.subwindow;
+       if (xevent->xcrossing.subwindow) e->win = xevent->xcrossing.subwindow;
+       else e->win = xevent->xcrossing.window;
+       e->event_win = xevent->xcrossing.window;
        if      (xevent->xcrossing.mode == NotifyNormal) e->mode = 
ECORE_X_EVENT_MODE_NORMAL;
        else if (xevent->xcrossing.mode == NotifyGrab)   e->mode = 
ECORE_X_EVENT_MODE_GRAB;
        else if (xevent->xcrossing.mode == NotifyUngrab) e->mode = 
ECORE_X_EVENT_MODE_UNGRAB;
@@ -309,10 +339,14 @@
        e->y = xevent->xcrossing.y;
        e->root.x = xevent->xcrossing.x_root;
        e->root.y = xevent->xcrossing.y_root;
-       e->win = xevent->xcrossing.window;
-       e->subwin = xevent->xcrossing.subwindow;
+       if (xevent->xcrossing.subwindow) e->win = xevent->xcrossing.subwindow;
+       else e->win = xevent->xcrossing.window;
+       e->event_win = xevent->xcrossing.window;
        e->time = xevent->xcrossing.time;
        _ecore_x_event_last_time = e->time;
+       _ecore_x_event_last_win = e->win;
+       _ecore_x_event_last_root_x = e->root.x;
+       _ecore_x_event_last_root_y = e->root.y;
        ecore_event_add(ECORE_EVENT_X_MOUSE_MOVE, e, _ecore_x_event_free_generic, 
NULL);
      }
      {
@@ -325,8 +359,9 @@
        e->y = xevent->xcrossing.y;
        e->root.x = xevent->xcrossing.x_root;
        e->root.y = xevent->xcrossing.y_root;
-       e->win = xevent->xcrossing.window;
-       e->subwin = xevent->xcrossing.subwindow;
+       if (xevent->xcrossing.subwindow) e->win = xevent->xcrossing.subwindow;
+       else e->win = xevent->xcrossing.window;
+       e->event_win = xevent->xcrossing.window;
        if      (xevent->xcrossing.mode == NotifyNormal) e->mode = 
ECORE_X_EVENT_MODE_NORMAL;
        else if (xevent->xcrossing.mode == NotifyGrab)   e->mode = 
ECORE_X_EVENT_MODE_GRAB;
        else if (xevent->xcrossing.mode == NotifyUngrab) e->mode = 
ECORE_X_EVENT_MODE_UNGRAB;
@@ -336,6 +371,10 @@
        else if (xevent->xcrossing.detail == NotifyNonlinear)        e->detail = 
ECORE_X_EVENT_DETAIL_NON_LINEAR;
        else if (xevent->xcrossing.detail == NotifyNonlinearVirtual) e->detail = 
ECORE_X_EVENT_DETAIL_NON_LINEAR_VIRTUAL;
        e->time = xevent->xcrossing.time;
+       _ecore_x_event_last_time = e->time;
+       _ecore_x_event_last_win = e->win;
+       _ecore_x_event_last_root_x = e->root.x;
+       _ecore_x_event_last_root_y = e->root.y;
        ecore_event_add(ECORE_EVENT_X_MOUSE_OUT, e, _ecore_x_event_free_generic, NULL);
      }
 }
@@ -449,6 +488,7 @@
    if (!e) return;
    e->win =  xevent->xdestroywindow.window;
    e->time = _ecore_x_event_last_time;
+   if (e->win == _ecore_x_event_last_win) _ecore_x_event_last_win = 0;
    ecore_event_add(ECORE_EVENT_X_WINDOW_DESTROY, e, _ecore_x_event_free_generic, 
NULL);   
 }
 
===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/Attic/ecore_x_private.h,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -3 -r1.1.2.4 -r1.1.2.5
--- ecore_x_private.h   3 Feb 2003 12:55:31 -0000       1.1.2.4
+++ ecore_x_private.h   5 Feb 2003 00:10:19 -0000       1.1.2.5
@@ -13,6 +13,9 @@
 extern Display *_ecore_x_disp;
 extern double   _ecore_x_double_click_time;
 extern Time     _ecore_x_event_last_time;
+extern Window   _ecore_x_event_last_win;
+extern int      _ecore_x_event_last_root_x;
+extern int      _ecore_x_event_last_root_y;
 
 extern Atom     _ecore_x_atom_wm_delete_window;
 extern Atom     _ecore_x_atom_wm_protocols;




-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to