Skip to content
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

Right click to abort selection #179

Open
tunalad opened this issue Jan 11, 2022 · 1 comment
Open

Right click to abort selection #179

tunalad opened this issue Jan 11, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@tunalad
Copy link

tunalad commented Jan 11, 2022

This might be subjective, but I think most people use the left click when using the selection option. I think it would be a lot better if we just could hit the right mouse button and cancel the operation, instead of having to hit a key on the keyboard.

I know that I can simply do that myself, but I still feel like it's a pretty good option for everyone using this tool.

@daltomi
Copy link
Collaborator

daltomi commented Jan 12, 2022

The problem is that the user may currently be using the right mouse button to capture, either with a simple click or by selecting an area.

Another option would be, once the selection area has started, determine which button (left / right) the user used and capture the event of the other button as a cancel.
But this is only possible once the user creates a selection area and maintains it; at that moment the other mouse button is pressed, which is not currently being used for the selection, canceling the capture.

diff --git a/src/scrot_selection.c b/src/scrot_selection.c
index d09b3d2..bae1cf5 100644
--- a/src/scrot_selection.c
+++ b/src/scrot_selection.c
@@ -242,6 +242,7 @@ bool scrotSelectionGetUserSel(struct SelectionRect *selectionRect)
     fd_set fdSet;
     int count = 0, done = 0;
     int rx = 0, ry = 0, rw = 0, rh = 0, isButtonPressed = 0;
+    unsigned int buttonPressedId = 0;
     Window target = None;
     Status ret;
 
@@ -275,6 +276,7 @@ bool scrotSelectionGetUserSel(struct SelectionRect *selectionRect)
                 break;
             case ButtonPress:
                 isButtonPressed = 1;
+                buttonPressedId = ev.xbutton.button;
                 rx = ev.xbutton.x;
                 ry = ev.xbutton.y;
                 target = scrotGetWindow(disp, ev.xbutton.subwindow, ev.xbutton.x, ev.xbutton.y);
@@ -283,6 +285,8 @@ bool scrotSelectionGetUserSel(struct SelectionRect *selectionRect)
                 break;
             case ButtonRelease:
                 done = 1;
+                if (buttonPressedId != ev.xbutton.button)
+                    done = 2;
                 break;
             case KeyPress:
             {

@daltomi daltomi added the enhancement New feature or request label Jan 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants