void
unfocus_win(struct ws_win *win)
{
+ DNPRINTF(SWM_D_FOCUS, "unfocus_win: id: %lu\n", WINID(win));
+
if (win == NULL)
return;
if (win->ws == NULL)
void
focus_win(struct ws_win *win)
{
+ int rtr;
+ Window wf;
+
DNPRINTF(SWM_D_FOCUS, "focus_win: id: %lu\n", win ? win->id : 0);
if (win == NULL)
win->ws->focus = win;
if (win->ws->r != NULL) {
- grabbuttons(win, 1);
- if (win->ws->cur_layout->flags & SWM_L_MAPONFOCUS)
- XMapRaised(display, win->id);
+ XGetInputFocus(display, &wf, &rtr);
+ if (wf != win->id) {
+ grabbuttons(win, 1);
+ if (win->java == 0)
+ XSetInputFocus(display, win->id,
+ RevertToParent, CurrentTime);
+ }
XSetWindowBorder(display, win->id,
win->ws->r->s->c[SWM_S_COLOR_FOCUS].color);
- if (win->java == 0)
- XSetInputFocus(display, win->id,
- RevertToPointerRoot, CurrentTime);
+ if (win->ws->cur_layout->flags & SWM_L_MAPONFOCUS)
+ XMapRaised(display, win->id);
}
}
if (win == NULL)
return;
+ if (win == win->ws->focus)
+ return;
+
if (do_trans == SWM_F_TRANSIENT && win->child_trans) {
/* win = parent & has a transient so focus on that */
if (win->java) {