[gnome-control-center/wip/exalm/screen-transition] background: Trigger screen transition when changing style




commit e71604151a0300bacfbb17ddad9897b58d2d7e1f
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Sun Dec 19 21:41:53 2021 +0500

    background: Trigger screen transition when changing style
    
    See https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2070

 panels/background/cc-background-panel.c | 61 +++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
---
diff --git a/panels/background/cc-background-panel.c b/panels/background/cc-background-panel.c
index d55566c55..187a6e971 100644
--- a/panels/background/cc-background-panel.c
+++ b/panels/background/cc-background-panel.c
@@ -57,6 +57,7 @@ struct _CcBackgroundPanel
   GSettings *interface_settings;
 
   GnomeDesktopThumbnailFactory *thumb_factory;
+  GDBusProxy *proxy;
 
   CcBackgroundItem *current_background;
 
@@ -103,10 +104,42 @@ reload_light_dark_toggles (CcBackgroundPanel *self)
     }
 }
 
+static void
+transition_screen (CcBackgroundPanel *self)
+{
+  g_autoptr (GError) error = NULL;
+
+  if (!self->proxy)
+    return;
+
+  g_dbus_proxy_call_sync (self->proxy,
+                          "Transition",
+                          NULL,
+                          G_DBUS_CALL_FLAGS_NONE,
+                          -1,
+                          NULL,
+                          &error);
+
+  if (error)
+    g_warning ("Couldn't transition screen: %s", error->message);
+}
+
 static void
 set_color_scheme (CcBackgroundPanel   *self,
                   GDesktopColorScheme  color_scheme)
 {
+  GDesktopColorScheme scheme;
+
+  scheme = g_settings_get_enum (self->interface_settings,
+                                INTERFACE_COLOR_SCHEME_KEY);
+
+  /* We have to check the equality manually to avoid starting an unnecessary
+   * screen transition */
+  if (color_scheme == scheme)
+    return;
+
+  transition_screen (self);
+
   g_settings_set_enum (self->interface_settings,
                        INTERFACE_COLOR_SCHEME_KEY,
                        color_scheme);
@@ -123,6 +156,23 @@ on_light_dark_toggle_active_cb (CcBackgroundPanel *self)
     set_color_scheme (self, G_DESKTOP_COLOR_SCHEME_PREFER_DARK);
 }
 
+static void
+got_transition_proxy_cb (GObject      *source_object,
+                         GAsyncResult *res,
+                         gpointer      data)
+{
+  g_autoptr(GError) error = NULL;
+  CcBackgroundPanel *self = data;
+
+  self->proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
+
+  if (self->proxy == NULL)
+    {
+      g_warning ("Error creating proxy: %s", error->message);
+      return;
+    }
+}
+
 /* Background */
 
 static void
@@ -288,6 +338,7 @@ cc_background_panel_dispose (GObject *object)
   g_clear_object (&panel->lock_settings);
   g_clear_object (&panel->interface_settings);
   g_clear_object (&panel->thumb_factory);
+  g_clear_object (&panel->proxy);
 
   G_OBJECT_CLASS (cc_background_panel_parent_class)->dispose (object);
 }
@@ -372,5 +423,15 @@ cc_background_panel_init (CcBackgroundPanel *panel)
                            panel,
                            G_CONNECT_SWAPPED);
 
+  g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
+                            G_DBUS_PROXY_FLAGS_NONE,
+                            NULL,
+                            "org.gnome.Shell",
+                            "/org/gnome/Shell/ScreenTransition",
+                            "org.gnome.Shell.ScreenTransition",
+                            NULL,
+                            got_transition_proxy_cb,
+                            panel);
+
   load_custom_css (panel);
 }


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