Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[auth] Potential fix for segfault on Linux due to bad window size

Neeraj Gupta05f86b895173
diff --git a/auth/lib/main.dart b/auth/lib/main.dart
index b88104c188..e837892f8c 100644
--- a/auth/lib/main.dart
+++ b/auth/lib/main.dart
@@ -71,6 +71,7 @@ void main() async {
await WindowListenerService.instance.init();
WindowOptions windowOptions = WindowOptions(
size: WindowListenerService.instance.getWindowSize(),
+ maximumSize: const Size(8192, 8192),
);
await windowManager.waitUntilReadyToShow(windowOptions, () async {
await DirectoryUtils.migrateNamingChanges();
diff --git a/auth/lib/services/window_listener_service.dart b/auth/lib/services/window_listener_service.dart
index 9ceefef9a3..261b56f457 100644
--- a/auth/lib/services/window_listener_service.dart
+++ b/auth/lib/services/window_listener_service.dart
@@ -5,6 +5,10 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'package:window_manager/window_manager.dart';
class WindowListenerService {
+ static const double minWindowHeight = 600.0;
+ static const double minWindowWidth = 800.0;
+ static const double maxWindowHeight = 8192.0;
+ static const double maxWindowWidth = 8192.0;
late SharedPreferences _preferences;
WindowListenerService._privateConstructor();
@@ -17,9 +21,14 @@ class WindowListenerService {
}
Size getWindowSize() {
- final double windowWidth = _preferences.getDouble('windowWidth') ?? 450.0;
- final double windowHeight = _preferences.getDouble('windowHeight') ?? 800.0;
- return Size(windowWidth, windowHeight);
+ final double windowWidth =
+ _preferences.getDouble('windowWidth') ?? minWindowWidth;
+ final double windowHeight =
+ _preferences.getDouble('windowHeight') ?? minWindowHeight;
+ return Size(
+ windowWidth.clamp(minWindowWidth, maxWindowWidth),
+ windowHeight.clamp(minWindowHeight, maxWindowHeight),
+ );
}
Future<void> onWindowResize() async {