[mutter] cursor-renderer-native: take rotation into account



commit ebff7fd7f4ee2c9636412fe661a1fbdf51f218a0
Author: Olivier Fourdan <ofourdan redhat com>
Date:   Mon Mar 26 15:56:04 2018 +0200

    cursor-renderer-native: take rotation into account
    
    Rotating an output would show duplicate cursors when the pointer is
    located over an area which would be within the output if not rotated.
    
    Make sure to swap the width/height of the output when rotated.
    
    Closes: https://gitlab.gnome.org/GNOME/mutter/issues/85

 src/backends/native/meta-cursor-renderer-native.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/src/backends/native/meta-cursor-renderer-native.c 
b/src/backends/native/meta-cursor-renderer-native.c
index b28d26ca3..aea86dffd 100644
--- a/src/backends/native/meta-cursor-renderer-native.c
+++ b/src/backends/native/meta-cursor-renderer-native.c
@@ -291,9 +291,11 @@ update_monitor_crtc_cursor (MetaMonitor         *monitor,
     data->in_cursor_renderer_native;
   MetaCursorRendererNativePrivate *priv =
     meta_cursor_renderer_native_get_instance_private (cursor_renderer_native);
+  MetaMonitorTransform transform;
   ClutterRect scaled_crtc_rect;
   float scale;
   int crtc_x, crtc_y;
+  int crtc_width, crtc_height;
 
   if (meta_is_stage_views_scaled ())
     scale = meta_logical_monitor_get_scale (data->in_logical_monitor);
@@ -305,14 +307,26 @@ update_monitor_crtc_cursor (MetaMonitor         *monitor,
                                    META_MONITOR_TRANSFORM_NORMAL,
                                    &crtc_x, &crtc_y);
 
+  transform = meta_logical_monitor_get_transform (data->in_logical_monitor);
+  if (meta_monitor_transform_is_rotated (transform))
+    {
+      crtc_width = monitor_crtc_mode->crtc_mode->height;
+      crtc_height = monitor_crtc_mode->crtc_mode->width;
+    }
+  else
+    {
+      crtc_width = monitor_crtc_mode->crtc_mode->width;
+      crtc_height = monitor_crtc_mode->crtc_mode->height;
+    }
+
   scaled_crtc_rect = (ClutterRect) {
     .origin = {
       .x = crtc_x / scale,
       .y = crtc_y / scale
     },
     .size = {
-      .width = monitor_crtc_mode->crtc_mode->width / scale,
-      .height = monitor_crtc_mode->crtc_mode->height / scale
+      .width = crtc_width / scale,
+      .height = crtc_height / scale
     },
   };
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]