ecore_drm: set a screen rotation angle to ecore_drm_output 72/137172/2 accepted/tizen/unified/20170711.181154 submit/tizen/20170707.071852 submit/tizen/20170711.023244
authorJengHyun Kang <jhyuni.kang@samsung.com>
Tue, 4 Jul 2017 13:51:26 +0000 (22:51 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Thu, 6 Jul 2017 10:34:00 +0000 (10:34 +0000)
  - change pointer device's width and height following rotation

Change-Id: I49bad62ca532e08d31c85ad9208099b3644b5469

src/lib/ecore_drm/Ecore_Drm.h
src/lib/ecore_drm/ecore_drm_device.c
src/lib/ecore_drm/ecore_drm_evdev.c
src/lib/ecore_drm/ecore_drm_output.c [changed mode: 0755->0644]
src/lib/ecore_drm/ecore_drm_private.h
src/modules/ecore_evas/engines/drm/ecore_evas_drm.c [changed mode: 0755->0644]

index 2988da0..3173af7 100644 (file)
@@ -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);
 
index 5fe6e8e..ee3a0ad 100644 (file)
@@ -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])
 {
index 47a26a6..db27aa7 100644 (file)
@@ -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();
old mode 100755 (executable)
new mode 100644 (file)
index 423fbb9..93aa906
@@ -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;
+}
index bfc35e9..09b9152 100644 (file)
@@ -182,6 +182,8 @@ struct _Ecore_Drm_Output
    int curr_fb_format;
 
    void *hal_output;
+
+   int rotation;
 };
 
 struct _Ecore_Drm_Seat
old mode 100755 (executable)
new mode 100644 (file)
index 9eeb185..36f521e
@@ -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;