qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PULL v2 16/17] gtk: update grab code for gtk 3.20
Date: Fri, 13 May 2016 14:32:56 +0200	[thread overview]
Message-ID: <1463142777-13040-17-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1463142777-13040-1-git-send-email-kraxel@redhat.com>

Fixes the remaining gtk 3.20 warnings.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Tested-by: Cole Robinson <crobinso@redhat.com>
Message-id: 1463038146-13939-1-git-send-email-kraxel@redhat.com
---
 ui/gtk.c | 49 +++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 43 insertions(+), 6 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 2c0f20b..a7d8a8b 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1329,7 +1329,31 @@ static void gd_menu_zoom_fit(GtkMenuItem *item, void *opaque)
     gd_update_full_redraw(vc);
 }
 
-#if GTK_CHECK_VERSION(3, 0, 0)
+#if GTK_CHECK_VERSION(3, 20, 0)
+static void gd_grab_update(VirtualConsole *vc, bool kbd, bool ptr)
+{
+    GdkDisplay *display = gtk_widget_get_display(vc->gfx.drawing_area);
+    GdkSeat *seat = gdk_display_get_default_seat(display);
+    GdkWindow *window = gtk_widget_get_window(vc->gfx.drawing_area);
+    GdkSeatCapabilities caps = 0;
+    GdkCursor *cursor = NULL;
+
+    if (kbd) {
+        caps |= GDK_SEAT_CAPABILITY_KEYBOARD;
+    }
+    if (ptr) {
+        caps |= GDK_SEAT_CAPABILITY_ALL_POINTING;
+        cursor = vc->s->null_cursor;
+    }
+
+    if (caps) {
+        gdk_seat_grab(seat, window, caps, false, cursor,
+                      NULL, NULL, NULL);
+    } else {
+        gdk_seat_ungrab(seat);
+    }
+}
+#elif GTK_CHECK_VERSION(3, 0, 0)
 static void gd_grab_devices(VirtualConsole *vc, bool grab,
                             GdkInputSource source, GdkEventMask mask,
                             GdkCursor *cursor)
@@ -1366,7 +1390,9 @@ static void gd_grab_keyboard(VirtualConsole *vc, const char *reason)
         }
     }
 
-#if GTK_CHECK_VERSION(3, 0, 0)
+#if GTK_CHECK_VERSION(3, 20, 0)
+    gd_grab_update(vc, true, vc->s->ptr_owner == vc);
+#elif GTK_CHECK_VERSION(3, 0, 0)
     gd_grab_devices(vc, true, GDK_SOURCE_KEYBOARD,
                    GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
                    NULL);
@@ -1389,7 +1415,9 @@ static void gd_ungrab_keyboard(GtkDisplayState *s)
     }
     s->kbd_owner = NULL;
 
-#if GTK_CHECK_VERSION(3, 0, 0)
+#if GTK_CHECK_VERSION(3, 20, 0)
+    gd_grab_update(vc, false, vc->s->ptr_owner == vc);
+#elif GTK_CHECK_VERSION(3, 0, 0)
     gd_grab_devices(vc, false, GDK_SOURCE_KEYBOARD, 0, NULL);
 #else
     gdk_keyboard_ungrab(GDK_CURRENT_TIME);
@@ -1410,7 +1438,11 @@ static void gd_grab_pointer(VirtualConsole *vc, const char *reason)
         }
     }
 
-#if GTK_CHECK_VERSION(3, 0, 0)
+#if GTK_CHECK_VERSION(3, 20, 0)
+    gd_grab_update(vc, vc->s->kbd_owner == vc, true);
+    gdk_device_get_position(gd_get_pointer(display),
+                            NULL, &vc->s->grab_x_root, &vc->s->grab_y_root);
+#elif GTK_CHECK_VERSION(3, 0, 0)
     gd_grab_devices(vc, true, GDK_SOURCE_MOUSE,
                     GDK_POINTER_MOTION_MASK |
                     GDK_BUTTON_PRESS_MASK |
@@ -1442,14 +1474,19 @@ static void gd_grab_pointer(VirtualConsole *vc, const char *reason)
 static void gd_ungrab_pointer(GtkDisplayState *s)
 {
     VirtualConsole *vc = s->ptr_owner;
+    GdkDisplay *display = gtk_widget_get_display(vc->gfx.drawing_area);
 
     if (vc == NULL) {
         return;
     }
     s->ptr_owner = NULL;
 
-    GdkDisplay *display = gtk_widget_get_display(vc->gfx.drawing_area);
-#if GTK_CHECK_VERSION(3, 0, 0)
+#if GTK_CHECK_VERSION(3, 20, 0)
+    gd_grab_update(vc, vc->s->kbd_owner == vc, false);
+    gdk_device_warp(gd_get_pointer(display),
+                    gtk_widget_get_screen(vc->gfx.drawing_area),
+                    vc->s->grab_x_root, vc->s->grab_y_root);
+#elif GTK_CHECK_VERSION(3, 0, 0)
     gd_grab_devices(vc, false, GDK_SOURCE_MOUSE, 0, NULL);
     gdk_device_warp(gd_get_pointer(display),
                     gtk_widget_get_screen(vc->gfx.drawing_area),
-- 
1.8.3.1

  parent reply	other threads:[~2016-05-13 12:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-13 12:32 [Qemu-devel] [PULL v2 00/17] ui patch queue Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 01/17] ui: gtk: fix crash when terminal inner-border is NULL Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 02/17] ui: sdl2: Release grab before opening console window Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 03/17] configure: build SDL if only SDL2 available Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 04/17] configure: error on unknown --with-sdlabi value Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 05/17] configure: add echo_version helper Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 06/17] configure: report GTK version Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 07/17] configure: report SDL version Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 08/17] configure: support vte-2.91 Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 09/17] ui: gtk: Fix a runtime warning on vte >= 0.37 Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 10/17] ui: gtk: Fix some deprecation warnings Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 11/17] ui/gtk: copy to clipboard support Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 12/17] spice/gl: add & use qemu_spice_gl_monitor_config Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 13/17] Changed malloc to g_malloc, free to g_free in ui/shader.c Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 14/17] egl-helpers: fix possible resource leak Gerd Hoffmann
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 15/17] spice: fix coverity complains Gerd Hoffmann
2016-05-13 12:32 ` Gerd Hoffmann [this message]
2016-05-20  7:55   ` [Qemu-devel] [PULL v2 16/17] gtk: update grab code for gtk 3.20 Paolo Bonzini
2016-05-13 12:32 ` [Qemu-devel] [PULL v2 17/17] gtk: don't leak the GtkBorder with VTE 0.36 Gerd Hoffmann
2016-05-13 14:39 ` [Qemu-devel] [PULL v2 00/17] ui patch queue Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1463142777-13040-17-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).