Possible to have NSWindow *without* NSWindowStyleMaskTitled to make the screen its on the main screen?

I have a NSWindow subclass. The window has a custom shape, and thus has a custom contentView which overrides drawRect to draw .

Since the window has a custom shape it cannot use the system provided titlebar.

The problem I'm having is when there are multiple screens, if my window is on the inactive screen (not mainScreen with menu bar) and I move the mouse over to the second monitor and click the window....the menu bar doesn't travel to the screen my app is on after the window is clicked.

This does not happen with any other window. In all other windows, the menu bar moves to the screen once you click a window on that screen. So it appears this is because my window is not using NSWindowStyleMaskTitled. As far as I know, I can't use the system title bar and draw my custom window shape. Abandoning the custom window shape is not an option.

Without going into too many details as to why I care, the menu bar really should travel with first click on my window like other apps.. Is there a way to tell the system (other than using the NSWindowStyleMaskTitled) that clicking on my window should make that screen the "main screen" (bring the menu bar over?

I tried programmatically activating the application, ordering the window to the front, etc. but none of this works. This forces the user to click outside my app window, say on the desktop, to move the menu bar over, which feels wrong.

Thanks in advance if anyone has any suggestions.

Our engineering teams need to investigate this issue, as resolution may involve changes to Apple's software. I'd greatly appreciate it if you could open a bug report, include a small sample, directions we can use to reproduce the problem, and post the FB number here once you do.

Bug Reporting: How and Why? has tips on creating your bug report.

Thank you for replying. I was having a hard time reproducing the issue in a sample project. Upon further inspection I discovered that simply using a custom shape window without a title bar is not sufficient to reproduce the issue (and may not be related to it at all).

Specifying: Application is agent (UIElement) to YES in Project Settings -> Info is also required (so no dock icon) triggers this behavior.

The documentation (in the archive which I believe has not been superseded) states:

LSUIElement (Boolean - macOS) specifies whether the app runs as an agent app. If this key is set to YES, Launch Services runs the app as an agent app. Agent apps do not appear in the Dock or in the Force Quit window. Although they typically run as background apps, they can come to the foreground to present a user interface if desired. A click on a window belonging to an agent app brings that app forward to handle events.

When the application is agent (which mine is) and the window is on a screen NOT equal to mainScreen the menu bar doesn't move over with the click. BUT if the window has a title bar (which mine doesn't because it can't, as I need the custom shape) the menu bar does travel with the click but only if you click on the title bar (if you click anywhere else on the window the screen doesn't become mainScreen).

I filed FB15237355

Is there a workaround you could recommend? I tried overriding -sendEvent: in my window subclass and passing the events to the application but none of that has made the screen active.

I imagine I should be able to reroute the event when I receive it when self.screen != NSScreen.mainScreen to a code path that would trigger the screen I'm on to become the main screen

Possible to have NSWindow *without* NSWindowStyleMaskTitled to make the screen its on the main screen?
 
 
Q