[gnome-shell/wip/carlosg/grabs-pt2: 6/15] main: Use Clutter.grab() underneath Main.push/popModal




commit e56123ce0d9dbae8aa0683991b323b9f11723505
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Nov 18 00:36:44 2021 +0100

    main: Use Clutter.grab() underneath Main.push/popModal

 js/ui/main.js | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/js/ui/main.js b/js/ui/main.js
index 19735ccc0e..cc77eaa5a6 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -540,13 +540,10 @@ function pushModal(actor, params) {
                                     options: 0,
                                     actionMode: Shell.ActionMode.NONE });
 
-    if (modalCount == 0) {
-        if (!global.begin_modal(params.timestamp, params.options)) {
-            log('pushModal: invocation of begin_modal failed');
-            return false;
-        }
+    let grab = global.stage.grab(actor);
+
+    if (modalCount === 0)
         Meta.disable_unredirect_for_display(global.display);
-    }
 
     modalCount += 1;
     let actorDestroyId = actor.connect('destroy', () => {
@@ -567,10 +564,12 @@ function pushModal(actor, params) {
         });
     }
     modalActorFocusStack.push({ actor,
-                                destroyId: actorDestroyId,
-                                prevFocus,
-                                prevFocusDestroyId,
-                                actionMode });
+        grab,
+        destroyId: actorDestroyId,
+        prevFocus,
+        prevFocusDestroyId,
+        actionMode,
+    });
 
     actionMode = params.actionMode;
     global.stage.set_key_focus(actor);
@@ -598,7 +597,6 @@ function popModal(actor, timestamp) {
     let focusIndex = _findModal(actor);
     if (focusIndex < 0) {
         global.stage.set_key_focus(null);
-        global.end_modal(timestamp);
         actionMode = Shell.ActionMode.NORMAL;
 
         throw new Error('incorrect pop');
@@ -609,6 +607,9 @@ function popModal(actor, timestamp) {
     let record = modalActorFocusStack[focusIndex];
     record.actor.disconnect(record.destroyId);
 
+    let grab = record.grab;
+    grab.dismiss();
+
     if (focusIndex == modalActorFocusStack.length - 1) {
         if (record.prevFocus)
             record.prevFocus.disconnect(record.prevFocusDestroyId);
@@ -646,7 +647,6 @@ function popModal(actor, timestamp) {
         return;
 
     layoutManager.modalEnded();
-    global.end_modal(timestamp);
     Meta.enable_unredirect_for_display(global.display);
     actionMode = Shell.ActionMode.NORMAL;
 }


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