From e6326b9b38041300bb3652eba7eb87a5816bdbd3 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Sat, 4 Jun 2022 12:00:13 +0000 Subject: [PATCH] state: Use dummy layout command --- src/main.rs | 13 +++++++++++++ src/state.rs | 25 +++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/main.rs b/src/main.rs index 47ac7982..7967de8e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -174,6 +174,18 @@ mod c { ) }; } + + if let Some(commands::SetLayout { description }) = msg.layout_selection { + dbg!(description); + } + } +} + +pub mod commands { + use crate::animation; + #[derive(Clone, Debug)] + pub struct SetLayout { + pub description: animation::Contents, } } @@ -184,4 +196,5 @@ pub struct Commands { pub panel_visibility: Option, pub layout_hint_set: Option, pub dbus_visible_set: Option, + pub layout_selection: Option, } diff --git a/src/state.rs b/src/state.rs index 19f58bcd..5c6d7431 100644 --- a/src/state.rs +++ b/src/state.rs @@ -9,6 +9,7 @@ use crate::animation; use crate::debug; use crate::imservice::{ ContentHint, ContentPurpose }; use crate::layout::ArrangementKind; +use crate::main; use crate::main::Commands; use crate::outputs; use crate::outputs::{Millimeter, OutputId, OutputState}; @@ -153,10 +154,34 @@ impl Outcome { animation::Outcome::Hidden => (Some(false), Some(panel::Command::Hide)), }; + // Compare the old and new states as not to flood with updates, + // which may look up in the file system. + use animation::Outcome::*; + let layout_selection = match &new_state.panel { + Visible{ contents: new_contents, ..} => { + let same + = if let Visible { contents, .. } = &self.panel { + contents == new_contents + } else { + false + }; + + if !same { + Some(main::commands::SetLayout { + description: new_contents.clone() + }) + } else { + None + } + }, + animation::Outcome::Hidden => None, + }; + Commands { panel_visibility, layout_hint_set, dbus_visible_set, + layout_selection, } } }