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 Makefile.am ecore_x.c ecore_x_private.h 
Added Files:
      Tag: SPLIT
        ecore_x_events.c 


Log Message:


x ubsystem now has event handlers to translate x events to ecore events...
empty right now.. but it works. this system later will need to be able to
generate synthetic events form client messages and property notify's

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/Attic/Ecore_X.h,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -3 -r1.1.2.2 -r1.1.2.3
--- Ecore_X.h   16 Jan 2003 11:39:41 -0000      1.1.2.2
+++ Ecore_X.h   21 Jan 2003 01:22:45 -0000      1.1.2.3
@@ -18,7 +18,41 @@
    
 #endif
 
-int ecore_x_init(const char *name);       
+extern int ECORE_EVENT_X_KEY_DOWN;
+extern int ECORE_EVENT_X_KEY_UP;
+extern int ECORE_EVENT_X_MOUSE_BUTTON_DOWN;
+extern int ECORE_EVENT_X_MOUSE_BUTTON_UP;
+extern int ECORE_EVENT_X_MOUSE_MOVE;
+extern int ECORE_EVENT_X_MOUSE_IN;
+extern int ECORE_EVENT_X_MOUSE_OUT;
+extern int ECORE_EVENT_X_WINDOW_FOCUS_IN;
+extern int ECORE_EVENT_X_WINDOW_FOCUS_OUT;
+extern int ECORE_EVENT_X_WINDOW_DAMAGE;
+extern int ECORE_EVENT_X_WINDOW_VISIBILITY_CHANGE;
+extern int ECORE_EVENT_X_WINDOW_CREATE;
+extern int ECORE_EVENT_X_WINDOW_DESTROY;
+extern int ECORE_EVENT_X_WINDOW_HIDE;
+extern int ECORE_EVENT_X_WINDOW_SHOW;
+extern int ECORE_EVENT_X_WINDOW_SHOW_REQUEST;
+extern int ECORE_EVENT_X_WINDOW_REPARENT;
+extern int ECORE_EVENT_X_WINDOW_CONFIGURE;
+extern int ECORE_EVENT_X_WINDOW_CONFIGURE_REQUEST;
+extern int ECORE_EVENT_X_WINDOW_STACK;
+extern int ECORE_EVENT_X_WINDOW_STACK_REQUEST;
+extern int ECORE_EVENT_X_WINDOW_PROPERTY;
+extern int ECORE_EVENT_X_WINDOW_COLORMAP;
+extern int ECORE_EVENT_X_CLIENT_MESSAGE;
+extern int ECORE_EVENT_X_SELECTION_NOTIFY;
+extern int ECORE_EVENT_X_SELECTION_CLEAR;
+extern int ECORE_EVENT_X_SELECTION_REQUEST;
+extern int ECORE_EVENT_X_WINDOW_SHAPE;
+   
+int      ecore_x_init(const char *name);       
+Display *ecore_x_display_get(void);
+       
+void ecore_x_error_handler_set(void (*func) (void *data), const void *data);
+int  ecore_x_error_request_get(void);
+int  ecore_x_error_code_get(void);
    
 #ifdef __cplusplus
 }
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/Attic/Makefile.am,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -3 -r1.1.2.1 -r1.1.2.2
--- Makefile.am 16 Jan 2003 11:26:42 -0000      1.1.2.1
+++ Makefile.am 21 Jan 2003 01:22:45 -0000      1.1.2.2
@@ -8,6 +8,8 @@
 
 libecore_x_la_SOURCES = \
 ecore_x.c \
+ecore_x_error.c \
+ecore_x_events.c \
 ecore_x_private.h
 
 libecore_x_la_LIBADD = @x_ldflags@ @x_libs@
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/Attic/ecore_x.c,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -3 -r1.1.2.2 -r1.1.2.3
--- ecore_x.c   16 Jan 2003 11:39:41 -0000      1.1.2.2
+++ ecore_x.c   21 Jan 2003 01:22:45 -0000      1.1.2.3
@@ -5,7 +5,41 @@
 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 Display *disp = NULL;
