From 5ca4b66157cc7a2ace9140260d52d224616ce924 Mon Sep 17 00:00:00 2001 From: q234rty Date: Mon, 1 Aug 2022 12:41:20 +0800 Subject: [PATCH] feat: Allow disabling the header bar on Linux desktop --- linux/my_application.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/linux/my_application.cc b/linux/my_application.cc index 8f830b57..f2616f7e 100644 --- a/linux/my_application.cc +++ b/linux/my_application.cc @@ -28,12 +28,17 @@ static void my_application_activate(GApplication* application) { // If running on Wayland assume the header bar will work (may need changing // if future cases occur). gboolean use_header_bar = TRUE; + const gchar* gtk_csd_env = g_getenv("GTK_CSD"); + if (gtk_csd_env != nullptr && g_strcmp0(gtk_csd_env, "1") != 0) + use_header_bar = FALSE; #ifdef GDK_WINDOWING_X11 GdkScreen *screen = gtk_window_get_screen(window); if (GDK_IS_X11_SCREEN(screen)) { const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); if (g_strcmp0(wm_name, "GNOME Shell") != 0) { use_header_bar = FALSE; + // Disable libhandy here, otherwise the close button disappears on KDE X11 + g_setenv("GTK_CSD", "0", TRUE); } } #endif