`y` for a secondary monitor has a different meaning in darwin vs other systems
I'm working with screeninfo + pyautogui. My code was working fine on Windows, but when I moved to MacOS, I noticed it would only work in my primary monitor (where y=0), not in other monitors. Pyautogui would move the cursor to the wrong coordinates.
The reason:
- In Windows (and probably Linux),
mon.yis the position of the top of the monitormonrelative to the top of the primary monitor. Above primary monitor is negative, below is positive*. - In MacOS,
mon.yis the position of the bottom of the monitormonrelative to the bottom of the primary monitor. Above primary monitor is positive, below is negative*.
* I think. I'm only submitting the issue today, but I encountered this issue months ago when I actually had an external monitor. My memory might be wrong, and I don't have another monitor anymore to confirm.
Pyautogui uses the Windows' meaning of y in all systems (afaik). I looked into pyautogui's code, but it doesn't seem to make any computations on y, it just passes it straight to the "internal" (Quartz) functions. It uses Quartz underneath though, and I didn't check what Quartz does.
I ended up solving my problem with:
xplatform_y = primary_mon.height - (mon.y + mon.height) if sys.platform == "darwin" else mon.y
Unsure which approach you'd rather take here. Add another field to Monitor for this y? Add a @property? Add some documentation explaining this distinction in semantics?