aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-06-29 00:23:46 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-06-29 00:23:46 +0200
commit5ff9125db3a7f8f545cbfb5f7bf452c8b0db4d41 (patch)
treee1a37a814e6f6544ed96848904ef48319fb77403
parent24497c3cf4d6810d3a69a2d2b412d86b548e4939 (diff)
downloadjwm-5ff9125db3a7f8f545cbfb5f7bf452c8b0db4d41.tar.gz
Raise window on next/prev key release
-rw-r--r--src/event.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/src/event.c b/src/event.c
index f88e2a5..8850665 100644
--- a/src/event.c
+++ b/src/event.c
@@ -30,6 +30,9 @@
#define MIN_TIME_DELTA 50
+/** Whether a window switch is active. */
+int switching = 0;
+
static void Signal();
static void DispatchBorderButtonEvent(const XButtonEvent *event,
ClientNode *np);
@@ -44,6 +47,7 @@ static void HandleMapRequest(const XMapEvent *event);
static void HandleUnmapNotify(const XUnmapEvent *event);
static void HandleButtonEvent(const XButtonEvent *event);
static void HandleKeyPress(const XKeyEvent *event);
+static void HandleKeyRelease(const XKeyEvent *event);
static void HandleEnterNotify(const XCrossingEvent *event);
static void HandleLeaveNotify(const XCrossingEvent *event);
static void HandleMotionNotify(const XMotionEvent *event);
@@ -207,6 +211,9 @@ void ProcessEvent(XEvent *event) {
case KeyPress:
HandleKeyPress(&event->xkey);
break;
+ case KeyRelease:
+ HandleKeyRelease(&event->xkey);
+ break;
case EnterNotify:
HandleEnterNotify(&event->xcrossing);
break;
@@ -219,7 +226,6 @@ void ProcessEvent(XEvent *event) {
break;
case DestroyNotify:
case Expose:
- case KeyRelease:
case ConfigureNotify:
break;
default:
@@ -343,6 +349,12 @@ void HandleKeyPress(const XKeyEvent *event) {
np = GetActiveClient();
+#define SWITCH() do { \
+ switching = 1; \
+ JXGrabKeyboard(display, rootWindow, False, \
+ GrabModeAsync, GrabModeAsync, CurrentTime); \
+ } while (0)
+
switch(key & 0xFF) {
case KEY_EXEC:
RunKeyCommand(event);
@@ -362,15 +374,19 @@ void HandleKeyPress(const XKeyEvent *event) {
break;
case KEY_NEXT:
FocusNext();
+ SWITCH();
break;
case KEY_NEXT_STACKED:
FocusNextStackedCircular();
+ SWITCH();
break;
case KEY_PREV:
FocusPrevious();
+ SWITCH();
break;
case KEY_PREV_STACKED:
FocusPreviousStackedCircular();
+ SWITCH();
break;
case KEY_RAISE:
if(np) {
@@ -434,6 +450,30 @@ void HandleKeyPress(const XKeyEvent *event) {
/****************************************************************************
****************************************************************************/
+void HandleKeyRelease(const XKeyEvent *event) {
+ ClientNode *np;
+ KeyType key;
+
+ key = GetKey(event);
+
+ switch(key & 0xFF) {
+ case KEY_NEXT:
+ case KEY_PREV:
+ case KEY_NEXT_STACKED:
+ case KEY_PREV_STACKED:
+ break;
+ default:
+ if(switching) {
+ switching = 0;
+ np = GetActiveClient();
+ if (np) RaiseClient(np);
+ JXUngrabKeyboard(display, CurrentTime);
+ }
+ }
+}
+
+/****************************************************************************
+ ****************************************************************************/
void HandleConfigureRequest(const XConfigureRequestEvent *event) {
XWindowChanges wc;