1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-08-17 14:51:04 +02:00

fix: issues with bar appearing on wrong monitor

Due to a GTK bug, the bar relied on GDK and the compositor reporting monitors in the same order. This broke down when monitors were connected, or occasionally on reload.

This reverts the workaround put in place for the bug, since it has since been patched upstream
This commit is contained in:
Jake Stanger 2025-05-19 15:29:26 +01:00
parent b13c725f67
commit 7b220cb2ae
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61

View file

@ -7,7 +7,7 @@ use std::path::PathBuf;
use std::process::exit; use std::process::exit;
use std::rc::Rc; use std::rc::Rc;
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::{Arc, Mutex, OnceLock, mpsc}; use std::sync::{Arc, OnceLock, mpsc};
use cfg_if::cfg_if; use cfg_if::cfg_if;
#[cfg(feature = "cli")] #[cfg(feature = "cli")]
@ -363,38 +363,20 @@ fn load_output_bars(
app: &Application, app: &Application,
output: &OutputInfo, output: &OutputInfo,
) -> Result<Vec<Bar>> { ) -> 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 output_size = output.logical_size.unwrap_or_default(); let output_size = output.logical_size.unwrap_or_default();
let Some(monitor_name) = &output.name else { let Some(monitor_name) = &output.name else {
return Err(Report::msg("Output missing monitor name")); 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 = if let Some(index) = index {
index
} else {
lock!(map).push(monitor_name.clone());
lock!(map).len() - 1
};
let config = ironbar.config.borrow(); let config = ironbar.config.borrow();
let icon_overrides = Arc::new(config.icon_overrides.clone()); let icon_overrides = Arc::new(config.icon_overrides.clone());
let display = get_display(); let display = get_display();
// let pos = output.logical_position.unwrap_or_default(); let pos = output.logical_position.unwrap_or_default();
// let monitor = display let monitor = display
// .monitor_at_point(pos.0, pos.1) .monitor_at_point(pos.0, pos.1)
// .expect("monitor to exist"); .expect("monitor to exist");
let monitor = display.monitor(index as i32).expect("monitor to exist");
let show_default_bar = let show_default_bar =
config.bar.start.is_some() || config.bar.center.is_some() || config.bar.end.is_some(); config.bar.start.is_some() || config.bar.center.is_some() || config.bar.end.is_some();