mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
Adding taggrid patch
This commit is contained in:
parent
b6928ab1fb
commit
15a4c58924
@ -13,7 +13,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
|
||||
|
||||
### 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
|
||||
|
||||
@ -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
|
||||
- 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)
|
||||
- allows moving a fullscreen window to another monitor while remaining in fullscreen
|
||||
|
||||
|
28
config.def.h
28
config.def.h
@ -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" };
|
||||
#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[] = {
|
||||
/* xprop(1):
|
||||
* WM_CLASS(STRING) = instance, class
|
||||
@ -460,6 +478,16 @@ static Key keys[] = {
|
||||
#if ALTERNATIVE_TAGS_PATCH
|
||||
{ MODKEY, XK_n, togglealttag, {0} },
|
||||
#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
|
||||
{ MODKEY|ShiftMask, XK_minus, setborderpx, {.i = -1 } },
|
||||
{ MODKEY|ShiftMask, XK_plus, setborderpx, {.i = +1 } },
|
||||
|
37
dwm.c
37
dwm.c
@ -601,11 +601,17 @@ void
|
||||
buttonpress(XEvent *e)
|
||||
{
|
||||
unsigned int i, x, click;
|
||||
#if TAGGRID_PATCH
|
||||
unsigned int columns;
|
||||
#endif // TAGGRID_PATCH
|
||||
Arg arg = {0};
|
||||
Client *c;
|
||||
Monitor *m;
|
||||
XButtonPressedEvent *ev = &e->xbutton;
|
||||
|
||||
#if TAGGRID_PATCH
|
||||
columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0);
|
||||
#endif // TAGGRID_PATCH
|
||||
click = ClkRootWin;
|
||||
/* focus monitor if necessary */
|
||||
if ((m = wintomon(ev->window)) && m != selmon
|
||||
@ -664,14 +670,35 @@ buttonpress(XEvent *e)
|
||||
#endif // AWESOMEBAR_PATCH
|
||||
}
|
||||
#else // LEFTLAYOUT_PATCH
|
||||
#if TAGGRID_PATCH
|
||||
if (drawtagmask & DRAWCLASSICTAGS)
|
||||
#endif // TAGGRID_PATCH
|
||||
do
|
||||
x += TEXTW(tags[i]);
|
||||
while (ev->x >= x && ++i < LENGTH(tags));
|
||||
if (i < LENGTH(tags)) {
|
||||
if (i < LENGTH(tags)
|
||||
#if TAGGRID_PATCH
|
||||
&& (drawtagmask & DRAWCLASSICTAGS)
|
||||
#endif
|
||||
) {
|
||||
click = ClkTagBar;
|
||||
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)
|
||||
click = ClkLtSymbol;
|
||||
#endif // TAGGRID_PATCH
|
||||
#if AWESOMEBAR_PATCH && SYSTRAY_PATCH
|
||||
else if (ev->x > selmon->ww - TEXTW(stext) + lrpad - 2 - getsystraywidth())
|
||||
#elif AWESOMEBAR_PATCH
|
||||
@ -1209,6 +1236,9 @@ drawbar(Monitor *m)
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
|
||||
#endif // LEFTLAYOUT_PATCH
|
||||
#if TAGGRID_PATCH
|
||||
if (drawtagmask & DRAWCLASSICTAGS)
|
||||
#endif // TAGGRID_PATCH
|
||||
for (i = 0; i < LENGTH(tags); i++) {
|
||||
w = TEXTW(tags[i]);
|
||||
#if ALTERNATIVE_TAGS_PATCH
|
||||
@ -1232,6 +1262,11 @@ drawbar(Monitor *m)
|
||||
#endif // ACTIVETAGINDICATORBAR_PATCH
|
||||
x += w;
|
||||
}
|
||||
#if TAGGRID_PATCH
|
||||
if (drawtagmask & DRAWTAGGRID) {
|
||||
drawtaggrid(m,&x,occ);
|
||||
}
|
||||
#endif // TAGGRID_PATCH
|
||||
#if !LEFTLAYOUT_PATCH
|
||||
w = blw = TEXTW(m->ltsymbol);
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
|
@ -110,6 +110,10 @@
|
||||
#include "tagallmon.c"
|
||||
#endif
|
||||
|
||||
#if TAGGRID_PATCH
|
||||
#include "taggrid.c"
|
||||
#endif
|
||||
|
||||
#if TAGSWAPMON_PATCH
|
||||
#include "tagswapmon.c"
|
||||
#endif
|
||||
|
@ -110,6 +110,10 @@
|
||||
#include "tagallmon.h"
|
||||
#endif
|
||||
|
||||
#if TAGGRID_PATCH
|
||||
#include "taggrid.h"
|
||||
#endif
|
||||
|
||||
#if TAGSWAPMON_PATCH
|
||||
#include "tagswapmon.h"
|
||||
#endif
|
||||
|
118
patch/taggrid.c
Normal file
118
patch/taggrid.c
Normal 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
2
patch/taggrid.h
Normal file
@ -0,0 +1,2 @@
|
||||
static void drawtaggrid(Monitor *m, int *x_pos, unsigned int occ);
|
||||
static void switchtag(const Arg *arg);
|
@ -331,6 +331,11 @@
|
||||
*/
|
||||
#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
|
||||
* 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
|
||||
|
Loading…
Reference in New Issue
Block a user