[Wayland] Add support for pointer lock via relative-pointer and pointer-constraints
Categories
(Core :: Widget: Gtk, defect, P1)
Tracking
()
People
(Reporter: yoasif, Assigned: val)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
(deleted),
text/x-phabricator-request
|
Details |
Spawned from https://github.com/swaywm/sway/issues/4486
I have Firefox (Wayland) running on Sway 1.1.1, and I was trying to play https://marsfortherich.com
Whenever I enter the game, if I click, it "captures" the pointer and then it goes insane rotating all over the place. I believe this to be a bug in Sway.
I remember there was some protocol required for this to work, but I couldn't find an open issue on wlroots and decided to open this one to make sure I understood what was happening.
I can reproduce this issue in GNOME as well.
Comment 1•5 years ago
|
||
:yoasif, if you think that's a regression, then could you try to find a regression range in using for example mozregression?
Assignee | ||
Comment 3•5 years ago
|
||
GrabPointer is currently disabled on Wayland with the following comment:
// Don't to the grab on Wayland as it causes a regression
// from Bug 1377084.
(the good news is that there's no need to implement the protocols directly in Firefox, GTK handles them.)
Assignee | ||
Comment 4•5 years ago
|
||
Hm, actually, this might be something else. GTK code doesn't seem to use these protocols.
Assignee | ||
Comment 5•5 years ago
|
||
Oh, so on all platforms pointer lock currently works by warping the pointer to the center all the time. This behavior is baked directly into EventStateManager
unfortunately..
Reporter | ||
Updated•5 years ago
|
Updated•5 years ago
|
Comment 7•4 years ago
|
||
Martin, this doesn't look like a "popup" issue.
Updated•4 years ago
|
Assignee | ||
Comment 8•4 years ago
|
||
WIP:
- probably would be ideal to have a relative movement event type that would bypass all normal handling
and only directly go to the UIEvent thing with the position?? Not sure how to implement that, all the places
that handle event types.. - currently this just aligns the event with the center of the window,
which would be easy except the center in the DOM handler thing is the child's center,
in non-fullscreen mode it's offset by the chrome height. I can't find a way to specifically get
the chrome height in the parent nsWidget :( - also, need to unlock the pointer when the requesting child process crashes!
Updated•4 years ago
|
Comment 9•4 years ago
|
||
Thanks a lot for looking into this, Greg! I'll shortly check back if it's indeed not possible with GDK on Wayland and then try to have a look into this.
Comment 10•4 years ago
|
||
Ok you're right, some future version of GTK4 will maybe have support for this. So we indeed need to implement this ourselves here :)
Comment 11•4 years ago
|
||
Greg: this looks very good to me already! How does the testing go, apart from the center issue?
Assignee | ||
Comment 12•4 years ago
|
||
(In reply to Robert Mader [:rmader] from comment #11)
Greg: this looks very good to me already! How does the testing go, apart from the center issue?
Well, it works for me, idk what else to say. I'd like to hear answers to all three points above. (First one would bypass the center one..)
Updated•4 years ago
|
Comment 13•4 years ago
|
||
From Matrix chat with emilio:
if so, you probably want the center of the <browser> that requests the locking, not the center of the content area in particular
you should have that in BrowserParent::RecvLockNativePointer for example
there's GetChildProcessOffset there for example, and a variety of conversion methods from parent to child coordinates
Comment 14•4 years ago
|
||
Another idea that I haven't verified yet: could we maybe reuse the point coordinates from nsWindow::SynthesizeNativeMouseEvent()
? They may return coordinates relative to the window on Wayland.
Updated•4 years ago
|
Assignee | ||
Comment 15•4 years ago
|
||
(In reply to Robert Mader [:rmader] from comment #13)
From Matrix chat with emilio:
if so, you probably want the center of the <browser> that requests the locking, not the center of the content area in particular
you should have that in BrowserParent::RecvLockNativePointer for example
there's GetChildProcessOffset there for example, and a variety of conversion methods from parent to child coordinates
Thanks, turns out this is easy :)
So the patch is basically working now, the only remaining problem is that the pointer remains locked if the content process crashes (have to "alt-tab" to unlock).
Looking at the code, the only unlocking for that case currently is PointerLockManager::ReleaseLockedRemoteTarget(this)
in BrowserParent::Deactivated()
which just unsets a pointer. I guess that's enough for the "force mouse move" thing, but not enough for us, we need to run an actual unlock. Not sure how exactly to do this.
Comment 16•4 years ago
|
||
Can't you just call RecvUnlockNativePointer()
from Deactivated()
? (Maybe move the actual guts of that to a common function with a better name, but you get the idea)
Updated•4 years ago
|
Assignee | ||
Comment 17•4 years ago
|
||
Actually, yes, that works fine.
(And doing that has revealed that I forgot to nullptr the protocol object fields in nsWindow's constructor :D)
Assignee | ||
Updated•4 years ago
|
Comment 18•4 years ago
|
||
Comment 19•4 years ago
|
||
bugherder |
Comment 22•4 years ago
|
||
Awesome work, Thanks! We may consider to uplift it to 89 too.
Updated•4 years ago
|
Comment 23•4 years ago
|
||
I can verify it works as expected on latest nightly:
https://noclip.website/#smg/PeachCastleGardenGalaxy
https://codepen.io/timohausmann/pen/GRZBvRq
www.justbuild.lol
www.3daimtrainer.com
Comment 24•4 years ago
|
||
\o/ great, thanks a lot!
Comment 25•4 years ago
|
||
The patch landed in nightly and beta is affected.
:unrelentingtech, is this bug important enough to require an uplift?
If not please set status_beta
to wontfix
.
For more information, please visit auto_nag documentation.
Assignee | ||
Updated•4 years ago
|
Updated•4 years ago
|
Comment 26•4 years ago
|
||
Given the size of the patch, where we are in the beta cycle and the fact that it is an old issue, I think this should ride the 90 train, thanks.
Updated•3 years ago
|
Description
•