From f78774137b146647a4024e1305c7dfbd89b39f18 Mon Sep 17 00:00:00 2001 From: Max Verevkin Date: Tue, 19 Jul 2022 12:39:41 +0300 Subject: some refactoring --- src/main.rs | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 823a137..730edf6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,7 @@ use smithay_client_toolkit::{ output::{with_output_info, OutputInfo}, reexports::{ calloop, - client::protocol::{wl_output, wl_pointer}, + client::protocol::{wl_output::WlOutput, wl_pointer}, protocols::wlr::unstable::layer_shell::v1::client::zwlr_layer_shell_v1, }, seat::pointer, @@ -66,21 +66,15 @@ fn main() { let mut bar_state = BarState::new(&env); let env_handle = env.clone(); - let output_handler = - move |output: wl_output::WlOutput, info: &OutputInfo, bar_state: &mut BarState| { - if info.obsolete { - info!("Output removed"); - bar_state.remove_surface(info.id); - output.release(); - } else { - info!("Output detected"); - let surface = env_handle.create_surface(); - let pool = env_handle - .create_auto_pool() - .expect("Failed to create a memory pool!"); - bar_state.add_surface(&output, info.id, surface, pool); - } - }; + let output_handler = move |output: WlOutput, info: &OutputInfo, bar_state: &mut BarState| { + if info.obsolete { + info!("Output {} removed", info.id); + output.release(); + } else { + info!("Output {} detected", info.id); + bar_state.add_surface(&output, info.id, &env_handle); + } + }; // Process currently existing outputs for output in env.get_all_outputs() { -- cgit v1.3.1