[gnome-shell] altTab: Don't refuse to work when a pointer grab is in place



commit f4d8a35b9d629c7e994fb5e15a59abccfa3932f7
Author: Adel Gadllah <adel gadllah gmail com>
Date:   Fri Oct 21 09:12:17 2011 +0200

    altTab: Don't refuse to work when a pointer grab is in place
    
    Allow push_modal to optionally only work with a keyboard only grab and
    use that in altTab as a fallback to allow switching windows while a pointer grab
    is in effect (like during DND operations).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=660457

 js/ui/altTab.js    |    8 ++++++--
 js/ui/main.js      |    7 +++++--
 src/shell-global.c |    8 ++++----
 src/shell-global.h |    3 ++-
 4 files changed, 17 insertions(+), 9 deletions(-)
---
diff --git a/js/ui/altTab.js b/js/ui/altTab.js
index e17344f..20bad20 100644
--- a/js/ui/altTab.js
+++ b/js/ui/altTab.js
@@ -170,8 +170,12 @@ AltTabPopup.prototype = {
         if (localApps.length == 0 && otherApps.length == 0)
             return false;
 
-        if (!Main.pushModal(this.actor))
-            return false;
+        if (!Main.pushModal(this.actor)) {
+            // Probably someone else has a pointer grab, try again with keyboard only
+            if (!Main.pushModal(this.actor, global.get_current_time(), Meta.ModalOptions.POINTER_ALREADY_GRABBED)) {
+                return false;
+            }
+        }
         this._haveModal = true;
         this._modifierMask = primaryModifier(mask);
 
diff --git a/js/ui/main.js b/js/ui/main.js
index 4c97440..e08de3d 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -668,14 +668,17 @@ function _findModal(actor) {
  * initiated event.  If not provided then the value of
  * global.get_current_time() is assumed.
  *
+ * @options: optional Meta.ModalOptions flags to indicate that the
+ *           pointer is alrady grabbed
+ *
  * Returns: true iff we successfully acquired a grab or already had one
  */
-function pushModal(actor, timestamp) {
+function pushModal(actor, timestamp, options) {
     if (timestamp == undefined)
         timestamp = global.get_current_time();
 
     if (modalCount == 0) {
-        if (!global.begin_modal(timestamp)) {
+        if (!global.begin_modal(timestamp, options ? options : 0)) {
             log('pushModal: invocation of begin_modal failed');
             return false;
         }
diff --git a/src/shell-global.c b/src/shell-global.c
index 13ce7b7..7b3e8f5 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -864,11 +864,11 @@ _shell_global_get_gjs_context (ShellGlobal *global)
  *  was previouly called.
  */
 gboolean
-shell_global_begin_modal (ShellGlobal *global,
-                          guint32      timestamp)
+shell_global_begin_modal (ShellGlobal       *global,
+                          guint32           timestamp,
+                          MetaModalOptions  options)
 {
-  return meta_plugin_begin_modal (global->plugin, global->stage_xwindow,
-                                  None, 0, timestamp);
+  return meta_plugin_begin_modal (global->plugin, global->stage_xwindow, None, options, timestamp);
 }
 
 /**
diff --git a/src/shell-global.h b/src/shell-global.h
index cc5cfe7..dcb1517 100644
--- a/src/shell-global.h
+++ b/src/shell-global.h
@@ -39,7 +39,8 @@ guint32        shell_global_get_current_time          (ShellGlobal *global);
 
 /* Input/event handling */
 gboolean shell_global_begin_modal            (ShellGlobal         *global,
-                                              guint32              timestamp);
+                                              guint32             timestamp,
+                                              MetaModalOptions    options);
 void     shell_global_end_modal              (ShellGlobal         *global,
                                               guint32              timestamp);
 



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