From ae640dda564210fae2510a4fd958f43e31603ef5 Mon Sep 17 00:00:00 2001 From: 21pages Date: Sun, 13 Aug 2023 17:50:19 +0800 Subject: [PATCH] fix macos minisized after checking permission Signed-off-by: 21pages --- flutter/lib/common.dart | 14 +++++++++++--- .../lib/desktop/pages/desktop_setting_page.dart | 5 +---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/flutter/lib/common.dart b/flutter/lib/common.dart index 6c3716f53..520156efb 100644 --- a/flutter/lib/common.dart +++ b/flutter/lib/common.dart @@ -222,7 +222,7 @@ class MyTheme { //tooltip static TooltipThemeData tooltipTheme() { return TooltipThemeData( - waitDuration: Duration(seconds: 1, milliseconds: 500), + waitDuration: Duration(seconds: 1, milliseconds: 500), ); } @@ -1554,7 +1554,7 @@ Future restoreWindowPosition(WindowType type, bool isRemotePeerPos = false; String? pos; // No need to check mainGetLocalBoolOptionSync(kOptionOpenNewConnInTabs) - // Though "open in tabs" is true and the new window restore peer position, it's ok. + // Though "open in tabs" is true and the new window restore peer position, it's ok. if (type == WindowType.RemoteDesktop && windowId != null && peerId != null) { // If the restore position is called by main window, and the peer id is not null // then we may need to get the position by reading the peer config. @@ -2281,10 +2281,18 @@ void onCopyFingerprint(String value) { } } +Future callMainCheckSuperUserPermission() async { + bool checked = await bind.mainCheckSuperUserPermission(); + if (Platform.isMacOS) { + await windowManager.show(); + } + return checked; +} + Future start_service(bool is_start) async { bool checked = !bind.mainIsInstalled() || !Platform.isMacOS || - await bind.mainCheckSuperUserPermission(); + await callMainCheckSuperUserPermission(); if (checked) { bind.mainSetOption(key: "stop-service", value: is_start ? "" : "Y"); } diff --git a/flutter/lib/desktop/pages/desktop_setting_page.dart b/flutter/lib/desktop/pages/desktop_setting_page.dart index e0e5858b7..b868042a4 100644 --- a/flutter/lib/desktop/pages/desktop_setting_page.dart +++ b/flutter/lib/desktop/pages/desktop_setting_page.dart @@ -1832,13 +1832,10 @@ Widget _lock( Text(translate(label)).marginOnly(left: 5), ]).marginSymmetric(vertical: 2)), onPressed: () async { - bool checked = await bind.mainCheckSuperUserPermission(); + bool checked = await callMainCheckSuperUserPermission(); if (checked) { onUnlock(); } - if (Platform.isMacOS) { - await windowManager.show(); - } }, ).marginSymmetric(horizontal: 2, vertical: 4), ).marginOnly(left: _kCardLeftMargin),