summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--dwm.c25
-rw-r--r--patch/scratchpad.c49
-rw-r--r--patches.def.h3
4 files changed, 55 insertions, 24 deletions
diff --git a/README.md b/README.md
index 4d60886..412a6b3 100644
--- a/README.md
+++ b/README.md
@@ -15,6 +15,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog:
+2020-09-07 - Scratchpads improvement (multi-monitor support)
+
2020-09-05 - Assortment of fullscreen improvements
2020-08-27 - Added aspectresize patch
diff --git a/dwm.c b/dwm.c
index f9e0615..05abd66 100644
--- a/dwm.c
+++ b/dwm.c
@@ -742,12 +742,12 @@ applyrules(Client *c)
#endif // SWALLOW_PATCH
c->isfloating = r->isfloating;
c->tags |= r->tags;
- #if SCRATCHPADS_PATCH && !SCRATCHPAD_KEEP_POSITION_AND_SIZE_PATCH
+ #if 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 | SCRATCHPAD_KEEP_POSITION_AND_SIZE_PATCH
+ #endif // SCRATCHPADS_PATCH
for (m = mons; m && m->num != r->monitor; m = m->next);
if (m)
c->mon = m;
@@ -2693,6 +2693,9 @@ sendmon(Client *c, Monitor *m)
arrange(c->mon);
#endif // SENDMON_KEEPFOCUS_PATCH
c->mon = m;
+ #if SCRATCHPADS_PATCH
+ if (!(c->tags & SPTAGMASK))
+ #endif // SCRATCHPADS_PATCH
#if EMPTYVIEW_PATCH
c->tags = (m->tagset[m->seltags] ? m->tagset[m->seltags] : 1);
#else
@@ -3115,12 +3118,26 @@ showhide(Client *c)
if (!c)
return;
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) {
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 | SCRATCHPAD_KEEP_POSITION_AND_SIZE_PATCH
+ #endif // SCRATCHPADS_KEEP_POSITION_AND_SIZE_PATCH | SCRATCHPADS_PATCH
/* show clients top down */
#if SAVEFLOATS_PATCH || EXRESIZE_PATCH
if (!c->mon->lt[c->mon->sellt]->arrange && c->sfx != -9999 && !c->isfullscreen) {
diff --git a/patch/scratchpad.c b/patch/scratchpad.c
index 4edff52..c0c1873 100644
--- a/patch/scratchpad.c
+++ b/patch/scratchpad.c
@@ -1,25 +1,34 @@
void
togglescratch(const Arg *arg)
{
- Client *c;
- unsigned int found = 0;
- unsigned int scratchtag = SPTAG(arg->ui);
- Arg sparg = {.v = scratchpads[arg->ui].cmd};
+ Client *c = NULL;
+ Monitor *mon;
+ unsigned int found = 0;
+ 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);
- if (found) {
- unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
- if (newtagset) {
- selmon->tagset[selmon->seltags] = newtagset;
- focus(NULL);
- arrange(selmon);
- }
- if (ISVISIBLE(c)) {
- focus(c);
- restack(selmon);
- }
- } else {
- selmon->tagset[selmon->seltags] |= scratchtag;
- spawn(&sparg);
- }
+ for (mon = mons; mon && !found; mon = mon->next)
+ for (c = mon->clients; c && !(found = c->tags & scratchtag); c = c->next);
+
+ if (found) {
+ if (c->mon != selmon) {
+ if (c->mon->tagset[c->mon->seltags] & SPTAGMASK)
+ c->mon->tagset[c->mon->seltags] ^= scratchtag;
+ sendmon(c, selmon);
+ }
+
+ unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
+ if (newtagset) {
+ selmon->tagset[selmon->seltags] = newtagset;
+ focus(NULL);
+ arrange(selmon);
+ }
+ if (ISVISIBLE(c)) {
+ focus(c);
+ restack(selmon);
+ }
+ } else {
+ selmon->tagset[selmon->seltags] |= scratchtag;
+ spawn(&sparg);
+ }
} \ No newline at end of file
diff --git a/patches.def.h b/patches.def.h
index 61c8c34..bbed419 100644
--- a/patches.def.h
+++ b/patches.def.h
@@ -714,6 +714,9 @@
*/
#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