From: Marco Peereboom Date: Fri, 23 Oct 2009 04:05:19 +0000 (+0000) Subject: get rid of a bunch of focus in and out events X-Git-Url: https://jasonwoof.com/gitweb/?a=commitdiff_plain;h=ef7f0f55ed7d5c95bd30e5e5be063de8ec3311a4;p=spectrwm.git get rid of a bunch of focus in and out events ok mcbride --- diff --git a/scrotwm.c b/scrotwm.c index 067806b..04dbd0f 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -1353,6 +1353,8 @@ validate_ws(struct workspace *testws) 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) @@ -1406,6 +1408,9 @@ unfocus_all_except(struct ws_win *except) 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) @@ -1431,14 +1436,17 @@ focus_win(struct ws_win *win) 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); } } @@ -3768,6 +3776,9 @@ focus_magic(struct ws_win *win, int do_trans) 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) {