Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 335
Mark Avatar asked Nov 27 '11 11:11

Mark


2 Answers

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 How can one detect Mission Control or Command-Tab switcher superseding one's program in OS X? for that :) maybe an answer will come up there

like image 160
Daij-Djan Avatar answered Oct 17 '22 07:10

Daij-Djan


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.

like image 39
Alex Avatar answered Oct 17 '22 08:10

Alex