Remove the scratchpads patch ref. #261

vertigo
bakkeby 2 years ago
parent baef26402f
commit 745143f930

@ -386,13 +386,7 @@ static const char *const autostart[] = {
#if RENAMED_SCRATCHPADS_PATCH
static const char *scratchpadcmd[] = {"s", "st", "-n", "spterm", NULL};
#elif SCRATCHPADS_PATCH
const char *spcmd1[] = {"st", "-n", "spterm", "-g", "120x34", NULL };
static Sp scratchpads[] = {
/* name cmd */
{"spterm", spcmd1},
};
#endif // SCRATCHPADS_PATCH
#endif // RENAMED_SCRATCHPADS_PATCH
/* Tags
* In a traditional dwm the number of tags in use can be changed simply by changing the number
@ -479,9 +473,7 @@ static const Rule rules[] = {
RULE(.class = "Firefox", .tags = 1 << 7)
#if RENAMED_SCRATCHPADS_PATCH
RULE(.instance = "spterm", .scratchkey = 's', .isfloating = 1)
#elif SCRATCHPADS_PATCH
RULE(.instance = "spterm", .tags = SPTAG(0), .isfloating = 1)
#endif // SCRATCHPADS_PATCH
#endif // RENAMED_SCRATCHPADS_PATCH
};
#if MONITOR_RULES_PATCH
@ -1078,11 +1070,7 @@ static const Key keys[] = {
{ MODKEY, XK_grave, togglescratch, {.v = scratchpadcmd } },
{ MODKEY|ControlMask, XK_grave, setscratch, {.v = scratchpadcmd } },
{ MODKEY|ShiftMask, XK_grave, removescratch, {.v = scratchpadcmd } },
#elif SCRATCHPADS_PATCH
{ MODKEY, XK_grave, togglescratch, {.ui = 0 } },
{ MODKEY|ControlMask, XK_grave, setscratch, {.ui = 0 } },
{ MODKEY|ShiftMask, XK_grave, removescratch, {.ui = 0 } },
#endif // SCRATCHPADS_PATCH | RENAMED_SCRATCHPADS_PATCH
#endif // RENAMED_SCRATCHPADS_PATCH
#if UNFLOATVISIBLE_PATCH
{ MODKEY|Mod4Mask, XK_space, unfloatvisible, {0} },
{ MODKEY|ShiftMask, XK_t, unfloatvisible, {.v = &layouts[0]} },
@ -1103,9 +1091,6 @@ static const Key keys[] = {
{ MODKEY, XK_minus, scratchpad_show, {0} },
{ MODKEY|ShiftMask, XK_minus, scratchpad_hide, {0} },
{ MODKEY, XK_equal, scratchpad_remove, {0} },
#elif SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
{ MODKEY, XK_0, view, {.ui = ~SPTAGMASK } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~SPTAGMASK } },
#else
{ MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
@ -1531,9 +1516,6 @@ static const Signal signals[] = {
{ "toggleverticalmax", toggleverticalmax },
{ "togglemax", togglemax },
#endif // MAXIMIZE_PATCH
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
{ "togglescratch", togglescratch },
#endif // SCRATCHPADS_PATCH
#if UNFLOATVISIBLE_PATCH
{ "unfloatvisible", unfloatvisible },
#endif // UNFLOATVISIBLE_PATCH
@ -1659,9 +1641,6 @@ static IPCCommand ipccommands[] = {
#if ROTATESTACK_PATCH
IPCCOMMAND( rotatestack, 1, {ARG_TYPE_SINT} ),
#endif // ROTATESTACK_PATCH
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
IPCCOMMAND( togglescratch, 1, {ARG_TYPE_UINT} ),
#endif // SCRATCHPADS_PATCH
#if SELFRESTART_PATCH
IPCCOMMAND( self_restart, 1, {ARG_TYPE_NONE} ),
#endif // SELFRESTART_PATCH

63
dwm.c

@ -106,14 +106,7 @@
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
#define WTYPE "_NET_WM_WINDOW_TYPE_"
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
#define TOTALTAGS (NUMTAGS + LENGTH(scratchpads))
#define TAGMASK ((1 << TOTALTAGS) - 1)
#define SPTAG(i) ((1 << NUMTAGS) << (i))
#define SPTAGMASK (((1 << LENGTH(scratchpads))-1) << NUMTAGS)
#else
#define TAGMASK ((1 << NUMTAGS) - 1)
#endif // SCRATCHPADS_PATCH
#define TEXTWM(X) (drw_fontset_getwidth(drw, (X), True) + lrpad)
#define TEXTW(X) (drw_fontset_getwidth(drw, (X), False) + lrpad)
#define HIDDEN(C) ((getstate(C->win) == IconicState))
@ -926,12 +919,7 @@ applyrules(Client *c)
c->tags |= r->tags;
#if RENAMED_SCRATCHPADS_PATCH
c->scratchkey = r->scratchkey;
#elif SCRATCHPADS_PATCH
if ((r->tags & SPTAGMASK) && r->isfloating) {
c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
}
#endif // SCRATCHPADS_PATCH
#endif // RENAMED_SCRATCHPADS_PATCH
for (m = mons; m && m->num != r->monitor; m = m->next);
if (m)
c->mon = m;
@ -999,16 +987,12 @@ applyrules(Client *c)
XFree(ch.res_name);
#if EMPTYVIEW_PATCH
if (c->tags & TAGMASK) c->tags = c->tags & TAGMASK;
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
else if (c->mon->tagset[c->mon->seltags]) c->tags = c->mon->tagset[c->mon->seltags] & ~SPTAGMASK;
#elif SCRATCHPAD_ALT_1_PATCH
#if SCRATCHPAD_ALT_1_PATCH
else if (c->tags != SCRATCHPAD_MASK && c->mon->tagset[c->mon->seltags]) c->tags = c->mon->tagset[c->mon->seltags];
#else
else if (c->mon->tagset[c->mon->seltags]) c->tags = c->mon->tagset[c->mon->seltags];
#endif // SCRATCHPADS_PATCH
#endif // SCRATCHPAD_ALT_1_PATCH
else c->tags = 1;
#elif SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : (c->mon->tagset[c->mon->seltags] & ~SPTAGMASK);
#elif SCRATCHPAD_ALT_1_PATCH
if (c->tags != SCRATCHPAD_MASK)
c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
@ -2778,12 +2762,6 @@ movemouse(const Arg *arg)
XUngrabPointer(dpy, CurrentTime);
if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
if (c->tags & SPTAGMASK) {
c->mon->tagset[c->mon->seltags] ^= (c->tags & SPTAGMASK);
m->tagset[m->seltags] |= (c->tags & SPTAGMASK);
}
#endif // SCRATCHPADS_PATCH
sendmon(c, m);
selmon = m;
focus(NULL);
@ -3104,12 +3082,6 @@ resizemouse(const Arg *arg)
XUngrabPointer(dpy, CurrentTime);
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
if (c->tags & SPTAGMASK) {
c->mon->tagset[c->mon->seltags] ^= (c->tags & SPTAGMASK);
m->tagset[m->seltags] |= (c->tags & SPTAGMASK);
}
#endif // SCRATCHPADS_PATCH
sendmon(c, m);
selmon = m;
focus(NULL);
@ -3327,9 +3299,6 @@ sendmon(Client *c, Monitor *m)
arrange(c->mon);
#endif // SENDMON_KEEPFOCUS_PATCH
c->mon = m;
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
if (!(c->tags & SPTAGMASK))
#endif // SCRATCHPADS_PATCH
#if EMPTYVIEW_PATCH
c->tags = (m->tagset[m->seltags] ? m->tagset[m->seltags] : 1);
#else
@ -3885,28 +3854,6 @@ showhide(Client *c)
if (!c)
return;
if (ISVISIBLE(c)) {
#if !RENAMED_SCRATCHPADS_PATCH
#if SCRATCHPADS_PATCH && SCRATCHPADS_KEEP_POSITION_AND_SIZE_PATCH
if (
(c->tags & SPTAGMASK) &&
c->isfloating &&
(
c->x < c->mon->mx ||
c->x > c->mon->mx + c->mon->mw ||
c->y < c->mon->my ||
c->y > c->mon->my + c->mon->mh
)
) {
c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
}
#elif SCRATCHPADS_PATCH
if ((c->tags & SPTAGMASK) && c->isfloating) {
c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
}
#endif // SCRATCHPADS_KEEP_POSITION_AND_SIZE_PATCH | SCRATCHPADS_PATCH
#endif // RENAMED_SCRATCHPADS_PATCH
/* show clients top down */
#if SAVEFLOATS_PATCH || EXRESIZE_PATCH
if (!c->mon->lt[c->mon->sellt]->arrange && c->sfx != -9999 && !c->isfullscreen) {
@ -4285,11 +4232,7 @@ toggleview(const Arg *arg)
selmon->tagset[selmon->seltags] = newtagset;
#if PERTAG_PATCH
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
if (newtagset == ~SPTAGMASK)
#else
if (newtagset == ~0)
#endif // SCRATCHPADS_PATCH
{
selmon->pertag->curtag = 0;
}

@ -13,11 +13,7 @@ viewex(const Arg *arg)
void
viewallex(const Arg *arg)
{
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
view(&((Arg){.ui = ~SPTAGMASK}));
#else
view(&((Arg){.ui = ~0}));
#endif // SCRATCHPADS_PATCH
}
void
@ -41,11 +37,7 @@ toggletagex(const Arg *arg)
void
tagallex(const Arg *arg)
{
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
tag(&((Arg){.ui = ~SPTAGMASK}));
#else
tag(&((Arg){.ui = ~0}));
#endif // SCRATCHPADS_PATCH
}
int

@ -227,8 +227,6 @@
#endif
#if RENAMED_SCRATCHPADS_PATCH
#include "renamed_scratchpads.c"
#elif SCRATCHPADS_PATCH
#include "scratchpad.c"
#endif
#if SCRATCHPAD_ALT_1_PATCH
#include "scratchpad_alt_1.c"

@ -226,8 +226,6 @@
#endif
#if RENAMED_SCRATCHPADS_PATCH
#include "renamed_scratchpads.h"
#elif SCRATCHPADS_PATCH
#include "scratchpad.h"
#endif
#if SCRATCHPAD_ALT_1_PATCH
#include "scratchpad_alt_1.h"

@ -29,12 +29,7 @@ void
pertagview(const Arg *arg)
{
int i;
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
if (arg->ui == ~SPTAGMASK)
#else
if (arg->ui == ~0)
#endif // SCRATCHPADS_PATCH
selmon->pertag->curtag = 0;
else {
for (i = 0; !(selmon->tagset[selmon->seltags] & 1 << i); i++);

@ -1,77 +0,0 @@
void
removescratch(const Arg *arg)
{
Client *c = selmon->sel;
if (!c)
return;
unsigned int scratchtag = SPTAG(arg->ui);
c->tags = c->mon->tagset[c->mon->seltags] ^ scratchtag;
arrange(c->mon);
}
void
setscratch(const Arg *arg)
{
Client *c = selmon->sel;
if (!c)
return;
unsigned int scratchtag = SPTAG(arg->ui);
c->tags = scratchtag;
arrange(c->mon);
}
void
togglescratch(const Arg *arg)
{
Client *c = NULL, *next = NULL, *found = NULL;
Monitor *mon;
unsigned int scratchtag = SPTAG(arg->ui);
unsigned int newtagset = 0;
int nh = 0, nw = 0;
Arg sparg = {.v = scratchpads[arg->ui].cmd};
for (mon = mons; mon; mon = mon->next) {
for (c = mon->clients; c; c = next) {
next = c->next;
if (!(c->tags & scratchtag))
continue;
found = c;
if (HIDDEN(c)) {
XMapWindow(dpy, c->win);
setclientstate(c, NormalState);
newtagset = 0;
} else
newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
if (c->mon != selmon) {
if (c->mon->tagset[c->mon->seltags] & SPTAGMASK)
c->mon->tagset[c->mon->seltags] ^= scratchtag;
if (c->w > selmon->ww)
nw = selmon->ww - c->bw * 2;
if (c->h > selmon->wh)
nh = selmon->wh - c->bw * 2;
if (nw > 0 || nh > 0)
resizeclient(c, c->x, c->y, nw ? nw : c->w, nh ? nh : c->h);
sendmon(c, selmon);
}
}
}
if (found) {
if (newtagset) {
selmon->tagset[selmon->seltags] = newtagset;
focus(NULL);
arrange(selmon);
}
if (ISVISIBLE(found)) {
focus(found);
restack(selmon);
}
} else {
selmon->tagset[selmon->seltags] |= scratchtag;
spawn(&sparg);
}
}

@ -1,9 +0,0 @@
typedef struct {
const char *name;
const void *cmd;
} Sp;
static void removescratch(const Arg *arg);
static void setscratch(const Arg *arg);
static void togglescratch(const Arg *arg);

@ -39,10 +39,6 @@ setborderpx(const Arg *arg)
if (HIDDEN(c))
continue;
#endif // BAR_WINTITLEACTIONS_PATCH
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
if ((c->tags & SPTAGMASK) && !ISVISIBLE(c))
continue;
#endif // SCRATCHPADS_PATCH
#if SCRATCHPAD_ALT_1_PATCH
if ((c->tags & SCRATCHPAD_MASK))
continue;

@ -5,11 +5,7 @@ shift(const Arg *arg, int clients)
Client *c;
unsigned int tagmask = 0;
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
shifted.ui = selmon->tagset[selmon->seltags];
#else
shifted.ui = selmon->tagset[selmon->seltags];
#endif // SCRATCHPADS_PATCH
#if TAGSYNC_PATCH
Monitor *origselmon = selmon;
@ -18,15 +14,12 @@ shift(const Arg *arg, int clients)
for (c = selmon->clients; c && clients; c = c->next) {
if (c == selmon->sel)
continue;
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
if (!(c->tags & SPTAGMASK))
tagmask |= c->tags;
#elif SCRATCHPAD_ALT_1_PATCH
#if SCRATCHPAD_ALT_1_PATCH
if (!(c->tags & SCRATCHPAD_MASK))
tagmask |= c->tags;
#else
tagmask |= c->tags;
#endif // SCRATCHPADS_PATCH
#endif // SCRATCHPAD_ALT_1_PATCH
}
#if TAGSYNC_PATCH
selmon = origselmon;
@ -37,9 +30,6 @@ shift(const Arg *arg, int clients)
shifted.ui = (shifted.ui << arg->i) | (shifted.ui >> (NUMTAGS - arg->i));
else // right circular shift
shifted.ui = (shifted.ui >> -arg->i) | (shifted.ui << (NUMTAGS + arg->i));
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
shifted.ui &= ~SPTAGMASK;
#endif // SCRATCHPADS_PATCH
} while (tagmask && !(shifted.ui & tagmask));
return shifted;

@ -963,22 +963,6 @@
*/
#define SAVEFLOATS_PATCH 0
/* The scratchpad patch allows you to spawn or restore floating terminal windows.
* It is typically useful when one need to do some short typing.
*
* Note that this patch changes TAGMASK to make room for special scratchpad tags,
* so ~0 does more than select all tags with this patch. Code that relies on ~0 to
* represent all tags should use ~SPTAGMASK instead.
*
* Upgraded to Christian Tenllado's multiple scratchpad version.
* https://lists.suckless.org/hackers/2004/17205.html
* https://dwm.suckless.org/patches/scratchpads/
*/
#define SCRATCHPADS_PATCH 0
/* Minor alteration of the above allowing clients to keep their size and position when shown */
#define SCRATCHPADS_KEEP_POSITION_AND_SIZE_PATCH 0
/* This alternative patch enables a scratchpad feature in dwm similar to the scratchpad
* feature in i3wm.
* https://github.com/GasparVardanyan/dwm-scratchpad

Loading…
Cancel
Save