From aa9a83b64ac38330991168ab799d482960e07437 Mon Sep 17 00:00:00 2001 From: raveit65 Date: Fri, 24 Jun 2016 17:14:26 +0200 Subject: GTK+-3: Use ev_document_misc_get_pointer_position() instad of deprecated gtk_widget_get_pointer() --- libdocument/ev-document-misc.c | 45 ++++++++++++++++++++++++++++++++++++++++++ libdocument/ev-document-misc.h | 6 ++++++ 2 files changed, 51 insertions(+) (limited to 'libdocument') diff --git a/libdocument/ev-document-misc.c b/libdocument/ev-document-misc.c index a695c050..a0ba4785 100644 --- a/libdocument/ev-document-misc.c +++ b/libdocument/ev-document-misc.c @@ -425,3 +425,48 @@ ev_document_misc_format_date (GTime utime) return g_locale_to_utf8 (s, -1, NULL, NULL, NULL); } + +#if GTK_CHECK_VERSION(3, 0, 0) +void +ev_document_misc_get_pointer_position (GtkWidget *widget, + gint *x, + gint *y) +{ +#if GTK_CHECK_VERSION (3, 20, 0) + GdkSeat *seat; +#else + GdkDeviceManager *device_manager; +#endif + GdkDevice *device_pointer; + GdkRectangle allocation; + + if (x) + *x = -1; + if (y) + *y = -1; + + if (!gtk_widget_get_realized (widget)) + return; + +#if GTK_CHECK_VERSION(3, 20, 0) + seat = gdk_display_get_default_seat (gtk_widget_get_display (widget)); + device_pointer = gdk_seat_get_pointer (seat); +#else + device_manager = gdk_display_get_device_manager (gtk_widget_get_display (widget)); + device_pointer = gdk_device_manager_get_client_pointer (device_manager); +#endif + gdk_window_get_device_position (gtk_widget_get_window (widget), + device_pointer, + x, y, NULL); + + if (gtk_widget_get_has_window (widget)) + return; + + gtk_widget_get_allocation (widget, &allocation); + if (x) + *x -= allocation.x; + if (y) + *y -= allocation.y; +} +#endif + diff --git a/libdocument/ev-document-misc.h b/libdocument/ev-document-misc.h index 3eac99a1..e6ddf02a 100644 --- a/libdocument/ev-document-misc.h +++ b/libdocument/ev-document-misc.h @@ -62,6 +62,12 @@ gdouble ev_document_misc_get_screen_dpi (GdkScreen *screen); gchar *ev_document_misc_format_date (GTime utime); +#if GTK_CHECK_VERSION(3, 0, 0) +void ev_document_misc_get_pointer_position (GtkWidget *widget, + gint *x, + gint *y); +#endif + G_END_DECLS #endif /* EV_DOCUMENT_MISC_H */ -- cgit v1.2.1