+static Ecore_Fd_Handler *_ecore_x_fd_handler_handle = 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;
+
+Display *_ecore_x_disp = NULL;
+
+int ECORE_EVENT_X_KEY_DOWN = 0;
+int ECORE_EVENT_X_KEY_UP = 0;
+int ECORE_EVENT_X_MOUSE_BUTTON_DOWN = 0;
+int ECORE_EVENT_X_MOUSE_BUTTON_UP = 0;
+int ECORE_EVENT_X_MOUSE_MOVE = 0;
+int ECORE_EVENT_X_MOUSE_IN = 0;
+int ECORE_EVENT_X_MOUSE_OUT = 0;
+int ECORE_EVENT_X_WINDOW_FOCUS_IN = 0;
+int ECORE_EVENT_X_WINDOW_FOCUS_OUT = 0;
+int ECORE_EVENT_X_WINDOW_DAMAGE = 0;
+int ECORE_EVENT_X_WINDOW_VISIBILITY_CHANGE = 0;
+int ECORE_EVENT_X_WINDOW_CREATE = 0;
+int ECORE_EVENT_X_WINDOW_DESTROY = 0;
+int ECORE_EVENT_X_WINDOW_HIDE = 0;
+int ECORE_EVENT_X_WINDOW_SHOW = 0;
+int ECORE_EVENT_X_WINDOW_SHOW_REQUEST = 0;
+int ECORE_EVENT_X_WINDOW_REPARENT = 0;
+int ECORE_EVENT_X_WINDOW_CONFIGURE = 0;
+int ECORE_EVENT_X_WINDOW_CONFIGURE_REQUEST = 0;
+int ECORE_EVENT_X_WINDOW_STACK = 0;
+int ECORE_EVENT_X_WINDOW_STACK_REQUEST = 0;
+int ECORE_EVENT_X_WINDOW_PROPERTY = 0;
+int ECORE_EVENT_X_WINDOW_COLORMAP = 0;
+int ECORE_EVENT_X_CLIENT_MESSAGE = 0;
+int ECORE_EVENT_X_SELECTION_NOTIFY = 0;
+int ECORE_EVENT_X_SELECTION_CLEAR = 0;
+int ECORE_EVENT_X_SELECTION_REQUEST = 0;
+int ECORE_EVENT_X_WINDOW_SHAPE = 0;
 
 /**
  * Init the X display connection
@@ -17,17 +51,132 @@
 int
 ecore_x_init(const char *name)
 {
-   if (disp) return 1;
-   disp = XOpenDisplay((char *)name);
-   if (!disp) return 0;
-   /* FIXME: more to go here... */
-   ecore_main_fd_handler_add(ConnectionNumber(disp),
-                            ECORE_FD_READ,
-                            _ecore_x_fd_handler, disp,
-                            _ecore_x_fd_handler_buf, disp);
+   int shape_base = 0;
+   int shape_err_base = 0;
+   
+   if (_ecore_x_disp) return 1;
+   _ecore_x_disp = XOpenDisplay((char *)name);
+   if (!_ecore_x_disp) return 0;
+   _ecore_x_error_handler_init();
+   _ecore_x_event_handlers_num = LASTEvent;
+   if (XShapeQueryExtension(_ecore_x_disp, &shape_base, &shape_err_base))
+     _ecore_x_event_shape_id = shape_base + ShapeNotify;
+   if (_ecore_x_event_shape_id >= LASTEvent)
+     _ecore_x_event_handlers_num = _ecore_x_event_shape_id + 1;
+   _ecore_x_event_handlers = calloc(_ecore_x_event_handlers_num, sizeof(void *));
+   if (!_ecore_x_event_handlers)
+     {
+        XCloseDisplay(_ecore_x_disp);
+       _ecore_x_fd_handler_handle = NULL;
+       _ecore_x_disp = NULL;
+       return 0;       
+     }
+   _ecore_x_event_handlers[KeyPress]         = _ecore_x_event_handle_key_press;
+   _ecore_x_event_handlers[KeyRelease]       = _ecore_x_event_handle_key_release;
+   _ecore_x_event_handlers[ButtonPress]      = _ecore_x_event_handle_button_press;
+   _ecore_x_event_handlers[ButtonRelease]    = _ecore_x_event_handle_button_release;
+   _ecore_x_event_handlers[MotionNotify]     = _ecore_x_event_handle_motion_notify;
+   _ecore_x_event_handlers[EnterNotify]      = _ecore_x_event_handle_enter_notify;
+   _ecore_x_event_handlers[LeaveNotify]      = _ecore_x_event_handle_leave_notify;
+   _ecore_x_event_handlers[FocusIn]          = _ecore_x_event_handle_focus_in;
+   _ecore_x_event_handlers[FocusOut]         = _ecore_x_event_handle_focus_out;
+   _ecore_x_event_handlers[Expose]           = _ecore_x_event_handle_expose;
+   _ecore_x_event_handlers[VisibilityNotify] = 
+_ecore_x_event_handle_visibility_notify;
+   _ecore_x_event_handlers[CreateNotify]     = _ecore_x_event_handle_create_notify;
+   _ecore_x_event_handlers[DestroyNotify]    = _ecore_x_event_handle_destroy_notify;
+   _ecore_x_event_handlers[UnmapNotify]      = _ecore_x_event_handle_unmap_notify;
+   _ecore_x_event_handlers[MapNotify]        = _ecore_x_event_handle_map_notify;
+   _ecore_x_event_handlers[MapRequest]       = _ecore_x_event_handle_map_request;
+   _ecore_x_event_handlers[ReparentNotify]   = _ecore_x_event_handle_reparent_notify;
+   _ecore_x_event_handlers[ConfigureNotify]  = _ecore_x_event_handle_configure_notify;
+   _ecore_x_event_handlers[ConfigureRequest] = 
+_ecore_x_event_handle_configure_request;
+   _ecore_x_event_handlers[CirculateNotify]  = _ecore_x_event_handle_circulate_notify;
+   _ecore_x_event_handlers[CirculateRequest] = 
+_ecore_x_event_handle_circulate_request;
+   _ecore_x_event_handlers[PropertyNotify]   = _ecore_x_event_handle_property_notify;
+   _ecore_x_event_handlers[ColormapNotify]   = _ecore_x_event_handle_colormap_notify;
+   _ecore_x_event_handlers[ClientMessage]    = _ecore_x_event_handle_client_message;
+   _ecore_x_event_handlers[SelectionNotify]  = _ecore_x_event_handle_selection_notify;
+   _ecore_x_event_handlers[SelectionClear]   = _ecore_x_event_handle_selection_clear;
+   _ecore_x_event_handlers[SelectionRequest] = 
+_ecore_x_event_handle_selection_request;
+   if (_ecore_x_event_shape_id)
+     _ecore_x_event_handlers[_ecore_x_event_shape_id] = 
+_ecore_x_event_handle_shape_change;
+   if (!ECORE_EVENT_X_KEY_DOWN)
+     {
+       ECORE_EVENT_X_KEY_DOWN                 = ecore_event_type_new();
+       ECORE_EVENT_X_KEY_UP                   = ecore_event_type_new();
+       ECORE_EVENT_X_MOUSE_BUTTON_DOWN        = ecore_event_type_new();
+       ECORE_EVENT_X_MOUSE_BUTTON_UP          = ecore_event_type_new();
+       ECORE_EVENT_X_MOUSE_MOVE               = ecore_event_type_new();
+       ECORE_EVENT_X_MOUSE_IN                 = ecore_event_type_new();
+       ECORE_EVENT_X_MOUSE_OUT                = ecore_event_type_new();
+       ECORE_EVENT_X_WINDOW_FOCUS_IN          = ecore_event_type_new();
+       ECORE_EVENT_X_WINDOW_FOCUS_OUT         = ecore_event_type_new();
+       ECORE_EVENT_X_WINDOW_DAMAGE            = ecore_event_type_new();
+       ECORE_EVENT_X_WINDOW_VISIBILITY_CHANGE = ecore_event_type_new();
+       ECORE_EVENT_X_WINDOW_CREATE            = ecore_event_type_new();
+       ECORE_EVENT_X_WINDOW_DESTROY           = ecore_event_type_new();
+       ECORE_EVENT_X_WINDOW_HIDE              = ecore_event_type_new();
+       ECORE_EVENT_X_WINDOW_SHOW              = ecore_event_type_new();
+       ECORE_EVENT_X_WINDOW_SHOW_REQUEST      = ecore_event_type_new();
+       ECORE_EVENT_X_WINDOW_REPARENT          = ecore_event_type_new();
+       ECORE_EVENT_X_WINDOW_CONFIGURE         = ecore_event_type_new();
+       ECORE_EVENT_X_WINDOW_CONFIGURE_REQUEST = ecore_event_type_new();
+       ECORE_EVENT_X_WINDOW_STACK             = ecore_event_type_new();
+       ECORE_EVENT_X_WINDOW_STACK_REQUEST     = ecore_event_type_new();
+       ECORE_EVENT_X_WINDOW_PROPERTY          = ecore_event_type_new();
+       ECORE_EVENT_X_WINDOW_COLORMAP          = ecore_event_type_new();
+       ECORE_EVENT_X_CLIENT_MESSAGE           = ecore_event_type_new();
+       ECORE_EVENT_X_SELECTION_NOTIFY         = ecore_event_type_new();
+       ECORE_EVENT_X_SELECTION_CLEAR          = ecore_event_type_new();
+       ECORE_EVENT_X_SELECTION_REQUEST        = ecore_event_type_new();
+       ECORE_EVENT_X_WINDOW_SHAPE             = ecore_event_type_new();
+     }
+   _ecore_x_fd_handler_handle = 
+     ecore_main_fd_handler_add(ConnectionNumber(_ecore_x_disp),
+                              ECORE_FD_READ,
+                              _ecore_x_fd_handler, _ecore_x_disp,
+                              _ecore_x_fd_handler_buf, _ecore_x_disp);
+   if (!_ecore_x_fd_handler_handle)
+     {
+       XCloseDisplay(_ecore_x_disp);
+       free(_ecore_x_event_handlers);
+       _ecore_x_fd_handler_handle = NULL;
+       _ecore_x_disp = NULL;
+       _ecore_x_event_handlers = NULL;
+       return 0;
+     }   
    return 1;
 }
 
