From 68f7e07e9861274de7c5a783dfc6a26e1e4bea5e Mon Sep 17 00:00:00 2001 From: JengHyun Kang Date: Tue, 4 Jul 2017 22:51:26 +0900 Subject: [PATCH] ecore_drm: set a screen rotation angle to ecore_drm_output - change pointer device's width and height following rotation Change-Id: I49bad62ca532e08d31c85ad9208099b3644b5469 --- src/lib/ecore_drm/Ecore_Drm.h | 3 +- src/lib/ecore_drm/ecore_drm_device.c | 38 ++++++++++++++++++++++ src/lib/ecore_drm/ecore_drm_evdev.c | 15 ++++++++- src/lib/ecore_drm/ecore_drm_output.c | 7 ++++ src/lib/ecore_drm/ecore_drm_private.h | 2 ++ .../ecore_evas/engines/drm/ecore_evas_drm.c | 8 ++++- 6 files changed, 70 insertions(+), 3 deletions(-) mode change 100755 => 100644 src/lib/ecore_drm/ecore_drm_output.c mode change 100755 => 100644 src/modules/ecore_evas/engines/drm/ecore_evas_drm.c diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h index 2988da00..3173af7 100644 --- a/src/lib/ecore_drm/Ecore_Drm.h +++ b/src/lib/ecore_drm/Ecore_Drm.h @@ -1093,6 +1093,7 @@ typedef void (*Ecore_Drm_VBlank_Cb)(void *data); EAPI Eina_Bool ecore_drm_output_wait_vblank(Ecore_Drm_Output *output, int interval, Ecore_Drm_VBlank_Cb func, void *data); EAPI int ecore_drm_output_dpms_get(Ecore_Drm_Output *output); EAPI void *ecore_drm_output_hal_private_get(Ecore_Drm_Output *output); +EAPI void ecore_drm_output_rotation_set(Ecore_Drm_Output *output, int rotation); /* This is ugly, will remove after rebaseing on 1.14 */ EAPI unsigned int ecore_drm_output_crtc_id_get(Ecore_Drm_Output *output); @@ -1106,7 +1107,7 @@ EAPI Eina_Bool ecore_drm_display_fb_hal_buffer_create(Ecore_Drm_Fb *fb); EAPI void ecore_drm_display_fb_hal_buffer_destroy(Ecore_Drm_Fb *fb); EAPI Eina_Bool ecore_drm_device_pointer_rotation_set(Ecore_Drm_Device *dev, int rotation); -EAPI Eina_Bool ecore_drm_evdev_device_rotate_set(Ecore_Drm_Device *dev, unsigned int rotation); +EAPI void ecore_drm_device_rotation_set(Ecore_Drm_Device *dev, unsigned int rotation); EAPI Eina_Bool ecore_drm_device_touch_rotation_set(Ecore_Drm_Device *dev, unsigned int rotation); EAPI Eina_Bool ecore_drm_device_touch_transformation_set(Ecore_Drm_Device *dev, int offset_x, int offset_y, int w, int h); diff --git a/src/lib/ecore_drm/ecore_drm_device.c b/src/lib/ecore_drm/ecore_drm_device.c index 5fe6e8e..ee3a0ad 100644 --- a/src/lib/ecore_drm/ecore_drm_device.c +++ b/src/lib/ecore_drm/ecore_drm_device.c @@ -900,6 +900,44 @@ ecore_drm_device_pointer_rotation_set(Ecore_Drm_Device *dev, int rotation) return EINA_TRUE; } +EAPI void +ecore_drm_device_rotation_set(Ecore_Drm_Device *dev, unsigned int rotation) +{ + unsigned int rot = 0; + Ecore_Drm_Seat *seat = NULL; + Ecore_Drm_Evdev *edev = NULL; + Eina_List *l = NULL, *l2 = NULL; + int temp; + + EINA_SAFETY_ON_NULL_RETURN(dev); + EINA_SAFETY_ON_NULL_RETURN(dev->seats); + + EINA_LIST_FOREACH(dev->seats, l, seat) + { + EINA_LIST_FOREACH(ecore_drm_seat_evdev_list_get(seat), l2, edev) + { + if (libinput_device_has_capability(edev->device, + LIBINPUT_DEVICE_CAP_POINTER)) + { + ecore_drm_outputs_geometry_get(edev->seat->input->dev, + &edev->mouse.minx, &edev->mouse.miny, + &edev->mouse.maxw, &edev->mouse.maxh); + + if (rotation == 90 || rotation == 270) + { + temp = edev->mouse.minx; + edev->mouse.minx = edev->mouse.miny; + edev->mouse.miny = temp; + + temp = edev->mouse.maxw; + edev->mouse.maxw = edev->mouse.maxh; + edev->mouse.maxh = temp; + } + } + } + } +} + static void _ecore_drm_device_touch_matrix_identify(float result[6]) { diff --git a/src/lib/ecore_drm/ecore_drm_evdev.c b/src/lib/ecore_drm/ecore_drm_evdev.c index 47a26a6..db27aa7 100644 --- a/src/lib/ecore_drm/ecore_drm_evdev.c +++ b/src/lib/ecore_drm/ecore_drm_evdev.c @@ -55,6 +55,7 @@ _device_output_set(Ecore_Drm_Evdev *edev) Ecore_Drm_Input *input; Ecore_Drm_Output *output = NULL; const char *oname; + int temp; if (!edev->seat) return; if (!(input = edev->seat->input)) return; @@ -77,13 +78,24 @@ _device_output_set(Ecore_Drm_Evdev *edev) edev->output = output; - if (libinput_device_has_capability(edev->device, + if (libinput_device_has_capability(edev->device, LIBINPUT_DEVICE_CAP_POINTER)) { edev->seat->ptr.ix = edev->seat->ptr.dx = edev->output->current_mode->width / 2; edev->seat->ptr.iy = edev->seat->ptr.dy = edev->output->current_mode->height / 2; edev->mouse.dx = edev->seat->ptr.dx; edev->mouse.dy = edev->seat->ptr.dy; + + if (output->rotation == 90 || output->rotation == 270) + { + temp = edev->mouse.minx; + edev->mouse.minx = edev->mouse.miny; + edev->mouse.miny = temp; + + temp = edev->mouse.maxw; + edev->mouse.maxw = edev->mouse.maxh; + edev->mouse.maxh = temp; + } } } @@ -512,6 +524,7 @@ _device_handle_pointer_motion(struct libinput_device *device, struct libinput_ev edev->seat->ptr.ix = edev->seat->ptr.dx; edev->seat->ptr.iy = edev->seat->ptr.dy; + _device_pointer_motion(edev, event); TRACE_INPUT_END(); diff --git a/src/lib/ecore_drm/ecore_drm_output.c b/src/lib/ecore_drm/ecore_drm_output.c old mode 100755 new mode 100644 index 423fbb9..93aa906 --- a/src/lib/ecore_drm/ecore_drm_output.c +++ b/src/lib/ecore_drm/ecore_drm_output.c @@ -1679,3 +1679,10 @@ ecore_drm_output_wait_vblank(Ecore_Drm_Output *output, int interval, Ecore_Drm_V return EINA_TRUE; #endif } + +EAPI void +ecore_drm_output_rotation_set(Ecore_Drm_Output *output, int rotation) +{ + EINA_SAFETY_ON_NULL_RETURN(output); + output->rotation = rotation; +} diff --git a/src/lib/ecore_drm/ecore_drm_private.h b/src/lib/ecore_drm/ecore_drm_private.h index bfc35e9..09b9152 100644 --- a/src/lib/ecore_drm/ecore_drm_private.h +++ b/src/lib/ecore_drm/ecore_drm_private.h @@ -182,6 +182,8 @@ struct _Ecore_Drm_Output int curr_fb_format; void *hal_output; + + int rotation; }; struct _Ecore_Drm_Seat diff --git a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c old mode 100755 new mode 100644 index 9eeb185..36f521e --- a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c +++ b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c @@ -858,12 +858,18 @@ static void _ecore_evas_drm_rotation_set(Ecore_Evas *ee, int rotation, int resize) { int rot_dif; + Ecore_Drm_Output *output; if (ee->rotation == rotation) return; /* rotate the input events in ecore_drm */ if (dev) - ecore_drm_device_touch_rotation_set(dev, rotation); + { + output = ecore_drm_device_output_find(dev, ee->x, ee->y); + ecore_drm_output_rotation_set(output, rotation); + ecore_drm_device_touch_rotation_set(dev, rotation); + ecore_drm_device_rotation_set(dev, rotation); + } /* calculate difference in rotation */ rot_dif = ee->rotation - rotation; -- 2.7.4