feat(wm): add cmd to identify 'close to tray' apps

Issue #6 highlighted a workflow that I don't personally use, but I am
sure is common among other Windows users, which is to use the Close
button to minimize an application to the tray.

Since this is largely a configurable option in those applications
(Discord etc.), I have implemented a command for the user to identify
those applications themselves when configuring the window manager,
instead of adding them to the previous Vec of known multi-window
applications that need to be identified by default.

Close/minimize to tray applications can be identified either by their
class or their executable name.

I figure it is pretty important to know the rules defined on the window
manager instance, so I have exposed these on a new window_manager::State
struct which is now what get returns from the 'komorebic.exe state'
command.

resolve #6
This commit is contained in:
LGUG2Z
2021-08-15 18:34:27 -07:00
parent b6ff862705
commit b2ab893e77
9 changed files with 122 additions and 29 deletions

View File

@@ -14,6 +14,7 @@ use bindings::Windows::Win32::Foundation::HWND;
use bindings::Windows::Win32::UI::WindowsAndMessaging::ShowWindow;
use bindings::Windows::Win32::UI::WindowsAndMessaging::SHOW_WINDOW_CMD;
use bindings::Windows::Win32::UI::WindowsAndMessaging::SW_RESTORE;
use komorebi_core::ApplicationIdentifier;
use komorebi_core::CycleDirection;
use komorebi_core::Layout;
use komorebi_core::LayoutFlip;
@@ -62,6 +63,7 @@ enum SubCommand {
FloatClass(FloatTarget),
FloatExe(FloatTarget),
FloatTitle(FloatTarget),
IdentifyTrayApplication(ApplicationTarget),
AdjustContainerPadding(SizingAdjustment),
AdjustWorkspacePadding(SizingAdjustment),
FlipLayout(LayoutFlip),
@@ -130,6 +132,12 @@ struct FloatTarget {
id: String,
}
#[derive(Clap)]
struct ApplicationTarget {
identifier: ApplicationIdentifier,
id: String,
}
#[derive(Clap)]
struct Resize {
edge: OperationDirection,
@@ -354,6 +362,12 @@ fn main() -> Result<()> {
};
send_message(&*SocketMessage::WatchConfiguration(enable).as_bytes()?)?;
}
SubCommand::IdentifyTrayApplication(target) => {
send_message(
&*SocketMessage::IdentifyTrayApplication(target.identifier, target.id)
.as_bytes()?,
)?;
}
}
Ok(())