app/internal/window: [macOS] introduce serious cascading

This time without arbitrary offsets and with support for multiple
windows.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-06-06 19:27:25 +02:00
parent 4408c2a695
commit 144a5a9cf5
2 changed files with 14 additions and 3 deletions
+8 -1
View File
@@ -110,7 +110,7 @@ void gio_setDisplayLinkDisplay(CFTypeRef dl, uint64_t did) {
CVDisplayLinkSetCurrentCGDisplay((CVDisplayLinkRef)dl, (CGDirectDisplayID)did);
}
void gio_createWindow(CFTypeRef viewRef, const char *title, CGFloat width, CGFloat height) {
NSPoint gio_createWindow(CFTypeRef viewRef, const char *title, CGFloat width, CGFloat height, NSPoint topLeft) {
@autoreleasepool {
NSRect rect = NSMakeRect(0, 0, width, height);
NSUInteger styleMask = NSTitledWindowMask |
@@ -127,9 +127,16 @@ void gio_createWindow(CFTypeRef viewRef, const char *title, CGFloat width, CGFlo
NSView *view = (__bridge NSView *)viewRef;
[window setContentView:view];
[window makeFirstResponder:view];
if (topLeft.x == 0 && topLeft.y == 0) {
// cascadeTopLeftFromPoint treats (0, 0) as a no-op,
// and just returns the offset we need for the first window.
topLeft = [window cascadeTopLeftFromPoint:topLeft];
}
topLeft = [window cascadeTopLeftFromPoint:topLeft];
window.releasedWhenClosed = NO;
window.delegate = globalWindowDel;
[window makeKeyAndOrderFront:nil];
return topLeft;
}
}