Skip to content

Commit c988dd8

Browse files
authored
fix: linux duplicated title bar (#462)
Fixes #459
1 parent f7d6c46 commit c988dd8

File tree

12 files changed

+122
-43
lines changed

12 files changed

+122
-43
lines changed

.metadata

+15-15
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This file should be version controlled and should not be manually edited.
55

66
version:
7-
revision: "bae5e49bc2a867403c43b2aae2de8f8c33b037e4"
7+
revision: "761747bfc538b5af34aa0d3fac380f1bc331ec49"
88
channel: "stable"
99

1010
project_type: app
@@ -13,26 +13,26 @@ project_type: app
1313
migration:
1414
platforms:
1515
- platform: root
16-
create_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
17-
base_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
16+
create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
17+
base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
1818
- platform: android
19-
create_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
20-
base_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
19+
create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
20+
base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
2121
- platform: ios
22-
create_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
23-
base_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
22+
create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
23+
base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
2424
- platform: linux
25-
create_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
26-
base_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
25+
create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
26+
base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
2727
- platform: macos
28-
create_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
29-
base_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
28+
create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
29+
base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
3030
- platform: web
31-
create_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
32-
base_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
31+
create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
32+
base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
3333
- platform: windows
34-
create_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
35-
base_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
34+
create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
35+
base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
3636

3737
# User provided section
3838

lib/data/model/app/backup.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class Backup {
170170
}
171171

172172
Pros.reload();
173-
RNodes.app.build();
173+
RNodes.app.notify();
174174

175175
_logger.info('Restore success');
176176
}

lib/data/res/build_data.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
class BuildData {
44
static const String name = "ServerBox";
5-
static const int build = 1011;
5+
static const int build = 1014;
66
static const int script = 50;
77
}

lib/intro.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ final class _IntroPage extends StatelessWidget {
9595
);
9696
if (selected != null) {
9797
_setting.locale.put(selected.code);
98-
RNodes.app.build();
98+
RNodes.app.notify();
9999
}
100100
},
101101
trailing: Text(

lib/main.dart

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Future<void> _initApp() async {
7575
size: windowSize.fetch().toSize(),
7676
listener: WindowSizeListener(windowSize),
7777
);
78+
7879
FontUtils.loadFrom(Stores.setting.fontPath.fetch());
7980

8081
_doPlatformRelated();

lib/view/page/setting/entry.dart

+8-8
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ class _SettingPageState extends State<SettingPage> {
305305
_setting.primaryColor.put(color.value);
306306
context.pop();
307307
context.pop();
308-
RNodes.app.build();
308+
RNodes.app.notify();
309309
}
310310

311311
// Widget _buildLaunchPage() {
@@ -393,7 +393,7 @@ class _SettingPageState extends State<SettingPage> {
393393
);
394394
if (selected != null) {
395395
_setting.themeMode.put(selected);
396-
RNodes.app.build();
396+
RNodes.app.notify();
397397
}
398398
},
399399
trailing: ValBuilder(
@@ -442,7 +442,7 @@ class _SettingPageState extends State<SettingPage> {
442442
onPressed: () {
443443
_setting.fontPath.delete();
444444
context.pop();
445-
RNodes.app.build();
445+
RNodes.app.notify();
446446
},
447447
child: Text(l10n.clear),
448448
)
@@ -466,7 +466,7 @@ class _SettingPageState extends State<SettingPage> {
466466
}
467467

468468
context.pop();
469-
RNodes.app.build();
469+
RNodes.app.notify();
470470
}
471471

472472
Widget _buildTermFontSize() {
@@ -536,7 +536,7 @@ class _SettingPageState extends State<SettingPage> {
536536
if (selected != null) {
537537
_setting.locale.put(selected.code);
538538
context.pop();
539-
RNodes.app.build();
539+
RNodes.app.notify();
540540
}
541541
},
542542
trailing: ListenBuilder(
@@ -609,7 +609,7 @@ class _SettingPageState extends State<SettingPage> {
609609
subtitle: Text(l10n.fullScreenTip, style: UIs.textGrey),
610610
trailing: StoreSwitch(
611611
prop: _setting.fullScreen,
612-
callback: (_) => RNodes.app.build(),
612+
callback: (_) => RNodes.app.notify(),
613613
),
614614
);
615615
}
@@ -802,7 +802,7 @@ class _SettingPageState extends State<SettingPage> {
802802
return;
803803
}
804804
_setting.textFactor.put(val);
805-
RNodes.app.build();
805+
RNodes.app.notify();
806806
context.pop();
807807
}
808808

