From b5900dd97a79b735444f31e96f7e34cf06172171 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 24 May 2023 18:02:17 +0200 Subject: [PATCH] backends: Avoid orientation changes around suspend/resume if locked We currently lock the capability of the MetaOrientationManager to emit the ::orientation-changed signal, but otherwise keep reading the current orientation and returning it if we are asked politely through meta_orientation_manager_get_orientation(). This may bring issues e.g. around suspend/resume, since there may be other parts of the code trying to get the current orientation without receiving ::orientation-changed signals, this may result in the display orientation being effectively rotated, then stay locked after that. In order to fix this, make the MetaOrientationManager return a fixed orientation while locked, only updated after changes in the lock state. Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2600 Part-of: --- src/backends/meta-orientation-manager.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/backends/meta-orientation-manager.c b/src/backends/meta-orientation-manager.c index ba7a500a7..88aa184c0 100644 --- a/src/backends/meta-orientation-manager.c +++ b/src/backends/meta-orientation-manager.c @@ -56,6 +56,7 @@ struct _MetaOrientationManager GDBusProxy *iio_proxy; MetaOrientation prev_orientation; MetaOrientation curr_orientation; + MetaOrientation effective_orientation; guint has_accel : 1; GSettings *settings; @@ -130,6 +131,7 @@ sync_state (MetaOrientationManager *self) return; self->prev_orientation = self->curr_orientation; + self->effective_orientation = self->curr_orientation; if (self->curr_orientation == META_ORIENTATION_UNDEFINED) return; @@ -293,6 +295,8 @@ meta_orientation_manager_init (MetaOrientationManager *self) G_CALLBACK (orientation_lock_changed), self, 0); sync_state (self); } + + self->effective_orientation = META_ORIENTATION_UNDEFINED; } static void @@ -361,7 +365,7 @@ meta_orientation_manager_class_init (MetaOrientationManagerClass *klass) MetaOrientation meta_orientation_manager_get_orientation (MetaOrientationManager *self) { - return self->curr_orientation; + return self->effective_orientation; } gboolean