2010-01-16 04:20:56 -08:00
|
|
|
/*
|
|
|
|
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "Ecore.h"
|
|
|
|
#include "ecore_x_private.h"
|
|
|
|
#include "Ecore_X.h"
|
|
|
|
|
|
|
|
#ifdef ECORE_XI2
|
2010-01-18 21:13:58 -08:00
|
|
|
#include "Ecore_Input.h"
|
|
|
|
#endif
|
|
|
|
|
2010-01-16 04:20:56 -08:00
|
|
|
int _ecore_x_xi2_opcode = -1;
|
2010-01-17 00:52:38 -08:00
|
|
|
|
2010-01-18 21:13:58 -08:00
|
|
|
#ifdef ECORE_XI2
|
2010-01-17 00:52:38 -08:00
|
|
|
static XIDeviceInfo *_ecore_x_xi2_devs = NULL;
|
|
|
|
static int _ecore_x_xi2_num = 0;
|
2010-01-16 04:20:56 -08:00
|
|
|
#endif
|
|
|
|
|
2010-01-17 00:52:38 -08:00
|
|
|
void
|
|
|
|
_ecore_x_input_init(void)
|
2010-01-16 04:20:56 -08:00
|
|
|
{
|
|
|
|
#ifdef ECORE_XI2
|
2010-01-17 00:52:38 -08:00
|
|
|
int event, error;
|
|
|
|
int major = 2, minor = 0;
|
2010-01-16 04:20:56 -08:00
|
|
|
|
2010-01-17 00:52:38 -08:00
|
|
|
if (!XQueryExtension(_ecore_x_disp, "XInputExtension",
|
|
|
|
&_ecore_x_xi2_opcode, &event, &error))
|
2010-01-16 04:20:56 -08:00
|
|
|
{
|
2010-01-17 00:52:38 -08:00
|
|
|
_ecore_x_xi2_opcode = -1;
|
|
|
|
return;
|
|
|
|
}
|
2010-01-16 04:20:56 -08:00
|
|
|
|
2010-01-17 00:52:38 -08:00
|
|
|
if (XIQueryVersion(_ecore_x_disp, &major, &minor) == BadRequest)
|
|
|
|
{
|
|
|
|
_ecore_x_xi2_opcode = -1;
|
|
|
|
return;
|
2010-01-16 04:20:56 -08:00
|
|
|
}
|
2010-01-17 00:52:38 -08:00
|
|
|
_ecore_x_xi2_devs = XIQueryDevice(_ecore_x_disp, XIAllDevices,
|
|
|
|
&_ecore_x_xi2_num);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_ecore_x_input_shutdown(void)
|
|
|
|
{
|
|
|
|
#ifdef ECORE_XI2
|
|
|
|
if (_ecore_x_xi2_devs)
|
2010-01-16 04:20:56 -08:00
|
|
|
{
|
2010-01-17 00:52:38 -08:00
|
|
|
XIFreeDeviceInfo(_ecore_x_xi2_devs);
|
|
|
|
_ecore_x_xi2_devs = NULL;
|
2010-01-16 04:20:56 -08:00
|
|
|
}
|
2010-01-17 00:52:38 -08:00
|
|
|
_ecore_x_xi2_num = 0;
|
|
|
|
_ecore_x_xi2_opcode = -1;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-01-18 21:13:58 -08:00
|
|
|
void
|
|
|
|
_ecore_x_input_handler(XEvent* xevent)
|
|
|
|
{
|
|
|
|
#ifdef ECORE_XI2
|
|
|
|
XIDeviceEvent *evd = (XIDeviceEvent *)(xevent->xcookie.data);
|
|
|
|
int devid = evd->deviceid;
|
|
|
|
|
|
|
|
//printf("deviceID = %d\n", devid);
|
|
|
|
switch (xevent->xcookie.evtype)
|
|
|
|
{
|
|
|
|
case XI_Motion:
|
|
|
|
_ecore_mouse_move
|
|
|
|
(evd->time,
|
|
|
|
0, // state
|
|
|
|
evd->event_x, evd->event_y,
|
|
|
|
evd->root_x, evd->root_y,
|
|
|
|
evd->event,
|
|
|
|
(evd->child ? evd->child : evd->event),
|
|
|
|
evd->root,
|
|
|
|
1, // same_screen
|
|
|
|
devid, 1, 1,
|
|
|
|
1.0, // pressure
|
|
|
|
0.0, // angle
|
|
|
|
evd->event_x, evd->event_y,
|
|
|
|
evd->root_x, evd->root_y);
|
|
|
|
break;
|
|
|
|
case XI_ButtonPress:
|
|
|
|
_ecore_mouse_button
|
|
|
|
(ECORE_EVENT_MOUSE_BUTTON_DOWN,
|
|
|
|
evd->time,
|
|
|
|
0, // state
|
|
|
|
0, // button
|
|
|
|
evd->event_x, evd->event_y,
|
|
|
|
evd->root_x, evd->root_y,
|
|
|
|
evd->event,
|
|
|
|
(evd->child ? evd->child : evd->event),
|
|
|
|
evd->root,
|
|
|
|
1, // same_screen
|
|
|
|
devid, 1, 1,
|
|
|
|
1.0, // pressure
|
|
|
|
0.0, // angle
|
|
|
|
evd->event_x, evd->event_y,
|
|
|
|
evd->root_x, evd->root_y);
|
|
|
|
break;
|
|
|
|
case XI_ButtonRelease:
|
|
|
|
_ecore_mouse_button
|
|
|
|
(ECORE_EVENT_MOUSE_BUTTON_UP,
|
|
|
|
evd->time,
|
|
|
|
0, // state
|
|
|
|
0, // button
|
|
|
|
evd->event_x, evd->event_y,
|
|
|
|
evd->root_x, evd->root_y,
|
|
|
|
evd->event,
|
|
|
|
(evd->child ? evd->child : evd->event),
|
|
|
|
evd->root,
|
|
|
|
1, // same_screen
|
|
|
|
devid, 1, 1,
|
|
|
|
1.0, // pressure
|
|
|
|
0.0, // angle
|
|
|
|
evd->event_x, evd->event_y,
|
|
|
|
evd->root_x, evd->root_y);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-01-17 00:52:38 -08:00
|
|
|
EAPI Eina_Bool
|
|
|
|
ecore_x_input_multi_select(Ecore_X_Window win)
|
|
|
|
{
|
|
|
|
#ifdef ECORE_XI2
|
|
|
|
int i, find = 0;
|
2010-01-17 11:57:50 -08:00
|
|
|
|
2010-01-17 00:52:38 -08:00
|
|
|
if (!_ecore_x_xi2_devs) return 0;
|
2010-01-16 04:20:56 -08:00
|
|
|
|
2010-01-17 11:57:50 -08:00
|
|
|
for (i = 0; i < _ecore_x_xi2_num; i++)
|
2010-01-16 04:20:56 -08:00
|
|
|
{
|
2010-01-17 00:52:38 -08:00
|
|
|
XIDeviceInfo *dev = &(_ecore_x_xi2_devs[i]);
|
2010-01-17 11:57:50 -08:00
|
|
|
|
2010-01-17 00:52:38 -08:00
|
|
|
if (dev->use == XIFloatingSlave)
|
2010-01-16 04:20:56 -08:00
|
|
|
{
|
2010-01-17 00:52:38 -08:00
|
|
|
XIEventMask eventmask;
|
|
|
|
unsigned char mask[1] = { 0 };
|
2010-01-17 11:57:50 -08:00
|
|
|
|
2010-01-17 00:52:38 -08:00
|
|
|
eventmask.deviceid = dev->deviceid;
|
|
|
|
eventmask.mask_len = sizeof(mask);
|
|
|
|
eventmask.mask = mask;
|
|
|
|
XISetMask(mask, XI_ButtonPress);
|
|
|
|
XISetMask(mask, XI_ButtonRelease);
|
|
|
|
XISetMask(mask, XI_Motion);
|
|
|
|
XISelectEvents(_ecore_x_disp, win, &eventmask, 1);
|
|
|
|
find = 1;
|
2010-01-16 04:20:56 -08:00
|
|
|
}
|
|
|
|
}
|
2010-01-17 11:57:50 -08:00
|
|
|
|
2010-01-16 04:20:56 -08:00
|
|
|
return find;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|