feat(wm): mouse follows focus enable/disable cmd

This commit adds a command to explicitly specify the desired state of
mouse follows focus to complement the previously added toggle command.
This commit is contained in:
LGUG2Z
2021-10-30 15:24:27 -07:00
parent a55069df48
commit 4e6e2b3aa8
4 changed files with 20 additions and 0 deletions

View File

@@ -93,6 +93,7 @@ pub enum SocketMessage {
Query(StateQuery), Query(StateQuery),
FocusFollowsMouse(FocusFollowsMouseImplementation, bool), FocusFollowsMouse(FocusFollowsMouseImplementation, bool),
ToggleFocusFollowsMouse(FocusFollowsMouseImplementation), ToggleFocusFollowsMouse(FocusFollowsMouseImplementation),
MouseFollowsFocus(bool),
ToggleMouseFollowsFocus, ToggleMouseFollowsFocus,
AddSubscriber(String), AddSubscriber(String),
RemoveSubscriber(String), RemoveSubscriber(String),

View File

@@ -453,6 +453,9 @@ impl WindowManager {
let mut pipes = SUBSCRIPTION_PIPES.lock(); let mut pipes = SUBSCRIPTION_PIPES.lock();
pipes.remove(&subscriber); pipes.remove(&subscriber);
} }
SocketMessage::MouseFollowsFocus(enable) => {
self.mouse_follows_focus = enable;
}
SocketMessage::ToggleMouseFollowsFocus => { SocketMessage::ToggleMouseFollowsFocus => {
self.mouse_follows_focus = !self.mouse_follows_focus; self.mouse_follows_focus = !self.mouse_follows_focus;
} }

View File

@@ -244,6 +244,10 @@ ToggleFocusFollowsMouse(implementation) {
Run, komorebic.exe toggle-focus-follows-mouse --implementation %implementation%, , Hide Run, komorebic.exe toggle-focus-follows-mouse --implementation %implementation%, , Hide
} }
MouseFollowsFocus(boolean_state) {
Run, komorebic.exe mouse-follows-focus %boolean_state%, , Hide
}
ToggleMouseFollowsFocus() { ToggleMouseFollowsFocus() {
Run, komorebic.exe toggle-mouse-follows-focus, , Hide Run, komorebic.exe toggle-mouse-follows-focus, , Hide
} }

View File

@@ -88,6 +88,7 @@ gen_enum_subcommand_args! {
FlipLayout: Flip, FlipLayout: Flip,
ChangeLayout: DefaultLayout, ChangeLayout: DefaultLayout,
WatchConfiguration: BooleanState, WatchConfiguration: BooleanState,
MouseFollowsFocus: BooleanState,
Query: StateQuery, Query: StateQuery,
} }
@@ -499,6 +500,9 @@ enum SubCommand {
/// Toggle focus follows mouse for the operating system /// Toggle focus follows mouse for the operating system
#[clap(setting = AppSettings::ArgRequiredElseHelp)] #[clap(setting = AppSettings::ArgRequiredElseHelp)]
ToggleFocusFollowsMouse(ToggleFocusFollowsMouse), ToggleFocusFollowsMouse(ToggleFocusFollowsMouse),
/// Enable or disable mouse follows focus on all workspaces
#[clap(setting = AppSettings::ArgRequiredElseHelp)]
MouseFollowsFocus(MouseFollowsFocus),
/// Toggle mouse follows focus on all workspaces /// Toggle mouse follows focus on all workspaces
ToggleMouseFollowsFocus, ToggleMouseFollowsFocus,
/// Generate a library of AutoHotKey helper functions /// Generate a library of AutoHotKey helper functions
@@ -924,6 +928,14 @@ fn main() -> Result<()> {
SubCommand::ToggleMouseFollowsFocus => { SubCommand::ToggleMouseFollowsFocus => {
send_message(&*SocketMessage::ToggleMouseFollowsFocus.as_bytes()?)?; 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(()) Ok(())