+/**
+ * Shut down the X syystem
+ * 
+ * This closes the X display connection and removes the handlers for it.
+ */
+void
+ecore_x_shutdown(void)
+{
+   if (!_ecore_x_disp) return;
+   XCloseDisplay(_ecore_x_disp);
+   free(_ecore_x_event_handlers);
+   ecore_main_fd_handler_del(_ecore_x_fd_handler_handle);
+   _ecore_x_fd_handler_handle = NULL;
+   _ecore_x_disp = NULL;
+   _ecore_x_event_handlers = NULL;
+}
+
+/**
+ * Get the X display pointer handle
+ * @return The X Display handle
+ * 
+ * This returns the X Display handle used for the X connection.
+ */
+Display *
+ecore_x_display_get(void)
+{
+   return _ecore_x_disp;
+}
+
 static int
 _ecore_x_fd_handler(Ecore_Fd_Handler *fd_handler, void *data)
 {
@@ -39,7 +188,11 @@
        XEvent ev;
        
        XNextEvent(d, &ev);
-       /* FIXME: here we should be putting an event on the event list */
+       if ((ev.type >= 0) && (ev.type < _ecore_x_event_handlers_num))
+         {
+            if (_ecore_x_event_handlers[ev.type])
+              _ecore_x_event_handlers[ev.type] (&ev);
+         }
      }
    return 1;
 }
