forked from enlightenment/efl
parent
0f8510fbf1
commit
23f1dc55f4
|
@ -1152,7 +1152,15 @@ EAPI int ecore_x_client_message8_send(Ecore_X_Window win, Ecore_X_A
|
|||
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
|
||||
}
|
||||
|
|
|
@ -1180,6 +1180,82 @@ ecore_x_ungrab(void)
|
|||
}
|
||||
}
|
||||
|
||||
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.
|
||||
|
|
|
@ -256,38 +256,61 @@ _ecore_x_event_handle_button_press(XEvent *xevent)
|
|||
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_handle_button_press(XEvent *xevent)
|
|||
_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)
|
||||
{
|
||||
|
|
|
@ -230,6 +230,11 @@ extern Atom _ecore_x_atom_xdnd_leave;
|
|||
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);
|
||||
|
|
Loading…
Reference in New Issue