[gnome-shell/gnome-3-38] screenshot: Still remove select/pick actor if grab promise was rejected



commit e3dc4401d12b5281954315e0953b8ad3a7876bc1
Author: Sebastian Keller <skeller gnome org>
Date:   Wed Jan 27 23:27:31 2021 +0100

    screenshot: Still remove select/pick actor if grab promise was rejected
    
    If the grab promise is rejected due to for example on X another app
    already having the grab, an error is thrown and the code that would
    revert the cursor and hide the actor is not run. This actor then
    prevents all mouse interactions with the shell and the windows beneath
    it.
    
    Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2869
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1600>
    (cherry picked from commit 0882074ecc9cef08125ad9c1e353d0429ca07e61)

 js/ui/screenshot.js | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)
---
diff --git a/js/ui/screenshot.js b/js/ui/screenshot.js
index de5d3c0630..787e60f9af 100644
--- a/js/ui/screenshot.js
+++ b/js/ui/screenshot.js
@@ -322,14 +322,16 @@ class SelectArea extends St.Widget {
         Main.uiGroup.set_child_above_sibling(this, null);
         this.show();
 
-        await this._grabHelper.grabAsync({ actor: this });
-
-        global.display.set_cursor(Meta.Cursor.DEFAULT);
+        try {
+            await this._grabHelper.grabAsync({ actor: this });
+        } finally {
+            global.display.set_cursor(Meta.Cursor.DEFAULT);
 
-        GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
-            this.destroy();
-            return GLib.SOURCE_REMOVE;
-        });
+            GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
+                this.destroy();
+                return GLib.SOURCE_REMOVE;
+            });
+        }
 
         return this._result;
     }
@@ -561,15 +563,17 @@ class PickPixel extends St.Widget {
 
         this._pickColor(...global.get_pointer());
 
-        await this._grabHelper.grabAsync({ actor: this });
-
-        global.display.set_cursor(Meta.Cursor.DEFAULT);
-        this._previewCursor.destroy();
+        try {
+            await this._grabHelper.grabAsync({ actor: this });
+        } finally {
+            global.display.set_cursor(Meta.Cursor.DEFAULT);
+            this._previewCursor.destroy();
 
-        GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
-            this.destroy();
-            return GLib.SOURCE_REMOVE;
-        });
+            GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
+                this.destroy();
+                return GLib.SOURCE_REMOVE;
+            });
+        }
 
         return this._result;
     }


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