From 570a398e290d93e2b6ef998b263004281f45097d Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Thu, 7 Jul 2016 16:01:58 +0900 Subject: [PATCH] ecore_drm2: Fix mouse pointer when using absolute coords Running E wl2 in KVM led to the following issue: integrated mouse pointer would always be stuck at (0,0). The reason was that calibration would never happen, and it's required* for absolute pointing devices, such as the qemu mouse integration. Fix: Listen to device add and calibrate based on the first output. No idea if we could calibrate on any other output, or how this should be done in case of multiple screens. [*] I believe calibration might actually not be required, as the absolute position is already the correct one when received from libinput. --- src/lib/ecore_drm2/ecore_drm2_device.c | 28 +++++++++++++++++++++++++--- src/lib/ecore_drm2/ecore_drm2_private.h | 1 + 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/lib/ecore_drm2/ecore_drm2_device.c b/src/lib/ecore_drm2/ecore_drm2_device.c index ad786e8..831c538 100644 --- a/src/lib/ecore_drm2/ecore_drm2_device.c +++ b/src/lib/ecore_drm2/ecore_drm2_device.c @@ -33,6 +33,25 @@ _cb_session_active(void *data, int type EINA_UNUSED, void *event) return ECORE_CALLBACK_RENEW; } +static Eina_Bool +_cb_device_change(void *data, int type EINA_UNUSED, void *event) +{ + Elput_Event_Device_Change *ev = event; + Ecore_Drm2_Device *device = data; + + if (ev->type == ELPUT_DEVICE_ADDED) + { + Ecore_Drm2_Output *output; + + /* FIXME: not sure which output to use to calibrate */ + output = eina_list_data_get(device->outputs); + if (output) + ecore_drm2_device_calibrate(device, output->w, output->h); + } + + return ECORE_CALLBACK_RENEW; +} + static const char * _drm2_device_find(const char *seat) { @@ -155,6 +174,10 @@ ecore_drm2_device_open(Ecore_Drm2_Device *device) ecore_event_handler_add(ELPUT_EVENT_SESSION_ACTIVE, _cb_session_active, device); + device->device_change_hdlr = + ecore_event_handler_add(ELPUT_EVENT_DEVICE_CHANGE, + _cb_device_change, device); + /* NB: Not going to enable planes if we don't support atomic */ /* if (drmSetClientCap(device->fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1) < 0) */ /* ERR("Could not set Universal Plane support: %m"); */ @@ -182,9 +205,8 @@ ecore_drm2_device_free(Ecore_Drm2_Device *device) { EINA_SAFETY_ON_NULL_RETURN(device); - if (device->active_hdlr) ecore_event_handler_del(device->active_hdlr); - device->active_hdlr = NULL; - + ecore_event_handler_del(device->active_hdlr); + ecore_event_handler_del(device->device_change_hdlr); eina_stringshare_del(device->path); free(device); } diff --git a/src/lib/ecore_drm2/ecore_drm2_private.h b/src/lib/ecore_drm2/ecore_drm2_private.h index 23c9c77..e3a9c90 100644 --- a/src/lib/ecore_drm2/ecore_drm2_private.h +++ b/src/lib/ecore_drm2/ecore_drm2_private.h @@ -178,6 +178,7 @@ struct _Ecore_Drm2_Device Eeze_Udev_Watch *watch; Ecore_Event_Handler *active_hdlr; + Ecore_Event_Handler *device_change_hdlr; Eina_List *outputs; }; -- 2.7.4