MouseLock on Dual Monitor - Ubuntu

Usually, I run firefox on my laptop and leave the second monitor just for coding. I’ve been doing that for the past three weeks. However, I don’t know why, I decided to run firefox on my second monitor. This is what happened:

Mouselock dual monitor bug from diogogmt on Vimeo.

If I lock the mouse when firefox is on my second monitor, the cursor gets repositioned back to my first monitor, and when I try to leave the boundaries of the first monitor, it repositions the cursor back to the middle of the screen. That’s exactly how MouseLock should work. However, it should be doing it on the second monitor, where firefox is running, not on the first.

Brainstorming with Raymond (rhung) on #seneca, we found that the bug was only happening on Linux, since he wasn’t able to reproduce it on windows.
Looking further, we started inspecting the screenX/Y and clientX/Y coords for both monitors

On Linux:

On the first monitor:
>screenX: 641 screenY: 782
clientX: 641 clientY: 160

On the second:
>screenX: 2006 screenY: 524
clientX: 640 clientY: 158

It looks like the screenX/Y are not relative to the monitor size, but to the total size of the display. On the other hand, clientX/Y are relative to each specific monitor.

My guess is that when the mouse is being locked, it’s using the clientX/Y coords to set the screenX/Y coords. So instead of the cursor being reseted to the middle of the screen of the second monitor it’s being reseted to the middle of the screen of the first monitor, since screenX:641 and screenY:158 are in the boundaries of the first monitor