Skip to content

Commit

Permalink
fix log
Browse files Browse the repository at this point in the history
  • Loading branch information
MalpenZibo committed Oct 23, 2024
1 parent 0e11245 commit e6bdbfc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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;

Expand Down
30 changes: 17 additions & 13 deletions src/outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ impl Outputs {
output_info: Option<OutputInfo>,
wl_output: WlOutput,
) -> Task<Message> {
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,
Expand All @@ -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,
Expand All @@ -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()
Expand All @@ -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,
Expand All @@ -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()
Expand Down

0 comments on commit e6bdbfc

Please sign in to comment.