My application initially had a window (Def). Then it spawned a new window (New). All the two windows can be switched from the Window sub menu item or by the space control.
But if I tried to set the "New" window to a fake full screen mode on OSX 10.6.8, there would be a problem that if I switched to the "Def" window either by menu or space control. I cannot "fully" switch back to "New" window.
// setting a fake full screen window on 10.6.8
NSApplicationPresentationOptions prereqOptions =
NSApplicationPresentationAutoHideDock |
NSApplicationPresentationAutoHideMenuBar;
[[NSApplication sharedApplication]
setPresentationOptions:prereqOptions];
[[self window] setToolbar:nil];
[[self window] setStyleMask:NSBorderlessWindowMask];
[[self window] setFrame:[[NSScreen mainScreen] frame]
display:YES];
The "fully" means I can see the "New" is brought to the top of screen, but the window controller cannot receive the notification "NSWindowDidBecomeKeyNotification". Furthermore, by [NSApp keyWindow], I can see the key window is always the "Def". And I can always see the "Def" is checked in the Window submenu.
Anyone had ever encountered this issue?
Finally after 2 days investigation, the answer goes back to the documentation of NSWindow.
There are two related methods.
And
So the conclusion is that if the window doesn't have a title bar or resize bar, it by default cannot become a main and key window. When setting the window to the fake full screen on 10.6.8 by [NSWindow setStyleMask:NSBorderlessWindowMask], the title bar is gong.
To resolve this issue, one needs to override the above 2 methods with returning YES.