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 
Added Files:
      Tag: SPLIT
        ecore_x_error.c 


Log Message:


the x module slowly solidifies... key events fully handled now.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/Attic/Ecore_X.h,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -3 -r1.1.2.3 -r1.1.2.4
--- Ecore_X.h   21 Jan 2003 01:22:45 -0000      1.1.2.3
+++ Ecore_X.h   23 Jan 2003 01:08:35 -0000      1.1.2.4
@@ -11,12 +11,196 @@
 #include <X11/extensions/shape.h>
 
 #ifdef __cplusplus
-extern "C" {
+//extern "C" {
 #endif
 
 #ifndef _ECORE_X_PRIVATE_H
    
 #endif
+typedef struct _Ecore_X_Event_Key_Down                 Ecore_X_Event_Key_Down;
+typedef struct _Ecore_X_Event_Key_Up                   Ecore_X_Event_Key_Up;
+typedef struct _Ecore_X_Event_Mouse_Button_Down        
+Ecore_X_Event_Mouse_Button_Down;
+typedef struct _Ecore_X_Event_Mouse_Button_Up          Ecore_X_Event_Mouse_Button_Up;
+typedef struct _Ecore_X_Event_Mouse_Move               Ecore_X_Event_Mouse_Move;
+typedef struct _Ecore_X_Event_Mouse_In                 Ecore_X_Event_Mouse_In;
+typedef struct _Ecore_X_Event_Window_Focus_In          Ecore_X_Event_Window_Focus_In;
+typedef struct _Ecore_X_Event_Window_Focus_Out         Ecore_X_Event_Window_Focus_Out;
+typedef struct _Ecore_X_Event_Window_Damage            Ecore_X_Event_Window_Damage;
+typedef struct _Ecore_X_Event_Window_Visibility_Change 
+Ecore_X_Event_Visibility_Change;
+typedef struct _Ecore_X_Event_Window_Create            Ecore_X_Event_Window_Create;
+typedef struct _Ecore_X_Event_Window_Destroy           Ecore_X_Event_Window_Destroy;
+typedef struct _Ecore_X_Event_Window_Hide              Ecore_X_Event_Window_Hide;
+typedef struct _Ecore_X_Event_Window_Show              Ecore_X_Event_Window_Show;
+typedef struct _Ecore_X_Event_Window_Show_Request      
+Ecore_X_Event_Window_Show_Request;
+typedef struct _Ecore_X_Event_Window_Reparent          Ecore_X_Event_Window_Reparent;
+typedef struct _Ecore_X_Event_Window_Configure         Ecore_X_Event_Window_Configure;
+typedef struct _Ecore_X_Event_Window_Configure_Request 
+Ecore_X_Event_Window_Configure_Request;
+typedef struct _Ecore_X_Event_Window_Stack             Ecore_X_Event_Window_Stack;
+typedef struct _Ecore_X_Event_Window_Stack_Request     
+Ecore_X_Event_Window_Stack_Request;
+typedef struct _Ecore_X_Event_Window_Property          Ecore_X_Event_Window_Property;
+typedef struct _Ecore_X_Event_Window_Colormap          Ecore_X_Event_Window_Colormap;
+typedef struct _Ecore_X_Event_Client_Message           Ecore_X_Event_Client_Message;
+typedef struct _Ecore_X_Event_Selection_Notify         Ecore_X_Event_Selection_Notify;
+typedef struct _Ecore_X_Event_Selection_Clear          Ecore_X_Event_Selection_Clear;
+typedef struct _Ecore_X_Event_Selection_Request        
+Ecore_X_Event_Selection_Request;
+typedef struct _Ecore_X_Event_Window_Shape             Ecore_X_Event_Window_Shape;
+
+struct _Ecore_X_Event_Key_Down
+{
+   char   *keyname;
+   char   *key_compose;
+   int     modifiers;
+   Window  win;
+   Window  subwin;
+   Time    time;
+};
+
+struct _Ecore_X_Event_Key_Up
+{
+   char   *keyname;
+   char   *key_compose;
+   int     modifiers;
+   Window  win;
+   Window  subwin;
+   Time    time;
+};
+
+struct _Ecore_X_Event_Mouse_Button_Down
+{
+   Window  win;
+   int     button;
+};
+
+struct _Ecore_X_Event_Mouse_Button_Up
+{
+   Window  win;
+   int     button;
+};
+
+struct _Ecore_X_Event_Mouse_Move
+{
+   Window  win;
+   int     x, y;
+};
+
+struct _Ecore_X_Event_Mouse_In
+{
+   Window  win;
+};
+
+struct _Ecore_X_Event_Mouse_Out
+{
+   Window  win;
+};
+
+struct _Ecore_X_Event_Window_Focus_In
+{
+   Window  win;
+};
+
+struct _Ecore_X_Event_Window_Focus_Out
+{
+   Window  win;
+};
+
+struct _Ecore_X_Event_Window_Damage
+{
+   Window  win;
+   int     x, y, w, h;
+};
+
+struct _Ecore_X_Event_Window_Visibility_Change
+{
+   Window  win;
+};
+
+struct _Ecore_X_Event_Window_Create
+{
+   Window  win;
+};
+
+struct _Ecore_X_Event_Window_Destroy
+{
+   Window  win;
+};
+
+struct _Ecore_X_Event_Window_Hide
+{
+   Window  win;
+};
+
+struct _Ecore_X_Event_Window_Show
+{
+   Window  win;
+};
+
+struct _Ecore_X_Event_Window_Show_Request
+{
+   Window  win;
+};
+
+struct _Ecore_X_Event_Window_Reparent
+{
+   Window  win;
+   Window  new_parent;
+};
+
+struct _Ecore_X_Event_Window_Configure
+{
+   Window  win;
+   int     x, y, w, h;
+};
+
+struct _Ecore_X_Event_Window_Configure_Request
+{
+   Window  win;
+   int     x, y, w, h;
+};
+
+struct _Ecore_X_Event_Window_Stack
+{
+   Window  win;
+};
+
+struct _Ecore_X_Event_Window_Stack_Request
+{
+   Window  win;
+};
+
+struct _Ecore_X_Event_Window_Property
+{
+   Window  win;
+};
+
+struct _Ecore_X_Event_Window_Colormap
+{
+   Window  win;
+};
+
+struct _Ecore_X_Event_Client_Message
+{
+   Window  win;
+};
+
+struct _Ecore_X_Event_Selection_Notify
+{
+   Window  win;
+};
+
+struct _Ecore_X_Event_Selection_Clear
+{
+   Window  win;
+};
+
+struct _Ecore_X_Event_Selection_Request
+{
+   Window  win;
+};
+
+struct _Ecore_X_Event_Window_Shape
+{
+   Window  win;
+};
 
 extern int ECORE_EVENT_X_KEY_DOWN;
 extern int ECORE_EVENT_X_KEY_UP;
@@ -46,7 +230,16 @@
 extern int ECORE_EVENT_X_SELECTION_CLEAR;
 extern int ECORE_EVENT_X_SELECTION_REQUEST;
 extern int ECORE_EVENT_X_WINDOW_SHAPE;
-   
+
+extern int ECORE_MODIFIER_SHIFT;
+extern int ECORE_MODIFIER_CTRL;
+extern int ECORE_MODIFIER_ALT;
+extern int ECORE_MODIFIER_WIN;
+
+extern int ECORE_LOCK_SCROLL;
+extern int ECORE_LOCK_NUM;
+extern int ECORE_LOCK_CAPS;
+
 int      ecore_x_init(const char *name);       
 Display *ecore_x_display_get(void);
        
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/Attic/ecore_x.c,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -3 -r1.1.2.3 -r1.1.2.4
--- ecore_x.c   21 Jan 2003 01:22:45 -0000      1.1.2.3
+++ ecore_x.c   23 Jan 2003 01:08:35 -0000      1.1.2.4
@@ -4,6 +4,7 @@
 
 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 Ecore_Fd_Handler *_ecore_x_fd_handler_handle = NULL;
 static int _ecore_x_event_shape_id = 0;
@@ -41,6 +42,15 @@
 int ECORE_EVENT_X_SELECTION_REQUEST = 0;
 int ECORE_EVENT_X_WINDOW_SHAPE = 0;
 
+int ECORE_MODIFIER_SHIFT = 0;
+int ECORE_MODIFIER_CTRL = 0;
+int ECORE_MODIFIER_ALT = 0;
+int ECORE_MODIFIER_WIN = 0;
+
+int ECORE_LOCK_SCROLL = 0;
+int ECORE_LOCK_NUM = 0;
+int ECORE_LOCK_CAPS = 0;
+
 /**
  * Init the X display connection
  * @param name
@@ -131,6 +141,18 @@
        ECORE_EVENT_X_SELECTION_REQUEST        = ecore_event_type_new();
        ECORE_EVENT_X_WINDOW_SHAPE             = ecore_event_type_new();
      }
+   
+   ECORE_MODIFIER_SHIFT = _ecore_x_key_mask_get(XK_Shift_L);
+   ECORE_MODIFIER_CTRL  = _ecore_x_key_mask_get(XK_Control_L);
+   ECORE_MODIFIER_ALT   = _ecore_x_key_mask_get(XK_Alt_L);
+   ECORE_MODIFIER_WIN   = _ecore_x_key_mask_get(XK_Super_L);
+   if (!ECORE_MODIFIER_WIN) 
+     ECORE_MODIFIER_WIN = _ecore_x_key_mask_get(XK_Meta_L);   
+   
+   ECORE_LOCK_SCROLL    = _ecore_x_key_mask_get(XK_Scroll_Lock);
+   ECORE_LOCK_NUM       = _ecore_x_key_mask_get(XK_Num_Lock);
+   ECORE_LOCK_CAPS      = _ecore_x_key_mask_get(XK_Caps_Lock);
+   
    _ecore_x_fd_handler_handle = 
      ecore_main_fd_handler_add(ConnectionNumber(_ecore_x_disp),
                               ECORE_FD_READ,
@@ -205,4 +227,41 @@
    d = data;
    if (XPending(d)) return 1;
    return 0;
+}
+
+static int
+_ecore_x_key_mask_get(KeySym sym)
+{
+   XModifierKeymap    *mod;
+   KeyCode             nl;
+   int                 i;
+   const int           masks[8] = 
+     {
+       ShiftMask, LockMask, ControlMask, 
+         Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
+     };
+   
+   mod = XGetModifierMapping(_ecore_x_disp);
+   nl = XKeysymToKeycode(_ecore_x_disp, sym);
+   if ((mod) && (mod->max_keypermod > 0))
+     {
+       for (i = 0; i < (8 * mod->max_keypermod); i++)
+         {
+            if ((nl) && (mod->modifiermap[i] == nl))
+              {
+                 int mask;
+                 
+                 mask = masks[i / mod->max_keypermod];
+                 if (mod->modifiermap) XFree(mod->modifiermap);
+                 XFree(mod);
+                 return mask;
+              }
+         }
+     }
+   if (mod)
+     {
+       if (mod->modifiermap) XFree(mod->modifiermap);
+       XFree(mod);
+     }
+  return 0;
 }
===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/Attic/ecore_x_events.c,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_events.c    21 Jan 2003 01:22:45 -0000      1.1.2.1
+++ ecore_x_events.c    23 Jan 2003 01:08:36 -0000      1.1.2.2
@@ -2,14 +2,101 @@
 #include "ecore_x_private.h"
 #include "Ecore_X.h"
 
+static void _ecore_x_event_handle_key_press_free(void *ev, void *data);
+static void _ecore_x_event_handle_key_release_free(void *ev, void *data);
+
+static void
+_ecore_x_event_handle_key_press_free(void *ev, void *data)
+{
+   Ecore_X_Event_Key_Down *e;
+
+   e = ev;
+   if (e->keyname) free(e->keyname);
+   if (e->key_compose) free(e->key_compose);
+   free(e);
+}
+
 void
 _ecore_x_event_handle_key_press(XEvent *xevent)
 {
+   Ecore_X_Event_Key_Down *e;
+   char                   *keyname;
+   int                     val;
+   char                    buf[256];
+   KeySym                  sym;
+   XComposeStatus          stat;
+   
+   e = calloc(1, sizeof(Ecore_X_Event_Key_Down));
+   if (!e) return;
+   keyname = XKeysymToString(XKeycodeToKeysym(xevent->xkey.display, 
+                                             xevent->xkey.keycode, 0));
+   if (!keyname) keyname = "";
+   e->keyname = strdup(keyname);
+   if (!e->keyname)
+     {
+       free(e);
+       return;
+     }
+   val = XLookupString((XKeyEvent *)xevent, buf, sizeof(buf), &sym, &stat);
+   if (val > 0)
+     {
+       buf[val] = 0;
+       e->key_compose = strdup(buf);
+     }
+   else e->key_compose = NULL;
+   e->win = xevent->xkey.window;
+   e->subwin = xevent->xkey.subwindow;
+   e->time = xevent->xkey.time;
+   e->modifiers = xevent->xkey.state;
+   ecore_event_add(ECORE_EVENT_X_KEY_DOWN, e,
+                  _ecore_x_event_handle_key_press_free, NULL);
+}
+
+static void
+_ecore_x_event_handle_key_release_free(void *ev, void *data)
+{
+   Ecore_X_Event_Key_Up *e;
+
+   e = ev;
+   if (e->keyname) free(e->keyname);
+   if (e->key_compose) free(e->key_compose);
+   free(e);
 }
 
 void
 _ecore_x_event_handle_key_release(XEvent *xevent)
 {
+   Ecore_X_Event_Key_Up *e;
+   char                   *keyname;
+   int                     val;
+   char                    buf[256];
+   KeySym                  sym;
+   XComposeStatus          stat;
+   
+   e = calloc(1, sizeof(Ecore_X_Event_Key_Up));
+   if (!e) return;
+   keyname = XKeysymToString(XKeycodeToKeysym(xevent->xkey.display, 
+                                             xevent->xkey.keycode, 0));
+   if (!keyname) keyname = "";
+   e->keyname = strdup(keyname);
+   if (!e->keyname)
+     {
+       free(e);
+       return;
+     }
+   val = XLookupString((XKeyEvent *)xevent, buf, sizeof(buf), &sym, &stat);
+   if (val > 0)
+     {
+       buf[val] = 0;
+       e->key_compose = strdup(buf);
+     }
+   else e->key_compose = NULL;
+   e->win = xevent->xkey.window;
+   e->subwin = xevent->xkey.subwindow;
+   e->time = xevent->xkey.time;
+   e->modifiers = xevent->xkey.state;
+   ecore_event_add(ECORE_EVENT_X_KEY_UP, e,
+                  _ecore_x_event_handle_key_release_free, NULL);
 }
 
 void




-------------------------------------------------------
This SF.net email is sponsored by: Scholarships for Techies!
Can't afford IT training? All 2003 ictp students receive scholarships.
Get hands-on training in Microsoft, Cisco, Sun, Linux/UNIX, and more.
www.ictp.com/training/sourceforge.asp
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to