Skip to content

An open-source cross-platform alternative to AirDrop

disable GTK3 headerbar by default on Linux (#2360)

Erik Junsvedd67b84ffdb96
diff --git a/app/linux/my_application.cc b/app/linux/my_application.cc
index d4d9068e..3c4dec00 100644
--- a/app/linux/my_application.cc
+++ b/app/linux/my_application.cc
@@ -23,28 +23,10 @@ static void my_application_activate(GApplication* application) {
GtkWindow* window =
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
- // Use a header bar when running in GNOME as this is the common style used
- // by applications and is the setup most users will be using (e.g. Ubuntu
- // desktop).
- // If running on X and not using GNOME then just use a traditional title bar
- // in case the window manager does more exotic layout, e.g. tiling.
- // If running on Wayland assume the header bar will work (may need changing
- // if future cases occur).
- gboolean use_header_bar = TRUE;
-#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;
- }
- }
-#endif
- // If have GTK_CSD in env and it is equal to 0 then don't add the gtk header bar
- // to disable client side decorations
+ // If have GTK_CSD in env and it is equal to 1 then add the gtk header bar
+ // to always use client side decorations
const char* GTK_CSD = getenv("GTK_CSD");
- gboolean use_gtk_csd = !GTK_CSD || strcmp(GTK_CSD, "0") != 0;
- if (use_header_bar && use_gtk_csd) {
+ if (GTK_CSD && strcmp(GTK_CSD, "1") == 0) {
GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
gtk_widget_show(GTK_WIDGET(header_bar));
gtk_header_bar_set_title(header_bar, "LocalSend");
@@ -104,6 +86,12 @@ static void my_application_class_init(MyApplicationClass* klass) {
static void my_application_init(MyApplication* self) {}
MyApplication* my_application_new() {
+ // Set the program name to the application ID, which helps various systems
+ // like GTK and desktop environments map this running application to its
+ // corresponding .desktop file. This ensures better integration by allowing
+ // the application to be recognized beyond its binary name.
+ g_set_prgname(APPLICATION_ID);
+
return MY_APPLICATION(g_object_new(my_application_get_type(),
"application-id", APPLICATION_ID,
"flags", G_APPLICATION_NON_UNIQUE,