Skip to content

Commit

Permalink
Fix for issue #131 (loss of focus after restoring windows).
Browse files Browse the repository at this point in the history
  • Loading branch information
joewing committed Aug 26, 2014
1 parent 4ef3649 commit 6d6b8c9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
15 changes: 15 additions & 0 deletions src/event.c
Expand Up @@ -77,6 +77,7 @@ static void HandleNetWMState(const XClientMessageEvent *event,
ClientNode *np);
static void HandleFrameExtentsRequest(const XClientMessageEvent *event);
static void UpdateState(ClientNode *np);
static void DiscardEnterEvents();

#ifdef USE_SHAPE
static void HandleShapeEvent(const XShapeEvent *event);
Expand Down Expand Up @@ -313,6 +314,18 @@ void DiscardKeyEvents(XEvent *event, Window w)
}
}

/** Discard enter notify events. */
void DiscardEnterEvents()
{
XEvent event;
JXSync(display, False);
while(JXCheckMaskEvent(display, EnterWindowMask, &event)) {
UpdateTime(&event);
SetMousePosition(event.xmotion.x_root, event.xmotion.y_root,
event.xmotion.window);
}
}

/** Process a selection clear event. */
char HandleSelectionClear(const XSelectionClearEvent *event)
{
Expand Down Expand Up @@ -517,6 +530,7 @@ void HandleKeyPress(const XKeyEvent *event)
default:
break;
}
DiscardEnterEvents();
}

/** Handle a key release event. */
Expand Down Expand Up @@ -1479,6 +1493,7 @@ void DispatchBorderButtonEvent(const XButtonEvent *event,
default:
break;
}
DiscardEnterEvents();
}

/** Update window state information. */
Expand Down
3 changes: 0 additions & 3 deletions src/key.c
Expand Up @@ -229,16 +229,13 @@ void RunKeyCommand(const XKeyEvent *event)

KeyNode *np;
unsigned int state;
XEvent dummy;

/* Remove the lock key modifiers. */
state = event->state & ~lockMask;

for(np = bindings; np; np = np->next) {
if(np->state == state && np->code == event->keycode) {
RunCommand(np->command);
JXSync(display, False);
while (JXCheckMaskEvent(display, EnterWindowMask, &dummy)) ;
return;
}
}
Expand Down

0 comments on commit 6d6b8c9

Please sign in to comment.