@@ -43,11 +43,25 @@ static void my_application_activate(GApplication* application) {
4343 MyApplication* self = MY_APPLICATION (application);
4444 GtkWindow* window =
4545 GTK_WINDOW (gtk_application_window_new (GTK_APPLICATION (application)));
46-
47- // If have GTK_CSD in env and it is equal to 1 then add the gtk header bar
48- // to always use client side decorations
49- const char * GTK_CSD = getenv (" GTK_CSD" );
50- if (GTK_CSD && strcmp (GTK_CSD, " 1" ) == 0 ) {
46+
47+ // Use a header bar when running in GNOME as this is the common style used
48+ // by applications and is the setup most users will be using (e.g. Ubuntu
49+ // desktop).
50+ // If running on X and not using GNOME then just use a traditional title bar
51+ // in case the window manager does more exotic layout, e.g. tiling.
52+ // If running on Wayland assume the header bar will work (may need changing
53+ // if future cases occur).
54+ gboolean use_header_bar = TRUE ;
55+ #ifdef GDK_WINDOWING_X11
56+ GdkScreen* screen = gtk_window_get_screen (window);
57+ if (GDK_IS_X11_SCREEN (screen)) {
58+ const gchar* wm_name = gdk_x11_screen_get_window_manager_name (screen);
59+ if (g_strcmp0 (wm_name, " GNOME Shell" ) != 0 ) {
60+ use_header_bar = FALSE ;
61+ }
62+ }
63+ #endif
64+ if (use_header_bar) {
5165 GtkHeaderBar* header_bar = GTK_HEADER_BAR (gtk_header_bar_new ());
5266 gtk_widget_show (GTK_WIDGET (header_bar));
5367 gtk_header_bar_set_title (header_bar, " kazumi" );
@@ -134,11 +148,6 @@ static void my_application_class_init(MyApplicationClass* klass) {
134148static void my_application_init (MyApplication* self) {}
135149
136150MyApplication* my_application_new () {
137- // Set the program name to the application ID, which helps various systems
138- // like GTK and desktop environments map this running application to its
139- // corresponding .desktop file. This ensures better integration by allowing
140- // the application to be recognized beyond its binary name.
141- g_set_prgname (APPLICATION_ID);
142151 return MY_APPLICATION (g_object_new (my_application_get_type (),
143152 " application-id" , APPLICATION_ID,
144153 " flags" , G_APPLICATION_NON_UNIQUE,
0 commit comments