Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 4 additions & 22 deletions scripts/app_config/templates/linux/my_application.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#include "my_application.h"

#include <flutter_linux/flutter_linux.h>
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#endif

#include "flutter/generated_plugin_registrant.h"

Expand All @@ -26,26 +23,11 @@ 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
// Use a traditional title bar by default for best compatibility across
// desktop environments (KDE, XFCE, tiling WMs, etc.).
// Set GTK_CSD=1 to use a GNOME-style header bar instead.
const char* gtk_csd_env_var = getenv("GTK_CSD");
gboolean use_gtk_csd = !gtk_csd_env_var || strcmp(gtk_csd_env_var, "0") != 0;
if (use_header_bar && use_gtk_csd) {
if (gtk_csd_env_var && strcmp(gtk_csd_env_var, "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, "PlaceHolderName");
Expand Down
Loading