1
0
Fork 0
forked from wry/wry

wayland: make object versions type safe

This commit is contained in:
Julian Orth 2024-04-08 14:47:50 +02:00
parent 0d7b45d149
commit e3a1a0b30f
50 changed files with 198 additions and 173 deletions

View file

@ -39,7 +39,7 @@ use {
zxdg_decoration_manager_v1::ZxdgDecorationManagerV1Global,
zxdg_output_manager_v1::ZxdgOutputManagerV1Global,
},
object::{Interface, ObjectId},
object::{Interface, ObjectId, Version},
state::State,
utils::{
copyhashmap::{CopyHashMap, Locked},
@ -97,7 +97,7 @@ pub trait GlobalBase {
self: Rc<Self>,
client: &'a Rc<Client>,
id: ObjectId,
version: u32,
version: Version,
) -> Result<(), GlobalsError>;
fn interface(&self) -> Interface;
}

View file

@ -7,7 +7,7 @@ use {
wl_surface::{x_surface::xwindow::Xwindow, xdg_surface::xdg_toplevel::XdgToplevel},
},
leaks::Tracker,
object::Object,
object::{Object, Version},
tree::{NodeVisitorBase, ToplevelNode},
utils::buffd::{MsgParser, MsgParserError},
wire::{
@ -32,7 +32,7 @@ impl ExtForeignToplevelListV1Global {
self: Rc<Self>,
id: ExtForeignToplevelListV1Id,
client: &Rc<Client>,
_version: u32,
_version: Version,
) -> Result<(), ExtForeignToplevelListV1Error> {
let obj = Rc::new(ExtForeignToplevelListV1 {
id,

View file

@ -4,7 +4,7 @@ use {
globals::{Global, GlobalName},
ifs::ext_idle_notification_v1::ExtIdleNotificationV1,
leaks::Tracker,
object::Object,
object::{Object, Version},
time::now_usec,
utils::{
buffd::{MsgParser, MsgParserError},
@ -29,7 +29,7 @@ impl ExtIdleNotifierV1Global {
self: Rc<Self>,
id: ExtIdleNotifierV1Id,
client: &Rc<Client>,
_version: u32,
_version: Version,
) -> Result<(), ExtIdleNotifierV1Error> {
let obj = Rc::new(ExtIdleNotifierV1 {
id,

View file

@ -4,7 +4,7 @@ use {
globals::{Global, GlobalName},
ifs::ext_session_lock_v1::ExtSessionLockV1,
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
wire::{ext_session_lock_manager_v1::*, ExtSessionLockManagerV1Id},
},
@ -25,7 +25,7 @@ impl ExtSessionLockManagerV1Global {
self: Rc<Self>,
id: ExtSessionLockManagerV1Id,
client: &Rc<Client>,
_version: u32,
_version: Version,
) -> Result<(), ExtSessionLockManagerV1Error> {
let obj = Rc::new(ExtSessionLockManagerV1 {
id,

View file

@ -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);
}
}

View file

@ -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,

View file

@ -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(),

View file

@ -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> {

View file

@ -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,

View file

@ -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(),

View file

@ -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,

View file

@ -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)
}
}

View file

@ -11,7 +11,7 @@ use {
jay_workspace_watcher::JayWorkspaceWatcher,
},
leaks::Tracker,
object::Object,
object::{Object, Version},
screenshoter::take_screenshot,
utils::{
buffd::{MsgParser, MsgParserError},
@ -39,7 +39,7 @@ impl JayCompositorGlobal {
self: Rc<Self>,
id: JayCompositorId,
client: &Rc<Client>,
_version: u32,
_version: Version,
) -> Result<(), JayCompositorError> {
let obj = Rc::new(JayCompositor {
id,

View file

@ -6,7 +6,7 @@ use {
OrgKdeKwinServerDecoration, OrgKdeKwinServerDecorationError,
},
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
wire::{org_kde_kwin_server_decoration_manager::*, OrgKdeKwinServerDecorationManagerId},
},
@ -32,7 +32,7 @@ impl OrgKdeKwinServerDecorationManagerGlobal {
self: Rc<Self>,
id: OrgKdeKwinServerDecorationManagerId,
client: &Rc<Client>,
version: u32,
version: Version,
) -> Result<(), OrgKdeKwinServerDecorationManagerError> {
let obj = Rc::new(OrgKdeKwinServerDecorationManager {
id,
@ -68,7 +68,7 @@ simple_add_global!(OrgKdeKwinServerDecorationManagerGlobal);
pub struct OrgKdeKwinServerDecorationManager {
id: OrgKdeKwinServerDecorationManagerId,
client: Rc<Client>,
_version: u32,
_version: Version,
pub tracker: Tracker<Self>,
}

View file

@ -4,7 +4,7 @@ use {
globals::{Global, GlobalName},
ifs::{wl_region::WlRegion, wl_surface::WlSurface},
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
wire::{wl_compositor::*, WlCompositorId},
xwayland::XWaylandEvent,
@ -20,7 +20,7 @@ pub struct WlCompositorGlobal {
pub struct WlCompositor {
id: WlCompositorId,
client: Rc<Client>,
version: u32,
version: Version,
pub tracker: Tracker<Self>,
}
@ -33,7 +33,7 @@ impl WlCompositorGlobal {
self: Rc<Self>,
id: WlCompositorId,
client: &Rc<Client>,
version: u32,
version: Version,
) -> Result<(), WlCompositorError> {
let obj = Rc::new(WlCompositor {
id,

View file

@ -5,7 +5,7 @@ use {
globals::{Global, GlobalName},
ifs::wl_buffer::WlBuffer,
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
video::{
dmabuf::{DmaBuf, DmaBufPlane, PlaneVec},
@ -33,7 +33,7 @@ impl WlDrmGlobal {
self: Rc<Self>,
id: WlDrmId,
client: &Rc<Client>,
version: u32,
version: Version,
) -> Result<(), WlDrmError> {
let obj = Rc::new(WlDrm {
id,
@ -68,7 +68,7 @@ simple_add_global!(WlDrmGlobal);
pub struct WlDrm {
id: WlDrmId,
pub client: Rc<Client>,
version: u32,
version: Version,
tracker: Tracker<Self>,
}

View file

@ -9,7 +9,7 @@ use {
zwlr_screencopy_frame_v1::ZwlrScreencopyFrameV1, zxdg_output_v1::ZxdgOutputV1,
},
leaks::Tracker,
object::Object,
object::{Object, Version},
rect::Rect,
state::{ConnectorData, State},
time::Time,
@ -183,7 +183,7 @@ impl WlOutputGlobal {
self: Rc<Self>,
id: WlOutputId,
client: &Rc<Client>,
version: u32,
version: Version,
) -> Result<(), WlOutputError> {
let obj = Rc::new(WlOutput {
global: self.clone(),
@ -328,13 +328,13 @@ pub struct WlOutput {
pub id: WlOutputId,
pub xdg_outputs: CopyHashMap<ZxdgOutputV1Id, Rc<ZxdgOutputV1>>,
client: Rc<Client>,
pub version: u32,
pub version: Version,
tracker: Tracker<Self>,
}
pub const SEND_DONE_SINCE: u32 = 2;
pub const SEND_SCALE_SINCE: u32 = 2;
pub const SEND_NAME_SINCE: u32 = 4;
pub const SEND_DONE_SINCE: Version = Version(2);
pub const SEND_SCALE_SINCE: Version = Version(2);
pub const SEND_NAME_SINCE: Version = Version(4);
impl WlOutput {
fn send_geometry(&self) {

View file

@ -3,7 +3,7 @@ use {
client::Client,
globals::{Global, GlobalName, GlobalsError},
leaks::Tracker,
object::{Interface, Object},
object::{Interface, Object, Version},
utils::buffd::{MsgParser, MsgParserError},
wire::{wl_registry::*, WlRegistryId},
},
@ -62,7 +62,7 @@ impl WlRegistry {
actual: bind.version,
}));
}
global.bind(&self.client, bind.id, bind.version)?;
global.bind(&self.client, bind.id, Version(bind.version))?;
Ok(())
}
}

View file

@ -45,7 +45,7 @@ use {
xdg_toplevel_drag_v1::XdgToplevelDragV1,
},
leaks::Tracker,
object::Object,
object::{Object, Version},
rect::Rect,
state::State,
time::now_usec,
@ -96,7 +96,7 @@ const MISSING_CAPABILITY: u32 = 0;
pub const BTN_LEFT: u32 = 0x110;
pub const SEAT_NAME_SINCE: u32 = 2;
pub const SEAT_NAME_SINCE: Version = Version(2);
pub const PX_PER_SCROLL: f64 = 15.0;
@ -1040,7 +1040,7 @@ impl WlSeatGlobal {
self: Rc<Self>,
id: WlSeatId,
client: &Rc<Client>,
version: u32,
version: Version,
) -> Result<(), WlSeatError> {
let obj = Rc::new(WlSeat {
global: self.clone(),
@ -1124,11 +1124,11 @@ pub struct WlSeat {
pointers: CopyHashMap<WlPointerId, Rc<WlPointer>>,
relative_pointers: CopyHashMap<ZwpRelativePointerV1Id, Rc<ZwpRelativePointerV1>>,
keyboards: CopyHashMap<WlKeyboardId, Rc<WlKeyboard>>,
version: u32,
version: Version,
tracker: Tracker<Self>,
}
const READ_ONLY_KEYMAP_SINCE: u32 = 7;
const READ_ONLY_KEYMAP_SINCE: Version = Version(7);
impl WlSeat {
fn send_capabilities(self: &Rc<Self>) {

View file

@ -27,6 +27,7 @@ use {
},
wl_surface::{xdg_surface::xdg_popup::XdgPopup, WlSurface},
},
object::Version,
state::DeviceHandlerData,
tree::{Direction, FloatNode, Node, ToplevelNode},
utils::{bitflags::BitflagsExt, smallmap::SmallMap},
@ -431,7 +432,7 @@ impl WlSeatGlobal {
self.kb_owner.set_kb_node(self, node);
}
fn for_each_seat<C>(&self, ver: u32, client: ClientId, mut f: C)
fn for_each_seat<C>(&self, ver: Version, client: ClientId, mut f: C)
where
C: FnMut(&Rc<WlSeat>),
{
@ -445,7 +446,7 @@ impl WlSeatGlobal {
}
}
fn for_each_pointer<C>(&self, ver: u32, client: ClientId, mut f: C)
fn for_each_pointer<C>(&self, ver: Version, client: ClientId, mut f: C)
where
C: FnMut(&Rc<WlPointer>),
{
@ -461,7 +462,7 @@ impl WlSeatGlobal {
where
C: FnMut(&Rc<ZwpRelativePointerV1>),
{
self.for_each_seat(0, client, |seat| {
self.for_each_seat(Version::ALL, client, |seat| {
let pointers = seat.relative_pointers.lock();
for pointer in pointers.values() {
f(pointer);
@ -469,7 +470,7 @@ impl WlSeatGlobal {
})
}
fn for_each_kb<C>(&self, ver: u32, client: ClientId, mut f: C)
fn for_each_kb<C>(&self, ver: Version, client: ClientId, mut f: C)
where
C: FnMut(&Rc<WlKeyboard>),
{
@ -481,7 +482,7 @@ impl WlSeatGlobal {
})
}
pub fn for_each_data_device<C>(&self, ver: u32, client: ClientId, mut f: C)
pub fn for_each_data_device<C>(&self, ver: Version, client: ClientId, mut f: C)
where
C: FnMut(&Rc<WlDataDevice>),
{
@ -495,7 +496,7 @@ impl WlSeatGlobal {
}
}
pub fn for_each_primary_selection_device<C>(&self, ver: u32, client: ClientId, mut f: C)
pub fn for_each_primary_selection_device<C>(&self, ver: Version, client: ClientId, mut f: C)
where
C: FnMut(&Rc<ZwpPrimarySelectionDeviceV1>),
{
@ -509,7 +510,7 @@ impl WlSeatGlobal {
}
}
pub fn for_each_wlr_data_device<C>(&self, ver: u32, mut f: C)
pub fn for_each_wlr_data_device<C>(&self, ver: Version, mut f: C)
where
C: FnMut(&Rc<ZwlrDataControlDeviceV1>),
{
@ -524,7 +525,7 @@ impl WlSeatGlobal {
self.surface_pointer_event(POINTER_FRAME_SINCE_VERSION, surface, |p| p.send_frame());
}
fn surface_pointer_event<F>(&self, ver: u32, surface: &WlSurface, mut f: F)
fn surface_pointer_event<F>(&self, ver: Version, surface: &WlSurface, mut f: F)
where
F: FnMut(&Rc<WlPointer>),
{
@ -545,7 +546,7 @@ impl WlSeatGlobal {
});
}
fn surface_kb_event<F>(&self, ver: u32, surface: &WlSurface, mut f: F)
fn surface_kb_event<F>(&self, ver: Version, surface: &WlSurface, mut f: F)
where
F: FnMut(&Rc<WlKeyboard>),
{
@ -603,7 +604,9 @@ impl WlSeatGlobal {
KeyState::Pressed => (wl_pointer::PRESSED, true),
};
let time = (time_usec / 1000) as u32;
self.surface_pointer_event(0, surface, |p| p.send_button(serial, time, button, state));
self.surface_pointer_event(Version::ALL, surface, |p| {
p.send_button(serial, time, button, state)
});
self.surface_pointer_frame(surface);
if pressed {
if let Some(node) = surface.get_focus_node(self.id) {
@ -625,7 +628,7 @@ impl WlSeatGlobal {
self.surface_pointer_event(since, surface, |p| p.send_axis_source(source));
}
let time = (event.time_usec.get() / 1000) as _;
self.for_each_pointer(0, surface.client.id, |p| {
self.for_each_pointer(Version::ALL, surface.client.id, |p| {
for i in 0..1 {
let axis = i as _;
if let Some(delta) = event.v120[i].get() {
@ -666,7 +669,7 @@ impl WlSeatGlobal {
}
}
let time = (self.pos_time_usec.get() / 1000) as u32;
self.surface_pointer_event(0, n, |p| p.send_motion(time, x, y));
self.surface_pointer_event(Version::ALL, n, |p| p.send_motion(time, x, y));
}
self.surface_pointer_frame(n);
self.maybe_constrain(n, x, y);
@ -705,7 +708,7 @@ impl WlSeatGlobal {
pub fn enter_surface(&self, n: &WlSurface, x: Fixed, y: Fixed) {
let serial = n.client.next_serial();
n.client.last_enter_serial.set(serial);
self.surface_pointer_event(0, n, |p| p.send_enter(serial, n.id, x, y));
self.surface_pointer_event(Version::ALL, n, |p| p.send_enter(serial, n.id, x, y));
self.surface_pointer_frame(n);
for (_, constraint) in &n.constraints {
if constraint.status.get() == SeatConstraintStatus::ActivatableOnFocus {
@ -723,7 +726,7 @@ impl WlSeatGlobal {
for (_, constraint) in &n.constraints {
constraint.deactivate();
}
self.surface_pointer_event(0, n, |p| p.send_leave(serial, n.id));
self.surface_pointer_event(Version::ALL, n, |p| p.send_leave(serial, n.id));
self.surface_pointer_frame(n);
}
}
@ -732,7 +735,7 @@ impl WlSeatGlobal {
impl WlSeatGlobal {
pub fn unfocus_surface(&self, surface: &WlSurface) {
let serial = surface.client.next_serial();
self.surface_kb_event(0, surface, |k| k.send_leave(serial, surface.id))
self.surface_kb_event(Version::ALL, surface, |k| k.send_leave(serial, surface.id))
}
}
@ -741,7 +744,7 @@ impl WlSeatGlobal {
pub fn focus_surface(&self, surface: &WlSurface) {
let pressed_keys: Vec<_> = self.pressed_keys.borrow().iter().copied().collect();
let serial = surface.client.next_serial();
self.surface_kb_event(0, surface, |k| {
self.surface_kb_event(Version::ALL, surface, |k| {
k.send_enter(serial, surface.id, &pressed_keys)
});
let ModifierState {
@ -752,7 +755,7 @@ impl WlSeatGlobal {
..
} = self.kb_state.borrow().mods();
let serial = surface.client.next_serial();
self.surface_kb_event(0, surface, |k| {
self.surface_kb_event(Version::ALL, surface, |k| {
k.send_modifiers(serial, mods_depressed, mods_latched, mods_locked, group)
});
@ -774,7 +777,9 @@ impl WlSeatGlobal {
pub fn key_surface(&self, surface: &WlSurface, time_usec: u64, key: u32, state: u32) {
let serial = surface.client.next_serial();
let time = (time_usec / 1000) as _;
self.surface_kb_event(0, surface, |k| k.send_key(serial, time, key, state));
self.surface_kb_event(Version::ALL, surface, |k| {
k.send_key(serial, time, key, state)
});
}
}
@ -782,7 +787,7 @@ impl WlSeatGlobal {
impl WlSeatGlobal {
pub fn mods_surface(&self, surface: &WlSurface, mods: ModifierState) {
let serial = surface.client.next_serial();
self.surface_kb_event(0, surface, |k| {
self.surface_kb_event(Version::ALL, surface, |k| {
k.send_modifiers(
serial,
mods.mods_depressed,
@ -798,7 +803,7 @@ impl WlSeatGlobal {
impl WlSeatGlobal {
pub fn dnd_surface_leave(&self, surface: &WlSurface, dnd: &Dnd) {
if dnd.src.is_some() || surface.client.id == dnd.client.id {
self.for_each_data_device(0, surface.client.id, |dd| {
self.for_each_data_device(Version::ALL, surface.client.id, |dd| {
dd.send_leave();
})
}
@ -810,7 +815,7 @@ impl WlSeatGlobal {
pub fn dnd_surface_drop(&self, surface: &WlSurface, dnd: &Dnd) {
if dnd.src.is_some() || surface.client.id == dnd.client.id {
self.for_each_data_device(0, surface.client.id, |dd| {
self.for_each_data_device(Version::ALL, surface.client.id, |dd| {
dd.send_drop();
})
}
@ -834,7 +839,7 @@ impl WlSeatGlobal {
offer.send_source_actions();
})
} else if surface.client.id == dnd.client.id {
self.for_each_data_device(0, dnd.client.id, |dd| {
self.for_each_data_device(Version::ALL, dnd.client.id, |dd| {
dd.send_enter(surface.id, x, y, WlDataOfferId::NONE, serial);
})
}
@ -850,7 +855,7 @@ impl WlSeatGlobal {
y: Fixed,
) {
if dnd.src.is_some() || surface.client.id == dnd.client.id {
self.for_each_data_device(0, surface.client.id, |dd| {
self.for_each_data_device(Version::ALL, surface.client.id, |dd| {
dd.send_motion(time_usec, x, y);
})
}

View file

@ -3,7 +3,7 @@ use {
client::ClientError,
ifs::wl_seat::WlSeat,
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::{
buffd::{MsgParser, MsgParserError},
oserror::OsError,
@ -15,7 +15,7 @@ use {
uapi::OwnedFd,
};
pub const REPEAT_INFO_SINCE: u32 = 4;
pub const REPEAT_INFO_SINCE: Version = Version(4);
#[allow(dead_code)]
const NO_KEYMAP: u32 = 0;

View file

@ -5,7 +5,7 @@ use {
fixed::Fixed,
ifs::{wl_seat::WlSeat, wl_surface::WlSurfaceError},
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
wire::{wl_pointer::*, WlPointerId, WlSurfaceId},
},
@ -31,13 +31,13 @@ pub const WHEEL_TILT: u32 = 3;
pub const IDENTICAL: u32 = 0;
pub const INVERTED: u32 = 1;
pub const POINTER_FRAME_SINCE_VERSION: u32 = 5;
pub const AXIS_SOURCE_SINCE_VERSION: u32 = 5;
pub const AXIS_DISCRETE_SINCE_VERSION: u32 = 5;
pub const AXIS_STOP_SINCE_VERSION: u32 = 5;
pub const WHEEL_TILT_SINCE_VERSION: u32 = 6;
pub const AXIS_VALUE120_SINCE_VERSION: u32 = 8;
pub const AXIS_RELATIVE_DIRECTION_SINCE_VERSION: u32 = 9;
pub const POINTER_FRAME_SINCE_VERSION: Version = Version(5);
pub const AXIS_SOURCE_SINCE_VERSION: Version = Version(5);
pub const AXIS_DISCRETE_SINCE_VERSION: Version = Version(5);
pub const AXIS_STOP_SINCE_VERSION: Version = Version(5);
pub const WHEEL_TILT_SINCE_VERSION: Version = Version(6);
pub const AXIS_VALUE120_SINCE_VERSION: Version = Version(8);
pub const AXIS_RELATIVE_DIRECTION_SINCE_VERSION: Version = Version(9);
#[derive(Default, Debug)]
pub struct PendingScroll {

View file

@ -11,7 +11,7 @@ use {
wl_surface::WlSurface,
},
leaks::Tracker,
object::Object,
object::{Object, Version},
rect::Region,
utils::{
buffd::{MsgParser, MsgParserError},
@ -154,7 +154,7 @@ impl ZwpPointerConstraintsV1Global {
self: Rc<Self>,
id: ZwpPointerConstraintsV1Id,
client: &Rc<Client>,
_version: u32,
_version: Version,
) -> Result<(), ZwpPointerConstraintsV1Error> {
let cs = Rc::new(ZwpPointerConstraintsV1 {
id,

View file

@ -4,7 +4,7 @@ use {
globals::{Global, GlobalName},
ifs::wl_seat::zwp_relative_pointer_v1::ZwpRelativePointerV1,
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
wire::{zwp_relative_pointer_manager_v1::*, ZwpRelativePointerManagerV1Id},
},
@ -31,7 +31,7 @@ impl ZwpRelativePointerManagerV1Global {
self: Rc<Self>,
id: ZwpRelativePointerManagerV1Id,
client: &Rc<Client>,
_version: u32,
_version: Version,
) -> Result<(), ZwpRelativePointerManagerV1Error> {
let obj = Rc::new(ZwpRelativePointerManagerV1 {
id,

View file

@ -5,7 +5,7 @@ use {
globals::{Global, GlobalName},
ifs::wl_shm_pool::{WlShmPool, WlShmPoolError},
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
wire::{wl_shm::*, WlShmId},
},
@ -21,7 +21,7 @@ pub struct WlShm {
_global: Rc<WlShmGlobal>,
id: WlShmId,
client: Rc<Client>,
version: u32,
version: Version,
pub tracker: Tracker<Self>,
}
@ -34,7 +34,7 @@ impl WlShmGlobal {
self: Rc<Self>,
id: WlShmId,
client: &Rc<Client>,
version: u32,
version: Version,
) -> Result<(), WlShmError> {
let obj = Rc::new(WlShm {
_global: self,

View file

@ -4,7 +4,7 @@ use {
globals::{Global, GlobalName},
ifs::wl_surface::wl_subsurface::{WlSubsurface, WlSubsurfaceError},
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
wire::{wl_subcompositor::*, WlSubcompositorId},
},
@ -34,7 +34,7 @@ impl WlSubcompositorGlobal {
self: Rc<Self>,
id: WlSubcompositorId,
client: &Rc<Client>,
_version: u32,
_version: Version,
) -> Result<(), WlSubcompositorError> {
let obj = Rc::new(WlSubcompositor {
id,

View file

@ -43,7 +43,7 @@ use {
zwp_linux_dmabuf_feedback_v1::ZwpLinuxDmabufFeedbackV1,
},
leaks::Tracker,
object::Object,
object::{Object, Version},
rect::{Rect, Region},
renderer::Renderer,
tree::{
@ -94,9 +94,9 @@ const INVALID_TRANSFORM: u32 = 1;
#[allow(dead_code)]
const INVALID_SIZE: u32 = 2;
const OFFSET_SINCE: u32 = 5;
const BUFFER_SCALE_SINCE: u32 = 6;
const TRANSFORM_SINCE: u32 = 6;
const OFFSET_SINCE: Version = Version(5);
const BUFFER_SCALE_SINCE: Version = Version(6);
const TRANSFORM_SINCE: Version = Version(6);
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum SurfaceRole {
@ -244,7 +244,7 @@ pub struct WlSurface {
xwayland_serial: Cell<Option<u64>>,
tearing_control: CloneCell<Option<Rc<WpTearingControlV1>>>,
tearing: Cell<bool>,
version: u32,
version: Version,
pub has_content_type_manager: Cell<bool>,
pub content_type: Cell<Option<ContentType>>,
pub drm_feedback: CopyHashMap<ZwpLinuxDmabufFeedbackV1Id, Rc<ZwpLinuxDmabufFeedbackV1>>,
@ -485,7 +485,7 @@ pub struct StackElement {
}
impl WlSurface {
pub fn new(id: WlSurfaceId, client: &Rc<Client>, version: u32) -> Self {
pub fn new(id: WlSurfaceId, client: &Rc<Client>, version: Version) -> Self {
Self {
id,
node_id: client.state.node_ids.next(),

View file

@ -15,7 +15,7 @@ use {
xdg_toplevel_drag_v1::XdgToplevelDragV1,
},
leaks::Tracker,
object::Object,
object::{Object, Version},
rect::Rect,
renderer::Renderer,
state::State,
@ -74,8 +74,8 @@ const CAP_FULLSCREEN: u32 = 3;
#[allow(dead_code)]
const CAP_MINIMIZE: u32 = 4;
pub const WM_CAPABILITIES_SINCE: u32 = 5;
pub const SUSPENDED_SINCE: u32 = 6;
pub const WM_CAPABILITIES_SINCE: Version = Version(5);
pub const SUSPENDED_SINCE: Version = Version(6);
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum Decoration {

View file

@ -4,7 +4,7 @@ use {
globals::{Global, GlobalName},
ifs::wl_surface::{x_surface::xwayland_surface_v1::XwaylandSurfaceV1, WlSurfaceError},
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
wire::{xwayland_shell_v1::*, WlSurfaceId, XwaylandShellV1Id},
},
@ -19,7 +19,7 @@ pub struct XwaylandShellV1Global {
pub struct XwaylandShellV1 {
id: XwaylandShellV1Id,
client: Rc<Client>,
pub version: u32,
pub version: Version,
pub tracker: Tracker<Self>,
}
@ -32,7 +32,7 @@ impl XwaylandShellV1Global {
self: Rc<Self>,
id: XwaylandShellV1Id,
client: &Rc<Client>,
version: u32,
version: Version,
) -> Result<(), XwaylandShellV1Error> {
let obj = Rc::new(XwaylandShellV1 {
id,

View file

@ -4,7 +4,7 @@ use {
globals::{Global, GlobalName},
ifs::wp_content_type_v1::WpContentTypeV1,
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
wire::{wp_content_type_manager_v1::*, WpContentTypeManagerV1Id},
},
@ -25,7 +25,7 @@ impl WpContentTypeManagerV1Global {
self: Rc<Self>,
id: WpContentTypeManagerV1Id,
client: &Rc<Client>,
version: u32,
version: Version,
) -> Result<(), WpContentTypeManagerV1Error> {
let mgr = Rc::new(WpContentTypeManagerV1 {
id,
@ -61,7 +61,7 @@ pub struct WpContentTypeManagerV1 {
pub id: WpContentTypeManagerV1Id,
pub client: Rc<Client>,
pub tracker: Tracker<Self>,
pub version: u32,
pub version: Version,
}
impl WpContentTypeManagerV1 {

View file

@ -4,7 +4,7 @@ use {
globals::{Global, GlobalName},
ifs::wp_cursor_shape_device_v1::WpCursorShapeDeviceV1,
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
wire::{wp_cursor_shape_manager_v1::*, WpCursorShapeManagerV1Id},
},
@ -25,7 +25,7 @@ impl WpCursorShapeManagerV1Global {
self: Rc<Self>,
id: WpCursorShapeManagerV1Id,
client: &Rc<Client>,
version: u32,
version: Version,
) -> Result<(), WpCursorShapeManagerV1Error> {
let mgr = Rc::new(WpCursorShapeManagerV1 {
id,
@ -61,7 +61,7 @@ pub struct WpCursorShapeManagerV1 {
pub id: WpCursorShapeManagerV1Id,
pub client: Rc<Client>,
pub tracker: Tracker<Self>,
pub version: u32,
pub version: Version,
}
impl WpCursorShapeManagerV1 {

View file

@ -4,7 +4,7 @@ use {
globals::{Global, GlobalName},
ifs::wl_surface::wp_fractional_scale_v1::{WpFractionalScaleError, WpFractionalScaleV1},
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
wire::{wp_fractional_scale_manager_v1::*, WpFractionalScaleManagerV1Id},
},
@ -31,7 +31,7 @@ impl WpFractionalScaleManagerV1Global {
self: Rc<Self>,
id: WpFractionalScaleManagerV1Id,
client: &Rc<Client>,
_version: u32,
_version: Version,
) -> Result<(), WpFractionalScaleManagerError> {
let obj = Rc::new(WpFractionalScaleManagerV1 {
id,

View file

@ -9,7 +9,7 @@ use {
wp_linux_drm_syncobj_timeline_v1::WpLinuxDrmSyncobjTimelineV1,
},
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
video::drm::sync_obj::SyncObj,
wire::{wp_linux_drm_syncobj_manager_v1::*, WpLinuxDrmSyncobjManagerV1Id},
@ -37,7 +37,7 @@ impl WpLinuxDrmSyncobjManagerV1Global {
self: Rc<Self>,
id: WpLinuxDrmSyncobjManagerV1Id,
client: &Rc<Client>,
_version: u32,
_version: Version,
) -> Result<(), WpLinuxDrmSyncobjManagerV1Error> {
let obj = Rc::new(WpLinuxDrmSyncobjManagerV1 {
id,

View file

@ -5,7 +5,7 @@ use {
globals::{Global, GlobalName},
ifs::wp_presentation_feedback::WpPresentationFeedback,
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
},
std::rc::Rc,
@ -26,7 +26,7 @@ impl WpPresentationGlobal {
self: Rc<Self>,
id: WpPresentationId,
client: &Rc<Client>,
_version: u32,
_version: Version,
) -> Result<(), WpPresentationError> {
let obj = Rc::new(WpPresentation {
id,

View file

@ -4,7 +4,7 @@ use {
globals::{Global, GlobalName},
ifs::wl_buffer::WlBuffer,
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
wire::{wp_single_pixel_buffer_manager_v1::*, WpSinglePixelBufferManagerV1Id},
},
@ -25,7 +25,7 @@ impl WpSinglePixelBufferManagerV1Global {
self: Rc<Self>,
id: WpSinglePixelBufferManagerV1Id,
client: &Rc<Client>,
_version: u32,
_version: Version,
) -> Result<(), WpSinglePixelBufferManagerV1Error> {
let obj = Rc::new(WpSinglePixelBufferManagerV1 {
id,

View file

@ -4,7 +4,7 @@ use {
globals::{Global, GlobalName},
ifs::wl_surface::wp_tearing_control_v1::{WpTearingControlV1, WpTearingControlV1Error},
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
wire::{
wp_tearing_control_manager_v1::{GET_TEARING_CONTROL, *},
@ -28,7 +28,7 @@ impl WpTearingControlManagerV1Global {
self: Rc<Self>,
id: WpTearingControlManagerV1Id,
client: &Rc<Client>,
_version: u32,
_version: Version,
) -> Result<(), WpTearingControlManagerV1Error> {
let obj = Rc::new(WpTearingControlManagerV1 {
id,

View file

@ -4,7 +4,7 @@ use {
globals::{Global, GlobalName},
ifs::wl_surface::wp_viewport::{WpViewport, WpViewportError},
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
wire::{wp_viewporter::*, WpViewporterId},
},
@ -25,7 +25,7 @@ impl WpViewporterGlobal {
self: Rc<Self>,
id: WpViewporterId,
client: &Rc<Client>,
_version: u32,
_version: Version,
) -> Result<(), WpViewporterError> {
let obj = Rc::new(WpViewporter {
id,

View file

@ -4,7 +4,7 @@ use {
globals::{Global, GlobalName},
ifs::xdg_activation_token_v1::XdgActivationTokenV1,
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::{
activation_token::ActivationToken,
buffd::{MsgParser, MsgParserError},
@ -29,7 +29,7 @@ impl XdgActivationV1Global {
self: Rc<Self>,
id: XdgActivationV1Id,
client: &Rc<Client>,
version: u32,
version: Version,
) -> Result<(), XdgActivationV1Error> {
let mgr = Rc::new(XdgActivationV1 {
id,
@ -61,7 +61,7 @@ pub struct XdgActivationV1 {
pub id: XdgActivationV1Id,
pub client: Rc<Client>,
pub tracker: Tracker<Self>,
pub version: u32,
pub version: Version,
}
impl XdgActivationV1 {

View file

@ -4,7 +4,7 @@ use {
globals::{Global, GlobalName},
ifs::xdg_toplevel_drag_v1::XdgToplevelDragV1,
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
wire::{xdg_toplevel_drag_manager_v1::*, XdgToplevelDragManagerV1Id},
},
@ -25,7 +25,7 @@ impl XdgToplevelDragManagerV1Global {
self: Rc<Self>,
id: XdgToplevelDragManagerV1Id,
client: &Rc<Client>,
version: u32,
version: Version,
) -> Result<(), XdgToplevelDragManagerV1Error> {
let mgr = Rc::new(XdgToplevelDragManagerV1 {
id,
@ -61,7 +61,7 @@ pub struct XdgToplevelDragManagerV1 {
pub id: XdgToplevelDragManagerV1Id,
pub client: Rc<Client>,
pub tracker: Tracker<Self>,
pub version: u32,
pub version: Version,
}
impl XdgToplevelDragManagerV1 {

View file

@ -7,7 +7,7 @@ use {
xdg_positioner::XdgPositioner,
},
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::{
buffd::{MsgParser, MsgParserError},
copyhashmap::CopyHashMap,
@ -37,7 +37,7 @@ pub struct XdgWmBaseGlobal {
pub struct XdgWmBase {
id: XdgWmBaseId,
client: Rc<Client>,
pub version: u32,
pub version: Version,
pub(super) surfaces: CopyHashMap<XdgSurfaceId, Rc<XdgSurface>>,
pub tracker: Tracker<Self>,
}
@ -51,7 +51,7 @@ impl XdgWmBaseGlobal {
self: Rc<Self>,
id: XdgWmBaseId,
client: &Rc<Client>,
version: u32,
version: Version,
) -> Result<(), XdgWmBaseError> {
let obj = Rc::new(XdgWmBase {
id,

View file

@ -4,7 +4,7 @@ use {
globals::{Global, GlobalName},
ifs::wl_surface::zwlr_layer_surface_v1::{ZwlrLayerSurfaceV1, ZwlrLayerSurfaceV1Error},
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
wire::{zwlr_layer_shell_v1::*, ZwlrLayerShellV1Id},
},
@ -24,7 +24,7 @@ pub struct ZwlrLayerShellV1Global {
pub struct ZwlrLayerShellV1 {
pub id: ZwlrLayerShellV1Id,
pub client: Rc<Client>,
pub version: u32,
pub version: Version,
pub tracker: Tracker<Self>,
}
@ -37,7 +37,7 @@ impl ZwlrLayerShellV1Global {
self: Rc<Self>,
id: ZwlrLayerShellV1Id,
client: &Rc<Client>,
version: u32,
version: Version,
) -> Result<(), ZwlrLayerShellV1Error> {
let obj = Rc::new(ZwlrLayerShellV1 {
id,

View file

@ -7,7 +7,7 @@ use {
wl_output::WlOutputGlobal,
},
leaks::Tracker,
object::Object,
object::{Object, Version},
rect::Rect,
utils::{
buffd::{MsgParser, MsgParserError},
@ -33,7 +33,7 @@ pub struct ZwlrScreencopyFrameV1 {
pub with_damage: Cell<bool>,
pub output_link: Cell<Option<LinkedNode<Rc<Self>>>>,
pub buffer: Cell<Option<Rc<WlBuffer>>>,
pub version: u32,
pub version: Version,
}
impl ZwlrScreencopyFrameV1 {

View file

@ -4,7 +4,7 @@ use {
globals::{Global, GlobalName},
ifs::zwlr_screencopy_frame_v1::ZwlrScreencopyFrameV1,
leaks::Tracker,
object::Object,
object::{Object, Version},
rect::Rect,
utils::buffd::{MsgParser, MsgParserError},
wire::{
@ -29,7 +29,7 @@ impl ZwlrScreencopyManagerV1Global {
self: Rc<Self>,
id: ZwlrScreencopyManagerV1Id,
client: &Rc<Client>,
version: u32,
version: Version,
) -> Result<(), ZwlrScreencopyManagerV1Error> {
let mgr = Rc::new(ZwlrScreencopyManagerV1 {
id,
@ -69,7 +69,7 @@ pub struct ZwlrScreencopyManagerV1 {
pub id: ZwlrScreencopyManagerV1Id,
pub client: Rc<Client>,
pub tracker: Tracker<Self>,
pub version: u32,
pub version: Version,
}
impl ZwlrScreencopyManagerV1 {

View file

@ -7,7 +7,7 @@ use {
zxdg_decoration_manager_v1::ZxdgDecorationManagerV1Error,
},
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
wire::{zwp_idle_inhibit_manager_v1::*, ZwpIdleInhibitManagerV1Id},
},
@ -28,7 +28,7 @@ impl ZwpIdleInhibitManagerV1Global {
self: Rc<Self>,
id: ZwpIdleInhibitManagerV1Id,
client: &Rc<Client>,
version: u32,
version: Version,
) -> Result<(), ZxdgDecorationManagerV1Error> {
let obj = Rc::new(ZwpIdleInhibitManagerV1 {
id,
@ -63,7 +63,7 @@ simple_add_global!(ZwpIdleInhibitManagerV1Global);
pub struct ZwpIdleInhibitManagerV1 {
pub id: ZwpIdleInhibitManagerV1Id,
pub client: Rc<Client>,
pub _version: u32,
pub _version: Version,
pub tracker: Tracker<Self>,
}

View file

@ -7,7 +7,7 @@ use {
zwp_linux_dmabuf_feedback_v1::ZwpLinuxDmabufFeedbackV1,
},
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
wire::{zwp_linux_dmabuf_v1::*, ZwpLinuxDmabufFeedbackV1Id, ZwpLinuxDmabufV1Id},
},
@ -28,7 +28,7 @@ impl ZwpLinuxDmabufV1Global {
self: Rc<Self>,
id: ZwpLinuxDmabufV1Id,
client: &Rc<Client>,
version: u32,
version: Version,
) -> Result<(), ZwpLinuxDmabufV1Error> {
let obj = Rc::new(ZwpLinuxDmabufV1 {
id,
@ -55,8 +55,8 @@ impl ZwpLinuxDmabufV1Global {
}
}
const MODIFIERS_SINCE_VERSION: u32 = 3;
const FEEDBACK_SINCE_VERSION: u32 = 4;
const MODIFIERS_SINCE_VERSION: Version = Version(3);
const FEEDBACK_SINCE_VERSION: Version = Version(4);
global_base!(
ZwpLinuxDmabufV1Global,
@ -79,7 +79,7 @@ simple_add_global!(ZwpLinuxDmabufV1Global);
pub struct ZwpLinuxDmabufV1 {
id: ZwpLinuxDmabufV1Id,
pub client: Rc<Client>,
pub version: u32,
pub version: Version,
pub tracker: Tracker<Self>,
}
@ -161,8 +161,8 @@ object_base! {
DESTROY => destroy,
CREATE_PARAMS => create_params,
GET_DEFAULT_FEEDBACK => get_default_feedback if self.version >= 4,
GET_SURFACE_FEEDBACK => get_surface_feedback if self.version >= 4,
GET_DEFAULT_FEEDBACK => get_default_feedback if self.version.0 >= 4,
GET_SURFACE_FEEDBACK => get_surface_feedback if self.version.0 >= 4,
}
impl Object for ZwpLinuxDmabufV1 {}

View file

@ -4,7 +4,7 @@ use {
globals::{Global, GlobalName},
ifs::zxdg_toplevel_decoration_v1::ZxdgToplevelDecorationV1,
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
wire::{zxdg_decoration_manager_v1::*, ZxdgDecorationManagerV1Id},
},
@ -25,7 +25,7 @@ impl ZxdgDecorationManagerV1Global {
self: Rc<Self>,
id: ZxdgDecorationManagerV1Id,
client: &Rc<Client>,
version: u32,
version: Version,
) -> Result<(), ZxdgDecorationManagerV1Error> {
let obj = Rc::new(ZxdgDecorationManagerV1 {
id,
@ -60,7 +60,7 @@ simple_add_global!(ZxdgDecorationManagerV1Global);
pub struct ZxdgDecorationManagerV1 {
id: ZxdgDecorationManagerV1Id,
client: Rc<Client>,
_version: u32,
_version: Version,
tracker: Tracker<Self>,
}

View file

@ -4,7 +4,7 @@ use {
globals::{Global, GlobalName},
ifs::zxdg_output_v1::ZxdgOutputV1,
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
wire::{zxdg_output_manager_v1::*, ZxdgOutputManagerV1Id},
},
@ -19,7 +19,7 @@ pub struct ZxdgOutputManagerV1Global {
pub struct ZxdgOutputManagerV1 {
pub id: ZxdgOutputManagerV1Id,
pub client: Rc<Client>,
pub version: u32,
pub version: Version,
pub tracker: Tracker<Self>,
}
@ -32,7 +32,7 @@ impl ZxdgOutputManagerV1Global {
self: Rc<Self>,
id: ZxdgOutputManagerV1Id,
client: &Rc<Client>,
version: u32,
version: Version,
) -> Result<(), ZxdgOutputManagerV1Error> {
let obj = Rc::new(ZxdgOutputManagerV1 {
id,

View file

@ -3,7 +3,7 @@ use {
client::{Client, ClientError},
ifs::wl_output::{WlOutput, SEND_DONE_SINCE},
leaks::Tracker,
object::Object,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
wire::{zxdg_output_v1::*, ZxdgOutputV1Id},
},
@ -11,14 +11,14 @@ use {
thiserror::Error,
};
pub const NAME_SINCE: u32 = 2;
pub const NAME_SINCE: Version = Version(2);
#[allow(dead_code)]
pub const DESCRIPTION_SINCE: u32 = 2;
pub const NO_DONE_SINCE: u32 = 3;
pub const DESCRIPTION_SINCE: Version = Version(2);
pub const NO_DONE_SINCE: Version = Version(3);
pub struct ZxdgOutputV1 {
pub id: ZxdgOutputV1Id,
pub version: u32,
pub version: Version,
pub client: Rc<Client>,
pub output: Rc<WlOutput>,
pub tracker: Tracker<Self>,

View file

@ -104,7 +104,7 @@ macro_rules! global_base {
self: std::rc::Rc<Self>,
client: &'a std::rc::Rc<crate::client::Client>,
id: crate::object::ObjectId,
version: u32,
version: crate::object::Version,
) -> Result<(), crate::globals::GlobalsError> {
if let Err(e) = self.bind_(id.into(), client, version) {
return Err(crate::globals::GlobalsError::GlobalError(e.into()));

View file

@ -2,6 +2,7 @@ use {
crate::{client::ClientError, utils::buffd::MsgParser, wire::WlDisplayId},
std::{
any::Any,
cmp::Ordering,
fmt::{Display, Formatter},
rc::Rc,
},
@ -54,3 +55,22 @@ impl Interface {
self.0
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
pub struct Version(pub u32);
impl Version {
pub const ALL: Version = Version(0);
}
impl PartialEq<u32> for Version {
fn eq(&self, other: &u32) -> bool {
self.0 == *other
}
}
impl PartialOrd<u32> for Version {
fn partial_cmp(&self, other: &u32) -> Option<Ordering> {
self.0.partial_cmp(other)
}
}