diff --git a/docs/known-issues.md b/docs/known-issues.md index da251eb0..3ef209f9 100644 --- a/docs/known-issues.md +++ b/docs/known-issues.md @@ -4,3 +4,4 @@ state (probably shouldn't) * Application hiding isn't supported (and probably won't be) and breaks the state (probably shouldn't) +* Resizing windows by dragging with animations on is a train wreck; don't do it diff --git a/komorebi/src/input_event_listener.rs b/komorebi/src/input_event_listener.rs index ac4a06de..3d6fbb78 100644 --- a/komorebi/src/input_event_listener.rs +++ b/komorebi/src/input_event_listener.rs @@ -44,14 +44,37 @@ extern "C-unwind" fn callback( element.pid(NonNull::from_mut(&mut pid)); } - if pid != 0 - && let Some(event) = WindowManagerEvent::from_system_notification( + if pid != 0 { + let window_id = AccessibilityApi::window_id(&element).ok(); + + // Send MoveEnd to handle pending drag-to-swap operations + // macOS doesn't reliably fire AXWindowMoved after mouse release + if let Some(event) = WindowManagerEvent::from_system_notification( + SystemNotification::Manual(ManualNotification::MoveEnd), + pid, + window_id, + ) { + window_manager_event_listener::send_notification(event); + } + + // Send ResizeEnd to handle pending resize operations + // macOS doesn't reliably fire AXWindowResized after mouse release + if let Some(event) = WindowManagerEvent::from_system_notification( + SystemNotification::Manual(ManualNotification::ResizeEnd), + pid, + window_id, + ) { + window_manager_event_listener::send_notification(event); + } + + // Handle tab dragging to create new windows + if let Some(event) = WindowManagerEvent::from_system_notification( SystemNotification::Manual(ManualNotification::ShowOnInputEvent), pid, - AccessibilityApi::window_id(&element).ok(), - ) - { - window_manager_event_listener::send_notification(event); + window_id, + ) { + window_manager_event_listener::send_notification(event); + } } } diff --git a/komorebi/src/window_manager_event.rs b/komorebi/src/window_manager_event.rs index 72ec784b..7109f04c 100644 --- a/komorebi/src/window_manager_event.rs +++ b/komorebi/src/window_manager_event.rs @@ -24,6 +24,8 @@ pub enum ManualNotification { ShowOnFocusChangeWindowlessAppRestored, Manage, Unmanage, + MoveEnd, + ResizeEnd, } #[derive(Debug, Copy, Clone, Serialize, Deserialize, Display)] @@ -95,6 +97,13 @@ impl WindowManagerEvent { .map(|window_id| WindowManagerEvent::Manage(notification, process_id, window_id)), SystemNotification::Manual(ManualNotification::Unmanage) => window_id .map(|window_id| WindowManagerEvent::Unmanage(notification, process_id, window_id)), + SystemNotification::Manual(ManualNotification::MoveEnd) => window_id + .map(|window_id| WindowManagerEvent::MoveEnd(notification, process_id, window_id)), + SystemNotification::Manual(ManualNotification::ResizeEnd) => { + window_id.map(|window_id| { + WindowManagerEvent::ResizeEnd(notification, process_id, window_id) + }) + } SystemNotification::Accessibility(AccessibilityNotification::AXWindowMoved) => { if MacosApi::left_mouse_button_is_pressed() { window_id.map(|window_id| {