summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdocument/ev-document-misc.c45
-rw-r--r--libdocument/ev-document-misc.h6
-rw-r--r--libview/ev-view-presentation.c8
-rw-r--r--libview/ev-view.c36
-rw-r--r--shell/ev-sidebar-attachments.c5
-rw-r--r--shell/ev-sidebar-bookmarks.c6
6 files changed, 104 insertions, 2 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 */
diff --git a/libview/ev-view-presentation.c b/libview/ev-view-presentation.c
index 01a49aac..08694cc1 100644
--- a/libview/ev-view-presentation.c
+++ b/libview/ev-view-presentation.c
@@ -528,7 +528,11 @@ ev_view_presentation_update_current_page (EvViewPresentation *pview,
if (pview->cursor != EV_VIEW_CURSOR_HIDDEN) {
gint x, y;
+#if GTK_CHECK_VERSION(3, 0, 0)
+ ev_document_misc_get_pointer_position (GTK_WIDGET (pview), &x, &y);
+#else
gtk_widget_get_pointer (GTK_WIDGET (pview), &x, &y);
+#endif
ev_view_presentation_set_cursor_for_location (pview, x, y);
}
@@ -1219,7 +1223,11 @@ ev_view_presentation_key_press_event (GtkWidget *widget,
ev_view_presentation_goto_window_create (pview);
ev_view_presentation_goto_window_send_key_event (pview, (GdkEvent *)event);
+#if GTK_CHECK_VERSION(3, 0, 0)
+ ev_document_misc_get_pointer_position (GTK_WIDGET (pview), &x, &y);
+#else
gtk_widget_get_pointer (GTK_WIDGET (pview), &x, &y);
+#endif
gtk_window_move (GTK_WINDOW (pview->goto_window), x, y);
gtk_widget_show (pview->goto_window);
ev_view_presentation_goto_entry_grab_focus (pview);
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 9ddf78d2..63e0979e 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -3040,7 +3040,11 @@ ev_view_cancel_add_annotation (EvView *view)
return;
view->adding_annot = FALSE;
+#if GTK_CHECK_VERSION(3, 0, 0)
+ ev_document_misc_get_pointer_position (GTK_WIDGET (view), &x, &y);
+#else
gtk_widget_get_pointer (GTK_WIDGET (view), &x, &y);
+#endif
ev_view_handle_cursor_over_xy (view, x, y);
}
@@ -3577,8 +3581,12 @@ static gboolean
ev_view_popup_menu (GtkWidget *widget)
{
gint x, y;
-
+
+#if GTK_CHECK_VERSION(3, 0, 0)
+ ev_document_misc_get_pointer_position (widget, &x, &y);
+#else
gtk_widget_get_pointer (widget, &x, &y);
+#endif
return ev_view_do_popup_menu (EV_VIEW (widget), x, y);
}
@@ -3906,7 +3914,11 @@ selection_scroll_timeout_cb (EvView *view)
GtkAllocation allocation;
gtk_widget_get_allocation (widget, &allocation);
+#if GTK_CHECK_VERSION(3, 0, 0)
+ ev_document_misc_get_pointer_position (widget, &x, &y);
+#else
gtk_widget_get_pointer (widget, &x, &y);
+#endif
if (y > allocation.height) {
shift = (y - allocation.height) / 2;
@@ -4028,7 +4040,11 @@ ev_view_motion_notify_event (GtkWidget *widget,
#endif
if (event->is_hint || event->window != bin_window) {
+#if GTK_CHECK_VERSION(3, 0, 0)
+ ev_document_misc_get_pointer_position (widget, &x, &y);
+#else
gtk_widget_get_pointer (widget, &x, &y);
+#endif
} else {
x = event->x;
y = event->y;
@@ -5091,7 +5107,11 @@ ev_view_change_page (EvView *view,
hide_loading_window (view);
+#if GTK_CHECK_VERSION(3, 0, 0)
+ ev_document_misc_get_pointer_position (GTK_WIDGET (view), &x, &y);
+#else
gtk_widget_get_pointer (GTK_WIDGET (view), &x, &y);
+#endif
ev_view_handle_cursor_over_xy (view, x, y);
gtk_widget_queue_resize (GTK_WIDGET (view));
@@ -5210,7 +5230,11 @@ on_adjustment_value_changed (GtkAdjustment *adjustment,
#endif
}
+#if GTK_CHECK_VERSION(3, 0, 0)
+ ev_document_misc_get_pointer_position (GTK_WIDGET (view), &x, &y);
+#else
gtk_widget_get_pointer (GTK_WIDGET (view), &x, &y);
+#endif
ev_view_handle_cursor_over_xy (view, x, y);
if (view->document)
@@ -5347,8 +5371,12 @@ ev_view_autoscroll_start (EvView *view)
view->scroll_info.timeout_id =
g_timeout_add (20, (GSourceFunc)ev_view_autoscroll_cb,
view);
-
+
+#if GTK_CHECK_VERSION(3, 0, 0)
+ ev_document_misc_get_pointer_position (GTK_WIDGET (view), &x, &y);
+#else
gtk_widget_get_pointer (GTK_WIDGET (view), &x, &y);
+#endif
ev_view_handle_cursor_over_xy (view, x, y);
}
@@ -5368,7 +5396,11 @@ ev_view_autoscroll_stop (EvView *view)
view->scroll_info.timeout_id = 0;
}
+#if GTK_CHECK_VERSION(3, 0, 0)
+ ev_document_misc_get_pointer_position (GTK_WIDGET (view), &x, &y);
+#else
gtk_widget_get_pointer (GTK_WIDGET (view), &x, &y);
+#endif
ev_view_handle_cursor_over_xy (view, x, y);
}
diff --git a/shell/ev-sidebar-attachments.c b/shell/ev-sidebar-attachments.c
index 84e6cb38..ddcaccda 100644
--- a/shell/ev-sidebar-attachments.c
+++ b/shell/ev-sidebar-attachments.c
@@ -32,6 +32,7 @@
#include <gtk/gtk.h>
#include "ev-document-attachments.h"
+#include "ev-document-misc.h"
#include "ev-jobs.h"
#include "ev-job-scheduler.h"
#include "ev-file-helpers.h"
@@ -263,7 +264,11 @@ ev_sidebar_attachments_popup_menu (GtkWidget *widget)
EvSidebarAttachments *ev_attachbar = EV_SIDEBAR_ATTACHMENTS (widget);
gint x, y;
+#if GTK_CHECK_VERSION(3, 0, 0)
+ ev_document_misc_get_pointer_position (widget, &x, &y);
+#else
gtk_widget_get_pointer (widget, &x, &y);
+#endif
return ev_sidebar_attachments_popup_menu_show (ev_attachbar, x, y);
}
diff --git a/shell/ev-sidebar-bookmarks.c b/shell/ev-sidebar-bookmarks.c
index 1e31fbc6..916985bb 100644
--- a/shell/ev-sidebar-bookmarks.c
+++ b/shell/ev-sidebar-bookmarks.c
@@ -21,10 +21,12 @@
#include "config.h"
#include <glib/gi18n.h>
+#include <gtk/gtk.h>
#include "ev-sidebar-bookmarks.h"
#include "ev-document.h"
+#include "ev-document-misc.h"
#include "ev-sidebar-page.h"
#include "ev-utils.h"
@@ -378,7 +380,11 @@ ev_sidebar_bookmarks_popup_menu (GtkWidget *widget)
EvSidebarBookmarks *sidebar_bookmarks = EV_SIDEBAR_BOOKMARKS (widget);
gint x, y;
+#if GTK_CHECK_VERSION(3, 0, 0)
+ ev_document_misc_get_pointer_position (widget, &x, &y);
+#else
gtk_widget_get_pointer (widget, &x, &y);
+#endif
return ev_sidebar_bookmarks_popup_menu_show (sidebar_bookmarks, x, y, TRUE);
}