summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@gnugeneration.com>2016-08-14 19:09:31 -0700
committerVito Caputo <vcaputo@gnugeneration.com>2016-08-14 19:09:31 -0700
commit667dbddff7a2656695fda5ea65529b918713359d (patch)
tree7f9876e6c3a6506cb306f9c91b31e994be4f7cf8
parente854f91f8bbf5a360c2a8713c52f6de19dfd9568 (diff)
Set input focus in vwm_win_focus() when is_mapped()
It's inappropriate to assume the window being focused is in the visible context. This caused the input focus to spuriously vanish if a window on another desktop went away causing the next one, also invisible, to get focused. I'm surprised how long I went without ever noticing this bug! My workflow basically never has windows vanishing that aren't in the focused context.
-rw-r--r--vwm.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/vwm.c b/vwm.c
index 3b16d8c..2f31f9d 100644
--- a/vwm.c
+++ b/vwm.c
@@ -1702,13 +1702,15 @@ static void vwm_win_autoconf(vwm_window_t *vwin, vwm_screen_rel_t rel, vwm_win_a
/* focus a window */
-/* this updates window border color as needed and the X input focus */
+/* this updates window border color as needed and the X input focus if mapped */
static void vwm_win_focus(vwm_window_t *vwin)
{
VWM_TRACE("focusing: %#x", (unsigned int)vwin->xwindow->id);
- /* change the focus to the new window */
- XSetInputFocus(display, vwin->xwindow->id, RevertToPointerRoot, CurrentTime);
+ if(vwm_xwin_is_mapped(vwin->xwindow)) {
+ /* if vwin is mapped give it the input focus */
+ XSetInputFocus(display, vwin->xwindow->id, RevertToPointerRoot, CurrentTime);
+ }
/* update the border color accordingly */
if(vwin->shelved) {
@@ -1717,17 +1719,16 @@ static void vwm_win_focus(vwm_window_t *vwin)
/* fullscreen windows in the shelf when focused, since we don't intend to overlap there */
vwm_win_autoconf(vwin, VWM_SCREEN_REL_POINTER, VWM_WIN_AUTOCONF_FULL); /* XXX TODO: for now the shelf follows the pointer, it's simple. */
} else {
- if(vwin->desktop == focused_desktop && focused_desktop->focused_window) {
- /* if we've changed focus within the same desktop, set the currently focused window border to the
- * unfocused color. Otherwise, we want to leave the focused color on the old window on the old desktop */
- XSetWindowBorder(display, focused_desktop->focused_window->xwindow->id, unfocused_window_border_color.pixel);
+ if(vwin->desktop->focused_window) {
+ /* set the border of the previously focused window on the same desktop to the unfocused color */
+ XSetWindowBorder(display, vwin->desktop->focused_window->xwindow->id, unfocused_window_border_color.pixel);
}
/* set the border of the newly focused window to the focused color */
XSetWindowBorder(display, vwin->xwindow->id, focused_window_border_color.pixel);
/* persist this on a per-desktop basis so it can be restored on desktop switches */
- focused_desktop->focused_window = vwin;
+ vwin->desktop->focused_window = vwin;
}
}
© All Rights Reserved