From 0bec10bb26e21cc2a7a028d1a4dc7240a1e6da3d Mon Sep 17 00:00:00 2001 From: Julian Winkler Date: Thu, 31 Oct 2024 16:44:56 +0100 Subject: [PATCH] disable decoration on mobile compositors by default On mobile compositors like Phosh, the title bar will have no buttons and is useless. Therefore it can be disabled by default. This behaviour can still be overwritten using the ATL_DISABLE_WINDOW_DECORATIONS environment variable. --- src/main-executable/main.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main-executable/main.c b/src/main-executable/main.c index b41e1128..ec36b370 100644 --- a/src/main-executable/main.c +++ b/src/main-executable/main.c @@ -401,8 +401,16 @@ static void open(GtkApplication *app, GFile **files, gint nfiles, const gchar *h window = gtk_application_window_new(app); - if (getenv("ATL_DISABLE_WINDOW_DECORATIONS")) - gtk_window_set_decorated(GTK_WINDOW(window), 0); + const char *disable_decoration_env = getenv("ATL_DISABLE_WINDOW_DECORATIONS"); + gboolean decorated; + if (disable_decoration_env) + decorated = !strcmp(disable_decoration_env, "0") || !strcmp(disable_decoration_env, "false"); + else { // by default only enable decorations if there are any action buttons to show in the title bar + const char *decoration_layout; + g_object_get(G_OBJECT(gtk_settings_get_default()), "gtk-decoration-layout", &decoration_layout, NULL); + decorated = strcmp(decoration_layout, "") && strcmp(decoration_layout, "menu"); + } + gtk_window_set_decorated(GTK_WINDOW(window), decorated); if (getenv("ATL_FORCE_FULLSCREEN")) gtk_window_fullscreen(GTK_WINDOW(window));