summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--configure.ac4
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_xi2.c216
3 files changed, 216 insertions, 5 deletions
diff --git a/AUTHORS b/AUTHORS
index a4bffc569c..44ad2de304 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -185,6 +185,7 @@ Alexey Yakovenko <wakeroid@gmail.com>
185Myoungwoon Roy Kim(roy_kim) <myoungwoon.kim@samsung.com> <myoungwoon@gmail.com> 185Myoungwoon Roy Kim(roy_kim) <myoungwoon.kim@samsung.com> <myoungwoon@gmail.com>
186Robert David <robert.david.public@gmail.com> 186Robert David <robert.david.public@gmail.com>
187Gwanglim Lee <gl77.lee@samsung.com> <gwanglim@gmail.com> 187Gwanglim Lee <gl77.lee@samsung.com> <gwanglim@gmail.com>
188Sung-Jin Park <sj76.park@samsung.com>
188 189
189Embryo 190Embryo
190------ 191------
diff --git a/configure.ac b/configure.ac
index ce4045fd0e..525456d981 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3381,7 +3381,8 @@ if test "x${have_ecore_x_xlib}" = "xyes" ; then
3381 ECORE_CHECK_X_EXTENSION([Xtest], [XTest.h], [Xtst], [XTestFakeKeyEvent], [$want_ecore_x_xtest]) 3381 ECORE_CHECK_X_EXTENSION([Xtest], [XTest.h], [Xtst], [XTestFakeKeyEvent], [$want_ecore_x_xtest])
3382 ECORE_CHECK_X_EXTENSION([Xss], [scrnsaver.h], [Xss], [XScreenSaverSelectInput], [$want_ecore_x_screensaver]) 3382 ECORE_CHECK_X_EXTENSION([Xss], [scrnsaver.h], [Xss], [XScreenSaverSelectInput], [$want_ecore_x_screensaver])
3383 ECORE_CHECK_X_EXTENSION([Xi2], [XInput2.h], [Xi], [XIQueryDevice], [$want_ecore_x_input]) 3383 ECORE_CHECK_X_EXTENSION([Xi2], [XInput2.h], [Xi], [XIQueryDevice], [$want_ecore_x_input])
3384 3384 ECORE_CHECK_X_EXTENSION([Xi2_2], [XInput2.h], [Xi], [XIGrabTouchBegin], [$want_ecore_x_input])
3385
3385 AC_DEFINE([HAVE_ECORE_X_XLIB], [1], [Defined to 1 if Xlib is enabled.]) 3386 AC_DEFINE([HAVE_ECORE_X_XLIB], [1], [Defined to 1 if Xlib is enabled.])
3386fi 3387fi
3387 3388
@@ -4400,6 +4401,7 @@ if test "x$have_ecore_x" = "xyes" ; then
4400 echo " Xtest......................: $use_xtest" 4401 echo " Xtest......................: $use_xtest"
4401 echo " XIM........................: $want_xim" 4402 echo " XIM........................: $want_xim"
4402 echo " Xi2........................: $use_xi2" 4403 echo " Xi2........................: $use_xi2"
4404 echo " Xi2.2......................: $use_xi2_2"
4403 fi 4405 fi
4404else 4406else
4405 echo " Ecore_X....................: $have_ecore_x" 4407 echo " Ecore_X....................: $have_ecore_x"
diff --git a/src/lib/ecore_x/xlib/ecore_x_xi2.c b/src/lib/ecore_x/xlib/ecore_x_xi2.c
index 04d1023ec7..5284b80aea 100644
--- a/src/lib/ecore_x/xlib/ecore_x_xi2.c
+++ b/src/lib/ecore_x/xlib/ecore_x_xi2.c
@@ -19,8 +19,23 @@ int _ecore_x_xi2_opcode = -1;
19#endif 19#endif
20 20
21#ifdef ECORE_XI2 21#ifdef ECORE_XI2
22#ifdef ECORE_XI2_2
23typedef struct _Ecore_X_Touch_Device_Info
24{
25 EINA_INLIST;
26 int devid;
27 int mode;
28 const char *name;
29 int max_touch;
30 int *slot;
31} Ecore_X_Touch_Device_Info;
32#endif /* ifdef ECORE_XI2_2 */
33
22static XIDeviceInfo *_ecore_x_xi2_devs = NULL; 34static XIDeviceInfo *_ecore_x_xi2_devs = NULL;
23static int _ecore_x_xi2_num = 0; 35static int _ecore_x_xi2_num = 0;
36#ifdef ECORE_XI2_2
37static Eina_Inlist *_ecore_x_xi2_touch_info_list = NULL;
38#endif /* ifdef ECORE_XI2_2 */
24#endif /* ifdef ECORE_XI2 */ 39#endif /* ifdef ECORE_XI2 */
25 40
26void 41void
@@ -28,7 +43,7 @@ _ecore_x_input_init(void)
28{ 43{
29#ifdef ECORE_XI2 44#ifdef ECORE_XI2
30 int event, error; 45 int event, error;
31 int major = 2, minor = 0; 46 int major = XI_2_Major, minor = XI_2_Minor;
32 47
33 if (!XQueryExtension(_ecore_x_disp, "XInputExtension", 48 if (!XQueryExtension(_ecore_x_disp, "XInputExtension",
34 &_ecore_x_xi2_opcode, &event, &error)) 49 &_ecore_x_xi2_opcode, &event, &error))
@@ -48,6 +63,26 @@ _ecore_x_input_init(void)
48#endif /* ifdef ECORE_XI2 */ 63#endif /* ifdef ECORE_XI2 */
49} 64}
50 65
66#ifdef ECORE_XI2
67#ifdef ECORE_XI2_2
68static void
69_ecore_x_input_touch_info_clear(void)
70{
71 Eina_Inlist *l = _ecore_x_xi2_touch_info_list;
72 Ecore_X_Touch_Device_Info *info = NULL;
73
74 while (l)
75 {
76 info = EINA_INLIST_CONTAINER_GET(l, Ecore_X_Touch_Device_Info);
77 l = eina_inlist_remove(l, l);
78 free(info);
79 }
80
81 _ecore_x_xi2_touch_info_list = NULL;
82}
83#endif /* ifdef ECORE_XI2_2 */
84#endif /* ifdef ECORE_XI2 */
85
51void 86void
52_ecore_x_input_shutdown(void) 87_ecore_x_input_shutdown(void)
53{ 88{
@@ -56,6 +91,9 @@ _ecore_x_input_shutdown(void)
56 { 91 {
57 XIFreeDeviceInfo(_ecore_x_xi2_devs); 92 XIFreeDeviceInfo(_ecore_x_xi2_devs);
58 _ecore_x_xi2_devs = NULL; 93 _ecore_x_xi2_devs = NULL;
94#ifdef ECORE_XI2_2
95 _ecore_x_input_touch_info_clear();
96#endif /* ifdef ECORE_XI2_2 */
59 } 97 }
60 98
61 _ecore_x_xi2_num = 0; 99 _ecore_x_xi2_num = 0;
@@ -63,6 +101,107 @@ _ecore_x_input_shutdown(void)
63#endif /* ifdef ECORE_XI2 */ 101#endif /* ifdef ECORE_XI2 */
64} 102}
65 103
104#ifdef ECORE_XI2
105#ifdef ECORE_XI2_2
106static int
107_ecore_x_input_touch_index_get(int devid, int detail, int event_type)
108{
109 int i;
110 Eina_Inlist *l = _ecore_x_xi2_touch_info_list;
111 Ecore_X_Touch_Device_Info *info = NULL;
112
113 if ((!_ecore_x_xi2_devs) || (!_ecore_x_xi2_touch_info_list))
114 return 0;
115
116 EINA_INLIST_FOREACH(l, info)
117 if (info->devid == devid) break;
118
119 if ((!info) || (!info->slot)) return 0;
120
121 for (i = 0; i < info->max_touch ; i++)
122 {
123 int *p = &(info->slot[i]);
124
125 if ((event_type == XI_TouchBegin) && (*p < 0))
126 {
127 *p = detail;
128 return i;
129 }
130 else if (*p == detail)
131 {
132 return i;
133 }
134 }
135
136 return 0;
137}
138
139static void
140_ecore_x_input_touch_index_clear(int devid, int idx)
141{
142 Eina_Inlist *l = _ecore_x_xi2_touch_info_list;
143 Ecore_X_Touch_Device_Info *info = NULL;
144
145 if ((!_ecore_x_xi2_devs) || (!_ecore_x_xi2_touch_info_list))
146 return;
147
148 EINA_INLIST_FOREACH(l, info)
149 {
150 if ((info->devid == devid) && (info->slot))
151 {
152 info->slot[idx] = -1;
153 return;
154 }
155 }
156}
157
158static Ecore_X_Touch_Device_Info*
159_ecore_x_input_touch_info_get(XIDeviceInfo* dev)
160{
161 int k;
162 int *slot = NULL;
163 XITouchClassInfo *t = NULL;
164 Ecore_X_Touch_Device_Info *info = NULL;
165
166 if (!dev)
167 return NULL;
168
169 for (k = 0; k < dev->num_classes; k++)
170 {
171 XIAnyClassInfo *class = dev->classes[k];
172
173 if (class && (class->type == XITouchClass))
174 {
175 t = (XITouchClassInfo*)class;
176 break;
177 }
178 }
179
180 if (t && (t->type == XITouchClass))
181 {
182 info = calloc(1, sizeof(Ecore_X_Touch_Device_Info));
183 if (!info) return NULL;
184
185 slot = (int*)malloc(sizeof(int)*(t->num_touches + 1));
186 if (!slot)
187 {
188 free(info);
189 return NULL;
190 }
191
192 info->devid = dev->deviceid;
193 info->max_touch = t->num_touches + 1;
194 info->mode = t->mode;
195 info->name = dev->name;
196 memset(slot, -1, sizeof(int)*info->max_touch);
197 info->slot = slot;
198 }
199
200 return info;
201}
202#endif /* ifdef ECORE_XI2_2 */
203#endif
204
66void 205void
67_ecore_x_input_handler(XEvent *xevent) 206_ecore_x_input_handler(XEvent *xevent)
68{ 207{
@@ -165,6 +304,9 @@ _ecore_x_input_handler(XEvent *xevent)
165 304
166#ifdef XI_TouchUpdate 305#ifdef XI_TouchUpdate
167 case XI_TouchUpdate: 306 case XI_TouchUpdate:
307#ifdef ECORE_XI2_2
308 i = _ecore_x_input_touch_index_get(devid, evd->detail, XI_TouchUpdate);
309#endif /* #ifdef ECORE_XI2_2 */
168 _ecore_mouse_move 310 _ecore_mouse_move
169 (evd->time, 311 (evd->time,
170 0, // state 312 0, // state
@@ -174,16 +316,23 @@ _ecore_x_input_handler(XEvent *xevent)
174 (evd->child ? evd->child : evd->event), 316 (evd->child ? evd->child : evd->event),
175 evd->root, 317 evd->root,
176 1, // same_screen 318 1, // same_screen
319#ifdef ECORE_XI2_2
320 i, 1, 1,
321#else
177 devid, 1, 1, 322 devid, 1, 1,
323#endif /* #ifdef ECORE_XI2_2 */
178 1.0, // pressure 324 1.0, // pressure
179 0.0, // angle 325 0.0, // angle
180 evd->event_x, evd->event_y, 326 evd->event_x, evd->event_y,
181 evd->root_x, evd->root_y); 327 evd->root_x, evd->root_y);
182 break; 328 break;
183
184#endif 329#endif
330
185#ifdef XI_TouchBegin 331#ifdef XI_TouchBegin
186 case XI_TouchBegin: 332 case XI_TouchBegin:
333#ifdef ECORE_XI2_2
334 i = _ecore_x_input_touch_index_get(devid, evd->detail, XI_TouchBegin);
335#endif /* #ifdef ECORE_XI2_2 */
187 _ecore_mouse_button 336 _ecore_mouse_button
188 (ECORE_EVENT_MOUSE_BUTTON_DOWN, 337 (ECORE_EVENT_MOUSE_BUTTON_DOWN,
189 evd->time, 338 evd->time,
@@ -195,16 +344,23 @@ _ecore_x_input_handler(XEvent *xevent)
195 (evd->child ? evd->child : evd->event), 344 (evd->child ? evd->child : evd->event),
196 evd->root, 345 evd->root,
197 1, // same_screen 346 1, // same_screen
347#ifdef ECORE_XI2_2
348 i, 1, 1,
349#else
198 devid, 1, 1, 350 devid, 1, 1,
351#endif /* #ifdef ECORE_XI2_2 */
199 1.0, // pressure 352 1.0, // pressure
200 0.0, // angle 353 0.0, // angle
201 evd->event_x, evd->event_y, 354 evd->event_x, evd->event_y,
202 evd->root_x, evd->root_y); 355 evd->root_x, evd->root_y);
203 break; 356 break;
204
205#endif 357#endif
358
206#ifdef XI_TouchEnd 359#ifdef XI_TouchEnd
207 case XI_TouchEnd: 360 case XI_TouchEnd:
361#ifdef ECORE_XI2_2
362 i = _ecore_x_input_touch_index_get(devid, evd->detail, XI_TouchEnd);
363#endif /* #ifdef ECORE_XI2_2 */
208 _ecore_mouse_button 364 _ecore_mouse_button
209 (ECORE_EVENT_MOUSE_BUTTON_UP, 365 (ECORE_EVENT_MOUSE_BUTTON_UP,
210 evd->time, 366 evd->time,
@@ -216,14 +372,21 @@ _ecore_x_input_handler(XEvent *xevent)
216 (evd->child ? evd->child : evd->event), 372 (evd->child ? evd->child : evd->event),
217 evd->root, 373 evd->root,
218 1, // same_screen 374 1, // same_screen
375#ifdef ECORE_XI2_2
376 i, 1, 1,
377#else
219 devid, 1, 1, 378 devid, 1, 1,
379#endif /* #ifdef ECORE_XI2_2 */
220 1.0, // pressure 380 1.0, // pressure
221 0.0, // angle 381 0.0, // angle
222 evd->event_x, evd->event_y, 382 evd->event_x, evd->event_y,
223 evd->root_x, evd->root_y); 383 evd->root_x, evd->root_y);
384#ifdef ECORE_XI2_2
385 _ecore_x_input_touch_index_clear(devid, i);
386#endif /* #ifdef ECORE_XI2_2 */
224 break; 387 break;
225
226#endif 388#endif
389
227 default: 390 default:
228 break; 391 break;
229 } 392 }
@@ -281,6 +444,21 @@ ecore_x_input_multi_select(Ecore_X_Window win)
281 XISetMask(mask, XI_ButtonPress); 444 XISetMask(mask, XI_ButtonPress);
282 XISetMask(mask, XI_ButtonRelease); 445 XISetMask(mask, XI_ButtonRelease);
283 XISetMask(mask, XI_Motion); 446 XISetMask(mask, XI_Motion);
447#ifdef ECORE_XI2_2
448 Eina_Inlist *l = _ecore_x_xi2_touch_info_list;
449 Ecore_X_Touch_Device_Info *info;
450 info = _ecore_x_input_touch_info_get(dev);
451
452 if (info)
453 {
454 XISetMask(mask, XI_TouchUpdate);
455 XISetMask(mask, XI_TouchBegin);
456 XISetMask(mask, XI_TouchEnd);
457
458 l = eina_inlist_append(l, (Eina_Inlist *)info);
459 _ecore_x_xi2_touch_info_list = l;
460 }
461#else
284# ifdef XI_TouchUpdate 462# ifdef XI_TouchUpdate
285 XISetMask(mask, XI_TouchUpdate); 463 XISetMask(mask, XI_TouchUpdate);
286# endif 464# endif
@@ -290,9 +468,39 @@ ecore_x_input_multi_select(Ecore_X_Window win)
290# ifdef XI_TouchEnd 468# ifdef XI_TouchEnd
291 XISetMask(mask, XI_TouchEnd); 469 XISetMask(mask, XI_TouchEnd);
292# endif 470# endif
471#endif /* #ifdef ECORE_XI2_2 */
472
293 XISelectEvents(_ecore_x_disp, win, &eventmask, 1); 473 XISelectEvents(_ecore_x_disp, win, &eventmask, 1);
294 find = EINA_TRUE; 474 find = EINA_TRUE;
295 } 475 }
476#ifdef ECORE_XI2_2
477 else if ((atdev) && (atdev->use == XIMasterPointer))
478 {
479 Eina_Inlist *l = _ecore_x_xi2_touch_info_list;
480 Ecore_X_Touch_Device_Info *info;
481 info = _ecore_x_input_touch_info_get(dev);
482
483 if (info)
484 {
485 XIEventMask eventmask;
486 unsigned char mask[4] = { 0 };
487
488 eventmask.deviceid = dev->deviceid;
489 eventmask.mask_len = sizeof(mask);
490 eventmask.mask = mask;
491
492 XISetMask(mask, XI_TouchUpdate);
493 XISetMask(mask, XI_TouchBegin);
494 XISetMask(mask, XI_TouchEnd);
495 XISelectEvents(_ecore_x_disp, win, &eventmask, 1);
496
497 l = eina_inlist_append(l, (Eina_Inlist *)info);
498 _ecore_x_xi2_touch_info_list = l;
499
500 find = EINA_TRUE;
501 }
502 }
503#endif /* #ifdef ECORE_XI2_2 */
296 } 504 }
297 } 505 }
298 506