mhdhejazi / Dynamic

Call hidden/private API in style! The Swift way.

Home Page:https://medium.com/@mhdhejazi/calling-ios-and-macos-hidden-api-in-style-1a924f244ad1

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to check if the window is in full screen mode or not ?

TheDudeOne opened this issue · comments

I want to check whether the window is in full screen or not in mac Catalyst. How can I do that using dynamic?

Is this (#5) what you're asking for?

Hi @mhdhejazi
That approach while working great on Catalina no longer works in Big Sir.
I'll add the debugger output details

Some API has been changed on macOS 11. Check if this solution (#7 (comment)) makes things work again.

hostWindowForUIWindow() is a private API. So, there is no documentation for it.

Consider the following to detect full screen (on macCatalyst mode):

#if targetEnvironment(macCatalyst)
extension UIScreen {
static var isFullScreen: Bool {
let options = CGWindowListOption(arrayLiteral: CGWindowListOption.optionAll)
let cgWindowListInfo = CGWindowListCopyWindowInfo(options, CGWindowID(0))
let cgWindowListInfo2 = cgWindowListInfo as NSArray? as? [[String: AnyObject]]

    for windowDict in cgWindowListInfo2 ?? [] {
        let windowParams = "\(windowDict)"
        if windowParams.contains("Y = \"-") && windowParams.contains(", \"kCGWindowIsOnscreen\": 1")
        {
        //                print("windowDict: \(windowDict)")
        return true
        }
    }
    return false
}

}
#endif