tmandry / Swindler

macOS window management library for Swift
https://tmandry.github.io/Swindler/docs/main/
MIT License
690 stars 66 forks source link

Window frame return wrong value #90

Open huanghui1998hhh opened 2 years ago

huanghui1998hhh commented 2 years ago

image When my screens display like this, window frame will return wrong value.

Example: image My screens frame are (0.0, 0.0, 1920.0, 1080.0)and (-337.0, 1080.0, 2560.0, 1440.0), this window frame should return (0, 0, 920, 436), but it return (0.0, 1440.0, 920.0, 436.0) actually. 1440 seems like my top screen's height, i don't know if it matter.

Update: Through experiment, i found some rule, when MainScreen size smaller than SubScreen, window's frame will be return x higher than real value (x = SubScreen.height + SubScreen.minY - MainScreen.height). Hope this can help you.

huanghui1998hhh commented 2 years ago

image When my screens display like this, window frame will return wrong value.

Example: image My screens frame are (0.0, 0.0, 1920.0, 1080.0)and (-337.0, 1080.0, 2560.0, 1440.0), this window frame should return (0, 0, 920, 436), but it return (0.0, 1440.0, 920.0, 436.0) actually. 1440 seems like my top screen's height, i don't know if it matter.

Update: Through experiment, i found some rule, when MainScreen size smaller than SubScreen, window's frame will be return x higher than real value (x = SubScreen.height + SubScreen.minY - MainScreen.height). Hope this can help you.

I have found out the reason, in the step of converting coordinate, a wrong method was used. This wrong methed equivalent to the origin before conversion always in the upper left corner of all screens, but in fact, it use the main screen's upper left corner as the origin. So I've solved this wrong.