app/internal/wm: use Option method to initialize windows

Added (*w.window).Option methods to the backends and use them for setting the initial options passed into NewWindow.

Signed-off-by: pierre <pierre.curto@gmail.com>
This commit is contained in:
pierre
2021-04-02 19:23:17 +02:00
committed by Elias Naur
parent b77c1628f3
commit ce7f0da06e
10 changed files with 207 additions and 110 deletions
+24 -1
View File
@@ -191,7 +191,9 @@ CFTypeRef gio_createWindow(CFTypeRef viewRef, const char *title, CGFloat width,
window.contentMaxSize = NSMakeSize(maxWidth, maxHeight);
}
[window setAcceptsMouseMovedEvents:YES];
window.title = [NSString stringWithUTF8String: title];
if (title != nil) {
window.title = [NSString stringWithUTF8String: title];
}
NSView *view = (__bridge NSView *)viewRef;
[window setContentView:view];
[window makeFirstResponder:view];
@@ -206,6 +208,27 @@ void gio_close(CFTypeRef windowRef) {
[window performClose:nil];
}
void gio_setSize(CFTypeRef windowRef, CGFloat width, CGFloat height) {
NSWindow* window = (__bridge NSWindow *)windowRef;
NSSize size = NSMakeSize(width, height);
[window setContentSize:size];
}
void gio_setMinSize(CFTypeRef windowRef, CGFloat width, CGFloat height) {
NSWindow* window = (__bridge NSWindow *)windowRef;
window.contentMinSize = NSMakeSize(width, height);
}
void gio_setMaxSize(CFTypeRef windowRef, CGFloat width, CGFloat height) {
NSWindow* window = (__bridge NSWindow *)windowRef;
window.contentMaxSize = NSMakeSize(width, height);
}
void gio_setTitle(CFTypeRef windowRef, const char *title) {
NSWindow* window = (__bridge NSWindow *)windowRef;
window.title = [NSString stringWithUTF8String: title];
}
@implementation GioAppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
[[NSRunningApplication currentApplication] activateWithOptions:(NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps)];