aboutsummaryrefslogtreecommitdiff
path: root/dwl.c
diff options
context:
space:
mode:
authorDevin J. Pohly <djpohly@gmail.com>2021-01-06 17:19:44 -0500
committerDevin J. Pohly <djpohly@gmail.com>2021-01-06 17:19:44 -0500
commite8ca8a8ac722d8db819280487a69e08cf3a76573 (patch)
tree84a2305ab29917ff93b2a671d0f908f4be095d91 /dwl.c
parent4bf2923f4ec7d3dadc5a36928f8e98d9734b207d (diff)
use output layout for dirtomon
No need to track our own order; wlroots has a reasonable default for us already.
Diffstat (limited to 'dwl.c')
-rw-r--r--dwl.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/dwl.c b/dwl.c
index c09f598..f16f0ed 100644
--- a/dwl.c
+++ b/dwl.c
@@ -235,7 +235,7 @@ static void cursorframe(struct wl_listener *listener, void *data);
static void destroylayersurfacenotify(struct wl_listener *listener, void *data);
static void destroynotify(struct wl_listener *listener, void *data);
static void destroyxdeco(struct wl_listener *listener, void *data);
-static Monitor *dirtomon(int dir);
+static Monitor *dirtomon(enum wlr_direction dir);
static void focusclient(Client *c, int lift);
static void focusmon(const Arg *arg);
static void focusstack(const Arg *arg);
@@ -1096,19 +1096,17 @@ fullscreennotify(struct wl_listener *listener, void *data)
}
Monitor *
-dirtomon(int dir)
-{
- Monitor *m;
-
- if (dir > 0) {
- if (selmon->link.next == &mons)
- return wl_container_of(mons.next, m, link);
- return wl_container_of(selmon->link.next, m, link);
- } else {
- if (selmon->link.prev == &mons)
- return wl_container_of(mons.prev, m, link);
- return wl_container_of(selmon->link.prev, m, link);
- }
+dirtomon(enum wlr_direction dir)
+{
+ struct wlr_output *next;
+ if ((next = wlr_output_layout_adjacent_output(output_layout,
+ dir, selmon->wlr_output, selmon->m.x, selmon->m.y)))
+ return next->data;
+ if ((next = wlr_output_layout_farthest_output(output_layout,
+ dir ^ (WLR_DIRECTION_LEFT|WLR_DIRECTION_RIGHT),
+ selmon->wlr_output, selmon->m.x, selmon->m.y)))
+ return next->data;
+ return selmon;
}
void