aboutsummaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorJoe <bousset.rudy@gmail.com>2022-08-12 15:21:36 +0200
committerJoe <bousset.rudy@gmail.com>2022-08-12 15:21:36 +0200
commitfcff044c2ca026b03fa969833a7eb16b3a41df02 (patch)
tree2ad26ca771e300c84c3ad6b37cd610e04ccf7ad6 /dwm.c
parentupdate (diff)
downloaddwm-fcff044c2ca026b03fa969833a7eb16b3a41df02.tar.gz
dwm-fcff044c2ca026b03fa969833a7eb16b3a41df02.tar.bz2
dwm-fcff044c2ca026b03fa969833a7eb16b3a41df02.tar.xz
dwm-fcff044c2ca026b03fa969833a7eb16b3a41df02.tar.zst
dwm-fcff044c2ca026b03fa969833a7eb16b3a41df02.zip
update
Diffstat (limited to '')
-rw-r--r--dwm.c148
1 files changed, 138 insertions, 10 deletions
diff --git a/dwm.c b/dwm.c
index b20c672..e5068e6 100644
--- a/dwm.c
+++ b/dwm.c
@@ -172,6 +172,7 @@ static void detachstack(Client *c);
static Monitor *dirtomon(int dir);
static void drawbar(Monitor *m);
static void drawbars(void);
+static void drawtaggrid(Monitor *m, int *x_pos, unsigned int occ);
static void expose(XEvent *e);
static void focus(Client *c);
static void focusin(XEvent *e);
@@ -216,6 +217,7 @@ static void seturgent(Client *c, int urg);
static void showhide(Client *c);
static void sigchld(int unused);
static void spawn(const Arg *arg);
+static void switchtag(const Arg *arg);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tagnextmon(const Arg *arg);
@@ -560,11 +562,13 @@ void
buttonpress(XEvent *e)
{
unsigned int i, x, click;
+ unsigned int columns;
Arg arg = {0};
Client *c;
Monitor *m;
XButtonPressedEvent *ev = &e->xbutton;
+ columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0);
click = ClkRootWin;
/* focus monitor if necessary */
if ((m = wintomon(ev->window)) && m != selmon
@@ -575,13 +579,23 @@ buttonpress(XEvent *e)
}
if (ev->window == selmon->barwin) {
i = x = 0;
+ if (drawtagmask & DRAWCLASSICTAGS)
do
x += TEXTW(tags[i]);
while (ev->x >= x && ++i < LENGTH(tags));
- if (i < LENGTH(tags)) {
+ if(i < LENGTH(tags) && (drawtagmask & DRAWCLASSICTAGS)) {
click = ClkTagBar;
arg.ui = 1 << i;
- } else if (ev->x < x + blw)
+ } else if((ev->x < x + columns * bh / tagrows) && (drawtagmask & DRAWTAGGRID) != 0) {
+ click = ClkTagBar;
+ i = (ev->x - x) / (bh / tagrows);
+ i = i + columns * (ev->y / (bh / tagrows));
+ if (i >= LENGTH(tags)) {
+ i = LENGTH(tags) - 1;
+ }
+ arg.ui = 1 << i;
+ }
+ else if(ev->x < x + blw + columns * bh / tagrows)
click = ClkLtSymbol;
else if (ev->x > selmon->ww - (int)TEXTW(stext))
click = ClkStatusText;
@@ -877,6 +891,7 @@ drawbar(Monitor *m)
urg |= c->tags;
}
x = 0;
+ if (drawtagmask & DRAWCLASSICTAGS)
for (i = 0; i < LENGTH(tags); i++) {
w = TEXTW(tags[i]);
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
@@ -887,6 +902,9 @@ drawbar(Monitor *m)
urg & 1 << i);
x += w;
}
+ if (drawtagmask & DRAWTAGGRID) {
+ drawtaggrid(m,&x,occ);
+ }
w = blw = TEXTW(m->ltsymbol);
drw_setscheme(drw, scheme[SchemeNorm]);
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
@@ -911,6 +929,48 @@ drawbars(void)
for (m = mons; m; m = m->next)
drawbar(m);
}
+void drawtaggrid(Monitor *m, int *x_pos, unsigned int occ)
+{
+ unsigned int x, y, h, max_x, columns;
+ int invert, i,j, k;
+
+ h = bh / tagrows;
+ x = max_x = *x_pos;
+ y = 0;
+ columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0);
+
+ /* Firstly we will fill the borders of squares */
+
+ XSetForeground(drw->dpy, drw->gc, scheme[SchemeNorm][ColBorder].pixel);
+ XFillRectangle(dpy, drw->drawable, drw->gc, x, y, h*columns + 1, bh);
+
+ /* We will draw LENGTH(tags) squares in tagraws raws. */
+ for(j = 0, i= 0; j < tagrows; j++) {
+ x = *x_pos;
+ for (k = 0; k < columns && i < LENGTH(tags); k++, i++) {
+ invert = m->tagset[m->seltags] & 1 << i ? 0 : 1;
+
+ /* Select active color for current square */
+ XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeSel][ColBg].pixel :
+ scheme[SchemeNorm][ColFg].pixel);
+ XFillRectangle(dpy, drw->drawable, drw->gc, x+1, y+1, h-1, h-1);
+
+ /* Mark square if tag has client */
+ if (occ & 1 << i) {
+ XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeSel][ColFg].pixel :
+ scheme[SchemeNorm][ColBg].pixel);
+ XFillRectangle(dpy, drw->drawable, drw->gc, x + 1, y + 1,
+ h / 2, h / 2);
+ }
+ x += h;
+ if (x > max_x) {
+ max_x = x;
+ }
+ }
+ y += h;
+ }
+ *x_pos = max_x + 1;
+}
void
expose(XEvent *e)
@@ -1424,13 +1484,6 @@ resizeclient(Client *c, int x, int y, int w, int h)
c->oldw = c->w; c->w = wc.width = w;
c->oldh = c->h; c->h = wc.height = h;
wc.border_width = c->bw;
- if (((nexttiled(c->mon->clients) == c && !nexttiled(c->next))
- || &monocle == c->mon->lt[c->mon->sellt]->arrange)
- && !c->isfullscreen && !c->isfloating) {
- c->w = wc.width += c->bw * 2;
- c->h = wc.height += c->bw * 2;
- wc.border_width = 0;
- }
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
configure(c);
XSync(dpy, False);
@@ -1704,7 +1757,7 @@ setup(void)
if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
die("no fonts could be loaded.");
lrpad = drw->fonts->h;
- bh = drw->fonts->h + 2;
+ bh = user_bh ? user_bh : drw->fonts->h + 2;
updategeom();
/* init atoms */
utf8string = XInternAtom(dpy, "UTF8_STRING", False);
@@ -1786,6 +1839,81 @@ showhide(Client *c)
XMoveWindow(dpy, c->win, WIDTH(c) * -2, c->y);
}
}
+void switchtag(const Arg *arg)
+{
+ unsigned int columns;
+ unsigned int new_tagset = 0;
+ unsigned int pos, i;
+ int col, row;
+ Arg new_arg;
+
+ columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0);
+
+ for (i = 0; i < LENGTH(tags); ++i) {
+ if (!(selmon->tagset[selmon->seltags] & 1 << i)) {
+ continue;
+ }
+ pos = i;
+ row = pos / columns;
+ col = pos % columns;
+ if (arg->ui & SWITCHTAG_UP) { /* UP */
+ row --;
+ if (row < 0) {
+ row = tagrows - 1;
+ }
+ do {
+ pos = row * columns + col;
+ row --;
+ } while (pos >= LENGTH(tags));
+ }
+ if (arg->ui & SWITCHTAG_DOWN) { /* DOWN */
+ row ++;
+ if (row >= tagrows) {
+ row = 0;
+ }
+ pos = row * columns + col;
+ if (pos >= LENGTH(tags)) {
+ row = 0;
+ }
+ pos = row * columns + col;
+ }
+ if (arg->ui & SWITCHTAG_LEFT) { /* LEFT */
+ col --;
+ if (col < 0) {
+ col = columns - 1;
+ }
+ do {
+ pos = row * columns + col;
+ col --;
+ } while (pos >= LENGTH(tags));
+ }
+ if (arg->ui & SWITCHTAG_RIGHT) { /* RIGHT */
+ col ++;
+ if (col >= columns) {
+ col = 0;
+ }
+ pos = row * columns + col;
+ if (pos >= LENGTH(tags)) {
+ col = 0;
+ pos = row * columns + col;
+ }
+ }
+ new_tagset |= 1 << pos;
+ }
+ new_arg.ui = new_tagset;
+ if (arg->ui & SWITCHTAG_TOGGLETAG) {
+ toggletag(&new_arg);
+ }
+ if (arg->ui & SWITCHTAG_TAG) {
+ tag(&new_arg);
+ }
+ if (arg->ui & SWITCHTAG_VIEW) {
+ view (&new_arg);
+ }
+ if (arg->ui & SWITCHTAG_TOGGLEVIEW) {
+ toggleview (&new_arg);
+ }
+}
void
sigchld(int unused)