Skip to content

Commit bb1181f

Browse files
committed
Fix titlebar on KDE desktops
KDE desktops automatically use the native title bar, so handy was required to properly display just the Yaru bar. This change is likely not enough long term as noted by the apps team, so it will change in the future.
1 parent 9203bfe commit bb1181f

File tree

4 files changed

+10
-29
lines changed

4 files changed

+10
-29
lines changed

packages/game_center/linux/flutter/generated_plugin_registrant.cc

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "generated_plugin_registrant.h"
88

99
#include <gtk/gtk_plugin.h>
10+
#include <handy_window/handy_window_plugin.h>
1011
#include <screen_retriever/screen_retriever_plugin.h>
1112
#include <window_manager/window_manager_plugin.h>
1213
#include <yaru_window_linux/yaru_window_linux_plugin.h>
@@ -15,6 +16,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
1516
g_autoptr(FlPluginRegistrar) gtk_registrar =
1617
fl_plugin_registry_get_registrar_for_plugin(registry, "GtkPlugin");
1718
gtk_plugin_register_with_registrar(gtk_registrar);
19+
g_autoptr(FlPluginRegistrar) handy_window_registrar =
20+
fl_plugin_registry_get_registrar_for_plugin(registry, "HandyWindowPlugin");
21+
handy_window_plugin_register_with_registrar(handy_window_registrar);
1822
g_autoptr(FlPluginRegistrar) screen_retriever_registrar =
1923
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin");
2024
screen_retriever_plugin_register_with_registrar(screen_retriever_registrar);

packages/game_center/linux/flutter/generated_plugins.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
list(APPEND FLUTTER_PLUGIN_LIST
66
gtk
7+
handy_window
78
screen_retriever
89
window_manager
910
yaru_window_linux

packages/game_center/linux/my_application.cc

+4-29
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "my_application.h"
22

33
#include <flutter_linux/flutter_linux.h>
4+
#include <handy.h>
45
#ifdef GDK_WINDOWING_X11
56
#include <gdk/gdkx.h>
67
#endif
@@ -17,35 +18,9 @@ G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
1718
// Implements GApplication::activate.
1819
static void my_application_activate(GApplication* application) {
1920
MyApplication* self = MY_APPLICATION(application);
20-
GtkWindow* window =
21-
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
22-
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) {
41-
GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
42-
gtk_widget_show(GTK_WIDGET(header_bar));
43-
gtk_header_bar_set_title(header_bar, "game_center");
44-
gtk_header_bar_set_show_close_button(header_bar, TRUE);
45-
gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
46-
} else {
47-
gtk_window_set_title(window, "game_center");
48-
}
21+
22+
GtkWindow* window = GTK_WINDOW(hdy_application_window_new());
23+
gtk_window_set_application(window, GTK_APPLICATION(application));
4924

5025
gtk_window_set_default_size(window, 1280, 720);
5126
gtk_widget_show(GTK_WIDGET(window));

packages/game_center/pubspec.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ dependencies:
1414
flutter_localizations:
1515
sdk: flutter
1616
flutter_riverpod: ^2.5.1
17+
handy_window: ^0.4.0
1718
intl: ^0.19.0
1819
path: ^1.9.0
1920
riverpod_annotation: ^2.3.5

0 commit comments

Comments
 (0)