Adding taggrid patch

This commit is contained in:
bakkeby 2019-10-05 23:28:50 +02:00
parent b6928ab1fb
commit 15a4c58924
8 changed files with 201 additions and 2 deletions

View File

@ -13,7 +13,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog: ### Changelog:
2019-10-05 - Added killunsel patch 2019-10-05 - Added killunsel and taggrid patches
2019-10-04 - Added maximize, movestack, monoclesymbol, noborder, tagall and tagintostack patches 2019-10-04 - Added maximize, movestack, monoclesymbol, noborder, tagall and tagintostack patches
@ -209,6 +209,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- makes new clients attach into the stack area when you toggle a new tag into view - makes new clients attach into the stack area when you toggle a new tag into view
- this means your master area will remain unchanged when toggling views - this means your master area will remain unchanged when toggling views
- [taggrid](https://dwm.suckless.org/patches/taggrid/)
- adds an option to place tags in rows like in many other window managers
- [tagmonfixfs](https://github.com/bakkeby/dwm-vanitygaps/blob/master/patches/dwm-tagmonfixfs-6.2.diff) - [tagmonfixfs](https://github.com/bakkeby/dwm-vanitygaps/blob/master/patches/dwm-tagmonfixfs-6.2.diff)
- allows moving a fullscreen window to another monitor while remaining in fullscreen - allows moving a fullscreen window to another monitor while remaining in fullscreen

View File

@ -144,6 +144,24 @@ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
static const char *tagsalt[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; static const char *tagsalt[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
#endif // ALTERNATIVE_TAGS_PATCH #endif // ALTERNATIVE_TAGS_PATCH
#if TAGGRID_PATCH
/* grid of tags */
#define DRAWCLASSICTAGS 1 << 0
#define DRAWTAGGRID 1 << 1
#define SWITCHTAG_UP 1 << 0
#define SWITCHTAG_DOWN 1 << 1
#define SWITCHTAG_LEFT 1 << 2
#define SWITCHTAG_RIGHT 1 << 3
#define SWITCHTAG_TOGGLETAG 1 << 4
#define SWITCHTAG_TAG 1 << 5
#define SWITCHTAG_VIEW 1 << 6
#define SWITCHTAG_TOGGLEVIEW 1 << 7
static const unsigned int drawtagmask = DRAWTAGGRID; /* | DRAWCLASSICTAGS to show classic row of tags */
static const int tagrows = 2;
#endif // TAGGRID_PATCH
static const Rule rules[] = { static const Rule rules[] = {
/* xprop(1): /* xprop(1):
* WM_CLASS(STRING) = instance, class * WM_CLASS(STRING) = instance, class
@ -460,6 +478,16 @@ static Key keys[] = {
#if ALTERNATIVE_TAGS_PATCH #if ALTERNATIVE_TAGS_PATCH
{ MODKEY, XK_n, togglealttag, {0} }, { MODKEY, XK_n, togglealttag, {0} },
#endif // ALTERNATIVE_TAGS_PATCH #endif // ALTERNATIVE_TAGS_PATCH
#if TAGGRID_PATCH
{ MODKEY|ControlMask, XK_Up, switchtag, { .ui = SWITCHTAG_UP | SWITCHTAG_VIEW } },
{ MODKEY|ControlMask, XK_Down, switchtag, { .ui = SWITCHTAG_DOWN | SWITCHTAG_VIEW } },
{ MODKEY|ControlMask, XK_Right, switchtag, { .ui = SWITCHTAG_RIGHT | SWITCHTAG_VIEW } },
{ MODKEY|ControlMask, XK_Left, switchtag, { .ui = SWITCHTAG_LEFT | SWITCHTAG_VIEW } },
{ MODKEY|Mod4Mask, XK_Up, switchtag, { .ui = SWITCHTAG_UP | SWITCHTAG_TAG | SWITCHTAG_VIEW } },
{ MODKEY|Mod4Mask, XK_Down, switchtag, { .ui = SWITCHTAG_DOWN | SWITCHTAG_TAG | SWITCHTAG_VIEW } },
{ MODKEY|Mod4Mask, XK_Right, switchtag, { .ui = SWITCHTAG_RIGHT | SWITCHTAG_TAG | SWITCHTAG_VIEW } },
{ MODKEY|Mod4Mask, XK_Left, switchtag, { .ui = SWITCHTAG_LEFT | SWITCHTAG_TAG | SWITCHTAG_VIEW } },
#endif // TAGGRID_PATCH
#if SETBORDERPX_PATCH #if SETBORDERPX_PATCH
{ MODKEY|ShiftMask, XK_minus, setborderpx, {.i = -1 } }, { MODKEY|ShiftMask, XK_minus, setborderpx, {.i = -1 } },
{ MODKEY|ShiftMask, XK_plus, setborderpx, {.i = +1 } }, { MODKEY|ShiftMask, XK_plus, setborderpx, {.i = +1 } },

37
dwm.c
View File

@ -601,11 +601,17 @@ void
buttonpress(XEvent *e) buttonpress(XEvent *e)
{ {
unsigned int i, x, click; unsigned int i, x, click;
#if TAGGRID_PATCH
unsigned int columns;
#endif // TAGGRID_PATCH
Arg arg = {0}; Arg arg = {0};
Client *c; Client *c;
Monitor *m; Monitor *m;
XButtonPressedEvent *ev = &e->xbutton; XButtonPressedEvent *ev = &e->xbutton;
#if TAGGRID_PATCH
columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0);
#endif // TAGGRID_PATCH
click = ClkRootWin; click = ClkRootWin;
/* focus monitor if necessary */ /* focus monitor if necessary */
if ((m = wintomon(ev->window)) && m != selmon if ((m = wintomon(ev->window)) && m != selmon
@ -664,14 +670,35 @@ buttonpress(XEvent *e)
#endif // AWESOMEBAR_PATCH #endif // AWESOMEBAR_PATCH
} }
#else // LEFTLAYOUT_PATCH #else // LEFTLAYOUT_PATCH
#if TAGGRID_PATCH
if (drawtagmask & DRAWCLASSICTAGS)
#endif // TAGGRID_PATCH
do do
x += TEXTW(tags[i]); x += TEXTW(tags[i]);
while (ev->x >= x && ++i < LENGTH(tags)); while (ev->x >= x && ++i < LENGTH(tags));
if (i < LENGTH(tags)) { if (i < LENGTH(tags)
#if TAGGRID_PATCH
&& (drawtagmask & DRAWCLASSICTAGS)
#endif
) {
click = ClkTagBar; click = ClkTagBar;
arg.ui = 1 << i; arg.ui = 1 << i;
#if TAGGRID_PATCH
} else if (ev->x < x + columns * bh / tagrows && (drawtagmask & DRAWTAGGRID)) {
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
} else if (ev->x < x + blw) } else if (ev->x < x + blw)
click = ClkLtSymbol; click = ClkLtSymbol;
#endif // TAGGRID_PATCH
#if AWESOMEBAR_PATCH && SYSTRAY_PATCH #if AWESOMEBAR_PATCH && SYSTRAY_PATCH
else if (ev->x > selmon->ww - TEXTW(stext) + lrpad - 2 - getsystraywidth()) else if (ev->x > selmon->ww - TEXTW(stext) + lrpad - 2 - getsystraywidth())
#elif AWESOMEBAR_PATCH #elif AWESOMEBAR_PATCH
@ -1209,6 +1236,9 @@ drawbar(Monitor *m)
drw_setscheme(drw, scheme[SchemeNorm]); drw_setscheme(drw, scheme[SchemeNorm]);
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
#endif // LEFTLAYOUT_PATCH #endif // LEFTLAYOUT_PATCH
#if TAGGRID_PATCH
if (drawtagmask & DRAWCLASSICTAGS)
#endif // TAGGRID_PATCH
for (i = 0; i < LENGTH(tags); i++) { for (i = 0; i < LENGTH(tags); i++) {
w = TEXTW(tags[i]); w = TEXTW(tags[i]);
#if ALTERNATIVE_TAGS_PATCH #if ALTERNATIVE_TAGS_PATCH
@ -1232,6 +1262,11 @@ drawbar(Monitor *m)
#endif // ACTIVETAGINDICATORBAR_PATCH #endif // ACTIVETAGINDICATORBAR_PATCH
x += w; x += w;
} }
#if TAGGRID_PATCH
if (drawtagmask & DRAWTAGGRID) {
drawtaggrid(m,&x,occ);
}
#endif // TAGGRID_PATCH
#if !LEFTLAYOUT_PATCH #if !LEFTLAYOUT_PATCH
w = blw = TEXTW(m->ltsymbol); w = blw = TEXTW(m->ltsymbol);
drw_setscheme(drw, scheme[SchemeNorm]); drw_setscheme(drw, scheme[SchemeNorm]);

View File

@ -110,6 +110,10 @@
#include "tagallmon.c" #include "tagallmon.c"
#endif #endif
#if TAGGRID_PATCH
#include "taggrid.c"
#endif
#if TAGSWAPMON_PATCH #if TAGSWAPMON_PATCH
#include "tagswapmon.c" #include "tagswapmon.c"
#endif #endif

View File

@ -110,6 +110,10 @@
#include "tagallmon.h" #include "tagallmon.h"
#endif #endif
#if TAGGRID_PATCH
#include "taggrid.h"
#endif
#if TAGSWAPMON_PATCH #if TAGSWAPMON_PATCH
#include "tagswapmon.h" #include "tagswapmon.h"
#endif #endif

118
patch/taggrid.c Normal file
View File

@ -0,0 +1,118 @@
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 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);
}
}

2
patch/taggrid.h Normal file
View File

@ -0,0 +1,2 @@
static void drawtaggrid(Monitor *m, int *x_pos, unsigned int occ);
static void switchtag(const Arg *arg);

View File

@ -331,6 +331,11 @@
*/ */
#define TAGALLMON_PATCH 0 #define TAGALLMON_PATCH 0
/* This patch adds an option to place tags in rows like in many other window managers.
* https://dwm.suckless.org/patches/taggrid/
*/
#define TAGGRID_PATCH 0
/* This patch makes new clients attach into the stack area when you toggle a new tag into /* This patch makes new clients attach into the stack area when you toggle a new tag into
* view. This means your master area will remain unchanged when toggling views. * view. This means your master area will remain unchanged when toggling views.
* The allmaster patch will cause all clients in the master area to be left alone. This patch * The allmaster patch will cause all clients in the master area to be left alone. This patch