Commit b32a84d4 authored by Alexander Mikhaylenko's avatar Alexander Mikhaylenko
Browse files

d/patches: Make adaptive

parent a4123d15
Pipeline #64802 passed with stages
in 10 minutes
From: Alexander Mikhaylenko <alexander.mikhaylenko@puri.sm>
Date: Tue, 22 Sep 2020 17:43:19 +0500
Subject: librem5: Disable WebKit fullscreen
This lets WebKit and websites they don't have the right to make the
window fullscreen.
---
embed/ephy-embed-prefs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c
index 3120897..e9ec876 100644
--- a/embed/ephy-embed-prefs.c
+++ b/embed/ephy-embed-prefs.c
@@ -566,6 +566,7 @@ ephy_embed_prefs_init (gpointer user_data)
webkit_settings = webkit_settings_new_with_settings ("enable-back-forward-navigation-gestures", TRUE,
"enable-developer-extras", TRUE,
"enable-dns-prefetching", TRUE,
+ "enable-fullscreen", FALSE,
"enable-plugins", FALSE,
NULL);
From: Adrien Plazas <kekun.plazas@laposte.net>
Date: Wed, 10 Jul 2019 19:17:38 +0200
From: Alexander Mikhaylenko <alexm@gnome.org>
Date: Wed, 24 Feb 2021 19:37:24 +0500
Subject: librem5: Disable fullscreen
This prevent the windows from going fullscreen, as we currently have no
way to exit fullscreen from a touch screen only.
We'll need to disable fullscreen on phosh because it doesn't work there.
This isn't a matter of adaptiveness, because fullscreen technically can
work on mobile, but just doesn't in phosh. So let's add a check.
---
src/ephy-lockdown.c | 18 ------------------
src/ephy-window.c | 40 ++++------------------------------------
src/window-commands.c | 24 ------------------------
src/window-commands.h | 3 ---
4 files changed, 4 insertions(+), 81 deletions(-)
embed/ephy-embed-prefs.c | 13 +++++++++++++
src/ephy-desktop-utils.c | 11 +++++++++++
src/ephy-desktop-utils.h | 1 +
src/ephy-header-bar.c | 5 +++++
src/ephy-lockdown.c | 3 ++-
src/ephy-window.c | 2 +-
src/resources/gtk/page-menu-popover.ui | 2 +-
src/window-commands.c | 3 ++-
8 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/src/ephy-lockdown.c b/src/ephy-lockdown.c
index 43f3113..fe08141 100644
--- a/src/ephy-lockdown.c
+++ b/src/ephy-lockdown.c
@@ -65,17 +65,6 @@ arbitrary_url_cb (GSettings *settings,
}
}
-static void
-fullscreen_cb (GSettings *settings,
- const char *key,
- EphyWindow *window)
-{
- if (g_settings_get_boolean (settings, key))
- gtk_window_fullscreen (GTK_WINDOW (window));
- else
- gtk_window_unfullscreen (GTK_WINDOW (window));
-}
-
typedef struct {
const char *key;
const char *action;
@@ -96,8 +85,6 @@ static const BindAction window_actions[] = {
{ EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING, "bookmark-page", "enabled" },
- { EPHY_PREFS_LOCKDOWN_FULLSCREEN, "fullscreen", "enabled" },
-
{ EPHY_PREFS_LOCKDOWN_PRINTING, "print", "enabled" },
diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c
index 3120897..e1ae1a7 100644
--- a/embed/ephy-embed-prefs.c
+++ b/embed/ephy-embed-prefs.c
@@ -558,12 +558,25 @@ static const PrefData webkit_pref_entries[] = {
webkit_pref_callback_hardware_acceleration_policy },
};
{ EPHY_PREFS_LOCKDOWN_SAVE_TO_DISK, "save-as", "enabled" }
@@ -194,16 +181,11 @@ window_added_cb (GtkApplication *application,
if (!EPHY_IS_WINDOW (window))
return;
+/* Unfortunately we can't reuse ephy-desktop-utils.h here */
+static gboolean
+is_session_phosh (void)
+{
+ const gchar *xdg_session_desktop = g_getenv ("XDG_SESSION_DESKTOP");
+
+ if (!xdg_session_desktop)
+ return FALSE;
+
+ return strstr (xdg_session_desktop, "phosh") != NULL;
+}
+
static gpointer
ephy_embed_prefs_init (gpointer user_data)
{
guint i;
webkit_settings = webkit_settings_new_with_settings ("enable-back-forward-navigation-gestures", TRUE,
+ "enable-fullscreen", !is_session_phosh (),
"enable-developer-extras", TRUE,
"enable-dns-prefetching", TRUE,
"enable-plugins", FALSE,
diff --git a/src/ephy-desktop-utils.c b/src/ephy-desktop-utils.c
index 008ed4d..3783c41 100644
--- a/src/ephy-desktop-utils.c
+++ b/src/ephy-desktop-utils.c
@@ -46,6 +46,17 @@ is_desktop_gnome (void)
return strstr (xdg_current_desktop, "GNOME") != NULL;
}
- g_signal_connect (EPHY_SETTINGS_LOCKDOWN,
- "changed::" EPHY_PREFS_LOCKDOWN_FULLSCREEN,
- G_CALLBACK (fullscreen_cb), window);
g_signal_connect (EPHY_SETTINGS_LOCKDOWN,
"changed::" EPHY_PREFS_LOCKDOWN_ARBITRARY_URL,
G_CALLBACK (arbitrary_url_cb), window);
+gboolean
+is_session_phosh (void)
+{
+ const gchar *xdg_session_desktop = g_getenv ("XDG_SESSION_DESKTOP");
+
+ if (!xdg_session_desktop)
+ return FALSE;
+
+ return strstr (xdg_session_desktop, "phosh") != NULL;
+}
+
GtkIconSize
get_icon_size (void)
{
diff --git a/src/ephy-desktop-utils.h b/src/ephy-desktop-utils.h
index c162f3f..64f739b 100644
--- a/src/ephy-desktop-utils.h
+++ b/src/ephy-desktop-utils.h
@@ -32,6 +32,7 @@ typedef enum {
gboolean is_desktop_pantheon (void);
gboolean is_desktop_gnome (void);
+gboolean is_session_phosh (void);
GtkIconSize get_icon_size (void);
diff --git a/src/ephy-header-bar.c b/src/ephy-header-bar.c
index 77dea2f..08ebf83 100644
--- a/src/ephy-header-bar.c
+++ b/src/ephy-header-bar.c
@@ -311,6 +311,11 @@ ephy_header_bar_constructed (GObject *object)
GTK_ICON_SIZE_LARGE_TOOLBAR));
}
/* Trigger an initial state on these elements. */
- fullscreen_cb (EPHY_SETTINGS_LOCKDOWN,
- EPHY_PREFS_LOCKDOWN_FULLSCREEN, EPHY_WINDOW (window));
arbitrary_url_cb (EPHY_SETTINGS_LOCKDOWN,
EPHY_PREFS_LOCKDOWN_ARBITRARY_URL, EPHY_WINDOW (window));
+ if (is_session_phosh ()) {
+ GtkWidget *fullscreen_button = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_button"));
+ gtk_widget_hide (fullscreen_button);
+ }
+
gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), page_menu_popover);
g_object_unref (builder);
diff --git a/src/ephy-lockdown.c b/src/ephy-lockdown.c
index 43f3113..e9116ca 100644
--- a/src/ephy-lockdown.c
+++ b/src/ephy-lockdown.c
@@ -25,6 +25,7 @@
#include "ephy-action-helper.h"
#include "ephy-debug.h"
+#include "ephy-desktop-utils.h"
#include "ephy-embed-container.h"
#include "ephy-embed-shell.h"
#include "ephy-embed-utils.h"
@@ -70,7 +71,7 @@ fullscreen_cb (GSettings *settings,
const char *key,
EphyWindow *window)
{
- if (g_settings_get_boolean (settings, key))
+ if (g_settings_get_boolean (settings, key) && !is_session_phosh ())
gtk_window_fullscreen (GTK_WINDOW (window));
else
gtk_window_unfullscreen (GTK_WINDOW (window));
diff --git a/src/ephy-window.c b/src/ephy-window.c
index d6adfb2..46b592f 100644
index d6adfb2..7f56ac6 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -120,7 +120,6 @@ const struct {
/* Toggle actions */
{ "win.browse-with-caret", { "F7", NULL } },
- { "win.fullscreen", { "F11", NULL } },
/* Navigation */
{ "toolbar.stop", { "Escape", "Stop", NULL } },
@@ -554,23 +553,6 @@ update_adaptive_mode (EphyWindow *window)
ephy_window_close_pages_view (window);
}
-static void
-ephy_window_fullscreen (EphyWindow *window)
-{
- EphyEmbed *embed;
-
- window->is_fullscreen = TRUE;
-
- /* sync status */
- embed = window->active_embed;
- sync_tab_load_status (ephy_embed_get_web_view (embed), WEBKIT_LOAD_STARTED, window);
- sync_tab_security (ephy_embed_get_web_view (embed), NULL, window);
-
- update_adaptive_mode (window);
- sync_chromes_visibility (window);
- ephy_embed_entering_fullscreen (embed);
-}
-
static void
ephy_window_unfullscreen (EphyWindow *window)
{
@@ -871,7 +853,6 @@ static const GActionEntry window_entries [] = {
/* Toggle actions */
{ "browse-with-caret", NULL, NULL, "false", window_cmd_change_browse_with_caret_state },
- { "fullscreen", NULL, NULL, "false", window_cmd_change_fullscreen_state },
};
static const GActionEntry tab_entries [] = {
@@ -3309,28 +3290,15 @@ ephy_window_state_event (GtkWidget *widget,
@@ -3308,7 +3308,7 @@ ephy_window_state_event (GtkWidget *widget,
result = GTK_WIDGET_CLASS (ephy_window_parent_class)->window_state_event (widget, event);
}
if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) {
- GActionGroup *action_group;
- GAction *action;
- gboolean fullscreen;
+ if (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)
+ gtk_window_unfullscreen (GTK_WINDOW (window));
- fullscreen = !!(event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN);
-
- if (fullscreen) {
- ephy_window_fullscreen (window);
- } else {
- ephy_window_unfullscreen (window);
- }
+ ephy_window_unfullscreen (window);
if (window->show_fullscreen_header_bar)
- dzl_application_window_set_fullscreen (DZL_APPLICATION_WINDOW (window), fullscreen);
+ dzl_application_window_set_fullscreen (DZL_APPLICATION_WINDOW (window), FALSE);
window->show_fullscreen_header_bar = FALSE;
-
- action_group = gtk_widget_get_action_group (GTK_WIDGET (window), "win");
- action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "fullscreen");
-
- g_simple_action_set_state (G_SIMPLE_ACTION (action),
- g_variant_new_boolean (fullscreen));
} else if (event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED) {
window->is_maximized = !!(event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED);
}
- if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) {
+ if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN && !is_session_phosh ()) {
GActionGroup *action_group;
GAction *action;
gboolean fullscreen;
diff --git a/src/resources/gtk/page-menu-popover.ui b/src/resources/gtk/page-menu-popover.ui
index 6942c99..9c7e5f0 100644
--- a/src/resources/gtk/page-menu-popover.ui
+++ b/src/resources/gtk/page-menu-popover.ui
@@ -110,7 +110,7 @@
</packing>
</child>
<child>
- <object class="GtkModelButton">
+ <object class="GtkModelButton" id="fullscreen_button">
<property name="tooltip_text" translatable="yes">Fullscreen</property>
<property name="action-name">win.fullscreen</property>
<property name="iconic">True</property>
diff --git a/src/window-commands.c b/src/window-commands.c
index fd4dafc..4ed4184 100644
index fd4dafc..52066c0 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -2616,30 +2616,6 @@ window_cmd_change_browse_with_caret_state (GSimpleAction *action,
EPHY_PREFS_ENABLE_CARET_BROWSING, active);
}
@@ -30,6 +30,7 @@
#include "ephy-bookmarks-import.h"
#include "ephy-bookmarks-manager.h"
#include "ephy-debug.h"
+#include "ephy-desktop-utils.h"
#include "ephy-embed-container.h"
#include "ephy-embed-prefs.h"
#include "ephy-embed-shell.h"
@@ -2624,7 +2625,7 @@ window_cmd_change_fullscreen_state (GSimpleAction *action,
EphyWindow *window = EPHY_WINDOW (user_data);
gboolean active;
-void
-window_cmd_change_fullscreen_state (GSimpleAction *action,
- GVariant *state,
- gpointer user_data)
-{
- EphyWindow *window = EPHY_WINDOW (user_data);
- gboolean active;
-
- active = g_variant_get_boolean (state);
-
- /* This is performed only here because we don't want it occuring when a window
- * enters fullscreen mode for some other reason other than action activation.
- * E.g. we don't want it appearing for fullscreen video.
- */
- ephy_window_show_fullscreen_header_bar (window);
-
- if (active)
- gtk_window_fullscreen (GTK_WINDOW (window));
- else
- gtk_window_unfullscreen (GTK_WINDOW (window));
-
- g_simple_action_set_state (action, g_variant_new_boolean (active));
-}
-
void
window_cmd_tabs_previous (GSimpleAction *action,
GVariant *variant,
diff --git a/src/window-commands.h b/src/window-commands.h
index ca80dcf..784363b 100644
--- a/src/window-commands.h
+++ b/src/window-commands.h
@@ -173,9 +173,6 @@ void window_cmd_go_tabs_view (GSimpleAction *action,
void window_cmd_change_browse_with_caret_state (GSimpleAction *action,
GVariant *state,
gpointer user_data);
-void window_cmd_change_fullscreen_state (GSimpleAction *action,
- GVariant *state,
- gpointer user_data);
void window_cmd_tabs_previous (GSimpleAction *action,
GVariant *state,
gpointer user_data);
+ active = g_variant_get_boolean (state) && !is_session_phosh ();
/* This is performed only here because we don't want it occuring when a window
* enters fullscreen mode for some other reason other than action activation.
From: Adrien Plazas <kekun.plazas@laposte.net>
Date: Wed, 10 Jul 2019 19:24:33 +0200
Subject: librem5: Drop the shortcuts window
The window doesn't fit on the screen and it's not very relevant.
---
src/resources/gtk/page-menu-popover.ui | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/resources/gtk/page-menu-popover.ui b/src/resources/gtk/page-menu-popover.ui
index 6942c99..a631085 100644
--- a/src/resources/gtk/page-menu-popover.ui
+++ b/src/resources/gtk/page-menu-popover.ui
@@ -305,7 +305,7 @@
<property name="can_focus">True</property>
<property name="text" translatable="yes">_Keyboard Shortcuts</property>
<property name="action-name">app.shortcuts</property>
- <property name="visible">True</property>
+ <property name="visible">False</property>
</object>
</child>
<!-- FRAGILE: This button is manually removed for app mode/Pantheon in ephy-header-bar.c. -->
From: Alexander Mikhaylenko <alexm@gnome.org>
Date: Wed, 24 Feb 2021 18:57:28 +0500
Subject: librem5: header-bar: Hide keyboard shortcuts button on mobile
GtkShortcutsWindow is not adaptive and not very useful on mobile to begin
with. Just hide it altogether.
---
src/ephy-header-bar.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/ephy-header-bar.c b/src/ephy-header-bar.c
index a248b0e..77dea2f 100644
--- a/src/ephy-header-bar.c
+++ b/src/ephy-header-bar.c
@@ -64,6 +64,8 @@ struct _EphyHeaderBar {
GtkWidget *restore_button;
GtkWidget *combined_stop_reload_button;
GtkWidget *combined_stop_reload_image;
+
+ GtkWidget *shortcuts_button;
};
G_DEFINE_TYPE (EphyHeaderBar, ephy_header_bar, GTK_TYPE_HEADER_BAR)
@@ -294,6 +296,9 @@ ephy_header_bar_constructed (GObject *object)
gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "run-in-background-button")));
}
+ if (ephy_embed_shell_get_mode (embed_shell) != EPHY_EMBED_SHELL_MODE_APPLICATION)
+ header_bar->shortcuts_button = GTK_WIDGET (gtk_builder_get_object (builder, "keyboard-shortcuts-button"));
+
header_bar->combined_stop_reload_button = GTK_WIDGET (gtk_builder_get_object (builder, "combined_stop_reload_button"));
header_bar->combined_stop_reload_image = GTK_WIDGET (gtk_builder_get_object (builder, "combined_stop_reload_image"));
gtk_widget_set_tooltip_text (header_bar->combined_stop_reload_button, _(REFRESH_BUTTON_TOOLTIP));
@@ -422,12 +427,16 @@ ephy_header_bar_set_adaptive_mode (EphyHeaderBar *header_bar,
gtk_revealer_set_reveal_child (GTK_REVEALER (header_bar->start_revealer), TRUE);
gtk_revealer_set_reveal_child (GTK_REVEALER (header_bar->end_revealer), TRUE);
gtk_widget_set_visible (header_bar->combined_stop_reload_button, FALSE);
+ if (header_bar->shortcuts_button)
+ gtk_widget_set_visible (header_bar->shortcuts_button, TRUE);
break;
case EPHY_ADAPTIVE_MODE_NARROW:
gtk_revealer_set_reveal_child (GTK_REVEALER (header_bar->start_revealer), FALSE);
gtk_revealer_set_reveal_child (GTK_REVEALER (header_bar->end_revealer), FALSE);
gtk_widget_set_visible (header_bar->combined_stop_reload_button, TRUE);
+ if (header_bar->shortcuts_button)
+ gtk_widget_set_visible (header_bar->shortcuts_button, FALSE);
break;
}
......@@ -2,9 +2,8 @@
07_bookmarks.patch
dont-make-compulsory.patch
build-Allow-libportal-support-to-be-disabled.patch
librem5-header-bar-Hide-keyboard-shortcuts-button-on-mobile.patch
librem5-Disable-fullscreen.patch
librem5-Drop-the-shortcuts-window.patch
librem5-Disable-WebKit-fullscreen.patch
librem5-search-engine-dialog-Make-it-fit-narrow-screens.patch
librem5-search-engine-dialog-Use-an-inline-toolbar.patch
librem5-search-engine-dialog-Restyle-header-labels.patch
......
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