aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd/dwm/layout.c
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2020-06-04 19:10:07 -0700
committerNicholas Noll <nbnoll@eml.cc>2020-06-04 19:10:07 -0700
commit0a8f62d8c7116be9e344f351df679599908fb29c (patch)
treebcf7fcf995b4cb97cec0b947e2b299d6bcc8ae1d /sys/cmd/dwm/layout.c
parentea50cbe1bf103372a3461c80cb172f4fb4167088 (diff)
refactored
Diffstat (limited to 'sys/cmd/dwm/layout.c')
-rw-r--r--sys/cmd/dwm/layout.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/sys/cmd/dwm/layout.c b/sys/cmd/dwm/layout.c
new file mode 100644
index 0000000..f7a2c60
--- /dev/null
+++ b/sys/cmd/dwm/layout.c
@@ -0,0 +1,37 @@
+#include "dwm.h"
+
+void
+tile(Monitor *m)
+{
+ Client *c;
+ uint i, n, h, mw, my, ty;
+
+ n = 0;
+ wl_list_for_each(c, &dwm.tiles, link.tiles)
+ if (VISIBLEON(c, m) && !c->floating)
+ n++;
+
+ if (n == 0)
+ return;
+
+ if (n > m->nmaster)
+ mw = m->nmaster ? m->area.win.width * m->mfact : 0;
+ else
+ mw = m->area.win.width;
+
+ i = my = ty = 0;
+ wl_list_for_each(c, &dwm.tiles, link.tiles) {
+ if (!VISIBLEON(c, m) || c->floating)
+ continue;
+ if (i < m->nmaster) {
+ h = (m->area.win.height - my) / (MIN(n, m->nmaster) - i);
+ resize(c, m->area.win.x, m->area.win.y + my, mw, h, 0);
+ my += c->dim.height;
+ } else {
+ h = (m->area.win.height - ty) / (n - i);
+ resize(c, m->area.win.x + mw, m->area.win.y + ty, m->area.win.width - mw, h, 0);
+ ty += c->dim.height;
+ }
+ i++;
+ }
+}