ui/cocoa/MainWindow.m

changeset 1176
87a906a990e3
parent 1174
8b8da1adef7d
--- a/ui/cocoa/MainWindow.m	Sat Jun 06 18:08:51 2026 +0200
+++ b/ui/cocoa/MainWindow.m	Sat Jun 06 18:37:04 2026 +0200
@@ -43,8 +43,8 @@
 
 @implementation MainWindow
 
-- (MainWindow*)init:(UiObject*)obj withSidebar:(BOOL)hasSidebar withSplitview:(BOOL)hasSplitview{
-    NSRect frame = NSMakeRect(300, 200, 600, 500);
+- (MainWindow*)init:(UiObject*)obj withSidebar:(BOOL)hasSidebar withSplitview:(BOOL)hasSplitview width:(int)width height:(int)height {
+    NSRect frame = NSMakeRect(300, 200, width, height);
     
     self = [self initWithContentRect:frame
                            styleMask:NSWindowStyleMaskTitled |
@@ -143,6 +143,18 @@
     return self;
 }
 
+- (void) saveWindowSize {
+    CGSize size = self.frame.size;
+    if(size.width > 0 && size.height > 0) {
+        char width_str[32];
+        char height_str[32];
+        snprintf(width_str, 32, "%d", (int)size.width);
+        snprintf(height_str, 32, "%d", (int)size.height);
+        ui_set_property("ui.window.width", width_str);
+        ui_set_property("ui.window.height", height_str);
+    }
+}
+
 - (BOOL) getIsVisible {
     return [self isVisible];
 }
@@ -175,9 +187,9 @@
     }
     
     if(obj->ref == 0) {
+        [self saveWindowSize];
         // this cleans up any widget references from the context
         uic_context_prepare_close(obj->ctx);
-        
         [[WindowManager sharedWindowManager] closeWindow:self];
     }
 }

mercurial