Skip to content

Commit 5f03540

Browse files
committed
feat(linux): use server-side window decorations by default
1 parent 2b926e0 commit 5f03540

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

linux/my_application.cc

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,12 @@ static void my_application_activate(GApplication* application) {
2020
GtkWindow* window =
2121
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
2222

23-
// Use a header bar when running in GNOME as this is the common style used
24-
// by applications and is the setup most users will be using (e.g. Ubuntu
25-
// desktop).
26-
// If running on X and not using GNOME then just use a traditional title bar
27-
// in case the window manager does more exotic layout, e.g. tiling.
28-
// If running on Wayland assume the header bar will work (may need changing
29-
// if future cases occur).
30-
gboolean use_header_bar = TRUE;
31-
#ifdef GDK_WINDOWING_X11
32-
GdkScreen* screen = gtk_window_get_screen(window);
33-
if (GDK_IS_X11_SCREEN(screen)) {
34-
const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
35-
if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
36-
use_header_bar = FALSE;
37-
}
38-
}
39-
#endif
40-
if (use_header_bar) {
23+
// The following code is adapted from LocalSend
24+
// (https://github.com/localsend/localsend/blob/main/app/linux/my_application.cc#L26-L37).
25+
//
26+
// Licensed under the Apache License, Version 2.0.
27+
const char *GTK_CSD = getenv("GTK_CSD");
28+
if (GTK_CSD && strcmp(GTK_CSD, "1") == 0) {
4129
GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
4230
gtk_widget_show(GTK_WIDGET(header_bar));
4331
gtk_header_bar_set_title(header_bar, "c001apk-flutter");

0 commit comments

Comments
 (0)