[gnome-shell/wip/exalm/dark-2: 212/212] shellDBus: Add ScreenTransition()




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

    shellDBus: Add ScreenTransition()
    
    Settings will use this when switching between light and dark styles.

 data/dbus-interfaces/org.gnome.Shell.xml |  1 +
 js/ui/background.js                      |  5 +++
 js/ui/shellDBus.js                       | 69 +++++++++++++++++++++++++++++++-
 3 files changed, 74 insertions(+), 1 deletion(-)
---
diff --git a/data/dbus-interfaces/org.gnome.Shell.xml b/data/dbus-interfaces/org.gnome.Shell.xml
index 38154cbdb9..3ffb5c3742 100644
--- a/data/dbus-interfaces/org.gnome.Shell.xml
+++ b/data/dbus-interfaces/org.gnome.Shell.xml
@@ -35,6 +35,7 @@
       <arg type="au" direction="in" name="action"/>
       <arg type="b" direction="out" name="success"/>
     </method>
+    <method name="ScreenTransition"/>
     <signal name="AcceleratorActivated">
       <arg name="action" type="u"/>
       <arg name="parameters" type="a{sv}"/>
diff --git a/js/ui/background.js b/js/ui/background.js
index 264ac7d704..bb3caef3f2 100644
--- a/js/ui/background.js
+++ b/js/ui/background.js
@@ -733,6 +733,11 @@ var BackgroundManager = class BackgroundManager {
         this._newBackgroundActor = null;
         this.emit('changed');
 
+        if (Main.shellDBusService.getScreenTransitionRunning()) {
+            oldBackgroundActor.destroy();
+            return;
+        }
+
         oldBackgroundActor.ease({
             opacity: 0,
             duration: FADE_ANIMATION_TIME,
diff --git a/js/ui/shellDBus.js b/js/ui/shellDBus.js
index 39bba7aa34..e8dd9574a2 100644
--- a/js/ui/shellDBus.js
+++ b/js/ui/shellDBus.js
@@ -1,7 +1,7 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 /* exported GnomeShell, ScreenSaverDBus */
 
-const { Gio, GLib, Meta, Shell } = imports.gi;
+const { Clutter, Gio, GLib, GObject, Meta, Shell, St } = imports.gi;
 
 const Config = imports.misc.config;
 const ExtensionDownloader = imports.ui.extensionDownloader;
@@ -16,6 +16,9 @@ const { ControlsState } = imports.ui.overviewControls;
 const GnomeShellIface = loadInterfaceXML('org.gnome.Shell');
 const ScreenSaverIface = loadInterfaceXML('org.gnome.ScreenSaver');
 
+const SCREEN_TRANSITION_DELAY = 250; // milliseconds
+const SCREEN_TRANSITION_DURATION = 500; // milliseconds
+
 var GnomeShell = class {
     constructor() {
         this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellIface, this);
@@ -251,6 +254,25 @@ var GnomeShell = class {
         invocation.return_value(GLib.Variant.new('(b)', [ungrabSucceeded]));
     }
 
+    ScreenTransitionAsync(params, invocation) {
+        try {
+            this._senderChecker.checkInvocation(invocation);
+        } catch (e) {
+            invocation.return_gerror(e);
+            return;
+        }
+
+        if (this._screenTransition)
+            this._screenTransition.destroy();
+
+        this._screenTransition = new ScreenTransition(() => {
+            this._screenTransition.destroy();
+            this._screenTransition = null;
+        });
+
+        invocation.return_value(null);
+    }
+
     _emitAcceleratorActivated(action, device, timestamp) {
         let destination = this._grabbedAccelerators.get(action);
         if (!destination)
@@ -351,6 +373,11 @@ var GnomeShell = class {
         if (Main.overview.visible !== this._cachedOverviewVisible) {
             this._cachedOverviewVisible = Main.overview.visible;
             this._dbusImpl.emit_property_changed('OverviewActive', new GLib.Variant('b', 
this._cachedOverviewVisible));
+
+            if (this._screenTransition) {
+                this._screenTransition.destroy();
+                this._screenTransition = null;
+            }
         }
     }
 
@@ -372,6 +399,10 @@ var GnomeShell = class {
     get ShellVersion() {
         return Config.PACKAGE_VERSION;
     }
+
+    getScreenTransitionRunning() {
+        return this._screenTransition != null;
+    }
 };
 
 const GnomeShellExtensionsIface = loadInterfaceXML('org.gnome.Shell.Extensions');
@@ -523,3 +554,39 @@ var ScreenSaverDBus = class {
             return 0;
     }
 };
+
+var ScreenTransition = GObject.registerClass(
+class ScreenTransition extends St.Bin {
+    _init(doneCallback) {
+        super._init();
+
+        Main.uiGroup.add_child(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,
+        });
+        const [, , , scale] = global.stage.get_capture_final_size(rect);
+        const content = global.stage.paint_to_content(rect, scale, Clutter.PaintFlag.NO_CURSORS);
+        this.child = new St.Widget({ content });
+
+        this.add_constraint(new Clutter.BindConstraint({
+            source: Main.uiGroup,
+            coordinate: Clutter.BindCoordinate.ALL,
+        }));
+
+        this.ease({
+            opacity: 0,
+            duration: SCREEN_TRANSITION_DURATION,
+            delay: SCREEN_TRANSITION_DELAY,
+            mode: Clutter.AnimationMode.LINEAR,
+            onComplete: () => {
+                if (doneCallback)
+                    doneCallback();
+            },
+        });
+    }
+});


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