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.selection: Introduce ext data control protocol #1577

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

PolyMeilex
Copy link
Member

@PolyMeilex PolyMeilex commented Nov 3, 2024

  • wayland.selection: ExtDataControl Adds support for the new ext data control protocol
  • wayland.selection: Introduce DataDeviceKind Removes TypeId in favor of DataDeviceKind enum

@ids1024
Copy link
Member

ids1024 commented Jan 31, 2025

wayland-protocols 0.32.6 is now released on crates.io.

@codecov-commenter
Copy link

codecov-commenter commented Feb 1, 2025

Codecov Report

Attention: Patch coverage is 0% with 326 lines in your changes missing coverage. Please review.

Project coverage is 19.17%. Comparing base (953959e) to head (ac7c63b).
Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
src/wayland/selection/ext_data_control/mod.rs 0.00% 84 Missing ⚠️
src/wayland/selection/ext_data_control/device.rs 0.00% 69 Missing ⚠️
src/wayland/selection/device.rs 0.00% 48 Missing ⚠️
src/wayland/selection/offer.rs 0.00% 38 Missing ⚠️
src/wayland/selection/source.rs 0.00% 35 Missing ⚠️
src/wayland/selection/ext_data_control/source.rs 0.00% 32 Missing ⚠️
src/wayland/selection/wlr_data_control/mod.rs 0.00% 8 Missing ⚠️
src/wayland/selection/wlr_data_control/device.rs 0.00% 7 Missing ⚠️
src/wayland/selection/seat_data.rs 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1577      +/-   ##
==========================================
+ Coverage   17.33%   19.17%   +1.84%     
==========================================
  Files         171      174       +3     
  Lines       28389    28689     +300     
==========================================
+ Hits         4922     5502     +580     
+ Misses      23467    23187     -280     
Flag Coverage Δ
wlcs-buffer 16.71% <0.00%> (-0.11%) ⬇️
wlcs-core 16.45% <0.00%> (-0.11%) ⬇️
wlcs-output 6.81% <0.00%> (-0.01%) ⬇️
wlcs-pointer-input 18.15% <0.00%> (?)

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

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

@PolyMeilex PolyMeilex marked this pull request as ready for review February 1, 2025 15:56
@PolyMeilex
Copy link
Member Author

This is now ready.

Copy link
Member

@kchibisov kchibisov left a comment

Choose a reason for hiding this comment

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

Would assume that the implementation of request handling was copy pasted 1 to 1 from the Wlr one, with the exception of removed version checks.

Comment on lines 58 to 74
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum DataControlOffer {
Wlr(ZwlrDataControlOfferV1),
Ext(ExtDataControlOfferV1),
}

impl DataControlOffer {
/// Advertise offered MIME type
///
/// Sent immediately after creating the wlr_data_control_offer object. One event per offered MIME type.
fn offer(&self, mime_type: String) {
match self {
Self::Wlr(obj) => obj.offer(mime_type),
Self::Ext(obj) => obj.offer(mime_type),
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I feel like it shouldn't be in this file, but rather in the place where you wrap data controls.

Comment on lines 26 to 86
pub(crate) enum DataControlDevice {
Wlr(ZwlrDataControlDeviceV1),
Ext(ExtDataControlDeviceV1),
}

impl DataControlDevice {
fn data_offer(&self, offer: &DataControlOffer) {
match (self, offer) {
(Self::Wlr(obj), DataControlOffer::Wlr(offer)) => obj.data_offer(offer),
(Self::Ext(obj), DataControlOffer::Ext(offer)) => obj.data_offer(offer),
_ => unreachable!(),
}
}

fn selection(&self, offer: Option<&DataControlOffer>) {
match (self, offer) {
(Self::Wlr(obj), Some(DataControlOffer::Wlr(offer))) => obj.selection(Some(offer)),
(Self::Ext(obj), Some(DataControlOffer::Ext(offer))) => obj.selection(Some(offer)),
(Self::Wlr(obj), None) => obj.selection(None),
(Self::Ext(obj), None) => obj.selection(None),
_ => unreachable!(),
}
}

fn primary_selection(&self, offer: Option<&DataControlOffer>) {
match (self, offer) {
(Self::Wlr(obj), Some(DataControlOffer::Wlr(offer))) => obj.primary_selection(Some(offer)),
(Self::Ext(obj), Some(DataControlOffer::Ext(offer))) => obj.primary_selection(Some(offer)),
(Self::Wlr(obj), None) => obj.primary_selection(None),
(Self::Ext(obj), None) => obj.primary_selection(None),
_ => unreachable!(),
}
}

fn wl_seat(&self) -> WlSeat {
match self {
Self::Wlr(device) => {
let data: &DataControlDeviceUserData = device.data().unwrap();
data.wl_seat.clone()
}
Self::Ext(device) => {
let data: &ExtDataControlDeviceUserData = device.data().unwrap();
data.wl_seat.clone()
}
}
}

fn id(&self) -> ObjectId {
match self {
Self::Wlr(obj) => obj.id(),
Self::Ext(obj) => obj.id(),
}
}

fn version(&self) -> u32 {
match self {
Self::Wlr(obj) => obj.version(),
Self::Ext(obj) => obj.version(),
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I'd probably move it somewhere else to data_control only related file. Though, as alternative, you could write it with WlrDataControl and ExtDataControl as top-level types, would be much easier on a review, since the code will be pretty much duplicated.

And in fact, it's already pretty much duplicated, so really seems like there's no point in having a wrapper? Though, I could be wrong.

/// The data is shared accross primary, data device, and data control selections.
pub struct SeatData<U: Clone + Sync + Send + 'static> {
/// The data is shared across primary, data device, and data control selections.
pub(crate) struct SeatData<U: Clone + Sync + Send + 'static> {
Copy link
Member

Choose a reason for hiding this comment

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

I think it's a part of the public API? At least all the Data was usually a public API.

Copy link
Member Author

Choose a reason for hiding this comment

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

The seat_data module is private, and the type is not reexported. So I just marked it as pub(crate) to make that fact more clear.

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