Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        E.h x.c 


Log Message:
A new event handler registration/dispatching engine (not used yet).
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/E.h,v
retrieving revision 1.274
retrieving revision 1.275
diff -u -3 -r1.274 -r1.275
--- E.h 31 May 2004 19:47:34 -0000      1.274
+++ E.h 31 May 2004 20:03:06 -0000      1.275
@@ -2696,6 +2696,21 @@
 void                RemoveWindowMatch(WindowMatch * wm);
 
 /* x.c */
+#if INCLUDE_NEW_EVENT_DISPATCHER
+typedef void        (EventCallbackFunc) (XEvent * ev, void *prm);
+void                EventCallbackRegister(Window win, int type,
+                                         EventCallbackFunc * func, void *prm);
+void                EventCallbackUnregister(Window win, int type,
+                                           EventCallbackFunc * func,
+                                           void *prm);
+void                EventCallbacksProcess(XEvent * ev);
+#endif /* INCLUDE_NEW_EVENT_DISPATCHER */
+Pixmap              ECreatePixmap(Display * display, Drawable d,
+                                 unsigned int width, unsigned int height,
+                                 unsigned depth);
+void                EFreePixmap(Display * display, Pixmap pixmap);
+Window              ECreateWindow(Window parent, int x, int y, int w, int h,
+                                 int saveunder);
 void                EMoveWindow(Display * d, Window win, int x, int y);
 void                EResizeWindow(Display * d, Window win, int w, int h);
 void                EMoveResizeWindow(Display * d, Window win, int x, int y,
@@ -2729,12 +2744,6 @@
 void                ESetWindowBackgroundPixmap(Display * d, Window win,
                                               Pixmap pmap);
 void                ESetWindowBackground(Display * d, Window win, int col);
-Pixmap              ECreatePixmap(Display * display, Drawable d,
-                                 unsigned int width, unsigned int height,
-                                 unsigned depth);
-void                EFreePixmap(Display * display, Pixmap pixmap);
-Window              ECreateWindow(Window parent, int x, int y, int w, int h,
-                                 int saveunder);
 Window              ECreateEventWindow(Window parent, int x, int y, int w,
                                       int h);
 Window              ECreateFocusWindow(Window parent, int x, int y, int w,
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/x.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -3 -r1.70 -r1.71
--- x.c 4 May 2004 19:04:42 -0000       1.70
+++ x.c 31 May 2004 20:03:06 -0000      1.71
@@ -20,12 +20,30 @@
  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
+#define INCLUDE_NEW_EVENT_DISPATCHER 0
 #include "E.h"
 #include <X11/Xutil.h>
 #include <X11/Xresource.h>
 
+#if INCLUDE_NEW_EVENT_DISPATCHER
+typedef struct
+{
+   EventCallbackFunc  *func;
+   void               *prm;
+} EventCallbackItem;
+
+typedef struct
+{
+   int                 num;
+   EventCallbackItem  *lst;
+} EventCallbackList;
+#endif /* INCLUDE_NEW_EVENT_DISPATCHER */
+
 typedef struct _exid
 {
+#if INCLUDE_NEW_EVENT_DISPATCHER
+   EventCallbackList   cbl;
+#endif                         /* INCLUDE_NEW_EVENT_DISPATCHER */
    Window              parent;
    Window              win;
    int                 x, y, w, h;
@@ -36,8 +54,7 @@
    int                 depth;
    Pixmap              bgpmap;
    int                 bgcol;
-}
-EXID;
+} EXID;
 
 static XContext     xid_context = 0;
 
@@ -46,20 +63,7 @@
 {
    EXID               *xid;
 
-   xid = Emalloc(sizeof(EXID));
-   xid->parent = 0;
-   xid->win = 0;
-   xid->x = 0;
-   xid->y = 0;
-   xid->w = 0;
-   xid->h = 0;
-   xid->num_rect = 0;
-   xid->ord = 0;
-   xid->rects = NULL;
-   xid->depth = 0;
-   xid->mapped = 0;
-   xid->bgpmap = 0;
-   xid->bgcol = 0;
+   xid = Ecalloc(1, sizeof(EXID));
 
    return xid;
 }
@@ -123,6 +127,73 @@
    depth = 0;
 }
 
+#if INCLUDE_NEW_EVENT_DISPATCHER
+void
+EventCallbackRegister(Window win, int type __UNUSED__, EventCallbackFunc * func,
+                     void *prm)
+{
+   EXID               *xid;
+   EventCallbackItem  *eci;
+
+   xid = FindXID(win);
+   if (xid == NULL)
+      return;
+
+   xid->cbl.num++;
+   xid->cbl.lst =
+      Erealloc(xid->cbl.lst, xid->cbl.num * sizeof(EventCallbackItem));
+   eci = xid->cbl.lst + xid->cbl.num - 1;
+   eci->func = func;
+   eci->prm = prm;
+}
+
+void
+EventCallbackUnregister(Window win, int type __UNUSED__,
+                       EventCallbackFunc * func, void *prm)
+{
+   EXID               *xid;
+   EventCallbackList  *ecl;
+   EventCallbackItem  *eci;
+   int                 i;
+
+   xid = FindXID(win);
+   if (xid == NULL)
+      return;
+
+   ecl = &xid->cbl;
+   eci = ecl->lst;
+   for (i = 0; i < ecl->num; i++, eci++)
+      if (eci->func == func && eci->prm == prm)
+       {
+          /* Well - remove it */
+          return;
+       }
+}
+
+void
+EventCallbacksProcess(XEvent * ev)
+{
+   EXID               *xid;
+   EventCallbackList  *ecl;
+   EventCallbackItem  *eci;
+   int                 i;
+
+   xid = FindXID(ev->xany.window);
+   if (xid == NULL)
+      return;
+
+   ecl = &xid->cbl;
+   eci = ecl->lst;
+   for (i = 0; i < ecl->num; i++, eci++)
+     {
+       if (EventDebug(200))
+          Eprintf("EventDispatch: type=%d win=%#lx func=%p prm=%p\n",
+                  ev->type, ev->xany.window, eci->func, eci->prm);
+       eci->func(ev, eci->prm);
+     }
+}
+#endif /* INCLUDE_NEW_EVENT_DISPATCHER */
+
 Pixmap
 ECreatePixmap(Display * display, Drawable d, unsigned int width,
              unsigned int height, unsigned depth)




-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to