[epiphany] window: Make triggering the narrow mode less aggressive
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] window: Make triggering the narrow mode less aggressive
- Date: Thu, 29 Nov 2018 20:23:07 +0000 (UTC)
commit b4dfb49966a738a28ee0ed345454c18a27e8e7a4
Author: Adrien Plazas <kekun plazas laposte net>
Date: Fri Nov 23 10:51:27 2018 +0100
window: Make triggering the narrow mode less aggressive
Trigger the narrow mode below widths of 600pt rather than 720pt to make
that mode less present on the desktop. Also tries to trigger the narrow
mode on landscape mobile phones by triggering it for maximized or
fullscreened windows that are either on short screens or themselves
short, short being defined as less than 400pt high.
src/ephy-window.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 51 insertions(+), 9 deletions(-)
---
diff --git a/src/ephy-window.c b/src/ephy-window.c
index e536ddd13..08d9085fd 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -475,6 +475,49 @@ sync_tab_security (EphyWebView *view,
ephy_title_widget_set_security_level (title_widget, security_level);
}
+static void
+update_adaptive_mode (EphyWindow *window)
+{
+ EphyHeaderBar *header_bar = EPHY_HEADER_BAR (ephy_window_get_header_bar (window));
+ EphyActionBar *action_bar = EPHY_ACTION_BAR (window->action_bar);
+ gboolean is_narrow, is_mobile_landscape;
+ EphyAdaptiveMode adaptive_mode;
+ gint width, height;
+ GdkDisplay *display;
+ GdkWindow *surface;
+ GdkMonitor *monitor = NULL;
+ GdkRectangle geometry = {};
+
+ gtk_window_get_size (GTK_WINDOW (window),
+ &width,
+ &height);
+
+ /* Get the monitor to guess whether we are on a mobile or not. If not found,
+ * fallback to the window size.
+ */
+ display = gtk_widget_get_display (GTK_WIDGET (window));
+ surface = gtk_widget_get_window (GTK_WIDGET (window));
+ if (display != NULL && surface != NULL)
+ monitor = gdk_display_get_monitor_at_window (display, surface);
+ if (monitor != NULL)
+ gdk_monitor_get_geometry (monitor, &geometry);
+ else
+ geometry.height = height;
+
+ /* window->is_maximized doesn't work here for some reason, so we use
+ * gtk_window_is_maximized() instead.
+ */
+ is_narrow = width <= 600;
+ is_mobile_landscape = geometry.height <= 400 &&
+ (gtk_window_is_maximized (GTK_WINDOW (window)) ||
+ window->is_fullscreen);
+ adaptive_mode = is_narrow || is_mobile_landscape ?
+ EPHY_ADAPTIVE_MODE_NARROW :
+ EPHY_ADAPTIVE_MODE_NORMAL;
+ ephy_header_bar_set_adaptive_mode (header_bar, adaptive_mode);
+ ephy_action_bar_set_adaptive_mode (action_bar, adaptive_mode);
+}
+
static void
ephy_window_fullscreen (EphyWindow *window)
{
@@ -487,6 +530,7 @@ ephy_window_fullscreen (EphyWindow *window)
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);
}
@@ -496,6 +540,7 @@ ephy_window_unfullscreen (EphyWindow *window)
{
window->is_fullscreen = FALSE;
+ update_adaptive_mode (window);
sync_chromes_visibility (window);
ephy_embed_leaving_fullscreen (window->active_embed);
}
@@ -2791,9 +2836,6 @@ ephy_window_configure_event (GtkWidget *widget,
GdkEventConfigure *event)
{
EphyWindow *window = EPHY_WINDOW (widget);
- EphyHeaderBar *header_bar = EPHY_HEADER_BAR (ephy_window_get_header_bar (window));
- EphyActionBar *action_bar = EPHY_ACTION_BAR (window->action_bar);
- EphyAdaptiveMode adaptive_mode;
gboolean result;
gint width, height;
@@ -2803,12 +2845,6 @@ ephy_window_configure_event (GtkWidget *widget,
&width,
&height);
- adaptive_mode = width <= 720 ?
- EPHY_ADAPTIVE_MODE_NARROW :
- EPHY_ADAPTIVE_MODE_NORMAL;
- ephy_header_bar_set_adaptive_mode (header_bar, adaptive_mode);
- ephy_action_bar_set_adaptive_mode (action_bar, adaptive_mode);
-
if (!window->is_maximized && !window->is_fullscreen) {
gtk_window_get_position (GTK_WINDOW (widget),
&window->current_x,
@@ -2817,6 +2853,8 @@ ephy_window_configure_event (GtkWidget *widget,
window->current_height = height;
}
+ update_adaptive_mode (window);
+
return result;
}
@@ -2854,6 +2892,8 @@ ephy_window_state_event (GtkWidget *widget,
window->is_maximized = event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED;
}
+ update_adaptive_mode (window);
+
return result;
}
@@ -2919,6 +2959,8 @@ ephy_window_show (GtkWidget *widget)
}
}
+ update_adaptive_mode (window);
+
GTK_WIDGET_CLASS (ephy_window_parent_class)->show (widget);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]