Skip to content

Commit 0acd19b

Browse files
committed
Disable GNOME CSD header bar by default
closes cypherstack#1248
1 parent 243015b commit 0acd19b

1 file changed

Lines changed: 8 additions & 22 deletions

File tree

scripts/app_config/templates/linux/my_application.cc

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#include "my_application.h"
22

33
#include <flutter_linux/flutter_linux.h>
4-
#ifdef GDK_WINDOWING_X11
5-
#include <gdk/gdkx.h>
6-
#endif
74

85
#include "flutter/generated_plugin_registrant.h"
96

@@ -26,26 +23,15 @@ static void my_application_activate(GApplication* application) {
2623
GtkWindow* window =
2724
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
2825

29-
// Use a header bar when running in GNOME as this is the common style used
30-
// by applications and is the setup most users will be using (e.g. Ubuntu
31-
// desktop).
32-
// If running on X and not using GNOME then just use a traditional title bar
33-
// in case the window manager does more exotic layout, e.g. tiling.
34-
// If running on Wayland assume the header bar will work (may need changing
35-
// if future cases occur).
36-
gboolean use_header_bar = TRUE;
37-
#ifdef GDK_WINDOWING_X11
38-
GdkScreen* screen = gtk_window_get_screen(window);
39-
if (GDK_IS_X11_SCREEN(screen)) {
40-
const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
41-
if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
42-
use_header_bar = FALSE;
43-
}
44-
}
45-
#endif
26+
// Use a traditional title bar by default for best compatibility across
27+
// desktop environments (KDE, XFCE, tiling WMs, etc.).
28+
// Set GTK_CSD=1 to use a GNOME-style header bar instead.
29+
gboolean use_header_bar = FALSE;
4630
const char* gtk_csd_env_var = getenv("GTK_CSD");
47-
gboolean use_gtk_csd = !gtk_csd_env_var || strcmp(gtk_csd_env_var, "0") != 0;
48-
if (use_header_bar && use_gtk_csd) {
31+
if (gtk_csd_env_var && strcmp(gtk_csd_env_var, "1") == 0) {
32+
use_header_bar = TRUE;
33+
}
34+
if (use_header_bar) {
4935
GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
5036
gtk_widget_show(GTK_WIDGET(header_bar));
5137
gtk_header_bar_set_title(header_bar, "PlaceHolderName");

0 commit comments

Comments
 (0)