Skip to content

Commit

Permalink
Fix deprecated - gdk_window_get_pointer
Browse files Browse the repository at this point in the history
Also fixes #399
  • Loading branch information
Colin Clark committed Jul 5, 2016
1 parent a26318c commit 3e8045c
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 6 deletions.
58 changes: 53 additions & 5 deletions src/collect-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions src/pixbuf-renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
9 changes: 8 additions & 1 deletion src/ui_bookmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,21 +511,28 @@ 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);

#if GTK_CHECK_VERSION(3,0,0)
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);
Expand Down
10 changes: 10 additions & 0 deletions src/ui_tree_edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,14 +575,24 @@ 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)
{
sd->max_step = MIN(sd->region_size, sd->max_step + 2);
}

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);

Expand Down
10 changes: 10 additions & 0 deletions src/view_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
Expand Down
30 changes: 30 additions & 0 deletions src/view_file_icon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3e8045c

Please sign in to comment.