Cocoa API accessibility and space?

I ran into a problem for the application I am writing ( http://code.google.com/p/blazingstars/issues/detail?id=25 ), where my program is a menu (bar menu) that uses the Accessibility API for interaction with another program and its management. I do the usual things, such as registering for API notifications and getting a list of windows through API calls, etc., but I realized that if my program starts in the second Space (virtual desktop) after the program interacts with the launch in First, my program will fail and burn out because it cannot access any information about its purpose. (Is there a way to solve this problem I'm missing?)

A simple solution would be a popup asking you to reload the program in the correct Space, but for life I can’t figure out how to determine which space my target is in, either through NSWorkspace or the Accessibility API so that I can compare it with the space in which I am. Any ideas?

Note that setting the collection behavior to NSWindowCollectionBehaviorCanJoinAllSpaces will not do me any good, because I have to do a lot of work at startup, so from the very beginning I should be in the same space as my target.

+3
source share
2 answers

, API- CGWindow.h..
, . CGWindowListCopyWindowInfo() kCGWindowWorkspace.

API , , ..

, API:

 extern CGSError CGSGetWindowWorkspace(const CGSConnectionID cid,
                                       CGSWindowID wid,
                                       CGSWorkspaceID *workspace);

.

+4

, , , , , .

Leopard , , .

0

Source: https://habr.com/ru/post/1728993/


All Articles