File: EvWindow-fix-launching-fullscreen-actions-from-popover.patch

package info (click to toggle)
evince 48.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,028 kB
  • sloc: ansic: 73,001; xml: 288; sh: 129; makefile: 22
file content (103 lines) | stat: -rw-r--r-- 3,856 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
From: =?utf-8?b?TmVsc29uIEJlbsOtdGV6IExlw7Nu?= <nbenitezl@gmail.com>
Date: Thu, 1 May 2025 21:54:19 +0100
Subject: EvWindow: fix launching fullscreen actions from popover

when launching fullscreen actions via the popover menu,
do it with a small timeout delay, to avoid the popover
getting stuck in the resulting fullscreen view.

Bug: https://gitlab.gnome.org/GNOME/evince/-/issues/2088
Bug-Debian: https://bugs.debian.org/1109381
Forwarded: https://gitlab.gnome.org/GNOME/evince/-/merge_requests/728
---
 shell/ev-toolbar.c | 18 ++++++++++++++++++
 shell/ev-toolbar.h |  1 +
 shell/ev-window.c  | 22 +++++++++++++++++-----
 3 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/shell/ev-toolbar.c b/shell/ev-toolbar.c
index bb20887..6ad2764 100644
--- a/shell/ev-toolbar.c
+++ b/shell/ev-toolbar.c
@@ -195,6 +195,24 @@ ev_toolbar_action_menu_toggle (EvToolbar *ev_toolbar)
                                       !is_active);
 }
 
+gboolean
+ev_toolbar_action_menu_popover_is_visible (EvToolbar *ev_toolbar)
+{
+	EvToolbarPrivate *priv;
+	GtkPopover *popover;
+
+	g_return_val_if_fail (EV_IS_TOOLBAR (ev_toolbar), FALSE);
+
+	priv = GET_PRIVATE (ev_toolbar);
+
+	popover = gtk_menu_button_get_popover (GTK_MENU_BUTTON (priv->action_menu_button));
+
+	if (popover)
+		return gtk_widget_get_visible (GTK_WIDGET (popover));
+
+	return FALSE;
+}
+
 GtkWidget *
 ev_toolbar_get_page_selector (EvToolbar *ev_toolbar)
 {
diff --git a/shell/ev-toolbar.h b/shell/ev-toolbar.h
index 6cb8ae4..92fca19 100644
--- a/shell/ev-toolbar.h
+++ b/shell/ev-toolbar.h
@@ -52,6 +52,7 @@ struct _EvToolbarClass {
 GType         ev_toolbar_get_type           (void);
 GtkWidget    *ev_toolbar_new                (EvWindow *window);
 void          ev_toolbar_action_menu_toggle (EvToolbar *ev_toolbar);
+gboolean      ev_toolbar_action_menu_popover_is_visible (EvToolbar *ev_toolbar);
 GtkWidget    *ev_toolbar_get_page_selector  (EvToolbar *ev_toolbar);
 HdyHeaderBar *ev_toolbar_get_header_bar     (EvToolbar *ev_toolbar);
 void          ev_toolbar_set_mode           (EvToolbar     *ev_toolbar,
diff --git a/shell/ev-window.c b/shell/ev-window.c
index be3b575..5e1ecdc 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -4724,14 +4724,19 @@ ev_window_cmd_view_fullscreen (GSimpleAction *action,
 			       gpointer       user_data)
 {
 	EvWindow *window = user_data;
+	EvWindowPrivate *priv = GET_PRIVATE (window);
 
 	if (g_variant_get_boolean (state)) {
-		ev_window_run_fullscreen (window);
+		if (ev_toolbar_action_menu_popover_is_visible (EV_TOOLBAR (priv->toolbar))) {
+			/* Popover menu is opened, so launch after a small delay
+			 * to avoid interfering with the popover closing - Issue #2088 */
+			g_timeout_add_once (200, (GSourceOnceFunc) ev_window_run_fullscreen, window);
+		} else {
+			ev_window_run_fullscreen (window);
+		}
 	} else {
 		ev_window_stop_fullscreen (window, TRUE);
 	}
-
-	g_simple_action_set_state (action, state);
 }
 
 static void
@@ -4897,8 +4902,15 @@ ev_window_cmd_view_presentation (GSimpleAction *action,
 	EvWindow *window = user_data;
 	EvWindowPrivate *priv = GET_PRIVATE (window);
 
-	if (!EV_WINDOW_IS_PRESENTATION (priv))
-		ev_window_run_presentation (window);
+	if (!EV_WINDOW_IS_PRESENTATION (priv)) {
+		if (ev_toolbar_action_menu_popover_is_visible (EV_TOOLBAR (priv->toolbar))) {
+			/* Popover menu is opened, so launch after a small delay
+			 * to avoid interfering with the popover closing - Issue #2088 */
+			g_timeout_add_once (200, (GSourceOnceFunc) ev_window_run_presentation, window);
+		} else {
+			ev_window_run_presentation (window);
+		}
+	}
 	/* We don't exit presentation when action is toggled because it conflicts with some
 	 * remote controls. The behaviour is also consistent with libreoffice and other
 	 * presentation tools. See https://bugzilla.gnome.org/show_bug.cgi?id=556162