A bit refactoring

timeout_old
Tassilo Horn 3 years ago
parent 360f8cd90d
commit 64052993d4
  1. 2
      src/cmds.rs
  2. 19
      src/con.rs
  3. 14
      src/config.rs
  4. 2
      src/layout.rs

@ -635,7 +635,7 @@ pub fn quit_workspace_or_window(extra_props: &HashMap<i64, con::ExtraProps>) {
{
match ws_or_win {
con::WsOrWin::Ws { ws } => {
for win in &ws.windows {
for win in ws.get_windows() {
quit_window_by_id(win.get_id())
}
}

@ -69,9 +69,13 @@ pub trait NodeMethods {
/// Returns all nodes being application windows.
fn windows(&self) -> Vec<&s::Node>;
/// Returns all nodes being containers.
fn containers(&self) -> Vec<&s::Node>;
/// Returns all nodes being workspaces.
fn workspaces(&self) -> Vec<&s::Node>;
// Returns true if this node is the scratchpad workspace.
fn is_scratchpad(&self) -> bool;
}
@ -87,8 +91,7 @@ impl NodeMethods for s::Node {
}
fn is_container(&self) -> bool {
self.node_type == s::NodeType::Workspace
|| self.node_type == s::NodeType::Con
self.node_type == s::NodeType::Con
&& self.name.is_none()
&& self.layout != s::NodeLayout::None
}
@ -97,6 +100,10 @@ impl NodeMethods for s::Node {
self.iter().filter(|n| n.is_window()).collect()
}
fn containers(&self) -> Vec<&s::Node> {
self.iter().filter(|n| n.is_container()).collect()
}
fn workspaces(&self) -> Vec<&s::Node> {
self.iter()
.filter(|n| n.node_type == s::NodeType::Workspace)
@ -439,10 +446,18 @@ impl Workspace<'_> {
self.node.id
}
pub fn get_windows(&self) -> &Vec<Window> {
&self.windows
}
pub fn is_scratchpad(&self) -> bool {
self.node.is_scratchpad()
}
pub fn is_focused(&self) -> bool {
self.node.focused
}
pub fn is_current(&self) -> bool {
is_current_container(self.node)
}

@ -79,6 +79,14 @@ impl Config {
.expect("No format.workspace_format defined.")
}
pub fn get_format_container_format(&self) -> String {
self.format
.as_ref()
.and_then(|f| f.container_format.clone())
.or_else(|| Format::default().container_format)
.expect("No format.container_format defined.")
}
pub fn get_format_urgency_start(&self) -> String {
self.format
.as_ref()
@ -147,6 +155,7 @@ pub struct Menu {
pub struct Format {
window_format: Option<String>,
workspace_format: Option<String>,
container_format: Option<String>,
urgency_start: Option<String>,
urgency_end: Option<String>,
html_escape: Option<bool>,
@ -207,6 +216,11 @@ impl Default for Format {
<span alpha=\"20000\">({id})</span>"
.to_string(),
),
container_format: Some(
"<i>Container {name}</i> \
<span alpha=\"20000\">({id})</span>"
.to_string(),
),
html_escape: Some(true),
urgency_start: Some(
"<span background=\"darkred\" foreground=\"yellow\">"

@ -139,7 +139,7 @@ pub fn relayout_current_workspace(
if let Ok(mut con) = s::Connection::new() {
let mut moved_wins: Vec<&con::Window> = vec![];
let mut focused_win = None;
for win in &cur_ws.windows {
for win in cur_ws.get_windows() {
if win.is_focused() {
focused_win = Some(win);
}

Loading…
Cancel
Save