fix: linux duplicated title bar (#462)

Fixes #459
This commit is contained in:
lollipopkit🏳️‍⚧️
2024-07-15 17:38:30 +08:00
committed by GitHub
parent f7d6c461dc
commit c988dd88d7
12 changed files with 122 additions and 43 deletions

View File

@@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited. # This file should be version controlled and should not be manually edited.
version: version:
revision: "bae5e49bc2a867403c43b2aae2de8f8c33b037e4" revision: "761747bfc538b5af34aa0d3fac380f1bc331ec49"
channel: "stable" channel: "stable"
project_type: app project_type: app
@@ -13,26 +13,26 @@ project_type: app
migration: migration:
platforms: platforms:
- platform: root - platform: root
create_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4 create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
base_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4 base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
- platform: android - platform: android
create_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4 create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
base_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4 base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
- platform: ios - platform: ios
create_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4 create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
base_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4 base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
- platform: linux - platform: linux
create_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4 create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
base_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4 base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
- platform: macos - platform: macos
create_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4 create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
base_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4 base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
- platform: web - platform: web
create_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4 create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
base_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4 base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
- platform: windows - platform: windows
create_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4 create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
base_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4 base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
# User provided section # User provided section

View File

@@ -170,7 +170,7 @@ class Backup {
} }
Pros.reload(); Pros.reload();
RNodes.app.build(); RNodes.app.notify();
_logger.info('Restore success'); _logger.info('Restore success');
} }

View File

@@ -2,6 +2,6 @@
class BuildData { class BuildData {
static const String name = "ServerBox"; static const String name = "ServerBox";
static const int build = 1011; static const int build = 1014;
static const int script = 50; static const int script = 50;
} }

View File

