jpeg pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=7b25619213ead0d39001ce57320075b69fccdec2
commit 7b25619213ead0d39001ce57320075b69fccdec2 Author: Jean-Philippe Andre <[email protected]> Date: Wed Aug 24 17:44:32 2016 +0900 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). --- src/lib/ecore_x/xlib/ecore_x_xi2.c | 30 ++++++++++++++++++++++-------- 1 file 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) { "Abs X", "Abs Y", "Abs Pressure", "Abs Distance", "Abs Rotary Z", - "Abs Wheel", "Abs Tilt X", "Abs Tilt Y" + "Abs Wheel", "Abs Tilt X", "Abs Tilt Y", + "Rel X", "Rel Y", "Rel Dial", "Rel Horiz Wheel", "Rel Vert Wheel" }; int n = sizeof(names) / sizeof(names[0]); int i; - if (atoms == NULL) + if (EINA_UNLIKELY(atoms == NULL)) { atoms = calloc(n, sizeof(Atom)); if (!atoms) return 0; @@ -501,6 +502,7 @@ _ecore_x_input_axis_handler(XEvent *xevent, XIDeviceInfo *dev) Ecore_Axis *axis = calloc(n, sizeof(Ecore_Axis)); if (!axis) return; Ecore_Axis *axis_ptr = axis; + Ecore_Axis *shrunk_axis; for (i = 0; i < dev->num_classes; i++) { @@ -562,6 +564,15 @@ _ecore_x_input_axis_handler(XEvent *xevent, XIDeviceInfo *dev) compute_tilt = EINA_TRUE; /* don't increment axis_ptr */ } + else if ((inf->label == _ecore_x_input_get_axis_label("Rel X")) || + (inf->label == _ecore_x_input_get_axis_label("Rel Y")) || + (inf->label == _ecore_x_input_get_axis_label("Rel Vert Wheel")) || + (inf->label == _ecore_x_input_get_axis_label("Rel Horiz Wheel")) || + (inf->label == _ecore_x_input_get_axis_label("Rel Dial"))) + { + /* Ignore those: mouse. Values are in fact not relative. + * No idea what is a "dial" event. */ + } else { axis_ptr->label = ECORE_AXIS_LABEL_UNKNOWN; @@ -589,13 +600,16 @@ _ecore_x_input_axis_handler(XEvent *xevent, XIDeviceInfo *dev) /* update n to reflect actual count and realloc array to free excess */ n = (axis_ptr - axis); - Ecore_Axis *shrunk_axis = realloc(axis, n * sizeof(Ecore_Axis)); - if (shrunk_axis != NULL) axis = shrunk_axis; - if (n > 0) - _ecore_x_axis_update(evd->child ? evd->child : evd->event, - evd->event, evd->root, evd->time, evd->deviceid, - evd->detail, n, axis); + { + shrunk_axis = realloc(axis, n * sizeof(Ecore_Axis)); + if (shrunk_axis != NULL) axis = shrunk_axis; + _ecore_x_axis_update(evd->child ? evd->child : evd->event, + evd->event, evd->root, evd->time, evd->deviceid, + evd->detail, n, axis); + } + else + free(axis); } #endif /* ifdef ECORE_XI2 */ --
