-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move selection on space
keypress
#35
Conversation
Can you explain what this feature is? I'm not familiar with macOS. |
Oh yeah my bad. When taking a screenshot, you can select a part of the screen as well. During this selection, you can also use the modifier Video: Also on mac, if you press |
Hey @emersion! I still have a couple of comments, let me know if you need anything else! |
main.c
Outdated
seat->selection.height = abs(seat->y - seat->pressed_y); | ||
break; | ||
case WL_POINTER_BUTTON_STATE_PRESSED: { | ||
int32_t anchor_x = max(0, seat->anchor_x); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm doing the max
here and not l.100 because we don't want the selection to be cropped if the user goes out of bounds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean you want to prevent the selection to go out of bounds?
The same needs to be done for the upper bound, I suppose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want the selection to go out of bound. I just don't want it to be cropped.
Example: I'm doing a 100x100 selection and I want to move it to the 0,0 position.
If I go out of bounds atop of the screen by 10px, I don't want it to become a 100x90 because I feel it frustrating having to go through the resizing part of the selection again.
And if you don't max
you could end up with a wrong anchor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, sorry for the delay. I'll have a look at this PR soon. |
Haha don't worry I'm just happy to contribute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi again! Thanks for your patience, here are a few comments :)
main.c
Outdated
result->y = min(seat->pressed_y, seat->y); | ||
result->width = abs(seat->x - seat->pressed_x); | ||
result->height = abs(seat->y - seat->pressed_y); | ||
int32_t anchor_x = max(0, seat->anchor_x); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, why is this required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you release the selection while out of bound - because you want to start at position 0,0 for example - you don't want to select the out of bound part of your screen.
main.c
Outdated
seat->selection.height = abs(seat->y - seat->pressed_y); | ||
break; | ||
case WL_POINTER_BUTTON_STATE_PRESSED: { | ||
int32_t anchor_x = max(0, seat->anchor_x); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean you want to prevent the selection to go out of bounds?
The same needs to be done for the upper bound, I suppose.
@emersion 😱 I got an issue with the following commit:
Somehow, if I move around my selection too fast between two monitors, it gets resized 😱 Tried moving fast on the same monitor, or out of bound and back, it's fine. I cannot reproduce this bug with the previous version of the build I did. Any idea? |
Thanks for the update, the code looks much better now :D I've tried to debug this, and after figuring out that the size of the box doesn't change between the beginning and the end of I'd suggest adding a |
main.c
Outdated
int y = wl_fixed_to_int(surface_y) + seat->current_output->logical_geometry.y; | ||
|
||
if (seat->state->edit_anchor) { | ||
seat->anchor_x = seat->anchor_x + (x - seat->x); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified to
seat->anchor_x += x - seat->x;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep forgot it when I was trying to debug 😅 Thanks
After these changes (and a rebase), this PR will be good to merge. |
Now that you gave me the answer, It seems pretty obvious. Thanks a lot 😄
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, this is good to go! Again, I'm sorry it took so long.
No issue whatsoever! I love using sway and its ecosystem 😄 |
Hi,
This is a feature add.
When dragging the selection, you can use the modifier
space
key to move your selection aroundVideo:


Result on second screen (not from the same recording and my screens aren't aligned):