@@ -95,7 +95,7 @@ final class _IntroPage extends StatelessWidget {
); );
if (selected != null) { if (selected != null) {
_setting.locale.put(selected.code); _setting.locale.put(selected.code);
RNodes.app.build(); RNodes.app.notify();
} }
}, },
trailing: Text( trailing: Text(

View File

@@ -75,6 +75,7 @@ Future<void> _initApp() async {
size: windowSize.fetch().toSize(), size: windowSize.fetch().toSize(),
listener: WindowSizeListener(windowSize), listener: WindowSizeListener(windowSize),
); );
FontUtils.loadFrom(Stores.setting.fontPath.fetch()); FontUtils.loadFrom(Stores.setting.fontPath.fetch());
_doPlatformRelated(); _doPlatformRelated();

View File

@@ -305,7 +305,7 @@ class _SettingPageState extends State<SettingPage> {
_setting.primaryColor.put(color.value); _setting.primaryColor.put(color.value);
context.pop(); context.pop();
context.pop(); context.pop();
RNodes.app.build(); RNodes.app.notify();
} }
// Widget _buildLaunchPage() { // Widget _buildLaunchPage() {
@@ -393,7 +393,7 @@ class _SettingPageState extends State<SettingPage> {
); );
if (selected != null) { if (selected != null) {
_setting.themeMode.put(selected); _setting.themeMode.put(selected);
RNodes.app.build(); RNodes.app.notify();
} }
}, },
trailing: ValBuilder( trailing: ValBuilder(
@@ -442,7 +442,7 @@ class _SettingPageState extends State<SettingPage> {
onPressed: () { onPressed: () {
_setting.fontPath.delete(); _setting.fontPath.delete();
context.pop(); context.pop();
RNodes.app.build(); RNodes.app.notify();
}, },
child: Text(l10n.clear), child: Text(l10n.clear),
) )
@@ -466,7 +466,7 @@ class _SettingPageState extends State<SettingPage> {
} }
context.pop(); context.pop();
RNodes.app.build(); RNodes.app.notify();
} }
Widget _buildTermFontSize() { Widget _buildTermFontSize() {
@@ -536,7 +536,7 @@ class _SettingPageState extends State<SettingPage> {
if (selected != null) { if (selected != null) {
_setting.locale.put(selected.code); _setting.locale.put(selected.code);
context.pop(); context.pop();
RNodes.app.build(); RNodes.app.notify();
} }
}, },
trailing: ListenBuilder( trailing: ListenBuilder(
@@ -609,7 +609,7 @@ class _SettingPageState extends State<SettingPage> {
subtitle: Text(l10n.fullScreenTip, style: UIs.textGrey), subtitle: Text(l10n.fullScreenTip, style: UIs.textGrey),
trailing: StoreSwitch( trailing: StoreSwitch(
prop: _setting.fullScreen, prop: _setting.fullScreen,
callback: (_) => RNodes.app.build(), callback: (_) => RNodes.app.notify(),
), ),
); );
} }
@@ -802,7 +802,7 @@ class _SettingPageState extends State<SettingPage> {
return; return;
} }
_setting.textFactor.put(val); _setting.textFactor.put(val);
RNodes.app.build(); RNodes.app.notify();
context.pop(); context.pop();
} }
@@ -1049,7 +1049,7 @@ class _SettingPageState extends State<SettingPage> {
title: Text(l10n.more), title: Text(l10n.more),
children: [ children: [
_buildBeta(), _buildBeta(),
_buildWakeLock(), if (isMobile) _buildWakeLock(),
_buildCollapseUI(), _buildCollapseUI(),
_buildCupertinoRoute(), _buildCupertinoRoute(),
if (isDesktop) _buildHideTitleBar(), if (isDesktop) _buildHideTitleBar(),

View File

@@ -1,4 +1,5 @@
import 'package:fl_lib/fl_lib.dart'; import 'package:fl_lib/fl_lib.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:icons_plus/icons_plus.dart'; import 'package:icons_plus/icons_plus.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@@ -89,7 +90,7 @@ class _SSHTabPageState extends State<SSHTabPage>
if (confirm != true) return; if (confirm != true) return;
_tabMap.remove(name); _tabMap.remove(name);
_tabRN.build(); _tabRN.notify();
_pageCtrl.previousPage( _pageCtrl.previousPage(
duration: Durations.medium1, curve: Curves.fastEaseInToSlowEaseOut); duration: Durations.medium1, curve: Curves.fastEaseInToSlowEaseOut);
} }
@@ -191,7 +192,7 @@ class _SSHTabPageState extends State<SSHTabPage>
), ),
key: key, key: key,
); );
_tabRN.build(); _tabRN.notify();
// Wait for the page to be built // Wait for the page to be built
await Future.delayed(Durations.short3); await Future.delayed(Durations.short3);
final idx = _tabMap.keys.toList().indexOf(name); final idx = _tabMap.keys.toList().indexOf(name);
@@ -213,7 +214,7 @@ final class _TabBar extends StatelessWidget implements PreferredSizeWidget {
required this.onClose, required this.onClose,
}); });
final ValueNotifier<int> idxVN; final ValueListenable<int> idxVN;
final _TabMap map; final _TabMap map;
final void Function(int idx) onTap; final void Function(int idx) onTap;
final void Function(String name) onClose; final void Function(String name) onClose;

View File

