Skip to content

Commit 7b220cb

Browse files
committed
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
1 parent b13c725 commit 7b220cb

File tree

1 file changed

+5
-23
lines changed

1 file changed

+5
-23
lines changed

src/main.rs

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::path::PathBuf;
77
use std::process::exit;
88
use std::rc::Rc;
99
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
10-
use std::sync::{Arc, Mutex, OnceLock, mpsc};
10+
use std::sync::{Arc, OnceLock, mpsc};
1111

1212
use cfg_if::cfg_if;
1313
#[cfg(feature = "cli")]
@@ -363,38 +363,20 @@ fn load_output_bars(
363363
app: &Application,
364364
output: &OutputInfo,
365365
) -> Result<Vec<Bar>> {
366-
// Hack to track monitor positions due to new GTK3/wlroots bug:
367-
// https://github.com/swaywm/sway/issues/8164
368-
// This relies on Wayland always tracking monitors in the same order as GDK.
369-
// We also need this static to ensure hot-reloading continues to work as best we can.
370-
static INDEX_MAP: OnceLock<Mutex<Vec<String>>> = OnceLock::new();
371-
372366
let output_size = output.logical_size.unwrap_or_default();
373367

374368
let Some(monitor_name) = &output.name else {
375369
return Err(Report::msg("Output missing monitor name"));
376370
};
377371

378-
let map = INDEX_MAP.get_or_init(|| Mutex::new(vec![]));
379-
380-
let index = lock!(map).iter().position(|n| n == monitor_name);
381-
let index = if let Some(index) = index {
382-
index
383-
} else {
384-
lock!(map).push(monitor_name.clone());
385-
lock!(map).len() - 1
386-
};
387-
388372
let config = ironbar.config.borrow();
389373
let icon_overrides = Arc::new(config.icon_overrides.clone());
390374
let display = get_display();
391375

392-
// let pos = output.logical_position.unwrap_or_default();
393-
// let monitor = display
394-
// .monitor_at_point(pos.0, pos.1)
395-
// .expect("monitor to exist");
396-
397-
let monitor = display.monitor(index as i32).expect("monitor to exist");
376+
let pos = output.logical_position.unwrap_or_default();
377+
let monitor = display
378+
.monitor_at_point(pos.0, pos.1)
379+
.expect("monitor to exist");
398380

399381
let show_default_bar =
400382
config.bar.start.is_some() || config.bar.center.is_some() || config.bar.end.is_some();

0 commit comments

Comments
 (0)