mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 12:57:24 +00:00
fix window placement
This commit is contained in:
@@ -15,6 +15,10 @@ class WindowPlacement {
|
|||||||
Future<void> applyToWindow() async {
|
Future<void> applyToWindow() async {
|
||||||
await windowManager.setBounds(rect);
|
await windowManager.setBounds(rect);
|
||||||
|
|
||||||
|
if(!validate(rect)){
|
||||||
|
await windowManager.center();
|
||||||
|
}
|
||||||
|
|
||||||
if (isMaximized) {
|
if (isMaximized) {
|
||||||
await windowManager.maximize();
|
await windowManager.maximize();
|
||||||
}
|
}
|
||||||
@@ -55,10 +59,17 @@ class WindowPlacement {
|
|||||||
|
|
||||||
static void loop() async {
|
static void loop() async {
|
||||||
var placement = await WindowPlacement.current;
|
var placement = await WindowPlacement.current;
|
||||||
|
if(!validate(placement.rect)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (placement.rect != cache.rect ||
|
if (placement.rect != cache.rect ||
|
||||||
placement.isMaximized != cache.isMaximized) {
|
placement.isMaximized != cache.isMaximized) {
|
||||||
cache = placement;
|
cache = placement;
|
||||||
await placement.writeToFile();
|
await placement.writeToFile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool validate(Rect rect){
|
||||||
|
return rect.topLeft.dx >= 0 && rect.topLeft.dy >= 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user