summaryrefslogtreecommitdiff
path: root/libdocument
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2016-06-24 17:14:26 +0200
committerraveit65 <[email protected]>2016-06-29 16:23:03 +0200
commitaa9a83b64ac38330991168ab799d482960e07437 (patch)
treec2004fa518b41740fd221939c581470fa464c86d /libdocument
parente3aaf39c9ca3fa3dc3d030caef68f28b8a27b086 (diff)
downloadatril-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')
-rw-r--r--libdocument/ev-document-misc.c45
-rw-r--r--libdocument/ev-document-misc.h6
2 files changed, 51 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
+
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 */