1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-04-19 19:34:24 +02:00

Merge pull request #592 from JakeStanger/fix/bar-positions

fix: all bars showing on same display due to GTK bug
This commit is contained in:
Jake Stanger 2024-05-18 01:28:19 +01:00 committed by GitHub
commit 47e3e0f9b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,7 +9,7 @@ use std::rc::Rc;
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
#[cfg(feature = "ipc")]
use std::sync::RwLock;
use std::sync::{mpsc, Arc, OnceLock};
use std::sync::{mpsc, Arc, Mutex, OnceLock};
use cfg_if::cfg_if;
#[cfg(feature = "cli")]
@ -339,17 +339,36 @@ fn load_output_bars(
app: &Application,
output: &OutputInfo,
) -> Result<Vec<Bar>> {
// Hack to track monitor positions due to new GTK3/wlroots bug:
// https://github.com/swaywm/sway/issues/8164
// This relies on Wayland always tracking monitors in the same order as GDK.
// We also need this static to ensure hot-reloading continues to work as best we can.
static INDEX_MAP: OnceLock<Mutex<Vec<String>>> = OnceLock::new();
let Some(monitor_name) = &output.name else {
return Err(Report::msg("Output missing monitor name"));
};
let map = INDEX_MAP.get_or_init(|| Mutex::new(vec![]));
let index = lock!(map).iter().position(|n| n == monitor_name);
let index = match index {
Some(index) => index - 1,
None => {
lock!(map).push(monitor_name.clone());
lock!(map).len() - 1
}
};
let config = ironbar.config.borrow();
let display = get_display();
let pos = output.logical_position.unwrap_or_default();
let monitor = display
.monitor_at_point(pos.0, pos.1)
.expect("monitor to exist");
// let pos = output.logical_position.unwrap_or_default();
// let monitor = display
// .monitor_at_point(pos.0, pos.1)
// .expect("monitor to exist");
let monitor = display.monitor(index as i32).expect("monitor to exist");
let show_default_bar =
config.bar.start.is_some() || config.bar.center.is_some() || config.bar.end.is_some();