===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/Attic/ecore_x_private.h,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -3 -r1.1.2.1 -r1.1.2.2
--- ecore_x_private.h   16 Jan 2003 11:26:42 -0000      1.1.2.1
+++ ecore_x_private.h   21 Jan 2003 01:22:45 -0000      1.1.2.2
@@ -1,4 +1,45 @@
 #ifndef _ECORE_X_PRIVATE_H
 #define _ECORE_X_PRIVATE_H
 
+#define XK_MISCELLANY 1
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <X11/Xresource.h>
+#include <X11/keysymdef.h>
+#include <X11/extensions/XShm.h>
+#include <X11/extensions/shape.h>
+
+extern Display *_ecore_x_disp;
+
+void _ecore_x_error_handler_init(void);
+void _ecore_x_event_handle_key_press(XEvent *xevent);
+void _ecore_x_event_handle_key_release(XEvent *xevent);
+void _ecore_x_event_handle_button_press(XEvent *xevent);
+void _ecore_x_event_handle_button_release(XEvent *xevent);
+void _ecore_x_event_handle_motion_notify(XEvent *xevent);
+void _ecore_x_event_handle_enter_notify(XEvent *xevent);
+void _ecore_x_event_handle_leave_notify(XEvent *xevent);
+void _ecore_x_event_handle_focus_in(XEvent *xevent);
+void _ecore_x_event_handle_focus_out(XEvent *xevent);
+void _ecore_x_event_handle_expose(XEvent *xevent);
+void _ecore_x_event_handle_visibility_notify(XEvent *xevent);
+void _ecore_x_event_handle_create_notify(XEvent *xevent);
+void _ecore_x_event_handle_destroy_notify(XEvent *xevent);
+void _ecore_x_event_handle_unmap_notify(XEvent *xevent);
+void _ecore_x_event_handle_map_notify(XEvent *xevent);
+void _ecore_x_event_handle_map_request(XEvent *xevent);
+void _ecore_x_event_handle_reparent_notify(XEvent *xevent);
+void _ecore_x_event_handle_configure_notify(XEvent *xevent);
+void _ecore_x_event_handle_configure_request(XEvent *xevent);
+void _ecore_x_event_handle_circulate_notify(XEvent *xevent);
+void _ecore_x_event_handle_circulate_request(XEvent *xevent);
+void _ecore_x_event_handle_property_notify(XEvent *xevent);
+void _ecore_x_event_handle_colormap_notify(XEvent *xevent);
+void _ecore_x_event_handle_client_message(XEvent *xevent);
+void _ecore_x_event_handle_selection_notify(XEvent *xevent);
+void _ecore_x_event_handle_selection_clear(XEvent *xevent);
+void _ecore_x_event_handle_selection_request(XEvent *xevent);
+void _ecore_x_event_handle_shape_change(XEvent *xevent);
+
 #endif




-------------------------------------------------------
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