summaryrefslogtreecommitdiff
path: root/dwl.c
diff options
context:
space:
mode:
Diffstat (limited to 'dwl.c')
-rw-r--r--dwl.c43
1 files changed, 16 insertions, 27 deletions
diff --git a/dwl.c b/dwl.c
index c09f598..eeb1210 100644
--- a/dwl.c
+++ b/dwl.c
@@ -176,7 +176,6 @@ struct Monitor {
double mfact;
int nmaster;
Client *fullscreenclient;
- int position;
};
typedef struct {
@@ -235,7 +234,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);
@@ -320,8 +319,10 @@ static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr;
static struct wlr_cursor *cursor;
static struct wlr_xcursor_manager *cursor_mgr;
+#ifdef XWAYLAND
static struct wlr_xcursor *xcursor;
static struct wlr_xcursor_manager *xcursor_mgr;
+#endif
static struct wlr_seat *seat;
static struct wl_list keyboards;
@@ -830,7 +831,6 @@ createmon(struct wl_listener *listener, void *data)
m = wlr_output->data = calloc(1, sizeof(*m));
m->wlr_output = wlr_output;
m->tagset[0] = m->tagset[1] = 1;
- m->position = -1;
for (r = monrules; r < END(monrules); r++) {
if (!r->name || strstr(wlr_output->name, r->name)) {
m->mfact = r->mfact;
@@ -839,7 +839,6 @@ createmon(struct wl_listener *listener, void *data)
wlr_xcursor_manager_load(cursor_mgr, r->scale);
m->lt[0] = m->lt[1] = r->lt;
wlr_output_set_transform(wlr_output, r->rr);
- m->position = r - monrules;
break;
}
}
@@ -848,15 +847,7 @@ createmon(struct wl_listener *listener, void *data)
LISTEN(&wlr_output->events.frame, &m->frame, rendermon);
LISTEN(&wlr_output->events.destroy, &m->destroy, cleanupmon);
- wl_list_for_each(moni, &mons, link)
- if (m->position > moni->position)
- insertmon = moni;
-
- if (insertmon) /* insertmon is the leftmost monitor to m */
- wl_list_insert(&insertmon->link, &m->link);
- else
- wl_list_insert(&mons, &m->link);
-
+ wl_list_insert(&mons, &m->link);
wlr_output_enable(wlr_output, 1);
if (!wlr_output_commit(wlr_output))
return;
@@ -1096,19 +1087,17 @@ fullscreennotify(struct wl_listener *listener, void *data)
}
Monitor *
-dirtomon(int dir)
+dirtomon(enum wlr_direction 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);
- }
+ 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
@@ -2517,8 +2506,8 @@ xwaylandready(struct wl_listener *listener, void *data)
* not detect that window type. */
netatom[NetWMWindowTypeDialog] = getatom(xc, "_NET_WM_WINDOW_TYPE_DIALOG");
netatom[NetWMWindowTypeSplash] = getatom(xc, "_NET_WM_WINDOW_TYPE_SPLASH");
- netatom[NetWMWindowTypeUtility] = getatom(xc, "_NET_WM_WINDOW_TYPE_TOOLBAR");
- netatom[NetWMWindowTypeToolbar] = getatom(xc, "_NET_WM_WINDOW_TYPE_UTILITY");
+ netatom[NetWMWindowTypeToolbar] = getatom(xc, "_NET_WM_WINDOW_TYPE_TOOLBAR");
+ netatom[NetWMWindowTypeUtility] = getatom(xc, "_NET_WM_WINDOW_TYPE_UTILITY");
/* assign the one and only seat */
wlr_xwayland_set_seat(xwayland, seat);