I try to support the work of the program in MacOS. The program must move one specific window of another program (the program must have more than 1 window open) to the specified monitor and maximize it to full screen. For Windows and Linux, this is implemented using the native API, but for MacOS I did not find an API for changing windows of not my application. Could find a way to get the window ID, but not change its state
m_currentWindow->mac = 0; CGWindowListOption option = kCGWindowListOptionAll; CGWindowID id = 0; CFArrayRef windows = CGWindowListCreate(option, id); if(windows == nullptr) { qCCritical(actOp) << "windows is null"; return; } CFArrayRef desc = CGWindowListCreateDescriptionFromArray(windows); if(desc == nullptr) { qCCritical(actOp) << "windows description is null"; return; } CFIndex count = CFArrayGetCount(desc); qCDebug(actOp) << "finded " << count << " window"; QList<quint32> allWindows; for(CFIndex i=0; i<count; i++) { CFDictionaryRef dictionary = static_cast<CFDictionaryRef>(CFArrayGetValueAtIndex(desc, i)); quint32 id; CFNumberGetValue(static_cast<CFNumberRef>(CFDictionaryGetValue(dictionary, kCGWindowNumber)), kCFNumberSInt32Type, &id); allWindows << id; } CFRelease(desc); CFRelease(windows); do { QThread::currentThread()->msleep(100); windows = CGWindowListCreate(option, id); desc = CGWindowListCreateDescriptionFromArray(windows); count = CFArrayGetCount(desc); for(CFIndex i=0; i<count; i++) { CFDictionaryRef dictionary = static_cast<CFDictionaryRef>(CFArrayGetValueAtIndex(desc, i)); quint32 id; CFNumberGetValue(static_cast<CFNumberRef>(CFDictionaryGetValue(dictionary, kCGWindowNumber)), kCFNumberSInt32Type, &id); if(allWindows.contains(id)) continue; QString name = QString::fromCFString(static_cast<CFStringRef>( CFDictionaryGetValue(dictionary, kCGWindowOwnerName))); qCDebug(actOp) << static_cast<CFNumberRef>(CFDictionaryGetValue(dictionary, kCGWindowNumber)) << " " << static_cast<CFStringRef>(CFDictionaryGetValue(dictionary, kCGWindowOwnerName)); if(name.contains(m_browserTitle)) { m_currentWindow->mac = id; qCDebug(actOp) << "window is finded"; return; } else allWindows << id; } CFRelease(desc); CFRelease(windows); } while(m_currentWindow->mac == 0 && !timer.hasExpired(maxTime)); I tried to look in the direction of the QWindow, but could not find how to get the NSView for the QWindow :: fromWinId method, having only the CGWindowID of the desired window.
Tell me how you can implement a similar task.