pmaports/temp/gtk4.0/0001-window-Maximize-resizable-transient-windows-on-small.patch
Stefan Hansson e17b71ffd1
temp/gtk4.0: upgrade to 4.12.0 (MR 4338)
[ci:skip-build]: already built successfully in CI
2023-08-19 21:49:35 +02:00

60 lines
2 KiB
Diff

From f045668198a98d744c88af508c4c5a8d0a51346d Mon Sep 17 00:00:00 2001
From: Teemu Ikonen <tpikonen@mailbox.org>
Date: Mon, 20 Feb 2023 19:35:17 +0200
Subject: [PATCH 1/2] window: Maximize resizable transient windows on small
screens
Based on Purism adaptive patches by Alexander Mikhaylenko,
https://source.puri.sm/Librem5/debs/gtk4/-/blob/pureos/byzantium/debian/patches/pureos/adaptive/
Only maximize transients on small (< 120 mm) screens
---
gtk/gtkwindow.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index bac2a25b89..e7d43f033e 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -32,6 +32,7 @@
#include "gtkbuildable.h"
#include "gtkcheckbutton.h"
#include "gtkcssshadowvalueprivate.h"
+#include "deprecated/gtkdialog.h"
#include "gtkdroptargetasync.h"
#include "gtkeventcontrollerlegacy.h"
#include "gtkeventcontrollerkey.h"
@@ -64,6 +65,7 @@
#include "inspector/window.h"
+#include "gdk/gdkmonitor.h"
#include "gdk/gdkprofilerprivate.h"
#include "gdk/gdksurfaceprivate.h"
#include "gdk/gdktextureprivate.h"
@@ -3989,6 +3991,8 @@ gtk_window_map (GtkWidget *widget)
GtkWindow *window = GTK_WINDOW (widget);
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GtkWidget *child = priv->child;
+ GdkMonitor *monitor;
+ gboolean is_dialog, on_small_screen;
GTK_WIDGET_CLASS (gtk_window_parent_class)->map (widget);
@@ -4002,6 +4006,13 @@ gtk_window_map (GtkWidget *widget)
gtk_window_present_toplevel (window);
+ /* Transient windows can be considered pseudo-dialogs. */
+ monitor = gdk_display_get_monitor_at_surface (priv->display, priv->surface);
+ on_small_screen = gdk_monitor_get_width_mm (monitor) < 120;
+ is_dialog = GTK_IS_DIALOG (widget) || !!gtk_window_get_transient_for (window);
+ if (on_small_screen && is_dialog && gtk_window_get_resizable (window))
+ gtk_window_maximize (window);
+
if (priv->minimize_initially)
gdk_toplevel_minimize (GDK_TOPLEVEL (priv->surface));
--
2.41.0