fix(wm): send manual move/resize end events on mouse release

The Acessibility API does not reliably fire AXWindowMoved and
AXWindowResized notifications after the mouse button is released,
causing drag-to-swap and drag-to-resize operations to fail.

This sends manual MoveEnd and ResizeEnd events from the input
event listener when LeftMouseUp is detected, ensuring these
operations complete reliably.

Resizing windows while dragging doesn't really work and has been noted
in the known-issues.md file.
This commit is contained in:
LGUG2Z committed 2025-12-31 18:41:44 -08:00
1 parent 05cd7832e8
commit 9b6b86cdea
3 files changed
+39 -6

No files matched your search

+1
View File
@@ -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
+29 -6
View File
@@ -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);
}
}
}
+9
View File
@@ -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| {