diff --git a/v2/internal/frontend/desktop/darwin/AppDelegate.h b/v2/internal/frontend/desktop/darwin/AppDelegate.h index 990c4e8a9..e2dd841c9 100644 --- a/v2/internal/frontend/desktop/darwin/AppDelegate.h +++ b/v2/internal/frontend/desktop/darwin/AppDelegate.h @@ -15,6 +15,7 @@ @property bool alwaysOnTop; @property bool startHidden; +@property bool startFullscreen; @property (retain) WailsWindow* mainWindow; @end diff --git a/v2/internal/frontend/desktop/darwin/AppDelegate.m b/v2/internal/frontend/desktop/darwin/AppDelegate.m index a605022fa..6d46deae4 100644 --- a/v2/internal/frontend/desktop/darwin/AppDelegate.m +++ b/v2/internal/frontend/desktop/darwin/AppDelegate.m @@ -26,6 +26,12 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { [NSApp activateIgnoringOtherApps:YES]; + if ( self.startFullscreen ) { + NSWindowCollectionBehavior behaviour = [self.mainWindow collectionBehavior]; + behaviour |= NSWindowCollectionBehaviorFullScreenPrimary; + [self.mainWindow setCollectionBehavior:behaviour]; + [self.mainWindow toggleFullScreen:nil]; + } } - (void)dealloc { diff --git a/v2/internal/frontend/desktop/darwin/Application.h b/v2/internal/frontend/desktop/darwin/Application.h index e42aab7bc..38e4cebc5 100644 --- a/v2/internal/frontend/desktop/darwin/Application.h +++ b/v2/internal/frontend/desktop/darwin/Application.h @@ -17,7 +17,7 @@ #define WindowStartsMinimised 2 #define WindowStartsFullscreen 3 -WailsContext* Create(const char* title, int width, int height, int frameless, int resizable, int fullscreen, int fullSizeContent, int hideTitleBar, int titlebarAppearsTransparent, int hideTitle, int useToolbar, int hideToolbarSeparator, int webviewIsTransparent, int alwaysOnTop, int hideWindowOnClose, const char *appearance, int windowIsTranslucent, int debug, int windowStartState, int startsHidden); +WailsContext* Create(const char* title, int width, int height, int frameless, int resizable, int fullscreen, int fullSizeContent, int hideTitleBar, int titlebarAppearsTransparent, int hideTitle, int useToolbar, int hideToolbarSeparator, int webviewIsTransparent, int alwaysOnTop, int hideWindowOnClose, const char *appearance, int windowIsTranslucent, int debug, int windowStartState, int startsHidden, int minWidth, int minHeight, int maxWidth, int maxHeight); void Run(void*); void SetTitle(void* ctx, const char *title); diff --git a/v2/internal/frontend/desktop/darwin/Application.m b/v2/internal/frontend/desktop/darwin/Application.m index f93a3e52c..de8a059d9 100644 --- a/v2/internal/frontend/desktop/darwin/Application.m +++ b/v2/internal/frontend/desktop/darwin/Application.m @@ -12,7 +12,7 @@ #import "WailsMenu.h" #import "WailsMenuItem.h" -WailsContext* Create(const char* title, int width, int height, int frameless, int resizable, int fullscreen, int fullSizeContent, int hideTitleBar, int titlebarAppearsTransparent, int hideTitle, int useToolbar, int hideToolbarSeparator, int webviewIsTransparent, int alwaysOnTop, int hideWindowOnClose, const char *appearance, int windowIsTranslucent, int debug, int windowStartState, int startsHidden) { +WailsContext* Create(const char* title, int width, int height, int frameless, int resizable, int fullscreen, int fullSizeContent, int hideTitleBar, int titlebarAppearsTransparent, int hideTitle, int useToolbar, int hideToolbarSeparator, int webviewIsTransparent, int alwaysOnTop, int hideWindowOnClose, const char *appearance, int windowIsTranslucent, int debug, int windowStartState, int startsHidden, int minWidth, int minHeight, int maxWidth, int maxHeight) { [NSApplication sharedApplication]; @@ -24,7 +24,7 @@ WailsContext* Create(const char* title, int width, int height, int frameless, in fullscreen = 1; } - [result CreateWindow:width :height :frameless :resizable :fullscreen :fullSizeContent :hideTitleBar :titlebarAppearsTransparent :hideTitle :useToolbar :hideToolbarSeparator :webviewIsTransparent :hideWindowOnClose :safeInit(appearance) :windowIsTranslucent]; + [result CreateWindow:width :height :frameless :resizable :fullscreen :fullSizeContent :hideTitleBar :titlebarAppearsTransparent :hideTitle :useToolbar :hideToolbarSeparator :webviewIsTransparent :hideWindowOnClose :safeInit(appearance) :windowIsTranslucent :minWidth :minHeight :maxWidth :maxHeight]; [result SetTitle:safeInit(title)]; [result Center]; @@ -41,6 +41,10 @@ WailsContext* Create(const char* title, int width, int height, int frameless, in result.startHidden = true; } + if ( fullscreen == 1 ) { + result.startFullscreen = true; + } + result.alwaysOnTop = alwaysOnTop; result.hideOnClose = hideWindowOnClose; @@ -324,6 +328,7 @@ void Run(void *inctx) { delegate.mainWindow = ctx.mainWindow; delegate.alwaysOnTop = ctx.alwaysOnTop; delegate.startHidden = ctx.startHidden; + delegate.startFullscreen = ctx.startFullscreen; [ctx loadRequest:@"wails://wails/"]; [app setMainMenu:ctx.applicationMenu]; diff --git a/v2/internal/frontend/desktop/darwin/WailsContext.h b/v2/internal/frontend/desktop/darwin/WailsContext.h index 364f1e378..f7ae2b72e 100644 --- a/v2/internal/frontend/desktop/darwin/WailsContext.h +++ b/v2/internal/frontend/desktop/darwin/WailsContext.h @@ -19,7 +19,13 @@ #define unicode(input) [NSString stringWithFormat:@"%C", input] @interface WailsWindow : NSWindow -- (BOOL)canBecomeKeyWindow; + +@property NSSize userMinSize; +@property NSSize userMaxSize; + +- (BOOL) canBecomeKeyWindow; +- (void) applyWindowConstraints; +- (void) disableWindowConstraints; @end @interface WailsContext : NSObject @@ -31,9 +37,7 @@ @property bool hideOnClose; @property bool shuttingDown; @property bool startHidden; - -@property NSSize maxSize; -@property NSSize minSize; +@property bool startFullscreen; @property (retain) NSEvent* mouseEvent; @@ -50,7 +54,7 @@ @property (retain) NSString* aboutTitle; @property (retain) NSString* aboutDescription; -- (void) CreateWindow:(int)width :(int)height :(bool)frameless :(bool)resizable :(bool)fullscreen :(bool)fullSizeContent :(bool)hideTitleBar :(bool)titlebarAppearsTransparent :(bool)hideTitle :(bool)useToolbar :(bool)hideToolbarSeparator :(bool)webviewIsTransparent :(bool)hideWindowOnClose :(NSString *)appearance :(bool)windowIsTranslucent; +- (void) CreateWindow:(int)width :(int)height :(bool)frameless :(bool)resizable :(bool)fullscreen :(bool)fullSizeContent :(bool)hideTitleBar :(bool)titlebarAppearsTransparent :(bool)hideTitle :(bool)useToolbar :(bool)hideToolbarSeparator :(bool)webviewIsTransparent :(bool)hideWindowOnClose :(NSString *)appearance :(bool)windowIsTranslucent :(int)minWidth :(int)minHeight :(int)maxWidth :(int)maxHeight; - (void) SetSize:(int)width :(int)height; - (void) SetPosition:(int)x :(int) y; - (void) SetMinSize:(int)minWidth :(int)minHeight; diff --git a/v2/internal/frontend/desktop/darwin/WailsContext.m b/v2/internal/frontend/desktop/darwin/WailsContext.m index 31dbaebbe..a42896123 100644 --- a/v2/internal/frontend/desktop/darwin/WailsContext.m +++ b/v2/internal/frontend/desktop/darwin/WailsContext.m @@ -21,6 +21,16 @@ return YES; } +- (void) applyWindowConstraints { + [self setMinSize:self.userMinSize]; + [self setMaxSize:self.userMaxSize]; +} + +- (void) disableWindowConstraints { + [self setMinSize:NSMakeSize(0, 0)]; + [self setMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)]; +} + @end @implementation WailsContext @@ -33,7 +43,7 @@ frame.origin.y += frame.size.height - height; frame.size.width = width; frame.size.height = height; - ON_MAIN_THREAD([self.mainWindow setFrame:frame display:TRUE animate:FALSE];); + [self.mainWindow setFrame:frame display:TRUE animate:FALSE]; } - (void) SetPosition:(int)x :(int)y { @@ -45,8 +55,8 @@ NSRect screenFrame = [screen frame]; windowFrame.origin.x = screenFrame.origin.x + (float)x; windowFrame.origin.y = (screenFrame.origin.y + screenFrame.size.height) - windowFrame.size.height - (float)y; - - ON_MAIN_THREAD([self.mainWindow setFrame:windowFrame display:TRUE animate:FALSE]; ); + + [self.mainWindow setFrame:windowFrame display:TRUE animate:FALSE]; } - (void) SetMinSize:(int)minWidth :(int)minHeight { @@ -54,13 +64,9 @@ if (self.shuttingDown) return; NSSize size = { minWidth, minHeight }; - - self.minSize = size; - - ON_MAIN_THREAD( - [self.mainWindow setMinSize:size]; - [self adjustWindowSize]; - ); + self.mainWindow.userMinSize = size; + [self.mainWindow setMinSize:size]; + [self adjustWindowSize]; } @@ -73,12 +79,9 @@ size.width = maxWidth > 0 ? maxWidth : FLT_MAX; size.height = maxHeight > 0 ? maxHeight : FLT_MAX; - self.maxSize = size; - - ON_MAIN_THREAD( - [self.mainWindow setMaxSize:size]; - [self adjustWindowSize]; - ); + self.mainWindow.userMaxSize = size; + [self.mainWindow setMaxSize:size]; + [self adjustWindowSize]; } @@ -88,10 +91,10 @@ NSRect currentFrame = [self.mainWindow frame]; - if ( currentFrame.size.width > self.maxSize.width ) currentFrame.size.width = self.maxSize.width; - if ( currentFrame.size.width < self.minSize.width ) currentFrame.size.width = self.minSize.width; - if ( currentFrame.size.height > self.maxSize.height ) currentFrame.size.height = self.maxSize.height; - if ( currentFrame.size.height < self.minSize.height ) currentFrame.size.height = self.minSize.height; + if ( currentFrame.size.width > self.mainWindow.userMaxSize.width ) currentFrame.size.width = self.mainWindow.userMaxSize.width; + if ( currentFrame.size.width < self.mainWindow.userMinSize.width ) currentFrame.size.width = self.mainWindow.userMinSize.width; + if ( currentFrame.size.height > self.mainWindow.userMaxSize.height ) currentFrame.size.height = self.mainWindow.userMaxSize.height; + if ( currentFrame.size.height < self.mainWindow.userMinSize.height ) currentFrame.size.height = self.mainWindow.userMinSize.height; [self.mainWindow setFrame:currentFrame display:YES animate:FALSE]; @@ -116,11 +119,11 @@ } - (void) SetTitle:(NSString*)title { - ON_MAIN_THREAD([self.mainWindow setTitle:title];) + [self.mainWindow setTitle:title]; } - (void) Center { - ON_MAIN_THREAD( [self.mainWindow center]; ); + [self.mainWindow center]; } - (BOOL) isFullscreen { @@ -131,37 +134,29 @@ return NO; } -- (void) CreateWindow:(int)width :(int)height :(bool)frameless :(bool)resizable :(bool)fullscreen :(bool)fullSizeContent :(bool)hideTitleBar :(bool)titlebarAppearsTransparent :(bool)hideTitle :(bool)useToolbar :(bool)hideToolbarSeparator :(bool)webviewIsTransparent :(bool)hideWindowOnClose :(NSString*)appearance :(bool)windowIsTranslucent { +- (void) CreateWindow:(int)width :(int)height :(bool)frameless :(bool)resizable :(bool)fullscreen :(bool)fullSizeContent :(bool)hideTitleBar :(bool)titlebarAppearsTransparent :(bool)hideTitle :(bool)useToolbar :(bool)hideToolbarSeparator :(bool)webviewIsTransparent :(bool)hideWindowOnClose :(NSString*)appearance :(bool)windowIsTranslucent :(int)minWidth :(int)minHeight :(int)maxWidth :(int)maxHeight { self.urlRequests = [NSMutableDictionary new]; - NSWindowStyleMask styleMask = NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable; + NSWindowStyleMask styleMask = 0; - if (frameless) { - styleMask = NSWindowStyleMaskBorderless; - titlebarAppearsTransparent = true; - hideTitle = true; - } else { + if( !frameless ) { if (!hideTitleBar) { styleMask |= NSWindowStyleMaskTitled; } - - if (fullscreen) { - styleMask |= NSWindowStyleMaskFullScreen; - } - - if( fullSizeContent || frameless || titlebarAppearsTransparent ) { - styleMask |= NSWindowStyleMaskFullSizeContentView; - } + styleMask |= NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable; } - + + if( fullSizeContent || frameless || titlebarAppearsTransparent ) { + styleMask |= NSWindowStyleMaskFullSizeContentView; + } + if (resizable) { styleMask |= NSWindowStyleMaskResizable; } - self.mainWindow = [[[WailsWindow alloc] initWithContentRect:NSMakeRect(0, 0, width, height) - styleMask:styleMask backing:NSBackingStoreBuffered defer:NO] - autorelease]; + self.mainWindow = [[WailsWindow alloc] initWithContentRect:NSMakeRect(0, 0, width, height) + styleMask:styleMask backing:NSBackingStoreBuffered defer:NO]; if (!frameless && useToolbar) { id toolbar = [[NSToolbar alloc] initWithIdentifier:@"wails.toolbar"]; @@ -192,15 +187,25 @@ [self.mainWindow setAppearance:nsAppearance]; } - // Set up min/max - NSSize maxSize = { FLT_MAX, FLT_MAX }; - self.maxSize = maxSize; - NSSize minSize = { 0, 0 }; - self.minSize = minSize; - [self adjustWindowSize]; + + NSSize minSize = { minWidth, minHeight }; + NSSize maxSize = { maxWidth, maxHeight }; + if (maxSize.width == 0) { + maxSize.width = FLT_MAX; + } + if (maxSize.height == 0) { + maxSize.height = FLT_MAX; + } + self.mainWindow.userMaxSize = maxSize; + self.mainWindow.userMinSize = minSize; + + if( !fullscreen ) { + [self.mainWindow applyWindowConstraints]; + } WindowDelegate *windowDelegate = [WindowDelegate new]; windowDelegate.hideOnClose = hideWindowOnClose; + windowDelegate.ctx = self; [self.mainWindow setDelegate:windowDelegate]; // Webview stuff here! @@ -301,7 +306,7 @@ id colour = [NSColor colorWithCalibratedRed:red green:green blue:blue alpha:alpha ]; - ON_MAIN_THREAD([self.mainWindow setBackgroundColor:colour];); + [self.mainWindow setBackgroundColor:colour]; } - (void) HideMouse { @@ -325,52 +330,50 @@ // Fullscreen sets the main window to be fullscreen - (void) Fullscreen { if( ! [self isFullScreen] ) { - ON_MAIN_THREAD([self.mainWindow toggleFullScreen:nil];) + [self.mainWindow disableWindowConstraints]; + [self.mainWindow toggleFullScreen:nil]; } } // UnFullscreen resets the main window after a fullscreen - (void) UnFullscreen { if( [self isFullScreen] ) { - ON_MAIN_THREAD([self.mainWindow toggleFullScreen:nil];) + [self.mainWindow applyWindowConstraints]; + [self.mainWindow toggleFullScreen:nil]; } } - (void) Minimise { - ON_MAIN_THREAD([self.mainWindow miniaturize:nil];) + [self.mainWindow miniaturize:nil]; } - (void) UnMinimise { - ON_MAIN_THREAD([self.mainWindow deminiaturize:nil];) + [self.mainWindow deminiaturize:nil]; } - (void) Hide { - ON_MAIN_THREAD([self.mainWindow orderOut:nil];) + [self.mainWindow orderOut:nil]; } - (void) Show { - ON_MAIN_THREAD( - [self.mainWindow makeKeyAndOrderFront:nil]; - [NSApp activateIgnoringOtherApps:YES]; - ) + [self.mainWindow makeKeyAndOrderFront:nil]; + [NSApp activateIgnoringOtherApps:YES]; } - (void) Maximise { if (![self.mainWindow isZoomed]) { - ON_MAIN_THREAD([self.mainWindow zoom:nil];) + [self.mainWindow zoom:nil]; } } - (void) UnMaximise { if ([self.mainWindow isZoomed]) { - ON_MAIN_THREAD([self.mainWindow zoom:nil];) + [self.mainWindow zoom:nil]; } } - (void) ExecJS:(NSString*)script { - ON_MAIN_THREAD( - [self.webview evaluateJavaScript:script completionHandler:nil]; - ) + [self.webview evaluateJavaScript:script completionHandler:nil]; } - (void) processURLResponse:(NSString *)url :(NSString *)contentType :(NSData *)data { @@ -406,15 +409,13 @@ // Check for drag if ( [m isEqualToString:@"drag"] ) { - if( ! [self isFullScreen] ) { - if( self.mouseEvent != nil ) { - [self HideMouse]; - ON_MAIN_THREAD( - [self.mainWindow performWindowDragWithEvent:self.mouseEvent]; - ); - } + if( [self isFullScreen] ) { return; } + if( self.mouseEvent != nil ) { + [self.mainWindow performWindowDragWithEvent:self.mouseEvent]; + } + return; } const char *_m = [m UTF8String]; @@ -455,28 +456,26 @@ NSData *imageData = [NSData dataWithBytes:iconData length:iconDataLength]; icon = [[NSImage alloc] initWithData:imageData]; } - ON_MAIN_THREAD( - if( icon != nil) { - [alert setIcon:icon]; - } - [alert.window setLevel:NSFloatingWindowLevel]; + if( icon != nil) { + [alert setIcon:icon]; + } + [alert.window setLevel:NSFloatingWindowLevel]; - long response = [alert runModal]; - int result; - - if( response == NSAlertFirstButtonReturn ) { - result = 0; - } - else if( response == NSAlertSecondButtonReturn ) { - result = 1; - } - else if( response == NSAlertThirdButtonReturn ) { - result = 2; - } else { - result = 3; - } - processMessageDialogResponse(result); - ) + long response = [alert runModal]; + int result; + + if( response == NSAlertFirstButtonReturn ) { + result = 0; + } + else if( response == NSAlertSecondButtonReturn ) { + result = 1; + } + else if( response == NSAlertThirdButtonReturn ) { + result = 2; + } else { + result = 3; + } + processMessageDialogResponse(result); } -(void) OpenFileDialog :(NSString*)title :(NSString*)defaultFilename :(NSString*)defaultDirectory :(bool)allowDirectories :(bool)allowFiles :(bool)canCreateDirectories :(bool)treatPackagesAsDirectories :(bool)resolveAliases :(bool)showHiddenFiles :(bool)allowMultipleSelection :(NSString*)filters { @@ -622,8 +621,7 @@ [alert setIcon:self.aboutImage]; } - ON_MAIN_THREAD([alert runModal];) - + [alert runModal]; } @end diff --git a/v2/internal/frontend/desktop/darwin/WindowDelegate.h b/v2/internal/frontend/desktop/darwin/WindowDelegate.h index e4ba038d1..6f83e0e48 100644 --- a/v2/internal/frontend/desktop/darwin/WindowDelegate.h +++ b/v2/internal/frontend/desktop/darwin/WindowDelegate.h @@ -8,10 +8,17 @@ #ifndef WindowDelegate_h #define WindowDelegate_h +#import "WailsContext.h" + @interface WindowDelegate : NSObject @property bool hideOnClose; +@property (assign) WailsContext* ctx; + +- (void)windowDidExitFullScreen:(NSNotification *)notification; + + @end diff --git a/v2/internal/frontend/desktop/darwin/WindowDelegate.m b/v2/internal/frontend/desktop/darwin/WindowDelegate.m index 60cff434a..aca68688f 100644 --- a/v2/internal/frontend/desktop/darwin/WindowDelegate.m +++ b/v2/internal/frontend/desktop/darwin/WindowDelegate.m @@ -21,4 +21,18 @@ return !self.hideOnClose; } + +- (void)windowDidExitFullScreen:(NSNotification *)notification { + [self.ctx.mainWindow applyWindowConstraints]; +} + +- (void)windowWillEnterFullScreen:(NSNotification *)notification { + [self.ctx.mainWindow disableWindowConstraints]; +} + +- (NSApplicationPresentationOptions)window:(WailsWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions { + return NSApplicationPresentationAutoHideToolbar | NSApplicationPresentationAutoHideMenuBar | NSApplicationPresentationFullScreen; +} + + @end diff --git a/v2/internal/frontend/desktop/darwin/frontend.go b/v2/internal/frontend/desktop/darwin/frontend.go index 4f7403b9f..c9c38e2eb 100644 --- a/v2/internal/frontend/desktop/darwin/frontend.go +++ b/v2/internal/frontend/desktop/darwin/frontend.go @@ -51,11 +51,10 @@ type Frontend struct { assets *assetserver.DesktopAssetServer // main window handle - mainWindow *Window - minWidth, minHeight, maxWidth, maxHeight int - bindings *binding.Bindings - dispatcher frontend.Dispatcher - servingFromDisk bool + mainWindow *Window + bindings *binding.Bindings + dispatcher frontend.Dispatcher + servingFromDisk bool } func NewFrontend(ctx context.Context, appoptions *options.App, myLogger *logger.Logger, appBindings *binding.Bindings, dispatcher frontend.Dispatcher) *Frontend { @@ -163,15 +162,11 @@ func (f *Frontend) WindowSetTitle(title string) { } func (f *Frontend) WindowFullscreen() { - f.mainWindow.SetMaxSize(0, 0) - f.mainWindow.SetMinSize(0, 0) f.mainWindow.Fullscreen() } func (f *Frontend) WindowUnFullscreen() { f.mainWindow.UnFullscreen() - f.mainWindow.SetMaxSize(f.maxWidth, f.maxHeight) - f.mainWindow.SetMinSize(f.minWidth, f.minHeight) } func (f *Frontend) WindowShow() { @@ -195,13 +190,9 @@ func (f *Frontend) WindowUnminimise() { } func (f *Frontend) WindowSetMinSize(width int, height int) { - f.minWidth = width - f.minHeight = height f.mainWindow.SetMinSize(width, height) } func (f *Frontend) WindowSetMaxSize(width int, height int) { - f.maxWidth = width - f.maxHeight = height f.mainWindow.SetMaxSize(width, height) } @@ -243,6 +234,11 @@ func (f *Frontend) processMessage(message string) { return } + //if strings.HasPrefix(message, "systemevent:") { + // f.processSystemEvent(message) + // return + //} + result, err := f.dispatcher.ProcessMessage(message, f) if err != nil { f.logger.Error(err.Error()) @@ -292,6 +288,22 @@ func (f *Frontend) processRequest(r *request) { C.ProcessURLResponse(r.ctx, r.url, mimetype, data, C.int(len(_contents))) } +//func (f *Frontend) processSystemEvent(message string) { +// sl := strings.Split(message, ":") +// if len(sl) != 2 { +// f.logger.Error("Invalid system message: %s", message) +// return +// } +// switch sl[1] { +// case "fullscreen": +// f.mainWindow.DisableSizeConstraints() +// case "unfullscreen": +// f.mainWindow.EnableSizeConstraints() +// default: +// f.logger.Error("Unknown system message: %s", message) +// } +//} + //export processMessage func processMessage(message *C.char) { goMessage := C.GoString(message) diff --git a/v2/internal/frontend/desktop/darwin/main.m b/v2/internal/frontend/desktop/darwin/main.m index a7200f6f7..2f911367a 100644 --- a/v2/internal/frontend/desktop/darwin/main.m +++ b/v2/internal/frontend/desktop/darwin/main.m @@ -200,9 +200,9 @@ unsigned int _Users_username_Pictures_SaltBae_png_len = 1863; int main(int argc, const char * argv[]) { // insert code here... - int frameless = 1; - int resizable = 0; - int fullscreen = 0; + int frameless = 0; + int resizable = 1; + int fullscreen = 1; int fullSizeContent = 1; int hideTitleBar = 0; int titlebarAppearsTransparent = 0; @@ -215,7 +215,10 @@ int main(int argc, const char * argv[]) { const char* appearance = "NSAppearanceNameDarkAqua"; int windowIsTranslucent = 1; int debug = 1; - WailsContext *result = Create("OI OI!",400,400, frameless, resizable, fullscreen, fullSizeContent, hideTitleBar, titlebarAppearsTransparent, hideTitle, useToolbar, hideToolbarSeparator, webviewIsTransparent, alwaysOnTop, hideWindowOnClose, appearance, windowIsTranslucent, debug); + int windowStartState = 0; + int startsHidden = 0; + WailsContext *result = Create("OI OI!",400,400, frameless, resizable, fullscreen, fullSizeContent, hideTitleBar, titlebarAppearsTransparent, hideTitle, useToolbar, hideToolbarSeparator, webviewIsTransparent, alwaysOnTop, hideWindowOnClose, appearance, windowIsTranslucent, debug, windowStartState, + startsHidden, 400, 400, 600, 600); SetRGBA(result, 255, 0, 0, 255); void *m = NewMenu(""); SetAbout(result, "Fake title", "I am a description", _Users_username_Pictures_SaltBae_png, _Users_username_Pictures_SaltBae_png_len); @@ -228,7 +231,7 @@ int main(int argc, const char * argv[]) { AppendSubmenu(m, submenu); UpdateMenuItem(menuITem, 1); SetAsApplicationMenu(result, m); - SetPosition(result, 100, 100); +// SetPosition(result, 100, 100); diff --git a/v2/internal/frontend/desktop/darwin/window.go b/v2/internal/frontend/desktop/darwin/window.go index 599eec067..ec18e3f3c 100644 --- a/v2/internal/frontend/desktop/darwin/window.go +++ b/v2/internal/frontend/desktop/darwin/window.go @@ -59,6 +59,10 @@ func NewWindow(frontendOptions *options.App, debugMode bool) *Window { width := C.int(frontendOptions.Width) height := C.int(frontendOptions.Height) + minWidth := C.int(frontendOptions.MinWidth) + minHeight := C.int(frontendOptions.MinHeight) + maxWidth := C.int(frontendOptions.MaxWidth) + maxHeight := C.int(frontendOptions.MaxHeight) windowStartState := C.int(int(frontendOptions.WindowStartState)) title = c.String(frontendOptions.Title) @@ -80,7 +84,8 @@ func NewWindow(frontendOptions *options.App, debugMode bool) *Window { } var context *C.WailsContext = C.Create(title, width, height, frameless, resizable, fullscreen, fullSizeContent, hideTitleBar, titlebarAppearsTransparent, hideTitle, useToolbar, hideToolbarSeparator, webviewIsTransparent, - alwaysOnTop, hideWindowOnClose, appearance, windowIsTranslucent, debug, windowStartState, startsHidden) + alwaysOnTop, hideWindowOnClose, appearance, windowIsTranslucent, debug, windowStartState, startsHidden, + minWidth, minHeight, maxWidth, maxHeight) // Create menu result := &Window{ @@ -107,9 +112,6 @@ func NewWindow(frontendOptions *options.App, debugMode bool) *Window { result.SetApplicationMenu(frontendOptions.Menu) } - result.SetMinSize(frontendOptions.MinWidth, frontendOptions.MinHeight) - result.SetMaxSize(frontendOptions.MaxWidth, frontendOptions.MaxHeight) - return result } @@ -166,16 +168,10 @@ func (w *Window) UnMinimise() { } func (w *Window) SetMinSize(width int, height int) { - if width == 0 && height == 0 { - return - } C.SetMinSize(w.context, C.int(width), C.int(height)) } func (w *Window) SetMaxSize(width int, height int) { - if width == 0 && height == 0 { - return - } C.SetMaxSize(w.context, C.int(width), C.int(height)) }