From 566e24d8a1a38f6ae48038451c86415adc761d7d Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 11 Jun 2020 18:18:37 +0200 Subject: [PATCH] backends: Hook ClutterSeat::touch-mode to PanelOrientationManaged We only want the panel autorotation to happen if the laptop has an accelerometer, and is in tablet mode. Regular laptop mode should lock the orientation, and let it be configured manually. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1311 --- src/backends/meta-backend.c | 2 ++ src/backends/meta-monitor-manager-private.h | 2 ++ src/backends/meta-monitor-manager.c | 22 ++++++++++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c index 39f275489..57cb43e20 100644 --- a/src/backends/meta-backend.c +++ b/src/backends/meta-backend.c @@ -573,6 +573,8 @@ meta_backend_real_post_init (MetaBackend *backend) reset_pointer_position (backend); priv->is_pointer_position_initialized = TRUE; } + + meta_monitor_manager_post_init (priv->monitor_manager); } static gboolean diff --git a/src/backends/meta-monitor-manager-private.h b/src/backends/meta-monitor-manager-private.h index 7df72f716..ac3bc94d6 100644 --- a/src/backends/meta-monitor-manager-private.h +++ b/src/backends/meta-monitor-manager-private.h @@ -407,4 +407,6 @@ meta_find_output_assignment (MetaOutputAssignment **outputs, return NULL; } +void meta_monitor_manager_post_init (MetaMonitorManager *manager); + #endif /* META_MONITOR_MANAGER_PRIVATE_H */ diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c index ff545da78..6084e4c37 100644 --- a/src/backends/meta-monitor-manager.c +++ b/src/backends/meta-monitor-manager.c @@ -756,12 +756,18 @@ static void update_panel_orientation_managed (MetaMonitorManager *manager) { MetaOrientationManager *orientation_manager; + ClutterBackend *clutter_backend; + ClutterSeat *seat; gboolean panel_orientation_managed; + clutter_backend = meta_backend_get_clutter_backend (manager->backend); + seat = clutter_backend_get_default_seat (clutter_backend); + orientation_manager = meta_backend_get_orientation_manager (manager->backend); panel_orientation_managed = - meta_orientation_manager_has_accelerometer (orientation_manager); + (clutter_seat_get_touch_mode (seat) && + meta_orientation_manager_has_accelerometer (orientation_manager)); if (manager->panel_orientation_managed == panel_orientation_managed) return; @@ -3227,3 +3233,17 @@ meta_monitor_manager_get_panel_orientation_managed (MetaMonitorManager *manager) return manager->panel_orientation_managed; } + +void +meta_monitor_manager_post_init (MetaMonitorManager *manager) +{ + ClutterBackend *clutter_backend; + ClutterSeat *seat; + + clutter_backend = meta_backend_get_clutter_backend (manager->backend); + seat = clutter_backend_get_default_seat (clutter_backend); + + g_signal_connect_object (seat, "notify::touch-mode", + G_CALLBACK (update_panel_orientation_managed), manager, + G_CONNECT_SWAPPED); +}