Enlightenment CVS committal
Author : raster
Project : e17
Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore_x
Modified Files:
Ecore_X.h ecore_x.c ecore_x_events.c ecore_x_private.h
Log Message:
button grabs... a start...
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/Ecore_X.h,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -3 -r1.80 -r1.81
--- Ecore_X.h 29 Nov 2004 23:25:10 -0000 1.80
+++ Ecore_X.h 4 Dec 2004 03:54:04 -0000 1.81
@@ -1152,7 +1152,15 @@
ecore_x_grab(void);
EAPI void
ecore_x_ungrab(void);
-
+ EAPI void
+ ecore_x_passive_grab_replay_func_set(int (*func) (void *data, int
event_type, void *event), void *data);
+ EAPI void
+ ecore_x_window_button_grab(Ecore_X_Window win, int button,
+ Ecore_X_Event_Mask event_mask,
+ int mod, int any_mod);
+ EAPI void
+ ecore_x_window_button_ungrab(Ecore_X_Window win, int button,
+ int mod, int any_mod);
#ifdef __cplusplus
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/ecore_x.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -3 -r1.51 -r1.52
--- ecore_x.c 29 Nov 2004 22:26:33 -0000 1.51
+++ ecore_x.c 4 Dec 2004 03:54:04 -0000 1.52
@@ -1180,6 +1180,82 @@
}
}
+int _ecore_window_grabs_num = 0;
+Window *_ecore_window_grabs = NULL;
+int (*_ecore_window_grab_replay_func) (void *data, int event_type, void
*event);
+void *_ecore_window_grab_replay_data;
+
+void
+ecore_x_passive_grab_replay_func_set(int (*func) (void *data, int event_type,
void *event), void *data)
+{
+ _ecore_window_grab_replay_func = func;
+ _ecore_window_grab_replay_data = data;
+}
+
+void
+ecore_x_window_button_grab(Ecore_X_Window win, int button,
+ Ecore_X_Event_Mask event_mask,
+ int mod, int any_mod)
+{
+ unsigned int b;
+ unsigned int m;
+ unsigned int locks[8];
+ int i, ev;
+
+ b = button;
+ if (b == 0) b = AnyButton;
+ m = mod;
+ if (any_mod) m = AnyModifier;
+ locks[0] = 0;
+ locks[1] = ECORE_X_LOCK_CAPS;
+ locks[2] = ECORE_X_LOCK_NUM;
+ locks[3] = ECORE_X_LOCK_SCROLL;
+ locks[4] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM;
+ locks[5] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_SCROLL;
+ locks[6] = ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
+ locks[7] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
+ ev = event_mask;
+ for (i = 0; i < 8; i++)
+ XGrabButton(_ecore_x_disp, b, m | locks[i],
+ win, False, ev, GrabModeSync, GrabModeAsync, None, None);
+ _ecore_window_grabs_num++;
+ _ecore_window_grabs = realloc(_ecore_window_grabs,
+ _ecore_window_grabs_num * sizeof(Window));
+ _ecore_window_grabs[_ecore_window_grabs_num - 1] = win;
+}
+
+void
+ecore_x_window_button_ungrab(Ecore_X_Window win, int button,
+ int mod, int any_mod)
+{
+ unsigned int b;
+ unsigned int m;
+ unsigned int locks[8];
+ int i, ev, shuffle = 0;
+
+ b = button;
+ if (b == 0) b = AnyButton;
+ m = mod;
+ if (any_mod) m = AnyModifier;
+ locks[0] = 0;
+ locks[1] = ECORE_X_LOCK_CAPS;
+ locks[2] = ECORE_X_LOCK_NUM;
+ locks[3] = ECORE_X_LOCK_SCROLL;
+ locks[4] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM;
+ locks[5] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_SCROLL;
+ locks[6] = ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
+ locks[7] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
+ for (i = 0; i < 8; i++)
+ XUngrabButton(_ecore_x_disp, b, m | locks[i], win);
+ for (i = 0; i < _ecore_window_grabs_num - 1; i++)
+ {
+ if (_ecore_window_grabs[i] == win) shuffle = 1;
+ if (shuffle) _ecore_window_grabs[i] = _ecore_window_grabs[i + 1];
+ }
+ _ecore_window_grabs_num--;
+ _ecore_window_grabs = realloc(_ecore_window_grabs,
+ _ecore_window_grabs_num * sizeof(Window));
+}
/**
* Send client message with given type and format 32.
===================================================================
RCS file:
/cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/ecore_x_events.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -3 -r1.38 -r1.39
--- ecore_x_events.c 29 Nov 2004 22:26:37 -0000 1.38
+++ ecore_x_events.c 4 Dec 2004 03:54:04 -0000 1.39
@@ -256,38 +256,61 @@
static Time last_time = 0;
static Time last_last_time = 0;
int did_triple = 0;
-
+ int i;
+
if ((xevent->xbutton.button > 3) && (xevent->xbutton.button < 6))
{
- Ecore_X_Event_Mouse_Wheel *e;
-
- e = malloc(sizeof(Ecore_X_Event_Mouse_Wheel));
-
- if (!e)
- return;
-
- e->modifiers = 0;
- e->direction = 0;
- e->z = 0;
- if (xevent->xbutton.button == 4) e->z = -1;
- else if (xevent->xbutton.button == 5) e->z = 1;
- e->x = xevent->xbutton.x;
- e->y = xevent->xbutton.y;
- e->root.x = xevent->xbutton.x_root;
+ Ecore_X_Event_Mouse_Wheel *e;
+
+ e = malloc(sizeof(Ecore_X_Event_Mouse_Wheel));
+
+ if (!e)
+ return;
+
+ e->modifiers = 0;
+ e->direction = 0;
+ e->z = 0;
+ if (xevent->xbutton.button == 4) e->z = -1;
+ else if (xevent->xbutton.button == 5) e->z = 1;
+ e->x = xevent->xbutton.x;
+ e->y = xevent->xbutton.y;
+ e->root.x = xevent->xbutton.x_root;
e->root.y = xevent->xbutton.y_root;
-
- 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_X_EVENT_MOUSE_WHEEL, e, NULL, NULL);
+
+ 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_X_EVENT_MOUSE_WHEEL, e, NULL, NULL);
+ for (i = 0; i < _ecore_window_grabs_num; i++)
+ {
+ if ((_ecore_window_grabs[i] == xevent->xbutton.window) ||
+ (_ecore_window_grabs[i] == xevent->xbutton.subwindow))
+ {
+ int replay = 0;
+
+ if (_ecore_window_grab_replay_func)
+ replay =
_ecore_window_grab_replay_func(_ecore_window_grab_replay_data,
+
ECORE_X_EVENT_MOUSE_WHEEL,
+ e);
+ if (replay)
+ XAllowEvents(xevent->xbutton.display,
+ ReplayPointer,
+ xevent->xbutton.time);
+ else
+ XAllowEvents(xevent->xbutton.display,
+ AsyncPointer,
+ xevent->xbutton.time);
+ break;
+ }
+ }
}
else
{
@@ -344,6 +367,28 @@
_ecore_x_event_last_root_x = e->root.x;
_ecore_x_event_last_root_y = e->root.y;
ecore_event_add(ECORE_X_EVENT_MOUSE_BUTTON_DOWN, e, NULL, NULL);
+ for (i = 0; i < _ecore_window_grabs_num; i++)
+ {
+ if ((_ecore_window_grabs[i] == xevent->xbutton.window) ||
+ (_ecore_window_grabs[i] == xevent->xbutton.subwindow))
+ {
+ int replay = 0;
+
+ if (_ecore_window_grab_replay_func)
+ replay =
_ecore_window_grab_replay_func(_ecore_window_grab_replay_data,
+
ECORE_X_EVENT_MOUSE_BUTTON_DOWN,
+ e);
+ if (replay)
+ XAllowEvents(xevent->xbutton.display,
+ ReplayPointer,
+ xevent->xbutton.time);
+ else
+ XAllowEvents(xevent->xbutton.display,
+ AsyncPointer,
+ xevent->xbutton.time);
+ break;
+ }
+ }
}
if (did_triple)
{
===================================================================
RCS file:
/cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/ecore_x_private.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -3 -r1.31 -r1.32
--- ecore_x_private.h 23 Nov 2004 15:17:56 -0000 1.31
+++ ecore_x_private.h 4 Dec 2004 03:54:04 -0000 1.32
@@ -230,6 +230,11 @@
extern Atom _ecore_x_atom_xdnd_drop;
extern Atom _ecore_x_atom_xdnd_finished;
+extern int _ecore_window_grabs_num;
+extern Window *_ecore_window_grabs;
+extern int (*_ecore_window_grab_replay_func) (void *data, int event_type,
void *event);
+extern void *_ecore_window_grab_replay_data;
+
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);
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs