Change to other space (MacOSX) programmatically

后端 未结 2 727
名媛妹妹
名媛妹妹 2020-12-14 05:02

I am making a customised window (a NSWindow with NSBorderlessWindowMask) So far I have been able to handle dragging, resizing, cmd+click and even miniaturize with double cli

相关标签:
2条回答
  • 2020-12-14 05:03

    Finally I found a solution. I can't change to a certain space programmatically but I can make my window behave like other non NSBorderlessWindowMask if [window setMovableByWindowBackground:YES] is done. That was the final purpose of this question :)

    The solution is written (with some detail) here because that question seems to be older (or maybe a duplicate of this question?)

    Is there a way to make a custom NSWindow work with Spaces

    0 讨论(0)
  • 2020-12-14 05:24

    Unfortunately there's no public API which allows you to do this, but if you're willing to use the Private API it's possible. Take a look at CGSPrivate.h and you'll see you can make a call like this:

    CGSConnection connection = _CGSDefaultConnection();
    CGSMoveWorkspaceWindowList(connection, &windowNumber, 1, newSpaceNumber);   
    

    Note that using this private API will cause your app to be rejected from Apple's Mac App Store though.

    0 讨论(0)
提交回复
热议问题