Fix deprecated - gdk_window_get_pointer
authorColin Clark <cclark@mcb.net>
Tue, 5 Jul 2016 18:47:40 +0000 (19:47 +0100)
committerColin Clark <cclark@mcb.net>
Tue, 5 Jul 2016 18:47:40 +0000 (19:47 +0100)
Also fixes https://github.com/BestImageViewer/geeqie/issues/399

src/collect-table.c
src/pixbuf-renderer.c
src/ui_bookmark.c
src/ui_tree_edit.c
src/view_dir.c
src/view_file_icon.c

index 1e70f6a..2695640 100644 (file)
@@ -527,11 +527,23 @@ static void tip_show(CollectTable *ct)
 {
        GtkWidget *label;
        gint x, y;
-       gint x_win = 0, y_win = 0;
+#if GTK_CHECK_VERSION(3,0,0)
+       GdkDisplay *display;
+       GdkDeviceManager *device_manager;
+       GdkDevice *device;
+#endif
 
        if (ct->tip_window) return;
 
+#if GTK_CHECK_VERSION(3,0,0)
+       device_manager = gdk_display_get_device_manager(gdk_window_get_display(
+                                                               gtk_widget_get_window(ct->listview)));
+       device = gdk_device_manager_get_client_pointer(device_manager);
+       gdk_window_get_device_position(gtk_widget_get_window(ct->listview),
+                                                               device, &x, &y, NULL);
+#else
        gdk_window_get_pointer(gtk_widget_get_window(ct->listview), &x, &y, NULL);
+#endif
 
        ct->tip_info = collection_table_find_data_by_coord(ct, x, y, NULL);
        if (!ct->tip_info) return;
@@ -547,13 +559,16 @@ static void tip_show(CollectTable *ct)
        gtk_widget_show(label);
 
 #if GTK_CHECK_VERSION(3,0,0)
-       gdk_window_get_origin(gtk_widget_get_window(ct->listview), &x_win, &y_win);
+       display = gdk_display_get_default();
+       device_manager = gdk_display_get_device_manager(display);
+       device = gdk_device_manager_get_client_pointer(device_manager);
+       gdk_device_get_position(device, NULL, &x, &y);
 #else
        gdk_window_get_pointer(NULL, &x, &y, NULL);
 #endif
 
        if (!gtk_widget_get_realized(ct->tip_window)) gtk_widget_realize(ct->tip_window);
-       gtk_window_move(GTK_WINDOW(ct->tip_window), x_win + x + 16, y_win + y + 16);
+       gtk_window_move(GTK_WINDOW(ct->tip_window), x + 16, y + 16);
        gtk_widget_show(ct->tip_window);
 }
 
