From 8ebc478f0f24720870c4911aef707f4dc34d140c Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Mon, 16 Aug 2021 10:16:19 +0300 Subject: [PATCH] Add scaffolding for the new screenshot UI Part-of: --- data/org.gnome.shell.gschema.xml.in | 4 ++ js/ui/layout.js | 6 ++ js/ui/main.js | 6 +- js/ui/screenshot.js | 93 ++++++++++++++++++++++++++++- 4 files changed, 107 insertions(+), 2 deletions(-) diff --git a/data/org.gnome.shell.gschema.xml.in b/data/org.gnome.shell.gschema.xml.in index a6b2f5a1f..1dadb13c2 100644 --- a/data/org.gnome.shell.gschema.xml.in +++ b/data/org.gnome.shell.gschema.xml.in @@ -230,6 +230,10 @@ ["<Super>9"] Switch to application 9 + + ["Print"] + Show screenshot UI + { + // Nope, not dealing with monitor changes. + this.close(true); + }); + + Main.wm.addKeybinding( + 'show-screenshot-ui', + new Gio.Settings({ schema_id: 'org.gnome.shell.keybindings' }), + Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, + Shell.ActionMode.NORMAL | + Shell.ActionMode.OVERVIEW | + Shell.ActionMode.SYSTEM_MODAL | + Shell.ActionMode.LOOKING_GLASS | + Shell.ActionMode.POPUP, + showScreenshotUI + ); + } + + open() { + // Get rid of any popup menus. + // We already have them captured on the screenshot anyway. + // + // This needs to happen before the grab below as closing menus will + // pop their grabs. + Main.layoutManager.emit('system-modal-opened'); + + const grabResult = this._grabHelper.grab({ + actor: this, + onUngrab: () => this.close(), + }); + if (!grabResult) + return; + + this.remove_all_transitions(); + this.visible = true; + this.ease({ + opacity: 255, + duration: 200, + mode: Clutter.AnimationMode.EASE_OUT_QUAD, + }); + } + + _finishClosing() { + this.hide(); + } + + close(instantly = false) { + this._grabHelper.ungrab(); + + if (instantly) { + this._finishClosing(); + return; + } + + this.remove_all_transitions(); + this.ease({ + opacity: 0, + duration: 200, + mode: Clutter.AnimationMode.EASE_OUT_QUAD, + onComplete: this._finishClosing.bind(this), + }); + } +}); + +/** + * Shows the screenshot UI. + */ +function showScreenshotUI() { + Main.screenshotUI.open(); +} + var ScreenshotService = class { constructor() { this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(ScreenshotIface, this);