[PATCH] Grab keyboard based on session focus

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

 



When using multiple monitors moving mouse between monitors releases
keyboard grab.

Reproduce bug
-Open multiple monitors remote-viewer session
-Click on one of the monitors to get focus & keyboard-grab
-Move mouse to another monitor and try any keyboard command (do not click)
At this point all keyboard commands are being executed on the client machine
instead of the remote machine

I added additional session focus test in addition to the
monitor focus test when trying keyboard-grab

Resolves: rhbz#1275231

---
-I noticed strange behavior when moving into appliction with alt-tab and then
alt-tab again when mouse is above the unfocused monitor, keyboard
is not being grabbed. when the second alt-tab is above the focused monitor
keyboard is grabbed.

-No GObject properties was set
---
---
 src/spice-gtk-session-priv.h |  2 ++
 src/spice-gtk-session.c      | 18 ++++++++++++++++++
 src/spice-widget.c           |  4 ++--
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/spice-gtk-session-priv.h b/src/spice-gtk-session-priv.h
index 91304b2..2a9b752 100644
--- a/src/spice-gtk-session-priv.h
+++ b/src/spice-gtk-session-priv.h
@@ -28,6 +28,8 @@ gboolean spice_gtk_session_get_read_only(SpiceGtkSession *self);
 void spice_gtk_session_sync_keyboard_modifiers(SpiceGtkSession *self);
 void spice_gtk_session_set_pointer_grabbed(SpiceGtkSession *self, gboolean grabbed);
 gboolean spice_gtk_session_get_pointer_grabbed(SpiceGtkSession *self);
+void spice_gtk_session_set_keyboard_grabbed(SpiceGtkSession *self, gboolean grabbed);
+gboolean spice_gtk_session_get_keyboard_grabbed(SpiceGtkSession *self);
 
 G_END_DECLS
 
diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
index 5abb16c..ae478db 100644
--- a/src/spice-gtk-session.c
+++ b/src/spice-gtk-session.c
@@ -64,6 +64,7 @@ struct _SpiceGtkSessionPrivate {
     gboolean                auto_usbredir_enable;
     int                     auto_usbredir_reqs;
     gboolean                pointer_grabbed;
+    gboolean                keyboard_grabbed;
 };
 
 /**
@@ -1220,6 +1221,15 @@ void spice_gtk_session_set_pointer_grabbed(SpiceGtkSession *self, gboolean grabb
     g_object_notify(G_OBJECT(self), "pointer-grabbed");
 }
 
+
+G_GNUC_INTERNAL
+void spice_gtk_session_set_keyboard_grabbed(SpiceGtkSession *self, gboolean grabbed)
+{
+    g_return_if_fail(SPICE_IS_GTK_SESSION(self));
+
+    self->priv->keyboard_grabbed = grabbed;
+}
+
 G_GNUC_INTERNAL
 gboolean spice_gtk_session_get_pointer_grabbed(SpiceGtkSession *self)
 {
@@ -1227,3 +1237,11 @@ gboolean spice_gtk_session_get_pointer_grabbed(SpiceGtkSession *self)
 
     return self->priv->pointer_grabbed;
 }
+
+G_GNUC_INTERNAL
+gboolean spice_gtk_session_get_keyboard_grabbed(SpiceGtkSession *self)
+{
+    g_return_val_if_fail(SPICE_IS_GTK_SESSION(self), FALSE);
+
+    return self->priv->keyboard_grabbed;
+}
diff --git a/src/spice-widget.c b/src/spice-widget.c
index 503f82a..b2c03a3 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -206,9 +206,9 @@ static void update_size_request(SpiceDisplay *display)
 static void update_keyboard_focus(SpiceDisplay *display, gboolean state)
 {
     SpiceDisplayPrivate *d = display->priv;
-
     d->keyboard_have_focus = state;
 
+    spice_gtk_session_set_keyboard_grabbed(d->gtk_session, state);
     /* keyboard grab gets inhibited by usb-device-manager when it is
        in the process of redirecting a usb-device (as this may show a
        policykit dialog). Making autoredir/automount setting changes while
@@ -737,7 +737,7 @@ static void try_keyboard_grab(SpiceDisplay *display)
         return;
     if (d->keyboard_grab_active)
         return;
-    if (!d->keyboard_have_focus)
+    if (!spice_gtk_session_get_keyboard_grabbed(d->gtk_session))
         return;
     if (!d->mouse_have_pointer)
         return;
-- 
2.4.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]