Scratchpads improvement (multi-monitor support)

pull/48/head
bakkeby 4 years ago
parent fce55dadcb
commit f4f5ecab75

@ -15,6 +15,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog: ### Changelog:
2020-09-07 - Scratchpads improvement (multi-monitor support)
2020-09-05 - Assortment of fullscreen improvements 2020-09-05 - Assortment of fullscreen improvements
2020-08-27 - Added aspectresize patch 2020-08-27 - Added aspectresize patch

25
dwm.c

@ -742,12 +742,12 @@ applyrules(Client *c)
#endif // SWALLOW_PATCH #endif // SWALLOW_PATCH
c->isfloating = r->isfloating; c->isfloating = r->isfloating;
c->tags |= r->tags; c->tags |= r->tags;
#if SCRATCHPADS_PATCH && !SCRATCHPAD_KEEP_POSITION_AND_SIZE_PATCH #if SCRATCHPADS_PATCH
if ((r->tags & SPTAGMASK) && r->isfloating) { if ((r->tags & SPTAGMASK) && r->isfloating) {
c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2); c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2); c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
} }
#endif // SCRATCHPADS_PATCH | SCRATCHPAD_KEEP_POSITION_AND_SIZE_PATCH #endif // SCRATCHPADS_PATCH
for (m = mons; m && m->num != r->monitor; m = m->next); for (m = mons; m && m->num != r->monitor; m = m->next);
if (m) if (m)
c->mon = m; c->mon = m;
@ -2693,6 +2693,9 @@ sendmon(Client *c, Monitor *m)
arrange(c->mon); arrange(c->mon);
#endif // SENDMON_KEEPFOCUS_PATCH #endif // SENDMON_KEEPFOCUS_PATCH
c->mon = m; c->mon = m;
#if SCRATCHPADS_PATCH
if (!(c->tags & SPTAGMASK))
#endif // SCRATCHPADS_PATCH
#if EMPTYVIEW_PATCH #if EMPTYVIEW_PATCH
c->tags = (m->tagset[m->seltags] ? m->tagset[m->seltags] : 1); c->tags = (m->tagset[m->seltags] ? m->tagset[m->seltags] : 1);
#else #else
@ -3115,12 +3118,26 @@ showhide(Client *c)
if (!c) if (!c)
return; return;
if (ISVISIBLE(c)) { if (ISVISIBLE(c)) {
#if SCRATCHPADS_PATCH && !SCRATCHPAD_KEEP_POSITION_AND_SIZE_PATCH #if 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) { if ((c->tags & SPTAGMASK) && c->isfloating) {
c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2); c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2); c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
} }
#endif // SCRATCHPADS_PATCH | SCRATCHPAD_KEEP_POSITION_AND_SIZE_PATCH #endif // SCRATCHPADS_KEEP_POSITION_AND_SIZE_PATCH | SCRATCHPADS_PATCH
/* show clients top down */ /* show clients top down */
#if SAVEFLOATS_PATCH || EXRESIZE_PATCH #if SAVEFLOATS_PATCH || EXRESIZE_PATCH
if (!c->mon->lt[c->mon->sellt]->arrange && c->sfx != -9999 && !c->isfullscreen) { if (!c->mon->lt[c->mon->sellt]->arrange && c->sfx != -9999 && !c->isfullscreen) {

@ -1,25 +1,34 @@
void void
togglescratch(const Arg *arg) togglescratch(const Arg *arg)
{ {
Client *c; Client *c = NULL;
unsigned int found = 0; Monitor *mon;
unsigned int scratchtag = SPTAG(arg->ui); unsigned int found = 0;
Arg sparg = {.v = scratchpads[arg->ui].cmd}; unsigned int scratchtag = SPTAG(arg->ui);
Arg sparg = {.v = scratchpads[arg->ui].cmd};
for (c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next); for (mon = mons; mon && !found; mon = mon->next)
if (found) { for (c = mon->clients; c && !(found = c->tags & scratchtag); c = c->next);
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
if (newtagset) { if (found) {
selmon->tagset[selmon->seltags] = newtagset; if (c->mon != selmon) {
focus(NULL); if (c->mon->tagset[c->mon->seltags] & SPTAGMASK)
arrange(selmon); c->mon->tagset[c->mon->seltags] ^= scratchtag;
} sendmon(c, selmon);
if (ISVISIBLE(c)) { }
focus(c);
restack(selmon); unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
} if (newtagset) {
} else { selmon->tagset[selmon->seltags] = newtagset;
selmon->tagset[selmon->seltags] |= scratchtag; focus(NULL);
spawn(&sparg); arrange(selmon);
} }
if (ISVISIBLE(c)) {
focus(c);
restack(selmon);
}
} else {
selmon->tagset[selmon->seltags] |= scratchtag;
spawn(&sparg);
}
} }

@ -714,6 +714,9 @@
*/ */
#define SCRATCHPADS_PATCH 0 #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 /* This alternative patch enables a scratchpad feature in dwm similar to the scratchpad
* feature in i3wm. * feature in i3wm.
* https://github.com/GasparVardanyan/dwm-scratchpad * https://github.com/GasparVardanyan/dwm-scratchpad

Loading…
Cancel
Save