summaryrefslogtreecommitdiff
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
parent925878e931a46212f47be805abdf5b09b810dad4 (diff)
downloadefl-7b25619213ead0d39001ce57320075b69fccdec2.tar.gz
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).
-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 b6e451926e..be19de2c94 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 */