mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-07-14 00:52:54 +02:00
fix(bar): handle monitor disconnect/reconnect
This commit allows a bar to be disabled when it's monitor is disconnected and re-enabled when said monitor reconnects. This commit also uses the new `monitor_usr_idx_map` to properly map the monitor index given by the users on config to the actual monitor index on the `WindowManager` - in case some middle monitor gets disconnected the index of the monitors to the "right" of that one will be lowered by 1. This should allow for the following in cases with monitor A, B and C: if monitor B disconnects, its bar will be disabled and monitor C will properly change its monitor index internally to 1 so it still gets the infos from monitor C (which now will have index 1 on the `WindowManager`).
This commit is contained in:
@@ -238,12 +238,16 @@ fn main() -> color_eyre::Result<()> {
|
||||
&SocketMessage::State,
|
||||
)?)?;
|
||||
|
||||
let (monitor_index, work_area_offset) = match &config.monitor {
|
||||
let (usr_monitor_index, work_area_offset) = match &config.monitor {
|
||||
MonitorConfigOrIndex::MonitorConfig(monitor_config) => {
|
||||
(monitor_config.index, monitor_config.work_area_offset)
|
||||
}
|
||||
MonitorConfigOrIndex::Index(idx) => (*idx, None),
|
||||
};
|
||||
let monitor_index = state
|
||||
.monitor_usr_idx_map
|
||||
.get(&usr_monitor_index)
|
||||
.map_or(usr_monitor_index, |i| *i);
|
||||
|
||||
MONITOR_RIGHT.store(
|
||||
state.monitors.elements()[monitor_index].size().right,
|
||||
|
||||
Reference in New Issue
Block a user