From b207c1d4a1cb4e92af4ff17d0145b1adee39fc6c Mon Sep 17 00:00:00 2001 From: Akemi Date: Sat, 26 Jan 2019 16:21:52 +0100 Subject: cocoa-cb: fix a Cocoa window position on init bug on init an NSWindow can't be placed on a none Main screen NSScreen outside the Main screen's frame bounds. To fix this we just check if the target screen is different from the main screen and if that is the case we check the actual position with the expect one. if they are different we try to reposition the window to the wanted position. Fixes #6453 --- video/out/cocoa-cb/window.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/video/out/cocoa-cb/window.swift b/video/out/cocoa-cb/window.swift index ae59f8bb6f..26308c5563 100644 --- a/video/out/cocoa-cb/window.swift +++ b/video/out/cocoa-cb/window.swift @@ -107,6 +107,19 @@ class Window: NSWindow, NSWindowDelegate { self.init(contentRect: contentRect, styleMask: [.titled, .closable, .miniaturizable, .resizable], backing: .buffered, defer: false, screen: screen) + + // workaround for an AppKit bug where the NSWindow can't be placed on a + // none Main screen NSScreen outside the Main screen's frame bounds + if screen != NSScreen.main() { + var absoluteWantedOrigin = contentRect.origin + absoluteWantedOrigin.x += screen!.frame.origin.x + absoluteWantedOrigin.y += screen!.frame.origin.y + + if !NSEqualPoints(absoluteWantedOrigin, self.frame.origin) { + self.setFrameOrigin(absoluteWantedOrigin) + } + } + cocoaCB = ccb title = cocoaCB.title minSize = NSMakeSize(160, 90) -- cgit v1.2.3