NSWindow with NSWindowCollectionBehaviorStationary is visible on the Dashboard. Is this a bug?

CocoaNswindowSpacesApple Expose

Cocoa Problem Overview


I'm trying to get my NSWindow to:

  1. Be visible on all Spaces
  2. Be visible when showing the Desktop (by pressing F11)
  3. Not be visible in Mission Control/Expose

The following does exactly that, but with a side effect:

[self setCollectionBehavior: NSWindowCollectionBehaviorCanJoinAllSpaces
                            | NSWindowCollectionBehaviorStationary ];

When switching to the Dashboard on Mac OS X Lion, the window remains visible alone with Dashboard items for a second, then it is hidden.

Is this expected behavior or a bug? Users of my app find it confusing to see the window on the Dashboard before they disappear. I would have expected them to only show on Spaces and not the Dashboard.

Cocoa Solutions


Solution 1 - Cocoa

I looked at http://cocoadev.com/wiki/DontExposeMe searching for workaround

nothing really worked except.

self.window.level = kCGDesktopWindowLevel;

now maybe DETECT changes to expose and set that then :) ...

see https://stackoverflow.com/questions/9352939/how-can-one-detect-mission-control-or-command-tab-switcher-superseding-ones-pro for that :) maybe an answer will come up there

Solution 2 - Cocoa

I was able to reproduce this behaviour and I think it's just a bit of faulty animation on Apple's side.

Just so I can explain this better, create a new project, add these two lines to applicationDidFinishLaunching:, and run it.

[self.window setCollectionBehavior: NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorStationary ];
[self.window setHidesOnDeactivate: YES];

(self.window is the window that is created automatically when creating a new project. it doesn't really matter here anyway, just as long as it is a window that appears on the screen)

Now notice this behaviour: when changing from one space where you can see your window to another in which there are other windows from other apps (and so your window is supposed to disappear since your app will be deactivated), your window only disappears when the animation finishes. So, what is happening?

Here's what I think it happens: when switching from one space to another, windows that show on all spaces only react to the change after the animation, hence the brief appearence of your window on the dashboard. I think you'll notice it disappears exactly when the slide animation ends.

So, unfortunately, I don't know how to fix your problem. It just seems to happen this way.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMarkView Question on Stackoverflow
Solution 1 - CocoaDaij-DjanView Answer on Stackoverflow
Solution 2 - CocoaAlexView Answer on Stackoverflow