Skip to content

How do I find the topmost window at a given point? #76

@stijlist

Description

@stijlist

How would I find the topmost window at a point?
Here's the code I have, but I'm not sure how to figure out which window is on top.

I don't see any references to z-index in the existing or planned API docs.

import Cocoa
import Swindler
import PromiseKit

let currentCursor = NSEvent.mouseLocation
print(currentCursor)
let _ = Swindler.initialize()
    .done { state -> Void in
        print(
            state.knownWindows.filter({
                window in
                guard window.isMinimized.value else { return false }
                return window.frame.value.contains(currentCursor)
            }))
        exit(0)
    }.catch { error in
        print(error)
    }
CFRunLoopRun()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions