aboutsummaryrefslogtreecommitdiff
path: root/dwl.c
diff options
context:
space:
mode:
authorDevin J. Pohly <djpohly@gmail.com>2020-04-23 00:38:09 -0500
committerDevin J. Pohly <djpohly@gmail.com>2020-04-23 00:38:09 -0500
commit59b09576b934c8837a90312fc8e7723640733172 (patch)
tree01e4a107b7be441d01febe7ee7dc47ebe7d47631 /dwl.c
parenta634b3f2e46361aa394dc2582023fe499f520d4a (diff)
restrict focusnext to the same monitor
Diffstat (limited to 'dwl.c')
-rw-r--r--dwl.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/dwl.c b/dwl.c
index 56c2d49..8add044 100644
--- a/dwl.c
+++ b/dwl.c
@@ -411,15 +411,18 @@ focus(Client *c, struct wlr_surface *surface)
void
focusnext(const Arg *arg)
{
+ /* Focus the client on the selected monitor which comes first in tiling
+ * order after the currently selected client */
Client *sel = selclient();
if (!sel)
return;
- /* Find the selected client (top of fstack) and focus the client
- * following it in tiling order */
- Client *c = wl_container_of(sel->link.next, c, link);
- /* Skip the sentinel node if we wrap around the end of the list */
- if (&c->link == &clients)
- c = wl_container_of(c->link.next, c, link);
+ Client *c;
+ wl_list_for_each(c, &sel->link, link) {
+ if (&c->link == &clients)
+ continue; /* wrap past the sentinel node */
+ if (VISIBLEON(c, selmon))
+ break; /* found it */
+ }
focus(c, c->xdg_surface->surface);
}