@@ -1049,7 +1049,7 @@ class _SettingPageState extends State<SettingPage> {
10491049
title: Text(l10n.more),
10501050
children: [
10511051
_buildBeta(),
1052-
_buildWakeLock(),
1052+
if (isMobile) _buildWakeLock(),
10531053
_buildCollapseUI(),
10541054
_buildCupertinoRoute(),
10551055
if (isDesktop) _buildHideTitleBar(),

lib/view/page/ssh/tab.dart

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:fl_lib/fl_lib.dart';
2+
import 'package:flutter/foundation.dart';
23
import 'package:flutter/material.dart';
34
import 'package:icons_plus/icons_plus.dart';
45
import 'package:provider/provider.dart';
@@ -89,7 +90,7 @@ class _SSHTabPageState extends State<SSHTabPage>
8990
if (confirm != true) return;
9091

9192
_tabMap.remove(name);
92-
_tabRN.build();
93+
_tabRN.notify();
9394
_pageCtrl.previousPage(
9495
duration: Durations.medium1, curve: Curves.fastEaseInToSlowEaseOut);
9596
}
@@ -191,7 +192,7 @@ class _SSHTabPageState extends State<SSHTabPage>
191192
),
192193
key: key,
193194
);
194-
_tabRN.build();
195+
_tabRN.notify();
195196
// Wait for the page to be built
196197
await Future.delayed(Durations.short3);
197198
final idx = _tabMap.keys.toList().indexOf(name);
@@ -213,7 +214,7 @@ final class _TabBar extends StatelessWidget implements PreferredSizeWidget {
213214
required this.onClose,
214215
});
215216

216-
final ValueNotifier<int> idxVN;
217+
final ValueListenable<int> idxVN;
217218
final _TabMap map;
218219
final void Function(int idx) onTap;
219220
final void Function(String name) onClose;

linux/CMakeLists.txt

+36-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
# Project-level configuration.
12
cmake_minimum_required(VERSION 3.10)
23
project(runner LANGUAGES CXX)
34

5+
# The name of the executable created for the application. Change this to change
6+
# the on-disk name of your application.
47
set(BINARY_NAME "ServerBox")
8+
# The unique GTK application identifier for this application. See:
9+
# https://wiki.gnome.org/HowDoI/ChooseApplicationID
510
set(APPLICATION_ID "tech.lolli.toolbox")
611

12+
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
13+
# versions of CMake.
714
cmake_policy(SET CMP0063 NEW)
815

16+
# Load bundled libraries from the lib/ directory relative to the binary.
917
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
1018

1119
# Root filesystem for cross-building.
@@ -18,7 +26,7 @@ if(FLUTTER_TARGET_PLATFORM_SYSROOT)
1826
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
1927
endif()
2028

21-
# Configure build options.
29+
# Define build configuration options.
2230
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
2331
set(CMAKE_BUILD_TYPE "Debug" CACHE
2432
STRING "Flutter build mode" FORCE)
@@ -27,16 +35,19 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
2735
endif()
2836

2937
# Compilation settings that should be applied to most targets.
38+
#
39+
# Be cautious about adding new options here, as plugins use this function by
40+
# default. In most cases, you should add new options to specific targets instead
41+
# of modifying this function.
3042
function(APPLY_STANDARD_SETTINGS TARGET)
3143
target_compile_features(${TARGET} PUBLIC cxx_std_14)
3244
target_compile_options(${TARGET} PRIVATE -Wall -Werror)
3345
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
3446
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
3547
endfunction()
3648

37-
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
38-
3949
# Flutter library and tool build rules.
50+
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
4051
add_subdirectory(${FLUTTER_MANAGED_DIR})
4152

4253
# System-level dependencies.
@@ -45,16 +56,27 @@ pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
4556

4657
add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
4758

