summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-08-24 17:44:32 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-08-26 10:18:01 +0900
commit7b25619213ead0d39001ce57320075b69fccdec2 (patch)
tree5c7b3a1e857c5cab62dd835e0a9f08fc42854937 /src
parent925878e931a46212f47be805abdf5b09b810dad4 (diff)
ecore xi2: Discard "axis" inputs from standard mice
Mice in X with xi2 send Axis events which are badly defined, and carry basically useless information, as we also receive proper mouse events. Notably, all mice input events are "Rel something" but in fact they are absolute values (even the wheel information is a counter increasing every time you scroll). This should not break any application as such axis events carried only values with label ECORE_AXIS_LABEL_UNKNOWN. This also fixes a leak when n == 0 (no "valuator" found in the list, this used to be unlikely, now happens at every mouse event).
Diffstat (limited to 'src')
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_xi2.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/lib/ecore_x/xlib/ecore_x_xi2.c b/src/lib/ecore_x/xlib/ecore_x_xi2.c
index b6e4519..be19de2 100644
--- a/src/lib/ecore_x/xlib/ecore_x_xi2.c
+++ b/src/lib/ecore_x/xlib/ecore_x_xi2.c
@@ -99,12 +99,13 @@ _ecore_x_input_get_axis_label(char *axis_name)
99 { 99 {
100 "Abs X", "Abs Y", "Abs Pressure", 100 "Abs X", "Abs Y", "Abs Pressure",
101 "Abs Distance", "Abs Rotary Z", 101 "Abs Distance", "Abs Rotary Z",
102 "Abs Wheel", "Abs Tilt X", "Abs Tilt Y" 102 "Abs Wheel", "Abs Tilt X", "Abs Tilt Y",
103 "Rel X", "Rel Y", "Rel Dial", "Rel Horiz Wheel", "Rel Vert Wheel"
103 }; 104 };
104 int n = sizeof(names) / sizeof(names[0]); 105 int n = sizeof(names) / sizeof(names[0]);
105 int i; 106 int i;
106 107
107 if (atoms == NULL) 108 if (EINA_UNLIKELY(atoms == NULL))
108 { 109 {
109 atoms = calloc(n, sizeof(Atom)); 110 atoms = calloc(n, sizeof(Atom));
110 if (!atoms) return 0; 111 if (!atoms) return 0;
@@ -501,6 +502,7 @@ _ecore_x_input_axis_handler(XEvent *xevent, XIDeviceInfo *dev)
501 Ecore_Axis *axis = calloc(n, sizeof(Ecore_Axis)); 502 Ecore_Axis *axis = calloc(n, sizeof(Ecore_Axis));
502 if (!axis) return; 503 if (!axis) return;
503 Ecore_Axis *axis_ptr = axis; 504 Ecore_Axis *axis_ptr = axis;
505 Ecore_Axis *shrunk_axis;
504 506
505 for (i = 0; i < dev->num_classes; i++) 507 for (i = 0; i < dev->num_classes; i++)
506 { 508 {
@@ -562,6 +564,15 @@ _ecore_x_input_axis_handler(XEvent *xevent, XIDeviceInfo *dev)
562 compute_tilt = EINA_TRUE; 564 compute_tilt = EINA_TRUE;
563 /* don't increment axis_ptr */ 565 /* don't increment axis_ptr */
564 } 566 }
567 else if ((inf->label == _ecore_x_input_get_axis_label("Rel X")) ||
568 (inf->label == _ecore_x_input_get_axis_label("Rel Y")) ||
569 (inf->label == _ecore_x_input_get_axis_label("Rel Vert Wheel")) ||
570 (inf->label == _ecore_x_input_get_axis_label("Rel Horiz Wheel")) ||
571 (inf->label == _ecore_x_input_get_axis_label("Rel Dial")))
572 {
573 /* Ignore those: mouse. Values are in fact not relative.
574 * No idea what is a "dial" event. */
575 }
565 else 576 else
566 { 577 {
567 axis_ptr->label = ECORE_AXIS_LABEL_UNKNOWN; 578 axis_ptr->label = ECORE_AXIS_LABEL_UNKNOWN;
@@ -589,13 +600,16 @@ _ecore_x_input_axis_handler(XEvent *xevent, XIDeviceInfo *dev)
589 600
590 /* update n to reflect actual count and realloc array to free excess */ 601 /* update n to reflect actual count and realloc array to free excess */
591 n = (axis_ptr - axis); 602 n = (axis_ptr - axis);
592 Ecore_Axis *shrunk_axis = realloc(axis, n * sizeof(Ecore_Axis));
593 if (shrunk_axis != NULL) axis = shrunk_axis;
594
595 if (n > 0) 603 if (n > 0)
596 _ecore_x_axis_update(evd->child ? evd->child : evd->event, 604 {
597 evd->event, evd->root, evd->time, evd->deviceid, 605 shrunk_axis = realloc(axis, n * sizeof(Ecore_Axis));
598 evd->detail, n, axis); 606 if (shrunk_axis != NULL) axis = shrunk_axis;
607 _ecore_x_axis_update(evd->child ? evd->child : evd->event,
608 evd->event, evd->root, evd->time, evd->deviceid,
609 evd->detail, n, axis);
610 }
611 else
612 free(axis);
599} 613}
600#endif /* ifdef ECORE_XI2 */ 614#endif /* ifdef ECORE_XI2 */
601 615