sindresorhus / get-windows

Get metadata about the active window and open windows (title, id, bounds, owner, etc)
MIT License
783 stars 161 forks source link

Incorrect Y bounds with second monitor case #164

Closed 10n37 closed 1 year ago

10n37 commented 1 year ago

Environment

OS: MacOS Monterey 12.6.3 PC: Second full-hd 120hz monitor connected to MacBook air with 2k display via dock.

Problem

Window real bounds is: {x: 464, y: 317, width: 762, height: 763}

active-win bounds is: { y: 257, width: 762, height: 763, x: -1456 }

I can calc the X position:

const realX = display.size - Math.abs(bounds.x)

And i can calc Y position:

const magicNumber = 60

const realY = bounds.y + magicNumber

I always need to plus magic +60 number to get correct Y axis position. Always, in any window position.

How to fix it, or how to understand what this magic number 60 is?

sindresorhus commented 1 year ago

The window position is fetched directly from macOS, so there's nothing we can do about it. You'll have to report this to Apple.

https://github.com/sindresorhus/active-win/blob/27221e5da0a64025bdec8759605694ea84ff9f68/Sources/ActiveWinCLI/main.swift#L34

10n37 commented 1 year ago

I Found the missing piece display.bounds.y is 60

So i should include display bound in my calculations