aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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;