-
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
wayland.selection: Introduce ext data control protocol #1577
base: master
Are you sure you want to change the base?
Conversation
021b549
to
c6ed6bd
Compare
9eb0022
to
f4fc2f2
Compare
|
f4fc2f2
to
ac7c63b
Compare
Codecov ReportAttention: Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
This is now ready. |
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.
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.
src/wayland/selection/offer.rs
Outdated
#[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), | ||
} | ||
} | ||
} |
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 feel like it shouldn't be in this file, but rather in the place where you wrap data controls.
src/wayland/selection/device.rs
Outdated
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(), | ||
} | ||
} | ||
} |
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'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> { |
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 it's a part of the public API? At least all the Data
was usually a public API.
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.
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.
8bdad86
to
e39e51a
Compare
wayland.selection: ExtDataControl
Adds support for the new ext data control protocolwayland.selection: Introduce DataDeviceKind
RemovesTypeId
in favor ofDataDeviceKind
enum