feat(cli): implement minimize cmd

This commit is contained in:
LGUG2Z committed 2025-09-25 10:19:11 -07:00
1 parent 8c4c1963bc
commit a89b9cf5ac
4 files changed
+17 -3

No files matched your search

+1 -1
View File
@@ -248,7 +248,7 @@ pub enum SocketMessage {
SwapWorkspacesToMonitorNumber(usize),
// ForceFocus,
// Close,
// Minimize,
Minimize,
Promote,
PromoteFocus,
PromoteWindow(OperationDirection),
+5
View File
@@ -240,6 +240,11 @@ impl WindowManager {
}
self.focus_container_window(idx)?;
}
SocketMessage::Minimize => {
let foreground_window =
MacosApi::foreground_window().ok_or_eyre("there is no foreground window")?;
AdhocWindow::minimize(&foreground_window)?;
}
SocketMessage::LockMonitorWorkspaceContainer(
monitor_idx,
workspace_idx,
+6
View File
@@ -752,6 +752,12 @@ impl AdhocWindow {
.map(|s| s.to_string())
}
pub fn minimize(element: &CFRetained<AXUIElement>) -> Result<(), AccessibilityError> {
let cf_boolean = CFBoolean::new(true);
let value = &**cf_boolean;
AccessibilityApi::set_attribute_cf_value(element, kAXMinimizedAttribute, value)
}
#[tracing::instrument(skip_all)]
pub fn hide(id: u32, element: &CFRetained<AXUIElement>) -> Result<(), AccessibilityError> {
let mut window_restore_positions = WINDOW_RESTORE_POSITIONS.lock();
+5 -2
View File
@@ -660,8 +660,8 @@ enum SubCommand {
/// Move the focused window in the specified direction
#[clap(arg_required_else_help = true)]
Move(Move),
// /// Minimize the focused window
// Minimize,
/// Minimize the focused window
Minimize,
// /// Close the focused window
// Close,
// /// Forcibly focus the window at the cursor with a left mouse click
@@ -1307,6 +1307,9 @@ fn main() -> eyre::Result<()> {
SubCommand::Retile => {
send_message(&SocketMessage::Retile)?;
}
SubCommand::Minimize => {
send_message(&SocketMessage::Minimize)?;
}
SubCommand::Promote => {
send_message(&SocketMessage::Promote)?;
}