mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-07-16 01:52:48 +02:00
feat(wm): add toggle-focus-follows-mouse cmd
Decided there should be a quick way to toggle the native ffm functionality, it gets especially annoying when trying to click drop downs from the system tray etc. re #7
This commit is contained in:
@@ -207,12 +207,13 @@ restore-windows Restore all hidden windows (debugging command)
|
||||
manage Force komorebi to manage the focused window
|
||||
unmanage Unmanage a window that was forcibly managed
|
||||
reload-configuration Reload ~/komorebi.ahk (if it exists)
|
||||
watch-configuration Toggle the automatic reloading of ~/komorebi.ahk (if it exists)
|
||||
watch-configuration Enable or disable watching of ~/komorebi.ahk (if it exists)
|
||||
float-rule Add a rule to always float the specified application
|
||||
manage-rule Add a rule to always manage the specified application
|
||||
workspace-rule Add a rule to associate an application with a workspace
|
||||
identify-tray-application Identify an application that closes to the system tray
|
||||
focus-follows-mouse Enable or disable focus follows mouse for the operating system
|
||||
toggle-focus-follows-mouse Toggle focus follows mouse for the operating system
|
||||
ahk-library Generate a library of AutoHotKey helper functions
|
||||
help Print this message or the help of the given subcommand(s)
|
||||
```
|
||||
|
||||
@@ -66,6 +66,7 @@ pub enum SocketMessage {
|
||||
IdentifyTrayApplication(ApplicationIdentifier, String),
|
||||
State,
|
||||
FocusFollowsMouse(bool),
|
||||
ToggleFocusFollowsMouse,
|
||||
}
|
||||
|
||||
impl SocketMessage {
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
; Enable hot reloading of changes to this file
|
||||
WatchConfiguration("enable")
|
||||
|
||||
; Enable focus follows mouse
|
||||
FocusFollowsMouse("enable")
|
||||
|
||||
; Ensure there are 5 workspaces created on monitor 0
|
||||
EnsureWorkspaces(0, 5)
|
||||
|
||||
@@ -41,6 +38,9 @@ FloatRule("exe", "wincompose.exe")
|
||||
FloatRule("exe", "1Password.exe")
|
||||
FloatRule("exe", "Wox.exe")
|
||||
|
||||
; Identify Minimize-to-Tray Applications
|
||||
IdentifyTrayApplication("exe", "Discord.exe")
|
||||
|
||||
; Change the focused window, Alt + Vim direction keys
|
||||
!h::
|
||||
Focus("left")
|
||||
@@ -170,6 +170,11 @@ return
|
||||
TogglePause()
|
||||
return
|
||||
|
||||
; Toggle focus follows mouse
|
||||
!0::
|
||||
ToggleFocusFollowsMouse()
|
||||
return
|
||||
|
||||
; Switch to workspace
|
||||
!1::
|
||||
Send !
|
||||
|
||||
@@ -179,6 +179,13 @@ impl WindowManager {
|
||||
WindowsApi::disable_focus_follows_mouse()?;
|
||||
}
|
||||
}
|
||||
SocketMessage::ToggleFocusFollowsMouse => {
|
||||
if WindowsApi::focus_follows_mouse()? {
|
||||
WindowsApi::disable_focus_follows_mouse()?;
|
||||
} else {
|
||||
WindowsApi::enable_focus_follows_mouse()?;
|
||||
}
|
||||
}
|
||||
SocketMessage::ReloadConfiguration => {
|
||||
Self::reload_configuration();
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ use bindings::Windows::Win32::UI::WindowsAndMessaging::HWND_TOPMOST;
|
||||
use bindings::Windows::Win32::UI::WindowsAndMessaging::SET_WINDOW_POS_FLAGS;
|
||||
use bindings::Windows::Win32::UI::WindowsAndMessaging::SHOW_WINDOW_CMD;
|
||||
use bindings::Windows::Win32::UI::WindowsAndMessaging::SPIF_SENDCHANGE;
|
||||
use bindings::Windows::Win32::UI::WindowsAndMessaging::SPI_GETACTIVEWINDOWTRACKING;
|
||||
use bindings::Windows::Win32::UI::WindowsAndMessaging::SPI_SETACTIVEWINDOWTRACKING;
|
||||
use bindings::Windows::Win32::UI::WindowsAndMessaging::SW_HIDE;
|
||||
use bindings::Windows::Win32::UI::WindowsAndMessaging::SW_MAXIMIZE;
|
||||
@@ -557,6 +558,19 @@ impl WindowsApi {
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn focus_follows_mouse() -> Result<bool> {
|
||||
let mut is_enabled: BOOL = unsafe { std::mem::zeroed() };
|
||||
|
||||
Self::system_parameters_info_w(
|
||||
SPI_GETACTIVEWINDOWTRACKING,
|
||||
0,
|
||||
(&mut is_enabled as *mut BOOL).cast(),
|
||||
SPIF_SENDCHANGE,
|
||||
)?;
|
||||
|
||||
Ok(is_enabled.into())
|
||||
}
|
||||
|
||||
pub fn enable_focus_follows_mouse() -> Result<()> {
|
||||
Self::system_parameters_info_w(
|
||||
SPI_SETACTIVEWINDOWTRACKING,
|
||||
|
||||
@@ -168,6 +168,10 @@ FocusFollowsMouse(boolean_state) {
|
||||
Run, komorebic.exe focus-follows-mouse %boolean_state%, , Hide
|
||||
}
|
||||
|
||||
ToggleFocusFollowsMouse() {
|
||||
Run, komorebic.exe toggle-focus-follows-mouse, , Hide
|
||||
}
|
||||
|
||||
AhkLibrary() {
|
||||
Run, komorebic.exe ahk-library, , Hide
|
||||
}
|
||||
@@ -328,7 +328,7 @@ enum SubCommand {
|
||||
Unmanage,
|
||||
/// Reload ~/komorebi.ahk (if it exists)
|
||||
ReloadConfiguration,
|
||||
/// Toggle the automatic reloading of ~/komorebi.ahk (if it exists)
|
||||
/// Enable or disable watching of ~/komorebi.ahk (if it exists)
|
||||
#[clap(setting = AppSettings::ArgRequiredElseHelp)]
|
||||
WatchConfiguration(WatchConfiguration),
|
||||
/// Add a rule to always float the specified application
|
||||
@@ -345,6 +345,8 @@ enum SubCommand {
|
||||
IdentifyTrayApplication(IdentifyTrayApplication),
|
||||
/// Enable or disable focus follows mouse for the operating system
|
||||
FocusFollowsMouse(FocusFollowsMouse),
|
||||
/// Toggle focus follows mouse for the operating system
|
||||
ToggleFocusFollowsMouse,
|
||||
/// Generate a library of AutoHotKey helper functions
|
||||
AhkLibrary,
|
||||
}
|
||||
@@ -439,6 +441,9 @@ fn main() -> Result<()> {
|
||||
&*SocketMessage::AdjustContainerPadding(arg.sizing, arg.adjustment).as_bytes()?,
|
||||
)?;
|
||||
}
|
||||
SubCommand::ToggleFocusFollowsMouse => {
|
||||
send_message(&*SocketMessage::ToggleFocusFollowsMouse.as_bytes()?)?;
|
||||
}
|
||||
SubCommand::ToggleTiling => {
|
||||
send_message(&*SocketMessage::ToggleTiling.as_bytes()?)?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user