mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-23 18:22:39 +03:00
Improve handling of hidden/shown window
This commit is contained in:
parent
3c260e5bac
commit
127b1427f1
@ -141,15 +141,14 @@ Future<Widget> initialize(List<String> argv) async {
|
||||
_log.debug('Using saved window bounds (or defaults): $bounds');
|
||||
|
||||
unawaited(windowManager
|
||||
.waitUntilReadyToShow(WindowOptions(
|
||||
.waitUntilReadyToShow(const WindowOptions(
|
||||
minimumSize: WindowDefaults.minSize,
|
||||
skipTaskbar: isHidden,
|
||||
skipTaskbar: false,
|
||||
))
|
||||
.then((_) async {
|
||||
await windowManagerHelper.setBounds(bounds);
|
||||
|
||||
if (isHidden) {
|
||||
await windowManager.setSkipTaskbar(true);
|
||||
} else {
|
||||
await windowManager.show();
|
||||
}
|
||||
|
@ -97,7 +97,6 @@ class DesktopWindowStateNotifier extends StateNotifier<WindowState>
|
||||
} else {
|
||||
await windowManager.show();
|
||||
}
|
||||
await windowManager.setSkipTaskbar(hidden);
|
||||
await _prefs.setBool(windowHidden, hidden);
|
||||
state = state.copyWith(hidden: hidden);
|
||||
}
|
||||
|
@ -149,9 +149,10 @@ class _Systray extends TrayListener {
|
||||
}
|
||||
|
||||
@override
|
||||
void onTrayIconMouseDown() {
|
||||
void onTrayIconMouseDown() async {
|
||||
if (Platform.isMacOS) {
|
||||
trayManager.popUpContextMenu();
|
||||
await _updateContextMenu();
|
||||
await trayManager.popUpContextMenu();
|
||||
} else {
|
||||
final now = DateTime.now().millisecondsSinceEpoch;
|
||||
if (now - _lastClick < 500) {
|
||||
@ -159,7 +160,7 @@ class _Systray extends TrayListener {
|
||||
if (_isHidden) {
|
||||
_ref.read(desktopWindowStateProvider.notifier).setWindowHidden(false);
|
||||
} else {
|
||||
windowManager.focus();
|
||||
await windowManager.focus();
|
||||
}
|
||||
} else {
|
||||
_lastClick = now;
|
||||
@ -173,6 +174,7 @@ class _Systray extends TrayListener {
|
||||
}
|
||||
|
||||
Future<void> _updateContextMenu() async {
|
||||
final isVisible = await windowManager.isVisible();
|
||||
await trayManager.setContextMenu(
|
||||
Menu(
|
||||
items: [
|
||||
@ -207,11 +209,11 @@ class _Systray extends TrayListener {
|
||||
),
|
||||
MenuItem.separator(),
|
||||
MenuItem(
|
||||
label: _isHidden ? _l10n.s_show_window : _l10n.s_hide_window,
|
||||
label: !isVisible ? _l10n.s_show_window : _l10n.s_hide_window,
|
||||
onClick: (_) {
|
||||
_ref
|
||||
.read(desktopWindowStateProvider.notifier)
|
||||
.setWindowHidden(!_isHidden);
|
||||
.setWindowHidden(isVisible);
|
||||
},
|
||||
),
|
||||
MenuItem.separator(),
|
||||
|
Loading…
Reference in New Issue
Block a user