From fcac49f9de2902ae6bb5c592978d5e474e10b36c Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Mon, 22 Nov 2021 21:39:58 +0100 Subject: [PATCH] first working scratchpad version --- dwm.c | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/dwm.c b/dwm.c index 9f0c62f..6e5b32d 100644 --- a/dwm.c +++ b/dwm.c @@ -1915,13 +1915,12 @@ void togglescratch(const Arg *arg) { Client *c; - Client *cfound; Monitor *m; unsigned int found = 0; unsigned int scratchtag = SPTAG(arg->ui); Arg sparg = {.v = scratchpads[arg->ui].cmd}; - for (m = mons; m; m = m->next){ + for (m = mons; m && ! found; m = m->next){ fprintf(stderr,"searching monitor %d\n", m->num); for (c = m->clients; c && !(found = c->tags & scratchtag); c = c->next){ fprintf(stderr, "client: %s\n", c->name); @@ -1929,12 +1928,11 @@ togglescratch(const Arg *arg) } if (found){ - cfound=c; - fprintf(stderr, "found client %s\n", cfound->name); - fprintf(stderr, "tags of scratchpad: %d\n", cfound->tags); + fprintf(stderr, "found client %s\n", c->name); + fprintf(stderr, "tags of scratchpad: %d\n", c->tags); fprintf(stderr, "scratchtag: %d\n", scratchtag); - fprintf(stderr, "num of monitor: %d\n", cfound->mon->num); - if (cfound->mon == selmon) { + fprintf(stderr, "num of monitor: %d\n", c->mon->num); + if (c->mon == selmon) { unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag; if (newtagset) { selmon->tagset[selmon->seltags] = newtagset; @@ -1950,18 +1948,33 @@ togglescratch(const Arg *arg) fprintf(stderr, "we should move to selmon\n"); //move client from cfound->mon to selmon but still in scratchtag // remove scratchtag from tagset of cfound->mon -> - unsigned int newtagset = cfound->mon->tagset[cfound->mon->seltags] ^ scratchtag; + unsigned int newtagset = c->mon->tagset[c->mon->seltags] ^ scratchtag; if (newtagset) - cfound->mon->tagset[cfound->mon->seltags] = newtagset; + c->mon->tagset[c->mon->seltags] = newtagset; //add scratchtag to monitor where client is sent to selmon->tagset[selmon->seltags] |= scratchtag; - sendmontags(cfound, selmon, scratchtag); - fprintf(stderr, "tags of scratchpad: %d\n", cfound->tags); - fprintf(stderr, "num of monitor: %d\n", cfound->mon->num); + sendmontags(c, selmon, scratchtag); + fprintf(stderr, "tags of scratchpad: %d\n", c->tags); + fprintf(stderr, "num of monitor: %d\n", c->mon->num); + //if(cfound->next->mon->num){ + // fprintf(stderr, "monitor of next client: %d\n", cfound->next->mon->num); + //} + //else{ + // fprintf(stderr, "monitor of next client: NULL"); + //} + //if(cfound->snext->mon->num){ + // //fprintf(stderr, "monitor of snext client: %d\n", cfound->snext->mon->num);} + // int a = 1; + //} + //else + //{ + // fprintf(stderr, "monitor of snext client: NULL"); + //} + } } else { - fprintf(stderr, "Did not find client"); + fprintf(stderr, "Did not find client\n"); selmon->tagset[selmon->seltags] |= scratchtag; spawn(&sparg); }