Skip to content

Commit

Permalink
feat(wm): mouse follows focus enable/disable cmd
Browse files Browse the repository at this point in the history
This commit adds a command to explicitly specify the desired state of
mouse follows focus to complement the previously added toggle command.
  • Loading branch information
LGUG2Z committed Oct 30, 2021
1 parent a55069d commit 4e6e2b3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions komorebi-core/src/lib.rs
Expand Up @@ -93,6 +93,7 @@ pub enum SocketMessage {
Query(StateQuery),
FocusFollowsMouse(FocusFollowsMouseImplementation, bool),
ToggleFocusFollowsMouse(FocusFollowsMouseImplementation),
MouseFollowsFocus(bool),
ToggleMouseFollowsFocus,
AddSubscriber(String),
RemoveSubscriber(String),
Expand Down
3 changes: 3 additions & 0 deletions komorebi/src/process_command.rs
Expand Up @@ -453,6 +453,9 @@ impl WindowManager {
let mut pipes = SUBSCRIPTION_PIPES.lock();
pipes.remove(&subscriber);
}
SocketMessage::MouseFollowsFocus(enable) => {
self.mouse_follows_focus = enable;
}
SocketMessage::ToggleMouseFollowsFocus => {
self.mouse_follows_focus = !self.mouse_follows_focus;
}
Expand Down
4 changes: 4 additions & 0 deletions komorebic.lib.sample.ahk
Expand Up @@ -244,6 +244,10 @@ ToggleFocusFollowsMouse(implementation) {
Run, komorebic.exe toggle-focus-follows-mouse --implementation %implementation%, , Hide
}

MouseFollowsFocus(boolean_state) {
Run, komorebic.exe mouse-follows-focus %boolean_state%, , Hide
}

ToggleMouseFollowsFocus() {
Run, komorebic.exe toggle-mouse-follows-focus, , Hide
}
Expand Down
12 changes: 12 additions & 0 deletions komorebic/src/main.rs
Expand Up @@ -88,6 +88,7 @@ gen_enum_subcommand_args! {
FlipLayout: Flip,
ChangeLayout: DefaultLayout,
WatchConfiguration: BooleanState,
MouseFollowsFocus: BooleanState,
Query: StateQuery,
}

Expand Down Expand Up @@ -499,6 +500,9 @@ enum SubCommand {
/// Toggle focus follows mouse for the operating system
#[clap(setting = AppSettings::ArgRequiredElseHelp)]
ToggleFocusFollowsMouse(ToggleFocusFollowsMouse),
/// Enable or disable mouse follows focus on all workspaces
#[clap(setting = AppSettings::ArgRequiredElseHelp)]
MouseFollowsFocus(MouseFollowsFocus),
/// Toggle mouse follows focus on all workspaces
ToggleMouseFollowsFocus,
/// Generate a library of AutoHotKey helper functions
Expand Down Expand Up @@ -924,6 +928,14 @@ fn main() -> Result<()> {
SubCommand::ToggleMouseFollowsFocus => {
send_message(&*SocketMessage::ToggleMouseFollowsFocus.as_bytes()?)?;
}
SubCommand::MouseFollowsFocus(arg) => {
let enable = match arg.boolean_state {
BooleanState::Enable => true,
BooleanState::Disable => false,
};

send_message(&*SocketMessage::MouseFollowsFocus(enable).as_bytes()?)?;
}
}

Ok(())
Expand Down

0 comments on commit 4e6e2b3

Please sign in to comment.