refactor(bar): use monitor idx when switching ws

This commit follows up on a point made by @notTamion in #1128 - since we
have the monitor index, we can use it in the bar's workspace widget to
more accurately target workspaces via
SocketMessage::FocusMonitorWorkspaceNumber.
This commit is contained in:
LGUG2Z
2024-11-19 20:44:48 -08:00
parent 779c12bc6a
commit 041ef5731c
2 changed files with 15 additions and 3 deletions
+11 -3
View File
@@ -4,6 +4,7 @@ use crate::render::RenderConfig;
use crate::ui::CustomUi;
use crate::widget::BarWidget;
use crate::MAX_LABEL_WIDTH;
use crate::MONITOR_INDEX;
use crossbeam_channel::Receiver;
use crossbeam_channel::TryRecvError;
use eframe::egui::text::LayoutJob;
@@ -103,6 +104,7 @@ impl From<&KomorebiConfig> for Komorebi {
work_area_offset: None,
focused_container_information: (vec![], vec![], 0),
stack_accent: None,
monitor_index: MONITOR_INDEX.load(Ordering::SeqCst),
})),
workspaces: value.workspaces,
layout: value.layout,
@@ -154,9 +156,12 @@ impl BarWidget for Komorebi {
}
if proceed
&& komorebi_client::send_message(&SocketMessage::FocusWorkspaceNumber(
i,
))
&& komorebi_client::send_message(
&SocketMessage::FocusMonitorWorkspaceNumber(
komorebi_notification_state.monitor_index,
i,
),
)
.is_err()
{
tracing::error!(
@@ -435,6 +440,7 @@ pub struct KomorebiNotificationState {
pub mouse_follows_focus: bool,
pub work_area_offset: Option<Rect>,
pub stack_accent: Option<Color32>,
pub monitor_index: usize,
}
#[derive(Copy, Clone, Debug)]
@@ -497,6 +503,8 @@ impl KomorebiNotificationState {
},
}
self.monitor_index = monitor_index;
self.mouse_follows_focus = notification.state.mouse_follows_focus;
let monitor = &notification.state.monitors.elements()[monitor_index];