diff options
author | raveit65 <[email protected]> | 2016-06-24 17:14:26 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2016-06-29 16:23:03 +0200 |
commit | aa9a83b64ac38330991168ab799d482960e07437 (patch) | |
tree | c2004fa518b41740fd221939c581470fa464c86d /libdocument/ev-document-misc.c | |
parent | e3aaf39c9ca3fa3dc3d030caef68f28b8a27b086 (diff) | |
download | atril-aa9a83b64ac38330991168ab799d482960e07437.tar.bz2 atril-aa9a83b64ac38330991168ab799d482960e07437.tar.xz |
GTK+-3: Use ev_document_misc_get_pointer_position() instad of deprecated gtk_widget_get_pointer()
Diffstat (limited to 'libdocument/ev-document-misc.c')
-rw-r--r-- | libdocument/ev-document-misc.c | 45 |
1 files changed, 45 insertions, 0 deletions
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 + |