mirror of
https://github.com/gryf/wmaker.git
synced 2026-06-18 00:15:25 +02:00
wmaker: grab the keyboard during partial screenshot selection
imageCaptureArea() already looked for XK_Escape in its event loop but only grabbed the pointer, so the KeyPress went to the focused client and the cancel branch was unreachable. Grab the keyboard for the duration of the rubber-band selection, erase the XOR rectangle when Escape aborts mid-drag, and release the keyboard on every exit path.
This commit is contained in:
committed by
Carlos R. Mafra
parent
b69c9db245
commit
f18de447f6
+7
-1
@@ -1143,6 +1143,7 @@ static XImage *imageCaptureArea(WScreen *scr)
|
||||
GrabModeAsync, None, wPreferences.cursor[WCUR_CAPTURE], CurrentTime) != Success) {
|
||||
return NULL;
|
||||
}
|
||||
XGrabKeyboard(dpy, scr->root_win, False, GrabModeAsync, GrabModeAsync, CurrentTime);
|
||||
|
||||
XGrabServer(dpy);
|
||||
|
||||
@@ -1162,6 +1163,7 @@ static XImage *imageCaptureArea(WScreen *scr)
|
||||
if (w > 0 && h > 0) {
|
||||
XDrawRectangle(dpy, scr->root_win, scr->frame_gc, x, y, w, h);
|
||||
XUngrabServer(dpy);
|
||||
XUngrabKeyboard(dpy, CurrentTime);
|
||||
XUngrabPointer(dpy, CurrentTime);
|
||||
return XGetImage(dpy, scr->root_win, x, y, w, h, AllPlanes, ZPixmap);
|
||||
}
|
||||
@@ -1186,8 +1188,11 @@ static XImage *imageCaptureArea(WScreen *scr)
|
||||
XDrawRectangle(dpy, scr->root_win, scr->frame_gc, x, y, w, h);
|
||||
break;
|
||||
case KeyPress:
|
||||
if (W_KeycodeToKeysym(dpy, event.xkey.keycode, 0) == XK_Escape)
|
||||
if (W_KeycodeToKeysym(dpy, event.xkey.keycode, 0) == XK_Escape) {
|
||||
if (w > 0 && h > 0)
|
||||
XDrawRectangle(dpy, scr->root_win, scr->frame_gc, x, y, w, h);
|
||||
quit = 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
WMHandleEvent(&event);
|
||||
@@ -1196,6 +1201,7 @@ static XImage *imageCaptureArea(WScreen *scr)
|
||||
}
|
||||
|
||||
XUngrabServer(dpy);
|
||||
XUngrabKeyboard(dpy, CurrentTime);
|
||||
XUngrabPointer(dpy, CurrentTime);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user