From 64aedce01fa668a88aabec66877485a2be5f5ca2 Mon Sep 17 00:00:00 2001 From: Victor Berger Date: Sat, 2 May 2020 12:42:02 +0200 Subject: [PATCH] anvil: Introduce ShellHandle type to simply return values --- anvil/src/shell.rs | 26 +++++++++++++++----------- anvil/src/state.rs | 8 ++++---- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/anvil/src/shell.rs b/anvil/src/shell.rs index f9e041d..d960393 100644 --- a/anvil/src/shell.rs +++ b/anvil/src/shell.rs @@ -282,16 +282,15 @@ impl PointerGrab for ResizeSurfaceGrab { } } -pub fn init_shell( - display: &mut Display, - buffer_utils: BufferUtils, - log: ::slog::Logger, -) -> ( - CompositorToken, - Arc>>, - Arc>>, - Rc>, -) { +#[derive(Clone)] +pub struct ShellHandles { + pub token: CompositorToken, + pub xdg_state: Arc>>, + pub wl_state: Arc>>, + pub window_map: Rc>, +} + +pub fn init_shell(display: &mut Display, buffer_utils: BufferUtils, log: ::slog::Logger) -> ShellHandles { // TODO: this is awkward... let almost_window_map = Rc::new(RefCell::new(None::>>)); let almost_window_map_compositor = almost_window_map.clone(); @@ -606,7 +605,12 @@ pub fn init_shell( log.clone(), ); - (compositor_token, xdg_shell_state, wl_shell_state, window_map) + ShellHandles { + token: compositor_token, + xdg_state: xdg_shell_state, + wl_state: wl_shell_state, + window_map, + } } /// Information about the resize operation. diff --git a/anvil/src/state.rs b/anvil/src/state.rs index 7b0927e..0b2d1d0 100644 --- a/anvil/src/state.rs +++ b/anvil/src/state.rs @@ -70,7 +70,7 @@ impl AnvilState { init_shm_global(&mut display.borrow_mut(), vec![], log.clone()); - let (ctoken, _, _, window_map) = init_shell(&mut display.borrow_mut(), buffer_utils, log.clone()); + let shell_handles = init_shell(&mut display.borrow_mut(), buffer_utils, log.clone()); let socket_name = display .borrow_mut() @@ -98,7 +98,7 @@ impl AnvilState { _ => {} }, default_action_chooser, - ctoken, + shell_handles.token, log.clone(), ); @@ -106,8 +106,8 @@ impl AnvilState { running: Arc::new(AtomicBool::new(true)), display, handle, - ctoken, - window_map, + ctoken: shell_handles.token, + window_map: shell_handles.window_map, dnd_icon, log, socket_name,