Skip to content

Commit

Permalink
koekeishiya#2102 lock assigned handle while mouse_action resize is in…
Browse files Browse the repository at this point in the history
… progress
  • Loading branch information
koekeishiya committed Feb 18, 2024
1 parent af9d4cd commit 66955f2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions src/event_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/mouse_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[] =
Expand Down

0 comments on commit 66955f2

Please sign in to comment.