diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/parser.c | 4 | ||||
| -rw-r--r-- | src/sxwm.c | 72 |
2 files changed, 50 insertions, 26 deletions
diff --git a/src/parser.c b/src/parser.c index ebfe4ef..5b8e6f0 100644 --- a/src/parser.c +++ b/src/parser.c @@ -104,9 +104,6 @@ static unsigned parse_combo(const char *combo, Config *cfg, KeySym *out_ks) } buf[sizeof buf - 1] = '\0'; for (char *tok = strtok(buf, "+"); tok; tok = strtok(NULL, "+")) { - for (char *q = tok; *q; q++) { - *q = tolower((unsigned char)*q); - } if (!strcmp(tok, "mod")) { m |= cfg->modkey; } @@ -123,6 +120,7 @@ static unsigned parse_combo(const char *combo, Config *cfg, KeySym *out_ks) m |= Mod4Mask; } else { + ks = XStringToKeysym(tok); ks = parse_keysym(tok); } } @@ -366,47 +366,73 @@ Window find_toplevel(Window w) void focus_next(void) { - if (!focused || !workspaces[current_ws]) { + if (!workspaces[current_ws]) { return; } - focused = (focused->next ? focused->next : workspaces[current_ws]); - current_monitor = focused->mon; - XSetInputFocus(dpy, focused->win, RevertToPointerRoot, CurrentTime); - XRaiseWindow(dpy, focused->win); - if (user_config.warp_cursor) { - warp_cursor(focused); + Client *start = focused ? focused : workspaces[current_ws]; + Client *c = start; + + /* loop until we find a mapped client or return to start */ + do { + c = c->next ? c->next : workspaces[current_ws]; + } while (!c->mapped && c != start); + + /* this stops invisible windows being detected or focused */ + if (!c->mapped) { + return; } + + focused = c; + current_monitor = c->mon; + XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); + XRaiseWindow(dpy, c->win); + if (user_config.warp_cursor) + warp_cursor(c); update_borders(); } void focus_prev(void) { - if (!focused || !workspaces[current_ws]) { + if (!workspaces[current_ws]) { return; } - Client *p = workspaces[current_ws], *prev = NULL; - while (p && p != focused) { - prev = p; - p = p->next; - } + Client *start = focused ? focused : workspaces[current_ws]; + Client *c = start; - if (!prev) { - while (p->next) { + /* loop until we find a mapped client or return to start */ + do { + Client *p = workspaces[current_ws], *prev = NULL; + while (p && p != c) { + prev = p; p = p->next; } - focused = p; - } - else { - focused = prev; + + if (prev) { + c = prev; + } + else { + /* wrap to tail */ + p = workspaces[current_ws]; + while (p->next) + p = p->next; + c = p; + } + } while (!c->mapped && c != start); + + /* this stops invisible windows being detected or focused */ + if (!c->mapped) { + return; } - current_monitor = focused->mon; - XSetInputFocus(dpy, focused->win, RevertToPointerRoot, CurrentTime); - XRaiseWindow(dpy, focused->win); + focused = c; + current_monitor = c->mon; + + XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); + XRaiseWindow(dpy, c->win); if (user_config.warp_cursor) { - warp_cursor(focused); + warp_cursor(c); } update_borders(); } |
