Skip to content

Commit d14a725

Browse files
committed
fix: Window size issue
1 parent 5f5958b commit d14a725

File tree

9 files changed

+30
-8
lines changed

9 files changed

+30
-8
lines changed

lib/main.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'package:fluent_ui/fluent_ui.dart';
88
import 'package:intl/intl_standalone.dart';
99
import 'package:tray_manager/tray_manager.dart';
1010
import 'package:system_theme/system_theme.dart';
11+
import 'package:desktop_window/desktop_window.dart';
1112
import 'package:flutter_acrylic/flutter_acrylic.dart';
1213
import 'package:bitsdojo_window/bitsdojo_window.dart';
1314
import 'package:device_info_plus/device_info_plus.dart';
@@ -177,11 +178,10 @@ void main(List<String> arguments) async {
177178
doWhenWindowReady(() {
178179
final windowSize = windowSizes[windowSizeSetting];
179180

180-
if (windowSize != null) {
181-
appWindow.size = windowSize;
182-
}
183-
appWindow.alignment = Alignment.center;
184-
appWindow.show();
181+
DesktopWindow.setWindowSize(windowSize!).then((_) {
182+
appWindow.alignment = Alignment.center;
183+
appWindow.show();
184+
});
185185
});
186186
}
187187

lib/screens/settings_theme/settings_theme.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import 'package:bitsdojo_window/bitsdojo_window.dart';
21
import 'package:fluent_ui/fluent_ui.dart';
2+
import 'package:desktop_window/desktop_window.dart';
33
import 'package:material_symbols_icons/symbols.dart';
4+
import 'package:bitsdojo_window/bitsdojo_window.dart';
45

56
import '../../utils/l10n.dart';
67
import '../../utils/ax_shadow.dart';
@@ -117,7 +118,7 @@ class _SettingsThemeState extends State<SettingsTheme> {
117118
windowSize = newWindowSize;
118119
});
119120

120-
appWindow.size = size;
121+
await DesktopWindow.setWindowSize(size);
121122
appWindow.alignment = Alignment.center;
122123
await SettingsManager().setValue(windowSizeKey, newWindowSize);
123124
}

linux/flutter/generated_plugin_registrant.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "generated_plugin_registrant.h"
88

99
#include <bitsdojo_window_linux/bitsdojo_window_plugin.h>
10+
#include <desktop_window/desktop_window_plugin.h>
1011
#include <file_selector_linux/file_selector_plugin.h>
1112
#include <flutter_acrylic/flutter_acrylic_plugin.h>
1213
#include <flutter_window_close/flutter_window_close_plugin.h>
@@ -20,6 +21,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
2021
g_autoptr(FlPluginRegistrar) bitsdojo_window_linux_registrar =
2122
fl_plugin_registry_get_registrar_for_plugin(registry, "BitsdojoWindowPlugin");
2223
bitsdojo_window_plugin_register_with_registrar(bitsdojo_window_linux_registrar);
24+
g_autoptr(FlPluginRegistrar) desktop_window_registrar =
25+
fl_plugin_registry_get_registrar_for_plugin(registry, "DesktopWindowPlugin");
26+
desktop_window_plugin_register_with_registrar(desktop_window_registrar);
2327
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
2428
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
2529
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);

linux/flutter/generated_plugins.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
list(APPEND FLUTTER_PLUGIN_LIST
66
bitsdojo_window_linux
7+
desktop_window
78
file_selector_linux
89
flutter_acrylic
910
flutter_window_close

linux/my_application.cc

Lines changed: 4 additions & 1 deletion
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 <bitsdojo_window_linux/bitsdojo_window_plugin.h>
45
#ifdef GDK_WINDOWING_X11
56
#include <gdk/gdkx.h>
67
#endif
@@ -47,7 +48,9 @@ static void my_application_activate(GApplication* application) {
4748
gtk_window_set_title(window, "rune");
4849
}
4950

50-
gtk_window_set_default_size(window, 1280, 720);
51+
auto bdw = bitsdojo_window_from(window);
52+
bdw->setCustomFrame(false);
53+
gtk_window_set_default_size(window, 0, 0);
5154
gtk_widget_show(GTK_WIDGET(window));
5255

5356
g_autoptr(FlDartProject) project = fl_dart_project_new();

pubspec.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,14 @@ packages:
246246
url: "https://pub.dev"
247247
source: hosted
248248
version: "2.3.7"
249+
desktop_window:
250+
dependency: "direct main"
251+
description:
252+
name: desktop_window
253+
sha256: d0590e75a0a8f91245b439fb7f2bf0ebb62d9cd9fdc7aa0622a5d50615c46845
254+
url: "https://pub.dev"
255+
source: hosted
256+
version: "0.4.2"
249257
device_info_plus:
250258
dependency: "direct main"
251259
description:

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ dependencies:
7474
bitsdojo_window: ^0.1.6
7575
flutter_window_close: ^1.2.0
7676
tray_manager: ^0.3.0
77+
desktop_window: ^0.4.2
7778

7879
dev_dependencies:
7980
build_runner: ^2.4.11

windows/flutter/generated_plugin_registrant.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "generated_plugin_registrant.h"
88

99
#include <bitsdojo_window_windows/bitsdojo_window_plugin.h>
10+
#include <desktop_window/desktop_window_plugin.h>
1011
#include <file_selector_windows/file_selector_windows.h>
1112
#include <flutter_acrylic/flutter_acrylic_plugin.h>
1213
#include <flutter_window_close/flutter_window_close_plugin.h>
@@ -20,6 +21,8 @@
2021
void RegisterPlugins(flutter::PluginRegistry* registry) {
2122
BitsdojoWindowPluginRegisterWithRegistrar(
2223
registry->GetRegistrarForPlugin("BitsdojoWindowPlugin"));
24+
DesktopWindowPluginRegisterWithRegistrar(
25+
registry->GetRegistrarForPlugin("DesktopWindowPlugin"));
2326
FileSelectorWindowsRegisterWithRegistrar(
2427
registry->GetRegistrarForPlugin("FileSelectorWindows"));
2528
FlutterAcrylicPluginRegisterWithRegistrar(

windows/flutter/generated_plugins.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
list(APPEND FLUTTER_PLUGIN_LIST
66
bitsdojo_window_windows
7+
desktop_window
78
file_selector_windows
89
flutter_acrylic
910
flutter_window_close

0 commit comments

Comments
 (0)