Fuck with sizing a bit

This commit is contained in:
2025-04-21 16:32:20 +02:00
parent eba79e61ba
commit 61db6cf0c5

View File

@@ -19,7 +19,7 @@ void main() async {
// Use it only after calling `hiddenWindowAtLaunch`
WindowOptions windowOptions = const WindowOptions(
size: Size(800, 600),
size: Size(1600, 900), // Increased size to 1600x900
center: true,
backgroundColor: Colors.transparent,
skipTaskbar: false,
@@ -131,6 +131,8 @@ class _MainPageState extends State<MainPage> with WindowListener {
// Needs `implements WindowListener` and `windowManager.addListener(this);`
// and `windowManager.removeListener(this);` in dispose
windowManager.setPreventClose(true);
// Set aspect ratio after ensuring initialized
_setWindowConfig();
}
@override
@@ -222,8 +224,14 @@ class _MainPageState extends State<MainPage> with WindowListener {
Future<void> _showWindow() async {
bool isVisible = await windowManager.isVisible();
if (!isVisible) {
// Ensure size and position before showing
await windowManager.setSize(const Size(1600, 900)); // Set desired size
await windowManager.center(); // Center the window
await windowManager.show();
await windowManager.focus();
} else {
// If already visible, just bring to front and focus
await windowManager.focus();
}
}
@@ -279,6 +287,16 @@ class _MainPageState extends State<MainPage> with WindowListener {
// _currentEntryController.clear(); // Decide if you want to clear it immediately
}
// Helper to set initial window config like aspect ratio
Future<void> _setWindowConfig() async {
// Wait a moment to ensure window manager is fully ready after init
// Might not be strictly necessary but can prevent race conditions
// await Future.delayed(const Duration(milliseconds: 100));
await windowManager.setAspectRatio(16 / 9);
// Optionally set min/max size if desired
// await windowManager.setMinimumSize(const Size(800, 450));
}
// --- UI Build --- //
@override
Widget build(BuildContext context) {