diff --git a/src/client/tasks.rs b/src/client/tasks.rs index 64e9f143..74ed4f3a 100644 --- a/src/client/tasks.rs +++ b/src/client/tasks.rs @@ -55,10 +55,6 @@ async fn receive(data: Rc) { } }; // log::trace!("obj: {}, request: {}, len: {}", obj_id, request, len); - if request >= obj.num_requests() { - data.invalid_request(&*obj, request); - return Err(ClientError::InvalidMethod); - } if len < 8 { return Err(ClientError::MessageSizeTooSmall); } @@ -76,6 +72,12 @@ async fn receive(data: Rc) { // log::trace!("{:x?}", data_buf); let parser = MsgParser::new(&mut buf, &data_buf[..]); if let Err(e) = obj.handle_request(request, parser) { + if let ClientError::InvalidMethod = e { + if let Ok(obj) = data.objects.get_obj(obj_id) { + data.invalid_request(&*obj, request); + return Err(e); + } + } return Err(ClientError::RequestError(Box::new(e))); } // data.flush(); diff --git a/src/ifs/ext_session_lock_manager_v1.rs b/src/ifs/ext_session_lock_manager_v1.rs index a7451f87..a81a8aac 100644 --- a/src/ifs/ext_session_lock_manager_v1.rs +++ b/src/ifs/ext_session_lock_manager_v1.rs @@ -104,17 +104,13 @@ impl Global for ExtSessionLockManagerV1Global { simple_add_global!(ExtSessionLockManagerV1Global); object_base! { - ExtSessionLockManagerV1; + self = ExtSessionLockManagerV1; DESTROY => destroy, LOCK => lock, } -impl Object for ExtSessionLockManagerV1 { - fn num_requests(&self) -> u32 { - LOCK + 1 - } -} +impl Object for ExtSessionLockManagerV1 {} simple_add_obj!(ExtSessionLockManagerV1); diff --git a/src/ifs/ext_session_lock_v1.rs b/src/ifs/ext_session_lock_v1.rs index 0d404bb0..f04e996e 100644 --- a/src/ifs/ext_session_lock_v1.rs +++ b/src/ifs/ext_session_lock_v1.rs @@ -98,7 +98,7 @@ impl ExtSessionLockV1 { } object_base! { - ExtSessionLockV1; + self = ExtSessionLockV1; DESTROY => destroy, GET_LOCK_SURFACE => get_lock_surface, @@ -106,10 +106,6 @@ object_base! { } impl Object for ExtSessionLockV1 { - fn num_requests(&self) -> u32 { - UNLOCK_AND_DESTROY + 1 - } - fn break_loops(&self) { if !self.finished.get() { self.client.state.lock.lock.take(); diff --git a/src/ifs/ipc/wl_data_device.rs b/src/ifs/ipc/wl_data_device.rs index ff66848a..6a8b0b08 100644 --- a/src/ifs/ipc/wl_data_device.rs +++ b/src/ifs/ipc/wl_data_device.rs @@ -199,7 +199,7 @@ impl IpcVtable for ClipboardIpc { } fn create_xwm_source(client: &Rc) -> Self::Source { - WlDataSource::new(WlDataSourceId::NONE, client, true) + WlDataSource::new(WlDataSourceId::NONE, client, true, 3) } fn set_seat_selection( @@ -287,18 +287,14 @@ impl IpcVtable for ClipboardIpc { } object_base! { - WlDataDevice; + self = WlDataDevice; START_DRAG => start_drag, SET_SELECTION => set_selection, - RELEASE => release, + RELEASE => release if self.version >= 2, } impl Object for WlDataDevice { - fn num_requests(&self) -> u32 { - RELEASE + 1 - } - fn break_loops(&self) { break_device_loops::(self); self.seat.remove_data_device(self); diff --git a/src/ifs/ipc/wl_data_device_manager.rs b/src/ifs/ipc/wl_data_device_manager.rs index dc4178c7..5feaa5dd 100644 --- a/src/ifs/ipc/wl_data_device_manager.rs +++ b/src/ifs/ipc/wl_data_device_manager.rs @@ -61,7 +61,7 @@ impl WlDataDeviceManager { parser: MsgParser<'_, '_>, ) -> Result<(), WlDataDeviceManagerError> { let req: CreateDataSource = self.client.parse(self, parser)?; - let res = Rc::new(WlDataSource::new(req.id, &self.client, false)); + let res = Rc::new(WlDataSource::new(req.id, &self.client, false, self.version)); track!(self.client, res); self.client.add_client_obj(&res)?; Ok(()) @@ -106,17 +106,13 @@ impl Global for WlDataDeviceManagerGlobal { simple_add_global!(WlDataDeviceManagerGlobal); object_base! { - WlDataDeviceManager; + self = WlDataDeviceManager; CREATE_DATA_SOURCE => create_data_source, GET_DATA_DEVICE => get_data_device, } -impl Object for WlDataDeviceManager { - fn num_requests(&self) -> u32 { - GET_DATA_DEVICE + 1 - } -} +impl Object for WlDataDeviceManager {} simple_add_obj!(WlDataDeviceManager); diff --git a/src/ifs/ipc/wl_data_offer.rs b/src/ifs/ipc/wl_data_offer.rs index d55645ee..83d16834 100644 --- a/src/ifs/ipc/wl_data_offer.rs +++ b/src/ifs/ipc/wl_data_offer.rs @@ -168,20 +168,16 @@ impl WlDataOffer { } object_base! { - WlDataOffer; + self = WlDataOffer; ACCEPT => accept, RECEIVE => receive, DESTROY => destroy, - FINISH => finish, - SET_ACTIONS => set_actions, + FINISH => finish if self.device.version >= 3, + SET_ACTIONS => set_actions if self.device.version >= 3, } impl Object for WlDataOffer { - fn num_requests(&self) -> u32 { - SET_ACTIONS + 1 - } - fn break_loops(&self) { break_offer_loops::(self); } diff --git a/src/ifs/ipc/wl_data_source.rs b/src/ifs/ipc/wl_data_source.rs index fbe92ff2..0dd9b69b 100644 --- a/src/ifs/ipc/wl_data_source.rs +++ b/src/ifs/ipc/wl_data_source.rs @@ -30,15 +30,17 @@ const INVALID_SOURCE: u32 = 1; pub struct WlDataSource { pub id: WlDataSourceId, pub data: SourceData, + pub version: u32, pub tracker: Tracker, } impl WlDataSource { - pub fn new(id: WlDataSourceId, client: &Rc, is_xwm: bool) -> Self { + pub fn new(id: WlDataSourceId, client: &Rc, is_xwm: bool, version: u32) -> Self { Self { id, tracker: Default::default(), data: SourceData::new(client, is_xwm), + version, } } @@ -196,18 +198,14 @@ impl WlDataSource { } object_base! { - WlDataSource; + self = WlDataSource; OFFER => offer, DESTROY => destroy, - SET_ACTIONS => set_actions, + SET_ACTIONS => set_actions if self.version >= 3, } impl Object for WlDataSource { - fn num_requests(&self) -> u32 { - SET_ACTIONS + 1 - } - fn break_loops(&self) { break_source_loops::(self); } diff --git a/src/ifs/ipc/zwp_primary_selection_device_manager_v1.rs b/src/ifs/ipc/zwp_primary_selection_device_manager_v1.rs index c0549def..1b33871b 100644 --- a/src/ifs/ipc/zwp_primary_selection_device_manager_v1.rs +++ b/src/ifs/ipc/zwp_primary_selection_device_manager_v1.rs @@ -113,18 +113,14 @@ impl Global for ZwpPrimarySelectionDeviceManagerV1Global { simple_add_global!(ZwpPrimarySelectionDeviceManagerV1Global); object_base! { - ZwpPrimarySelectionDeviceManagerV1; + self = ZwpPrimarySelectionDeviceManagerV1; CREATE_SOURCE => create_source, GET_DEVICE => get_data_device, DESTROY => destroy, } -impl Object for ZwpPrimarySelectionDeviceManagerV1 { - fn num_requests(&self) -> u32 { - DESTROY + 1 - } -} +impl Object for ZwpPrimarySelectionDeviceManagerV1 {} simple_add_obj!(ZwpPrimarySelectionDeviceManagerV1); diff --git a/src/ifs/ipc/zwp_primary_selection_device_v1.rs b/src/ifs/ipc/zwp_primary_selection_device_v1.rs index a75112e8..f5e4eb2a 100644 --- a/src/ifs/ipc/zwp_primary_selection_device_v1.rs +++ b/src/ifs/ipc/zwp_primary_selection_device_v1.rs @@ -231,17 +231,13 @@ impl IpcVtable for PrimarySelectionIpc { } object_base! { - ZwpPrimarySelectionDeviceV1; + self = ZwpPrimarySelectionDeviceV1; SET_SELECTION => set_selection, DESTROY => destroy, } impl Object for ZwpPrimarySelectionDeviceV1 { - fn num_requests(&self) -> u32 { - DESTROY + 1 - } - fn break_loops(&self) { break_device_loops::(self); self.seat.remove_primary_selection_device(self); diff --git a/src/ifs/ipc/zwp_primary_selection_offer_v1.rs b/src/ifs/ipc/zwp_primary_selection_offer_v1.rs index db02a0b0..c70d6d82 100644 --- a/src/ifs/ipc/zwp_primary_selection_offer_v1.rs +++ b/src/ifs/ipc/zwp_primary_selection_offer_v1.rs @@ -63,17 +63,13 @@ impl ZwpPrimarySelectionOfferV1 { } object_base! { - ZwpPrimarySelectionOfferV1; + self = ZwpPrimarySelectionOfferV1; RECEIVE => receive, DESTROY => destroy, } impl Object for ZwpPrimarySelectionOfferV1 { - fn num_requests(&self) -> u32 { - DESTROY + 1 - } - fn break_loops(&self) { break_offer_loops::(self); } diff --git a/src/ifs/ipc/zwp_primary_selection_source_v1.rs b/src/ifs/ipc/zwp_primary_selection_source_v1.rs index ef42148f..a563f9fe 100644 --- a/src/ifs/ipc/zwp_primary_selection_source_v1.rs +++ b/src/ifs/ipc/zwp_primary_selection_source_v1.rs @@ -80,17 +80,13 @@ impl ZwpPrimarySelectionSourceV1 { } object_base! { - ZwpPrimarySelectionSourceV1; + self = ZwpPrimarySelectionSourceV1; OFFER => offer, DESTROY => destroy, } impl Object for ZwpPrimarySelectionSourceV1 { - fn num_requests(&self) -> u32 { - DESTROY + 1 - } - fn break_loops(&self) { break_source_loops::(self); } diff --git a/src/ifs/jay_compositor.rs b/src/ifs/jay_compositor.rs index 2794d7e2..47da44bf 100644 --- a/src/ifs/jay_compositor.rs +++ b/src/ifs/jay_compositor.rs @@ -310,7 +310,7 @@ impl JayCompositor { } object_base! { - JayCompositor; + self = JayCompositor; DESTROY => destroy, GET_LOG_FILE => get_log_file, @@ -330,11 +330,7 @@ object_base! { CREATE_SCREENCAST => create_screencast, } -impl Object for JayCompositor { - fn num_requests(&self) -> u32 { - CREATE_SCREENCAST + 1 - } -} +impl Object for JayCompositor {} simple_add_obj!(JayCompositor); diff --git a/src/ifs/jay_idle.rs b/src/ifs/jay_idle.rs index b0286094..b36bbbd8 100644 --- a/src/ifs/jay_idle.rs +++ b/src/ifs/jay_idle.rs @@ -58,17 +58,13 @@ impl JayIdle { } object_base! { - JayIdle; + self = JayIdle; GET_STATUS => get_status, SET_INTERVAL => set_interval, } -impl Object for JayIdle { - fn num_requests(&self) -> u32 { - SET_INTERVAL + 1 - } -} +impl Object for JayIdle {} simple_add_obj!(JayIdle); diff --git a/src/ifs/jay_log_file.rs b/src/ifs/jay_log_file.rs index ebb81253..3c75e23e 100644 --- a/src/ifs/jay_log_file.rs +++ b/src/ifs/jay_log_file.rs @@ -41,16 +41,12 @@ impl JayLogFile { } object_base! { - JayLogFile; + self = JayLogFile; DESTROY => destroy, } -impl Object for JayLogFile { - fn num_requests(&self) -> u32 { - DESTROY + 1 - } -} +impl Object for JayLogFile {} simple_add_obj!(JayLogFile); diff --git a/src/ifs/jay_output.rs b/src/ifs/jay_output.rs index 088d246e..6dde371c 100644 --- a/src/ifs/jay_output.rs +++ b/src/ifs/jay_output.rs @@ -50,16 +50,12 @@ impl JayOutput { } object_base! { - JayOutput; + self = JayOutput; DESTROY => destroy, } impl Object for JayOutput { - fn num_requests(&self) -> u32 { - 1 - } - fn break_loops(&self) { self.remove_from_node(); } diff --git a/src/ifs/jay_pointer.rs b/src/ifs/jay_pointer.rs index 2e31357f..6f9c219e 100644 --- a/src/ifs/jay_pointer.rs +++ b/src/ifs/jay_pointer.rs @@ -49,17 +49,13 @@ impl JayPointer { } object_base! { - JayPointer; + self = JayPointer; DESTROY => destroy, SET_KNOWN_CURSOR => set_known_cursor, } -impl Object for JayPointer { - fn num_requests(&self) -> u32 { - SET_KNOWN_CURSOR + 1 - } -} +impl Object for JayPointer {} simple_add_obj!(JayPointer); diff --git a/src/ifs/jay_render_ctx.rs b/src/ifs/jay_render_ctx.rs index 3b58c2a0..17b16166 100644 --- a/src/ifs/jay_render_ctx.rs +++ b/src/ifs/jay_render_ctx.rs @@ -58,16 +58,12 @@ impl JayRenderCtx { } object_base! { - JayRenderCtx; + self = JayRenderCtx; DESTROY => destroy, } impl Object for JayRenderCtx { - fn num_requests(&self) -> u32 { - DESTROY + 1 - } - fn break_loops(&self) { self.remove_from_state(); } diff --git a/src/ifs/jay_screencast.rs b/src/ifs/jay_screencast.rs index 951a12c4..6097ac67 100644 --- a/src/ifs/jay_screencast.rs +++ b/src/ifs/jay_screencast.rs @@ -408,7 +408,7 @@ impl JayScreencast { } object_base! { - JayScreencast; + self = JayScreencast; DESTROY => destroy, SET_OUTPUT => set_output, @@ -424,10 +424,6 @@ object_base! { } impl Object for JayScreencast { - fn num_requests(&self) -> u32 { - RELEASE_BUFFER + 1 - } - fn break_loops(&self) { self.detach(); } diff --git a/src/ifs/jay_screenshot.rs b/src/ifs/jay_screenshot.rs index 8b9b5518..6ef3c7fc 100644 --- a/src/ifs/jay_screenshot.rs +++ b/src/ifs/jay_screenshot.rs @@ -45,13 +45,9 @@ impl JayScreenshot { } object_base! { - JayScreenshot; + self = JayScreenshot; } -impl Object for JayScreenshot { - fn num_requests(&self) -> u32 { - 0 - } -} +impl Object for JayScreenshot {} simple_add_obj!(JayScreenshot); diff --git a/src/ifs/jay_seat_events.rs b/src/ifs/jay_seat_events.rs index 42293735..e77c948e 100644 --- a/src/ifs/jay_seat_events.rs +++ b/src/ifs/jay_seat_events.rs @@ -125,14 +125,10 @@ impl JaySeatEvents { } object_base! { - JaySeatEvents; + self = JaySeatEvents; } impl Object for JaySeatEvents { - fn num_requests(&self) -> u32 { - 0 - } - fn break_loops(&self) { self.client .state diff --git a/src/ifs/jay_workspace.rs b/src/ifs/jay_workspace.rs index 96080b42..55009f28 100644 --- a/src/ifs/jay_workspace.rs +++ b/src/ifs/jay_workspace.rs @@ -73,16 +73,12 @@ impl JayWorkspace { } object_base! { - JayWorkspace; + self = JayWorkspace; DESTROY => destroy, } impl Object for JayWorkspace { - fn num_requests(&self) -> u32 { - DESTROY + 1 - } - fn break_loops(&self) { self.remove_from_node(); } diff --git a/src/ifs/jay_workspace_watcher.rs b/src/ifs/jay_workspace_watcher.rs index 0422adf0..430f8ab3 100644 --- a/src/ifs/jay_workspace_watcher.rs +++ b/src/ifs/jay_workspace_watcher.rs @@ -63,16 +63,12 @@ impl JayWorkspaceWatcher { } object_base! { - JayWorkspaceWatcher; + self = JayWorkspaceWatcher; DESTROY => destroy, } impl Object for JayWorkspaceWatcher { - fn num_requests(&self) -> u32 { - DESTROY + 1 - } - fn break_loops(&self) { self.remove_from_state(); } diff --git a/src/ifs/org_kde_kwin_server_decoration.rs b/src/ifs/org_kde_kwin_server_decoration.rs index 910ec715..e02bb893 100644 --- a/src/ifs/org_kde_kwin_server_decoration.rs +++ b/src/ifs/org_kde_kwin_server_decoration.rs @@ -65,17 +65,13 @@ impl OrgKdeKwinServerDecoration { } object_base! { - OrgKdeKwinServerDecoration; + self = OrgKdeKwinServerDecoration; RELEASE => release, REQUEST_MODE => request_mode, } -impl Object for OrgKdeKwinServerDecoration { - fn num_requests(&self) -> u32 { - REQUEST_MODE + 1 - } -} +impl Object for OrgKdeKwinServerDecoration {} simple_add_obj!(OrgKdeKwinServerDecoration); diff --git a/src/ifs/org_kde_kwin_server_decoration_manager.rs b/src/ifs/org_kde_kwin_server_decoration_manager.rs index 93488580..d01ae3ce 100644 --- a/src/ifs/org_kde_kwin_server_decoration_manager.rs +++ b/src/ifs/org_kde_kwin_server_decoration_manager.rs @@ -92,16 +92,12 @@ impl OrgKdeKwinServerDecorationManager { } object_base! { - OrgKdeKwinServerDecorationManager; + self = OrgKdeKwinServerDecorationManager; CREATE => create, } -impl Object for OrgKdeKwinServerDecorationManager { - fn num_requests(&self) -> u32 { - CREATE + 1 - } -} +impl Object for OrgKdeKwinServerDecorationManager {} simple_add_obj!(OrgKdeKwinServerDecorationManager); diff --git a/src/ifs/wl_buffer.rs b/src/ifs/wl_buffer.rs index 0e4c7139..5926435f 100644 --- a/src/ifs/wl_buffer.rs +++ b/src/ifs/wl_buffer.rs @@ -204,16 +204,12 @@ impl WlBuffer { } object_base! { - WlBuffer; + self = WlBuffer; DESTROY => destroy, } -impl Object for WlBuffer { - fn num_requests(&self) -> u32 { - DESTROY + 1 - } -} +impl Object for WlBuffer {} dedicated_add_obj!(WlBuffer, WlBufferId, buffers); diff --git a/src/ifs/wl_callback.rs b/src/ifs/wl_callback.rs index d42477c1..470feef0 100644 --- a/src/ifs/wl_callback.rs +++ b/src/ifs/wl_callback.rs @@ -33,14 +33,10 @@ impl WlCallback { } object_base! { - WlCallback; + self = WlCallback; } -impl Object for WlCallback { - fn num_requests(&self) -> u32 { - 0 - } -} +impl Object for WlCallback {} simple_add_obj!(WlCallback); diff --git a/src/ifs/wl_compositor.rs b/src/ifs/wl_compositor.rs index 0156c46a..97086f5a 100644 --- a/src/ifs/wl_compositor.rs +++ b/src/ifs/wl_compositor.rs @@ -87,17 +87,13 @@ impl Global for WlCompositorGlobal { simple_add_global!(WlCompositorGlobal); object_base! { - WlCompositor; + self = WlCompositor; CREATE_SURFACE => create_surface, CREATE_REGION => create_region, } -impl Object for WlCompositor { - fn num_requests(&self) -> u32 { - CREATE_REGION + 1 - } -} +impl Object for WlCompositor {} simple_add_obj!(WlCompositor); diff --git a/src/ifs/wl_display.rs b/src/ifs/wl_display.rs index 9a990015..b228c3bc 100644 --- a/src/ifs/wl_display.rs +++ b/src/ifs/wl_display.rs @@ -89,17 +89,13 @@ impl WlDisplay { } object_base! { - WlDisplay; + self = WlDisplay; SYNC => sync, GET_REGISTRY => get_registry, } -impl Object for WlDisplay { - fn num_requests(&self) -> u32 { - GET_REGISTRY + 1 - } -} +impl Object for WlDisplay {} #[derive(Debug, Error)] pub enum WlDisplayError { diff --git a/src/ifs/wl_drm.rs b/src/ifs/wl_drm.rs index bc791506..f38b4e55 100644 --- a/src/ifs/wl_drm.rs +++ b/src/ifs/wl_drm.rs @@ -38,7 +38,7 @@ impl WlDrmGlobal { let obj = Rc::new(WlDrm { id, client: client.clone(), - _version: version, + version, tracker: Default::default(), }); track!(client, obj); @@ -68,7 +68,7 @@ simple_add_global!(WlDrmGlobal); pub struct WlDrm { id: WlDrmId, pub client: Rc, - _version: u32, + version: u32, tracker: Tracker, } @@ -161,19 +161,15 @@ impl WlDrm { } object_base! { - WlDrm; + self = WlDrm; AUTHENTICATE => authenticate, CREATE_BUFFER => create_buffer, CREATE_PLANAR_BUFFER => create_planar_buffer, - CREATE_PRIME_BUFFER => create_prime_buffer, + CREATE_PRIME_BUFFER => create_prime_buffer if self.version >= 2, } -impl Object for WlDrm { - fn num_requests(&self) -> u32 { - CREATE_PRIME_BUFFER + 1 - } -} +impl Object for WlDrm {} simple_add_obj!(WlDrm); diff --git a/src/ifs/wl_output.rs b/src/ifs/wl_output.rs index 9085f62b..45947675 100644 --- a/src/ifs/wl_output.rs +++ b/src/ifs/wl_output.rs @@ -362,20 +362,12 @@ impl WlOutput { } object_base! { - WlOutput; + self = WlOutput; - RELEASE => release, + RELEASE => release if self.version >= 3, } impl Object for WlOutput { - fn num_requests(&self) -> u32 { - if self.version < 3 { - 0 - } else { - RELEASE + 1 - } - } - fn break_loops(&self) { self.xdg_outputs.clear(); self.remove_binding(); diff --git a/src/ifs/wl_region.rs b/src/ifs/wl_region.rs index 8d69c152..06a8c3ad 100644 --- a/src/ifs/wl_region.rs +++ b/src/ifs/wl_region.rs @@ -60,18 +60,14 @@ impl WlRegion { } object_base! { - WlRegion; + self = WlRegion; DESTROY => destroy, ADD => add, SUBTRACT => subtract, } -impl Object for WlRegion { - fn num_requests(&self) -> u32 { - SUBTRACT + 1 - } -} +impl Object for WlRegion {} dedicated_add_obj!(WlRegion, WlRegionId, regions); diff --git a/src/ifs/wl_registry.rs b/src/ifs/wl_registry.rs index 9391d375..698fd95a 100644 --- a/src/ifs/wl_registry.rs +++ b/src/ifs/wl_registry.rs @@ -68,16 +68,12 @@ impl WlRegistry { } object_base! { - WlRegistry; + self = WlRegistry; BIND => bind, } -impl Object for WlRegistry { - fn num_requests(&self) -> u32 { - BIND + 1 - } -} +impl Object for WlRegistry {} dedicated_add_obj!(WlRegistry, WlRegistryId, registries); diff --git a/src/ifs/wl_seat.rs b/src/ifs/wl_seat.rs index 0bccd0f8..d68f9f9b 100644 --- a/src/ifs/wl_seat.rs +++ b/src/ifs/wl_seat.rs @@ -1020,23 +1020,15 @@ impl WlSeat { } object_base! { - WlSeat; + self = WlSeat; GET_POINTER => get_pointer, GET_KEYBOARD => get_keyboard, GET_TOUCH => get_touch, - RELEASE => release, + RELEASE => release if self.version >= 5, } impl Object for WlSeat { - fn num_requests(&self) -> u32 { - if self.version < 5 { - GET_TOUCH + 1 - } else { - RELEASE + 1 - } - } - fn break_loops(&self) { { let mut bindings = self.global.bindings.borrow_mut(); diff --git a/src/ifs/wl_seat/wl_keyboard.rs b/src/ifs/wl_seat/wl_keyboard.rs index 80937845..8987bead 100644 --- a/src/ifs/wl_seat/wl_keyboard.rs +++ b/src/ifs/wl_seat/wl_keyboard.rs @@ -110,16 +110,12 @@ impl WlKeyboard { } object_base! { - WlKeyboard; + self = WlKeyboard; - RELEASE => release, + RELEASE => release if self.seat.version >= 3, } -impl Object for WlKeyboard { - fn num_requests(&self) -> u32 { - RELEASE + 1 - } -} +impl Object for WlKeyboard {} simple_add_obj!(WlKeyboard); diff --git a/src/ifs/wl_seat/wl_pointer.rs b/src/ifs/wl_seat/wl_pointer.rs index 6bd04cc0..49149d57 100644 --- a/src/ifs/wl_seat/wl_pointer.rs +++ b/src/ifs/wl_seat/wl_pointer.rs @@ -214,17 +214,13 @@ impl WlPointer { } object_base! { - WlPointer; + self = WlPointer; SET_CURSOR => set_cursor, - RELEASE => release, + RELEASE => release if self.seat.version >= 3, } -impl Object for WlPointer { - fn num_requests(&self) -> u32 { - RELEASE + 1 - } -} +impl Object for WlPointer {} dedicated_add_obj!(WlPointer, WlPointerId, pointers); diff --git a/src/ifs/wl_seat/wl_touch.rs b/src/ifs/wl_seat/wl_touch.rs index 3a470769..502c7257 100644 --- a/src/ifs/wl_seat/wl_touch.rs +++ b/src/ifs/wl_seat/wl_touch.rs @@ -49,16 +49,12 @@ impl WlTouch { } object_base! { - WlTouch; + self = WlTouch; - RELEASE => release, + RELEASE => release if self.seat.version >= 3, } -impl Object for WlTouch { - fn num_requests(&self) -> u32 { - RELEASE + 1 - } -} +impl Object for WlTouch {} simple_add_obj!(WlTouch); diff --git a/src/ifs/wl_seat/zwp_pointer_constraints_v1.rs b/src/ifs/wl_seat/zwp_pointer_constraints_v1.rs index 8d84a73c..1062d55a 100644 --- a/src/ifs/wl_seat/zwp_pointer_constraints_v1.rs +++ b/src/ifs/wl_seat/zwp_pointer_constraints_v1.rs @@ -278,18 +278,14 @@ impl Global for ZwpPointerConstraintsV1Global { simple_add_global!(ZwpPointerConstraintsV1Global); object_base! { - ZwpPointerConstraintsV1; + self = ZwpPointerConstraintsV1; DESTROY => destroy, LOCK_POINTER => lock_pointer, CONFINE_POINTER => confine_pointer, } -impl Object for ZwpPointerConstraintsV1 { - fn num_requests(&self) -> u32 { - CONFINE_POINTER + 1 - } -} +impl Object for ZwpPointerConstraintsV1 {} simple_add_obj!(ZwpPointerConstraintsV1); diff --git a/src/ifs/wl_seat/zwp_pointer_constraints_v1/zwp_confined_pointer_v1.rs b/src/ifs/wl_seat/zwp_pointer_constraints_v1/zwp_confined_pointer_v1.rs index 7aba3296..e01a0001 100644 --- a/src/ifs/wl_seat/zwp_pointer_constraints_v1/zwp_confined_pointer_v1.rs +++ b/src/ifs/wl_seat/zwp_pointer_constraints_v1/zwp_confined_pointer_v1.rs @@ -47,17 +47,13 @@ impl ConstraintOwner for ZwpConfinedPointerV1 { } object_base! { - ZwpConfinedPointerV1; + self = ZwpConfinedPointerV1; DESTROY => destroy, SET_REGION => set_region, } impl Object for ZwpConfinedPointerV1 { - fn num_requests(&self) -> u32 { - SET_REGION + 1 - } - fn break_loops(&self) { self.constraint.detach(); } diff --git a/src/ifs/wl_seat/zwp_pointer_constraints_v1/zwp_locked_pointer_v1.rs b/src/ifs/wl_seat/zwp_pointer_constraints_v1/zwp_locked_pointer_v1.rs index d5eb5806..3c5207b4 100644 --- a/src/ifs/wl_seat/zwp_pointer_constraints_v1/zwp_locked_pointer_v1.rs +++ b/src/ifs/wl_seat/zwp_pointer_constraints_v1/zwp_locked_pointer_v1.rs @@ -53,7 +53,7 @@ impl ConstraintOwner for ZwpLockedPointerV1 { } object_base! { - ZwpLockedPointerV1; + self = ZwpLockedPointerV1; DESTROY => destroy, SET_CURSOR_POSITION_HINT => set_cursor_position_hint, @@ -61,10 +61,6 @@ object_base! { } impl Object for ZwpLockedPointerV1 { - fn num_requests(&self) -> u32 { - SET_REGION + 1 - } - fn break_loops(&self) { self.constraint.detach(); } diff --git a/src/ifs/wl_seat/zwp_relative_pointer_manager_v1.rs b/src/ifs/wl_seat/zwp_relative_pointer_manager_v1.rs index 9f0cf69f..035f3ae1 100644 --- a/src/ifs/wl_seat/zwp_relative_pointer_manager_v1.rs +++ b/src/ifs/wl_seat/zwp_relative_pointer_manager_v1.rs @@ -89,17 +89,13 @@ impl ZwpRelativePointerManagerV1 { } object_base! { - ZwpRelativePointerManagerV1; + self = ZwpRelativePointerManagerV1; DESTROY => destroy, GET_RELATIVE_POINTER => get_relative_pointer, } -impl Object for ZwpRelativePointerManagerV1 { - fn num_requests(&self) -> u32 { - GET_RELATIVE_POINTER + 1 - } -} +impl Object for ZwpRelativePointerManagerV1 {} simple_add_obj!(ZwpRelativePointerManagerV1); diff --git a/src/ifs/wl_seat/zwp_relative_pointer_v1.rs b/src/ifs/wl_seat/zwp_relative_pointer_v1.rs index e853e705..277e201a 100644 --- a/src/ifs/wl_seat/zwp_relative_pointer_v1.rs +++ b/src/ifs/wl_seat/zwp_relative_pointer_v1.rs @@ -48,16 +48,12 @@ impl ZwpRelativePointerV1 { } object_base! { - ZwpRelativePointerV1; + self = ZwpRelativePointerV1; DESTROY => destroy, } -impl Object for ZwpRelativePointerV1 { - fn num_requests(&self) -> u32 { - DESTROY + 1 - } -} +impl Object for ZwpRelativePointerV1 {} simple_add_obj!(ZwpRelativePointerV1); diff --git a/src/ifs/wl_shm.rs b/src/ifs/wl_shm.rs index 90ac412e..cc6b11dd 100644 --- a/src/ifs/wl_shm.rs +++ b/src/ifs/wl_shm.rs @@ -21,6 +21,7 @@ pub struct WlShm { _global: Rc, id: WlShmId, client: Rc, + version: u32, pub tracker: Tracker, } @@ -33,12 +34,13 @@ impl WlShmGlobal { self: Rc, id: WlShmId, client: &Rc, - _version: u32, + version: u32, ) -> Result<(), WlShmError> { let obj = Rc::new(WlShm { _global: self, id, client: client.clone(), + version, tracker: Default::default(), }); track!(client, obj); @@ -94,17 +96,13 @@ impl Global for WlShmGlobal { simple_add_global!(WlShmGlobal); object_base! { - WlShm; + self = WlShm; CREATE_POOL => create_pool, - RELEASE => release, + RELEASE => release if self.version >= 2, } -impl Object for WlShm { - fn num_requests(&self) -> u32 { - RELEASE + 1 - } -} +impl Object for WlShm {} simple_add_obj!(WlShm); diff --git a/src/ifs/wl_shm_pool.rs b/src/ifs/wl_shm_pool.rs index 3830ec46..8d512774 100644 --- a/src/ifs/wl_shm_pool.rs +++ b/src/ifs/wl_shm_pool.rs @@ -87,18 +87,14 @@ impl WlShmPool { } object_base! { - WlShmPool; + self = WlShmPool; CREATE_BUFFER => create_buffer, DESTROY => destroy, RESIZE => resize, } -impl Object for WlShmPool { - fn num_requests(&self) -> u32 { - RESIZE + 1 - } -} +impl Object for WlShmPool {} simple_add_obj!(WlShmPool); diff --git a/src/ifs/wl_subcompositor.rs b/src/ifs/wl_subcompositor.rs index 350ac29f..034e9257 100644 --- a/src/ifs/wl_subcompositor.rs +++ b/src/ifs/wl_subcompositor.rs @@ -81,17 +81,13 @@ impl Global for WlSubcompositorGlobal { simple_add_global!(WlSubcompositorGlobal); object_base! { - WlSubcompositor; + self = WlSubcompositor; DESTROY => destroy, GET_SUBSURFACE => get_subsurface, } -impl Object for WlSubcompositor { - fn num_requests(&self) -> u32 { - GET_SUBSURFACE + 1 - } -} +impl Object for WlSubcompositor {} simple_add_obj!(WlSubcompositor); diff --git a/src/ifs/wl_surface.rs b/src/ifs/wl_surface.rs index 1e2f0ab0..ee28db9f 100644 --- a/src/ifs/wl_surface.rs +++ b/src/ifs/wl_surface.rs @@ -1049,7 +1049,7 @@ impl WlSurface { } object_base! { - WlSurface; + self = WlSurface; DESTROY => destroy, ATTACH => attach, @@ -1058,17 +1058,13 @@ object_base! { SET_OPAQUE_REGION => set_opaque_region, SET_INPUT_REGION => set_input_region, COMMIT => commit, - SET_BUFFER_TRANSFORM => set_buffer_transform, - SET_BUFFER_SCALE => set_buffer_scale, - DAMAGE_BUFFER => damage_buffer, - OFFSET => offset, + SET_BUFFER_TRANSFORM => set_buffer_transform if self.version >= 2, + SET_BUFFER_SCALE => set_buffer_scale if self.version >= 3, + DAMAGE_BUFFER => damage_buffer if self.version >= 4, + OFFSET => offset if self.version >= 5, } impl Object for WlSurface { - fn num_requests(&self) -> u32 { - OFFSET + 1 - } - fn break_loops(&self) { self.unset_dnd_icons(); self.unset_cursors(); diff --git a/src/ifs/wl_surface/ext_session_lock_surface_v1.rs b/src/ifs/wl_surface/ext_session_lock_surface_v1.rs index f16f6c18..08b0b14f 100644 --- a/src/ifs/wl_surface/ext_session_lock_surface_v1.rs +++ b/src/ifs/wl_surface/ext_session_lock_surface_v1.rs @@ -130,17 +130,13 @@ impl Node for ExtSessionLockSurfaceV1 { } object_base! { - ExtSessionLockSurfaceV1; + self = ExtSessionLockSurfaceV1; DESTROY => destroy, ACK_CONFIGURE => ack_configure, } impl Object for ExtSessionLockSurfaceV1 { - fn num_requests(&self) -> u32 { - ACK_CONFIGURE + 1 - } - fn break_loops(&self) { self.destroy_node(); } diff --git a/src/ifs/wl_surface/wl_subsurface.rs b/src/ifs/wl_surface/wl_subsurface.rs index 908227ab..f1fce993 100644 --- a/src/ifs/wl_surface/wl_subsurface.rs +++ b/src/ifs/wl_surface/wl_subsurface.rs @@ -244,7 +244,7 @@ impl WlSubsurface { } object_base! { - WlSubsurface; + self = WlSubsurface; DESTROY => destroy, SET_POSITION => set_position, @@ -255,10 +255,6 @@ object_base! { } impl Object for WlSubsurface { - fn num_requests(&self) -> u32 { - SET_DESYNC + 1 - } - fn break_loops(&self) { *self.pending.node.borrow_mut() = None; *self.node.borrow_mut() = None; diff --git a/src/ifs/wl_surface/wp_fractional_scale_v1.rs b/src/ifs/wl_surface/wp_fractional_scale_v1.rs index 9914bbbc..922e2625 100644 --- a/src/ifs/wl_surface/wp_fractional_scale_v1.rs +++ b/src/ifs/wl_surface/wp_fractional_scale_v1.rs @@ -52,16 +52,12 @@ impl WpFractionalScaleV1 { } object_base! { - WpFractionalScaleV1; + self = WpFractionalScaleV1; DESTROY => destroy, } -impl Object for WpFractionalScaleV1 { - fn num_requests(&self) -> u32 { - DESTROY + 1 - } -} +impl Object for WpFractionalScaleV1 {} simple_add_obj!(WpFractionalScaleV1); diff --git a/src/ifs/wl_surface/wp_tearing_control_v1.rs b/src/ifs/wl_surface/wp_tearing_control_v1.rs index 181c4d3b..f52a0c9f 100644 --- a/src/ifs/wl_surface/wp_tearing_control_v1.rs +++ b/src/ifs/wl_surface/wp_tearing_control_v1.rs @@ -53,17 +53,13 @@ impl WpTearingControlV1 { } object_base! { - WpTearingControlV1; + self = WpTearingControlV1; SET_PRESENTATION_HINT => set_presentation_hint, DESTROY => destroy, } -impl Object for WpTearingControlV1 { - fn num_requests(&self) -> u32 { - DESTROY + 1 - } -} +impl Object for WpTearingControlV1 {} simple_add_obj!(WpTearingControlV1); diff --git a/src/ifs/wl_surface/wp_viewport.rs b/src/ifs/wl_surface/wp_viewport.rs index a240373c..4628979e 100644 --- a/src/ifs/wl_surface/wp_viewport.rs +++ b/src/ifs/wl_surface/wp_viewport.rs @@ -75,18 +75,14 @@ impl WpViewport { } object_base! { - WpViewport; + self = WpViewport; DESTROY => destroy, SET_SOURCE => set_source, SET_DESTINATION => set_destination, } -impl Object for WpViewport { - fn num_requests(&self) -> u32 { - SET_DESTINATION + 1 - } -} +impl Object for WpViewport {} simple_add_obj!(WpViewport); diff --git a/src/ifs/wl_surface/x_surface/xwayland_surface_v1.rs b/src/ifs/wl_surface/x_surface/xwayland_surface_v1.rs index ea6b16eb..31d76e33 100644 --- a/src/ifs/wl_surface/x_surface/xwayland_surface_v1.rs +++ b/src/ifs/wl_surface/x_surface/xwayland_surface_v1.rs @@ -42,17 +42,13 @@ impl XwaylandSurfaceV1 { } object_base! { - XwaylandSurfaceV1; + self = XwaylandSurfaceV1; SET_SERIAL => set_serial, DESTROY => destroy, } impl Object for XwaylandSurfaceV1 { - fn num_requests(&self) -> u32 { - DESTROY + 1 - } - fn break_loops(&self) { self.x.xwayland_surface.set(None); } diff --git a/src/ifs/wl_surface/xdg_surface.rs b/src/ifs/wl_surface/xdg_surface.rs index 217a7d35..dfbdd42e 100644 --- a/src/ifs/wl_surface/xdg_surface.rs +++ b/src/ifs/wl_surface/xdg_surface.rs @@ -314,7 +314,7 @@ impl XdgSurface { } object_base! { - XdgSurface; + self = XdgSurface; DESTROY => destroy, GET_TOPLEVEL => get_toplevel, @@ -324,10 +324,6 @@ object_base! { } impl Object for XdgSurface { - fn num_requests(&self) -> u32 { - ACK_CONFIGURE + 1 - } - fn break_loops(&self) { self.ext.take(); self.popups.clear(); diff --git a/src/ifs/wl_surface/xdg_surface/xdg_popup.rs b/src/ifs/wl_surface/xdg_surface/xdg_popup.rs index a24498b9..58d19d4c 100644 --- a/src/ifs/wl_surface/xdg_surface/xdg_popup.rs +++ b/src/ifs/wl_surface/xdg_surface/xdg_popup.rs @@ -253,22 +253,14 @@ impl XdgPopup { } object_base! { - XdgPopup; + self = XdgPopup; DESTROY => destroy, GRAB => grab, - REPOSITION => reposition, + REPOSITION => reposition if self.xdg.base.version >= 3, } impl Object for XdgPopup { - fn num_requests(&self) -> u32 { - let last_req = match self.xdg.base.version { - 0..=2 => GRAB, - _ => REPOSITION, - }; - last_req + 1 - } - fn break_loops(&self) { self.destroy_node(); self.parent.set(None); diff --git a/src/ifs/wl_surface/xdg_surface/xdg_toplevel.rs b/src/ifs/wl_surface/xdg_surface/xdg_toplevel.rs index 830c7556..7995d5ec 100644 --- a/src/ifs/wl_surface/xdg_surface/xdg_toplevel.rs +++ b/src/ifs/wl_surface/xdg_surface/xdg_toplevel.rs @@ -360,7 +360,7 @@ impl XdgToplevel { } object_base! { - XdgToplevel; + self = XdgToplevel; DESTROY => destroy, SET_PARENT => set_parent, @@ -379,10 +379,6 @@ object_base! { } impl Object for XdgToplevel { - fn num_requests(&self) -> u32 { - SET_MINIMIZED + 1 - } - fn break_loops(&self) { self.tl_destroy(); self.parent.set(None); diff --git a/src/ifs/wl_surface/xwayland_shell_v1.rs b/src/ifs/wl_surface/xwayland_shell_v1.rs index c4920a5f..c995d005 100644 --- a/src/ifs/wl_surface/xwayland_shell_v1.rs +++ b/src/ifs/wl_surface/xwayland_shell_v1.rs @@ -91,17 +91,13 @@ impl Global for XwaylandShellV1Global { simple_add_global!(XwaylandShellV1Global); object_base! { - XwaylandShellV1; + self = XwaylandShellV1; DESTROY => destroy, GET_XWAYLAND_SURFACE => get_xwayland_surface, } -impl Object for XwaylandShellV1 { - fn num_requests(&self) -> u32 { - GET_XWAYLAND_SURFACE + 1 - } -} +impl Object for XwaylandShellV1 {} simple_add_obj!(XwaylandShellV1); diff --git a/src/ifs/wl_surface/zwlr_layer_surface_v1.rs b/src/ifs/wl_surface/zwlr_layer_surface_v1.rs index 924e473e..0cc368a0 100644 --- a/src/ifs/wl_surface/zwlr_layer_surface_v1.rs +++ b/src/ifs/wl_surface/zwlr_layer_surface_v1.rs @@ -407,7 +407,7 @@ impl Node for ZwlrLayerSurfaceV1 { } object_base! { - ZwlrLayerSurfaceV1; + self = ZwlrLayerSurfaceV1; SET_SIZE => set_size, SET_ANCHOR => set_anchor, @@ -417,18 +417,10 @@ object_base! { GET_POPUP => get_popup, ACK_CONFIGURE => ack_configure, DESTROY => destroy, - SET_LAYER => set_layer, + SET_LAYER => set_layer if self.shell.version >= 2, } impl Object for ZwlrLayerSurfaceV1 { - fn num_requests(&self) -> u32 { - let last_req = match self.shell.version { - 0..=1 => DESTROY, - _ => SET_LAYER, - }; - last_req + 1 - } - fn break_loops(&self) { self.destroy_node(); self.link.set(None); diff --git a/src/ifs/wl_surface/zwp_idle_inhibitor_v1.rs b/src/ifs/wl_surface/zwp_idle_inhibitor_v1.rs index c6825cdf..8b5aeebc 100644 --- a/src/ifs/wl_surface/zwp_idle_inhibitor_v1.rs +++ b/src/ifs/wl_surface/zwp_idle_inhibitor_v1.rs @@ -49,16 +49,12 @@ impl ZwpIdleInhibitorV1 { } object_base! { - ZwpIdleInhibitorV1; + self = ZwpIdleInhibitorV1; DESTROY => destroy, } impl Object for ZwpIdleInhibitorV1 { - fn num_requests(&self) -> u32 { - DESTROY + 1 - } - fn break_loops(&self) { self.deactivate(); } diff --git a/src/ifs/wp_fractional_scale_manager_v1.rs b/src/ifs/wp_fractional_scale_manager_v1.rs index 91367423..4f3c4a19 100644 --- a/src/ifs/wp_fractional_scale_manager_v1.rs +++ b/src/ifs/wp_fractional_scale_manager_v1.rs @@ -85,17 +85,13 @@ impl WpFractionalScaleManagerV1 { } object_base! { - WpFractionalScaleManagerV1; + self = WpFractionalScaleManagerV1; DESTROY => destroy, GET_FRACTIONAL_SCALE => get_fractional_scale, } -impl Object for WpFractionalScaleManagerV1 { - fn num_requests(&self) -> u32 { - GET_FRACTIONAL_SCALE + 1 - } -} +impl Object for WpFractionalScaleManagerV1 {} simple_add_obj!(WpFractionalScaleManagerV1); diff --git a/src/ifs/wp_presentation.rs b/src/ifs/wp_presentation.rs index 1417d263..f9cc4768 100644 --- a/src/ifs/wp_presentation.rs +++ b/src/ifs/wp_presentation.rs @@ -91,17 +91,13 @@ impl WpPresentation { } object_base! { - WpPresentation; + self = WpPresentation; DESTROY => destroy, FEEDBACK => feedback, } -impl Object for WpPresentation { - fn num_requests(&self) -> u32 { - FEEDBACK + 1 - } -} +impl Object for WpPresentation {} simple_add_obj!(WpPresentation); diff --git a/src/ifs/wp_presentation_feedback.rs b/src/ifs/wp_presentation_feedback.rs index 89c02484..a1bc3438 100644 --- a/src/ifs/wp_presentation_feedback.rs +++ b/src/ifs/wp_presentation_feedback.rs @@ -51,14 +51,10 @@ impl WpPresentationFeedback { } object_base! { - WpPresentationFeedback; + self = WpPresentationFeedback; } -impl Object for WpPresentationFeedback { - fn num_requests(&self) -> u32 { - 0 - } -} +impl Object for WpPresentationFeedback {} simple_add_obj!(WpPresentationFeedback); diff --git a/src/ifs/wp_tearing_control_manager_v1.rs b/src/ifs/wp_tearing_control_manager_v1.rs index a84e57a9..b150d815 100644 --- a/src/ifs/wp_tearing_control_manager_v1.rs +++ b/src/ifs/wp_tearing_control_manager_v1.rs @@ -91,17 +91,13 @@ impl WpTearingControlManagerV1 { } object_base! { - WpTearingControlManagerV1; + self = WpTearingControlManagerV1; DESTROY => destroy, GET_TEARING_CONTROL => get_tearing_control, } -impl Object for WpTearingControlManagerV1 { - fn num_requests(&self) -> u32 { - GET_TEARING_CONTROL + 1 - } -} +impl Object for WpTearingControlManagerV1 {} simple_add_obj!(WpTearingControlManagerV1); diff --git a/src/ifs/wp_viewporter.rs b/src/ifs/wp_viewporter.rs index d128c7e9..69c76c4f 100644 --- a/src/ifs/wp_viewporter.rs +++ b/src/ifs/wp_viewporter.rs @@ -77,17 +77,13 @@ impl WpViewporter { } object_base! { - WpViewporter; + self = WpViewporter; DESTROY => destroy, GET_VIEWPORT => get_viewport, } -impl Object for WpViewporter { - fn num_requests(&self) -> u32 { - GET_VIEWPORT + 1 - } -} +impl Object for WpViewporter {} simple_add_obj!(WpViewporter); diff --git a/src/ifs/xdg_positioner.rs b/src/ifs/xdg_positioner.rs index b2115d16..51b53bac 100644 --- a/src/ifs/xdg_positioner.rs +++ b/src/ifs/xdg_positioner.rs @@ -264,7 +264,7 @@ impl XdgPositioner { } object_base! { - XdgPositioner; + self = XdgPositioner; DESTROY => destroy, SET_SIZE => set_size, @@ -273,20 +273,12 @@ object_base! { SET_GRAVITY => set_gravity, SET_CONSTRAINT_ADJUSTMENT => set_constraint_adjustment, SET_OFFSET => set_offset, - SET_REACTIVE => set_reactive, - SET_PARENT_SIZE => set_parent_size, - SET_PARENT_CONFIGURE => set_parent_configure, + SET_REACTIVE => set_reactive if self.base.version >= 3, + SET_PARENT_SIZE => set_parent_size if self.base.version >= 3, + SET_PARENT_CONFIGURE => set_parent_configure if self.base.version >= 3, } -impl Object for XdgPositioner { - fn num_requests(&self) -> u32 { - if self.base.version < 3 { - SET_OFFSET + 1 - } else { - SET_PARENT_CONFIGURE + 1 - } - } -} +impl Object for XdgPositioner {} dedicated_add_obj!(XdgPositioner, XdgPositionerId, xdg_positioners); diff --git a/src/ifs/xdg_wm_base.rs b/src/ifs/xdg_wm_base.rs index 551b7514..2225b6e1 100644 --- a/src/ifs/xdg_wm_base.rs +++ b/src/ifs/xdg_wm_base.rs @@ -124,7 +124,7 @@ impl Global for XdgWmBaseGlobal { simple_add_global!(XdgWmBaseGlobal); object_base! { - XdgWmBase; + self = XdgWmBase; DESTROY => destroy, CREATE_POSITIONER => create_positioner, @@ -135,10 +135,6 @@ object_base! { dedicated_add_obj!(XdgWmBase, XdgWmBaseId, xdg_wm_bases); impl Object for XdgWmBase { - fn num_requests(&self) -> u32 { - PONG + 1 - } - fn break_loops(&self) { self.surfaces.clear(); } diff --git a/src/ifs/zwlr_layer_shell_v1.rs b/src/ifs/zwlr_layer_shell_v1.rs index 9e340cee..d36e2a64 100644 --- a/src/ifs/zwlr_layer_shell_v1.rs +++ b/src/ifs/zwlr_layer_shell_v1.rs @@ -118,26 +118,15 @@ impl Global for ZwlrLayerShellV1Global { simple_add_global!(ZwlrLayerShellV1Global); object_base! { - ZwlrLayerShellV1; + self = ZwlrLayerShellV1; GET_LAYER_SURFACE => get_layer_surface, - DESTROY => destroy, + DESTROY => destroy if self.version >= 3, } simple_add_obj!(ZwlrLayerShellV1); -impl Object for ZwlrLayerShellV1 { - fn num_requests(&self) -> u32 { - // todo - // let last_request = if self.version >= 3 { - // DESTROY - // } else { - // GET_LAYER_SURFACE - // }; - // last_request + 1 - DESTROY + 1 - } -} +impl Object for ZwlrLayerShellV1 {} #[derive(Debug, Error)] pub enum ZwlrLayerShellV1Error { diff --git a/src/ifs/zwlr_screencopy_frame_v1.rs b/src/ifs/zwlr_screencopy_frame_v1.rs index ed480494..1b7c1af0 100644 --- a/src/ifs/zwlr_screencopy_frame_v1.rs +++ b/src/ifs/zwlr_screencopy_frame_v1.rs @@ -151,24 +151,16 @@ impl ZwlrScreencopyFrameV1 { } object_base! { - ZwlrScreencopyFrameV1; + self = ZwlrScreencopyFrameV1; COPY => copy, DESTROY => destroy, - COPY_WITH_DAMAGE => copy_with_damage, + COPY_WITH_DAMAGE => copy_with_damage if self.version >= 2, } simple_add_obj!(ZwlrScreencopyFrameV1); impl Object for ZwlrScreencopyFrameV1 { - fn num_requests(&self) -> u32 { - if self.version >= 2 { - COPY_WITH_DAMAGE + 1 - } else { - DESTROY + 1 - } - } - fn break_loops(&self) { self.output_link.take(); } diff --git a/src/ifs/zwlr_screencopy_manager_v1.rs b/src/ifs/zwlr_screencopy_manager_v1.rs index 89de8465..581d528f 100644 --- a/src/ifs/zwlr_screencopy_manager_v1.rs +++ b/src/ifs/zwlr_screencopy_manager_v1.rs @@ -135,18 +135,14 @@ impl ZwlrScreencopyManagerV1 { } object_base! { - ZwlrScreencopyManagerV1; + self = ZwlrScreencopyManagerV1; CAPTURE_OUTPUT => capture_output, CAPTURE_OUTPUT_REGION => capture_output_region, DESTROY => destroy, } -impl Object for ZwlrScreencopyManagerV1 { - fn num_requests(&self) -> u32 { - DESTROY + 1 - } -} +impl Object for ZwlrScreencopyManagerV1 {} simple_add_obj!(ZwlrScreencopyManagerV1); diff --git a/src/ifs/zwp_idle_inhibit_manager_v1.rs b/src/ifs/zwp_idle_inhibit_manager_v1.rs index 1d853f07..85ec928e 100644 --- a/src/ifs/zwp_idle_inhibit_manager_v1.rs +++ b/src/ifs/zwp_idle_inhibit_manager_v1.rs @@ -95,17 +95,13 @@ impl ZwpIdleInhibitManagerV1 { } object_base! { - ZwpIdleInhibitManagerV1; + self = ZwpIdleInhibitManagerV1; DESTROY => destroy, CREATE_INHIBITOR => create_inhibitor, } -impl Object for ZwpIdleInhibitManagerV1 { - fn num_requests(&self) -> u32 { - CREATE_INHIBITOR + 1 - } -} +impl Object for ZwpIdleInhibitManagerV1 {} simple_add_obj!(ZwpIdleInhibitManagerV1); diff --git a/src/ifs/zwp_linux_buffer_params_v1.rs b/src/ifs/zwp_linux_buffer_params_v1.rs index f75d66d0..67fcbff3 100644 --- a/src/ifs/zwp_linux_buffer_params_v1.rs +++ b/src/ifs/zwp_linux_buffer_params_v1.rs @@ -187,19 +187,15 @@ impl ZwpLinuxBufferParamsV1 { } object_base! { - ZwpLinuxBufferParamsV1; + self = ZwpLinuxBufferParamsV1; DESTROY => destroy, ADD => add, CREATE => create, - CREATE_IMMED => create_immed, + CREATE_IMMED => create_immed if self.parent.version >= 2, } -impl Object for ZwpLinuxBufferParamsV1 { - fn num_requests(&self) -> u32 { - CREATE_IMMED + 1 - } -} +impl Object for ZwpLinuxBufferParamsV1 {} simple_add_obj!(ZwpLinuxBufferParamsV1); diff --git a/src/ifs/zwp_linux_dmabuf_v1.rs b/src/ifs/zwp_linux_dmabuf_v1.rs index 6bf80a79..b449a386 100644 --- a/src/ifs/zwp_linux_dmabuf_v1.rs +++ b/src/ifs/zwp_linux_dmabuf_v1.rs @@ -30,7 +30,7 @@ impl ZwpLinuxDmabufV1Global { let obj = Rc::new(ZwpLinuxDmabufV1 { id, client: client.clone(), - _version: version, + version, tracker: Default::default(), }); track!(client, obj); @@ -79,7 +79,7 @@ simple_add_global!(ZwpLinuxDmabufV1Global); pub struct ZwpLinuxDmabufV1 { id: ZwpLinuxDmabufV1Id, pub client: Rc, - _version: u32, + pub version: u32, pub tracker: Tracker, } @@ -119,17 +119,13 @@ impl ZwpLinuxDmabufV1 { } object_base! { - ZwpLinuxDmabufV1; + self = ZwpLinuxDmabufV1; DESTROY => destroy, CREATE_PARAMS => create_params, } -impl Object for ZwpLinuxDmabufV1 { - fn num_requests(&self) -> u32 { - CREATE_PARAMS + 1 - } -} +impl Object for ZwpLinuxDmabufV1 {} simple_add_obj!(ZwpLinuxDmabufV1); diff --git a/src/ifs/zxdg_decoration_manager_v1.rs b/src/ifs/zxdg_decoration_manager_v1.rs index 32cd8ad7..6cd227f8 100644 --- a/src/ifs/zxdg_decoration_manager_v1.rs +++ b/src/ifs/zxdg_decoration_manager_v1.rs @@ -86,17 +86,13 @@ impl ZxdgDecorationManagerV1 { } object_base! { - ZxdgDecorationManagerV1; + self = ZxdgDecorationManagerV1; DESTROY => destroy, GET_TOPLEVEL_DECORATION => get_toplevel_decoration, } -impl Object for ZxdgDecorationManagerV1 { - fn num_requests(&self) -> u32 { - GET_TOPLEVEL_DECORATION + 1 - } -} +impl Object for ZxdgDecorationManagerV1 {} simple_add_obj!(ZxdgDecorationManagerV1); diff --git a/src/ifs/zxdg_output_manager_v1.rs b/src/ifs/zxdg_output_manager_v1.rs index cda300ec..06654ed7 100644 --- a/src/ifs/zxdg_output_manager_v1.rs +++ b/src/ifs/zxdg_output_manager_v1.rs @@ -93,7 +93,7 @@ impl Global for ZxdgOutputManagerV1Global { simple_add_global!(ZxdgOutputManagerV1Global); object_base! { - ZxdgOutputManagerV1; + self = ZxdgOutputManagerV1; DESTROY => destroy, GET_XDG_OUTPUT => get_xdg_output, @@ -101,11 +101,7 @@ object_base! { simple_add_obj!(ZxdgOutputManagerV1); -impl Object for ZxdgOutputManagerV1 { - fn num_requests(&self) -> u32 { - GET_XDG_OUTPUT + 1 - } -} +impl Object for ZxdgOutputManagerV1 {} #[derive(Debug, Error)] pub enum ZxdgOutputManagerV1Error { diff --git a/src/ifs/zxdg_output_v1.rs b/src/ifs/zxdg_output_v1.rs index 30d40f77..58b4c8b7 100644 --- a/src/ifs/zxdg_output_v1.rs +++ b/src/ifs/zxdg_output_v1.rs @@ -85,16 +85,12 @@ impl ZxdgOutputV1 { } object_base! { - ZxdgOutputV1; + self = ZxdgOutputV1; DESTROY => destroy, } -impl Object for ZxdgOutputV1 { - fn num_requests(&self) -> u32 { - DESTROY + 1 - } -} +impl Object for ZxdgOutputV1 {} simple_add_obj!(ZxdgOutputV1); diff --git a/src/ifs/zxdg_toplevel_decoration_v1.rs b/src/ifs/zxdg_toplevel_decoration_v1.rs index a8afdaba..65c1d304 100644 --- a/src/ifs/zxdg_toplevel_decoration_v1.rs +++ b/src/ifs/zxdg_toplevel_decoration_v1.rs @@ -77,18 +77,14 @@ impl ZxdgToplevelDecorationV1 { } object_base! { - ZxdgToplevelDecorationV1; + self = ZxdgToplevelDecorationV1; DESTROY => destroy, SET_MODE => set_mode, UNSET_MODE => unset_mode, } -impl Object for ZxdgToplevelDecorationV1 { - fn num_requests(&self) -> u32 { - UNSET_MODE + 1 - } -} +impl Object for ZxdgToplevelDecorationV1 {} simple_add_obj!(ZxdgToplevelDecorationV1); diff --git a/src/macros.rs b/src/macros.rs index c905c10f..e2740362 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -52,30 +52,30 @@ macro_rules! usr_object_base { } macro_rules! object_base { - ($oname:ident; $($code:ident => $f:ident,)*) => { + ($self:ident = $oname:ident; $($code:ident => $f:ident $(if $cond:expr)?,)*) => { impl crate::object::ObjectBase for $oname { - fn id(&self) -> crate::object::ObjectId { - self.id.into() + fn id(&$self) -> crate::object::ObjectId { + $self.id.into() } - fn into_any(self: std::rc::Rc) -> std::rc::Rc { - self + fn into_any($self: std::rc::Rc) -> std::rc::Rc { + $self } #[allow(unused_variables, unreachable_code)] fn handle_request( - self: std::rc::Rc, + $self: std::rc::Rc, request: u32, parser: crate::utils::buffd::MsgParser<'_, '_>, ) -> Result<(), crate::client::ClientError> { let res: Result<(), crate::client::MethodError> = match request { $( - $code => $oname::$f(&self, parser).map_err(|e| crate::client::MethodError { + $code $(if $cond)? => $oname::$f(&$self, parser).map_err(|e| crate::client::MethodError { method: stringify!($f), error: Box::new(e), }), )* - _ => unreachable!(), + _ => return Err(crate::client::ClientError::InvalidMethod), }; if let Err(e) = res { return Err(crate::client::ClientError::ObjectError(crate::client::ObjectError { @@ -86,7 +86,7 @@ macro_rules! object_base { Ok(()) } - fn interface(&self) -> crate::object::Interface { + fn interface(&$self) -> crate::object::Interface { crate::wire::$oname } } diff --git a/src/object.rs b/src/object.rs index 29ed25d9..0aa0938c 100644 --- a/src/object.rs +++ b/src/object.rs @@ -43,7 +43,6 @@ pub trait ObjectBase { } pub trait Object: ObjectBase + 'static { - fn num_requests(&self) -> u32; fn break_loops(&self) {} }