OK, as a digital dilettante I'm beginning to appreciate beefs with Wayland. I had hoped I'd never reach the point of having an opinion on this.
So, the pyautogui.position() function. What it should do is get me a nice tuple containing the x and y coordinates of the mouse pointer. Except it doesn't, not on Ubuntu 22.04!
When my python script is executed via command line (python3 ...), it will report back a seemingly-arbitrary position, over and over again, regardless of actual mouse position. If I run it from within IDLE, it will report cursor position while the pointer is within the IDLE gui, but nowhere else, defaulting to reporting the last mouse cursor position within the IDLE gui if the mouse exceeds those bounds.
I looked into the pyautogui library, and saw that it relied on an Xlib library. That does get the neurons firin', but not quite enough just yet. To try and get a better handle of what was going on a layer deeper, I copied the position() function and its necessary imports over to my script, bypassing pyautogui entirely. Still no dice, the same unintended behavior is replicated.
Well, now I'm desperate. I start looking on Google, and when no combination of search terms dredges up the slightest hint, I start to feel like I'm losing sanity. Then it finally wriggles into my awareness: Xlib. X11. What display server (is Wayland the display server, or is it something else? Apologies, dilettante!) is Ubuntu 22.04 using? Oh, Wayland by default.
One edit to gdm3/custom.conf later, I'm back to X11 and everything is working perfectly. I move my mouse cursor and the outputs of my test script adjust in accordance with my heretofore-lying eyes.