Upgrading Gaspar Vardanyan's scratchpad patch to the 20200510 version.

https://github.com/GasparVardanyan/dwm-scratchpad/blob/master/dwm-scratchpad-20200510-f09418b.diff
This commit is contained in:
bakkeby 2020-06-05 09:43:27 +02:00
parent fbb1537da6
commit bad53d2cc4
4 changed files with 16 additions and 11 deletions

View File

@ -825,10 +825,6 @@ static const char *statuscmds[] = { "notify-send Mouse$BUTTON" };
static char *statuscmd[] = { "/bin/sh", "-c", NULL, NULL }; static char *statuscmd[] = { "/bin/sh", "-c", NULL, NULL };
#endif // STATUSCMD_PATCH | DWMBLOCKS_PATCH #endif // STATUSCMD_PATCH | DWMBLOCKS_PATCH
#if SCRATCHPAD_ALT_1_PATCH
static const unsigned scratchpad_mask = 1u << sizeof tags / sizeof * tags;
#endif // SCRATCHPAD_ALT_1_PATCH
static Key keys[] = { static Key keys[] = {
/* modifier key function argument */ /* modifier key function argument */
#if KEYMODES_PATCH #if KEYMODES_PATCH
@ -997,8 +993,6 @@ static Key keys[] = {
{ MODKEY|ShiftMask, XK_s, togglesticky, {0} }, { MODKEY|ShiftMask, XK_s, togglesticky, {0} },
#endif // STICKY_PATCH #endif // STICKY_PATCH
#if SCRATCHPAD_ALT_1_PATCH #if SCRATCHPAD_ALT_1_PATCH
{ MODKEY, XK_0, view, {.ui = ~scratchpad_mask } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~scratchpad_mask } },
{ MODKEY, XK_minus, scratchpad_show, {0} }, { MODKEY, XK_minus, scratchpad_show, {0} },
{ MODKEY|ShiftMask, XK_minus, scratchpad_hide, {0} }, { MODKEY|ShiftMask, XK_minus, scratchpad_hide, {0} },
{ MODKEY, XK_equal, scratchpad_remove, {0} }, { MODKEY, XK_equal, scratchpad_remove, {0} },

9
dwm.c
View File

@ -514,7 +514,11 @@ static Window root, wmcheckwin;
#include "patch/include.c" #include "patch/include.c"
/* compile-time check if all tags fit into an unsigned int bit array. */ /* compile-time check if all tags fit into an unsigned int bit array. */
#if SCRATCHPAD_ALT_1_PATCH
struct NumTags { char limitexceeded[LENGTH(tags) > 30 ? -1 : 1]; };
#else
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
#endif // SCRATCHPAD_ALT_1_PATCH
/* function implementations */ /* function implementations */
void void
@ -606,12 +610,17 @@ applyrules(Client *c)
if (c->tags & TAGMASK) c->tags = c->tags & TAGMASK; if (c->tags & TAGMASK) c->tags = c->tags & TAGMASK;
#if SCRATCHPAD_PATCH #if SCRATCHPAD_PATCH
else if (c->mon->tagset[c->mon->seltags]) c->tags = c->mon->tagset[c->mon->seltags] & ~SPTAGMASK; else if (c->mon->tagset[c->mon->seltags]) c->tags = c->mon->tagset[c->mon->seltags] & ~SPTAGMASK;
#elif 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
else if (c->mon->tagset[c->mon->seltags]) c->tags = c->mon->tagset[c->mon->seltags]; else if (c->mon->tagset[c->mon->seltags]) c->tags = c->mon->tagset[c->mon->seltags];
#endif // SCRATCHPAD_PATCH #endif // SCRATCHPAD_PATCH
else c->tags = 1; else c->tags = 1;
#elif SCRATCHPAD_PATCH #elif SCRATCHPAD_PATCH
c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : (c->mon->tagset[c->mon->seltags] & ~SPTAGMASK); 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];
#else #else
c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags]; c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
#endif // EMPTYVIEW_PATCH #endif // EMPTYVIEW_PATCH

View File

@ -4,7 +4,7 @@ static void scratchpad_hide ()
{ {
if (selmon -> sel) if (selmon -> sel)
{ {
selmon -> sel -> tags = scratchpad_mask; selmon -> sel -> tags = SCRATCHPAD_MASK;
focus(NULL); focus(NULL);
arrange(selmon); arrange(selmon);
} }
@ -36,9 +36,9 @@ static void scratchpad_show ()
scratchpad_show_first (); scratchpad_show_first ();
else else
{ {
if (scratchpad_last_showed -> tags != scratchpad_mask) if (scratchpad_last_showed -> tags != SCRATCHPAD_MASK)
{ {
scratchpad_last_showed -> tags = scratchpad_mask; scratchpad_last_showed -> tags = SCRATCHPAD_MASK;
focus(NULL); focus(NULL);
arrange(selmon); arrange(selmon);
} }
@ -58,7 +58,7 @@ static void scratchpad_show ()
} }
else else
{ {
if (c -> tags == scratchpad_mask) if (c -> tags == SCRATCHPAD_MASK)
{ {
found_next = 1; found_next = 1;
scratchpad_show_client (c); scratchpad_show_client (c);
@ -83,7 +83,7 @@ static void scratchpad_show_first (void)
{ {
for (Client * c = selmon -> clients; c != NULL; c = c -> next) for (Client * c = selmon -> clients; c != NULL; c = c -> next)
{ {
if (c -> tags == scratchpad_mask) if (c -> tags == SCRATCHPAD_MASK)
{ {
scratchpad_show_client (c); scratchpad_show_client (c);
break; break;

View File

@ -1,3 +1,5 @@
# define SCRATCHPAD_MASK (1u << sizeof tags / sizeof * tags)
static void scratchpad_hide (); static void scratchpad_hide ();
static _Bool scratchpad_last_showed_is_killed (void); static _Bool scratchpad_last_showed_is_killed (void);
static void scratchpad_remove (); static void scratchpad_remove ();