48-
# Application build
59+
# Define the application target. To change its name, change BINARY_NAME above,
60+
# not the value here, or `flutter run` will no longer work.
61+
#
62+
# Any new source files that you add to the application should be added here.
4963
add_executable(${BINARY_NAME}
5064
"main.cc"
5165
"my_application.cc"
5266
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
5367
)
68+
69+
# Apply the standard set of build settings. This can be removed for applications
70+
# that need different build settings.
5471
apply_standard_settings(${BINARY_NAME})
72+
73+
# Add dependency libraries. Add any application-specific dependencies here.
5574
target_link_libraries(${BINARY_NAME} PRIVATE flutter)
5675
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
76+
77+
# Run the Flutter tool portions of the build. This must not be removed.
5778
add_dependencies(${BINARY_NAME} flutter_assemble)
79+
5880
# Only the install-generated bundle's copy of the executable will launch
5981
# correctly, since the resources must in the right relative locations. To avoid
6082
# people trying to run the unbundled copy, put it in a subdirectory instead of
@@ -64,6 +86,7 @@ set_target_properties(${BINARY_NAME}
6486
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
6587
)
6688

89+
6790
# Generated plugin build rules, which manage building the plugins and adding
6891
# them to the application.
6992
include(flutter/generated_plugins.cmake)
@@ -94,11 +117,17 @@ install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}
94117
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
95118
COMPONENT Runtime)
96119

97-
if(PLUGIN_BUNDLED_LIBRARIES)
98-
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
120+
foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
121+
install(FILES "${bundled_library}"
99122
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
100123
COMPONENT Runtime)
101-
endif()
124+
endforeach(bundled_library)
125+
126+
# Copy the native assets provided by the build.dart from all packages.
127+
set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/")
128+
install(DIRECTORY "${NATIVE_ASSETS_DIR}"
129+
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
130+
COMPONENT Runtime)
102131

103132
# Fully re-copy the assets directory on each build to avoid having stale files
104133
# from a previous install.

linux/flutter/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# This file controls Flutter-level build steps. It should not be edited.
12
cmake_minimum_required(VERSION 3.10)
23

34
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")

linux/my_application.cc

+47
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,33 @@ 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) {
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, "ServerBox");
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, "ServerBox");
48+
}
49+
2350
gtk_window_set_default_size(window, 400, 777);
2451
gtk_widget_show(GTK_WIDGET(window));
2552

@@ -54,6 +81,24 @@ static gboolean my_application_local_command_line(GApplication* application, gch
5481
return TRUE;
5582
}
5683

84+
// Implements GApplication::startup.
85+
static void my_application_startup(GApplication* application) {
86+
//MyApplication* self = MY_APPLICATION(object);
87+
88+
// Perform any actions required at application startup.
89+
90+
G_APPLICATION_CLASS(my_application_parent_class)->startup(application);
91+
}
92+
93+
// Implements GApplication::shutdown.
94+
static void my_application_shutdown(GApplication* application) {
95+
//MyApplication* self = MY_APPLICATION(object);
96+
97+
// Perform any actions required at application shutdown.
98+
99+
G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application);
100+
}
101+
57102
// Implements GObject::dispose.
58103
static void my_application_dispose(GObject* object) {
59104
MyApplication* self = MY_APPLICATION(object);
@@ -64,6 +109,8 @@ static void my_application_dispose(GObject* object) {
64109
static void my_application_class_init(MyApplicationClass* klass) {
65110
G_APPLICATION_CLASS(klass)->activate = my_application_activate;
66111
G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line;
112+
G_APPLICATION_CLASS(klass)->startup = my_application_startup;
113+
G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown;
67114
G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
68115
}
69116

pubspec.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ packages:
368368
dependency: "direct dev"
369369
description:
370370
path: "."
371-
ref: "v1.0.32"
372-
resolved-ref: "66b36278a2f9f60da3dba804e81148afc60e342e"
371+
ref: "v1.0.33"
372+
resolved-ref: "885c3479db8867f1c4078b97f65578ee2cbc9466"
373373
url: "https://github.com/lppcg/fl_build.git"
374374
source: git
375375
version: "1.0.0"
@@ -385,8 +385,8 @@ packages:
385385
dependency: "direct main"
386386
description:
387387
path: "."
388-
ref: "v1.0.60"
389-
resolved-ref: "5a88f7c6901e8f2c556a1d79ceaf7be9fb518233"
388+
ref: "v1.0.67"
389+
resolved-ref: e91886e49ccede77ba7fed14325963ac260f999e
390390
url: "https://github.com/lppcg/fl_lib"
391391
source: git
392392
version: "0.0.1"

0 commit comments

Comments
 (0)