spice-widget: fixing issue with keyboard already grabbed

Submitted by Julio Faracco on May 20, 2018, 3:50 a.m.

Details

Message ID 20180520035046.4836-1-jcfaracco@gmail.com
State New
Headers show
Series "spice-widget: fixing issue with keyboard already grabbed" ( rev: 2 ) in Spice

Not browsing as part of any series.

Commit Message

Julio Faracco May 20, 2018, 3:50 a.m.
For some reason, after unlocking a locked screen, spice receives an
enter event before focus-in event (this possible a Gtk issue). This
wrong sequence of events is causing a wrong mouse focus. This operation
gives to enter event the ability to grab keyboard and when focus-in
event is raised, keyboard is already grabbed by enter event.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1485968
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1571422

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
---
 src/spice-widget.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/spice-widget.c b/src/spice-widget.c
index 767550b..650c314 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -1805,8 +1805,12 @@  static gboolean enter_event(GtkWidget *widget, GdkEventCrossing *crossing G_GNUC
 
     DISPLAY_DEBUG(display, "%s", __FUNCTION__);
 
-    d->mouse_have_pointer = true;
-    spice_gtk_session_set_mouse_has_pointer(d->gtk_session, true);
+    if (spice_gtk_session_get_keyboard_has_focus(d->gtk_session) &&
+        spice_gtk_session_get_mouse_has_pointer(d->gtk_session)) {
+        d->mouse_have_pointer = true;
+        spice_gtk_session_set_mouse_has_pointer(d->gtk_session, true);
+    }
+
     try_keyboard_grab(display);
     update_display(display);