summaryrefslogtreecommitdiff
path: root/src/lib/ecore_x
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-08-25 17:54:04 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-08-26 10:18:01 +0900
commit60526528a6cc85050a74d5d45f6502ea5c07d70f (patch)
treea7dcd52c66f6b71d501de65da0280b5dc4ccd593 /src/lib/ecore_x
parent443aa91d5352810c24403281dffad96f0472b368 (diff)
evas: Add normalized and window coordinates to axis events
This is for Wacom graphics tablets (with a pen). The raw data sent by ecore to evas (and then to apps) is pretty useless as it's not normalized, and apps have no way of knowing the dimensions of the tablet, without themselves opening the device (we don't know nor expose the path to the device). This is for Xi2 only for now, as Wayland support hasn't been done yet. The intent is to deprecate LABEL_X and LABEL_Y. I'm not sure yet if the normalized value is useful or not (it would seem we may not be able to provide this info in Wayland). The new WINDOW_X, WINDOW_Y labels will be used in the new event type (Efl.Event.Pointer). Normalized values are not exposed yet, let's decide if we want them or not first (based on what can be done in Wayland space). @feature
Diffstat (limited to 'src/lib/ecore_x')
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_xi2.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/lib/ecore_x/xlib/ecore_x_xi2.c b/src/lib/ecore_x/xlib/ecore_x_xi2.c
index be19de2c94..089c2a7029 100644
--- a/src/lib/ecore_x/xlib/ecore_x_xi2.c
+++ b/src/lib/ecore_x/xlib/ecore_x_xi2.c
@@ -494,7 +494,7 @@ _ecore_x_input_axis_handler(XEvent *xevent, XIDeviceInfo *dev)
494{ 494{
495 if (xevent->type != GenericEvent) return; 495 if (xevent->type != GenericEvent) return;
496 XIDeviceEvent *evd = (XIDeviceEvent *)(xevent->xcookie.data); 496 XIDeviceEvent *evd = (XIDeviceEvent *)(xevent->xcookie.data);
497 unsigned int n = _ecore_x_count_bits(*evd->valuators.mask); 497 unsigned int n = _ecore_x_count_bits(*evd->valuators.mask) + 4;
498 int i; 498 int i;
499 int j = 0; 499 int j = 0;
500 double tiltx = 0, tilty = 0; 500 double tiltx = 0, tilty = 0;
@@ -514,15 +514,29 @@ _ecore_x_input_axis_handler(XEvent *xevent, XIDeviceInfo *dev)
514 { 514 {
515 if (inf->label == _ecore_x_input_get_axis_label("Abs X")) 515 if (inf->label == _ecore_x_input_get_axis_label("Abs X"))
516 { 516 {
517 int x = evd->valuators.values[j];
517 axis_ptr->label = ECORE_AXIS_LABEL_X; 518 axis_ptr->label = ECORE_AXIS_LABEL_X;
518 axis_ptr->value = evd->valuators.values[j]; 519 axis_ptr->value = x;
519 axis_ptr++; 520 axis_ptr++;
521 if (inf->max > inf->min)
522 {
523 axis_ptr->label = ECORE_AXIS_LABEL_NORMAL_X;
524 axis_ptr->value = (x - inf->min) / (inf->max - inf->min);
525 axis_ptr++;
526 }
520 } 527 }
521 else if (inf->label == _ecore_x_input_get_axis_label("Abs Y")) 528 else if (inf->label == _ecore_x_input_get_axis_label("Abs Y"))
522 { 529 {
530 int y = evd->valuators.values[j];
523 axis_ptr->label = ECORE_AXIS_LABEL_Y; 531 axis_ptr->label = ECORE_AXIS_LABEL_Y;
524 axis_ptr->value = evd->valuators.values[j]; 532 axis_ptr->value = y;
525 axis_ptr++; 533 axis_ptr++;
534 if (inf->max > inf->min)
535 {
536 axis_ptr->label = ECORE_AXIS_LABEL_NORMAL_Y;
537 axis_ptr->value = (y - inf->min) / (inf->max - inf->min);
538 axis_ptr++;
539 }
526 } 540 }
527 else if (inf->label == _ecore_x_input_get_axis_label("Abs Pressure")) 541 else if (inf->label == _ecore_x_input_get_axis_label("Abs Pressure"))
528 { 542 {
@@ -602,6 +616,15 @@ _ecore_x_input_axis_handler(XEvent *xevent, XIDeviceInfo *dev)
602 n = (axis_ptr - axis); 616 n = (axis_ptr - axis);
603 if (n > 0) 617 if (n > 0)
604 { 618 {
619 /* event position in the window - most useful */
620 axis_ptr->label = ECORE_AXIS_LABEL_WINDOW_X;
621 axis_ptr->value = evd->event_x;
622 axis_ptr++;
623 axis_ptr->label = ECORE_AXIS_LABEL_WINDOW_Y;
624 axis_ptr->value = evd->event_y;
625 axis_ptr++;
626 n += 2;
627
605 shrunk_axis = realloc(axis, n * sizeof(Ecore_Axis)); 628 shrunk_axis = realloc(axis, n * sizeof(Ecore_Axis));
606 if (shrunk_axis != NULL) axis = shrunk_axis; 629 if (shrunk_axis != NULL) axis = shrunk_axis;
607 _ecore_x_axis_update(evd->child ? evd->child : evd->event, 630 _ecore_x_axis_update(evd->child ? evd->child : evd->event,