mirror of
https://gitlab.com/hyask/swaysome.git
synced 2025-12-10 07:44:43 +01:00
get_current_*: don't use outdated cache is these functions
Fixes https://gitlab.com/hyask/swaysome/-/issues/18 Thanks a lot @mahieujeremy for reporting that and providing a fix so quickly!
This commit is contained in:
parent
9da99893c4
commit
aa3b47fbad
1 changed files with 11 additions and 12 deletions
23
src/main.rs
23
src/main.rs
|
|
@ -263,14 +263,18 @@ impl SwaySome {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_current_output_index(&self) -> usize {
|
fn get_current_output_index(&self) -> usize {
|
||||||
match self.outputs.iter().position(|x| x.focused) {
|
// Do not use `self.outputs`, as the information here could be outdated, especially the `focused` attribute
|
||||||
|
let outputs = self.get_outputs();
|
||||||
|
match outputs.iter().position(|x| x.focused) {
|
||||||
Some(i) => i,
|
Some(i) => i,
|
||||||
None => panic!("WTF! No focused output???"),
|
None => panic!("WTF! No focused output???"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_current_output_name(&self) -> String {
|
fn get_current_output_name(&self) -> String {
|
||||||
let focused_output_index = match self.outputs.iter().find(|x| x.focused) {
|
// Do not use `self.outputs`, as the information here could be outdated, especially the `focused` attribute
|
||||||
|
let outputs = self.get_outputs();
|
||||||
|
let focused_output_index = match outputs.iter().find(|x| x.focused) {
|
||||||
Some(i) => i.name.as_str(),
|
Some(i) => i.name.as_str(),
|
||||||
None => panic!("WTF! No focused output???"),
|
None => panic!("WTF! No focused output???"),
|
||||||
};
|
};
|
||||||
|
|
@ -279,17 +283,12 @@ impl SwaySome {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_current_workspace_index(&self) -> usize {
|
fn get_current_workspace_index(&self) -> usize {
|
||||||
self.workspaces
|
// Do not use `self.outputs`, as the information here could be outdated, especially the `focused` attribute
|
||||||
|
let outputs = self.get_outputs();
|
||||||
|
// Do not use `self.workspaces`, as the information here could be outdated, especially the `visible` attribute
|
||||||
|
self.get_workspaces()
|
||||||
.iter()
|
.iter()
|
||||||
.find(|w| {
|
.find(|w| w.visible && outputs.iter().find(|o| o.name == w.output).unwrap().focused)
|
||||||
w.visible
|
|
||||||
&& self
|
|
||||||
.outputs
|
|
||||||
.iter()
|
|
||||||
.find(|o| o.name == w.output)
|
|
||||||
.unwrap()
|
|
||||||
.focused
|
|
||||||
})
|
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.num
|
.num
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue