[spice-gtk] spice-widget: fixing issue with keyboard already grabbed

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

Details

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

Not browsing as part of any series.

Commit Message

Julio Faracco May 21, 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);
 

Comments

Hi,

Thanks for trying to fix this issue.

On Mon, May 21, 2018 at 12:50:38AM -0300, Julio Faracco wrote:
> For some reason, after unlocking a locked screen, spice receives an
> enter event before focus-in event (this possible a Gtk issue).

Yes..

> 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.

.. or we can move back to the deprecated gtk apis that don't
seem to trigger this issue - i.e not using gdk_seat_grab* which
are surrounded by GTK_CHECK_VERSION(3, 20, 0) in spice-widget.c

> 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(-)
>
> 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)) {

Note that we can have the mouse pointer even without keyboard
grab so, I'm not sure this is correct in all possible scenarios
(wayland/x11 and windows).

I'm waiting for feedback from gtk+ folks in both bugs that you
have mentioned. It might be that there is a bug in spice-gtk but
as you have mentioned, the order of the events are weird here and
it seems to happen only when user is going to lock the screen.

Cheers,
        toso

> +        d->mouse_have_pointer = true;
> +        spice_gtk_session_set_mouse_has_pointer(d->gtk_session, true);
> +    }
> +
>      try_keyboard_grab(display);
>      update_display(display);
>
> --
> 2.17.0
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel