Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow use of qt window decorations #235

Merged
merged 1 commit into from
Jun 24, 2024
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
20 changes: 20 additions & 0 deletions linux/my_application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#include <gdk/gdkx.h>
#endif

#ifdef GDK_WINDOWING_WAYLAND
#include <gdk/gdkwayland.h>
#endif

#include "flutter/generated_plugin_registrant.h"

struct _MyApplication {
Expand All @@ -28,6 +32,7 @@ static void my_application_activate(GApplication* application) {
// 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)) {
Expand All @@ -37,6 +42,21 @@ static void my_application_activate(GApplication* application) {
}
}
#endif

#ifdef GDK_WINDOWING_WAYLAND
GdkDisplay* display = gtk_widget_get_display(GTK_WIDGET(window));
if (GDK_IS_WAYLAND_DISPLAY(display)) {
// Check the XDG_CURRENT_DESKTOP environment variable to determine the
// desktop environment.
const gchar* current_desktop = g_getenv("XDG_CURRENT_DESKTOP");
if (current_desktop != NULL && g_str_has_prefix(current_desktop, "GNOME")) {
use_header_bar = TRUE;
} else {
use_header_bar = FALSE;
}
}
#endif

if (use_header_bar) {
GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
gtk_widget_show(GTK_WIDGET(header_bar));
Expand Down
Loading