diff --git a/CHANGELOG.md b/CHANGELOG.md index b586e280..4e74942b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed +- Lock assigned handle while mouse_action resize is in progress [#2102](https://github.com/koekeishiya/yabai/issues/2102) ## [6.0.12] - 2024-02-12 ### Added diff --git a/src/event_loop.c b/src/event_loop.c index ec493dc7..e7bc8de3 100644 --- a/src/event_loop.c +++ b/src/event_loop.c @@ -838,8 +838,9 @@ static EVENT_HANDLER(MOUSE_DOWN) if (!window || window_is_fullscreen(window)) goto out; g_mouse_state.window = window; - g_mouse_state.down_location = point; g_mouse_state.window_frame = g_mouse_state.window->frame; + g_mouse_state.down_location = point; + g_mouse_state.direction = 0; int64_t button = CGEventGetIntegerValueField(context, kCGMouseEventButtonNumber); uint8_t mod = (uint8_t) param1; @@ -850,6 +851,14 @@ static EVENT_HANDLER(MOUSE_DOWN) g_mouse_state.current_action = g_mouse_state.action2; } + if (g_mouse_state.current_action == MOUSE_MODE_RESIZE) { + CGPoint frame_mid = { CGRectGetMidX(g_mouse_state.window_frame), CGRectGetMidY(g_mouse_state.window_frame) }; + if (point.x < frame_mid.x) g_mouse_state.direction |= HANDLE_LEFT; + if (point.y < frame_mid.y) g_mouse_state.direction |= HANDLE_TOP; + if (point.x > frame_mid.x) g_mouse_state.direction |= HANDLE_RIGHT; + if (point.y > frame_mid.y) g_mouse_state.direction |= HANDLE_BOTTOM; + } + out: CFRelease(context); } @@ -966,16 +975,7 @@ static EVENT_HANDLER(MOUSE_DRAGGED) int dx = point.x - g_mouse_state.down_location.x; int dy = point.y - g_mouse_state.down_location.y; - uint8_t direction = 0; - CGRect frame = g_mouse_state.window->frame; - CGPoint frame_mid = { CGRectGetMidX(frame), CGRectGetMidY(frame) }; - - if (point.x < frame_mid.x) direction |= HANDLE_LEFT; - if (point.y < frame_mid.y) direction |= HANDLE_TOP; - if (point.x > frame_mid.x) direction |= HANDLE_RIGHT; - if (point.y > frame_mid.y) direction |= HANDLE_BOTTOM; - - window_manager_resize_window_relative_internal(g_mouse_state.window, frame, direction, dx, dy, false); + window_manager_resize_window_relative_internal(g_mouse_state.window, g_mouse_state.window->frame, g_mouse_state.direction, dx, dy, false); g_mouse_state.last_moved_time = event_time; g_mouse_state.down_location = point; diff --git a/src/mouse_handler.h b/src/mouse_handler.h index aa40dc80..d5dad7fc 100644 --- a/src/mouse_handler.h +++ b/src/mouse_handler.h @@ -72,6 +72,7 @@ struct mouse_state struct window *window; CGRect window_frame; uint32_t ffm_window_id; + uint8_t direction; }; static char *mouse_mod_str[] =