From fa2faff41b0396917b7a1da98a9f262cffc82723 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Tue, 3 Oct 2017 13:25:03 -0400 Subject: [PATCH] elput: Fix issue of pointer rotation not being set on startup elput_input_pointer_rotation_set may be getting called before input devices are actually added, so we need to be able to set pointer rotation when a device actually gets added. To fix this, we will store the requested input rotation value, and apply it at the time of input device creation. NB: The current case is that the wl_drm module will apply existing output rotation before Input has completely initialized, thus any calls to set the pointer rotation there will not succeed as input devices have not been created yet. @fix Signed-off-by: Chris Michael --- src/lib/elput/elput_input.c | 38 +++++++++++++++++++++++++++++++++-- src/lib/elput/elput_private.h | 1 + 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/lib/elput/elput_input.c b/src/lib/elput/elput_input.c index d219eff9ff..ed6f3f322d 100644 --- a/src/lib/elput/elput_input.c +++ b/src/lib/elput/elput_input.c @@ -217,12 +217,44 @@ _device_add(Elput_Manager *em, struct libinput_device *dev) eseat->devices = eina_list_append(eseat->devices, edev); DBG("Input Device Added: %s", libinput_device_get_name(dev)); + if (edev->caps & ELPUT_DEVICE_CAPS_KEYBOARD) DBG("\tDevice added as Keyboard device"); + if (edev->caps & ELPUT_DEVICE_CAPS_POINTER) - DBG("\tDevice added as Pointer device"); + { + DBG("\tDevice added as Pointer device"); + switch (em->input.rotation) + { + case 0: + edev->swap = EINA_FALSE; + edev->invert_x = EINA_FALSE; + edev->invert_y = EINA_FALSE; + break; + case 90: + edev->swap = EINA_TRUE; + edev->invert_x = EINA_FALSE; + edev->invert_y = EINA_TRUE; + break; + case 180: + edev->swap = EINA_FALSE; + edev->invert_x = EINA_TRUE; + edev->invert_y = EINA_TRUE; + break; + case 270: + edev->swap = EINA_TRUE; + edev->invert_x = EINA_TRUE; + edev->invert_y = EINA_FALSE; + break; + default: + break; + } + } + if (edev->caps & ELPUT_DEVICE_CAPS_TOUCH) - DBG("\tDevice added as Touch device"); + { + DBG("\tDevice added as Touch device"); + } _device_event_send(edev, ELPUT_DEVICE_ADDED); } @@ -578,6 +610,8 @@ elput_input_pointer_rotation_set(Elput_Manager *manager, int rotation) if ((rotation % 90 != 0) || (rotation / 90 > 3) || (rotation < 0)) return EINA_FALSE; + manager->input.rotation = rotation; + EINA_LIST_FOREACH(manager->input.seats, l, eseat) { EINA_LIST_FOREACH(eseat->devices, ll, edev) diff --git a/src/lib/elput/elput_private.h b/src/lib/elput/elput_private.h index a4ea37b8a1..692dd4a83e 100644 --- a/src/lib/elput/elput_private.h +++ b/src/lib/elput/elput_private.h @@ -82,6 +82,7 @@ typedef struct _Elput_Input Eldbus_Pending *current_pending; int pipe; int pointer_w, pointer_h; + int rotation; Eina_Bool suspended : 1; } Elput_Input;