From e6bdbfc7f8145726b48052b2f6d2834eb2b51453 Mon Sep 17 00:00:00 2001 From: Simone Camito Date: Wed, 23 Oct 2024 09:40:19 +0200 Subject: [PATCH] fix log --- src/app.rs | 2 +- src/main.rs | 5 ++--- src/outputs.rs | 30 +++++++++++++++++------------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/app.rs b/src/app.rs index 5353600..7871f8b 100644 --- a/src/app.rs +++ b/src/app.rs @@ -15,7 +15,7 @@ use crate::{ use flexi_logger::LoggerHandle; use iced::{ daemon::Appearance, - event::{listen_raw, listen_with, wayland::Event as WaylandEvent}, + event::{listen_with, wayland::Event as WaylandEvent}, widget::{row, Row}, window::Id, Alignment, Color, Element, Length, Subscription, Task, Theme, diff --git a/src/main.rs b/src/main.rs index f679e52..ccdce1a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,8 @@ use app::App; -use config::{read_config, Position}; +use config::read_config; use flexi_logger::{ Age, Cleanup, Criterion, FileSpec, LogSpecBuilder, LogSpecification, Logger, Naming, }; -use iced::Font; use log::{error, LevelFilter}; use std::panic; @@ -13,11 +12,11 @@ mod components; mod config; mod menu; mod modules; +mod outputs; mod password_dialog; mod services; mod style; mod utils; -mod outputs; const HEIGHT: u32 = 34; diff --git a/src/outputs.rs b/src/outputs.rs index 46578ae..608b394 100644 --- a/src/outputs.rs +++ b/src/outputs.rs @@ -28,15 +28,14 @@ impl Outputs { output_info: Option, wl_output: WlOutput, ) -> Task { - debug!("request_outputs: {:?}", request_outputs); let target = request_outputs.iter().any(|output| { Some(output.as_str()) == output_info.as_ref().and_then(|info| info.name.as_deref()) }); - debug!("target: {:?}", target); - let id = Id::unique(); if self.0.is_empty() { - let cmd = get_layer_surface(SctkLayerSurfaceSettings { + debug!("No outputs, creating a new layer surface. Is a fallback surface {}", target); + let id = Id::unique(); + let task = get_layer_surface(SctkLayerSurfaceSettings { id, size: Some((None, Some(HEIGHT))), pointer_interactivity: true, @@ -53,9 +52,11 @@ impl Outputs { self.0.push((id, target.then_some(wl_output))); - cmd + task } else if target { - let create_cmd = get_layer_surface(SctkLayerSurfaceSettings { + debug!("Found target output, creating a new layer surface"); + let id = Id::unique(); + let create_task = get_layer_surface(SctkLayerSurfaceSettings { id, size: Some((None, Some(HEIGHT))), pointer_interactivity: true, @@ -73,12 +74,13 @@ impl Outputs { self.0.push((id, Some(wl_output))); if let Some(index) = self.0.iter().position(|(_, wl_output)| wl_output.is_none()) { + debug!("Found fallback output, removing it"); let (id, _) = self.0.swap_remove(index); - let destroy_cmd = destroy_layer_surface(id); + let destroy_task = destroy_layer_surface(id); - Task::batch(vec![create_cmd, destroy_cmd]) + Task::batch(vec![create_task, destroy_task]) } else { - create_cmd + create_task } } else { Task::none() @@ -95,13 +97,15 @@ impl Outputs { .iter() .position(|(_, output)| output.as_ref() == Some(&wl_output)) { + debug!("Removing layer surface for output"); let (id, _) = self.0.swap_remove(to_remove); - let destroy_cmd = destroy_layer_surface(id); + let destroy_task = destroy_layer_surface(id); if self.0.is_empty() { + debug!("No outputs left, creating a fallback layer surface"); let id = Id::unique(); - let create_cmd = get_layer_surface(SctkLayerSurfaceSettings { + let create_task = get_layer_surface(SctkLayerSurfaceSettings { id, size: Some((None, Some(HEIGHT))), pointer_interactivity: true, @@ -118,9 +122,9 @@ impl Outputs { self.0.push((id, None)); - Task::batch(vec![destroy_cmd, create_cmd]) + Task::batch(vec![destroy_task, create_task]) } else { - destroy_cmd + destroy_task } } else { Task::none()