[gnome-shell/wip/exalm/dark-2] ui: Add ScreenTransition




commit 59b2b8a8cd7265608484276036c1ce5b8803e9cf
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Thu Sep 23 12:45:14 2021 +0500

    ui: Add ScreenTransition

 .../org.gnome.Shell.ScreenTransition.xml           | 22 ++++++
 data/gnome-shell-dbus-interfaces.gresource.xml     |  1 +
 js/js-resources.gresource.xml                      |  1 +
 js/ui/screenTransition.js                          | 82 ++++++++++++++++++++++
 js/ui/shellDBus.js                                 |  2 +
 5 files changed, 108 insertions(+)
---
diff --git a/data/dbus-interfaces/org.gnome.Shell.ScreenTransition.xml 
b/data/dbus-interfaces/org.gnome.Shell.ScreenTransition.xml
new file mode 100644
index 0000000000..1865a73866
--- /dev/null
+++ b/data/dbus-interfaces/org.gnome.Shell.ScreenTransition.xml
@@ -0,0 +1,22 @@
+<!DOCTYPE node PUBLIC
+'-//freedesktop//DTD D-BUS Object Introspection 1.0//EN'
+'http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd'>
+<node>
+
+  <!--
+      org.gnome.Shell.ScreenTransition:
+      @short_description: Screen transition interface
+
+      The interface used to initiate screen transition after changing the system-wide color scheme.
+  -->
+  <interface name="org.gnome.Shell.ScreenTransition">
+
+    <!--
+        Transition:
+
+        Initiate the screen transition.
+    -->
+    <method name="Transition"/>
+
+  </interface>
+</node>
diff --git a/data/gnome-shell-dbus-interfaces.gresource.xml b/data/gnome-shell-dbus-interfaces.gresource.xml
index 6682c462d6..4df7a22d3e 100644
--- a/data/gnome-shell-dbus-interfaces.gresource.xml
+++ b/data/gnome-shell-dbus-interfaces.gresource.xml
@@ -49,6 +49,7 @@
     <file preprocess="xml-stripblanks">org.gnome.Shell.PortalHelper.xml</file>
     <file preprocess="xml-stripblanks">org.gnome.Shell.Screencast.xml</file>
     <file preprocess="xml-stripblanks">org.gnome.Shell.Screenshot.xml</file>
+    <file preprocess="xml-stripblanks">org.gnome.Shell.ScreenTransition.xml</file>
     <file preprocess="xml-stripblanks">org.gnome.Shell.Wacom.PadOsd.xml</file>
     <file preprocess="xml-stripblanks">org.gnome.Shell.WeatherIntegration.xml</file>
     <file preprocess="xml-stripblanks">org.gnome.Shell.xml</file>
diff --git a/js/js-resources.gresource.xml b/js/js-resources.gresource.xml
index 93d5932f52..147804cfad 100644
--- a/js/js-resources.gresource.xml
+++ b/js/js-resources.gresource.xml
@@ -94,6 +94,7 @@
     <file>ui/runDialog.js</file>
     <file>ui/screenShield.js</file>
     <file>ui/screenshot.js</file>
+    <file>ui/screenTransition.js</file>
     <file>ui/scripting.js</file>
     <file>ui/search.js</file>
     <file>ui/searchController.js</file>
diff --git a/js/ui/screenTransition.js b/js/ui/screenTransition.js
new file mode 100644
index 0000000000..bdb277c616
--- /dev/null
+++ b/js/ui/screenTransition.js
@@ -0,0 +1,82 @@
+// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
+/* exported ScreenTransitionService */
+
+const { Clutter, Gio, GObject, St } = imports.gi;
+
+const Main = imports.ui.main;
+
+const { loadInterfaceXML } = imports.misc.fileUtils;
+const { DBusSenderChecker } = imports.misc.util;
+
+const ScreenTransitionIface = loadInterfaceXML('org.gnome.Shell.ScreenTransition');
+
+const SCREEN_TRANSITION_DURATION = 500; // milliseconds
+
+var ScreenTransitionService = class {
+    constructor() {
+        this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(ScreenTransitionIface, this);
+        this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell/ScreenTransition');
+
+        this._senderChecker = new DBusSenderChecker([
+            'org.gnome.ControlCenter',
+        ]);
+
+        Gio.DBus.session.own_name('org.gnome.Shell.ScreenTransition', Gio.BusNameOwnerFlags.REPLACE, null, 
null);
+    }
+
+    TransitionAsync(params, invocation) {
+        try {
+            this._senderChecker.checkInvocation(invocation);
+        } catch (e) {
+            invocation.return_gerror(e);
+            return;
+        }
+
+        if (this._transition)
+            this._transition.destroy();
+
+        this._transition = new ScreenTransition(() => {
+            this._transition = null;
+        });
+        invocation.return_value(null);
+    }
+};
+
+var ScreenTransition = GObject.registerClass(
+class ScreenTransition extends St.Bin {
+    _init(doneCallback) {
+        super._init();
+
+        Main.uiGroup.add_actor(this);
+        Main.uiGroup.set_child_above_sibling(this, null);
+
+        const rect = new imports.gi.cairo.RectangleInt({
+            x: 0,
+            y: 0,
+            width: global.screen_width,
+            height: global.screen_height,
+        });
+        // FIXME if scale-monitor-framebuffer is enabled, with mixed dpi the lower dpi screen
+        // will be glitchy. Should this be done for every screen separately instead?
+        const [, , , scale] = global.stage.get_capture_final_size(rect);
+        const content = global.stage.paint_to_content(rect, scale, Clutter.PaintFlag.NO_CURSORS);
+        const clone = new St.Widget({ content });
+        this.add_actor(clone);
+
+        this.add_constraint(new Clutter.BindConstraint({
+            source: Main.uiGroup,
+            coordinate: Clutter.BindCoordinate.ALL,
+        }));
+
+        this.ease({
+            opacity: 0,
+            duration: SCREEN_TRANSITION_DURATION,
+            mode: Clutter.AnimationMode.LINEAR,
+            onComplete: () => {
+                if (doneCallback)
+                    doneCallback();
+                this.destroy();
+            },
+        });
+    }
+});
diff --git a/js/ui/shellDBus.js b/js/ui/shellDBus.js
index aeabe6d81e..191c947626 100644
--- a/js/ui/shellDBus.js
+++ b/js/ui/shellDBus.js
@@ -8,6 +8,7 @@ const ExtensionDownloader = imports.ui.extensionDownloader;
 const ExtensionUtils = imports.misc.extensionUtils;
 const Main = imports.ui.main;
 const Screenshot = imports.ui.screenshot;
+const ScreenTransition = imports.ui.screenTransition;
 
 const { loadInterfaceXML } = imports.misc.fileUtils;
 const { DBusSenderChecker } = imports.misc.util;
@@ -28,6 +29,7 @@ var GnomeShell = class {
 
         this._extensionsService = new GnomeShellExtensions();
         this._screenshotService = new Screenshot.ScreenshotService();
+        this._screenTransitionService = new ScreenTransition.ScreenTransitionService();
 
         this._grabbedAccelerators = new Map();
         this._grabbers = new Map();


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