From 6addfed1ce30309dc04a8d9af5b30895efc3f94c Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 17 Sep 2024 18:09:00 -0700 Subject: [PATCH] fix(bar): read mouse follows focus from state --- komorebi-bar/src/date.rs | 1 - komorebi-bar/src/komorebi.rs | 12 ++++++++++-- komorebi-bar/src/main.rs | 8 ++++---- komorebi-bar/src/time.rs | 1 - 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/komorebi-bar/src/date.rs b/komorebi-bar/src/date.rs index 10ee1183..1cf449af 100644 --- a/komorebi-bar/src/date.rs +++ b/komorebi-bar/src/date.rs @@ -117,7 +117,6 @@ impl BarWidget for Date { } } - // TODO: make spacing configurable ui.add_space(WIDGET_SPACING); } } diff --git a/komorebi-bar/src/komorebi.rs b/komorebi-bar/src/komorebi.rs index 2c9f0ca4..c3b1aaf0 100644 --- a/komorebi-bar/src/komorebi.rs +++ b/komorebi-bar/src/komorebi.rs @@ -66,6 +66,7 @@ impl From for Komorebi { layout: String::new(), workspaces: vec![], hide_empty_workspaces: value.workspaces.hide_empty_workspaces, + mouse_follows_focus: true, })), workspaces: value.workspaces, layout: value.layout, @@ -101,8 +102,12 @@ impl BarWidget for Komorebi { komorebi_client::send_message(&SocketMessage::MouseFollowsFocus(false)) .unwrap(); komorebi_client::send_message(&SocketMessage::FocusWorkspaceNumber(i)).unwrap(); - // TODO: store MFF value from state and restore that here instead of "true" - komorebi_client::send_message(&SocketMessage::MouseFollowsFocus(true)).unwrap(); + komorebi_client::send_message(&SocketMessage::MouseFollowsFocus( + self.komorebi_notification_state + .borrow() + .mouse_follows_focus, + )) + .unwrap(); komorebi_client::send_message(&SocketMessage::Retile).unwrap(); } } @@ -164,6 +169,7 @@ pub struct KomorebiNotificationState { pub focused_window_icon: Option, pub layout: String, pub hide_empty_workspaces: bool, + pub mouse_follows_focus: bool, } impl KomorebiNotificationState { @@ -190,6 +196,8 @@ impl KomorebiNotificationState { } } + self.mouse_follows_focus = notification.state.mouse_follows_focus; + let monitor = ¬ification.state.monitors.elements()[monitor_index]; let focused_workspace_idx = monitor.focused_workspace_idx(); diff --git a/komorebi-bar/src/main.rs b/komorebi-bar/src/main.rs index afbb26d1..46cfa264 100644 --- a/komorebi-bar/src/main.rs +++ b/komorebi-bar/src/main.rs @@ -132,16 +132,16 @@ fn main() -> color_eyre::Result<()> { let config_path = config_path.unwrap(); + let state = serde_json::from_str::( + &komorebi_client::send_query(&SocketMessage::State).unwrap(), + )?; + let mut viewport_builder = ViewportBuilder::default() .with_decorations(false) // .with_transparent(config.transparent) .with_taskbar(false) .with_position(Position { x: 0.0, y: 0.0 }) .with_inner_size({ - let state = serde_json::from_str::( - &komorebi_client::send_query(&SocketMessage::State).unwrap(), - )?; - Position { x: state.monitors.elements()[config.monitor.index].size().right as f32, y: 20.0, diff --git a/komorebi-bar/src/time.rs b/komorebi-bar/src/time.rs index 321c25ec..85b5db8b 100644 --- a/komorebi-bar/src/time.rs +++ b/komorebi-bar/src/time.rs @@ -108,7 +108,6 @@ impl BarWidget for Time { } } - // TODO: make spacing configurable ui.add_space(WIDGET_SPACING); } }