handle windows corner cases

This commit is contained in:
Adam Velebil 2023-03-07 10:28:22 +01:00
parent 20b7ccb733
commit 5f9f333336
No known key found for this signature in database
GPG Key ID: C9B1E4A3CBBD2E10

View File

@ -39,15 +39,18 @@ class WindowManagerHelperWindows {
return await _getAllDisplays() != allDisplays;
}
static bool displayContainsBounds(Display d, Rect rect) {
static bool _displayContainsBounds(Display d, Rect rect) {
final displayRect = Rect.fromLTWH(
d.visiblePosition?.dx ?? 0.0,
d.visiblePosition?.dy ?? 0.0,
d.visibleSize?.width ?? 0.0,
d.visibleSize?.height ?? 0.0);
return displayRect.contains(rect.topLeft) ||
displayRect.contains(rect.topRight);
// validate top bounds of the rectangle
// the translations limit amount of minimum vertical and horizontal distance
// which needs to be present to allow mouse interaction
return displayRect.contains(rect.topLeft.translate(48.0, 48.0)) ||
displayRect.contains(rect.topCenter.translate(0.0, 48.0));
}
static Future<void> setBounds(SharedPreferences prefs, Rect bounds) async {
@ -66,7 +69,7 @@ class WindowManagerHelperWindows {
final configChanged = await _displayConfigurationChanged(prefs);
final windowRect =
!configChanged || displayContainsBounds(primaryDisplay, savedBounds)
!configChanged || _displayContainsBounds(primaryDisplay, savedBounds)
? savedBounds
: WindowDefaults.bounds;