File atril-gtk-3.20.patch of Package atril

--- a/configure.ac
+++ b/configure.ac
@@ -83,8 +83,8 @@ GLIB_GSETTINGS
 
 dnl Specify required versions of dependencies
 CAIRO_REQUIRED=1.10.0
-GLIB_REQUIRED=2.50.0
-GTK_REQUIRED=3.22.0
+GLIB_REQUIRED=2.48.0
+GTK_REQUIRED=3.20.0
 WEBKIT_REQUIRED=2.4.3
 LIBSECRET_REQUIRED=0.5
 LIBXML_REQUIRED=2.5.0
--- a/cut-n-paste/toolbar-editor/egg-editable-toolbar.c
+++ b/cut-n-paste/toolbar-editor/egg-editable-toolbar.c
@@ -367,7 +367,11 @@ popup_context_menu_cb (GtkWidget
       menu = GTK_MENU (gtk_ui_manager_get_widget (etoolbar->priv->manager,
 						  etoolbar->priv->popup_path));
       g_return_if_fail (menu != NULL);
+#if GTK_CHECK_VERSION (3, 22, 0)
       gtk_menu_popup_at_pointer (menu, NULL);
+#else
+      gtk_menu_popup (menu, NULL, NULL, NULL, NULL, button_number, GDK_CURRENT_TIME);
+#endif
       g_signal_connect_object (menu, "selection-done",
 			       G_CALLBACK (popup_context_deactivate),
 			       etoolbar, 0);
@@ -401,7 +405,11 @@ button_press_event_cb (GtkWidget *widget
       menu = GTK_MENU (gtk_ui_manager_get_widget (etoolbar->priv->manager,
 						  etoolbar->priv->popup_path));
       g_return_val_if_fail (menu != NULL, FALSE);
+#if GTK_CHECK_VERSION (3, 22, 0)
       gtk_menu_popup_at_pointer (menu, (const GdkEvent*) event);
+#else
+      gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event->button, event->time);
+#endif
       g_signal_connect_object (menu, "selection-done",
 			       G_CALLBACK (popup_context_deactivate),
 			       etoolbar, 0);
--- a/libdocument/ev-document-misc.c
+++ b/libdocument/ev-document-misc.c
@@ -339,7 +339,11 @@ ev_document_misc_invert_pixbuf (GdkPixbu
 }
 
 gdouble
+#if GTK_CHECK_VERSION (3, 22, 0)
 ev_document_misc_get_screen_dpi (GdkScreen *screen, GdkMonitor *monitor)
+#else
+ev_document_misc_get_screen_dpi (GdkScreen *screen, gint monitor)
+#endif
 {
 	gdouble dp, di;
 
@@ -347,8 +351,13 @@ ev_document_misc_get_screen_dpi (GdkScre
 	dp = hypot (WidthOfScreen (gdk_x11_screen_get_xscreen (screen)), HeightOfScreen (gdk_x11_screen_get_xscreen (screen)));
 
 	/*diagonal in inches*/
+#if GTK_CHECK_VERSION (3, 22, 0)
 	di = hypot (gdk_monitor_get_width_mm(monitor), gdk_monitor_get_height_mm (monitor)) / 25.4;
 	di /= gdk_monitor_get_scale_factor (monitor);
+#else
+	di = hypot (gdk_screen_get_width_mm (screen), gdk_screen_get_height_mm (screen)) / 25.4;
+	di /= gdk_screen_get_monitor_scale_factor (screen, monitor);
+#endif
 
 	return (dp / di);
 }
--- a/libdocument/ev-document-misc.h
+++ b/libdocument/ev-document-misc.h
@@ -61,7 +61,11 @@ cairo_surface_t *ev_document_misc_surfac
 void             ev_document_misc_invert_surface (cairo_surface_t *surface);
 void             ev_document_misc_invert_pixbuf  (GdkPixbuf       *pixbuf);
 
+#if GTK_CHECK_VERSION (3, 22, 0)
 gdouble          ev_document_misc_get_screen_dpi (GdkScreen *screen, GdkMonitor *monitor);
+#else
+gdouble          ev_document_misc_get_screen_dpi (GdkScreen *screen, gint monitor);
+#endif
 
 gchar           *ev_document_misc_format_date (GTime utime);
 
--- a/libview/ev-annotation-window.c
+++ b/libview/ev-annotation-window.c
@@ -97,12 +97,20 @@ static gdouble
 get_screen_dpi (EvAnnotationWindow *window)
 {
 	GdkScreen  *screen;
+#if GTK_CHECK_VERSION (3, 22, 0)
 	GdkMonitor *monitor;
+#else
+	gint        monitor;
+#endif
 	GdkDisplay *display;
 
 	screen = gtk_window_get_screen (GTK_WINDOW (window));
 	display = gdk_screen_get_display (screen);
+#if GTK_CHECK_VERSION (3, 22, 0)
 	monitor = gdk_display_get_primary_monitor (display);
+#else
+	monitor = gdk_screen_get_primary_monitor (screen);
+#endif
 
 	return ev_document_misc_get_screen_dpi (screen, monitor);
 }
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -495,7 +495,11 @@ is_dual_page (EvView   *view,
 	switch (view->page_layout) {
 	case EV_PAGE_LAYOUT_AUTOMATIC: {
 		GdkScreen    *screen;
+#if GTK_CHECK_VERSION (3, 22, 0)
 		GdkMonitor *monitor;
+#else
+		gint        monitor;
+#endif
 		GdkDisplay *display;
 		double        scale;
 		double        doc_width;
@@ -504,7 +508,11 @@ is_dual_page (EvView   *view,
 
 		screen = gtk_widget_get_screen (GTK_WIDGET (view));
 		display = gdk_screen_get_display (screen);
+#if GTK_CHECK_VERSION (3, 22, 0)
 		monitor = gdk_display_get_primary_monitor (display);
+#else
+		monitor = gdk_screen_get_primary_monitor (screen);
+#endif
 		scale = ev_document_misc_get_screen_dpi (screen, monitor) / 72.0;
 
 		ev_document_get_max_page_size (view->document, &doc_width, &doc_height);
@@ -7111,7 +7119,11 @@ zoom_for_size_automatic (GdkScreen *scre
 			 int        target_width,
 			 int        target_height)
 {
+#if GTK_CHECK_VERSION (3, 22, 0)
 	GdkMonitor *monitor;
+#else
+	gint        monitor;
+#endif
 	GdkDisplay *display;
 	double fit_width_scale;
 	double scale;
@@ -7127,7 +7139,11 @@ zoom_for_size_automatic (GdkScreen *scre
 		double actual_scale;
 
 		display = gdk_screen_get_display (screen);
+#if GTK_CHECK_VERSION (3, 22, 0)
 		monitor = gdk_display_get_primary_monitor (display);
+#else
+		monitor = gdk_screen_get_primary_monitor (screen);
+#endif
 		actual_scale = ev_document_misc_get_screen_dpi (screen, monitor) / 72.0;
 		scale = MIN (fit_width_scale, actual_scale);
 	}
--- a/libview/ev-view-presentation.c
+++ b/libview/ev-view-presentation.c
@@ -1255,11 +1255,20 @@ static void
 ev_view_presentation_update_monitor_geometry (EvViewPresentation *pview)
 {
 	GdkDisplay          *display = gtk_widget_get_display (GTK_WIDGET (pview));
+#if GTK_CHECK_VERSION (3, 22, 0)
 	GdkRectangle        monitor;
 	GdkMonitor          *monitor_num;
 
 	monitor_num = gdk_display_get_monitor_at_window (display, gtk_widget_get_window (GTK_WIDGET (pview)));
 	gdk_monitor_get_geometry (monitor_num, &monitor);
+#else
+	GdkScreen           *screen = gdk_display_get_default_screen (display);
+	GdkRectangle        monitor;
+	gint                monitor_num;
+
+	monitor_num = gdk_screen_get_monitor_at_window (screen, gtk_widget_get_window (GTK_WIDGET (pview)));
+	gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+#endif
 	pview->monitor_width = monitor.width;
 	pview->monitor_height = monitor.height;
 }
--- a/previewer/ev-previewer-window.c
+++ b/previewer/ev-previewer-window.c
@@ -71,12 +71,20 @@ static gdouble
 get_screen_dpi (EvPreviewerWindow *window)
 {
 	GdkScreen  *screen;
+#if GTK_CHECK_VERSION (3, 22, 0)
 	GdkMonitor *monitor;
+#else
+	gint        monitor;
+#endif
 	GdkDisplay *display;
 
 	screen = gtk_window_get_screen (GTK_WINDOW (window));
 	display = gdk_screen_get_display (screen);
+#if GTK_CHECK_VERSION (3, 22, 0)
 	monitor = gdk_display_get_primary_monitor (display);
+#else
+	monitor = gdk_screen_get_primary_monitor (screen);
+#endif
 
 	return ev_document_misc_get_screen_dpi (screen, monitor);
 }
--- a/shell/ev-navigation-action-widget.c
+++ b/shell/ev-navigation-action-widget.c
@@ -118,6 +118,56 @@ ev_navigation_action_widget_set_menu(EvN
 	}
 }
 
+#if !GTK_CHECK_VERSION (3, 22, 0)
+static void
+popup_menu_position_func (GtkMenu                  *menu,
+                          gint                     *x,
+                          gint                     *y,
+                          gboolean                 *push_in,
+                          EvNavigationActionWidget *button)
+{
+	GdkScreen       *screen;
+	GdkWindow       *window;
+	gint             monitor_num;
+	GdkRectangle     monitor;
+	GtkAllocation    allocation;
+	GtkTextDirection direction;
+	GtkRequisition   menu_req;
+
+	screen = gtk_widget_get_screen (GTK_WIDGET (menu));
+	window = gtk_widget_get_window (GTK_WIDGET (button));
+
+	monitor_num = gdk_screen_get_monitor_at_window (screen, window);
+	if (monitor_num > 0)
+		monitor_num = 0;
+	gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+	gdk_window_get_origin (window, x, y);
+
+	gtk_widget_get_allocation (GTK_WIDGET (button), &allocation);
+	*x += allocation.x;
+	*y += allocation.y;
+
+	direction = gtk_widget_get_direction (GTK_WIDGET (button));
+	gtk_widget_get_preferred_size (GTK_WIDGET (button->menu), &menu_req, NULL);
+
+	if (direction == GTK_TEXT_DIR_LTR)
+		*x += MAX (allocation.width - menu_req.width, 0);
+	else if (menu_req.width > allocation.width)
+    		*x -= menu_req.width - allocation.width;
+
+	if ((*y + allocation.height + menu_req.height) <= monitor.y + monitor.height)
+    		*y += allocation.height;
+	else if ((*y - menu_req.height) >= monitor.y)
+    		*y -= menu_req.height;
+	else if (monitor.y + monitor.height - (*y + allocation.height) > *y)
+    		*y += allocation.height;
+	else
+    		*y -= menu_req.height;
+
+	*push_in = FALSE;
+}
+#endif
+
 static void
 popup_menu_under_arrow (EvNavigationActionWidget *button,
                         GdkEventButton    *event)
@@ -127,8 +177,16 @@ popup_menu_under_arrow (EvNavigationActi
 	if (!button->menu)
 		return;
 
+#if GTK_CHECK_VERSION (3, 22, 0)
 	gtk_menu_popup_at_pointer (button->menu,
 	                           (const GdkEvent*) event);
+#else
+	gtk_menu_popup (button->menu, NULL, NULL,
+	                (GtkMenuPositionFunc) popup_menu_position_func,
+	                button,
+	                event != NULL ? event->button : 0,
+	                event != NULL ? event->time : GDK_CURRENT_TIME);
+#endif
 }
 
 static void
--- a/shell/ev-sidebar-bookmarks.c
+++ b/shell/ev-sidebar-bookmarks.c
@@ -354,7 +354,16 @@ ev_sidebar_bookmarks_popup_menu_show (Ev
         if (!priv->popup)
                 priv->popup = gtk_ui_manager_get_widget (priv->ui_manager, "/BookmarksPopup");
 
+#if GTK_CHECK_VERSION (3, 22, 0)
         gtk_menu_popup_at_pointer (GTK_MENU (priv->popup), NULL);
+#else
+        gtk_menu_popup (GTK_MENU (priv->popup),
+                        NULL, NULL,
+                        keyboard_mode ? ev_gui_menu_position_tree_selection : NULL,
+                        keyboard_mode ? tree_view : NULL,
+                        keyboard_mode ? 0 : 3,
+                        GDK_CURRENT_TIME);
+#endif
         return TRUE;
 }
 
--- a/shell/ev-sidebar.c
+++ b/shell/ev-sidebar.c
@@ -192,6 +192,32 @@ ev_sidebar_class_init (EvSidebarClass *e
 							      G_PARAM_READWRITE));
 }
 
+#if !GTK_CHECK_VERSION (3, 22, 0)
+static void
+ev_sidebar_menu_position_under (GtkMenu  *menu,
+				gint     *x,
+				gint     *y,
+				gboolean *push_in,
+				gpointer  user_data)
+{
+	GtkWidget    *widget;
+	GtkAllocation allocation;
+
+	g_return_if_fail (GTK_IS_BUTTON (user_data));
+	g_return_if_fail (!gtk_widget_get_has_window (GTK_WIDGET (user_data)));
+
+	widget = GTK_WIDGET (user_data);
+
+	gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
+	gtk_widget_get_allocation (widget, &allocation);
+
+	*x += allocation.x;
+	*y += allocation.y + allocation.height;
+
+	*push_in = FALSE;
+}
+#endif
+
 static gboolean
 ev_sidebar_select_button_press_cb (GtkWidget      *widget,
 				   GdkEventButton *event,
@@ -214,11 +240,18 @@ ev_sidebar_select_button_press_cb (GtkWi
 		gtk_widget_grab_focus (widget);
 			 
 		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
+#if GTK_CHECK_VERSION (3, 22, 0)
 		gtk_menu_popup_at_widget (GTK_MENU (ev_sidebar->priv->menu),
 		                          widget,
 		                          GDK_GRAVITY_SOUTH_WEST,
 		                          GDK_GRAVITY_NORTH_WEST,
 		                          (const GdkEvent*) event);
+#else
+		gtk_menu_popup (GTK_MENU (ev_sidebar->priv->menu),
+		                NULL, NULL,
+		                ev_sidebar_menu_position_under, widget,
+		                event->button, event->time);
+#endif
 
 		return TRUE;
 	}
@@ -238,11 +271,18 @@ ev_sidebar_select_button_key_press_cb (G
 	    event->keyval == GDK_KEY_Return ||
 	    event->keyval == GDK_KEY_KP_Enter) {
 		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
+#if GTK_CHECK_VERSION (3, 22, 0)
 		gtk_menu_popup_at_widget (GTK_MENU (ev_sidebar->priv->menu),
 		                          widget,
 		                          GDK_GRAVITY_SOUTH_WEST,
 		                          GDK_GRAVITY_NORTH_WEST,
 		                          (const GdkEvent*) event);
+#else
+		gtk_menu_popup (GTK_MENU (ev_sidebar->priv->menu),
+		                NULL, NULL,
+		                ev_sidebar_menu_position_under, widget,
+		                1, event->time);
+#endif
 		return TRUE;
 	}
 
--- a/shell/ev-sidebar-links.c
+++ b/shell/ev-sidebar-links.c
@@ -347,7 +347,14 @@ popup_menu_cb (GtkWidget *treeview, EvSi
 {
 	GtkMenu *menu = build_popup_menu (sidebar);
 
+#if GTK_CHECK_VERSION (3, 22, 0)
 	gtk_menu_popup_at_pointer (menu, NULL);
+#else
+	gtk_menu_popup (menu, NULL, NULL,
+			ev_gui_menu_position_tree_selection,
+			sidebar->priv->tree_view, 0,
+			GDK_CURRENT_TIME);
+#endif
 	gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
 }
 
@@ -366,8 +373,14 @@ button_press_cb (GtkWidget *treeview,
         	                                   NULL, NULL, NULL)) {
 			gtk_tree_view_set_cursor (GTK_TREE_VIEW (treeview),
 						  path, NULL, FALSE);
+#if GTK_CHECK_VERSION (3, 22, 0)
 			gtk_menu_popup_at_pointer (build_popup_menu (sidebar),
 			                           (const GdkEvent*) event);
+#else
+			gtk_menu_popup (build_popup_menu (sidebar), NULL,
+			                NULL, NULL, NULL, event->button,
+			                GDK_CURRENT_TIME);
+#endif
 			gtk_tree_path_free (path);
 
 			return TRUE;
--- a/shell/ev-utils.c
+++ b/shell/ev-utils.c
@@ -107,3 +107,74 @@ get_gdk_pixbuf_format_by_extension (gcha
 	g_slist_free (pixbuf_formats);
 	return NULL;
 }
+
+#if !GTK_CHECK_VERSION (3, 22, 0)
+static void
+ev_gui_menu_position_tree_selection_sanitize (GtkMenu   *menu,
+                                              GtkWidget *widget,
+                                              gint      *x,
+                                              gint      *y)
+{
+	GdkScreen     *screen = gtk_widget_get_screen (widget);
+	gint           monitor_num;
+	GdkRectangle   monitor;
+	GtkRequisition req;
+
+	gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
+	monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
+	gtk_menu_set_monitor (menu, monitor_num);
+	gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+
+	*x = CLAMP (*x, monitor.x,
+	            monitor.x + MAX (0, monitor.width - req.width));
+	*y = CLAMP (*y, monitor.y,
+	            monitor.y + MAX (0, monitor.height - req.height));
+}
+
+void
+ev_gui_menu_position_tree_selection (GtkMenu  *menu,
+                                     gint     *x,
+                                     gint     *y,
+                                     gboolean *push_in,
+                                     gpointer  user_data)
+{
+	GtkTreeView      *tree_view = GTK_WIDGET (user_data);
+	GtkTreeSelection *selection;
+	GList            *selected_rows;
+	GtkTreeModel     *model;
+	GtkRequisition    req;
+	GtkAllocation     allocation;
+	GdkRectangle      visible;
+
+	g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
+
+	gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
+	gdk_window_get_origin (gtk_widget_get_window (tree_view), x, y);
+	gtk_widget_get_allocation (tree_view, &allocation);
+
+	*x += (allocation.width - req.width) / 2;
+	/* Add on height for the treeview title */
+	gtk_tree_view_get_visible_rect (GTK_TREE_VIEW (tree_view), &visible);
+	*y += allocation.height - visible.height;
+
+	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
+	selected_rows = gtk_tree_selection_get_selected_rows (selection,
+	                                                      &model);
+
+	if (selected_rows != NULL) {
+		GdkRectangle cell_rect;
+		gtk_tree_view_get_cell_area (GTK_TREE_VIEW (tree_view),
+		                             selected_rows->data,
+		                             NULL,
+		                             &cell_rect);
+		*y += CLAMP (cell_rect.y + cell_rect.height, 0,
+		             visible.height);
+		g_list_foreach (selected_rows,
+		                (GFunc) gtk_tree_path_free,
+		                NULL);
+		g_list_free (selected_rows);
+	}
+
+	ev_gui_menu_position_tree_selection_sanitize (menu, tree_view, x, y);
+}
+#endif
--- a/shell/ev-utils.h
+++ b/shell/ev-utils.h
@@ -28,6 +28,13 @@ G_BEGIN_DECLS
 
 void           		file_chooser_dialog_add_writable_pixbuf_formats (GtkFileChooser *chooser);
 GdkPixbufFormat* 	get_gdk_pixbuf_format_by_extension (gchar *uri);
+#if !GTK_CHECK_VERSION (3, 22, 0)
+void                    ev_gui_menu_position_tree_selection (GtkMenu  *menu,
+                                                             gint     *x,
+                                                             gint     *y,
+                                                             gboolean *push_in,
+                                                             gpointer  user_data);
+#endif
 
 G_END_DECLS
 
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -398,12 +398,20 @@ static gdouble
 get_screen_dpi (EvWindow *window)
 {
 	GdkScreen  *screen;
+#if GTK_CHECK_VERSION (3, 22, 0)
 	GdkMonitor *monitor;
+#else
+	gint        monitor;
+#endif
 	GdkDisplay *display;
 
 	screen = gtk_window_get_screen (GTK_WINDOW (window));
 	display = gdk_screen_get_display (screen);
+#if GTK_CHECK_VERSION (3, 22, 0)
 	monitor = gdk_display_get_primary_monitor (display);
+#else
+	monitor = gdk_screen_get_primary_monitor (screen);
+#endif
 
 	return ev_document_misc_get_screen_dpi (screen, monitor);
 }
@@ -5031,10 +5039,17 @@ ev_window_cmd_help_contents (GtkAction *
 {
 	GError  *error = NULL;
 
+#if GTK_CHECK_VERSION (3, 22, 0)
 	gtk_show_uri_on_window (GTK_WINDOW (ev_window),
 		      EV_HELP,
 		      gtk_get_current_event_time (),
 		      &error);
+#else
+	gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (ev_window)),
+	              EV_HELP,
+	              gtk_get_current_event_time (),
+	              &error);
+#endif
 
 	if (error) {
 		ev_window_error_message (ev_window, error, 
@@ -5602,8 +5617,14 @@ view_menu_popup_cb (EvView   *view,
 	if (!has_annot)
 		view_menu_annot_popup (ev_window, NULL);
 
+#if GTK_CHECK_VERSION (3, 22, 0)
 	gtk_menu_popup_at_pointer (GTK_MENU (ev_window->priv->view_popup),
 	                           NULL);
+#else
+	gtk_menu_popup (GTK_MENU (ev_window->priv->view_popup),
+	                NULL, NULL, NULL, NULL, 3,
+	                GDK_CURRENT_TIME);
+#endif
 	return TRUE;
 }
 
@@ -5626,8 +5647,14 @@ attachment_bar_menu_popup_cb (EvSidebarA
 	
 	popup = ev_window->priv->attachment_popup;
 
+#if GTK_CHECK_VERSION (3, 22, 0)
 	gtk_menu_popup_at_pointer (GTK_MENU (popup),
 	                           NULL);
+#else
+	gtk_menu_popup (GTK_MENU (popup),
+	                NULL, NULL, NULL, NULL, 3,
+	                GDK_CURRENT_TIME);
+#endif
 	return TRUE;
 }
openSUSE Build Service is sponsored by