I need to be able to force a child window to open on a specific external display. Example: main window resides on monitor 0, when child window is created, it opens on monitor 1 or 2.
I’m able to get the number of displays and their CGDirectDisplayID’s like this:
NSRect frame;
NSScreen *screen;
CGDirectDisplayID displays[4];
CGDisplayCount displayCount;
screen = [window frame]
frame = [screen frame];
err = CGGetDisplaysWithRect((CGRect){NSMinX(frame), NSMinY(frame), NSWidth(frame), NSHeight(frame)}, 4, displays, &displayCount);
but I’m not able to force a window there unless I manually drag it over after it’s been instantiated.
Any ideas? I’ve seen applications that do this, but can’t find any code examples or documentation.
You can set child window’s origin point. This code is not tested, but should work: