Commit 5da7fad3 authored by Carlos Garcia Campos's avatar Carlos Garcia Campos

libdocument: Add ev_document_misc_get_pointer_position()

Helper function to get the pointer position to replace
gtk_widget_get_pointer() that is now deprecated.
parent 28cd78cf
......@@ -356,3 +356,36 @@ ev_document_misc_format_date (GTime utime)
return g_locale_to_utf8 (s, -1, NULL, NULL, NULL);
ev_document_misc_get_pointer_position (GtkWidget *widget,
gint *x,
gint *y)
GdkDeviceManager *device_manager;
GdkDevice *device_pointer;
GdkRectangle allocation;
if (x)
*x = -1;
if (y)
*y = -1;
if (!gtk_widget_get_realized (widget))
device_manager = gdk_display_get_device_manager (gtk_widget_get_display (widget));
device_pointer = gdk_device_manager_get_client_pointer (device_manager);
gdk_window_get_device_position (gtk_widget_get_window (widget),
x, y, NULL);
if (gtk_widget_get_has_window (widget))
gtk_widget_get_allocation (widget, &allocation);
if (x)
*x -= allocation.x;
if (y)
*y -= allocation.y;
......@@ -62,6 +62,10 @@ gdouble ev_document_misc_get_screen_dpi (GdkScreen *screen);
gchar *ev_document_misc_format_date (GTime utime);
void ev_document_misc_get_pointer_position (GtkWidget *widget,
gint *x,
gint *y);
#endif /* EV_DOCUMENT_MISC_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment