[gnome-boxes] display-page: Hint about keyboard grab



commit 27435e07e3f7803b8160c70866a66c124f7776c9
Author: Pavel Grunt <pgrunt redhat com>
Date:   Mon Feb 9 10:07:43 2015 +0100

    display-page: Hint about keyboard grab
    
    Inform users how to release the keyboard grab.
    
    Co-author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=743319

 src/display-page.vala |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/src/display-page.vala b/src/display-page.vala
index 1cc5d8e..37f8270 100644
--- a/src/display-page.vala
+++ b/src/display-page.vala
@@ -45,6 +45,7 @@ private class Boxes.DisplayPage: Gtk.Box {
     }
     private ulong can_grab_mouse_id;
     private ulong mouse_grabbed_id;
+    private ulong keyboard_grabbed_id;
 
     public void setup_ui (AppWindow window) {
         this.window = window;
@@ -101,9 +102,12 @@ private class Boxes.DisplayPage: Gtk.Box {
         return_if_fail (machine != null);
 
         string? hint = null;
-        if (mouse_grabbed)
-            hint = _("Press (left) Ctrl+Alt to ungrab");
-
+        if (can_grab_mouse) {
+            if (mouse_grabbed)
+                hint = _("Press (left) Ctrl+Alt to ungrab");
+        } else if (keyboard_grabbed) {
+            hint = _("Press & release (left) Ctrl+Alt to ungrab keyboard.");
+        }
         toolbar.set_subtitle (hint);
     }
 
@@ -130,6 +134,12 @@ private class Boxes.DisplayPage: Gtk.Box {
                 return false;
             });
         });
+        keyboard_grabbed_id = display.notify["keyboard-grabbed"].connect(() => {
+            Idle.add_full (Priority.HIGH, () => {
+                update_subtitle ();
+                return false;
+            });
+        });
         update_toolbar_visible ();
         can_grab_mouse_id = display.notify["can-grab-mouse"].connect(() => {
             update_toolbar_visible ();
@@ -171,6 +181,11 @@ private class Boxes.DisplayPage: Gtk.Box {
             can_grab_mouse_id = 0;
         }
 
+        if (keyboard_grabbed_id != 0) {
+            display.disconnect (keyboard_grabbed_id);
+            keyboard_grabbed_id = 0;
+        }
+
         var widget = event_box.get_child ();
 
         if (cursor_id != 0) {


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