scrot icon indicating copy to clipboard operation
scrot copied to clipboard

Right click to abort selection

Open tunalad opened this issue 3 years ago • 1 comments

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.

tunalad avatar Jan 11 '22 12:01 tunalad

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 avatar Jan 12 '22 00:01 daltomi