4

In my app, there is a utility window (actually it is a NSPanel object). It would show up sometime and be in front of other application's window.

But when other application runs in full-screen mode, the utility window doesn't show. But I found that when full-screen application ran, it would create new desktop.

(I guess the desktop here is the space people talk about in other questions.)

When I checked "Mission Control" in Launchpad, I saw the utility window was displayed in the original desktop, while the full-screen application was in the new desktop that the user currently saw.

I read the document and found some similar questions. It seems like I should set the collection behavior of window. So I tried this:

[self.window setCollectionBehavior:NSWindowCollectionBehaviorDefault | NSWindowCollectionBehaviorTransient | NSWindowCollectionBehaviorFullScreenAuxiliary];

It doesn't work.

How can I move my window to the current desktop / space that the full-screen application created?

jordanhill123
  • 4,142
  • 2
  • 31
  • 40
Gon
  • 1,135
  • 12
  • 22

1 Answers1

1

follow is my test code, it work ok, hope can help.

NSPanel *test_panel = [[NSPanel alloc] initWithContentRect:NSMakeRect(300, 300, 500, 500) styleMask:NSTitledWindowMask|NSClosableWindowMask backing:NSBackingStoreBuffered defer:YES];
        [test_panel setReleasedWhenClosed:YES];
        [test_panel setHidesOnDeactivate:NO];
        [test_panel setFloatingPanel:YES];
        [test_panel setStyleMask:NSClosableWindowMask|NSTitledWindowMask | NSNonactivatingPanelMask];
        [test_panel setLevel:kCGMainMenuWindowLevel-1];
        [test_panel setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces|NSWindowCollectionBehaviorFullScreenAuxiliary];
        [test_panel setCanBeVisibleOnAllSpaces:YES];
        [test_panel center];
        [test_panel orderFront:nil];
feell
  • 11
  • 1