Skip to content

Conversation

@axel-angel
Copy link

@axel-angel axel-angel commented Sep 20, 2025

This implements a new mirror behavior while pressing Ctrl: the box selection will grow outwards from the starting selection (first click) symmetrically. This also works in conjunction with restricted aspect ratio (-a flag or shift key) and/or edit anchor (space key). The doc is also updated to mention this feature.

Demo follows.

capture2.mp4

The code isn't very straightforward, there may be a better way to implement this. Also the behavior is a bit surprising when switching between regular and mirror mode, any idea is welcomed to do this differently.

EDIT: demo updated with last change.

Comment on lines +111 to +112
width = 2 * abs(start_x - current_selection->x);
height = 2 * abs(start_y - current_selection->y);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also include the +1 offset implemented below?

Comment on lines +130 to +131
current_selection->selection.x = dist_x > 0 || seat->state->mirror_mode ? anchor_x : anchor_x - (width - 1);
current_selection->selection.y = dist_y > 0 || seat->state->mirror_mode ? anchor_y : anchor_y - (height - 1);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, the -1 offset when dist is negative may be required for mirror mode. We may need to structure the code a bit differently to write the code only once.

PS: is the -1 to compensate the border? in that case we need to use state border_weight instead.

@axel-angel
Copy link
Author

Also the behavior is a bit surprising when switching between regular and mirror mode

commit 636efee addresss this issue making the transition predictable and flawless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant