Merge remote-tracking branch 'upstream/master'

- Add renamed scratchpads patch
- hide systray when there are no systray icons to show
This commit is contained in:
Sravan Balaji
2022-07-01 16:38:19 -04:00
17 changed files with 357 additions and 37 deletions

View File

@ -19,6 +19,8 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/X9IiSSM6
### Changelog:
2022-06-20 - Added the renamed scratchpads patch
2022-06-17 - Ported the seamless restart feature from dusk into dwm-flexipatch
2022-02-11 - Added the isfreesize version of the sizehints patch and the [tagsync](https://github.com/bakkeby/dwm-flexipatch/pull/219) patch (contributed by [Bagelli](https://github.com/Bagellll))
@ -565,6 +567,9 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/X9IiSSM6
- [push](https://dwm.suckless.org/patches/push/)
- this patch provides a way to move clients up and down inside the client list
- [renamed_scratchpads](https://github.com/bakkeby/patches/wiki/renamedscratchpads)
- variant of the [named scratchpads](https://dwm.suckless.org/patches/namedscratchpads/) patch
- [reorganizetags](https://dwm.suckless.org/patches/reorganizetags/)
- shifts all clients per tag to leftmost unoccupied tags
- e.g. if clients A, B, C are tagged on tags 1, 5, 9 respectively, when reorganized they will

View File

@ -289,6 +289,8 @@ Browsing patches? There is a [[https://coggle.it/diagram/X9IiSSM6PTWOM9Wz][map o
** Changelog
2022-06-20 - Added the renamed scratchpads patch
2022-06-17 - Ported the seamless restart feature from dusk into dwm-flexipatch
2022-02-11 - Added the isfreesize version of the sizehints patch and the [[https://github.com/bakkeby/dwm-flexipatch/pull/219][tagsync]] patch (contributed by [[https://github.com/Bagellll][Bagelli]])
@ -834,6 +836,9 @@ Browsing patches? There is a [[https://coggle.it/diagram/X9IiSSM6PTWOM9Wz][map o
- [[https://dwm.suckless.org/patches/push/][push]]
- this patch provides a way to move clients up and down inside the client list
- [[https://github.com/bakkeby/patches/wiki/renamedscratchpads][renamed_scratchpads]]
- variant of the [[https://dwm.suckless.org/patches/namedscratchpads/][named scratchpads]] patch
- [[https://dwm.suckless.org/patches/reorganizetags/][reorganizetags]]
- shifts all clients per tag to leftmost unoccupied tags
- e.g. if clients A, B, C are tagged on tags 1, 5, 9 respectively, when reorganized they will
@ -2462,6 +2467,29 @@ https://dwm.suckless.org/patches/push/
#define PUSH_NO_MASTER_PATCH 0
#+END_SRC
*** Renamed Scratchpads
**** Main
Variant of the named scratchpads patch allowing scratch keys to be added or removed
on demand, allowing multiple scratchpad windows to be toggled into and out of view
in unison, as well as including multi-monitor support.
https://github.com/bakkeby/patches/wiki/renamedscratchpads
#+BEGIN_SRC c :tangle patches.def.h
#define RENAMED_SCRATCHPADS_PATCH 0
#+END_SRC
**** Auto-Hide
Renamed scratchpads option to auto-hide scratchpads when moving to a different tag.
This behaviour is similar to that of the (multiple) scratchpads patch.
#+BEGIN_SRC c :tangle patches.def.h
#define RENAMED_SCRATCHPADS_AUTO_HIDE_PATCH 0
#+END_SRC
*** Re-Organize Tags
Shifts all clients per tag to leftmost unoccupied tags.
@ -3685,6 +3713,22 @@ static char urgbordercolor[] = "#FF5555";
static char urgfloatcolor[] = "#FF5555";
#+END_SRC
*** Renamed Scratchpads
#+BEGIN_SRC c :tangle config.def.h
#if RENAMED_SCRATCHPADS_PATCH
static char scratchselfgcolor[] = "#FFF7D4";
static char scratchselbgcolor[] = "#77547E";
static char scratchselbordercolor[] = "#894B9F";
static char scratchselfloatcolor[] = "#894B9F";
static char scratchnormfgcolor[] = "#FFF7D4";
static char scratchnormbgcolor[] = "#664C67";
static char scratchnormbordercolor[] = "#77547E";
static char scratchnormfloatcolor[] = "#77547E";
#endif // RENAMED_SCRATCHPADS_PATCH
#+END_SRC
*** Bar Flex Win Title
#+BEGIN_SRC c :tangle config.def.h
@ -3742,6 +3786,10 @@ static const unsigned int alphas[][3] = {
[SchemeHidNorm] = { OPAQUE, baralpha, borderalpha },
[SchemeHidSel] = { OPAQUE, baralpha, borderalpha },
[SchemeUrg] = { OPAQUE, baralpha, borderalpha },
#if RENAMED_SCRATCHPADS_PATCH
[SchemeScratchSel] = { OPAQUE, baralpha, borderalpha },
[SchemeScratchNorm] = { OPAQUE, baralpha, borderalpha },
#endif // RENAMED_SCRATCHPADS_PATCH
#if BAR_FLEXWINTITLE_PATCH
[SchemeFlexActTTB] = { OPAQUE, baralpha, borderalpha },
[SchemeFlexActLTR] = { OPAQUE, baralpha, borderalpha },
@ -3816,6 +3864,10 @@ static char *colors[][ColCount] = {
[SchemeHidNorm] = { hidnormfgcolor, hidnormbgcolor, c000000, c000000 },
[SchemeHidSel] = { hidselfgcolor, hidselbgcolor, c000000, c000000 },
[SchemeUrg] = { urgfgcolor, urgbgcolor, urgbordercolor, urgfloatcolor },
#if RENAMED_SCRATCHPADS_PATCH
[SchemeScratchSel] = { scratchselfgcolor, scratchselbgcolor, scratchselbordercolor, scratchselfloatcolor },
[SchemeScratchNorm] = { scratchnormfgcolor, scratchnormbgcolor, scratchnormbordercolor, scratchnormfloatcolor },
#endif // RENAMED_SCRATCHPADS_PATCH
#if BAR_FLEXWINTITLE_PATCH
[SchemeFlexActTTB] = { titleselfgcolor, actTTBbgcolor, actTTBbgcolor, c000000 },
[SchemeFlexActLTR] = { titleselfgcolor, actLTRbgcolor, actLTRbgcolor, c000000 },
@ -3895,7 +3947,9 @@ static const char *const autostart[] = {
** Scratchpads
#+BEGIN_SRC c :tangle config.def.h
#if SCRATCHPADS_PATCH
#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 */
@ -4011,7 +4065,9 @@ static const Rule rules[] = {
RULE(.class = "NoiseTorch", .tags = 1 << 8)
RULE(.class = "kdenlive", .tags = 1 << 8)
RULE(.class = "Motrix", .tags = 1 << 8)
#if SCRATCHPADS_PATCH
#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
};
@ -4736,11 +4792,15 @@ static Key keys[] = {
{ MODKEY|ShiftMask, XK_Escape, togglenomodbuttons, {0} },
#endif // NO_MOD_BUTTONS_PATCH
#if SCRATCHPADS_PATCH
#if RENAMED_SCRATCHPADS_PATCH
{ 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
#endif // SCRATCHPADS_PATCH | RENAMED_SCRATCHPADS_PATCH
#if UNFLOATVISIBLE_PATCH
{ MODKEY|Mod1Mask, XK_space, unfloatvisible, {0} },
@ -4770,7 +4830,7 @@ static Key keys[] = {
{ MODKEY, XK_minus, scratchpad_show, {0} },
{ MODKEY|ShiftMask, XK_minus, scratchpad_hide, {0} },
{ MODKEY, XK_equal, scratchpad_remove, {0} },
#elif SCRATCHPADS_PATCH
#elif SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
{ MODKEY, XK_0, view, {.ui = ~SPTAGMASK } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~SPTAGMASK } },
#else
@ -5192,7 +5252,7 @@ static Signal signals[] = {
{ "toggleverticalmax", toggleverticalmax },
{ "togglemax", togglemax },
#endif // MAXIMIZE_PATCH
#if SCRATCHPADS_PATCH
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
{ "togglescratch", togglescratch },
#endif // SCRATCHPADS_PATCH
#if UNFLOATVISIBLE_PATCH
@ -5319,7 +5379,7 @@ static IPCCommand ipccommands[] = {
#if ROTATESTACK_PATCH
IPCCOMMAND( rotatestack, 1, {ARG_TYPE_SINT} ),
#endif // ROTATESTACK_PATCH
#if SCRATCHPADS_PATCH
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
IPCCOMMAND( togglescratch, 1, {ARG_TYPE_UINT} ),
#endif // SCRATCHPADS_PATCH
#if SELFRESTART_PATCH

View File

@ -196,6 +196,18 @@ static char urgbgcolor[] = "#282A36";
static char urgbordercolor[] = "#FF5555";
static char urgfloatcolor[] = "#FF5555";
#if RENAMED_SCRATCHPADS_PATCH
static char scratchselfgcolor[] = "#FFF7D4";
static char scratchselbgcolor[] = "#77547E";
static char scratchselbordercolor[] = "#894B9F";
static char scratchselfloatcolor[] = "#894B9F";
static char scratchnormfgcolor[] = "#FFF7D4";
static char scratchnormbgcolor[] = "#664C67";
static char scratchnormbordercolor[] = "#77547E";
static char scratchnormfloatcolor[] = "#77547E";
#endif // RENAMED_SCRATCHPADS_PATCH
#if BAR_FLEXWINTITLE_PATCH
static char normTTBbgcolor[] = "#330000";
static char normLTRbgcolor[] = "#330033";
@ -246,6 +258,10 @@ static const unsigned int alphas[][3] = {
[SchemeHidNorm] = { OPAQUE, baralpha, borderalpha },
[SchemeHidSel] = { OPAQUE, baralpha, borderalpha },
[SchemeUrg] = { OPAQUE, baralpha, borderalpha },
#if RENAMED_SCRATCHPADS_PATCH
[SchemeScratchSel] = { OPAQUE, baralpha, borderalpha },
[SchemeScratchNorm] = { OPAQUE, baralpha, borderalpha },
#endif // RENAMED_SCRATCHPADS_PATCH
#if BAR_FLEXWINTITLE_PATCH
[SchemeFlexActTTB] = { OPAQUE, baralpha, borderalpha },
[SchemeFlexActLTR] = { OPAQUE, baralpha, borderalpha },
@ -312,6 +328,10 @@ static char *colors[][ColCount] = {
[SchemeHidNorm] = { hidnormfgcolor, hidnormbgcolor, c000000, c000000 },
[SchemeHidSel] = { hidselfgcolor, hidselbgcolor, c000000, c000000 },
[SchemeUrg] = { urgfgcolor, urgbgcolor, urgbordercolor, urgfloatcolor },
#if RENAMED_SCRATCHPADS_PATCH
[SchemeScratchSel] = { scratchselfgcolor, scratchselbgcolor, scratchselbordercolor, scratchselfloatcolor },
[SchemeScratchNorm] = { scratchnormfgcolor, scratchnormbgcolor, scratchnormbordercolor, scratchnormfloatcolor },
#endif // RENAMED_SCRATCHPADS_PATCH
#if BAR_FLEXWINTITLE_PATCH
[SchemeFlexActTTB] = { titleselfgcolor, actTTBbgcolor, actTTBbgcolor, c000000 },
[SchemeFlexActLTR] = { titleselfgcolor, actLTRbgcolor, actLTRbgcolor, c000000 },
@ -375,7 +395,9 @@ static const char *const autostart[] = {
};
#endif // COOL_AUTOSTART_PATCH
#if SCRATCHPADS_PATCH
#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 */
@ -432,7 +454,9 @@ static const Rule rules[] = {
RULE(.class = "NoiseTorch", .tags = 1 << 8)
RULE(.class = "kdenlive", .tags = 1 << 8)
RULE(.class = "Motrix", .tags = 1 << 8)
#if SCRATCHPADS_PATCH
#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
};
@ -1090,11 +1114,15 @@ static Key keys[] = {
{ MODKEY|ShiftMask, XK_Escape, togglenomodbuttons, {0} },
#endif // NO_MOD_BUTTONS_PATCH
#if SCRATCHPADS_PATCH
#if RENAMED_SCRATCHPADS_PATCH
{ 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
#endif // SCRATCHPADS_PATCH | RENAMED_SCRATCHPADS_PATCH
#if UNFLOATVISIBLE_PATCH
{ MODKEY|Mod1Mask, XK_space, unfloatvisible, {0} },
@ -1124,7 +1152,7 @@ static Key keys[] = {
{ MODKEY, XK_minus, scratchpad_show, {0} },
{ MODKEY|ShiftMask, XK_minus, scratchpad_hide, {0} },
{ MODKEY, XK_equal, scratchpad_remove, {0} },
#elif SCRATCHPADS_PATCH
#elif SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
{ MODKEY, XK_0, view, {.ui = ~SPTAGMASK } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~SPTAGMASK } },
#else
@ -1540,7 +1568,7 @@ static Signal signals[] = {
{ "toggleverticalmax", toggleverticalmax },
{ "togglemax", togglemax },
#endif // MAXIMIZE_PATCH
#if SCRATCHPADS_PATCH
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
{ "togglescratch", togglescratch },
#endif // SCRATCHPADS_PATCH
#if UNFLOATVISIBLE_PATCH
@ -1665,7 +1693,7 @@ static IPCCommand ipccommands[] = {
#if ROTATESTACK_PATCH
IPCCOMMAND( rotatestack, 1, {ARG_TYPE_SINT} ),
#endif // ROTATESTACK_PATCH
#if SCRATCHPADS_PATCH
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
IPCCOMMAND( togglescratch, 1, {ARG_TYPE_UINT} ),
#endif // SCRATCHPADS_PATCH
#if SELFRESTART_PATCH

60
dwm.c
View File

@ -101,7 +101,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
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
#define TOTALTAGS (NUMTAGS + LENGTH(scratchpads))
#define TAGMASK ((1 << TOTALTAGS) - 1)
#define SPTAG(i) ((1 << NUMTAGS) << (i))
@ -144,6 +144,10 @@ enum {
SchemeHidNorm,
SchemeHidSel,
SchemeUrg,
#if RENAMED_SCRATCHPADS_PATCH
SchemeScratchSel,
SchemeScratchNorm,
#endif // RENAMED_SCRATCHPADS_PATCH
#if BAR_FLEXWINTITLE_PATCH
SchemeFlexActTTB,
SchemeFlexActLTR,
@ -402,6 +406,9 @@ struct Client {
#if IPC_PATCH
ClientState prevstate;
#endif // IPC_PATCH
#if RENAMED_SCRATCHPADS_PATCH
char scratchkey;
#endif // RENAMED_SCRATCHPADS_PATCH
#if XKB_PATCH
XkbInfo *xkb;
#endif // XKB_PATCH
@ -543,6 +550,9 @@ typedef struct {
const char *floatpos;
#endif // FLOATPOS_PATCH
int monitor;
#if RENAMED_SCRATCHPADS_PATCH
const char scratchkey;
#endif // RENAMED_SCRATCHPADS_PATCH
#if XKB_PATCH
int xkb_layout;
#endif // XKB_PATCH
@ -849,6 +859,9 @@ applyrules(Client *c)
#endif // SIZEHINTS_ISFREESIZE_PATCH
c->isfloating = 0;
c->tags = 0;
#if RENAMED_SCRATCHPADS_PATCH
c->scratchkey = 0;
#endif // RENAMED_SCRATCHPADS_PATCH
XGetClassHint(dpy, c->win, &ch);
class = ch.res_class ? ch.res_class : broken;
instance = ch.res_name ? ch.res_name : broken;
@ -890,7 +903,9 @@ applyrules(Client *c)
#endif // SIZEHINTS_ISFREESIZE_PATCH
c->isfloating = r->isfloating;
c->tags |= r->tags;
#if SCRATCHPADS_PATCH
#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);
@ -963,7 +978,7 @@ applyrules(Client *c)
XFree(ch.res_name);
#if EMPTYVIEW_PATCH
if (c->tags & TAGMASK) c->tags = c->tags & TAGMASK;
#if SCRATCHPADS_PATCH
#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
else if (c->tags != SCRATCHPAD_MASK && c->mon->tagset[c->mon->seltags]) c->tags = c->mon->tagset[c->mon->seltags];
@ -971,7 +986,7 @@ applyrules(Client *c)
else if (c->mon->tagset[c->mon->seltags]) c->tags = c->mon->tagset[c->mon->seltags];
#endif // SCRATCHPADS_PATCH
else c->tags = 1;
#elif SCRATCHPADS_PATCH
#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)
@ -1997,10 +2012,21 @@ focus(Client *c)
attachstack(c);
grabbuttons(c, 1);
#if !BAR_FLEXWINTITLE_PATCH
#if RENAMED_SCRATCHPADS_PATCH
if (c->scratchkey != 0 && c->isfloating)
XSetWindowBorder(dpy, c->win, scheme[SchemeScratchSel][ColFloat].pixel);
else if (c->scratchkey != 0)
XSetWindowBorder(dpy, c->win, scheme[SchemeScratchSel][ColBorder].pixel);
else if (c->isfloating)
XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColFloat].pixel);
else
XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
#else
if (c->isfloating)
XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColFloat].pixel);
else
XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
#endif // RENAMED_SCRATCHPADS_PATCH
#endif // BAR_FLEXWINTITLE_PATCH
setfocus(c);
} else {
@ -2688,7 +2714,7 @@ movemouse(const Arg *arg)
XUngrabPointer(dpy, CurrentTime);
if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
#if SCRATCHPADS_PATCH
#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);
@ -3040,7 +3066,7 @@ 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
#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);
@ -3239,7 +3265,7 @@ sendmon(Client *c, Monitor *m)
arrange(c->mon);
#endif // SENDMON_KEEPFOCUS_PATCH
c->mon = m;
#if SCRATCHPADS_PATCH
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
if (!(c->tags & SPTAGMASK))
#endif // SCRATCHPADS_PATCH
#if EMPTYVIEW_PATCH
@ -3782,6 +3808,7 @@ 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) &&
@ -3802,6 +3829,7 @@ showhide(Client *c)
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) {
@ -3829,6 +3857,11 @@ showhide(Client *c)
resize(c, c->x, c->y, c->w, c->h, 0);
showhide(c->snext);
} else {
#if RENAMED_SCRATCHPADS_PATCH && RENAMED_SCRATCHPADS_AUTO_HIDE_PATCH
/* optional: auto-hide scratchpads when moving to other tags */
if (c->scratchkey != 0 && !(c->tags & c->mon->tagset[c->mon->seltags]))
c->tags = 0;
#endif // RENAMED_SCRATCHPADS_AUTO_HIDE_PATCH
/* hide clients bottom up */
showhide(c->snext);
XMoveWindow(dpy, c->win, WIDTH(c) * -2, c->y);
@ -4168,7 +4201,7 @@ toggleview(const Arg *arg)
selmon->tagset[selmon->seltags] = newtagset;
#if PERTAG_PATCH
#if SCRATCHPADS_PATCH
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
if (newtagset == ~SPTAGMASK)
#else
if (newtagset == ~0)
@ -4238,10 +4271,21 @@ unfocus(Client *c, int setfocus, Client *nextfocus)
#endif // LOSEFULLSCREEN_PATCH
grabbuttons(c, 0);
#if !BAR_FLEXWINTITLE_PATCH
#if RENAMED_SCRATCHPADS_PATCH
if (c->scratchkey != 0 && c->isfloating)
XSetWindowBorder(dpy, c->win, scheme[SchemeScratchNorm][ColFloat].pixel);
else if (c->scratchkey != 0)
XSetWindowBorder(dpy, c->win, scheme[SchemeScratchNorm][ColBorder].pixel);
else if (c->isfloating)
XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColFloat].pixel);
else
XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel);
#else
if (c->isfloating)
XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColFloat].pixel);
else
XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel);
#endif // RENAMED_SCRATCHPADS_PATCH
#endif // BAR_FLEXWINTITLE_PATCH
if (setfocus) {
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);

View File

@ -182,6 +182,13 @@ flextitledraw(Monitor *m, Client *c, int unused, int x, int w, int tabscheme, Ar
int tw = w;
int clientscheme = (
#if RENAMED_SCRATCHPADS_PATCH
c->scratchkey != 0 && c == selmon->sel
? SchemeScratchSel
: c->scratchkey != 0
? SchemeScratchNorm
:
#endif // RENAMED_SCRATCHPADS_PATCH
c == selmon->sel && HIDDEN(c)
? SchemeHidSel
: HIDDEN(c)

View File

@ -8,8 +8,11 @@ width_systray(Bar *bar, BarArg *a)
Client *i;
if (!systray)
return 1;
if (showsystray)
if (showsystray) {
for (i = systray->icons; i; w += i->w + systrayspacing, i = i->next);
if (!w)
XMoveWindow(dpy, systray->win, -systray->h, bar->by);
}
return w ? w + lrpad - systrayspacing : 0;
}
@ -36,12 +39,12 @@ draw_systray(Bar *bar, BarArg *a)
#if BAR_ALPHA_PATCH
wa.background_pixel = 0;
wa.colormap = cmap;
systray->win = XCreateWindow(dpy, root, bar->bx + a->x + lrpad / 2, bar->by + a->y + (a->h - systray->h) / 2, MAX(a->w + 40, 1), systray->h, 0, depth,
systray->win = XCreateWindow(dpy, root, bar->bx + a->x + lrpad / 2, -systray->h, MAX(a->w + 40, 1), systray->h, 0, depth,
InputOutput, visual,
CWOverrideRedirect|CWBorderPixel|CWBackPixel|CWColormap|CWEventMask, &wa); // CWBackPixmap
#else
wa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
systray->win = XCreateSimpleWindow(dpy, root, bar->bx + a->x + lrpad / 2, bar->by + a->y + (a->h - systray->h) / 2, MIN(a->w, 1), systray->h, 0, 0, scheme[SchemeNorm][ColBg].pixel);
systray->win = XCreateSimpleWindow(dpy, root, bar->bx + a->x + lrpad / 2, -systray->h, MIN(a->w, 1), systray->h, 0, 0, scheme[SchemeNorm][ColBg].pixel);
XChangeWindowAttributes(dpy, systray->win, CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWEventMask, &wa);
#endif // BAR_ALPHA_PATCH
@ -91,7 +94,7 @@ draw_systray(Bar *bar, BarArg *a)
i->mon = bar->mon;
}
XMoveResizeWindow(dpy, systray->win, bar->bx + a->x + lrpad / 2, (w ? bar->by + a->y + (a->h - systray->h) / 2: -bar->by - a->y), MAX(w, 1), systray->h);
XMoveResizeWindow(dpy, systray->win, bar->bx + a->x + lrpad / 2, (w ? bar->by + a->y + (a->h - systray->h) / 2: -systray->h), MAX(w, 1), systray->h);
return w;
}

View File

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

View File

@ -218,7 +218,9 @@
#if ROUNDED_CORNERS_PATCH
#include "roundedcorners.c"
#endif
#if SCRATCHPADS_PATCH
#if RENAMED_SCRATCHPADS_PATCH
#include "renamed_scratchpads.c"
#elif SCRATCHPADS_PATCH
#include "scratchpad.c"
#endif
#if SCRATCHPAD_ALT_1_PATCH

View File

@ -217,7 +217,9 @@
#if ROUNDED_CORNERS_PATCH
#include "roundedcorners.h"
#endif
#if SCRATCHPADS_PATCH
#if RENAMED_SCRATCHPADS_PATCH
#include "renamed_scratchpads.h"
#elif SCRATCHPADS_PATCH
#include "scratchpad.h"
#endif
#if SCRATCHPAD_ALT_1_PATCH

View File

@ -33,7 +33,7 @@ pertagview(const Arg *arg)
if (arg->ui & TAGMASK) {
selmon->pertag->prevtag = selmon->pertag->curtag;
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
#if SCRATCHPADS_PATCH
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
if (arg->ui == ~SPTAGMASK)
#else
if (arg->ui == ~0)

151
patch/renamed_scratchpads.c Normal file
View File

@ -0,0 +1,151 @@
void
removescratch(const Arg *arg)
{
Client *c = selmon->sel;
if (!c)
return;
c->scratchkey = 0;
}
void
setscratch(const Arg *arg)
{
Client *c = selmon->sel;
if (!c)
return;
c->scratchkey = ((char**)arg->v)[0][0];
}
void spawnscratch(const Arg *arg)
{
if (fork() == 0) {
if (dpy)
close(ConnectionNumber(dpy));
setsid();
execvp(((char **)arg->v)[1], ((char **)arg->v)+1);
fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[1]);
perror(" failed");
exit(EXIT_SUCCESS);
}
}
void
togglescratch(const Arg *arg)
{
Client *c, *next, *last = NULL, *found = NULL, *monclients = NULL;
Monitor *mon;
int scratchvisible = 0; // whether the scratchpads are currently visible or not
int multimonscratch = 0; // whether we have scratchpads that are placed on multiple monitors
int scratchmon = -1; // the monitor where the scratchpads exist
int numscratchpads = 0; // count of scratchpads
/* Looping through monitors and client's twice, the first time to work out whether we need
to move clients across from one monitor to another or not */
for (mon = mons; mon; mon = mon->next)
for (c = mon->clients; c; c = c->next) {
if (c->scratchkey != ((char**)arg->v)[0][0])
continue;
if (scratchmon != -1 && scratchmon != mon->num)
multimonscratch = 1;
if (c->mon->tagset[c->mon->seltags] & c->tags) // && !HIDDEN(c)
++scratchvisible;
scratchmon = mon->num;
++numscratchpads;
}
/* Now for the real deal. The logic should go like:
- hidden scratchpads will be shown
- shown scratchpads will be hidden, unless they are being moved to the current monitor
- the scratchpads will be moved to the current monitor if they all reside on the same monitor
- multiple scratchpads residing on separate monitors will be left in place
*/
for (mon = mons; mon; mon = mon->next) {
for (c = mon->stack; c; c = next) {
next = c->snext;
if (c->scratchkey != ((char**)arg->v)[0][0])
continue;
/* awesomebar / wintitleactions compatibility, unhide scratchpad if hidden
if (HIDDEN(c)) {
XMapWindow(dpy, c->win);
setclientstate(c, NormalState);
}
*/
/* Record the first found scratchpad client for focus purposes, but prioritise the
scratchpad on the current monitor if one exists */
if (!found || (mon == selmon && found->mon != selmon))
found = c;
/* If scratchpad clients reside on another monitor and we are moving them across then
as we are looping through monitors we could be moving a client to a monitor that has
not been processed yet, hence we could be processing a scratchpad twice. To avoid
this we detach them and add them to a temporary list (monclients) which is to be
processed later. */
if (!multimonscratch && c->mon != selmon) {
detach(c);
detachstack(c);
c->next = NULL;
/* Note that we are adding clients at the end of the list, this is to preserve the
order of clients as they were on the adjacent monitor (relevant when tiled) */
if (last)
last = last->next = c;
else
last = monclients = c;
} else if (scratchvisible == numscratchpads) {
c->tags = 0;
} else {
XSetWindowBorder(dpy, c->win, scheme[SchemeScratchNorm][ColBorder].pixel);
c->tags = c->mon->tagset[c->mon->seltags];
if (c->isfloating)
XRaiseWindow(dpy, c->win);
}
}
}
/* Attach moved scratchpad clients on the selected monitor */
for (c = monclients; c; c = next) {
next = c->next;
mon = c->mon;
c->mon = selmon;
c->tags = selmon->tagset[selmon->seltags];
/* Attach scratchpad clients from other monitors at the bottom of the stack */
if (selmon->clients) {
for (last = selmon->clients; last && last->next; last = last->next);
last->next = c;
} else
selmon->clients = c;
c->next = NULL;
attachstack(c);
/* Center floating scratchpad windows when moved from one monitor to another */
if (c->isfloating) {
if (c->w > selmon->ww)
c->w = selmon->ww - c->bw * 2;
if (c->h > selmon->wh)
c->h = selmon->wh - c->bw * 2;
if (numscratchpads > 1) {
c->x = c->mon->wx + (c->x - mon->wx) * ((double)(abs(c->mon->ww - WIDTH(c))) / MAX(abs(mon->ww - WIDTH(c)), 1));
c->y = c->mon->wy + (c->y - mon->wy) * ((double)(abs(c->mon->wh - HEIGHT(c))) / MAX(abs(mon->wh - HEIGHT(c)), 1));
} else if (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);
}
resizeclient(c, c->x, c->y, c->w, c->h);
XRaiseWindow(dpy, c->win);
}
}
if (found) {
focus(ISVISIBLE(found) ? found : NULL);
arrange(NULL);
if (found->isfloating)
XRaiseWindow(dpy, found->win);
} else {
spawnscratch(arg);
}
}

View File

@ -0,0 +1,4 @@
static void removescratch(const Arg *arg);
static void setscratch(const Arg *arg);
static void spawnscratch(const Arg *arg);
static void togglescratch(const Arg *arg);

View File

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

View File

@ -2,7 +2,7 @@ void
shiftview(const Arg *arg)
{
Arg shifted;
#if SCRATCHPADS_PATCH
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
unsigned int seltagset = selmon->tagset[selmon->seltags] & ~SPTAGMASK;
#else
unsigned int seltagset = selmon->tagset[selmon->seltags];
@ -11,7 +11,7 @@ shiftview(const Arg *arg)
shifted.ui = (seltagset << arg->i) | (seltagset >> (NUMTAGS - arg->i));
else // right circular shift
shifted.ui = (seltagset >> -arg->i) | (seltagset << (NUMTAGS + arg->i));
#if SCRATCHPADS_PATCH
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
shifted.ui &= ~SPTAGMASK;
#endif // SCRATCHPADS_PATCH

View File

@ -10,7 +10,7 @@ shiftviewclients(const Arg *arg)
for (selmon = mons; selmon; selmon = selmon->next)
#endif // TAGSYNC_PATCH
for (c = selmon->clients; c; c = c->next) {
#if SCRATCHPADS_PATCH
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
if (!(c->tags & SPTAGMASK))
tagmask = tagmask | c->tags;
#elif SCRATCHPAD_ALT_1_PATCH
@ -24,7 +24,7 @@ shiftviewclients(const Arg *arg)
selmon = origselmon;
#endif // TAGSYNC_PATCH
#if SCRATCHPADS_PATCH
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
shifted.ui = selmon->tagset[selmon->seltags] & ~SPTAGMASK;
#else
shifted.ui = selmon->tagset[selmon->seltags];
@ -37,7 +37,7 @@ shiftviewclients(const Arg *arg)
else // right circular shift
shifted.ui = (shifted.ui >> -arg->i)
| (shifted.ui << (NUMTAGS + arg->i));
#if SCRATCHPADS_PATCH
#if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH
shifted.ui &= ~SPTAGMASK;
#endif // SCRATCHPADS_PATCH
} while (tagmask && !(shifted.ui & tagmask));

View File

@ -48,6 +48,16 @@ loadxrdb()
XRDB_LOAD_COLOR("dwm.urgbgcolor", urgbgcolor);
XRDB_LOAD_COLOR("dwm.urgbordercolor", urgbordercolor);
XRDB_LOAD_COLOR("dwm.urgfloatcolor", urgfloatcolor);
#if RENAMED_SCRATCHPADS_PATCH
XRDB_LOAD_COLOR("dwm.scratchselfgcolor", scratchselfgcolor);
XRDB_LOAD_COLOR("dwm.scratchselbgcolor", scratchselbgcolor);
XRDB_LOAD_COLOR("dwm.scratchselbordercolor", scratchselbordercolor);
XRDB_LOAD_COLOR("dwm.scratchselfloatcolor", scratchselfloatcolor);
XRDB_LOAD_COLOR("dwm.scratchnormfgcolor", scratchnormfgcolor);
XRDB_LOAD_COLOR("dwm.scratchnormbgcolor", scratchnormbgcolor);
XRDB_LOAD_COLOR("dwm.scratchnormbordercolor", scratchnormbordercolor);
XRDB_LOAD_COLOR("dwm.scratchnormfloatcolor", scratchnormfloatcolor);
#endif // RENAMED_SCRATCHPADS_PATCH
#if BAR_FLEXWINTITLE_PATCH
XRDB_LOAD_COLOR("dwm.normTTBbgcolor", normTTBbgcolor);
XRDB_LOAD_COLOR("dwm.normLTRbgcolor", normLTRbgcolor);

View File

@ -231,6 +231,10 @@
#define PUSH_NO_MASTER_PATCH 0
#define RENAMED_SCRATCHPADS_PATCH 0
#define RENAMED_SCRATCHPADS_AUTO_HIDE_PATCH 0
#define REORGANIZETAGS_PATCH 0
#define RESIZECORNERS_PATCH 1