Andrea Ippolito
Andrea Ippolito

Reputation: 113

Programmatically open NSWindow in another Desktop (Space)

In my OSX Project I want to:

Is there a way to do these simple tasks?

Exploring the documentation (NSWindowController, NSWindow, NSScreen) I can't find anything regarding multiple Desktop Management.

Thanks in advance!

Upvotes: 10

Views: 2175

Answers (1)

Mark Bessey
Mark Bessey

Reputation: 19782

You'd think there would be some API for working with Spaces, but there really isn't. You can use CGWindowListCopyWindowInfo to determine which Space a particular window is on, but there's no easy way to open a particular window on a specific space.

There is private API to move windows between spaces, of course. Whether you want to use this in your application depends on your needs - you couldn't use it on a Mac App Store application, obviously.

Found a copy-of-a-copy of the reverse-engineered header I was looking for: https://gist.github.com/rjw57/5495406

Upvotes: 8

Related Questions