[ui/gtk,07/13] Conditionalize use of gdk_display_warp_pointer

Submitted by Daniel P. Berrange on Feb. 25, 2013, 3:20 p.m.

Details

Message ID 1361805646-6425-8-git-send-email-berrange@redhat.com
State New
Headers show

Commit Message

Daniel P. Berrange Feb. 25, 2013, 3:20 p.m.
From: "Daniel P. Berrange" <berrange@redhat.com>

In GTK3 the gdk_display_warp_pointer method is deprecated.
Instead we should use gdk_device_warp on the GdkDevice
instead associated with the event being processed.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 ui/gtk.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/ui/gtk.c b/ui/gtk.c
index 182a16c..93c3b43 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -501,7 +501,6 @@  static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
     }
 
     if (!kbd_mouse_is_absolute() && gd_is_grab_active(s)) {
-        GdkDisplay *display = gtk_widget_get_display(s->drawing_area);
         GdkScreen *screen = gtk_widget_get_screen(s->drawing_area);
         int x = (int)motion->x_root;
         int y = (int)motion->y_root;
@@ -527,7 +526,13 @@  static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
         }
 
         if (x != (int)motion->x_root || y != (int)motion->y_root) {
+#if GTK_CHECK_VERSION(3, 0, 0)
+            GdkDevice *dev = gdk_event_get_device((GdkEvent *)motion);
+            gdk_device_warp(dev, screen, x, y);
+#else
+            GdkDisplay *display = gtk_widget_get_display(widget);
             gdk_display_warp_pointer(display, screen, x, y);
+#endif
             s->last_x = -1;
             s->last_y = -1;
             return FALSE;