Skip to content
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

wayland: add wlr-data-control protocol #1151

Merged
merged 1 commit into from
Oct 2, 2023

Conversation

kchibisov
Copy link
Member

@kchibisov kchibisov commented Sep 30, 2023

wlr_data_control is a protocol used to implement clipboard managers or
access clipboard without creating a window. The implementation of it
ties to regular selections, thus the selection handling was unified
to reduce the maintainance burden.

The present selection modules, like walyand/primary_selection and
wayland/data_device moved into the new wayland/selection module.
Keeping their original implementation, where it was possible.

The new selection module uses the common structure of seat_data,
device, source, and mod.rs used in the said above modules, however
it uses the hand-rolled dynamic dispatch with the selection_dispatch!
macro. The offers and selection replies are all handled together,
so the code is unique in the most cases.

As a side effect of the selection update and merging the handling of
the primary and clipboard selection into the single SelectionHandler
trait (users could still just use one of them, it's not a must to have
both), the xwayland was changed to use some types from the
wayland/selection module.

--

I haven't tested XWayland, but the protocol is implemented in anvil, and it should be dead simple to add into any compositor.

The implementation was tested with wl-clipboard and YaLTeR/niri#27

@kchibisov kchibisov force-pushed the smithay-wlr-data-control branch 5 times, most recently from 72cbfb6 to f8cd94d Compare September 30, 2023 16:58
@kchibisov kchibisov marked this pull request as ready for review September 30, 2023 16:59
@codecov-commenter
Copy link

codecov-commenter commented Sep 30, 2023

Codecov Report

Attention: 643 lines in your changes are missing coverage. Please review.

Comparison is base (b2bfac9) 22.57% compared to head (8e779d0) 22.58%.
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1151   +/-   ##
=======================================
  Coverage   22.57%   22.58%           
=======================================
  Files         146      152    +6     
  Lines       23526    23614   +88     
=======================================
+ Hits         5312     5334   +22     
- Misses      18214    18280   +66     
Flag Coverage Δ
wlcs-buffer 19.51% <3.30%> (+0.02%) ⬆️
wlcs-core 19.17% <3.30%> (+0.02%) ⬆️
wlcs-output 8.05% <3.30%> (+0.06%) ⬆️
wlcs-pointer-input 21.38% <3.30%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/wayland/selection/data_device/source.rs 0.00% <ø> (ø)
src/wayland/selection/primary_selection/source.rs 0.00% <ø> (ø)
...c/wayland/selection/data_device/server_dnd_grab.rs 0.00% <0.00%> (ø)
anvil/src/state.rs 37.00% <33.33%> (+0.18%) ⬆️
src/wayland/selection/data_device/dnd_grab.rs 0.00% <0.00%> (ø)
src/wayland/selection/mod.rs 0.00% <0.00%> (ø)
src/wayland/selection/data_device/mod.rs 7.50% <0.00%> (ø)
src/wayland/selection/primary_selection/mod.rs 9.09% <0.00%> (ø)
src/wayland/selection/wlr_data_control/source.rs 0.00% <0.00%> (ø)
src/wayland/selection/source.rs 0.00% <0.00%> (ø)
... and 7 more

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@Drakulix Drakulix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I really like the simplicity of the data_control implementation, there is no way to filter what wlr_data_device-clients see, right?

Would it maybe make sense to add a method to the DataControlHandler to make it possible for downstream to filter selections send? (Default implementation could be "allow all" and it seems like send_selection would be an easy point to hook into.)

I don't have any particular use-cases in mind for this, but the current implementation feels like all or nothing. Either I want the protocol with all of the security problems it brings, or I don't advertise it at all.

Overall though, this is a great PR with so many good improvements. Thanks a bunch!

wlr_data_control is a protocol used to implement clipboard managers or
access clipboard without creating a window. The implementation of it
ties to regular selections, thus the selection handling was unified
to reduce the maintainance burden.

The present selection modules, like `walyand/primary_selection` and
`wayland/data_device` moved into the new `wayland/selection` module.
Keeping their original implementation, where it was possible.

The new selection module uses the common structure of `seat_data`,
`device`, `source`, and `mod.rs` used in the said above modules, however
it uses the hand-rolled dynamic dispatch with the `selection_dispatch!`
macro. The offers and selection replies are all handled together,
so the code is unique in the most cases.

As a side effect of the selection update and merging the handling of
the primary and clipboard selection into the single `SelectionHandler`
trait (users could still just use one of them, it's not a must to have
both), the xwayland was changed to use some types from the
`wayland/selection` module.
@kchibisov kchibisov force-pushed the smithay-wlr-data-control branch from f8cd94d to 8e779d0 Compare October 2, 2023 11:55
@kchibisov kchibisov requested a review from Drakulix October 2, 2023 11:56
@Drakulix Drakulix merged commit f5882a1 into Smithay:master Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants