From b1aa09bf5791c442dbee453298ce4889d0030dc1 Mon Sep 17 00:00:00 2001 From: SquidSpirit Date: Sun, 29 Jun 2025 18:15:55 +0800 Subject: [PATCH] MCSI-1 feat: adjust window size --- lib/main/main.dart | 19 +++++++++- linux/runner/my_application.cc | 29 ++------------- pubspec.lock | 64 ++++++++++++++++++++++++++++++++++ pubspec.yaml | 1 + 4 files changed, 85 insertions(+), 28 deletions(-) diff --git a/lib/main/main.dart b/lib/main/main.dart index 96db365..b3aa558 100644 --- a/lib/main/main.dart +++ b/lib/main/main.dart @@ -1,6 +1,23 @@ import 'package:flutter/material.dart'; import 'package:minecraft_server_installer/main/framework/ui/minecraft_server_installer.dart'; +import 'package:window_manager/window_manager.dart'; + +Future main() async { + WidgetsFlutterBinding.ensureInitialized(); + await windowManager.ensureInitialized(); + + final windowOptions = const WindowOptions( + size: Size(400, 600), + minimumSize: Size(400, 600), + center: true, + backgroundColor: Colors.transparent, + skipTaskbar: false, + titleBarStyle: TitleBarStyle.hidden, + ); + windowManager.waitUntilReadyToShow(windowOptions, () async { + await windowManager.show(); + await windowManager.focus(); + }); -void main() { runApp(const MinecraftServerInstaller()); } diff --git a/linux/runner/my_application.cc b/linux/runner/my_application.cc index ac27961..b1cd8f2 100644 --- a/linux/runner/my_application.cc +++ b/linux/runner/my_application.cc @@ -20,34 +20,9 @@ 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 - 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, "minecraft_server_installer"); - 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, "minecraft_server_installer"); - } + gtk_window_set_decorated(window, FALSE); - gtk_window_set_default_size(window, 1280, 720); + gtk_window_set_default_size(window, 400, 600); gtk_widget_show(GTK_WIDGET(window)); g_autoptr(FlDartProject) project = fl_dart_project_new(); diff --git a/pubspec.lock b/pubspec.lock index f8cf391..d89613a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -123,6 +123,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.1.2" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" + url: "https://pub.dev" + source: hosted + version: "4.9.0" leak_tracker: dependency: transitive description: @@ -195,6 +203,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.1" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" provider: dependency: transitive description: @@ -203,6 +219,46 @@ packages: url: "https://pub.dev" source: hosted version: "6.1.5" + screen_retriever: + dependency: transitive + description: + name: screen_retriever + sha256: "570dbc8e4f70bac451e0efc9c9bb19fa2d6799a11e6ef04f946d7886d2e23d0c" + url: "https://pub.dev" + source: hosted + version: "0.2.0" + screen_retriever_linux: + dependency: transitive + description: + name: screen_retriever_linux + sha256: f7f8120c92ef0784e58491ab664d01efda79a922b025ff286e29aa123ea3dd18 + url: "https://pub.dev" + source: hosted + version: "0.2.0" + screen_retriever_macos: + dependency: transitive + description: + name: screen_retriever_macos + sha256: "71f956e65c97315dd661d71f828708bd97b6d358e776f1a30d5aa7d22d78a149" + url: "https://pub.dev" + source: hosted + version: "0.2.0" + screen_retriever_platform_interface: + dependency: transitive + description: + name: screen_retriever_platform_interface + sha256: ee197f4581ff0d5608587819af40490748e1e39e648d7680ecf95c05197240c0 + url: "https://pub.dev" + source: hosted + version: "0.2.0" + screen_retriever_windows: + dependency: transitive + description: + name: screen_retriever_windows + sha256: "449ee257f03ca98a57288ee526a301a430a344a161f9202b4fcc38576716fe13" + url: "https://pub.dev" + source: hosted + version: "0.2.0" sky_engine: dependency: transitive description: flutter @@ -288,6 +344,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.1" + window_manager: + dependency: "direct main" + description: + name: window_manager + sha256: "51d50168ab267d344b975b15390426b1243600d436770d3f13de67e55b05ec16" + url: "https://pub.dev" + source: hosted + version: "0.5.0" sdks: dart: ">=3.7.2 <4.0.0" flutter: ">=3.18.0-18.0.pre.54" diff --git a/pubspec.yaml b/pubspec.yaml index 8c714c9..a19fc57 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -39,6 +39,7 @@ dependencies: gap: ^3.0.1 http: ^1.4.0 path: ^1.9.1 + window_manager: ^0.5.0 dev_dependencies: flutter_test: