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 ecore_x_window_prop.c Log Message: example of porperty change to event translation... eventually might want to turn the property one into a table... =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/Attic/Ecore_X.h,v retrieving revision 1.1.2.13 retrieving revision 1.1.2.14 diff -u -3 -r1.1.2.13 -r1.1.2.14 --- Ecore_X.h 5 Feb 2003 00:10:19 -0000 1.1.2.13 +++ Ecore_X.h 5 Feb 2003 06:51:57 -0000 1.1.2.14 @@ -92,8 +92,10 @@ typedef struct _Ecore_X_Event_Client_Message Ecore_X_Event_Client_Message; typedef struct _Ecore_X_Event_Window_Shape Ecore_X_Event_Window_Shape; -typedef struct _Ecore_X_Event_Window_Delete_Request Ecore_X_Event_Window_Delete_Request; - +typedef struct _Ecore_X_Event_Window_Delete_Request +Ecore_X_Event_Window_Delete_Request; +typedef struct _Ecore_X_Event_Window_Prop_Title_Change +Ecore_X_Event_Window_Prop_Title_Change; +typedef struct _Ecore_X_Event_Window_Prop_Name_Class_Change +Ecore_X_Event_Window_Prop_Name_Class_Change; + struct _Ecore_X_Event_Key_Down { char *keyname; @@ -322,7 +324,22 @@ Window win; Time time; }; - + +struct _Ecore_X_Event_Window_Prop_Title_Change +{ + Window win; + char *title; + Time time; +}; + +struct _Ecore_X_Event_Window_Prop_Name_Class_Change +{ + Window win; + char *name; + char *clas; + Time time; +}; + extern int ECORE_EVENT_X_KEY_DOWN; extern int ECORE_EVENT_X_KEY_UP; extern int ECORE_EVENT_X_MOUSE_BUTTON_DOWN; @@ -357,6 +374,8 @@ extern int ECORE_EVENT_X_WINDOW_SHAPE; extern int ECORE_EVENT_X_WINDOW_DELETE_REQUEST; +extern int ECORE_EVENT_X_WINDOW_PROP_TITLE_CHANGE; +extern int ECORE_EVENT_X_WINDOW_PROP_NAME_CLASS_CHANGE; extern int ECORE_MODIFIER_SHIFT; extern int ECORE_MODIFIER_CTRL; @@ -383,9 +402,11 @@ void ecore_x_window_show(Window win); void ecore_x_window_hide(Window win); -void ecore_x_window_prop_title_set(Window win, const char *t); -void ecore_x_window_prop_name_class_set(Window win, const char *n, const char *c); -void ecore_x_window_prop_delete_request_set(Window win, int on); +void ecore_x_window_prop_title_set(Window win, const char *t); +char *ecore_x_window_prop_title_get(Window win); +void ecore_x_window_prop_name_class_set(Window win, const char *n, const char *c); +void ecore_x_window_prop_name_class_get(Window win, char **n, char **c); +void ecore_x_window_prop_delete_request_set(Window win, int on); #ifdef __cplusplus } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/Attic/ecore_x.c,v retrieving revision 1.1.2.10 retrieving revision 1.1.2.11 diff -u -3 -r1.1.2.10 -r1.1.2.11 --- ecore_x.c 5 Feb 2003 00:10:19 -0000 1.1.2.10 +++ ecore_x.c 5 Feb 2003 06:51:57 -0000 1.1.2.11 @@ -24,6 +24,8 @@ Atom _ecore_x_atom_wm_delete_window = 0; Atom _ecore_x_atom_wm_protocols = 0; +Atom _ecore_x_atom_wm_class = 0; +Atom _ecore_x_atom_wm_name = 0; int ECORE_EVENT_X_KEY_DOWN = 0; int ECORE_EVENT_X_KEY_UP = 0; @@ -59,6 +61,8 @@ int ECORE_EVENT_X_WINDOW_SHAPE = 0; int ECORE_EVENT_X_WINDOW_DELETE_REQUEST = 0; +int ECORE_EVENT_X_WINDOW_PROP_TITLE_CHANGE = 0; +int ECORE_EVENT_X_WINDOW_PROP_NAME_CLASS_CHANGE = 0; int ECORE_MODIFIER_SHIFT = 0; int ECORE_MODIFIER_CTRL = 0; @@ -168,7 +172,9 @@ ECORE_EVENT_X_CLIENT_MESSAGE = ecore_event_type_new(); ECORE_EVENT_X_WINDOW_SHAPE = ecore_event_type_new(); - ECORE_EVENT_X_WINDOW_DELETE_REQUEST = ecore_event_type_new(); + ECORE_EVENT_X_WINDOW_DELETE_REQUEST = ecore_event_type_new(); + ECORE_EVENT_X_WINDOW_PROP_TITLE_CHANGE = ecore_event_type_new(); + ECORE_EVENT_X_WINDOW_PROP_NAME_CLASS_CHANGE = ecore_event_type_new(); } ECORE_MODIFIER_SHIFT = _ecore_x_key_mask_get(XK_Shift_L); @@ -199,6 +205,8 @@ _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); + _ecore_x_atom_wm_class = XInternAtom(_ecore_x_disp, "WM_CLASS", False); + _ecore_x_atom_wm_name = XInternAtom(_ecore_x_disp, "WM_NAME", False); return 1; } @@ -349,38 +357,46 @@ return 0; } +typedef struct _Ecore_X_Filter_Data Ecore_X_Filter_Data; + +struct _Ecore_X_Filter_Data +{ + int last_event_type; +}; + static void * _ecore_x_event_filter_start(void *data) { - static int last_event_type; + Ecore_X_Filter_Data *filter_data; - last_event_type = 0; - return &last_event_type; + filter_data = calloc(1, sizeof(Ecore_X_Filter_Data)); + return filter_data; } static int _ecore_x_event_filter_filter(int type, void *event, void *loop_data, void *data) { - int *last_event_type; + Ecore_X_Filter_Data *filter_data; - last_event_type = loop_data; + filter_data = loop_data; + if (!filter_data) return 1; if (type == ECORE_EVENT_X_MOUSE_MOVE) { - if ((*last_event_type) == ECORE_EVENT_X_MOUSE_MOVE) + if ((filter_data->last_event_type) == ECORE_EVENT_X_MOUSE_MOVE) { - *last_event_type = type; + filter_data->last_event_type = type; return 0; } } - *last_event_type = type; + filter_data->last_event_type = type; return 1; } static void _ecore_x_event_filter_end(void *loop_data, void *data) { - int *last_event_type; + Ecore_X_Filter_Data *filter_data; - last_event_type = loop_data; - *last_event_type = 0; + filter_data = loop_data; + if (filter_data) free(filter_data); } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/Attic/ecore_x_events.c,v retrieving revision 1.1.2.8 retrieving revision 1.1.2.9 diff -u -3 -r1.1.2.8 -r1.1.2.9 --- ecore_x_events.c 5 Feb 2003 00:10:19 -0000 1.1.2.8 +++ ecore_x_events.c 5 Feb 2003 06:51:57 -0000 1.1.2.9 @@ -2,11 +2,34 @@ #include "ecore_x_private.h" #include "Ecore_X.h" +static void _ecore_x_event_free_window_prop_name_class_change(void *ev, void *data); +static void _ecore_x_event_free_window_prop_title_change(void *ev, void *data); static void _ecore_x_event_free_key_down(void *ev, void *data); static void _ecore_x_event_free_key_up(void *ev, void *data); static void _ecore_x_event_free_generic(void *ev, void *data); static void +_ecore_x_event_free_window_prop_name_class_change(void *ev, void *data) +{ + Ecore_X_Event_Window_Prop_Name_Class_Change *e; + + e = ev; + if (e->name) free(e->name); + if (e->clas) free(e->clas); + free(e); +} + +static void +_ecore_x_event_free_window_prop_title_change(void *ev, void *data) +{ + Ecore_X_Event_Window_Prop_Title_Change *e; + + e = ev; + if (e->title) free(e->title); + free(e); +} + +static void _ecore_x_event_free_key_down(void *ev, void *data) { Ecore_X_Event_Key_Down *e; @@ -34,6 +57,7 @@ free(ev); } + void _ecore_x_event_handle_key_press(XEvent *xevent) { @@ -569,7 +593,25 @@ void _ecore_x_event_handle_property_notify(XEvent *xevent) { - /* FIXME: handle this event type */ + if (xevent->xproperty.atom == _ecore_x_atom_wm_class) + { + Ecore_X_Event_Window_Prop_Name_Class_Change *e; + + e = calloc(1, sizeof(Ecore_X_Event_Window_Prop_Name_Class_Change)); + if (!e) return; + ecore_x_window_prop_name_class_get(xevent->xproperty.window, + &(e->name), &(e->clas)); + ecore_event_add(ECORE_EVENT_X_WINDOW_PROP_NAME_CLASS_CHANGE, e, +_ecore_x_event_free_window_prop_name_class_change, NULL); + } + else if (xevent->xproperty.atom == _ecore_x_atom_wm_name) + { + Ecore_X_Event_Window_Prop_Title_Change *e; + + e = calloc(1, sizeof(Ecore_X_Event_Window_Prop_Title_Change)); + if (!e) return; + e->title = ecore_x_window_prop_title_get(xevent->xproperty.window); + ecore_event_add(ECORE_EVENT_X_WINDOW_PROP_TITLE_CHANGE, e, +_ecore_x_event_free_window_prop_title_change, NULL); + } } void =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/Attic/ecore_x_private.h,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -3 -r1.1.2.5 -r1.1.2.6 --- ecore_x_private.h 5 Feb 2003 00:10:19 -0000 1.1.2.5 +++ ecore_x_private.h 5 Feb 2003 06:51:57 -0000 1.1.2.6 @@ -19,6 +19,8 @@ extern Atom _ecore_x_atom_wm_delete_window; extern Atom _ecore_x_atom_wm_protocols; +extern Atom _ecore_x_atom_wm_class; +extern Atom _ecore_x_atom_wm_name; void _ecore_x_error_handler_init(void); void _ecore_x_event_handle_key_press(XEvent *xevent); =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/Attic/ecore_x_window_prop.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_window_prop.c 4 Feb 2003 09:15:52 -0000 1.1.2.2 +++ ecore_x_window_prop.c 5 Feb 2003 06:51:57 -0000 1.1.2.3 @@ -16,6 +16,44 @@ } /** + * Get a window title + * @param win + * @return The windows title + * + * Return the title of a window. String must be free'd when done with. + */ +char * +ecore_x_window_prop_title_get(Window win) +{ + XTextProperty xtp; + + if (XGetWMName(_ecore_x_disp, win, &xtp)) + { + int items; + char **list; + Status s; + char *title = NULL; + + if (xtp.format == 8) + { + s = XmbTextPropertyToTextList(_ecore_x_disp, &xtp, &list, &items); + if ((s == Success) && (items > 0)) + { + title = strdup(*list); + XFreeStringList(list); + } + else + title = strdup((char *)xtp.value); + } + else + title = strdup((char *)xtp.value); + XFree(xtp.value); + return title; + } + return NULL; +} + +/** * Set a window name & class * @param win * @param n @@ -34,6 +72,37 @@ xch->res_class = (char *)c; XSetClassHint(_ecore_x_disp, win, xch); XFree(xch); +} + +/** + * Get a window name & class + * @param win + * @param n + * @param c + * + * Get a windows name and class property. strings must be free'd when done + * with. + */ +void +ecore_x_window_prop_name_class_get(Window win, char **n, char **c) +{ + XClassHint xch; + + if (n) *n = NULL; + if (c) *c = NULL; + if (XGetClassHint(_ecore_x_disp, win, &xch)) + { + if (n) + { + if (xch.res_name) *n = strdup(xch.res_name); + } + if (c) + { + if (xch.res_class) *c = strdup(xch.res_class); + } + XFree(xch.res_name); + XFree(xch.res_class); + } } /** ------------------------------------------------------- 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