From da600b8400e4e42b6cd3fe4431a7b9fdf47fc553 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 27 Mar 2020 14:57:27 +0100 Subject: [PATCH] cursor-renderer-native: Take panel-orientation into account for sprite transform When calculating the transform we should apply to the cursor sprite before uploading it to the cursor plane, we must also take into account non upright mounted LCD panels. Otherwise the cursor ends up 90 degrees rotated on devices where the LCD panel is mounted 90 degrees rotated in its enclosure. This commit fixes this by calling meta_monitor_logical_to_crtc_transform in get_common_crtc_sprite_transform_for_logical_monitors to adjust the transform for each Monitor in the LogicalMonitor. Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1123 https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1153 --- .../native/meta-cursor-renderer-native.c | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/backends/native/meta-cursor-renderer-native.c b/src/backends/native/meta-cursor-renderer-native.c index 62cd54b8a..2450e19f2 100644 --- a/src/backends/native/meta-cursor-renderer-native.c +++ b/src/backends/native/meta-cursor-renderer-native.c @@ -823,22 +823,30 @@ get_common_crtc_sprite_transform_for_logical_monitors (MetaCursorRenderer *ren MetaLogicalMonitor *logical_monitor = l->data; graphene_rect_t logical_monitor_rect = meta_rectangle_to_graphene_rect (&logical_monitor->rect); - MetaMonitorTransform tmp_transform; + MetaMonitorTransform logical_transform, tmp_transform; + GList *monitors, *l_mon; if (!graphene_rect_intersection (&cursor_rect, &logical_monitor_rect, NULL)) continue; - tmp_transform = meta_monitor_transform_relative_transform ( - meta_cursor_sprite_get_texture_transform (cursor_sprite), - meta_logical_monitor_get_transform (logical_monitor)); + logical_transform = meta_logical_monitor_get_transform (logical_monitor); + monitors = meta_logical_monitor_get_monitors (logical_monitor); + for (l_mon = monitors; l_mon; l_mon = l_mon->next) + { + MetaMonitor *monitor = l_mon->data; - if (has_visible_crtc_sprite && transform != tmp_transform) - return FALSE; + tmp_transform = meta_monitor_transform_relative_transform ( + meta_cursor_sprite_get_texture_transform (cursor_sprite), + meta_monitor_logical_to_crtc_transform (monitor, logical_transform)); - has_visible_crtc_sprite = TRUE; - transform = tmp_transform; + if (has_visible_crtc_sprite && transform != tmp_transform) + return FALSE; + + has_visible_crtc_sprite = TRUE; + transform = tmp_transform; + } } if (!has_visible_crtc_sprite)