<div dir="ltr"><div><div>The intention of those commits was to be ready for new things (wayland, gtk4... wait, actually gtk3). That side effect was not desired...</div><div> </div><div>I'm not sure whether is better to revert it completely and go back to gtk2 api.</div><div><br></div></div><div>Ack,<br></div><div>Pavel<br></div><div><br></div><div><div></div><div>If there is a bug/regression in gtk+, it'd be good to have reference to it in the commit ;)</div><br></div><div>Maybe it's easier for you to come up with a simple gtk reproducer since you analyzed the issue properly.</div><div><div></div><div>If the comment is still valid, pity that the gtk+ bug did not get any reaction (in the bug report).</div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2018-05-22 8:42 GMT+02:00 Victor Toso <span dir="ltr"><<a href="mailto:victortoso@redhat.com" target="_blank">victortoso@redhat.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Victor Toso <<a href="mailto:me@victortoso.com">me@victortoso.com</a>><br>
<br>
We are using those APIs to avoid the deprecated ones from GTK but<br>
unexpected events are handled different by them introducing a<br>
regression that is easy to reproduce when Spice client holds the<br>
focus and user locks the screen.<br>
<br>
We need to better handle the situation where gdk_seat_grab() fails,<br>
specifically with GDK_GRAB_ALREADY_GRABBED which is the situation<br>
for the bugs mentioned below. The grab does not fail with older API<br>
in the same situation.<br>
<br>
Note that gdk_seat_grab() returning GDK_GRAB_ALREADY_GRABBED is due<br>
the locking screen holding the keyboard device which also means that<br>
remote-viewer isn't visible/show but gdk_window_is_visible() returns<br>
true till gdk_seat_grab() is called. The failure in gtk+ function<br>
call sets the visibility to false and the next gdk_seat_grab() call<br>
does return GDK_GRAB_NOT_VIEWABLE and gdk_window_is_visible() false<br>
as it should.<br>
<br>
So, gtk+ needs to fix some behavior and spice-gtk improve error<br>
handle but till then, let's avoid the regression for users.<br>
<br>
This patch basically avoid the changes introduced by following<br>
commits:<br>
<br>
| commit 283f41cd289084689fbdf1151da55a<wbr>a451ba343c<br>
| gtk: Use gdk_window_get_device_position<br>
|<br>
| commit a718aec66658ba6bb3bb45a9af81a3<wbr>aa2a652d18<br>
| widget: Use deprecated function to ungrab device<br>
|<br>
| commit 3f4c5bcc88ca5db125ec48ebf696cb<wbr>23a8e6339a<br>
| gtk: Avoid deprecated gdk_keyboard_grab<br>
|<br>
| commit ef7a6fa1798c8e53c0b77330b398a7<wbr>8181cf90e5<br>
| gtk: Avoid deprecated gdk_pointer_grab<br>
<br>
Related: <a href="https://bugzilla.redhat.com/show_bug.cgi?id=1485968" rel="noreferrer" target="_blank">https://bugzilla.redhat.com/<wbr>show_bug.cgi?id=1485968</a><br>
Related: <a href="https://bugzilla.redhat.com/show_bug.cgi?id=1571422" rel="noreferrer" target="_blank">https://bugzilla.redhat.com/<wbr>show_bug.cgi?id=1571422</a><br>
<br>
Signed-off-by: Victor Toso <<a href="mailto:victortoso@redhat.com">victortoso@redhat.com</a>><br>
---<br>
src/spice-widget.c | 12 ++++++------<br>
1 file changed, 6 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/src/spice-widget.c b/src/spice-widget.c<br>
index 72f5334..ec6a197 100644<br>
--- a/src/spice-widget.c<br>
+++ b/src/spice-widget.c<br>
@@ -811,7 +811,7 @@ SpiceGrabSequence *spice_display_get_grab_keys(<wbr>SpiceDisplay *display)<br>
return d->grabseq;<br>
}<br>
<br>
-#if GTK_CHECK_VERSION(3, 20, 0)<br>
+#if 0 && GTK_CHECK_VERSION(3, 20, 0)<br>
static GdkSeat *spice_display_get_default_<wbr>seat(SpiceDisplay *display)<br>
{<br>
GdkWindow *window = gtk_widget_get_window(GTK_<wbr>WIDGET(display));<br>
@@ -867,7 +867,7 @@ static void try_keyboard_grab(SpiceDisplay *display)<br>
GetModuleHandle(NULL), 0);<br>
g_warn_if_fail(d->keyboard_<wbr>hook != NULL);<br>
#endif<br>
-#if GTK_CHECK_VERSION(3, 20, 0)<br>
+#if 0 && GTK_CHECK_VERSION(3, 20, 0)<br>
status = gdk_seat_grab(spice_display_<wbr>get_default_seat(display),<br>
gtk_widget_get_window(widget),<br>
GDK_SEAT_CAPABILITY_KEYBOARD,<br>
@@ -892,7 +892,7 @@ static void try_keyboard_grab(SpiceDisplay *display)<br>
static void ungrab_keyboard(G_GNUC_UNUSED SpiceDisplay *display)<br>
{<br>
G_GNUC_BEGIN_IGNORE_<wbr>DEPRECATIONS<br>
-#if GTK_CHECK_VERSION(3, 20, 0)<br>
+#if 0 && GTK_CHECK_VERSION(3, 20, 0)<br>
/* we want to ungrab just the keyboard - it is not possible using gdk_seat_ungrab().<br>
See also <a href="https://bugzilla.gnome.org/show_bug.cgi?id=780133" rel="noreferrer" target="_blank">https://bugzilla.gnome.org/<wbr>show_bug.cgi?id=780133</a> */<br>
GdkDevice *keyboard = gdk_seat_get_keyboard(spice_<wbr>display_get_default_seat(<wbr>display));<br>
@@ -1042,7 +1042,7 @@ static gboolean do_pointer_grab(SpiceDisplay *display)<br>
<br>
try_keyboard_grab(display);<br>
G_GNUC_BEGIN_IGNORE_<wbr>DEPRECATIONS<br>
-#if GTK_CHECK_VERSION(3, 20, 0)<br>
+#if 0 && GTK_CHECK_VERSION(3, 20, 0)<br>
status = gdk_seat_grab(spice_display_<wbr>get_default_seat(display),<br>
window,<br>
GDK_SEAT_CAPABILITY_ALL_<wbr>POINTING,<br>
@@ -1174,7 +1174,7 @@ static void mouse_wrap(SpiceDisplay *display, GdkEventMotion *motion)<br>
static void ungrab_pointer(G_GNUC_UNUSED SpiceDisplay *display)<br>
{<br>
G_GNUC_BEGIN_IGNORE_<wbr>DEPRECATIONS<br>
-#if GTK_CHECK_VERSION(3, 20, 0)<br>
+#if 0 && GTK_CHECK_VERSION(3, 20, 0)<br>
/* we want to ungrab just the pointer - it is not possible using gdk_seat_ungrab().<br>
See also <a href="https://bugzilla.gnome.org/show_bug.cgi?id=780133" rel="noreferrer" target="_blank">https://bugzilla.gnome.org/<wbr>show_bug.cgi?id=780133</a> */<br>
GdkDevice *pointer = gdk_seat_get_pointer(spice_<wbr>display_get_default_seat(<wbr>display));<br>
@@ -2431,7 +2431,7 @@ static GdkDevice *spice_gdk_window_get_<wbr>pointing_device(GdkWindow *window)<br>
{<br>
GdkDisplay *gdk_display = gdk_window_get_display(window)<wbr>;<br>
G_GNUC_BEGIN_IGNORE_<wbr>DEPRECATIONS<br>
-#if GTK_CHECK_VERSION(3, 20, 0)<br>
+#if 0 && GTK_CHECK_VERSION(3, 20, 0)<br>
return gdk_seat_get_pointer(gdk_<wbr>display_get_default_seat(gdk_<wbr>display));<br>
#else<br>
return gdk_device_manager_get_client_<wbr>pointer(gdk_display_get_<wbr>device_manager(gdk_display));<br>
<span class="HOEnZb"><font color="#888888">-- <br>
2.17.0<br>
<br>
______________________________<wbr>_________________<br>
Spice-devel mailing list<br>
<a href="mailto:Spice-devel@lists.freedesktop.org">Spice-devel@lists.freedesktop.<wbr>org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/spice-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/spice-devel</a><br>
</font></span></blockquote></div><br></div>