summaryrefslogtreecommitdiffstats
path: root/dwl.c
diff options
context:
space:
mode:
Diffstat (limited to 'dwl.c')
-rw-r--r--dwl.c70
1 files changed, 63 insertions, 7 deletions
diff --git a/dwl.c b/dwl.c
index 5b7b671..e810b6a 100644
--- a/dwl.c
+++ b/dwl.c
@@ -341,6 +341,7 @@ static void focusstack(const Arg *arg);
static Client *focustop(Monitor *m);
static void fullscreennotify(struct wl_listener *listener, void *data);
static void gpureset(struct wl_listener *listener, void *data);
+static void gaplessgrid(Monitor *m);
static void handlesig(int signo);
static void incnmaster(const Arg *arg);
static void incigaps(const Arg *arg);
@@ -1629,8 +1630,6 @@ void
drawbar(Monitor *m)
{
int x, w, tw = 0;
- int boxs = m->drw->font->height / 9;
- int boxw = m->drw->font->height / 6 + 2;
uint32_t i, occ = 0, urg = 0;
Client *c;
Buffer *buf;
@@ -1661,14 +1660,18 @@ drawbar(Monitor *m)
c = focustop(m);
for (i = 0; i < LENGTH(tags); i++) {
w = TEXTW(m, tags[i]);
- drwl_setscheme(m->drw, colors[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
+ if (occ & 1 << i)
+ drwl_setscheme(m->drw, tagsel[i]);
+ else
+ drwl_setscheme(m->drw, tagsel[9]);
+ // drwl_setscheme(m->drw, (m->tagset[m->seltags] & 1 << i ? tagsel[i] : colors[SchemeNorm]));
drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, tags[i], urg & 1 << i);
if (ulineall || m->tagset[m->seltags] & 1 << i) /* if there are conflicts, just move these lines directly underneath both 'drw_setscheme' and 'dr w_text' :) */
drwl_rect(m->drw, x + ulinepad, m->b.height - ulinestroke - ulinevoffset, w - (ulinepad * 2), ulinestroke, 1, 0);
- if (occ & 1 << i)
- drwl_rect(m->drw, x + boxs, boxs, boxw, boxw,
- m == selmon && c && c->tags & 1 << i,
- urg & 1 << i);
+ // if (occ & 1 << i)
+ // drwl_rect(m->drw, x + boxs, boxs, boxw, boxw,
+ // m == selmon && c && c->tags & 1 << i,
+ // urg & 1 << i);
x += w;
}
w = TEXTW(m, m->ltsymbol);
@@ -1875,6 +1878,56 @@ handlesig(int signo)
}
}
+void
+gaplessgrid(Monitor *m)
+{
+ unsigned int n = 0, i = 0, ch, cw, cn, rn, rows, cols;
+ Client *c;
+
+ wl_list_for_each(c, &clients, link)
+ if (VISIBLEON(c, m) && !c->isfloating)
+ n++;
+ if (n == 0)
+ return;
+
+ /* grid dimensions */
+ for (cols = 0; cols <= (n / 2); cols++)
+ if ((cols * cols) >= n)
+ break;
+
+ if (n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
+ cols = 2;
+
+ /* widescreen is better if 3 columns */
+ if (n >= 3 && n <= 6 && (m->w.width / m->w.height) > 1)
+ cols = 3;
+
+ rows = n / cols;
+
+ /* window geometries */
+ cw = cols ? m->w.width / cols : (unsigned int)m->w.width;
+ cn = 0; /* current column number */
+ rn = 0; /* current row number */
+ wl_list_for_each(c, &clients, link) {
+ unsigned int cx, cy;
+ if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ continue;
+
+ if ((i / rows + 1) > (cols - n % cols))
+ rows = n / cols + 1;
+ ch = rows ? m->w.height / rows : (unsigned int)m->w.height;
+ cx = m->w.x + cn * cw;
+ cy = m->w.y + rn * ch;
+ resize(c, (struct wlr_box) { cx, cy, cw, ch}, 0);
+ rn++;
+ if (rn >= rows) {
+ rn = 0;
+ cn++;
+ }
+ i++;
+ }
+}
+
pid_t
getparentprocess(pid_t p)
{
@@ -2897,6 +2950,9 @@ setup(void)
drag_icon = wlr_scene_tree_create(&scene->tree);
wlr_scene_node_place_below(&drag_icon->node, &layers[LyrBlock]->node);
+ if (LENGTH(tags) > LENGTH(tagsel))
+ die("too few color schemes for the tags");
+
/* Autocreates a renderer, either Pixman, GLES2 or Vulkan for us. The user
* can also specify a renderer using the WLR_RENDERER env var.
* The renderer is responsible for defining the various pixel formats it