wayland: make object versions type safe
This commit is contained in:
parent
0d7b45d149
commit
e3a1a0b30f
50 changed files with 198 additions and 173 deletions
|
|
@ -12,7 +12,7 @@ use {
|
|||
wl_surface::{SurfaceRole, WlSurfaceError},
|
||||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
object::{Object, Version},
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{wl_data_device::*, WlDataDeviceId, WlDataOfferId, WlSurfaceId},
|
||||
},
|
||||
|
|
@ -26,7 +26,7 @@ const ROLE: u32 = 0;
|
|||
pub struct WlDataDevice {
|
||||
pub id: WlDataDeviceId,
|
||||
pub client: Rc<Client>,
|
||||
pub version: u32,
|
||||
pub version: Version,
|
||||
pub seat: Rc<WlSeatGlobal>,
|
||||
pub data: DeviceData<WlDataOffer>,
|
||||
pub tracker: Tracker<Self>,
|
||||
|
|
@ -36,7 +36,7 @@ impl WlDataDevice {
|
|||
pub fn new(
|
||||
id: WlDataDeviceId,
|
||||
client: &Rc<Client>,
|
||||
version: u32,
|
||||
version: Version,
|
||||
seat: &Rc<WlSeatGlobal>,
|
||||
) -> Self {
|
||||
Self {
|
||||
|
|
@ -158,7 +158,7 @@ impl IterableIpcVtable for ClipboardIpc {
|
|||
where
|
||||
C: FnMut(&Rc<Self::Device>),
|
||||
{
|
||||
seat.for_each_data_device(0, client, f);
|
||||
seat.for_each_data_device(Version::ALL, client, f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use {
|
|||
globals::{Global, GlobalName},
|
||||
ifs::ipc::{wl_data_device::WlDataDevice, wl_data_source::WlDataSource},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
object::{Object, Version},
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{wl_data_device_manager::*, WlDataDeviceManagerId},
|
||||
},
|
||||
|
|
@ -28,7 +28,7 @@ pub struct WlDataDeviceManagerGlobal {
|
|||
pub struct WlDataDeviceManager {
|
||||
pub id: WlDataDeviceManagerId,
|
||||
pub client: Rc<Client>,
|
||||
pub version: u32,
|
||||
pub version: Version,
|
||||
tracker: Tracker<Self>,
|
||||
}
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ impl WlDataDeviceManagerGlobal {
|
|||
self: Rc<Self>,
|
||||
id: WlDataDeviceManagerId,
|
||||
client: &Rc<Client>,
|
||||
version: u32,
|
||||
version: Version,
|
||||
) -> Result<(), WlDataDeviceManagerError> {
|
||||
let obj = Rc::new(WlDataDeviceManager {
|
||||
id,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use {
|
|||
xdg_toplevel_drag_v1::XdgToplevelDragV1,
|
||||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
object::{Object, Version},
|
||||
utils::{
|
||||
bitflags::BitflagsExt,
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
|
|
@ -40,7 +40,7 @@ const INVALID_SOURCE: u32 = 1;
|
|||
pub struct WlDataSource {
|
||||
pub id: WlDataSourceId,
|
||||
pub data: SourceData,
|
||||
pub version: u32,
|
||||
pub version: Version,
|
||||
pub tracker: Tracker<Self>,
|
||||
pub toplevel_drag: CloneCell<Option<Rc<XdgToplevelDragV1>>>,
|
||||
}
|
||||
|
|
@ -94,7 +94,7 @@ impl DynDataSource for WlDataSource {
|
|||
}
|
||||
|
||||
impl WlDataSource {
|
||||
pub fn new(id: WlDataSourceId, client: &Rc<Client>, version: u32) -> Self {
|
||||
pub fn new(id: WlDataSourceId, client: &Rc<Client>, version: Version) -> Self {
|
||||
Self {
|
||||
id,
|
||||
tracker: Default::default(),
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use {
|
|||
wl_seat::{WlSeatError, WlSeatGlobal},
|
||||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
object::{Object, Version},
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{
|
||||
zwlr_data_control_device_v1::*, ZwlrDataControlDeviceV1Id, ZwlrDataControlOfferV1Id,
|
||||
|
|
@ -25,12 +25,12 @@ use {
|
|||
thiserror::Error,
|
||||
};
|
||||
|
||||
pub const PRIMARY_SELECTION_SINCE: u32 = 2;
|
||||
pub const PRIMARY_SELECTION_SINCE: Version = Version(2);
|
||||
|
||||
pub struct ZwlrDataControlDeviceV1 {
|
||||
pub id: ZwlrDataControlDeviceV1Id,
|
||||
pub client: Rc<Client>,
|
||||
pub version: u32,
|
||||
pub version: Version,
|
||||
pub seat: Rc<WlSeatGlobal>,
|
||||
pub clipboard_data: DeviceData<ZwlrDataControlOfferV1>,
|
||||
pub primary_selection_data: DeviceData<ZwlrDataControlOfferV1>,
|
||||
|
|
@ -41,7 +41,7 @@ impl ZwlrDataControlDeviceV1 {
|
|||
pub fn new(
|
||||
id: ZwlrDataControlDeviceV1Id,
|
||||
client: &Rc<Client>,
|
||||
version: u32,
|
||||
version: Version,
|
||||
seat: &Rc<WlSeatGlobal>,
|
||||
) -> Self {
|
||||
Self {
|
||||
|
|
@ -137,7 +137,7 @@ pub type WlrClipboardIpc = WlrIpcImpl<WlrClipboardIpcCore>;
|
|||
pub type WlrPrimarySelectionIpc = WlrIpcImpl<WlrPrimarySelectionIpcCore>;
|
||||
|
||||
trait WlrIpc {
|
||||
const MIN_VERSION: u32;
|
||||
const MIN_VERSION: Version;
|
||||
const LOCATION: IpcLocation;
|
||||
|
||||
fn wlr_get_device_data(dd: &ZwlrDataControlDeviceV1) -> &DeviceData<ZwlrDataControlOfferV1>;
|
||||
|
|
@ -153,7 +153,7 @@ trait WlrIpc {
|
|||
}
|
||||
|
||||
impl WlrIpc for WlrClipboardIpcCore {
|
||||
const MIN_VERSION: u32 = 1;
|
||||
const MIN_VERSION: Version = Version::ALL;
|
||||
const LOCATION: IpcLocation = IpcLocation::Clipboard;
|
||||
|
||||
fn wlr_get_device_data(dd: &ZwlrDataControlDeviceV1) -> &DeviceData<ZwlrDataControlOfferV1> {
|
||||
|
|
@ -180,7 +180,7 @@ impl WlrIpc for WlrClipboardIpcCore {
|
|||
}
|
||||
|
||||
impl WlrIpc for WlrPrimarySelectionIpcCore {
|
||||
const MIN_VERSION: u32 = PRIMARY_SELECTION_SINCE;
|
||||
const MIN_VERSION: Version = PRIMARY_SELECTION_SINCE;
|
||||
const LOCATION: IpcLocation = IpcLocation::PrimarySelection;
|
||||
|
||||
fn wlr_get_device_data(dd: &ZwlrDataControlDeviceV1) -> &DeviceData<ZwlrDataControlOfferV1> {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use {
|
|||
zwlr_data_control_source_v1::ZwlrDataControlSourceV1,
|
||||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
object::{Object, Version},
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{zwlr_data_control_manager_v1::*, ZwlrDataControlManagerV1Id},
|
||||
},
|
||||
|
|
@ -22,7 +22,7 @@ pub struct ZwlrDataControlManagerV1Global {
|
|||
pub struct ZwlrDataControlManagerV1 {
|
||||
pub id: ZwlrDataControlManagerV1Id,
|
||||
pub client: Rc<Client>,
|
||||
pub version: u32,
|
||||
pub version: Version,
|
||||
tracker: Tracker<Self>,
|
||||
}
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ impl ZwlrDataControlManagerV1Global {
|
|||
self: Rc<Self>,
|
||||
id: ZwlrDataControlManagerV1Id,
|
||||
client: &Rc<Client>,
|
||||
version: u32,
|
||||
version: Version,
|
||||
) -> Result<(), ZwlrDataControlManagerV1Error> {
|
||||
let obj = Rc::new(ZwlrDataControlManagerV1 {
|
||||
id,
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use {
|
|||
wl_seat::WlSeatGlobal,
|
||||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
object::{Object, Version},
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{zwlr_data_control_source_v1::*, ZwlrDataControlSourceV1Id},
|
||||
},
|
||||
|
|
@ -29,7 +29,7 @@ use {
|
|||
pub struct ZwlrDataControlSourceV1 {
|
||||
pub id: ZwlrDataControlSourceV1Id,
|
||||
pub data: SourceData,
|
||||
pub version: u32,
|
||||
pub version: Version,
|
||||
pub location: Cell<IpcLocation>,
|
||||
pub used: Cell<bool>,
|
||||
pub tracker: Tracker<Self>,
|
||||
|
|
@ -91,7 +91,7 @@ impl DynDataSource for ZwlrDataControlSourceV1 {
|
|||
}
|
||||
|
||||
impl ZwlrDataControlSourceV1 {
|
||||
pub fn new(id: ZwlrDataControlSourceV1Id, client: &Rc<Client>, version: u32) -> Self {
|
||||
pub fn new(id: ZwlrDataControlSourceV1Id, client: &Rc<Client>, version: Version) -> Self {
|
||||
Self {
|
||||
id,
|
||||
tracker: Default::default(),
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use {
|
|||
zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1,
|
||||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
object::{Object, Version},
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{zwp_primary_selection_device_manager_v1::*, ZwpPrimarySelectionDeviceManagerV1Id},
|
||||
},
|
||||
|
|
@ -22,7 +22,7 @@ pub struct ZwpPrimarySelectionDeviceManagerV1Global {
|
|||
pub struct ZwpPrimarySelectionDeviceManagerV1 {
|
||||
pub id: ZwpPrimarySelectionDeviceManagerV1Id,
|
||||
pub client: Rc<Client>,
|
||||
pub version: u32,
|
||||
pub version: Version,
|
||||
pub tracker: Tracker<Self>,
|
||||
}
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ impl ZwpPrimarySelectionDeviceManagerV1Global {
|
|||
self: Rc<Self>,
|
||||
id: ZwpPrimarySelectionDeviceManagerV1Id,
|
||||
client: &Rc<Client>,
|
||||
version: u32,
|
||||
version: Version,
|
||||
) -> Result<(), ZwpPrimarySelectionDeviceManagerV1Error> {
|
||||
let obj = Rc::new(ZwpPrimarySelectionDeviceManagerV1 {
|
||||
id,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use {
|
|||
wl_seat::{WlSeatError, WlSeatGlobal},
|
||||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
object::{Object, Version},
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{
|
||||
zwp_primary_selection_device_v1::*, ZwpPrimarySelectionDeviceV1Id,
|
||||
|
|
@ -25,7 +25,7 @@ use {
|
|||
pub struct ZwpPrimarySelectionDeviceV1 {
|
||||
pub id: ZwpPrimarySelectionDeviceV1Id,
|
||||
pub client: Rc<Client>,
|
||||
pub version: u32,
|
||||
pub version: Version,
|
||||
pub seat: Rc<WlSeatGlobal>,
|
||||
data: DeviceData<ZwpPrimarySelectionOfferV1>,
|
||||
pub tracker: Tracker<Self>,
|
||||
|
|
@ -35,7 +35,7 @@ impl ZwpPrimarySelectionDeviceV1 {
|
|||
pub fn new(
|
||||
id: ZwpPrimarySelectionDeviceV1Id,
|
||||
client: &Rc<Client>,
|
||||
version: u32,
|
||||
version: Version,
|
||||
seat: &Rc<WlSeatGlobal>,
|
||||
) -> Self {
|
||||
Self {
|
||||
|
|
@ -106,7 +106,7 @@ impl IterableIpcVtable for PrimarySelectionIpc {
|
|||
where
|
||||
C: FnMut(&Rc<Self::Device>),
|
||||
{
|
||||
seat.for_each_primary_selection_device(0, client, f)
|
||||
seat.for_each_primary_selection_device(Version::ALL, client, f)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue