-
Notifications
You must be signed in to change notification settings - Fork 175
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
input: Split off input-handling and wayland-specific seat handling #689
Conversation
} | ||
|
||
fn serialize_pressed_keys(keys: Vec<u32>) -> Vec<u8> { | ||
let serialized = unsafe { ::std::slice::from_raw_parts(keys.as_ptr() as *const u8, keys.len() * 4) }; |
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.
Could this unsafe be eliminated?
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.
What are you suggesting? As far as I know, this is the recommended way to transmute a Vector.
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.
Except for the part that it does not compile because slice::from_raw_parts
produces a &[T]
, not a Vec<T>
😅
but I suppose this is fixed in a later commit
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.
We could use something like bytemuck and shift the blame elsewhere.
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.
We could use something like bytemuck and shift the blame elsewhere.
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.
We could use something like bytemuck and shift the blame elsewhere.
I mean in general... yes, but for this one case... really?
Codecov Report
@@ Coverage Diff @@
## master #689 +/- ##
==========================================
- Coverage 30.39% 29.98% -0.41%
==========================================
Files 94 97 +3
Lines 14919 15196 +277
==========================================
+ Hits 4535 4557 +22
- Misses 10384 10639 +255
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
320388c
to
7d0b31e
Compare
Ok, so as a first pass, high-level review (mostly from cloning the PR, running
In addition, the documentation of My suggestion would be to rename the (All the same applies to Other than this big thing, I quite like the overall shape of this PR. I'll take some time to get a little more nitpicky on the details. |
Co-authored-by: i509VCB <git@i509.me>
If handlers can by cloned and the reference shall still match a test with same_handler_as, they need to have interior mutability anyway and likely represent handles like the wl_surface. For that reason it makes no sense to require mutable access to send events.
7d0b31e
to
771edca
Compare
bb060bf
to
50dfc57
Compare
c05c3f2
to
71a2fff
Compare
71a2fff
to
66d004f
Compare
let focus = surface.and_then(|s| dh.get_client(s.id()).ok()); | ||
let focus2 = surface.and_then(|s| dh.get_client(s.id()).ok()); |
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.
This is a workaround for Client not being clone right?
Looks like it could be clonable:
#[derive(Debug)]
pub struct Client {
pub(crate) id: ClientId,
pub(crate) data: Arc<dyn ClientData>,
}
@vberger Is there a hidden reason behind this?
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.
I think @vberger already acknowledged, that Client
could and should be Clone
. This is mostly just a matter of somebody has to do that.
9806c31
to
34e162a
Compare
Continuation from #575
Ready for review and testing with smallvil and anvil.
This is the second attempt at decoupling a large portion of the
wayland/seat
module fromWlSurface
as the only object to receive any input events and in the progress making the seat-abstractions usable without thewayland_frontend
feature.Motivation
Currently all custom input-handling code has to be build from ground-up in downstream compositors. smithay either provides raw input events or converts those (almost automatically, except for focus handling) into appropriate wayland-events.
There is no middle ground, where some pre-processing can take place other components could benefit from. Especially implementing window-decorations on the server-side is tedious currently. Custom shells are a giant pain.
The plan with this is to allow custom elements to be attached to a
Window
or even aSpace
, that can handle input events or trigger grabs like any wayland client inside smithay.Drawbacks
Somemotion
-calls that set and explicitNone
focus, have to provide a*Handler
-type (e.g.WlSurface
to satisfy rustc type checks)..The*Handler
-traits have some clunckyas_any
,same_handler_as
andclone_handler
functions to work around issues of object-safety and dynamic dispatch withAny
,PartialEq
andClone
.Open Questions
input
module a good place to put this?Output
still lives incrate::wayland
, should we give it the same treatment (given that it is also used for rendering in desktop).backend::input
moved into here? (Those don't require any feature to be enabled right now and will always be available.)