bool AXLibInitializeApplication(pid_t PID) { ax_application *Application = AXLibGetApplicationByPID(PID); if(Application) { bool Result = AXLibAddApplicationObserver(Application); if(Result) { AXLibAddApplicationWindows(Application); Application->Focus = AXLibGetFocusedWindow(Application); } else { AXLibRemoveApplicationObserver(Application); if(++Application->Retries < AX_APPLICATION_RETRIES) { #ifdef DEBUG_BUILD printf("AX: %s - Not responding, retry %d\n", Application->Name.c_str(), Application->Retries); #endif dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ if(AXLibInitializeApplication(PID)) { AXLibInitializedApplication(Application); } }); } else {
void AXLibRunningApplications() { std::map<pid_t, std::string> List = SharedWorkspaceRunningApplications(); std::map<pid_t, std::string>::iterator It; for(It = List.begin(); It != List.end(); ++It) { pid_t PID = It->first; if(!AXLibIsApplicationCached(PID)) { std::string Name = It->second; (*AXApplications)[PID] = AXLibConstructApplication(PID, Name); AXLibAddApplicationObserver(&(*AXApplications)[PID]); } AXLibAddApplicationWindows(&(*AXApplications)[PID]); } }