@@ -601,13 +616,22 @@ static void tip_unschedule(CollectTable *ct)
 
 static void tip_update(CollectTable *ct, CollectInfo *info)
 {
+#if GTK_CHECK_VERSION(3,0,0)
+       GdkDisplay *display = gdk_display_get_default();
+       GdkDeviceManager *device_manager = gdk_display_get_device_manager(display);
+       GdkDevice *device = gdk_device_manager_get_client_pointer(device_manager);
+#endif
+
        tip_schedule(ct);
 
        if (ct->tip_window)
                {
                gint x, y;
-
+#if GTK_CHECK_VERSION(3,0,0)
+               gdk_device_get_position(device, NULL, &x, &y);
+#else
                gdk_window_get_pointer(NULL, &x, &y, NULL);
+#endif
                gtk_window_move(GTK_WINDOW(ct->tip_window), x + 16, y + 16);
 
                if (info != ct->tip_info)
@@ -1272,11 +1296,25 @@ static CollectInfo *collection_table_insert_find(CollectTable *ct, CollectInfo *
        GtkTreeIter iter;
        GtkTreePath *tpath;
        GtkTreeViewColumn *column;
+#if GTK_CHECK_VERSION(3,0,0)
+       GdkDeviceManager *device_manager;
+       GdkDevice *device;
+#endif
 
        store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview));
 
+#if GTK_CHECK_VERSION(3,0,0)
+       if (!use_coord)
+               {
+               device_manager = gdk_display_get_device_manager(gdk_window_get_display(
+                                                                       gtk_widget_get_window(ct->listview)));
+               device = gdk_device_manager_get_client_pointer(device_manager);
+               gdk_window_get_device_position(gtk_widget_get_window(ct->listview),
+                                                                       device, &x, &y, NULL);
+               }
+#else
        if (!use_coord) gdk_window_get_pointer(gtk_widget_get_window(ct->listview), &x, &y, NULL);
-
+#endif
        if (source)
                {
                gint col;
@@ -1490,11 +1528,21 @@ static gboolean collection_table_auto_scroll_idle_cb(gpointer data)
        GdkWindow *window;
        gint x, y;
        gint w, h;
+#if GTK_CHECK_VERSION(3,0,0)
+       GdkDeviceManager *device_manager;
+       GdkDevice *device;
+#endif
 
        if (!ct->drop_idle_id) return FALSE;
 
        window = gtk_widget_get_window(ct->listview);
+#if GTK_CHECK_VERSION(3,0,0)
+       device_manager = gdk_display_get_device_manager(gdk_window_get_display(window));
+       device = gdk_device_manager_get_client_pointer(device_manager);
+       gdk_window_get_device_position(window, device, &x, &y, NULL);
+#else
        gdk_window_get_pointer(window, &x, &y, NULL);
+#endif
        w = gdk_window_get_width(window);
        h = gdk_window_get_height(window);
        if (x >= 0 && x < w && y >= 0 && y < h)
index 327e398..c654e45 100644 (file)
@@ -1959,11 +1959,21 @@ static gboolean pr_mouse_motion_cb(GtkWidget *widget, GdkEventButton *bevent, gp
 {
        PixbufRenderer *pr;
        gint accel;
+#if GTK_CHECK_VERSION(3,0,0)
+       GdkDeviceManager *device_manager;
+       GdkDevice *device;
+#endif
 
        /* This is a hack, but work far the best, at least for single pointer systems.
         * See http://bugzilla.gnome.org/show_bug.cgi?id=587714 for more. */
        gint x, y;
+#if GTK_CHECK_VERSION(3,0,0)
+       device_manager = gdk_display_get_device_manager(gdk_window_get_display(bevent->window));
+       device = gdk_device_manager_get_client_pointer(device_manager);
+       gdk_window_get_device_position(bevent->window, device, &x, &y, NULL);
+#else
        gdk_window_get_pointer (bevent->window, &x, &y, NULL);
+#endif
        bevent->x = x;
        bevent->y = y;
 
index 517be7b..2de1a44 100644 (file)
@@ -511,6 +511,10 @@ static void bookmark_drag_begin(GtkWidget *button, GdkDragContext *context, gpoi
        GdkModifierType mask;
        gint x, y;
        GtkAllocation allocation;
+#if GTK_CHECK_VERSION(3,0,0)
+       GdkDeviceManager *device_manager;
+       GdkDevice *device;
+#endif
 
        gtk_widget_get_allocation(button, &allocation);
 
@@ -518,14 +522,17 @@ static void bookmark_drag_begin(GtkWidget *button, GdkDragContext *context, gpoi
        pixbuf = gdk_pixbuf_get_from_window(gtk_widget_get_window(button),
                                            allocation.x, allocation.y,
                                            allocation.width, allocation.height);
+       device_manager = gdk_display_get_device_manager(gdk_window_get_display(button));
+       device = gdk_device_manager_get_client_pointer(device_manager);
+       gdk_window_get_device_position(gtk_widget_get_window(button), device, &x, &y, &mask);
 #else
        pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8,
                                allocation.width, allocation.height);
        gdk_pixbuf_get_from_drawable(pixbuf, gtk_widget_get_window(button), NULL,
                                     allocation.x, allocation.y,
                                     0, 0, allocation.width, allocation.height);
-#endif
        gdk_window_get_pointer(gtk_widget_get_window(button), &x, &y, &mask);
+#endif
 
        gtk_drag_set_icon_pixbuf(context, pixbuf,
                                 x - allocation.x, y - allocation.y);
index eeb13d2..0fe4b23 100644 (file)
@@ -575,6 +575,10 @@ static gboolean widget_auto_scroll_cb(gpointer data)
        gint x, y;
        gint w, h;
        gint amt = 0;
+#if GTK_CHECK_VERSION(3,0,0)
+       GdkDeviceManager *device_manager;
+       GdkDevice *device;
+#endif
 
        if (sd->max_step < sd->region_size)
                {
@@ -582,7 +586,13 @@ static gboolean widget_auto_scroll_cb(gpointer data)
                }
 
        window = gtk_widget_get_window(sd->widget);
+#if GTK_CHECK_VERSION(3,0,0)
+       device_manager = gdk_display_get_device_manager(gdk_window_get_display(window));
+       device = gdk_device_manager_get_client_pointer(device_manager);
+       gdk_window_get_device_position(window, device, &x, &y, NULL);
+#else
        gdk_window_get_pointer(window, &x, &y, NULL);
+#endif
        w = gdk_window_get_width(window);
        h = gdk_window_get_height(window);
 
index cfe3fc2..bc7c85a 100644 (file)
@@ -865,6 +865,10 @@ void vd_dnd_drop_scroll_cancel(ViewDir *vd)
 static gboolean vd_auto_scroll_idle_cb(gpointer data)
 {
        ViewDir *vd = data;
+#if GTK_CHECK_VERSION(3,0,0)
+       GdkDeviceManager *device_manager;
+       GdkDevice *device;
+#endif
 
        if (vd->drop_fd)
                {
@@ -873,7 +877,13 @@ static gboolean vd_auto_scroll_idle_cb(gpointer data)
                gint w, h;
 
                window = gtk_widget_get_window(vd->view);
+#if GTK_CHECK_VERSION(3,0,0)
+               device_manager = gdk_display_get_device_manager(gdk_window_get_display(window));
+               device = gdk_device_manager_get_client_pointer(device_manager);
+               gdk_window_get_device_position(window, device, &x, &y, NULL);
+#else
                gdk_window_get_pointer(window, &x, &y, NULL);
+#endif
                w = gdk_window_get_width(window);
                h = gdk_window_get_height(window);
                if (x >= 0 && x < w && y >= 0 && y < h)
index ec7ec3a..1457f81 100644 (file)
@@ -390,10 +390,23 @@ static void tip_show(ViewFile *vf)
 {
        GtkWidget *label;
        gint x, y;
+#if GTK_CHECK_VERSION(3,0,0)
+       GdkDisplay *display;
+       GdkDeviceManager *device_manager;
+       GdkDevice *device;
+#endif
 
        if (VFICON(vf)->tip_window) return;
 
+#if GTK_CHECK_VERSION(3,0,0)
+       device_manager = gdk_display_get_device_manager(gdk_window_get_display(
+                                               gtk_tree_view_get_bin_window(GTK_TREE_VIEW(vf->listview))));
+       device = gdk_device_manager_get_client_pointer(device_manager);
+       gdk_window_get_device_position(gtk_tree_view_get_bin_window(GTK_TREE_VIEW(vf->listview)),
+                                               device, &x, &y, NULL);
+#else
        gdk_window_get_pointer(gtk_tree_view_get_bin_window(GTK_TREE_VIEW(vf->listview)), &x, &y, NULL);
+#endif
 
        VFICON(vf)->tip_id = vficon_find_data_by_coord(vf, x, y, NULL);
        if (!VFICON(vf)->tip_id) return;
@@ -408,7 +421,14 @@ static void tip_show(ViewFile *vf)
        gtk_container_add(GTK_CONTAINER(VFICON(vf)->tip_window), label);
        gtk_widget_show(label);
 
+#if GTK_CHECK_VERSION(3,0,0)
+       display = gdk_display_get_default();
+       device_manager = gdk_display_get_device_manager(display);
+       device = gdk_device_manager_get_client_pointer(device_manager);
+       gdk_device_get_position(device, NULL, &x, &y);
+#else
        gdk_window_get_pointer(NULL, &x, &y, NULL);
+#endif
 
        if (!gtk_widget_get_realized(VFICON(vf)->tip_window)) gtk_widget_realize(VFICON(vf)->tip_window);
        gtk_window_move(GTK_WINDOW(VFICON(vf)->tip_window), x + 16, y + 16);
@@ -469,11 +489,21 @@ static void tip_unschedule(ViewFile *vf)
 
 static void tip_update(ViewFile *vf, IconData *id)
 {
+#if GTK_CHECK_VERSION(3,0,0)
+       GdkDisplay *display = gdk_display_get_default();
+       GdkDeviceManager *device_manager = gdk_display_get_device_manager(display);
+       GdkDevice *device = gdk_device_manager_get_client_pointer(device_manager);
+#endif
+
        if (VFICON(vf)->tip_window)
                {
                gint x, y;
 
+#if GTK_CHECK_VERSION(3,0,0)
+               gdk_device_get_position(device, NULL, &x, &y);
+#else
                gdk_window_get_pointer(NULL, &x, &y, NULL);
+#endif
                gtk_window_move(GTK_WINDOW(VFICON(vf)->tip_window), x + 16, y + 16);
 
                if (id != VFICON(vf)->tip_id)