Skip to content

Commit

Permalink
fix log
Browse files Browse the repository at this point in the history
  • Loading branch information
MalpenZibo committed Nov 8, 2024
1 parent d381ef7 commit 585bc48
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ mod components;
mod config;
mod menu;
mod modules;
mod outputs;
mod password_dialog;
mod services;
mod style;
mod utils;
mod outputs;

const ICON_FONT: &[u8] = include_bytes!("../assets/SymbolsNerdFont-Regular.ttf");
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 585bc48

Please sign in to comment.