From 19aef8c58a701d54ceb0bf2d4b1fd0ea234a9928 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Thu, 28 Apr 2022 15:19:15 +0200 Subject: [PATCH] autocommit 2022-04-28 15:19:15 CEST --- src/ifs/ipc/wl_data_device.rs | 60 ++---- src/ifs/ipc/wl_data_device_manager.rs | 33 +-- src/ifs/ipc/wl_data_offer.rs | 99 ++------- src/ifs/ipc/wl_data_source.rs | 51 +---- ...zwp_primary_selection_device_manager_v1.rs | 47 +--- .../ipc/zwp_primary_selection_device_v1.rs | 35 +-- src/ifs/ipc/zwp_primary_selection_offer_v1.rs | 33 +-- .../ipc/zwp_primary_selection_source_v1.rs | 33 +-- src/ifs/jay_compositor.rs | 2 +- src/ifs/jay_idle.rs | 2 +- src/ifs/jay_log_file.rs | 14 +- src/ifs/jay_screenshot.rs | 2 +- src/ifs/org_kde_kwin_server_decoration.rs | 37 +--- .../org_kde_kwin_server_decoration_manager.rs | 24 +-- src/ifs/wl_buffer.rs | 22 +- src/ifs/wl_callback.rs | 2 +- src/ifs/wl_compositor.rs | 37 +--- src/ifs/wl_display.rs | 39 +--- src/ifs/wl_drm.rs | 68 ++---- src/ifs/wl_output.rs | 19 +- src/ifs/wl_region.rs | 44 +--- src/ifs/wl_registry.rs | 22 +- src/ifs/wl_seat.rs | 63 +----- src/ifs/wl_seat/wl_keyboard.rs | 24 +-- src/ifs/wl_seat/wl_pointer.rs | 35 +-- src/ifs/wl_seat/wl_touch.rs | 19 +- src/ifs/wl_shm.rs | 23 +- src/ifs/wl_shm_pool.rs | 67 ++---- src/ifs/wl_subcompositor.rs | 39 +--- src/ifs/wl_surface.rs | 149 ++----------- src/ifs/wl_surface/wl_subsurface.rs | 87 ++------ src/ifs/wl_surface/xdg_surface.rs | 107 ++------- src/ifs/wl_surface/xdg_surface/xdg_popup.rs | 50 +---- .../wl_surface/xdg_surface/xdg_toplevel.rs | 204 ++---------------- src/ifs/wl_surface/zwlr_layer_surface_v1.rs | 148 ++----------- src/ifs/wl_surface/zwp_idle_inhibitor_v1.rs | 2 +- src/ifs/wp_presentation.rs | 2 +- src/ifs/wp_presentation_feedback.rs | 2 +- src/ifs/xdg_positioner.rs | 151 +++---------- src/ifs/xdg_wm_base.rs | 62 +----- src/ifs/zwlr_layer_shell_v1.rs | 39 +--- src/ifs/zwp_idle_inhibit_manager_v1.rs | 2 +- src/ifs/zwp_linux_buffer_params_v1.rs | 100 ++------- src/ifs/zwp_linux_dmabuf_v1.rs | 33 +-- src/ifs/zxdg_decoration_manager_v1.rs | 33 +-- src/ifs/zxdg_output_manager_v1.rs | 33 +-- src/ifs/zxdg_output_v1.rs | 14 +- src/ifs/zxdg_toplevel_decoration_v1.rs | 36 +--- src/macros.rs | 50 +---- 49 files changed, 413 insertions(+), 1886 deletions(-) diff --git a/src/ifs/ipc/wl_data_device.rs b/src/ifs/ipc/wl_data_device.rs index c1eb6cf0..377b755b 100644 --- a/src/ifs/ipc/wl_data_device.rs +++ b/src/ifs/ipc/wl_data_device.rs @@ -92,7 +92,7 @@ impl WlDataDevice { self.manager.client.event(Drop { self_id: self.id }) } - fn start_drag(&self, parser: MsgParser<'_, '_>) -> Result<(), StartDragError> { + fn start_drag(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataDeviceError> { let req: StartDrag = self.manager.client.parse(self, parser)?; if !self.manager.client.valid_serial(req.serial) { log::warn!("Client tried to start_drag with an invalid serial"); @@ -117,7 +117,7 @@ impl WlDataDevice { Ok(()) } - fn set_selection(&self, parser: MsgParser<'_, '_>) -> Result<(), SetSelectionError> { + fn set_selection(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataDeviceError> { let req: SetSelection = self.manager.client.parse(self, parser)?; if !self.manager.client.valid_serial(req.serial) { log::warn!("Client tried to set_selection with an invalid serial"); @@ -140,7 +140,7 @@ impl WlDataDevice { Ok(()) } - fn release(&self, parser: MsgParser<'_, '_>) -> Result<(), ReleaseError> { + fn release(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataDeviceError> { let _req: Release = self.manager.client.parse(self, parser)?; destroy_device::(self); self.seat.remove_data_device(self); @@ -229,7 +229,7 @@ impl Vtable for WlDataDevice { } object_base! { - WlDataDevice, WlDataDeviceError; + WlDataDevice; START_DRAG => start_drag, SET_SELECTION => set_selection, @@ -251,52 +251,16 @@ simple_add_obj!(WlDataDevice); #[derive(Debug, Error)] pub enum WlDataDeviceError { + #[error("Parsing failed")] + MsgParserError(#[source] Box), #[error(transparent)] ClientError(Box), - #[error("Could not process `start_drag` request")] - StartDragError(#[from] StartDragError), - #[error("Could not process `set_selection` request")] - SetSelectionError(#[from] SetSelectionError), - #[error("Could not process `release` request")] - ReleaseError(#[from] ReleaseError), -} -efrom!(WlDataDeviceError, ClientError); - -#[derive(Debug, Error)] -pub enum StartDragError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), + #[error(transparent)] + WlSeatError(Box), #[error(transparent)] WlSurfaceError(Box), - #[error(transparent)] - ClientError(Box), - #[error(transparent)] - WlSeatError(Box), } -efrom!(StartDragError, ParseFailed, MsgParserError); -efrom!(StartDragError, ClientError); -efrom!(StartDragError, WlSeatError); -efrom!(StartDragError, WlSurfaceError); - -#[derive(Debug, Error)] -pub enum SetSelectionError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), - #[error(transparent)] - WlSeatError(Box), -} -efrom!(SetSelectionError, ParseFailed, MsgParserError); -efrom!(SetSelectionError, ClientError); -efrom!(SetSelectionError, WlSeatError); - -#[derive(Debug, Error)] -pub enum ReleaseError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(ReleaseError, ParseFailed, MsgParserError); -efrom!(ReleaseError, ClientError); +efrom!(WlDataDeviceError, MsgParserError); +efrom!(WlDataDeviceError, ClientError); +efrom!(WlDataDeviceError, WlSeatError); +efrom!(WlDataDeviceError, WlSurfaceError); diff --git a/src/ifs/ipc/wl_data_device_manager.rs b/src/ifs/ipc/wl_data_device_manager.rs index cb485b84..7f83ed5a 100644 --- a/src/ifs/ipc/wl_data_device_manager.rs +++ b/src/ifs/ipc/wl_data_device_manager.rs @@ -56,7 +56,7 @@ impl WlDataDeviceManagerGlobal { } impl WlDataDeviceManager { - fn create_data_source(&self, parser: MsgParser<'_, '_>) -> Result<(), CreateDataSourceError> { + fn create_data_source(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataDeviceManagerError> { let req: CreateDataSource = self.client.parse(self, parser)?; let res = Rc::new(WlDataSource::new(req.id, &self.client)); track!(self.client, res); @@ -67,7 +67,7 @@ impl WlDataDeviceManager { fn get_data_device( self: &Rc, parser: MsgParser<'_, '_>, - ) -> Result<(), GetDataDeviceError> { + ) -> Result<(), WlDataDeviceManagerError> { let req: GetDataDevice = self.client.parse(&**self, parser)?; let seat = self.client.lookup(req.seat)?; let dev = Rc::new(WlDataDevice::new(req.id, self, &seat)); @@ -97,7 +97,7 @@ impl Global for WlDataDeviceManagerGlobal { simple_add_global!(WlDataDeviceManagerGlobal); object_base! { - WlDataDeviceManager, WlDataDeviceManagerError; + WlDataDeviceManager; CREATE_DATA_SOURCE => create_data_source, GET_DATA_DEVICE => get_data_device, @@ -115,29 +115,8 @@ simple_add_obj!(WlDataDeviceManager); pub enum WlDataDeviceManagerError { #[error(transparent)] ClientError(Box), - #[error("Could not process `create_data_source` request")] - CreateDataSourceError(#[from] CreateDataSourceError), - #[error("Could not process `get_data_device` request")] - GetDataDeviceError(#[from] GetDataDeviceError), + #[error("Parsing failed")] + MsgParserError(#[source] Box), } efrom!(WlDataDeviceManagerError, ClientError); - -#[derive(Debug, Error)] -pub enum CreateDataSourceError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(CreateDataSourceError, ParseFailed, MsgParserError); -efrom!(CreateDataSourceError, ClientError); - -#[derive(Debug, Error)] -pub enum GetDataDeviceError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(GetDataDeviceError, ParseFailed, MsgParserError); -efrom!(GetDataDeviceError, ClientError); +efrom!(WlDataDeviceManagerError, MsgParserError); diff --git a/src/ifs/ipc/wl_data_offer.rs b/src/ifs/ipc/wl_data_offer.rs index 1b4b2a0a..f1f2f58d 100644 --- a/src/ifs/ipc/wl_data_offer.rs +++ b/src/ifs/ipc/wl_data_offer.rs @@ -61,12 +61,12 @@ impl WlDataOffer { }) } - fn accept(&self, parser: MsgParser<'_, '_>) -> Result<(), AcceptError> { + fn accept(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataOfferError> { let req: Accept = self.client.parse(self, parser)?; let _ = req.serial; // unused let mut state = self.data.shared.state.get(); if state.contains(OFFER_STATE_FINISHED) { - return Err(AcceptError::AlreadyFinished); + return Err(WlDataOfferError::AlreadyFinished); } if req.mime_type.is_some() { state |= OFFER_STATE_ACCEPTED; @@ -80,36 +80,36 @@ impl WlDataOffer { Ok(()) } - fn receive(&self, parser: MsgParser<'_, '_>) -> Result<(), ReceiveError> { + fn receive(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataOfferError> { let req: Receive = self.client.parse(self, parser)?; if self.data.shared.state.get().contains(OFFER_STATE_FINISHED) { - return Err(ReceiveError::AlreadyFinished); + return Err(WlDataOfferError::AlreadyFinished); } receive::(self, req.mime_type, req.fd); Ok(()) } - fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataOfferError> { let _req: Destroy = self.client.parse(self, parser)?; destroy_offer::(self); self.client.remove_obj(self)?; Ok(()) } - fn finish(&self, parser: MsgParser<'_, '_>) -> Result<(), FinishError> { + fn finish(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataOfferError> { let _req: Finish = self.client.parse(self, parser)?; if self.data.shared.role.get() != Role::Dnd { - return Err(FinishError::NotDnd); + return Err(WlDataOfferError::NotDnd); } let mut state = self.data.shared.state.get(); if state.contains(OFFER_STATE_FINISHED) { - return Err(FinishError::AlreadyFinished); + return Err(WlDataOfferError::AlreadyFinished); } if !state.contains(OFFER_STATE_DROPPED) { - return Err(FinishError::StillDragging); + return Err(WlDataOfferError::StillDragging); } if !state.contains(OFFER_STATE_ACCEPTED) { - return Err(FinishError::NoMimeTypeAccepted); + return Err(WlDataOfferError::NoMimeTypeAccepted); } state |= OFFER_STATE_FINISHED; if let Some(src) = self.data.source.get() { @@ -122,17 +122,17 @@ impl WlDataOffer { Ok(()) } - fn set_actions(&self, parser: MsgParser<'_, '_>) -> Result<(), SetActionsError> { + fn set_actions(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataOfferError> { let req: SetActions = self.client.parse(self, parser)?; let state = self.data.shared.state.get(); if state.contains(OFFER_STATE_FINISHED) { - return Err(SetActionsError::AlreadyFinished); + return Err(WlDataOfferError::AlreadyFinished); } if (req.dnd_actions & !DND_ALL, req.preferred_action & !DND_ALL) != (0, 0) { - return Err(SetActionsError::InvalidActions); + return Err(WlDataOfferError::InvalidActions); } if req.preferred_action.count_ones() > 1 { - return Err(SetActionsError::MultiplePreferred); + return Err(WlDataOfferError::MultiplePreferred); } self.data.shared.receiver_actions.set(req.dnd_actions); self.data @@ -147,7 +147,7 @@ impl WlDataOffer { } object_base! { - WlDataOffer, WlDataOfferError; + WlDataOffer; ACCEPT => accept, RECEIVE => receive, @@ -172,59 +172,8 @@ simple_add_obj!(WlDataOffer); pub enum WlDataOfferError { #[error(transparent)] ClientError(Box), - #[error("Could not process `accept` request")] - AcceptError(#[from] AcceptError), - #[error("Could not process `receive` request")] - ReceiveError(#[from] ReceiveError), - #[error("Could not process `destroy` request")] - DestroyError(#[from] DestroyError), - #[error("Could not process `finish` request")] - FinishError(#[from] FinishError), - #[error("Could not process `set_actions` request")] - SetActionsError(#[from] SetActionsError), -} -efrom!(WlDataOfferError, ClientError); - -#[derive(Debug, Error)] -pub enum AcceptError { #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), - #[error("`finish` was already called")] - AlreadyFinished, -} -efrom!(AcceptError, ParseFailed, MsgParserError); -efrom!(AcceptError, ClientError); - -#[derive(Debug, Error)] -pub enum ReceiveError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), - #[error("`finish` was already called")] - AlreadyFinished, -} -efrom!(ReceiveError, ParseFailed, MsgParserError); -efrom!(ReceiveError, ClientError); - -#[derive(Debug, Error)] -pub enum DestroyError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(DestroyError, ParseFailed, MsgParserError); -efrom!(DestroyError, ClientError); - -#[derive(Debug, Error)] -pub enum FinishError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), + MsgParserError(#[source] Box), #[error("`finish` was already called")] AlreadyFinished, #[error("The drag operation is still ongoing")] @@ -233,22 +182,10 @@ pub enum FinishError { NoMimeTypeAccepted, #[error("This is not a drag-and-drop offer")] NotDnd, -} -efrom!(FinishError, ParseFailed, MsgParserError); -efrom!(FinishError, ClientError); - -#[derive(Debug, Error)] -pub enum SetActionsError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), - #[error("`finish` was already called")] - AlreadyFinished, #[error("The set of actions is invalid")] InvalidActions, #[error("Multiple preferred actions were specified")] MultiplePreferred, } -efrom!(SetActionsError, ParseFailed, MsgParserError); -efrom!(SetActionsError, ClientError); +efrom!(WlDataOfferError, ClientError); +efrom!(WlDataOfferError, MsgParserError); diff --git a/src/ifs/ipc/wl_data_source.rs b/src/ifs/ipc/wl_data_source.rs index 4a8e337c..cc64537d 100644 --- a/src/ifs/ipc/wl_data_source.rs +++ b/src/ifs/ipc/wl_data_source.rs @@ -138,26 +138,26 @@ impl WlDataSource { .event(DndDropPerformed { self_id: self.id }) } - fn offer(&self, parser: MsgParser<'_, '_>) -> Result<(), OfferError> { + fn offer(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataSourceError> { let req: Offer = self.data.client.parse(self, parser)?; add_mime_type::(self, req.mime_type); Ok(()) } - fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataSourceError> { let _req: Destroy = self.data.client.parse(self, parser)?; destroy_source::(self); self.data.client.remove_obj(self)?; Ok(()) } - fn set_actions(&self, parser: MsgParser<'_, '_>) -> Result<(), SetActionsError> { + fn set_actions(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataSourceError> { let req: SetActions = self.data.client.parse(self, parser)?; if self.data.actions.get().is_some() { - return Err(SetActionsError::AlreadySet); + return Err(WlDataSourceError::AlreadySet); } if req.dnd_actions & !DND_ALL != 0 { - return Err(SetActionsError::InvalidActions); + return Err(WlDataSourceError::InvalidActions); } self.data.actions.set(Some(req.dnd_actions)); Ok(()) @@ -165,7 +165,7 @@ impl WlDataSource { } object_base! { - WlDataSource, WlDataSourceError; + WlDataSource; OFFER => offer, DESTROY => destroy, @@ -186,41 +186,8 @@ dedicated_add_obj!(WlDataSource, WlDataSourceId, wl_data_source); #[derive(Debug, Error)] pub enum WlDataSourceError { - #[error(transparent)] - ClientError(Box), - #[error("Could not process `offer` request")] - OfferError(#[from] OfferError), - #[error("Could not process `destroy` request")] - DestroyError(#[from] DestroyError), - #[error("Could not process `set_actions` request")] - SetActionsError(#[from] SetActionsError), -} -efrom!(WlDataSourceError, ClientError); - -#[derive(Debug, Error)] -pub enum OfferError { #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(OfferError, ParseFailed, MsgParserError); -efrom!(OfferError, ClientError); - -#[derive(Debug, Error)] -pub enum DestroyError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(DestroyError, ParseFailed, MsgParserError); -efrom!(DestroyError, ClientError); - -#[derive(Debug, Error)] -pub enum SetActionsError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), + MsgParserError(#[source] Box), #[error(transparent)] ClientError(Box), #[error("The set of actions is invalid")] @@ -228,5 +195,5 @@ pub enum SetActionsError { #[error("The actions have already been set")] AlreadySet, } -efrom!(SetActionsError, ParseFailed, MsgParserError); -efrom!(SetActionsError, ClientError); +efrom!(WlDataSourceError, ClientError); +efrom!(WlDataSourceError, MsgParserError); 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 72eb62fa..fcfb0501 100644 --- a/src/ifs/ipc/zwp_primary_selection_device_manager_v1.rs +++ b/src/ifs/ipc/zwp_primary_selection_device_manager_v1.rs @@ -50,7 +50,7 @@ impl ZwpPrimarySelectionDeviceManagerV1Global { } impl ZwpPrimarySelectionDeviceManagerV1 { - fn create_source(&self, parser: MsgParser<'_, '_>) -> Result<(), CreateSourceError> { + fn create_source(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwpPrimarySelectionDeviceManagerV1Error> { let req: CreateSource = self.client.parse(self, parser)?; let res = Rc::new(ZwpPrimarySelectionSourceV1::new(req.id, &self.client)); track!(self.client, res); @@ -58,7 +58,7 @@ impl ZwpPrimarySelectionDeviceManagerV1 { Ok(()) } - fn get_data_device(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), GetDeviceError> { + fn get_data_device(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), ZwpPrimarySelectionDeviceManagerV1Error> { let req: GetDevice = self.client.parse(&**self, parser)?; let seat = self.client.lookup(req.seat)?; let dev = Rc::new(ZwpPrimarySelectionDeviceV1::new(req.id, self, &seat)); @@ -68,7 +68,7 @@ impl ZwpPrimarySelectionDeviceManagerV1 { Ok(()) } - fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwpPrimarySelectionDeviceManagerV1Error> { let _req: Destroy = self.client.parse(self, parser)?; self.client.remove_obj(self)?; Ok(()) @@ -94,7 +94,7 @@ impl Global for ZwpPrimarySelectionDeviceManagerV1Global { simple_add_global!(ZwpPrimarySelectionDeviceManagerV1Global); object_base! { - ZwpPrimarySelectionDeviceManagerV1, ZwpPrimarySelectionDeviceManagerV1Error; + ZwpPrimarySelectionDeviceManagerV1; CREATE_SOURCE => create_source, GET_DEVICE => get_data_device, @@ -111,43 +111,10 @@ simple_add_obj!(ZwpPrimarySelectionDeviceManagerV1); #[derive(Debug, Error)] pub enum ZwpPrimarySelectionDeviceManagerV1Error { + #[error("Parsing failed")] + MsgParserError(#[source] Box), #[error(transparent)] ClientError(Box), - #[error("Could not process `destroy` request")] - DestroyError(#[from] DestroyError), - #[error("Could not process `create_source` request")] - CreateSourceError(#[from] CreateSourceError), - #[error("Could not process `get_device` request")] - GetDeviceError(#[from] GetDeviceError), } efrom!(ZwpPrimarySelectionDeviceManagerV1Error, ClientError); - -#[derive(Debug, Error)] -pub enum DestroyError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(DestroyError, ParseFailed, MsgParserError); -efrom!(DestroyError, ClientError); - -#[derive(Debug, Error)] -pub enum CreateSourceError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(CreateSourceError, ParseFailed, MsgParserError); -efrom!(CreateSourceError, ClientError); - -#[derive(Debug, Error)] -pub enum GetDeviceError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(GetDeviceError, ParseFailed, MsgParserError); -efrom!(GetDeviceError, ClientError); +efrom!(ZwpPrimarySelectionDeviceManagerV1Error, MsgParserError); diff --git a/src/ifs/ipc/zwp_primary_selection_device_v1.rs b/src/ifs/ipc/zwp_primary_selection_device_v1.rs index fa4d2025..66e3e76f 100644 --- a/src/ifs/ipc/zwp_primary_selection_device_v1.rs +++ b/src/ifs/ipc/zwp_primary_selection_device_v1.rs @@ -61,7 +61,7 @@ impl ZwpPrimarySelectionDeviceV1 { }) } - fn set_selection(&self, parser: MsgParser<'_, '_>) -> Result<(), SetSelectionError> { + fn set_selection(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwpPrimarySelectionDeviceV1Error> { let req: SetSelection = self.manager.client.parse(self, parser)?; if !self.manager.client.valid_serial(req.serial) { log::warn!("Client tried to set_selection with an invalid serial"); @@ -86,7 +86,7 @@ impl ZwpPrimarySelectionDeviceV1 { Ok(()) } - fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwpPrimarySelectionDeviceV1Error> { let _req: Destroy = self.manager.client.parse(self, parser)?; destroy_device::(self); self.seat.remove_primary_selection_device(self); @@ -171,7 +171,7 @@ impl Vtable for ZwpPrimarySelectionDeviceV1 { } object_base! { - ZwpPrimarySelectionDeviceV1, ZwpPrimarySelectionDeviceV1Error; + ZwpPrimarySelectionDeviceV1; SET_SELECTION => set_selection, DESTROY => destroy, @@ -194,32 +194,11 @@ simple_add_obj!(ZwpPrimarySelectionDeviceV1); pub enum ZwpPrimarySelectionDeviceV1Error { #[error(transparent)] ClientError(Box), - #[error("Could not process `set_selection` request")] - SetSelectionError(#[from] SetSelectionError), - #[error("Could not process `destroy` request")] - DestroyError(#[from] DestroyError), -} -efrom!(ZwpPrimarySelectionDeviceV1Error, ClientError); - -#[derive(Debug, Error)] -pub enum SetSelectionError { #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), + MsgParserError(#[source] Box), #[error(transparent)] WlSeatError(Box), } -efrom!(SetSelectionError, ParseFailed, MsgParserError); -efrom!(SetSelectionError, ClientError); -efrom!(SetSelectionError, WlSeatError); - -#[derive(Debug, Error)] -pub enum DestroyError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(DestroyError, ParseFailed, MsgParserError); -efrom!(DestroyError, ClientError); +efrom!(ZwpPrimarySelectionDeviceV1Error, ClientError); +efrom!(ZwpPrimarySelectionDeviceV1Error, MsgParserError); +efrom!(ZwpPrimarySelectionDeviceV1Error, WlSeatError); diff --git a/src/ifs/ipc/zwp_primary_selection_offer_v1.rs b/src/ifs/ipc/zwp_primary_selection_offer_v1.rs index d1f7bd71..81db26b5 100644 --- a/src/ifs/ipc/zwp_primary_selection_offer_v1.rs +++ b/src/ifs/ipc/zwp_primary_selection_offer_v1.rs @@ -29,13 +29,13 @@ impl ZwpPrimarySelectionOfferV1 { }) } - fn receive(&self, parser: MsgParser<'_, '_>) -> Result<(), ReceiveError> { + fn receive(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwpPrimarySelectionOfferV1Error> { let req: Receive = self.client.parse(self, parser)?; receive::(self, req.mime_type, req.fd); Ok(()) } - fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwpPrimarySelectionOfferV1Error> { let _req: Destroy = self.client.parse(self, parser)?; destroy_offer::(self); self.client.remove_obj(self)?; @@ -44,7 +44,7 @@ impl ZwpPrimarySelectionOfferV1 { } object_base! { - ZwpPrimarySelectionOfferV1, ZwpPrimarySelectionOfferV1Error; + ZwpPrimarySelectionOfferV1; RECEIVE => receive, DESTROY => destroy, @@ -64,31 +64,10 @@ simple_add_obj!(ZwpPrimarySelectionOfferV1); #[derive(Debug, Error)] pub enum ZwpPrimarySelectionOfferV1Error { + #[error("Parsing failed")] + MsgParserError(#[source] Box), #[error(transparent)] ClientError(Box), - #[error("Could not process `receive` request")] - ReceiveError(#[from] ReceiveError), - #[error("Could not process `destroy` request")] - DestroyError(#[from] DestroyError), } efrom!(ZwpPrimarySelectionOfferV1Error, ClientError); - -#[derive(Debug, Error)] -pub enum ReceiveError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(ReceiveError, ParseFailed, MsgParserError); -efrom!(ReceiveError, ClientError); - -#[derive(Debug, Error)] -pub enum DestroyError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(DestroyError, ParseFailed, MsgParserError); -efrom!(DestroyError, ClientError); +efrom!(ZwpPrimarySelectionOfferV1Error, MsgParserError); diff --git a/src/ifs/ipc/zwp_primary_selection_source_v1.rs b/src/ifs/ipc/zwp_primary_selection_source_v1.rs index 05a461f6..ab750c86 100644 --- a/src/ifs/ipc/zwp_primary_selection_source_v1.rs +++ b/src/ifs/ipc/zwp_primary_selection_source_v1.rs @@ -42,13 +42,13 @@ impl ZwpPrimarySelectionSourceV1 { }) } - fn offer(&self, parser: MsgParser<'_, '_>) -> Result<(), OfferError> { + fn offer(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwpPrimarySelectionSourceV1Error> { let req: Offer = self.data.client.parse(self, parser)?; add_mime_type::(self, req.mime_type); Ok(()) } - fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwpPrimarySelectionSourceV1Error> { let _req: Destroy = self.data.client.parse(self, parser)?; destroy_source::(self); self.data.client.remove_obj(self)?; @@ -57,7 +57,7 @@ impl ZwpPrimarySelectionSourceV1 { } object_base! { - ZwpPrimarySelectionSourceV1, ZwpPrimarySelectionSourceV1Error; + ZwpPrimarySelectionSourceV1; OFFER => offer, DESTROY => destroy, @@ -83,29 +83,8 @@ dedicated_add_obj!( pub enum ZwpPrimarySelectionSourceV1Error { #[error(transparent)] ClientError(Box), - #[error("Could not process `offer` request")] - OfferError(#[from] OfferError), - #[error("Could not process `destroy` request")] - DestroyError(#[from] DestroyError), + #[error("Parsing failed")] + MsgParserError(#[source] Box), } efrom!(ZwpPrimarySelectionSourceV1Error, ClientError); - -#[derive(Debug, Error)] -pub enum OfferError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(OfferError, ParseFailed, MsgParserError); -efrom!(OfferError, ClientError); - -#[derive(Debug, Error)] -pub enum DestroyError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(DestroyError, ParseFailed, MsgParserError); -efrom!(DestroyError, ClientError); +efrom!(ZwpPrimarySelectionSourceV1Error, MsgParserError); diff --git a/src/ifs/jay_compositor.rs b/src/ifs/jay_compositor.rs index c2b9f20a..3640a5b5 100644 --- a/src/ifs/jay_compositor.rs +++ b/src/ifs/jay_compositor.rs @@ -154,7 +154,7 @@ impl JayCompositor { } } -object_base2! { +object_base! { JayCompositor; DESTROY => destroy, diff --git a/src/ifs/jay_idle.rs b/src/ifs/jay_idle.rs index cf6f5c0c..b0286094 100644 --- a/src/ifs/jay_idle.rs +++ b/src/ifs/jay_idle.rs @@ -57,7 +57,7 @@ impl JayIdle { } } -object_base2! { +object_base! { JayIdle; GET_STATUS => get_status, diff --git a/src/ifs/jay_log_file.rs b/src/ifs/jay_log_file.rs index 8578ed65..ebb81253 100644 --- a/src/ifs/jay_log_file.rs +++ b/src/ifs/jay_log_file.rs @@ -26,7 +26,7 @@ impl JayLogFile { } } - fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), JayLogFileError> { let _req: Destroy = self.client.parse(self, parser)?; self.client.remove_obj(self)?; Ok(()) @@ -41,7 +41,7 @@ impl JayLogFile { } object_base! { - JayLogFile, JayLogFileError; + JayLogFile; DESTROY => destroy, } @@ -56,16 +56,10 @@ simple_add_obj!(JayLogFile); #[derive(Debug, Error)] pub enum JayLogFileError { - #[error("Could not process a `destroy` request")] - DestroyError(#[from] DestroyError), -} - -#[derive(Debug, Error)] -pub enum DestroyError { #[error("Parsing failed")] MsgParserError(#[source] Box), #[error(transparent)] ClientError(Box), } -efrom!(DestroyError, ClientError); -efrom!(DestroyError, MsgParserError); +efrom!(JayLogFileError, ClientError); +efrom!(JayLogFileError, MsgParserError); diff --git a/src/ifs/jay_screenshot.rs b/src/ifs/jay_screenshot.rs index 60b6475f..8b9b5518 100644 --- a/src/ifs/jay_screenshot.rs +++ b/src/ifs/jay_screenshot.rs @@ -44,7 +44,7 @@ impl JayScreenshot { } } -object_base2! { +object_base! { JayScreenshot; } diff --git a/src/ifs/org_kde_kwin_server_decoration.rs b/src/ifs/org_kde_kwin_server_decoration.rs index 2cf8996e..57829527 100644 --- a/src/ifs/org_kde_kwin_server_decoration.rs +++ b/src/ifs/org_kde_kwin_server_decoration.rs @@ -40,16 +40,16 @@ impl OrgKdeKwinServerDecoration { }) } - fn release(&self, parser: MsgParser<'_, '_>) -> Result<(), ReleaseError> { + fn release(&self, parser: MsgParser<'_, '_>) -> Result<(), OrgKdeKwinServerDecorationError> { let _req: Release = self.client.parse(self, parser)?; self.client.remove_obj(self)?; Ok(()) } - fn request_mode(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), RequestModeError> { + fn request_mode(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), OrgKdeKwinServerDecorationError> { let req: RequestMode = self.client.parse(&**self, parser)?; if req.mode > SERVER { - return Err(RequestModeError::InvalidMode(req.mode)); + return Err(OrgKdeKwinServerDecorationError::InvalidMode(req.mode)); } let mode = if self.requested.replace(true) { req.mode @@ -62,7 +62,7 @@ impl OrgKdeKwinServerDecoration { } object_base! { - OrgKdeKwinServerDecoration, OrgKdeKwinServerDecorationError; + OrgKdeKwinServerDecoration; RELEASE => release, REQUEST_MODE => request_mode, @@ -78,33 +78,12 @@ simple_add_obj!(OrgKdeKwinServerDecoration); #[derive(Debug, Error)] pub enum OrgKdeKwinServerDecorationError { - #[error("Could not process a `release` request")] - ReleaseError(#[from] ReleaseError), - #[error("Could not process a `request_mode` request")] - RequestModeError(#[from] RequestModeError), #[error(transparent)] ClientError(Box), -} -efrom!(OrgKdeKwinServerDecorationError, ClientError); - -#[derive(Debug, Error)] -pub enum ReleaseError { - #[error(transparent)] - ClientError(Box), - #[error("Parsing failed")] - ParseError(#[source] Box), -} -efrom!(ReleaseError, ClientError); -efrom!(ReleaseError, ParseError, MsgParserError); - -#[derive(Debug, Error)] -pub enum RequestModeError { - #[error(transparent)] - ClientError(Box), - #[error("Parsing failed")] - ParseError(#[source] Box), #[error("Mode {0} does not exist")] InvalidMode(u32), + #[error("Parsing failed")] + MsgParserError(#[source] Box), } -efrom!(RequestModeError, ClientError); -efrom!(RequestModeError, ParseError, MsgParserError); +efrom!(OrgKdeKwinServerDecorationError, ClientError); +efrom!(OrgKdeKwinServerDecorationError, MsgParserError); diff --git a/src/ifs/org_kde_kwin_server_decoration_manager.rs b/src/ifs/org_kde_kwin_server_decoration_manager.rs index 400407fe..2939044d 100644 --- a/src/ifs/org_kde_kwin_server_decoration_manager.rs +++ b/src/ifs/org_kde_kwin_server_decoration_manager.rs @@ -11,6 +11,7 @@ use { std::rc::Rc, thiserror::Error, }; +use crate::ifs::org_kde_kwin_server_decoration::OrgKdeKwinServerDecorationError; #[allow(dead_code)] const NONE: u32 = 0; @@ -78,7 +79,7 @@ impl OrgKdeKwinServerDecorationManager { }) } - fn create(&self, parser: MsgParser<'_, '_>) -> Result<(), CreateError> { + fn create(&self, parser: MsgParser<'_, '_>) -> Result<(), OrgKdeKwinServerDecorationError> { let req: Create = self.client.parse(self, parser)?; let _ = self.client.lookup(req.surface)?; let obj = Rc::new(OrgKdeKwinServerDecoration::new(req.id, &self.client)); @@ -90,7 +91,7 @@ impl OrgKdeKwinServerDecorationManager { } object_base! { - OrgKdeKwinServerDecorationManager, OrgKdeKwinServerDecorationManagerError; + OrgKdeKwinServerDecorationManager; CREATE => create, } @@ -105,23 +106,10 @@ simple_add_obj!(OrgKdeKwinServerDecorationManager); #[derive(Debug, Error)] pub enum OrgKdeKwinServerDecorationManagerError { - #[error("Could not process a `create` request")] - CreateError(#[from] CreateError), - #[error(transparent)] - ClientError(Box), -} -efrom!( - OrgKdeKwinServerDecorationManagerError, - ClientError, - ClientError -); - -#[derive(Debug, Error)] -pub enum CreateError { #[error(transparent)] ClientError(Box), #[error("Parsing failed")] - ParseError(#[source] Box), + MsgParserError(#[source] Box), } -efrom!(CreateError, ClientError); -efrom!(CreateError, ParseError, MsgParserError); +efrom!(OrgKdeKwinServerDecorationManagerError, ClientError); +efrom!(OrgKdeKwinServerDecorationManagerError, MsgParserError); diff --git a/src/ifs/wl_buffer.rs b/src/ifs/wl_buffer.rs index fb726b6d..de3fe63d 100644 --- a/src/ifs/wl_buffer.rs +++ b/src/ifs/wl_buffer.rs @@ -118,7 +118,7 @@ impl WlBuffer { Ok(()) } - fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), WlBufferError> { let _req: Destroy = self.client.parse(self, parser)?; self.client.remove_obj(self)?; self.destroyed.set(true); @@ -131,7 +131,7 @@ impl WlBuffer { } object_base! { - WlBuffer, WlBufferError; + WlBuffer; DESTROY => destroy, } @@ -150,22 +150,16 @@ pub enum WlBufferError { OutOfBounds, #[error("The stride does not fit all pixels in a row")] StrideTooSmall, - #[error("Could not handle a `destroy` request")] - DestroyError(#[from] DestroyError), #[error("Could not access the client memory")] ClientMemError(#[source] Box), #[error("GLES could not import the client image")] - GlesError(#[source] Box), -} -efrom!(WlBufferError, ClientMemError); -efrom!(WlBufferError, GlesError, RenderError); - -#[derive(Debug, Error)] -pub enum DestroyError { + RenderError(#[source] Box), #[error("Parsing failed")] - ParseFailed(#[source] Box), + MsgParserError(#[source] Box), #[error(transparent)] ClientError(Box), } -efrom!(DestroyError, ParseFailed, MsgParserError); -efrom!(DestroyError, ClientError); +efrom!(WlBufferError, ClientMemError); +efrom!(WlBufferError, RenderError); +efrom!(WlBufferError, MsgParserError); +efrom!(WlBufferError, ClientError); diff --git a/src/ifs/wl_callback.rs b/src/ifs/wl_callback.rs index df6dd5ec..d42477c1 100644 --- a/src/ifs/wl_callback.rs +++ b/src/ifs/wl_callback.rs @@ -33,7 +33,7 @@ impl WlCallback { } object_base! { - WlCallback, WlCallbackError; + WlCallback; } impl Object for WlCallback { diff --git a/src/ifs/wl_compositor.rs b/src/ifs/wl_compositor.rs index cb32cdaa..88936825 100644 --- a/src/ifs/wl_compositor.rs +++ b/src/ifs/wl_compositor.rs @@ -48,7 +48,7 @@ impl WlCompositorGlobal { } impl WlCompositor { - fn create_surface(&self, parser: MsgParser<'_, '_>) -> Result<(), CreateSurfaceError> { + fn create_surface(&self, parser: MsgParser<'_, '_>) -> Result<(), WlCompositorError> { let surface: CreateSurface = self.client.parse(self, parser)?; let surface = Rc::new(WlSurface::new(surface.id, &self.client)); track!(self.client, surface); @@ -63,7 +63,7 @@ impl WlCompositor { Ok(()) } - fn create_region(&self, parser: MsgParser<'_, '_>) -> Result<(), CreateRegionError> { + fn create_region(&self, parser: MsgParser<'_, '_>) -> Result<(), WlCompositorError> { let region: CreateRegion = self.client.parse(self, parser)?; let region = Rc::new(WlRegion::new(region.id, &self.client)); track!(self.client, region); @@ -87,7 +87,7 @@ impl Global for WlCompositorGlobal { simple_add_global!(WlCompositorGlobal); object_base! { - WlCompositor, WlCompositorError; + WlCompositor; CREATE_SURFACE => create_surface, CREATE_REGION => create_region, @@ -105,34 +105,9 @@ simple_add_obj!(WlCompositor); pub enum WlCompositorError { #[error(transparent)] ClientError(Box), - #[error("Could not process `create_surface` request")] - CreateSurfaceError(#[source] Box), - #[error("Could not process `create_region` request")] - CreateRegionError(#[source] Box), + #[error("Parsing failed")] + MsgParserError(#[source] Box), } efrom!(WlCompositorError, ClientError); -efrom!(WlCompositorError, CreateSurfaceError); -efrom!(WlCompositorError, CreateRegionError); - -#[derive(Debug, Error)] -pub enum CreateSurfaceError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} - -efrom!(CreateSurfaceError, ParseFailed, MsgParserError); -efrom!(CreateSurfaceError, ClientError); - -#[derive(Debug, Error)] -pub enum CreateRegionError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} - -efrom!(CreateRegionError, ParseFailed, MsgParserError); -efrom!(CreateRegionError, ClientError, ClientError); +efrom!(WlCompositorError, MsgParserError); diff --git a/src/ifs/wl_display.rs b/src/ifs/wl_display.rs index ca8d4bfb..9a990015 100644 --- a/src/ifs/wl_display.rs +++ b/src/ifs/wl_display.rs @@ -1,7 +1,6 @@ use { crate::{ client::{Client, ClientError}, - globals::GlobalsError, ifs::{wl_callback::WlCallback, wl_registry::WlRegistry}, leaks::Tracker, object::{Object, ObjectId, WL_DISPLAY_ID}, @@ -33,7 +32,7 @@ impl WlDisplay { } } - fn sync(&self, parser: MsgParser<'_, '_>) -> Result<(), SyncError> { + fn sync(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDisplayError> { let sync: Sync = self.client.parse(self, parser)?; let cb = Rc::new(WlCallback::new(sync.callback, &self.client)); track!(self.client, cb); @@ -43,7 +42,7 @@ impl WlDisplay { Ok(()) } - fn get_registry(&self, parser: MsgParser<'_, '_>) -> Result<(), GetRegistryError> { + fn get_registry(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDisplayError> { let gr: GetRegistry = self.client.parse(self, parser)?; let registry = Rc::new(WlRegistry::new(gr.registry, &self.client)); track!(self.client, registry); @@ -90,7 +89,7 @@ impl WlDisplay { } object_base! { - WlDisplay, WlDisplayError; + WlDisplay; SYNC => sync, GET_REGISTRY => get_registry, @@ -104,36 +103,10 @@ impl Object for WlDisplay { #[derive(Debug, Error)] pub enum WlDisplayError { - #[error("Could not process a get_registry request")] - GetRegistryError(#[source] Box), - #[error("A client error occurred")] - SyncError(#[source] Box), -} - -efrom!(WlDisplayError, GetRegistryError); -efrom!(WlDisplayError, SyncError); - -#[derive(Debug, Error)] -pub enum GetRegistryError { #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), - #[error("An error occurred while processing globals")] - GlobalsError(#[source] Box), -} - -efrom!(GetRegistryError, ParseFailed, MsgParserError); -efrom!(GetRegistryError, GlobalsError); -efrom!(GetRegistryError, ClientError); - -#[derive(Debug, Error)] -pub enum SyncError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), + MsgParserError(#[source] Box), #[error(transparent)] ClientError(Box), } - -efrom!(SyncError, ParseFailed, MsgParserError); -efrom!(SyncError, ClientError); +efrom!(WlDisplayError, MsgParserError); +efrom!(WlDisplayError, ClientError); diff --git a/src/ifs/wl_drm.rs b/src/ifs/wl_drm.rs index 16185832..2730705f 100644 --- a/src/ifs/wl_drm.rs +++ b/src/ifs/wl_drm.rs @@ -91,38 +91,38 @@ impl WlDrm { }) } - fn authenticate(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), AuthenticateError> { + fn authenticate(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), WlDrmError> { let _req: Authenticate = self.client.parse(&**self, parser)?; self.send_authenticated(); Ok(()) } - fn create_buffer(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), CreateBufferError> { + fn create_buffer(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), WlDrmError> { let _req: CreateBuffer = self.client.parse(&**self, parser)?; - Err(CreateBufferError::Unsupported) + Err(WlDrmError::Unsupported) } fn create_planar_buffer( self: &Rc, parser: MsgParser<'_, '_>, - ) -> Result<(), CreatePlanarBufferError> { + ) -> Result<(), WlDrmError> { let _req: CreatePlanarBuffer = self.client.parse(&**self, parser)?; - Err(CreatePlanarBufferError::Unsupported) + Err(WlDrmError::Unsupported) } fn create_prime_buffer( self: &Rc, parser: MsgParser<'_, '_>, - ) -> Result<(), CreatePrimeBufferError> { + ) -> Result<(), WlDrmError> { let req: CreatePrimeBuffer = self.client.parse(&**self, parser)?; let ctx = match self.client.state.render_ctx.get() { Some(ctx) => ctx, - None => return Err(CreatePrimeBufferError::NoRenderContext), + None => return Err(WlDrmError::NoRenderContext), }; let formats = ctx.formats(); let format = match formats.get(&req.format) { Some(f) => f.format, - None => return Err(CreatePrimeBufferError::InvalidFormat(req.format)), + None => return Err(WlDrmError::InvalidFormat(req.format)), }; let mut dmabuf = DmaBuf { width: req.width, @@ -161,7 +161,7 @@ impl WlDrm { } object_base! { - WlDrm, WlDrmError; + WlDrm; AUTHENTICATE => authenticate, CREATE_BUFFER => create_buffer, @@ -179,56 +179,18 @@ simple_add_obj!(WlDrm); #[derive(Debug, Error)] pub enum WlDrmError { - #[error("Could not process a `authenticate` request")] - AuthenticateError(#[from] AuthenticateError), - #[error("Could not process a `create_buffer` request")] - CreateBufferError(#[from] CreateBufferError), - #[error("Could not process a `create_planar_buffer` request")] - CreatePlanarBufferError(#[from] CreatePlanarBufferError), - #[error("Could not process a `create_prime_buffer` request")] - CreatePrimeBufferError(#[from] CreatePrimeBufferError), - #[error(transparent)] - ClientError(Box), -} -efrom!(WlDrmError, ClientError); - -#[derive(Debug, Error)] -pub enum AuthenticateError { - #[error("Parsing failed")] - ParseError(#[source] Box), -} -efrom!(AuthenticateError, ParseError, MsgParserError); - -#[derive(Debug, Error)] -pub enum CreateBufferError { - #[error("Parsing failed")] - ParseError(#[source] Box), - #[error("This api is not supported")] - Unsupported, -} -efrom!(CreateBufferError, ParseError, MsgParserError); - -#[derive(Debug, Error)] -pub enum CreatePlanarBufferError { - #[error("Parsing failed")] - ParseError(#[source] Box), - #[error("This api is not supported")] - Unsupported, -} -efrom!(CreatePlanarBufferError, ParseError, MsgParserError); - -#[derive(Debug, Error)] -pub enum CreatePrimeBufferError { #[error("Parsing failed")] MsgParserError(#[source] Box), + #[error(transparent)] + ClientError(Box), + #[error("This api is not supported")] + Unsupported, #[error("The compositor has no render context attached")] NoRenderContext, #[error("The format {0} is not supported")] InvalidFormat(u32), #[error("Could not import the buffer")] ImportError(#[from] RenderError), - #[error(transparent)] - ClientError(Box), } -efrom!(CreatePrimeBufferError, MsgParserError); -efrom!(CreatePrimeBufferError, ClientError); +efrom!(WlDrmError, ClientError); +efrom!(WlDrmError, MsgParserError); diff --git a/src/ifs/wl_output.rs b/src/ifs/wl_output.rs index f2fdd1d5..9f847702 100644 --- a/src/ifs/wl_output.rs +++ b/src/ifs/wl_output.rs @@ -230,7 +230,7 @@ impl WlOutput { } } - fn release(&self, parser: MsgParser<'_, '_>) -> Result<(), ReleaseError> { + fn release(&self, parser: MsgParser<'_, '_>) -> Result<(), WlOutputError> { let _req: Release = self.client.parse(self, parser)?; self.xdg_outputs.clear(); self.remove_binding(); @@ -240,7 +240,7 @@ impl WlOutput { } object_base! { - WlOutput, WlOutputError; + WlOutput; RELEASE => release, } @@ -264,19 +264,10 @@ dedicated_add_obj!(WlOutput, WlOutputId, outputs); #[derive(Debug, Error)] pub enum WlOutputError { - #[error("Could not handle `release` request")] - ReleaseError(#[from] ReleaseError), #[error(transparent)] ClientError(Box), + #[error("Parsing failed")] + MsgParserError(#[source] Box), } efrom!(WlOutputError, ClientError); - -#[derive(Debug, Error)] -pub enum ReleaseError { - #[error("Parsing failed")] - ParseError(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(ReleaseError, ClientError); -efrom!(ReleaseError, ParseError, MsgParserError); +efrom!(WlOutputError, MsgParserError); diff --git a/src/ifs/wl_region.rs b/src/ifs/wl_region.rs index 589912cd..8d69c152 100644 --- a/src/ifs/wl_region.rs +++ b/src/ifs/wl_region.rs @@ -32,26 +32,26 @@ impl WlRegion { self.region.borrow_mut().get() } - fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), WlRegionError> { let _destroy: Destroy = self.client.parse(self, parser)?; self.client.remove_obj(self)?; Ok(()) } - fn add(&self, parser: MsgParser<'_, '_>) -> Result<(), AddError> { + fn add(&self, parser: MsgParser<'_, '_>) -> Result<(), WlRegionError> { let add: Add = self.client.parse(self, parser)?; if add.width < 0 || add.height < 0 { - return Err(AddError::NegativeExtents); + return Err(WlRegionError::NegativeExtents); } let mut region = self.region.borrow_mut(); region.add(Rect::new_sized(add.x, add.y, add.width, add.height).unwrap()); Ok(()) } - fn subtract(&self, parser: MsgParser<'_, '_>) -> Result<(), SubtractError> { + fn subtract(&self, parser: MsgParser<'_, '_>) -> Result<(), WlRegionError> { let req: Subtract = self.client.parse(self, parser)?; if req.width < 0 || req.height < 0 { - return Err(SubtractError::NegativeExtents); + return Err(WlRegionError::NegativeExtents); } let mut region = self.region.borrow_mut(); region.sub(Rect::new_sized(req.x, req.y, req.width, req.height).unwrap()); @@ -60,7 +60,7 @@ impl WlRegion { } object_base! { - WlRegion, WlRegionError; + WlRegion; DESTROY => destroy, ADD => add, @@ -77,38 +77,12 @@ dedicated_add_obj!(WlRegion, WlRegionId, regions); #[derive(Debug, Error)] pub enum WlRegionError { - #[error("Could not process `destroy` request")] - DestroyError(#[from] DestroyError), - #[error("Could not process `add` request")] - AddError(#[from] AddError), - #[error("Could not process `subtract` request")] - SubtractError(#[from] SubtractError), -} - -#[derive(Debug, Error)] -pub enum DestroyError { #[error("Parsing failed")] - ParseFailed(#[source] Box), + MsgParserError(#[source] Box), #[error(transparent)] ClientError(Box), -} -efrom!(DestroyError, ParseFailed, MsgParserError); -efrom!(DestroyError, ClientError); - -#[derive(Debug, Error)] -pub enum AddError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), #[error("width and/or height are negative")] NegativeExtents, } -efrom!(AddError, ParseFailed, MsgParserError); - -#[derive(Debug, Error)] -pub enum SubtractError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error("width and/or height are negative")] - NegativeExtents, -} -efrom!(SubtractError, ParseFailed, MsgParserError); +efrom!(WlRegionError, MsgParserError); +efrom!(WlRegionError, ClientError); diff --git a/src/ifs/wl_registry.rs b/src/ifs/wl_registry.rs index fdfc1d9f..116f4027 100644 --- a/src/ifs/wl_registry.rs +++ b/src/ifs/wl_registry.rs @@ -42,7 +42,7 @@ impl WlRegistry { }) } - fn bind(&self, parser: MsgParser<'_, '_>) -> Result<(), BindError> { + fn bind(&self, parser: MsgParser<'_, '_>) -> Result<(), WlRegistryError> { let bind: Bind = self.client.parse(self, parser)?; let global = self .client @@ -50,14 +50,14 @@ impl WlRegistry { .globals .get(GlobalName::from_raw(bind.name))?; if global.interface().name() != bind.interface { - return Err(BindError::InvalidInterface(InterfaceError { + return Err(WlRegistryError::InvalidInterface(InterfaceError { name: global.name(), interface: global.interface(), actual: bind.interface.to_string(), })); } if bind.version > global.version() { - return Err(BindError::InvalidVersion(VersionError { + return Err(WlRegistryError::InvalidVersion(VersionError { name: global.name(), interface: global.interface(), version: global.version(), @@ -70,7 +70,7 @@ impl WlRegistry { } object_base! { - WlRegistry, WlRegistryError; + WlRegistry; BIND => bind, } @@ -85,16 +85,8 @@ simple_add_obj!(WlRegistry); #[derive(Debug, Error)] pub enum WlRegistryError { - #[error("Could not process bind request")] - BindError(#[source] Box), -} - -efrom!(WlRegistryError, BindError); - -#[derive(Debug, Error)] -pub enum BindError { #[error("Parsing failed")] - ParseError(#[source] Box), + MsgParserError(#[source] Box), #[error(transparent)] GlobalsError(Box), #[error("Tried to bind to global {} of type {} using interface {}", .0.name, .0.interface.name(), .0.actual)] @@ -102,8 +94,8 @@ pub enum BindError { #[error("Tried to bind to global {} of type {} and version {} using version {}", .0.name, .0.interface.name(), .0.version, .0.actual)] InvalidVersion(VersionError), } -efrom!(BindError, ParseError, MsgParserError); -efrom!(BindError, GlobalsError); +efrom!(WlRegistryError, MsgParserError); +efrom!(WlRegistryError, GlobalsError); #[derive(Debug)] pub struct InterfaceError { diff --git a/src/ifs/wl_seat.rs b/src/ifs/wl_seat.rs index 2f323100..b67c8917 100644 --- a/src/ifs/wl_seat.rs +++ b/src/ifs/wl_seat.rs @@ -711,7 +711,7 @@ impl WlSeat { self.global.move_(node); } - fn get_pointer(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), GetPointerError> { + fn get_pointer(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), WlSeatError> { let req: GetPointer = self.client.parse(&**self, parser)?; let p = Rc::new(WlPointer::new(req.id, self)); track!(self.client, p); @@ -720,7 +720,7 @@ impl WlSeat { Ok(()) } - fn get_keyboard(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), GetKeyboardError> { + fn get_keyboard(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), WlSeatError> { let req: GetKeyboard = self.client.parse(&**self, parser)?; let p = Rc::new(WlKeyboard::new(req.id, self)); track!(self.client, p); @@ -760,7 +760,7 @@ impl WlSeat { Ok(Rc::new(fd)) } - fn get_touch(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), GetTouchError> { + fn get_touch(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), WlSeatError> { let req: GetTouch = self.client.parse(&**self, parser)?; let p = Rc::new(WlTouch::new(req.id, self)); track!(self.client, p); @@ -768,7 +768,7 @@ impl WlSeat { Ok(()) } - fn release(&self, parser: MsgParser<'_, '_>) -> Result<(), ReleaseError> { + fn release(&self, parser: MsgParser<'_, '_>) -> Result<(), WlSeatError> { let _req: Release = self.client.parse(self, parser)?; { let mut bindings = self.global.bindings.borrow_mut(); @@ -785,7 +785,7 @@ impl WlSeat { } object_base! { - WlSeat, WlSeatError; + WlSeat; GET_POINTER => get_pointer, GET_KEYBOARD => get_keyboard, @@ -821,63 +821,18 @@ dedicated_add_obj!(WlSeat, WlSeatId, seats); #[derive(Debug, Error)] pub enum WlSeatError { - #[error("Could not handle `get_pointer` request")] - GetPointerError(#[from] GetPointerError), - #[error("Could not handle `get_keyboard` request")] - GetKeyboardError(#[from] GetKeyboardError), - #[error("Could not handle `get_touch` request")] - GetTouchError(#[from] GetTouchError), - #[error("Could not handle `release` request")] - ReleaseError(#[from] ReleaseError), #[error(transparent)] ClientError(Box), #[error(transparent)] IpcError(#[from] IpcError), -} -efrom!(WlSeatError, ClientError); - -#[derive(Debug, Error)] -pub enum GetPointerError { #[error("Parsing failed")] - ParseError(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(GetPointerError, ClientError); -efrom!(GetPointerError, ParseError, MsgParserError); - -#[derive(Debug, Error)] -pub enum GetKeyboardError { - #[error("Parsing failed")] - ParseError(#[source] Box), - #[error(transparent)] - ClientError(Box), + MsgParserError(#[source] Box), #[error(transparent)] WlKeyboardError(Box), } -efrom!(GetKeyboardError, ClientError); -efrom!(GetKeyboardError, ParseError, MsgParserError); -efrom!(GetKeyboardError, WlKeyboardError, WlKeyboardError); - -#[derive(Debug, Error)] -pub enum GetTouchError { - #[error("Parsing failed")] - ParseError(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(GetTouchError, ClientError, ClientError); -efrom!(GetTouchError, ParseError, MsgParserError); - -#[derive(Debug, Error)] -pub enum ReleaseError { - #[error("Parsing failed")] - ParseError(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(ReleaseError, ClientError, ClientError); -efrom!(ReleaseError, ParseError, MsgParserError); +efrom!(WlSeatError, ClientError); +efrom!(WlSeatError, MsgParserError); +efrom!(WlSeatError, WlKeyboardError); pub fn collect_kb_foci2(node: Rc, seats: &mut SmallVec<[Rc; 3]>) { node.node_visit(&mut generic_node_visitor(|node| { diff --git a/src/ifs/wl_seat/wl_keyboard.rs b/src/ifs/wl_seat/wl_keyboard.rs index 250cf14d..2046adc4 100644 --- a/src/ifs/wl_seat/wl_keyboard.rs +++ b/src/ifs/wl_seat/wl_keyboard.rs @@ -11,6 +11,7 @@ use { thiserror::Error, uapi::OwnedFd, }; +use crate::utils::oserror::OsError; pub const REPEAT_INFO_SINCE: u32 = 4; @@ -98,7 +99,7 @@ impl WlKeyboard { }) } - fn release(&self, parser: MsgParser<'_, '_>) -> Result<(), ReleaseError> { + fn release(&self, parser: MsgParser<'_, '_>) -> Result<(), WlKeyboardError> { let _req: Release = self.seat.client.parse(self, parser)?; self.seat.keyboards.remove(&self.id); self.seat.client.remove_obj(self)?; @@ -107,7 +108,7 @@ impl WlKeyboard { } object_base! { - WlKeyboard, WlKeyboardError; + WlKeyboard; RELEASE => release, } @@ -124,21 +125,12 @@ simple_add_obj!(WlKeyboard); pub enum WlKeyboardError { #[error(transparent)] ClientError(Box), - #[error("Could not process a `release` request")] - ReleaseError(#[from] ReleaseError), #[error("Could not create a keymap memfd")] - KeymapMemfd(#[source] crate::utils::oserror::OsError), + KeymapMemfd(#[source] OsError), #[error("Could not copy the keymap")] - KeymapCopy(#[source] crate::utils::oserror::OsError), -} -efrom!(WlKeyboardError, ClientError, ClientError); - -#[derive(Debug, Error)] -pub enum ReleaseError { + KeymapCopy(#[source] OsError), #[error("Parsing failed")] - ParseError(#[source] Box), - #[error(transparent)] - ClientError(Box), + MsgParserError(#[source] Box), } -efrom!(ReleaseError, ParseError, MsgParserError); -efrom!(ReleaseError, ClientError, ClientError); +efrom!(WlKeyboardError, ClientError); +efrom!(WlKeyboardError, MsgParserError); diff --git a/src/ifs/wl_seat/wl_pointer.rs b/src/ifs/wl_seat/wl_pointer.rs index b642ee27..cc549858 100644 --- a/src/ifs/wl_seat/wl_pointer.rs +++ b/src/ifs/wl_seat/wl_pointer.rs @@ -154,7 +154,7 @@ impl WlPointer { }) } - fn set_cursor(&self, parser: MsgParser<'_, '_>) -> Result<(), SetCursorError> { + fn set_cursor(&self, parser: MsgParser<'_, '_>) -> Result<(), WlPointerError> { let req: SetCursor = self.seat.client.parse(self, parser)?; if !self.seat.client.valid_serial(req.serial) { log::warn!("Client tried to set_cursor with an invalid serial"); @@ -184,7 +184,7 @@ impl WlPointer { Ok(()) } - fn release(&self, parser: MsgParser<'_, '_>) -> Result<(), ReleaseError> { + fn release(&self, parser: MsgParser<'_, '_>) -> Result<(), WlPointerError> { let _req: Release = self.seat.client.parse(self, parser)?; self.seat.pointers.remove(&self.id); self.seat.client.remove_obj(self)?; @@ -193,7 +193,7 @@ impl WlPointer { } object_base! { - WlPointer, WlPointerError; + WlPointer; SET_CURSOR => set_cursor, RELEASE => release, @@ -211,32 +211,11 @@ simple_add_obj!(WlPointer); pub enum WlPointerError { #[error(transparent)] ClientError(Box), - #[error("Could not process a `set_cursor` request")] - SetCursorError(#[from] SetCursorError), - #[error("Could not process a `release` request")] - ReleaseError(#[from] ReleaseError), -} -efrom!(WlPointerError, ClientError); - -#[derive(Debug, Error)] -pub enum SetCursorError { #[error("Parsing failed")] - ParseError(#[source] Box), - #[error(transparent)] - ClientError(Box), + MsgParserError(#[source] Box), #[error(transparent)] WlSurfaceError(Box), } -efrom!(SetCursorError, ParseError, MsgParserError); -efrom!(SetCursorError, ClientError); -efrom!(SetCursorError, WlSurfaceError); - -#[derive(Debug, Error)] -pub enum ReleaseError { - #[error("Parsing failed")] - ParseError(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(ReleaseError, ParseError, MsgParserError); -efrom!(ReleaseError, ClientError, ClientError); +efrom!(WlPointerError, ClientError); +efrom!(WlPointerError, MsgParserError); +efrom!(WlPointerError, WlSurfaceError); diff --git a/src/ifs/wl_seat/wl_touch.rs b/src/ifs/wl_seat/wl_touch.rs index 4d864106..3a470769 100644 --- a/src/ifs/wl_seat/wl_touch.rs +++ b/src/ifs/wl_seat/wl_touch.rs @@ -41,7 +41,7 @@ impl WlTouch { } } - fn release(&self, parser: MsgParser<'_, '_>) -> Result<(), ReleaseError> { + fn release(&self, parser: MsgParser<'_, '_>) -> Result<(), WlTouchError> { let _req: Release = self.seat.client.parse(self, parser)?; self.seat.client.remove_obj(self)?; Ok(()) @@ -49,7 +49,7 @@ impl WlTouch { } object_base! { - WlTouch, WlTouchError; + WlTouch; RELEASE => release, } @@ -66,17 +66,8 @@ simple_add_obj!(WlTouch); pub enum WlTouchError { #[error(transparent)] ClientError(Box), - #[error("Could not process a `release` request")] - ReleaseError(#[from] ReleaseError), + #[error("Parsing failed")] + MsgParserError(#[source] Box), } efrom!(WlTouchError, ClientError); - -#[derive(Debug, Error)] -pub enum ReleaseError { - #[error("Parsing failed")] - ParseError(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(ReleaseError, ParseError, MsgParserError); -efrom!(ReleaseError, ClientError); +efrom!(WlTouchError, MsgParserError); diff --git a/src/ifs/wl_shm.rs b/src/ifs/wl_shm.rs index a2f44c61..2222e816 100644 --- a/src/ifs/wl_shm.rs +++ b/src/ifs/wl_shm.rs @@ -54,10 +54,10 @@ impl WlShmGlobal { } impl WlShm { - fn create_pool(&self, parser: MsgParser<'_, '_>) -> Result<(), CreatePoolError> { + fn create_pool(&self, parser: MsgParser<'_, '_>) -> Result<(), WlShmError> { let create: CreatePool = self.client.parse(self, parser)?; if create.size < 0 { - return Err(CreatePoolError::NegativeSize); + return Err(WlShmError::NegativeSize); } let pool = Rc::new(WlShmPool::new( create.id, @@ -86,7 +86,7 @@ impl Global for WlShmGlobal { simple_add_global!(WlShmGlobal); object_base! { - WlShm, WlShmError; + WlShm; CREATE_POOL => create_pool, } @@ -103,22 +103,13 @@ simple_add_obj!(WlShm); pub enum WlShmError { #[error(transparent)] ClientError(Box), - #[error("Could not process a `create_pool` request")] - CreatePoolError(#[from] CreatePoolError), -} -efrom!(WlShmError, ClientError); - -#[derive(Debug, Error)] -pub enum CreatePoolError { #[error("Parsing failed")] - ParseError(#[source] Box), + MsgParserError(#[source] Box), #[error("The passed size is negative")] NegativeSize, #[error(transparent)] WlShmPoolError(Box), - #[error(transparent)] - ClientError(Box), } -efrom!(CreatePoolError, ParseError, MsgParserError); -efrom!(CreatePoolError, WlShmPoolError); -efrom!(CreatePoolError, ClientError); +efrom!(WlShmError, ClientError); +efrom!(WlShmError, MsgParserError); +efrom!(WlShmError, WlShmPoolError); diff --git a/src/ifs/wl_shm_pool.rs b/src/ifs/wl_shm_pool.rs index 29cf6862..0d888c16 100644 --- a/src/ifs/wl_shm_pool.rs +++ b/src/ifs/wl_shm_pool.rs @@ -41,15 +41,15 @@ impl WlShmPool { }) } - fn create_buffer(&self, parser: MsgParser<'_, '_>) -> Result<(), CreateBufferError> { + fn create_buffer(&self, parser: MsgParser<'_, '_>) -> Result<(), WlShmPoolError> { let req: CreateBuffer = self.client.parse(self, parser)?; let drm_format = map_wayland_format_id(req.format); let format = match formats().get(&drm_format) { Some(f) => *f, - _ => return Err(CreateBufferError::InvalidFormat(req.format)), + _ => return Err(WlShmPoolError::InvalidFormat(req.format)), }; if req.height < 0 || req.width < 0 || req.stride < 0 || req.offset < 0 { - return Err(CreateBufferError::NegativeParameters); + return Err(WlShmPoolError::NegativeParameters); } let buffer = Rc::new(WlBuffer::new_shm( req.id, @@ -66,19 +66,19 @@ impl WlShmPool { Ok(()) } - fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), WlShmPoolError> { let _req: Destroy = self.client.parse(self, parser)?; self.client.remove_obj(self)?; Ok(()) } - fn resize(&self, parser: MsgParser<'_, '_>) -> Result<(), ResizeError> { + fn resize(&self, parser: MsgParser<'_, '_>) -> Result<(), WlShmPoolError> { let req: Resize = self.client.parse(self, parser)?; if req.size < 0 { - return Err(ResizeError::NegativeSize); + return Err(WlShmPoolError::NegativeSize); } if (req.size as usize) < self.mem.get().len() { - return Err(ResizeError::CannotShrink); + return Err(WlShmPoolError::CannotShrink); } self.mem .set(Rc::new(ClientMem::new(self.fd.raw(), req.size as usize)?)); @@ -87,7 +87,7 @@ impl WlShmPool { } object_base! { - WlShmPool, WlShmPoolError; + WlShmPool; CREATE_BUFFER => create_buffer, DESTROY => destroy, @@ -106,24 +106,14 @@ simple_add_obj!(WlShmPool); pub enum WlShmPoolError { #[error(transparent)] ClientError(Box), - #[error("Could not process a `create_buffer` request")] - CreateBufferError(#[from] CreateBufferError), - #[error("Could not process a `destroy` request")] - DestroyError(#[from] DestroyError), - #[error("Could not process a `resize` request")] - ResizeError(#[from] ResizeError), #[error(transparent)] ClientMemError(Box), -} -efrom!(WlShmPoolError, ClientError); -efrom!(WlShmPoolError, ClientMemError); - -#[derive(Debug, Error)] -pub enum CreateBufferError { #[error("Parsing failed")] - ParseError(#[source] Box), - #[error(transparent)] - ClientError(Box), + MsgParserError(#[source] Box), + #[error("Tried to shrink the pool")] + CannotShrink, + #[error("Requested size is negative")] + NegativeSize, #[error("Format {0} is not supported")] InvalidFormat(u32), #[error("All parameters in a create_buffer request must be non-negative")] @@ -131,30 +121,7 @@ pub enum CreateBufferError { #[error(transparent)] WlBufferError(Box), } -efrom!(CreateBufferError, ParseError, MsgParserError); -efrom!(CreateBufferError, ClientError); -efrom!(CreateBufferError, WlBufferError); - -#[derive(Debug, Error)] -pub enum DestroyError { - #[error("Parsing failed")] - ParseError(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(DestroyError, ParseError, MsgParserError); -efrom!(DestroyError, ClientError); - -#[derive(Debug, Error)] -pub enum ResizeError { - #[error("Parsing failed")] - ParseError(#[source] Box), - #[error("Tried to shrink the pool")] - CannotShrink, - #[error("Requested size is negative")] - NegativeSize, - #[error(transparent)] - ClientMemError(Box), -} -efrom!(ResizeError, ParseError, MsgParserError); -efrom!(ResizeError, ClientMemError); +efrom!(WlShmPoolError, ClientError); +efrom!(WlShmPoolError, ClientMemError); +efrom!(WlShmPoolError, WlBufferError); +efrom!(WlShmPoolError, MsgParserError); diff --git a/src/ifs/wl_subcompositor.rs b/src/ifs/wl_subcompositor.rs index e7548d0f..350ac29f 100644 --- a/src/ifs/wl_subcompositor.rs +++ b/src/ifs/wl_subcompositor.rs @@ -48,13 +48,13 @@ impl WlSubcompositorGlobal { } impl WlSubcompositor { - fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), WlSubcompositorError> { let _req: Destroy = self.client.parse(self, parser)?; self.client.remove_obj(self)?; Ok(()) } - fn get_subsurface(&self, parser: MsgParser<'_, '_>) -> Result<(), GetSubsurfaceError> { + fn get_subsurface(&self, parser: MsgParser<'_, '_>) -> Result<(), WlSubcompositorError> { let req: GetSubsurface = self.client.parse(self, parser)?; let surface = self.client.lookup(req.surface)?; let parent = self.client.lookup(req.parent)?; @@ -81,7 +81,7 @@ impl Global for WlSubcompositorGlobal { simple_add_global!(WlSubcompositorGlobal); object_base! { - WlSubcompositor, WlSubcompositorError; + WlSubcompositor; DESTROY => destroy, GET_SUBSURFACE => get_subsurface, @@ -99,32 +99,11 @@ simple_add_obj!(WlSubcompositor); pub enum WlSubcompositorError { #[error(transparent)] ClientError(Box), - #[error("Could not process `destroy` request")] - DestroyError(#[from] DestroyError), - #[error("Could not process `get_subsurface` request")] - GetSubsurfaceError(#[from] GetSubsurfaceError), + #[error("Parsing failed")] + MsgParserError(#[source] Box), + #[error(transparent)] + WlSubsurfaceError(Box), } efrom!(WlSubcompositorError, ClientError); - -#[derive(Debug, Error)] -pub enum DestroyError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(DestroyError, ParseFailed, MsgParserError); -efrom!(DestroyError, ClientError); - -#[derive(Debug, Error)] -pub enum GetSubsurfaceError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), - #[error(transparent)] - SubsurfaceError(Box), -} -efrom!(GetSubsurfaceError, ParseFailed, MsgParserError); -efrom!(GetSubsurfaceError, ClientError); -efrom!(GetSubsurfaceError, SubsurfaceError, WlSubsurfaceError); +efrom!(WlSubcompositorError, MsgParserError); +efrom!(WlSubcompositorError, WlSubsurfaceError); diff --git a/src/ifs/wl_surface.rs b/src/ifs/wl_surface.rs index 866ae730..81fa735d 100644 --- a/src/ifs/wl_surface.rs +++ b/src/ifs/wl_surface.rs @@ -375,7 +375,7 @@ impl WlSurface { } } - fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), WlSurfaceError> { let _req: Destroy = self.parse(parser)?; self.unset_dnd_icons(); self.unset_cursors(); @@ -402,7 +402,7 @@ impl WlSurface { Ok(()) } - fn attach(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), AttachError> { + fn attach(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), WlSurfaceError> { let req: Attach = self.parse(parser)?; let buf = if req.buffer.is_some() { Some((req.x, req.y, self.client.lookup(req.buffer)?)) @@ -413,13 +413,13 @@ impl WlSurface { Ok(()) } - fn damage(&self, parser: MsgParser<'_, '_>) -> Result<(), DamageError> { + fn damage(&self, parser: MsgParser<'_, '_>) -> Result<(), WlSurfaceError> { let _req: Damage = self.parse(parser)?; self.pending.damage.set(true); Ok(()) } - fn frame(&self, parser: MsgParser<'_, '_>) -> Result<(), FrameError> { + fn frame(&self, parser: MsgParser<'_, '_>) -> Result<(), WlSurfaceError> { let req: Frame = self.parse(parser)?; let cb = Rc::new(WlCallback::new(req.callback, &self.client)); track!(self.client, cb); @@ -428,7 +428,7 @@ impl WlSurface { Ok(()) } - fn set_opaque_region(&self, parser: MsgParser<'_, '_>) -> Result<(), SetOpaqueRegionError> { + fn set_opaque_region(&self, parser: MsgParser<'_, '_>) -> Result<(), WlSurfaceError> { let region: SetOpaqueRegion = self.parse(parser)?; let region = if region.region.is_some() { Some(self.client.lookup(region.region)?.region()) @@ -439,7 +439,7 @@ impl WlSurface { Ok(()) } - fn set_input_region(&self, parser: MsgParser<'_, '_>) -> Result<(), SetInputRegionError> { + fn set_input_region(&self, parser: MsgParser<'_, '_>) -> Result<(), WlSurfaceError> { let req: SetInputRegion = self.parse(parser)?; let region = if req.region.is_some() { Some(self.client.lookup(req.region)?.region()) @@ -533,7 +533,7 @@ impl WlSurface { Ok(()) } - fn commit(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), CommitError> { + fn commit(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), WlSurfaceError> { let _req: Commit = self.parse(parser)?; self.do_commit(CommitContext::RootCommit)?; Ok(()) @@ -542,17 +542,17 @@ impl WlSurface { fn set_buffer_transform( &self, parser: MsgParser<'_, '_>, - ) -> Result<(), SetBufferTransformError> { + ) -> Result<(), WlSurfaceError> { let _req: SetBufferTransform = self.parse(parser)?; Ok(()) } - fn set_buffer_scale(&self, parser: MsgParser<'_, '_>) -> Result<(), SetBufferScaleError> { + fn set_buffer_scale(&self, parser: MsgParser<'_, '_>) -> Result<(), WlSurfaceError> { let _req: SetBufferScale = self.parse(parser)?; Ok(()) } - fn damage_buffer(&self, parser: MsgParser<'_, '_>) -> Result<(), DamageBufferError> { + fn damage_buffer(&self, parser: MsgParser<'_, '_>) -> Result<(), WlSurfaceError> { let _req: DamageBuffer = self.parse(parser)?; self.pending.damage.set(true); Ok(()) @@ -670,7 +670,7 @@ impl WlSurface { } object_base! { - WlSurface, WlSurfaceError; + WlSurface; DESTROY => destroy, ATTACH => attach, @@ -832,26 +832,6 @@ pub enum WlSurfaceError { ZwlrLayerSurfaceV1Error(Box), #[error(transparent)] XdgSurfaceError(Box), - #[error("Could not process `destroy` request")] - DestroyError(#[source] Box), - #[error("Could not process `attach` request")] - AttachError(#[source] Box), - #[error("Could not process `damage` request")] - DamageError(#[source] Box), - #[error("Could not process `frame` request")] - FrameError(#[source] Box), - #[error("Could not process `set_opaque_region` request")] - SetOpaqueRegionError(#[source] Box), - #[error("Could not process `set_input_region` request")] - SetInputRegionError(#[source] Box), - #[error("Could not process `commit` request")] - CommitError(#[source] Box), - #[error("Could not process `set_buffer_transform` request")] - SetBufferTransformError(#[source] Box), - #[error("Could not process `set_buffer_scale_error` request")] - SetBufferScaleError(#[source] Box), - #[error("Could not process `damage_buffer` request")] - DamageBufferError(#[source] Box), #[error("Surface {} cannot be assigned the role {} because it already has the role {}", .id, .new.name(), .old.name())] IncompatibleRole { id: WlSurfaceId, @@ -860,111 +840,10 @@ pub enum WlSurfaceError { }, #[error("Cannot destroy a `wl_surface` before its role object")] ReloObjectStillExists, + #[error("Parsing failed")] + MsgParserError(#[source] Box), } efrom!(WlSurfaceError, ClientError); efrom!(WlSurfaceError, XdgSurfaceError); -efrom!(WlSurfaceError, DestroyError); -efrom!(WlSurfaceError, AttachError); -efrom!(WlSurfaceError, DamageError); -efrom!(WlSurfaceError, FrameError); -efrom!(WlSurfaceError, SetOpaqueRegionError); -efrom!(WlSurfaceError, SetInputRegionError); -efrom!(WlSurfaceError, CommitError); -efrom!(WlSurfaceError, SetBufferTransformError); -efrom!(WlSurfaceError, SetBufferScaleError); -efrom!(WlSurfaceError, DamageBufferError); efrom!(WlSurfaceError, ZwlrLayerSurfaceV1Error); - -#[derive(Debug, Error)] -pub enum DestroyError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), - #[error(transparent)] - WlSurfaceError(Box), -} -efrom!(DestroyError, ParseFailed, MsgParserError); -efrom!(DestroyError, ClientError); -efrom!(DestroyError, WlSurfaceError); - -#[derive(Debug, Error)] -pub enum AttachError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(AttachError, ParseFailed, MsgParserError); -efrom!(AttachError, ClientError); - -#[derive(Debug, Error)] -pub enum DamageError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), -} -efrom!(DamageError, ParseFailed, MsgParserError); - -#[derive(Debug, Error)] -pub enum FrameError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(FrameError, ParseFailed, MsgParserError); -efrom!(FrameError, ClientError); - -#[derive(Debug, Error)] -pub enum SetOpaqueRegionError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(SetOpaqueRegionError, ParseFailed, MsgParserError); -efrom!(SetOpaqueRegionError, ClientError); - -#[derive(Debug, Error)] -pub enum SetInputRegionError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(SetInputRegionError, ParseFailed, MsgParserError); -efrom!(SetInputRegionError, ClientError); - -#[derive(Debug, Error)] -pub enum CommitError { - #[error(transparent)] - WlSurfaceError(Box), - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(CommitError, WlSurfaceError); -efrom!(CommitError, ParseFailed, MsgParserError); -efrom!(CommitError, ClientError); - -#[derive(Debug, Error)] -pub enum SetBufferTransformError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), -} -efrom!(SetBufferTransformError, ParseFailed, MsgParserError); - -#[derive(Debug, Error)] -pub enum SetBufferScaleError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), -} -efrom!(SetBufferScaleError, ParseFailed, MsgParserError); - -#[derive(Debug, Error)] -pub enum DamageBufferError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), -} -efrom!(DamageBufferError, ParseFailed, MsgParserError); +efrom!(WlSurfaceError, MsgParserError); diff --git a/src/ifs/wl_surface/wl_subsurface.rs b/src/ifs/wl_surface/wl_subsurface.rs index 4ebf881f..fe488d12 100644 --- a/src/ifs/wl_surface/wl_subsurface.rs +++ b/src/ifs/wl_surface/wl_subsurface.rs @@ -136,7 +136,7 @@ impl WlSubsurface { Ok(()) } - fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), WlSubsurfaceError> { let _req: Destroy = self.surface.client.parse(self, parser)?; self.surface.unset_ext(); *self.node.borrow_mut() = None; @@ -160,15 +160,15 @@ impl WlSubsurface { Ok(()) } - fn set_position(&self, parser: MsgParser<'_, '_>) -> Result<(), SetPositionError> { + fn set_position(&self, parser: MsgParser<'_, '_>) -> Result<(), WlSubsurfaceError> { let req: SetPosition = self.surface.client.parse(self, parser)?; self.pending.position.set(Some((req.x, req.y))); Ok(()) } - fn place(self: &Rc, sibling: WlSurfaceId, above: bool) -> Result<(), PlacementError> { + fn place(self: &Rc, sibling: WlSurfaceId, above: bool) -> Result<(), WlSubsurfaceError> { if sibling == self.surface.id { - return Err(PlacementError::AboveSelf(sibling)); + return Err(WlSubsurfaceError::AboveSelf(sibling)); } let pdata = self.parent.children.borrow(); if let Some(pdata) = &*pdata { @@ -184,7 +184,7 @@ impl WlSubsurface { } else { let sibling = match pdata.subsurfaces.get(&sibling) { Some(s) => s, - _ => return Err(PlacementError::NotASibling(sibling, self.surface.id)), + _ => return Err(WlSubsurfaceError::NotASibling(sibling, self.surface.id)), }; let node = match sibling.pending.node.borrow().deref() { Some(n) => n.to_ref(), @@ -203,13 +203,13 @@ impl WlSubsurface { Ok(()) } - fn place_above(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), PlaceAboveError> { + fn place_above(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), WlSubsurfaceError> { let req: PlaceAbove = self.surface.client.parse(self.deref(), parser)?; self.place(req.sibling, true)?; Ok(()) } - fn place_below(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), PlaceBelowError> { + fn place_below(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), WlSubsurfaceError> { let req: PlaceBelow = self.surface.client.parse(self.deref(), parser)?; self.place(req.sibling, false)?; Ok(()) @@ -228,13 +228,13 @@ impl WlSubsurface { } } - fn set_sync(&self, parser: MsgParser<'_, '_>) -> Result<(), SetSyncError> { + fn set_sync(&self, parser: MsgParser<'_, '_>) -> Result<(), WlSubsurfaceError> { let _req: SetSync = self.surface.client.parse(self, parser)?; self.update_sync(true); Ok(()) } - fn set_desync(&self, parser: MsgParser<'_, '_>) -> Result<(), SetDesyncError> { + fn set_desync(&self, parser: MsgParser<'_, '_>) -> Result<(), WlSubsurfaceError> { let _req: SetDesync = self.surface.client.parse(self, parser)?; self.update_sync(false); Ok(()) @@ -242,7 +242,7 @@ impl WlSubsurface { } object_base! { - WlSubsurface, WlSubsurfaceError; + WlSubsurface; DESTROY => destroy, SET_POSITION => set_position, @@ -303,18 +303,6 @@ impl SurfaceExt for WlSubsurface { #[derive(Debug, Error)] pub enum WlSubsurfaceError { - #[error("Could not process `destroy` request")] - DestroyError(#[from] DestroyError), - #[error("Could not process `set_position` request")] - SetPosition(#[from] SetPositionError), - #[error("Could not process `place_above` request")] - PlaceAbove(#[from] PlaceAboveError), - #[error("Could not process `place_below` request")] - PlaceBelow(#[from] PlaceBelowError), - #[error("Could not process `set_sync` request")] - SetSync(#[from] SetSyncError), - #[error("Could not process `set_desync` request")] - SetDesync(#[from] SetDesyncError), #[error("Surface {0} already has an attached `wl_subsurface`")] AlreadyAttached(WlSurfaceId), #[error("Surface {0} cannot be made its own parent")] @@ -325,62 +313,15 @@ pub enum WlSubsurfaceError { MaxDepthExceeded, #[error(transparent)] WlSurfaceError(Box), -} -efrom!(WlSubsurfaceError, WlSurfaceError); - -#[derive(Debug, Error)] -pub enum DestroyError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), #[error(transparent)] ClientError(Box), -} -efrom!(DestroyError, ParseFailed, MsgParserError); -efrom!(DestroyError, ClientError); - -#[derive(Debug, Error)] -pub enum SetPositionError { #[error("Parsing failed")] - ParseFailed(#[source] Box), -} -efrom!(SetPositionError, ParseFailed, MsgParserError); - -#[derive(Debug, Error)] -pub enum PlaceAboveError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - PlacementError(#[from] PlacementError), -} -efrom!(PlaceAboveError, ParseFailed, MsgParserError); - -#[derive(Debug, Error)] -pub enum PlacementError { + MsgParserError(#[source] Box), #[error("Cannot place {0} above/below itself")] AboveSelf(WlSurfaceId), #[error("{0} is not a sibling of {1}")] NotASibling(WlSurfaceId, WlSurfaceId), } - -#[derive(Debug, Error)] -pub enum PlaceBelowError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - PlacementError(#[from] PlacementError), -} -efrom!(PlaceBelowError, ParseFailed, MsgParserError); - -#[derive(Debug, Error)] -pub enum SetSyncError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), -} -efrom!(SetSyncError, ParseFailed, MsgParserError); - -#[derive(Debug, Error)] -pub enum SetDesyncError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), -} -efrom!(SetDesyncError, ParseFailed, MsgParserError); +efrom!(WlSubsurfaceError, WlSurfaceError); +efrom!(WlSubsurfaceError, MsgParserError); +efrom!(WlSubsurfaceError, ClientError); diff --git a/src/ifs/wl_surface/xdg_surface.rs b/src/ifs/wl_surface/xdg_surface.rs index 2f0e582a..f606b7d7 100644 --- a/src/ifs/wl_surface/xdg_surface.rs +++ b/src/ifs/wl_surface/xdg_surface.rs @@ -181,15 +181,15 @@ impl XdgSurface { Ok(()) } - fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgSurfaceError> { let _req: Destroy = self.surface.client.parse(self, parser)?; if self.ext.get().is_some() { - return Err(DestroyError::RoleNotYetDestroyed(self.id)); + return Err(XdgSurfaceError::RoleNotYetDestroyed(self.id)); } { let children = self.popups.lock(); if !children.is_empty() { - return Err(DestroyError::PopupsNotYetDestroyed); + return Err(XdgSurfaceError::PopupsNotYetDestroyed); } } self.surface.unset_ext(); @@ -198,7 +198,7 @@ impl XdgSurface { Ok(()) } - fn get_toplevel(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), GetToplevelError> { + fn get_toplevel(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), XdgSurfaceError> { let req: GetToplevel = self.surface.client.parse(&**self, parser)?; self.set_role(XdgSurfaceRole::XdgToplevel)?; if self.ext.get().is_some() { @@ -210,7 +210,7 @@ impl XdgSurface { self.surface.id ), ); - return Err(GetToplevelError::AlreadyConstructed); + return Err(XdgSurfaceError::AlreadyConstructed); } let toplevel = Rc::new(XdgToplevel::new(req.id, self)); track!(self.surface.client, toplevel); @@ -220,7 +220,7 @@ impl XdgSurface { Ok(()) } - fn get_popup(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), GetPopupError> { + fn get_popup(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), XdgSurfaceError> { let req: GetPopup = self.surface.client.parse(&**self, parser)?; self.set_role(XdgSurfaceRole::XdgPopup)?; let mut parent = None; @@ -237,7 +237,7 @@ impl XdgSurface { self.surface.id ), ); - return Err(GetPopupError::AlreadyConstructed); + return Err(XdgSurfaceError::AlreadyConstructed); } let popup = Rc::new(XdgPopup::new(req.id, self, parent.as_ref(), &positioner)?); track!(self.surface.client, popup); @@ -249,17 +249,17 @@ impl XdgSurface { Ok(()) } - fn set_window_geometry(&self, parser: MsgParser<'_, '_>) -> Result<(), SetWindowGeometryError> { + fn set_window_geometry(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgSurfaceError> { let req: SetWindowGeometry = self.surface.client.parse(self, parser)?; if req.height <= 0 || req.width <= 0 { - return Err(SetWindowGeometryError::NonPositiveWidthHeight); + return Err(XdgSurfaceError::NonPositiveWidthHeight); } let extents = Rect::new_sized(req.x, req.y, req.width, req.height).unwrap(); self.pending.geometry.set(Some(extents)); Ok(()) } - fn ack_configure(&self, parser: MsgParser<'_, '_>) -> Result<(), AckConfigureError> { + fn ack_configure(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgSurfaceError> { let req: AckConfigure = self.surface.client.parse(self, parser)?; if self.requested_serial.get() == req.serial { self.acked_serial.set(Some(req.serial)); @@ -306,7 +306,7 @@ impl XdgSurface { } object_base! { - XdgSurface, XdgSurfaceError; + XdgSurface; DESTROY => destroy, GET_TOPLEVEL => get_toplevel, @@ -368,21 +368,9 @@ impl SurfaceExt for XdgSurface { #[derive(Debug, Error)] pub enum XdgSurfaceError { - #[error("Could not process `destroy` request")] - DestroyError(#[from] DestroyError), - #[error("Could not process `get_toplevel` request")] - GetToplevelError(#[from] GetToplevelError), - #[error("Could not process `get_popup` request")] - GetPopupError(#[from] GetPopupError), - #[error("Could not process `set_window_geometry` request")] - SetWindowGeometryError(#[from] SetWindowGeometryError), - #[error("Could not process `ack_configure` request")] - AckConfigureError(#[from] AckConfigureError), #[error("Surface {0} cannot be turned into a xdg_surface because it already has an attached xdg_surface")] AlreadyAttached(WlSurfaceId), #[error(transparent)] - WlSurfaceError(Box), - #[error(transparent)] XdgPopupError(#[from] XdgPopupError), #[error("Surface {} cannot be assigned the role {} because it already has the role {}", .id, .new.name(), .old.name())] IncompatibleRole { @@ -390,80 +378,21 @@ pub enum XdgSurfaceError { old: XdgSurfaceRole, new: XdgSurfaceRole, }, -} -efrom!(XdgSurfaceError, WlSurfaceError); - -#[derive(Debug, Error)] -pub enum DestroyError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), #[error(transparent)] ClientError(Box), + #[error("Parsing failed")] + MsgParserError(#[source] Box), + #[error("Tried no set a non-positive width/height")] + NonPositiveWidthHeight, #[error("Cannot destroy xdg_surface {0} because it's associated xdg_toplevel/popup is not yet destroyed")] RoleNotYetDestroyed(XdgSurfaceId), #[error("The surface still has popups attached")] PopupsNotYetDestroyed, -} -efrom!(DestroyError, ParseFailed, MsgParserError); -efrom!(DestroyError, ClientError); - -#[derive(Debug, Error)] -pub enum GetToplevelError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), #[error("The surface already has an assigned xdg_toplevel")] AlreadyConstructed, #[error(transparent)] WlSurfaceError(Box), - #[error(transparent)] - XdgSurfaceError(Box), } -efrom!(GetToplevelError, ParseFailed, MsgParserError); -efrom!(GetToplevelError, ClientError); -efrom!(GetToplevelError, WlSurfaceError); -efrom!(GetToplevelError, XdgSurfaceError); - -#[derive(Debug, Error)] -pub enum GetPopupError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), - #[error("The surface already has an assigned xdg_popup")] - AlreadyConstructed, - #[error(transparent)] - WlSurfaceError(Box), - #[error(transparent)] - XdgPopupError(Box), - #[error(transparent)] - XdgSurfaceError(Box), -} -efrom!(GetPopupError, ParseFailed, MsgParserError); -efrom!(GetPopupError, ClientError); -efrom!(GetPopupError, XdgPopupError); -efrom!(GetPopupError, WlSurfaceError); -efrom!(GetPopupError, XdgSurfaceError); - -#[derive(Debug, Error)] -pub enum SetWindowGeometryError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), - #[error("Tried no set a non-positive width/height")] - NonPositiveWidthHeight, -} -efrom!(SetWindowGeometryError, ParseFailed, MsgParserError); -efrom!(SetWindowGeometryError, ClientError); - -#[derive(Debug, Error)] -pub enum AckConfigureError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(AckConfigureError, ParseFailed, MsgParserError); -efrom!(AckConfigureError, ClientError); +efrom!(XdgSurfaceError, WlSurfaceError); +efrom!(XdgSurfaceError, ClientError); +efrom!(XdgSurfaceError, MsgParserError); diff --git a/src/ifs/wl_surface/xdg_surface/xdg_popup.rs b/src/ifs/wl_surface/xdg_surface/xdg_popup.rs index ed87ea38..66cfa65b 100644 --- a/src/ifs/wl_surface/xdg_surface/xdg_popup.rs +++ b/src/ifs/wl_surface/xdg_surface/xdg_popup.rs @@ -201,7 +201,7 @@ impl XdgPopup { } } - fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgPopupError> { let _req: Destroy = self.xdg.surface.client.parse(self, parser)?; self.destroy_node(); { @@ -216,12 +216,12 @@ impl XdgPopup { Ok(()) } - fn grab(&self, parser: MsgParser<'_, '_>) -> Result<(), GrabError> { + fn grab(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgPopupError> { let _req: Grab = self.xdg.surface.client.parse(self, parser)?; Ok(()) } - fn reposition(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), RepositionError> { + fn reposition(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), XdgPopupError> { let req: Reposition = self.xdg.surface.client.parse(&**self, parser)?; *self.pos.borrow_mut() = self.xdg.surface.client.lookup(req.positioner)?.value(); if let Some(parent) = self.parent.get() { @@ -253,7 +253,7 @@ impl XdgPopup { } object_base! { - XdgPopup, XdgPopupError; + XdgPopup; DESTROY => destroy, GRAB => grab, @@ -386,48 +386,12 @@ impl XdgSurfaceExt for XdgPopup { #[derive(Debug, Error)] pub enum XdgPopupError { - #[error("Could not process `destroy` request")] - DestroyError(#[from] DestroyError), - #[error("Could not process `grab` request")] - GrabError(#[from] GrabError), - #[error("Could not process `reposition` request")] - RepositionError(#[from] RepositionError), #[error("The `xdg_positioner` is incomplete")] Incomplete, - #[error("The anchor rectangle of the `xdg_positioner` extends outside the parent")] - #[allow(dead_code)] - AnchorRectOutside, -} - -#[derive(Debug, Error)] -pub enum DestroyError { #[error("Parsing failed")] - ParseFailed(#[source] Box), + MsgParserError(#[source] Box), #[error(transparent)] ClientError(Box), } -efrom!(DestroyError, ParseFailed, MsgParserError); -efrom!(DestroyError, ClientError); - -#[derive(Debug, Error)] -pub enum GrabError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(GrabError, ParseFailed, MsgParserError); -efrom!(GrabError, ClientError); - -#[derive(Debug, Error)] -pub enum RepositionError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), - #[error(transparent)] - XdgPopupError(Box), -} -efrom!(RepositionError, ParseFailed, MsgParserError); -efrom!(RepositionError, ClientError); -efrom!(RepositionError, XdgPopupError); +efrom!(XdgPopupError, MsgParserError); +efrom!(XdgPopupError, ClientError); diff --git a/src/ifs/wl_surface/xdg_surface/xdg_toplevel.rs b/src/ifs/wl_surface/xdg_surface/xdg_toplevel.rs index 98c919eb..f3be0d3a 100644 --- a/src/ifs/wl_surface/xdg_surface/xdg_toplevel.rs +++ b/src/ifs/wl_surface/xdg_surface/xdg_toplevel.rs @@ -165,7 +165,7 @@ impl XdgToplevel { }) } - fn destroy(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> { let _req: Destroy = self.xdg.surface.client.parse(self.deref(), parser)?; self.tl_destroy(); self.xdg.ext.set(None); @@ -193,7 +193,7 @@ impl XdgToplevel { Ok(()) } - fn set_parent(&self, parser: MsgParser<'_, '_>) -> Result<(), SetParentError> { + fn set_parent(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> { let req: SetParent = self.xdg.surface.client.parse(self, parser)?; let mut parent = None; if req.parent.is_some() { @@ -203,25 +203,25 @@ impl XdgToplevel { Ok(()) } - fn set_title(&self, parser: MsgParser<'_, '_>) -> Result<(), SetTitleError> { + fn set_title(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> { let req: SetTitle = self.xdg.surface.client.parse(self, parser)?; *self.toplevel_data.title.borrow_mut() = req.title.to_string(); self.tl_title_changed(); Ok(()) } - fn set_app_id(&self, parser: MsgParser<'_, '_>) -> Result<(), SetAppIdError> { + fn set_app_id(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> { let req: SetAppId = self.xdg.surface.client.parse(self, parser)?; self.bugs.set(bugs::get(req.app_id)); Ok(()) } - fn show_window_menu(&self, parser: MsgParser<'_, '_>) -> Result<(), ShowWindowMenuError> { + fn show_window_menu(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> { let _req: ShowWindowMenu = self.xdg.surface.client.parse(self, parser)?; Ok(()) } - fn move_(&self, parser: MsgParser<'_, '_>) -> Result<(), MoveError> { + fn move_(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> { let req: Move = self.xdg.surface.client.parse(self, parser)?; let seat = self.xdg.surface.client.lookup(req.seat)?; if let Some(parent) = self.toplevel_data.parent.get() { @@ -232,15 +232,15 @@ impl XdgToplevel { Ok(()) } - fn resize(&self, parser: MsgParser<'_, '_>) -> Result<(), ResizeError> { + fn resize(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> { let _req: Resize = self.xdg.surface.client.parse(self, parser)?; Ok(()) } - fn set_max_size(&self, parser: MsgParser<'_, '_>) -> Result<(), SetMaxSizeError> { + fn set_max_size(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> { let req: SetMaxSize = self.xdg.surface.client.parse(self, parser)?; if req.height < 0 || req.width < 0 { - return Err(SetMaxSizeError::NonNegative); + return Err(XdgToplevelError::NonNegative); } self.max_width.set(if req.width == 0 { None @@ -255,10 +255,10 @@ impl XdgToplevel { Ok(()) } - fn set_min_size(&self, parser: MsgParser<'_, '_>) -> Result<(), SetMinSizeError> { + fn set_min_size(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> { let req: SetMinSize = self.xdg.surface.client.parse(self, parser)?; if req.height < 0 || req.width < 0 { - return Err(SetMinSizeError::NonNegative); + return Err(XdgToplevelError::NonNegative); } self.min_width.set(if req.width == 0 { None @@ -273,12 +273,12 @@ impl XdgToplevel { Ok(()) } - fn set_maximized(&self, parser: MsgParser<'_, '_>) -> Result<(), SetMaximizedError> { + fn set_maximized(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> { let _req: SetMaximized = self.xdg.surface.client.parse(self, parser)?; Ok(()) } - fn unset_maximized(&self, parser: MsgParser<'_, '_>) -> Result<(), UnsetMaximizedError> { + fn unset_maximized(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> { let _req: UnsetMaximized = self.xdg.surface.client.parse(self, parser)?; Ok(()) } @@ -286,7 +286,7 @@ impl XdgToplevel { fn set_fullscreen( self: &Rc, parser: MsgParser<'_, '_>, - ) -> Result<(), SetFullscreenError> { + ) -> Result<(), XdgToplevelError> { let client = &self.xdg.surface.client; let req: SetFullscreen = client.parse(self.deref(), parser)?; self.states.borrow_mut().insert(STATE_FULLSCREEN); @@ -314,7 +314,7 @@ impl XdgToplevel { fn unset_fullscreen( self: &Rc, parser: MsgParser<'_, '_>, - ) -> Result<(), UnsetFullscreenError> { + ) -> Result<(), XdgToplevelError> { let _req: UnsetFullscreen = self.xdg.surface.client.parse(self.deref(), parser)?; self.states.borrow_mut().remove(&STATE_FULLSCREEN); self.toplevel_data @@ -323,7 +323,7 @@ impl XdgToplevel { Ok(()) } - fn set_minimized(&self, parser: MsgParser<'_, '_>) -> Result<(), SetMinimizedError> { + fn set_minimized(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> { let _req: SetMinimized = self.xdg.surface.client.parse(self, parser)?; Ok(()) } @@ -347,7 +347,7 @@ impl XdgToplevel { } object_base! { - XdgToplevel, XdgToplevelError; + XdgToplevel; DESTROY => destroy, SET_PARENT => set_parent, @@ -576,176 +576,12 @@ impl XdgSurfaceExt for XdgToplevel { #[derive(Debug, Error)] pub enum XdgToplevelError { - #[error("Could not process `destroy` request")] - DestroyError(#[from] DestroyError), - #[error("Could not process `set_parent` request")] - SetParentError(#[from] SetParentError), - #[error("Could not process `set_title` request")] - SetTitleError(#[from] SetTitleError), - #[error("Could not process `set_app_id` request")] - SetAppIdError(#[from] SetAppIdError), - #[error("Could not process `show_window_menu` request")] - ShowWindowMenuError(#[from] ShowWindowMenuError), - #[error("Could not process `move` request")] - MoveError(#[from] MoveError), - #[error("Could not process `resize` request")] - ResizeError(#[from] ResizeError), - #[error("Could not process `set_max_size` request")] - SetMaxSizeError(#[from] SetMaxSizeError), - #[error("Could not process `set_min_size` request")] - SetMinSizeError(#[from] SetMinSizeError), - #[error("Could not process `set_maximized` request")] - SetMaximizedError(#[from] SetMaximizedError), - #[error("Could not process `unset_maximized` request")] - UnsetMaximizedError(#[from] UnsetMaximizedError), - #[error("Could not process `set_fullscreen` request")] - SetFullscreenError(#[from] SetFullscreenError), - #[error("Could not process `unset_fullscreen` request")] - UnsetFullscreenError(#[from] UnsetFullscreenError), - #[error("Could not process `set_minimized` request")] - SetMinimizedError(#[from] SetMinimizedError), -} - -#[derive(Debug, Error)] -pub enum DestroyError { #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(DestroyError, ParseFailed, MsgParserError); -efrom!(DestroyError, ClientError); - -#[derive(Debug, Error)] -pub enum SetParentError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(SetParentError, ParseFailed, MsgParserError); -efrom!(SetParentError, ClientError); - -#[derive(Debug, Error)] -pub enum SetTitleError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(SetTitleError, ParseFailed, MsgParserError); -efrom!(SetTitleError, ClientError); - -#[derive(Debug, Error)] -pub enum SetAppIdError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(SetAppIdError, ParseFailed, MsgParserError); -efrom!(SetAppIdError, ClientError); - -#[derive(Debug, Error)] -pub enum ShowWindowMenuError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(ShowWindowMenuError, ParseFailed, MsgParserError); -efrom!(ShowWindowMenuError, ClientError); - -#[derive(Debug, Error)] -pub enum MoveError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(MoveError, ParseFailed, MsgParserError); -efrom!(MoveError, ClientError); - -#[derive(Debug, Error)] -pub enum ResizeError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(ResizeError, ParseFailed, MsgParserError); -efrom!(ResizeError, ClientError); - -#[derive(Debug, Error)] -pub enum SetMaxSizeError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), + MsgParserError(#[source] Box), #[error(transparent)] ClientError(Box), #[error("width/height must be non-negative")] NonNegative, } -efrom!(SetMaxSizeError, ParseFailed, MsgParserError); -efrom!(SetMaxSizeError, ClientError); - -#[derive(Debug, Error)] -pub enum SetMinSizeError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), - #[error("width/height must be non-negative")] - NonNegative, -} -efrom!(SetMinSizeError, ParseFailed, MsgParserError); -efrom!(SetMinSizeError, ClientError); - -#[derive(Debug, Error)] -pub enum SetMaximizedError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(SetMaximizedError, ParseFailed, MsgParserError); -efrom!(SetMaximizedError, ClientError); - -#[derive(Debug, Error)] -pub enum UnsetMaximizedError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(UnsetMaximizedError, ParseFailed, MsgParserError); -efrom!(UnsetMaximizedError, ClientError); - -#[derive(Debug, Error)] -pub enum SetFullscreenError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(SetFullscreenError, ParseFailed, MsgParserError); -efrom!(SetFullscreenError, ClientError); - -#[derive(Debug, Error)] -pub enum UnsetFullscreenError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(UnsetFullscreenError, ParseFailed, MsgParserError); -efrom!(UnsetFullscreenError, ClientError, ClientError); - -#[derive(Debug, Error)] -pub enum SetMinimizedError { - #[error("Parsing failed")] - ParseFailed(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(SetMinimizedError, ParseFailed, MsgParserError); -efrom!(SetMinimizedError, ClientError, ClientError); +efrom!(XdgToplevelError, MsgParserError); +efrom!(XdgToplevelError, ClientError); diff --git a/src/ifs/wl_surface/zwlr_layer_surface_v1.rs b/src/ifs/wl_surface/zwlr_layer_surface_v1.rs index 268280c9..7c93bac9 100644 --- a/src/ifs/wl_surface/zwlr_layer_surface_v1.rs +++ b/src/ifs/wl_surface/zwlr_layer_surface_v1.rs @@ -130,10 +130,10 @@ impl ZwlrLayerSurfaceV1 { self.client.event(Closed { self_id: self.id }); } - fn set_size(&self, parser: MsgParser<'_, '_>) -> Result<(), SetSizeError> { + fn set_size(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrLayerSurfaceV1Error> { let req: SetSize = self.client.parse(self, parser)?; if req.width > u16::MAX as u32 || req.height > u16::MAX as u32 { - return Err(SetSizeError::ExcessiveSize); + return Err(ZwlrLayerSurfaceV1Error::ExcessiveSize); } self.pending .size @@ -142,24 +142,24 @@ impl ZwlrLayerSurfaceV1 { Ok(()) } - fn set_anchor(&self, parser: MsgParser<'_, '_>) -> Result<(), SetAnchorError> { + fn set_anchor(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrLayerSurfaceV1Error> { let req: SetAnchor = self.client.parse(self, parser)?; if req.anchor & !(LEFT | RIGHT | TOP | BOTTOM) != 0 { - return Err(SetAnchorError::UnknownAnchor(req.anchor)); + return Err(ZwlrLayerSurfaceV1Error::UnknownAnchor(req.anchor)); } self.pending.anchor.set(Some(req.anchor)); self.pending.any.set(true); Ok(()) } - fn set_exclusive_zone(&self, parser: MsgParser<'_, '_>) -> Result<(), SetExclusiveZoneError> { + fn set_exclusive_zone(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrLayerSurfaceV1Error> { let req: SetExclusiveZone = self.client.parse(self, parser)?; self.pending.exclusive_zone.set(Some(req.zone)); self.pending.any.set(true); Ok(()) } - fn set_margin(&self, parser: MsgParser<'_, '_>) -> Result<(), SetMarginError> { + fn set_margin(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrLayerSurfaceV1Error> { let req: SetMargin = self.client.parse(self, parser)?; self.pending .margin @@ -171,10 +171,10 @@ impl ZwlrLayerSurfaceV1 { fn set_keyboard_interactivity( &self, parser: MsgParser<'_, '_>, - ) -> Result<(), SetKeyboardInteractivityError> { + ) -> Result<(), ZwlrLayerSurfaceV1Error> { let req: SetKeyboardInteractivity = self.client.parse(self, parser)?; if req.keyboard_interactivity > KI_ON_DEMAND { - return Err(SetKeyboardInteractivityError::UnknownKi( + return Err(ZwlrLayerSurfaceV1Error::UnknownKi( req.keyboard_interactivity, )); } @@ -185,18 +185,18 @@ impl ZwlrLayerSurfaceV1 { Ok(()) } - fn get_popup(&self, parser: MsgParser<'_, '_>) -> Result<(), GetPopupError> { + fn get_popup(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrLayerSurfaceV1Error> { let _req: GetPopup = self.client.parse(self, parser)?; Ok(()) } - fn ack_configure(&self, parser: MsgParser<'_, '_>) -> Result<(), AckConfigureError> { + fn ack_configure(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrLayerSurfaceV1Error> { let req: AckConfigure = self.client.parse(self, parser)?; self.acked_serial.set(Some(req.serial)); Ok(()) } - fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrLayerSurfaceV1Error> { let _req: Destroy = self.client.parse(self, parser)?; self.destroy_node(); self.client.remove_obj(self)?; @@ -204,10 +204,10 @@ impl ZwlrLayerSurfaceV1 { Ok(()) } - fn set_layer(&self, parser: MsgParser<'_, '_>) -> Result<(), SetLayerError> { + fn set_layer(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrLayerSurfaceV1Error> { let req: SetLayer = self.client.parse(self, parser)?; if req.layer > OVERLAY { - return Err(SetLayerError::UnknownLayer(req.layer)); + return Err(ZwlrLayerSurfaceV1Error::UnknownLayer(req.layer)); } self.pending.layer.set(Some(req.layer)); self.pending.any.set(true); @@ -396,7 +396,7 @@ impl Node for ZwlrLayerSurfaceV1 { } object_base! { - ZwlrLayerSurfaceV1, ZwlrLayerSurfaceV1Error; + ZwlrLayerSurfaceV1; SET_SIZE => set_size, SET_ANCHOR => set_anchor, @@ -428,24 +428,6 @@ simple_add_obj!(ZwlrLayerSurfaceV1); #[derive(Debug, Error)] pub enum ZwlrLayerSurfaceV1Error { - #[error("Could not process `set_size` request")] - SetSizeError(#[from] SetSizeError), - #[error("Could not process `set_anchor` request")] - SetAnchorError(#[from] SetAnchorError), - #[error("Could not process `set_exclusive_zone` request")] - SetExclusiveZoneError(#[from] SetExclusiveZoneError), - #[error("Could not process `set_margin` request")] - SetMarginError(#[from] SetMarginError), - #[error("Could not process `set_keyboard_interactivity` request")] - SetKeyboardInteractivityError(#[from] SetKeyboardInteractivityError), - #[error("Could not process `get_popup` request")] - GetPopupError(#[from] GetPopupError), - #[error("Could not process `ack_configure` request")] - AckConfigureError(#[from] AckConfigureError), - #[error("Could not process `destroy` request")] - DestroyError(#[from] DestroyError), - #[error("Could not process `set_layer` request")] - SetLayerError(#[from] SetLayerError), #[error("Surface {0} cannot be turned into a zwlr_layer_surface because it already has an attached zwlr_layer_surface")] AlreadyAttached(WlSurfaceId), #[error("Width was set to 0 but anchor did not contain LEFT and RIGHT")] @@ -454,103 +436,19 @@ pub enum ZwlrLayerSurfaceV1Error { HeightZero, #[error(transparent)] WlSurfaceError(Box), -} -efrom!(ZwlrLayerSurfaceV1Error, WlSurfaceError); - -#[derive(Debug, Error)] -pub enum SetSizeError { - #[error("Parsing failed")] - MsgParserError(#[source] Box), - #[error(transparent)] - ClientError(Box), - #[error("Surface size must not be larger than 65535x65535")] - ExcessiveSize, -} -efrom!(SetSizeError, MsgParserError); -efrom!(SetSizeError, ClientError); - -#[derive(Debug, Error)] -pub enum SetAnchorError { - #[error("Parsing failed")] - MsgParserError(#[source] Box), - #[error(transparent)] - ClientError(Box), - #[error("Unknown anchor {0}")] - UnknownAnchor(u32), -} -efrom!(SetAnchorError, MsgParserError); -efrom!(SetAnchorError, ClientError); - -#[derive(Debug, Error)] -pub enum SetExclusiveZoneError { - #[error("Parsing failed")] - MsgParserError(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(SetExclusiveZoneError, MsgParserError); -efrom!(SetExclusiveZoneError, ClientError); - -#[derive(Debug, Error)] -pub enum SetMarginError { - #[error("Parsing failed")] - MsgParserError(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(SetMarginError, MsgParserError); -efrom!(SetMarginError, ClientError); - -#[derive(Debug, Error)] -pub enum SetKeyboardInteractivityError { - #[error("Parsing failed")] - MsgParserError(#[source] Box), - #[error(transparent)] - ClientError(Box), - #[error("Unknown keyboard interactivity {0}")] - UnknownKi(u32), -} -efrom!(SetKeyboardInteractivityError, MsgParserError); -efrom!(SetKeyboardInteractivityError, ClientError); - -#[derive(Debug, Error)] -pub enum GetPopupError { - #[error("Parsing failed")] - MsgParserError(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(GetPopupError, MsgParserError); -efrom!(GetPopupError, ClientError); - -#[derive(Debug, Error)] -pub enum AckConfigureError { - #[error("Parsing failed")] - MsgParserError(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(AckConfigureError, MsgParserError); -efrom!(AckConfigureError, ClientError); - -#[derive(Debug, Error)] -pub enum DestroyError { - #[error("Parsing failed")] - MsgParserError(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(DestroyError, MsgParserError); -efrom!(DestroyError, ClientError); - -#[derive(Debug, Error)] -pub enum SetLayerError { #[error("Parsing failed")] MsgParserError(#[source] Box), #[error(transparent)] ClientError(Box), #[error("Unknown layer {0}")] UnknownLayer(u32), + #[error("Surface size must not be larger than 65535x65535")] + ExcessiveSize, + #[error("Unknown anchor {0}")] + UnknownAnchor(u32), + #[error("Unknown keyboard interactivity {0}")] + UnknownKi(u32), } -efrom!(SetLayerError, MsgParserError); -efrom!(SetLayerError, ClientError); +efrom!(ZwlrLayerSurfaceV1Error, WlSurfaceError); +efrom!(ZwlrLayerSurfaceV1Error, MsgParserError); +efrom!(ZwlrLayerSurfaceV1Error, ClientError); diff --git a/src/ifs/wl_surface/zwp_idle_inhibitor_v1.rs b/src/ifs/wl_surface/zwp_idle_inhibitor_v1.rs index 71063973..c6825cdf 100644 --- a/src/ifs/wl_surface/zwp_idle_inhibitor_v1.rs +++ b/src/ifs/wl_surface/zwp_idle_inhibitor_v1.rs @@ -48,7 +48,7 @@ impl ZwpIdleInhibitorV1 { } } -object_base2! { +object_base! { ZwpIdleInhibitorV1; DESTROY => destroy, diff --git a/src/ifs/wp_presentation.rs b/src/ifs/wp_presentation.rs index 4a3e73f4..1417d263 100644 --- a/src/ifs/wp_presentation.rs +++ b/src/ifs/wp_presentation.rs @@ -90,7 +90,7 @@ impl WpPresentation { } } -object_base2! { +object_base! { WpPresentation; DESTROY => destroy, diff --git a/src/ifs/wp_presentation_feedback.rs b/src/ifs/wp_presentation_feedback.rs index 7db03676..89c02484 100644 --- a/src/ifs/wp_presentation_feedback.rs +++ b/src/ifs/wp_presentation_feedback.rs @@ -50,7 +50,7 @@ impl WpPresentationFeedback { } } -object_base2! { +object_base! { WpPresentationFeedback; } diff --git a/src/ifs/xdg_positioner.rs b/src/ifs/xdg_positioner.rs index 6f0a457c..70b4cd57 100644 --- a/src/ifs/xdg_positioner.rs +++ b/src/ifs/xdg_positioner.rs @@ -157,13 +157,13 @@ impl XdgPositioner { *self.position.borrow() } - fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgPositionerError> { let _req: Destroy = self.client.parse(self, parser)?; self.client.remove_obj(self)?; Ok(()) } - fn set_size(&self, parser: MsgParser<'_, '_>) -> Result<(), SetSizeError> { + fn set_size(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgPositionerError> { let req: SetSize = self.client.parse(self, parser)?; if req.width <= 0 || req.height <= 0 { self.client.protocol_error( @@ -171,7 +171,7 @@ impl XdgPositioner { INVALID_INPUT, &format!("Cannot set a non-positive size"), ); - return Err(SetSizeError::NonPositiveSize); + return Err(XdgPositionerError::NonPositiveSize); } let mut position = self.position.borrow_mut(); position.size_width = req.width; @@ -179,7 +179,7 @@ impl XdgPositioner { Ok(()) } - fn set_anchor_rect(&self, parser: MsgParser<'_, '_>) -> Result<(), SetAnchorRectError> { + fn set_anchor_rect(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgPositionerError> { let req: SetAnchorRect = self.client.parse(self, parser)?; if req.width < 0 || req.height < 0 { self.client.protocol_error( @@ -187,28 +187,28 @@ impl XdgPositioner { INVALID_INPUT, &format!("Cannot set an anchor rect with negative size"), ); - return Err(SetAnchorRectError::NegativeAnchorRect); + return Err(XdgPositionerError::NegativeAnchorRect); } let mut position = self.position.borrow_mut(); position.ar = Rect::new_sized(req.x, req.y, req.width, req.height).unwrap(); Ok(()) } - fn set_anchor(&self, parser: MsgParser<'_, '_>) -> Result<(), SetAnchorError> { + fn set_anchor(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgPositionerError> { let req: SetAnchor = self.client.parse(self, parser)?; let anchor = match Edge::from_enum(req.anchor) { Some(a) => a, - _ => return Err(SetAnchorError::UnknownAnchor(req.anchor)), + _ => return Err(XdgPositionerError::UnknownAnchor(req.anchor)), }; self.position.borrow_mut().anchor = anchor; Ok(()) } - fn set_gravity(&self, parser: MsgParser<'_, '_>) -> Result<(), SetGravityError> { + fn set_gravity(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgPositionerError> { let req: SetGravity = self.client.parse(self, parser)?; let gravity = match Edge::from_enum(req.gravity) { Some(a) => a, - _ => return Err(SetGravityError::UnknownGravity(req.gravity)), + _ => return Err(XdgPositionerError::UnknownGravity(req.gravity)), }; self.position.borrow_mut().gravity = gravity; Ok(()) @@ -217,12 +217,12 @@ impl XdgPositioner { fn set_constraint_adjustment( &self, parser: MsgParser<'_, '_>, - ) -> Result<(), SetConstraintAdjustmentError> { + ) -> Result<(), XdgPositionerError> { let req: SetConstraintAdjustment = self.client.parse(self, parser)?; let ca = match CA::from_bits(req.constraint_adjustment) { Some(c) => c, _ => { - return Err(SetConstraintAdjustmentError::UnknownCa( + return Err(XdgPositionerError::UnknownCa( req.constraint_adjustment, )) } @@ -231,7 +231,7 @@ impl XdgPositioner { Ok(()) } - fn set_offset(&self, parser: MsgParser<'_, '_>) -> Result<(), SetOffsetError> { + fn set_offset(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgPositionerError> { let req: SetOffset = self.client.parse(self, parser)?; let mut position = self.position.borrow_mut(); position.off_x = req.x; @@ -239,13 +239,13 @@ impl XdgPositioner { Ok(()) } - fn set_reactive(&self, parser: MsgParser<'_, '_>) -> Result<(), SetReactiveError> { + fn set_reactive(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgPositionerError> { let _req: SetReactive = self.client.parse(self, parser)?; self.position.borrow_mut().reactive = true; Ok(()) } - fn set_parent_size(&self, parser: MsgParser<'_, '_>) -> Result<(), SetParentSizeError> { + fn set_parent_size(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgPositionerError> { let req: SetParentSize = self.client.parse(self, parser)?; if req.parent_width < 0 || req.parent_height < 0 { self.client.protocol_error( @@ -253,7 +253,7 @@ impl XdgPositioner { INVALID_INPUT, &format!("Cannot set a negative parent size"), ); - return Err(SetParentSizeError::NegativeParentSize); + return Err(XdgPositionerError::NegativeParentSize); } let mut position = self.position.borrow_mut(); position.parent_width = req.parent_width; @@ -264,7 +264,7 @@ impl XdgPositioner { fn set_parent_configure( &self, parser: MsgParser<'_, '_>, - ) -> Result<(), SetParentConfigureError> { + ) -> Result<(), XdgPositionerError> { let req: SetParentConfigure = self.client.parse(self, parser)?; self.position.borrow_mut().parent_serial = req.serial; Ok(()) @@ -272,7 +272,7 @@ impl XdgPositioner { } object_base! { - XdgPositioner, XdgPositionerError; + XdgPositioner; DESTROY => destroy, SET_SIZE => set_size, @@ -300,109 +300,22 @@ dedicated_add_obj!(XdgPositioner, XdgPositionerId, xdg_positioners); #[derive(Debug, Error)] pub enum XdgPositionerError { - #[error("Could not process a `destroy` request")] - DestroyError(#[from] DestroyError), - #[error("Could not process a `set_size` request")] - SetSizeError(#[from] SetSizeError), - #[error("Could not process a `set_anchor_rect` request")] - SetAnchorRectError(#[from] SetAnchorRectError), - #[error("Could not process a `set_anchor` request")] - SetAnchorError(#[from] SetAnchorError), - #[error("Could not process a `set_gravity` request")] - SetGravityError(#[from] SetGravityError), - #[error("Could not process a `set_constraint_adjustment` request")] - SetConstraintAdjustmentError(#[from] SetConstraintAdjustmentError), - #[error("Could not process a `set_offset` request")] - SetOffsetError(#[from] SetOffsetError), - #[error("Could not process a `set_reactive` request")] - SetReactiveError(#[from] SetReactiveError), - #[error("Could not process a `set_parent_size` request")] - SetParentSizeError(#[from] SetParentSizeError), - #[error("Could not process a `set_parent_configure` request")] - SetParentConfigureError(#[from] SetParentConfigureError), -} - -#[derive(Debug, Error)] -pub enum DestroyError { + #[error("Cannot set a non-positive size")] + NonPositiveSize, + #[error("Cannot set an anchor rect with a negative size")] + NegativeAnchorRect, + #[error("Unknown anchor {0}")] + UnknownAnchor(u32), + #[error("Unknown gravity {0}")] + UnknownGravity(u32), + #[error("Unknown constraint adjustment {0}")] + UnknownCa(u32), #[error("Parsing failed")] - ParseError(#[source] Box), + MsgParserError(#[source] Box), + #[error("Cannot set a negative parent size")] + NegativeParentSize, #[error(transparent)] ClientError(Box), } -efrom!(DestroyError, ParseError, MsgParserError); -efrom!(DestroyError, ClientError); - -#[derive(Debug, Error)] -pub enum SetSizeError { - #[error("Parsing failed")] - ParseError(#[source] Box), - #[error("Cannot set a non-positive size")] - NonPositiveSize, -} -efrom!(SetSizeError, ParseError, MsgParserError); - -#[derive(Debug, Error)] -pub enum SetAnchorRectError { - #[error("Parsing failed")] - ParseError(#[source] Box), - #[error("Cannot set an anchor rect with a negative size")] - NegativeAnchorRect, -} -efrom!(SetAnchorRectError, ParseError, MsgParserError); - -#[derive(Debug, Error)] -pub enum SetAnchorError { - #[error("Parsing failed")] - ParseError(#[source] Box), - #[error("Unknown anchor {0}")] - UnknownAnchor(u32), -} -efrom!(SetAnchorError, ParseError, MsgParserError); - -#[derive(Debug, Error)] -pub enum SetGravityError { - #[error("Parsing failed")] - ParseError(#[source] Box), - #[error("Unknown gravity {0}")] - UnknownGravity(u32), -} -efrom!(SetGravityError, ParseError, MsgParserError); - -#[derive(Debug, Error)] -pub enum SetConstraintAdjustmentError { - #[error("Parsing failed")] - ParseError(#[source] Box), - #[error("Unknown constraint adjustment {0}")] - UnknownCa(u32), -} -efrom!(SetConstraintAdjustmentError, ParseError, MsgParserError); - -#[derive(Debug, Error)] -pub enum SetOffsetError { - #[error("Parsing failed")] - ParseError(#[source] Box), -} -efrom!(SetOffsetError, ParseError, MsgParserError); - -#[derive(Debug, Error)] -pub enum SetReactiveError { - #[error("Parsing failed")] - ParseError(#[source] Box), -} -efrom!(SetReactiveError, ParseError, MsgParserError); - -#[derive(Debug, Error)] -pub enum SetParentSizeError { - #[error("Parsing failed")] - ParseError(#[source] Box), - #[error("Cannot set a negative parent size")] - NegativeParentSize, -} -efrom!(SetParentSizeError, ParseError, MsgParserError); - -#[derive(Debug, Error)] -pub enum SetParentConfigureError { - #[error("Parsing failed")] - ParseError(#[source] Box), -} -efrom!(SetParentConfigureError, ParseError, MsgParserError); +efrom!(XdgPositionerError, MsgParserError); +efrom!(XdgPositionerError, ClientError); diff --git a/src/ifs/xdg_wm_base.rs b/src/ifs/xdg_wm_base.rs index 53b6c317..566b34e4 100644 --- a/src/ifs/xdg_wm_base.rs +++ b/src/ifs/xdg_wm_base.rs @@ -67,7 +67,7 @@ impl XdgWmBaseGlobal { } impl XdgWmBase { - fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgWmBaseError> { let _req: Destroy = self.client.parse(self, parser)?; if !self.surfaces.is_empty() { self.client.protocol_error( @@ -78,7 +78,7 @@ impl XdgWmBase { self.id ), ); - return Err(DestroyError::DefunctSurfaces); + return Err(XdgWmBaseError::DefunctSurfaces); } self.client.remove_obj(self)?; Ok(()) @@ -87,7 +87,7 @@ impl XdgWmBase { fn create_positioner( self: &Rc, parser: MsgParser<'_, '_>, - ) -> Result<(), CreatePositionerError> { + ) -> Result<(), XdgWmBaseError> { let req: CreatePositioner = self.client.parse(&**self, parser)?; let pos = Rc::new(XdgPositioner::new(self, req.id, &self.client)); track!(self.client, pos); @@ -98,7 +98,7 @@ impl XdgWmBase { fn get_xdg_surface( self: &Rc, parser: MsgParser<'_, '_>, - ) -> Result<(), GetXdgSurfaceError> { + ) -> Result<(), XdgWmBaseError> { let req: GetXdgSurface = self.client.parse(&**self, parser)?; let surface = self.client.lookup(req.surface)?; let xdg_surface = Rc::new(XdgSurface::new(self, req.id, &surface)); @@ -109,7 +109,7 @@ impl XdgWmBase { Ok(()) } - fn pong(&self, parser: MsgParser<'_, '_>) -> Result<(), PongError> { + fn pong(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgWmBaseError> { let _req: Pong = self.client.parse(self, parser)?; Ok(()) } @@ -130,7 +130,7 @@ impl Global for XdgWmBaseGlobal { simple_add_global!(XdgWmBaseGlobal); object_base! { - XdgWmBase, XdgWmBaseError; + XdgWmBase; DESTROY => destroy, CREATE_POSITIONER => create_positioner, @@ -154,55 +154,13 @@ impl Object for XdgWmBase { pub enum XdgWmBaseError { #[error(transparent)] ClientError(Box), - #[error("Could not process a `destroy` request")] - DestroyError(#[from] DestroyError), - #[error("Could not process a `create_positioner` request")] - CreatePositionerError(#[from] CreatePositionerError), - #[error("Could not process a `get_xdg_surface` request")] - GetXdgSurfaceError(#[from] GetXdgSurfaceError), - #[error("Could not process a `pong` request")] - PongError(#[from] PongError), -} -efrom!(XdgWmBaseError, ClientError); - -#[derive(Debug, Error)] -pub enum DestroyError { #[error("Parsing failed")] - ParseError(#[source] Box), + MsgParserError(#[source] Box), #[error("Tried to destroy xdg_wm_base object before destroying its surfaces")] DefunctSurfaces, #[error(transparent)] - ClientError(Box), -} -efrom!(DestroyError, ParseError, MsgParserError); -efrom!(DestroyError, ClientError); - -#[derive(Debug, Error)] -pub enum CreatePositionerError { - #[error("Parsing failed")] - ParseError(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(CreatePositionerError, ParseError, MsgParserError); -efrom!(CreatePositionerError, ClientError); - -#[derive(Debug, Error)] -pub enum GetXdgSurfaceError { - #[error("Parsing failed")] - ParseError(#[source] Box), - #[error(transparent)] - ClientError(Box), - #[error(transparent)] XdgSurfaceError(Box), } -efrom!(GetXdgSurfaceError, ParseError, MsgParserError); -efrom!(GetXdgSurfaceError, ClientError); -efrom!(GetXdgSurfaceError, XdgSurfaceError); - -#[derive(Debug, Error)] -pub enum PongError { - #[error("Parsing failed")] - ParseError(#[source] Box), -} -efrom!(PongError, ParseError, MsgParserError); +efrom!(XdgWmBaseError, ClientError); +efrom!(XdgWmBaseError, MsgParserError); +efrom!(XdgWmBaseError, XdgSurfaceError); diff --git a/src/ifs/zwlr_layer_shell_v1.rs b/src/ifs/zwlr_layer_shell_v1.rs index 89e4337b..0a977d65 100644 --- a/src/ifs/zwlr_layer_shell_v1.rs +++ b/src/ifs/zwlr_layer_shell_v1.rs @@ -54,7 +54,7 @@ impl ZwlrLayerShellV1Global { } impl ZwlrLayerShellV1 { - fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrLayerSurfaceV1Error> { let _req: Destroy = self.client.parse(self, parser)?; self.client.remove_obj(self)?; Ok(()) @@ -63,7 +63,7 @@ impl ZwlrLayerShellV1 { fn get_layer_surface( self: &Rc, parser: MsgParser<'_, '_>, - ) -> Result<(), GetLayerSurfaceError> { + ) -> Result<(), ZwlrLayerShellV1Error> { let req: GetLayerSurface = self.client.parse(&**self, parser)?; let surface = self.client.lookup(req.surface)?; let output = 'get_output: { @@ -80,11 +80,11 @@ impl ZwlrLayerShellV1 { if let Some(output) = outputs.values().next() { break 'get_output output.node.clone(); } - return Err(GetLayerSurfaceError::NoOutputs); + return Err(ZwlrLayerShellV1Error::NoOutputs); } }; if req.layer > OVERLAY { - return Err(GetLayerSurfaceError::UnknownLayer(req.layer)); + return Err(ZwlrLayerShellV1Error::UnknownLayer(req.layer)); } let surface = Rc::new(ZwlrLayerSurfaceV1::new( req.id, @@ -120,7 +120,7 @@ impl Global for ZwlrLayerShellV1Global { simple_add_global!(ZwlrLayerShellV1Global); object_base! { - ZwlrLayerShellV1, ZwlrLayerShellV1Error; + ZwlrLayerShellV1; GET_LAYER_SURFACE => get_layer_surface, DESTROY => destroy, @@ -141,29 +141,8 @@ impl Object for ZwlrLayerShellV1 { #[derive(Debug, Error)] pub enum ZwlrLayerShellV1Error { - #[error(transparent)] - ClientError(Box), - #[error("Could not process a `destroy` request")] - DestroyError(#[from] DestroyError), - #[error("Could not process a `get_layer_surface` request")] - GetLayerSurfaceError(#[from] GetLayerSurfaceError), -} -efrom!(ZwlrLayerShellV1Error, ClientError); - -#[derive(Debug, Error)] -pub enum DestroyError { #[error("Parsing failed")] - ParseError(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(DestroyError, ParseError, MsgParserError); -efrom!(DestroyError, ClientError); - -#[derive(Debug, Error)] -pub enum GetLayerSurfaceError { - #[error("Parsing failed")] - ParseError(#[source] Box), + MsgParserError(#[source] Box), #[error(transparent)] ClientError(Box), #[error("Unknown layer {0}")] @@ -173,6 +152,6 @@ pub enum GetLayerSurfaceError { #[error(transparent)] ZwlrLayerSurfaceV1Error(Box), } -efrom!(GetLayerSurfaceError, ParseError, MsgParserError); -efrom!(GetLayerSurfaceError, ClientError); -efrom!(GetLayerSurfaceError, ZwlrLayerSurfaceV1Error); +efrom!(ZwlrLayerShellV1Error, ClientError); +efrom!(ZwlrLayerShellV1Error, MsgParserError); +efrom!(ZwlrLayerShellV1Error, ZwlrLayerSurfaceV1Error); diff --git a/src/ifs/zwp_idle_inhibit_manager_v1.rs b/src/ifs/zwp_idle_inhibit_manager_v1.rs index ee7dd835..1d853f07 100644 --- a/src/ifs/zwp_idle_inhibit_manager_v1.rs +++ b/src/ifs/zwp_idle_inhibit_manager_v1.rs @@ -94,7 +94,7 @@ impl ZwpIdleInhibitManagerV1 { } } -object_base2! { +object_base! { ZwpIdleInhibitManagerV1; DESTROY => destroy, diff --git a/src/ifs/zwp_linux_buffer_params_v1.rs b/src/ifs/zwp_linux_buffer_params_v1.rs index 93e241a7..ce2d7c8b 100644 --- a/src/ifs/zwp_linux_buffer_params_v1.rs +++ b/src/ifs/zwp_linux_buffer_params_v1.rs @@ -61,25 +61,25 @@ impl ZwpLinuxBufferParamsV1 { self.parent.client.event(Failed { self_id: self.id }) } - fn destroy(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), ZwpLinuxBufferParamsV1Error> { let _req: Destroy = self.parent.client.parse(&**self, parser)?; self.parent.client.remove_obj(&**self)?; Ok(()) } - fn add(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), AddError> { + fn add(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), ZwpLinuxBufferParamsV1Error> { let req: Add = self.parent.client.parse(&**self, parser)?; let modifier = ((req.modifier_hi as u64) << 32) | req.modifier_lo as u64; match self.modifier.get() { - Some(m) if m != modifier => return Err(AddError::MixedModifiers(modifier, m)), + Some(m) if m != modifier => return Err(ZwpLinuxBufferParamsV1Error::MixedModifiers(modifier, m)), _ => self.modifier.set(Some(modifier)), } let plane = req.plane_idx; if plane > MAX_PLANE { - return Err(AddError::MaxPlane); + return Err(ZwpLinuxBufferParamsV1Error::MaxPlane); } if self.planes.borrow_mut().insert(plane, req).is_some() { - return Err(AddError::AlreadySet(plane)); + return Err(ZwpLinuxBufferParamsV1Error::AlreadySet(plane)); } Ok(()) } @@ -91,22 +91,22 @@ impl ZwpLinuxBufferParamsV1 { height: i32, format: u32, _flags: u32, - ) -> Result { + ) -> Result { let ctx = match self.parent.client.state.render_ctx.get() { Some(ctx) => ctx, - None => return Err(DoCreateError::NoRenderContext), + None => return Err(ZwpLinuxBufferParamsV1Error::NoRenderContext), }; let formats = ctx.formats(); let format = match formats.get(&format) { Some(f) => f, - None => return Err(DoCreateError::InvalidFormat(format)), + None => return Err(ZwpLinuxBufferParamsV1Error::InvalidFormat(format)), }; let modifier = match self.modifier.get() { Some(m) => m, - _ => return Err(DoCreateError::NoPlanes), + _ => return Err(ZwpLinuxBufferParamsV1Error::NoPlanes), }; if !format.modifiers.contains_key(&modifier) { - return Err(DoCreateError::InvalidModifier(modifier)); + return Err(ZwpLinuxBufferParamsV1Error::InvalidModifier(modifier)); } let mut dmabuf = DmaBuf { width, @@ -119,7 +119,7 @@ impl ZwpLinuxBufferParamsV1 { planes.sort_by_key(|a| a.plane_idx); for (i, p) in planes.into_iter().enumerate() { if p.plane_idx as usize != i { - return Err(DoCreateError::MissingPlane(i)); + return Err(ZwpLinuxBufferParamsV1Error::MissingPlane(i)); } dmabuf.planes.push(DmaBufPlane { offset: p.offset, @@ -147,27 +147,27 @@ impl ZwpLinuxBufferParamsV1 { Ok(buffer_id) } - fn create(self: &Rc, parser: MsgParser) -> Result<(), CreateError> { + fn create(self: &Rc, parser: MsgParser) -> Result<(), ZwpLinuxBufferParamsV1Error> { let req: Create = self.parent.client.parse(&**self, parser)?; if self.used.replace(true) { - return Err(CreateError::AlreadyUsed); + return Err(ZwpLinuxBufferParamsV1Error::AlreadyUsed); } match self.do_create(None, req.width, req.height, req.format, req.flags) { Ok(id) => { self.send_created(id); } Err(e) => { - log::debug!("Could not create a dmabuf buffer: {}", ErrorFmt(e)); + log::warn!("Could not create a dmabuf buffer: {}", ErrorFmt(e)); self.send_failed(); } } Ok(()) } - fn create_immed(self: &Rc, parser: MsgParser) -> Result<(), CreateImmedError> { + fn create_immed(self: &Rc, parser: MsgParser) -> Result<(), ZwpLinuxBufferParamsV1Error> { let req: CreateImmed = self.parent.client.parse(&**self, parser)?; if self.used.replace(true) { - return Err(CreateImmedError::AlreadyUsed); + return Err(ZwpLinuxBufferParamsV1Error::AlreadyUsed); } self.do_create( Some(req.buffer_id), @@ -181,7 +181,7 @@ impl ZwpLinuxBufferParamsV1 { } object_base! { - ZwpLinuxBufferParamsV1, ZwpLinuxBufferParamsV1Error; + ZwpLinuxBufferParamsV1; DESTROY => destroy, ADD => add, @@ -199,49 +199,18 @@ simple_add_obj!(ZwpLinuxBufferParamsV1); #[derive(Debug, Error)] pub enum ZwpLinuxBufferParamsV1Error { - #[error("Could not process a `destroy` request")] - DestroyError(#[from] DestroyError), - #[error("Could not process a `add` request")] - AddError(#[from] AddError), - #[error("Could not process a `create` request")] - Create(#[from] CreateError), - #[error("Could not process a `create_immed` request")] - CreateImmed(#[from] CreateImmedError), #[error(transparent)] ClientError(Box), -} -efrom!(ZwpLinuxBufferParamsV1Error, ClientError); - -#[derive(Debug, Error)] -pub enum DestroyError { + #[error("The params object has already been used")] + AlreadyUsed, #[error("Parsing failed")] - ParseError(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(DestroyError, ClientError); -efrom!(DestroyError, ParseError, MsgParserError); - -#[derive(Debug, Error)] -pub enum AddError { - #[error("Parsing failed")] - ParseError(#[source] Box), + MsgParserError(#[source] Box), #[error("A buffer can contain at most 4 planes")] MaxPlane, - #[error(transparent)] - ClientError(Box), #[error("Tried to add a plane with modifier {0} that differs from a previous modifier {1}")] MixedModifiers(u64, u64), #[error("The plane {0} was already set")] AlreadySet(u32), -} -efrom!(AddError, ClientError); -efrom!(AddError, ParseError, MsgParserError); - -#[derive(Debug, Error)] -pub enum DoCreateError { - #[error(transparent)] - ClientError(Box), #[error("The compositor has no render context attached")] NoRenderContext, #[error("The format {0} is not supported")] @@ -255,30 +224,5 @@ pub enum DoCreateError { #[error("Could not import the buffer")] ImportError(#[from] RenderError), } -efrom!(DoCreateError, ClientError); - -#[derive(Debug, Error)] -pub enum CreateError { - #[error("The params object has already been used")] - AlreadyUsed, - #[error("Parsing failed")] - ParseError(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(CreateError, ClientError, ClientError); -efrom!(CreateError, ParseError, MsgParserError); - -#[derive(Debug, Error)] -pub enum CreateImmedError { - #[error("The params object has already been used")] - AlreadyUsed, - #[error("Parsing failed")] - ParseError(#[source] Box), - #[error(transparent)] - DoCreateError(#[from] DoCreateError), - #[error(transparent)] - ClientError(Box), -} -efrom!(CreateImmedError, ClientError, ClientError); -efrom!(CreateImmedError, ParseError, MsgParserError); +efrom!(ZwpLinuxBufferParamsV1Error, ClientError); +efrom!(ZwpLinuxBufferParamsV1Error, MsgParserError); diff --git a/src/ifs/zwp_linux_dmabuf_v1.rs b/src/ifs/zwp_linux_dmabuf_v1.rs index ffaf142c..52408e78 100644 --- a/src/ifs/zwp_linux_dmabuf_v1.rs +++ b/src/ifs/zwp_linux_dmabuf_v1.rs @@ -94,13 +94,13 @@ impl ZwpLinuxDmabufV1 { }) } - fn destroy(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), ZwpLinuxDmabufV1Error> { let _req: Destroy = self.client.parse(&**self, parser)?; self.client.remove_obj(&**self)?; Ok(()) } - fn create_params(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), CreateParamsError> { + fn create_params(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), ZwpLinuxDmabufV1Error> { let req: CreateParams = self.client.parse(&**self, parser)?; let params = Rc::new(ZwpLinuxBufferParamsV1::new(req.params_id, self)); track!(self.client, params); @@ -110,7 +110,7 @@ impl ZwpLinuxDmabufV1 { } object_base! { - ZwpLinuxDmabufV1, ZwpLinuxDmabufV1Error; + ZwpLinuxDmabufV1; DESTROY => destroy, CREATE_PARAMS => create_params, @@ -126,31 +126,10 @@ simple_add_obj!(ZwpLinuxDmabufV1); #[derive(Debug, Error)] pub enum ZwpLinuxDmabufV1Error { - #[error("Could not process a `destroy` request")] - DestroyError(#[from] DestroyError), - #[error("Could not process a `create_params` request")] - CreateParamsError(#[from] CreateParamsError), #[error(transparent)] ClientError(Box), + #[error("Parsing failed")] + MsgParserError(#[source] Box), } efrom!(ZwpLinuxDmabufV1Error, ClientError); - -#[derive(Debug, Error)] -pub enum DestroyError { - #[error("Parsing failed")] - ParseError(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(DestroyError, ClientError); -efrom!(DestroyError, ParseError, MsgParserError); - -#[derive(Debug, Error)] -pub enum CreateParamsError { - #[error("Parsing failed")] - ParseError(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(CreateParamsError, ClientError); -efrom!(CreateParamsError, ParseError, MsgParserError); +efrom!(ZwpLinuxDmabufV1Error, MsgParserError); diff --git a/src/ifs/zxdg_decoration_manager_v1.rs b/src/ifs/zxdg_decoration_manager_v1.rs index 6a716b02..32cd8ad7 100644 --- a/src/ifs/zxdg_decoration_manager_v1.rs +++ b/src/ifs/zxdg_decoration_manager_v1.rs @@ -65,7 +65,7 @@ pub struct ZxdgDecorationManagerV1 { } impl ZxdgDecorationManagerV1 { - fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZxdgDecorationManagerV1Error> { let _req: Destroy = self.client.parse(self, parser)?; self.client.remove_obj(self)?; Ok(()) @@ -74,7 +74,7 @@ impl ZxdgDecorationManagerV1 { fn get_toplevel_decoration( &self, parser: MsgParser<'_, '_>, - ) -> Result<(), GetToplevelDecorationError> { + ) -> Result<(), ZxdgDecorationManagerV1Error> { let req: GetToplevelDecoration = self.client.parse(self, parser)?; let tl = self.client.lookup(req.toplevel)?; let obj = Rc::new(ZxdgToplevelDecorationV1::new(req.id, &self.client, &tl)); @@ -86,7 +86,7 @@ impl ZxdgDecorationManagerV1 { } object_base! { - ZxdgDecorationManagerV1, ZxdgDecorationManagerV1Error; + ZxdgDecorationManagerV1; DESTROY => destroy, GET_TOPLEVEL_DECORATION => get_toplevel_decoration, @@ -102,31 +102,10 @@ simple_add_obj!(ZxdgDecorationManagerV1); #[derive(Debug, Error)] pub enum ZxdgDecorationManagerV1Error { - #[error("Could not process a `destroy` request")] - DestroyError(#[from] DestroyError), - #[error("Could not process a `get_toplevel_decoration` request")] - GetToplevelDecorationError(#[from] GetToplevelDecorationError), #[error(transparent)] ClientError(Box), + #[error("Parsing failed")] + MsgParserError(#[source] Box), } efrom!(ZxdgDecorationManagerV1Error, ClientError); - -#[derive(Debug, Error)] -pub enum DestroyError { - #[error("Parsing failed")] - MsgParserError(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(DestroyError, ClientError); -efrom!(DestroyError, MsgParserError); - -#[derive(Debug, Error)] -pub enum GetToplevelDecorationError { - #[error("Parsing failed")] - MsgParserError(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(GetToplevelDecorationError, ClientError); -efrom!(GetToplevelDecorationError, MsgParserError); +efrom!(ZxdgDecorationManagerV1Error, MsgParserError); diff --git a/src/ifs/zxdg_output_manager_v1.rs b/src/ifs/zxdg_output_manager_v1.rs index 4f6425e5..11336253 100644 --- a/src/ifs/zxdg_output_manager_v1.rs +++ b/src/ifs/zxdg_output_manager_v1.rs @@ -47,13 +47,13 @@ impl ZxdgOutputManagerV1Global { } impl ZxdgOutputManagerV1 { - fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZxdgOutputManagerV1Error> { let _req: Destroy = self.client.parse(self, parser)?; self.client.remove_obj(self)?; Ok(()) } - fn get_xdg_output(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), GetXdgOutputError> { + fn get_xdg_output(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), ZxdgOutputManagerV1Error> { let req: GetXdgOutput = self.client.parse(&**self, parser)?; let output = self.client.lookup(req.output)?; let xdg_output = Rc::new(ZxdgOutputV1 { @@ -90,7 +90,7 @@ impl Global for ZxdgOutputManagerV1Global { simple_add_global!(ZxdgOutputManagerV1Global); object_base! { - ZxdgOutputManagerV1, ZxdgOutputManagerV1Error; + ZxdgOutputManagerV1; DESTROY => destroy, GET_XDG_OUTPUT => get_xdg_output, @@ -108,29 +108,8 @@ impl Object for ZxdgOutputManagerV1 { pub enum ZxdgOutputManagerV1Error { #[error(transparent)] ClientError(Box), - #[error("Could not process a `destroy` request")] - DestroyError(#[from] DestroyError), - #[error("Could not process a `get_xdg_output` request")] - GetXdgOutputError(#[from] GetXdgOutputError), + #[error("Parsing failed")] + MsgParserError(#[source] Box), } efrom!(ZxdgOutputManagerV1Error, ClientError); - -#[derive(Debug, Error)] -pub enum DestroyError { - #[error("Parsing failed")] - ParseError(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(DestroyError, ParseError, MsgParserError); -efrom!(DestroyError, ClientError); - -#[derive(Debug, Error)] -pub enum GetXdgOutputError { - #[error("Parsing failed")] - ParseError(#[source] Box), - #[error(transparent)] - ClientError(Box), -} -efrom!(GetXdgOutputError, ParseError, MsgParserError); -efrom!(GetXdgOutputError, ClientError); +efrom!(ZxdgOutputManagerV1Error, MsgParserError); diff --git a/src/ifs/zxdg_output_v1.rs b/src/ifs/zxdg_output_v1.rs index 85478a6d..c52a8035 100644 --- a/src/ifs/zxdg_output_v1.rs +++ b/src/ifs/zxdg_output_v1.rs @@ -74,7 +74,7 @@ impl ZxdgOutputV1 { } } - pub fn destroy(&self, msg: MsgParser) -> Result<(), DestroyError> { + pub fn destroy(&self, msg: MsgParser) -> Result<(), ZxdgOutputV1Error> { let _req: Destroy = self.client.parse(self, msg)?; self.output.xdg_outputs.remove(&self.id); self.client.remove_obj(self)?; @@ -83,7 +83,7 @@ impl ZxdgOutputV1 { } object_base! { - ZxdgOutputV1, ZxdgOutputV1Error; + ZxdgOutputV1; DESTROY => destroy, } @@ -98,16 +98,10 @@ simple_add_obj!(ZxdgOutputV1); #[derive(Debug, Error)] pub enum ZxdgOutputV1Error { - #[error("Could not process a `destroy` request")] - DestroyError(#[from] DestroyError), -} - -#[derive(Debug, Error)] -pub enum DestroyError { #[error("Parsing failed")] MsgParserError(#[source] Box), #[error(transparent)] ClientError(Box), } -efrom!(DestroyError, MsgParserError); -efrom!(DestroyError, ClientError); +efrom!(ZxdgOutputV1Error, MsgParserError); +efrom!(ZxdgOutputV1Error, ClientError); diff --git a/src/ifs/zxdg_toplevel_decoration_v1.rs b/src/ifs/zxdg_toplevel_decoration_v1.rs index fe50f706..18ae7edc 100644 --- a/src/ifs/zxdg_toplevel_decoration_v1.rs +++ b/src/ifs/zxdg_toplevel_decoration_v1.rs @@ -51,19 +51,19 @@ impl ZxdgToplevelDecorationV1 { self.toplevel.xdg.do_send_configure(); } - fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> { + fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZxdgToplevelDecorationV1Error> { let _req: Destroy = self.client.parse(self, parser)?; self.client.remove_obj(self)?; Ok(()) } - fn set_mode(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), SetModeError> { + fn set_mode(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), ZxdgToplevelDecorationV1Error> { let _req: SetMode = self.client.parse(&**self, parser)?; self.do_send_configure(); Ok(()) } - fn unset_mode(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), UnsetModeError> { + fn unset_mode(self: &Rc, parser: MsgParser<'_, '_>) -> Result<(), ZxdgToplevelDecorationV1Error> { let _req: UnsetMode = self.client.parse(&**self, parser)?; self.do_send_configure(); Ok(()) @@ -71,7 +71,7 @@ impl ZxdgToplevelDecorationV1 { } object_base! { - ZxdgToplevelDecorationV1, ZxdgToplevelDecorationV1Error; + ZxdgToplevelDecorationV1; DESTROY => destroy, SET_MODE => set_mode, @@ -88,34 +88,10 @@ simple_add_obj!(ZxdgToplevelDecorationV1); #[derive(Debug, Error)] pub enum ZxdgToplevelDecorationV1Error { - #[error("Could not process a `destroy` request")] - DestoryError(#[from] DestroyError), - #[error("Could not process a `set_mode` request")] - SetModeError(#[from] SetModeError), - #[error("Could not process a `unset_mode` request")] - UnsetModeError(#[from] UnsetModeError), -} - -#[derive(Debug, Error)] -pub enum DestroyError { #[error("Parsing failed")] MsgParserError(#[source] Box), #[error(transparent)] ClientError(Box), } -efrom!(DestroyError, ClientError); -efrom!(DestroyError, MsgParserError); - -#[derive(Debug, Error)] -pub enum SetModeError { - #[error("Parsing failed")] - MsgParserError(#[source] Box), -} -efrom!(SetModeError, MsgParserError); - -#[derive(Debug, Error)] -pub enum UnsetModeError { - #[error("Parsing failed")] - MsgParserError(#[source] Box), -} -efrom!(UnsetModeError, MsgParserError); +efrom!(ZxdgToplevelDecorationV1Error, ClientError); +efrom!(ZxdgToplevelDecorationV1Error, MsgParserError); diff --git a/src/macros.rs b/src/macros.rs index c67788fc..57fb72c4 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -11,7 +11,7 @@ macro_rules! efrom { }; } -macro_rules! object_base2 { +macro_rules! object_base { ($oname:ident; $($code:ident => $f:ident,)*) => { impl crate::object::ObjectBase for $oname { fn id(&self) -> crate::object::ObjectId { @@ -49,54 +49,6 @@ macro_rules! object_base2 { }; } -macro_rules! object_base { - ($oname:ident, $ename:ty; $($code:ident => $f:ident,)*) => { - impl crate::object::ObjectBase for $oname { - fn id(&self) -> crate::object::ObjectId { - self.id.into() - } - - #[allow(unused_variables, unreachable_code)] - fn handle_request( - self: std::rc::Rc, - request: u32, - parser: crate::utils::buffd::MsgParser<'_, '_>, - ) -> Result<(), crate::client::ClientError> { - fn handle_request( - slf: std::rc::Rc<$oname>, - request: u32, - parser: crate::utils::buffd::MsgParser<'_, '_>, - ) -> Result<(), $ename> { - match request { - $( - $code => $oname::$f(&slf, parser)?, - )* - _ => unreachable!(), - } - Ok(()) - } - if let Err(e) = handle_request(self, request, parser) { - return Err(crate::client::ClientError::ObjectError(e.into())); - } - Ok(()) - } - - fn interface(&self) -> crate::object::Interface { - crate::wire::$oname - } - } - - impl From<$ename> for crate::client::ObjectError { - fn from(v: $ename) -> Self { - Self { - interface: crate::wire::$oname, - error: Box::new(v), - } - } - } - }; -} - macro_rules! global_base { ($oname:ty, $ifname:ident, $ename:ty) => { impl crate::globals::GlobalBase for $oname {