mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
fix calcWindowPosition
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -115,7 +115,10 @@ void main() async {
|
||||
title: Constants.appName,
|
||||
);
|
||||
windowManager.waitUntilReadyToShow(windowOptions, () async {
|
||||
await windowManager.setBounds(await calcWindowPosition & Pref.windowSize);
|
||||
final windowSize = Pref.windowSize;
|
||||
await windowManager.setBounds(
|
||||
await calcWindowPosition(windowSize) & windowSize,
|
||||
);
|
||||
if (Pref.isWindowMaximized) await windowManager.maximize();
|
||||
await windowManager.show();
|
||||
await windowManager.focus();
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:screen_retriever/screen_retriever.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
Future<Offset> get calcWindowPosition async {
|
||||
Future<Offset> calcWindowPosition(Size windowSize) async {
|
||||
Display primaryDisplay = await screenRetriever.getPrimaryDisplay();
|
||||
List<Display> allDisplays = await screenRetriever.getAllDisplays();
|
||||
Offset cursorScreenPoint = await screenRetriever.getCursorScreenPoint();
|
||||
@@ -46,7 +45,6 @@ Future<Offset> get calcWindowPosition async {
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
final windowSize = await windowManager.getSize();
|
||||
return Offset(
|
||||
visibleStartX + (visibleWidth / 2) - (windowSize.width / 2),
|
||||
visibleStartY + ((visibleHeight / 2) - (windowSize.height / 2)),
|
||||
|
||||
Reference in New Issue
Block a user