@@ -1,11 +1,19 @@
# Project-level configuration.
cmake_minimum_required(VERSION 3.10) cmake_minimum_required(VERSION 3.10)
project(runner LANGUAGES CXX) project(runner LANGUAGES CXX)
# The name of the executable created for the application. Change this to change
# the on-disk name of your application.
set(BINARY_NAME "ServerBox") set(BINARY_NAME "ServerBox")
# The unique GTK application identifier for this application. See:
# https://wiki.gnome.org/HowDoI/ChooseApplicationID
set(APPLICATION_ID "tech.lolli.toolbox") set(APPLICATION_ID "tech.lolli.toolbox")
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
# versions of CMake.
cmake_policy(SET CMP0063 NEW) cmake_policy(SET CMP0063 NEW)
# Load bundled libraries from the lib/ directory relative to the binary.
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
# Root filesystem for cross-building. # Root filesystem for cross-building.
@@ -18,7 +26,7 @@ if(FLUTTER_TARGET_PLATFORM_SYSROOT)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
endif() endif()
# Configure build options. # Define build configuration options.
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Debug" CACHE set(CMAKE_BUILD_TYPE "Debug" CACHE
STRING "Flutter build mode" FORCE) STRING "Flutter build mode" FORCE)
@@ -27,6 +35,10 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
endif() endif()
# Compilation settings that should be applied to most targets. # Compilation settings that should be applied to most targets.
#
# Be cautious about adding new options here, as plugins use this function by
# default. In most cases, you should add new options to specific targets instead
# of modifying this function.
function(APPLY_STANDARD_SETTINGS TARGET) function(APPLY_STANDARD_SETTINGS TARGET)
target_compile_features(${TARGET} PUBLIC cxx_std_14) target_compile_features(${TARGET} PUBLIC cxx_std_14)
target_compile_options(${TARGET} PRIVATE -Wall -Werror) target_compile_options(${TARGET} PRIVATE -Wall -Werror)
@@ -34,9 +46,8 @@ function(APPLY_STANDARD_SETTINGS TARGET)
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>") target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
endfunction() endfunction()
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
# Flutter library and tool build rules. # Flutter library and tool build rules.
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
add_subdirectory(${FLUTTER_MANAGED_DIR}) add_subdirectory(${FLUTTER_MANAGED_DIR})
# System-level dependencies. # System-level dependencies.
@@ -45,16 +56,27 @@ pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
# Application build # Define the application target. To change its name, change BINARY_NAME above,
# not the value here, or `flutter run` will no longer work.
#
# Any new source files that you add to the application should be added here.
add_executable(${BINARY_NAME} add_executable(${BINARY_NAME}
"main.cc" "main.cc"
"my_application.cc" "my_application.cc"
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
) )
# Apply the standard set of build settings. This can be removed for applications
# that need different build settings.
apply_standard_settings(${BINARY_NAME}) apply_standard_settings(${BINARY_NAME})
# Add dependency libraries. Add any application-specific dependencies here.
target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE flutter)
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
# Run the Flutter tool portions of the build. This must not be removed.
add_dependencies(${BINARY_NAME} flutter_assemble) add_dependencies(${BINARY_NAME} flutter_assemble)
# Only the install-generated bundle's copy of the executable will launch # Only the install-generated bundle's copy of the executable will launch
# correctly, since the resources must in the right relative locations. To avoid # correctly, since the resources must in the right relative locations. To avoid
# people trying to run the unbundled copy, put it in a subdirectory instead of # people trying to run the unbundled copy, put it in a subdirectory instead of
@@ -64,6 +86,7 @@ set_target_properties(${BINARY_NAME}
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
) )
# Generated plugin build rules, which manage building the plugins and adding # Generated plugin build rules, which manage building the plugins and adding
# them to the application. # them to the application.
include(flutter/generated_plugins.cmake) include(flutter/generated_plugins.cmake)
@@ -94,11 +117,17 @@ install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime) COMPONENT Runtime)
if(PLUGIN_BUNDLED_LIBRARIES) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" install(FILES "${bundled_library}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endforeach(bundled_library)
# Copy the native assets provided by the build.dart from all packages.
set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/")
install(DIRECTORY "${NATIVE_ASSETS_DIR}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime) COMPONENT Runtime)
endif()
# Fully re-copy the assets directory on each build to avoid having stale files # Fully re-copy the assets directory on each build to avoid having stale files
# from a previous install. # from a previous install.

View File

@@ -1,3 +1,4 @@
# This file controls Flutter-level build steps. It should not be edited.
cmake_minimum_required(VERSION 3.10) cmake_minimum_required(VERSION 3.10)
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")

View File

@@ -20,6 +20,33 @@ static void my_application_activate(GApplication* application) {
GtkWindow* window = GtkWindow* window =
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 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
if (use_header_bar) {
GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
gtk_widget_show(GTK_WIDGET(header_bar));
gtk_header_bar_set_title(header_bar, "ServerBox");
gtk_header_bar_set_show_close_button(header_bar, TRUE);
gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
} else {
gtk_window_set_title(window, "ServerBox");
}
gtk_window_set_default_size(window, 400, 777); gtk_window_set_default_size(window, 400, 777);
gtk_widget_show(GTK_WIDGET(window)); gtk_widget_show(GTK_WIDGET(window));
@@ -54,6 +81,24 @@ static gboolean my_application_local_command_line(GApplication* application, gch
return TRUE; return TRUE;
} }
// Implements GApplication::startup.
static void my_application_startup(GApplication* application) {
//MyApplication* self = MY_APPLICATION(object);
// Perform any actions required at application startup.
G_APPLICATION_CLASS(my_application_parent_class)->startup(application);
}
// Implements GApplication::shutdown.
static void my_application_shutdown(GApplication* application) {
//MyApplication* self = MY_APPLICATION(object);
// Perform any actions required at application shutdown.
G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application);
}
// Implements GObject::dispose. // Implements GObject::dispose.
static void my_application_dispose(GObject* object) { static void my_application_dispose(GObject* object) {
MyApplication* self = MY_APPLICATION(object); MyApplication* self = MY_APPLICATION(object);
@@ -64,6 +109,8 @@ static void my_application_dispose(GObject* object) {
static void my_application_class_init(MyApplicationClass* klass) { static void my_application_class_init(MyApplicationClass* klass) {
G_APPLICATION_CLASS(klass)->activate = my_application_activate; G_APPLICATION_CLASS(klass)->activate = my_application_activate;
G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line;
G_APPLICATION_CLASS(klass)->startup = my_application_startup;
G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown;
G_OBJECT_CLASS(klass)->dispose = my_application_dispose; G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
} }

View File

@@ -368,8 +368,8 @@ packages:
dependency: "direct dev" dependency: "direct dev"
description: description:
path: "." path: "."
ref: "v1.0.32" ref: "v1.0.33"
resolved-ref: "66b36278a2f9f60da3dba804e81148afc60e342e" resolved-ref: "885c3479db8867f1c4078b97f65578ee2cbc9466"
url: "https://github.com/lppcg/fl_build.git" url: "https://github.com/lppcg/fl_build.git"
source: git source: git
version: "1.0.0" version: "1.0.0"
@@ -385,8 +385,8 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
path: "." path: "."
ref: "v1.0.60" ref: "v1.0.67"
resolved-ref: "5a88f7c6901e8f2c556a1d79ceaf7be9fb518233" resolved-ref: e91886e49ccede77ba7fed14325963ac260f999e
url: "https://github.com/lppcg/fl_lib" url: "https://github.com/lppcg/fl_lib"
source: git source: git
version: "0.0.1" version: "0.0.1"

View File

@@ -1,7 +1,7 @@
name: server_box name: server_box
description: server status & toolbox app. description: server status & toolbox app.
publish_to: 'none' publish_to: 'none'
version: 1.0.1011+1011 version: 1.0.1014+1014
environment: environment:
sdk: ">=3.0.0" sdk: ">=3.0.0"
@@ -58,7 +58,7 @@ dependencies:
fl_lib: fl_lib:
git: git:
url: https://github.com/lppcg/fl_lib url: https://github.com/lppcg/fl_lib
ref: v1.0.60 ref: v1.0.67
dependency_overrides: dependency_overrides:
# dartssh2: # dartssh2:
@@ -79,7 +79,7 @@ dev_dependencies:
# path: ../fl_build # path: ../fl_build
git: git:
url: https://github.com/lppcg/fl_build.git url: https://github.com/lppcg/fl_build.git
ref: v1.0.32 ref: v1.0.33
flutter: flutter:
generate: true generate: true