-
-
Notifications
You must be signed in to change notification settings - Fork 23.5k
Add pointer warping on wayland #112287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add pointer warping on wayland #112287
Conversation
|
It seems the commit hash in I just copied the pointer warp xml file from the main branch, should i include the one from 1.45 if its different? |
| if (!ss) { | ||
| return; | ||
| } | ||
|
|
||
| WindowState *ws = window_get_state(ss->pointer_data.pointed_id); | ||
|
|
||
| int wl_pos_x = 0; | ||
| int wl_pos_y = 0; | ||
|
|
||
| if (ws) { | ||
| // NOTE: It looks like it's not really recommended to convert from | ||
| // "godot-space" to "wayland-space" and in general I received mixed feelings | ||
| // discussing about this. I'm not really sure about the maths behind this but, | ||
| // oh well, we're setting a cursor hint. ¯\_(ツ)_/¯ | ||
| // See: https://oftc.irclog.whitequark.org/wayland/2023-08-23#1692756914-1692816818 | ||
| wl_pos_x = std::round(p_to.x / window_state_get_scale_factor(ws)); | ||
| wl_pos_y = std::round(p_to.y / window_state_get_scale_factor(ws)); | ||
| } | ||
|
|
||
| if (ss) { | ||
| seat_state_warp_pointer(ss, wl_pos_x, wl_pos_y); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied this code from pointer_set_hint, should there be a function to remove the duplicate scaling code?
What about the comment?
| // WaylandThread::PointerConstraint old_constraint = wayland_thread.pointer_get_constraint(); | ||
| wayland_thread.pointer_warp(p_to); | ||
| // wayland_thread.pointer_set_constraint(WaylandThread::PointerConstraint::LOCKED); | ||
| // wayland_thread.pointer_set_hint(p_to); | ||
|
|
||
| wayland_thread.pointer_set_constraint(WaylandThread::PointerConstraint::LOCKED); | ||
| wayland_thread.pointer_set_hint(p_to); | ||
|
|
||
| wayland_thread.pointer_set_constraint(old_constraint); | ||
| // wayland_thread.pointer_set_constraint(old_constraint); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this try to use the old logic in case the pointer-warp protocol isn't supported?
This old code didn't seem to work on kwin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, it was very wonky (and I think that I might've done something wrong actually, like, regarding surface commit timing or something) but it's better than nothing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How should i check if the pointer-warp protocol is available?
It seems the registry is a private field.
Yea, as wayland-protocols is at that version. If the protocol is not available there feel free to make a PR updating it.
Nah, it's done in only two places now and it's something that we should generally not do, as pointed out by the big comment.
Not sure tbh. I'll be fair, in these cases I just keep them there, duplicated. You never know if the other half will be there by the time you'll need to read that comment again :P |
fixes #64296
Note: I have no idea if how i did things is correct, this is my second time working with c++ and godot source.
I just tried to follow how things were done in the surrounding code.
Pointer warp protocol links:
Tested on latest kwin plasma 6.5, seems to work. I haven't tested multiple windows.
The project i tested it with is GodSVG.
Pointer warping in the editor viewport doesn't seem to work though.