Weechat scratchpad #1

Merged
AlexBocken merged 3 commits from weechat_scratch into master 2021-11-22 21:50:30 +01:00
Showing only changes of commit fcac49f9de - Show all commits

39
dwm.c
View File

@ -1915,13 +1915,12 @@ void
togglescratch(const Arg *arg) togglescratch(const Arg *arg)
{ {
Client *c; Client *c;
Client *cfound;
Monitor *m; Monitor *m;
unsigned int found = 0; unsigned int found = 0;
unsigned int scratchtag = SPTAG(arg->ui); unsigned int scratchtag = SPTAG(arg->ui);
Arg sparg = {.v = scratchpads[arg->ui].cmd}; 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); fprintf(stderr,"searching monitor %d\n", m->num);
for (c = m->clients; c && !(found = c->tags & scratchtag); c = c->next){ for (c = m->clients; c && !(found = c->tags & scratchtag); c = c->next){
fprintf(stderr, "client: %s\n", c->name); fprintf(stderr, "client: %s\n", c->name);
@ -1929,12 +1928,11 @@ togglescratch(const Arg *arg)
} }
if (found){ if (found){
cfound=c; fprintf(stderr, "found client %s\n", c->name);
fprintf(stderr, "found client %s\n", cfound->name); fprintf(stderr, "tags of scratchpad: %d\n", c->tags);
fprintf(stderr, "tags of scratchpad: %d\n", cfound->tags);
fprintf(stderr, "scratchtag: %d\n", scratchtag); fprintf(stderr, "scratchtag: %d\n", scratchtag);
fprintf(stderr, "num of monitor: %d\n", cfound->mon->num); fprintf(stderr, "num of monitor: %d\n", c->mon->num);
if (cfound->mon == selmon) { if (c->mon == selmon) {
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag; unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
if (newtagset) { if (newtagset) {
selmon->tagset[selmon->seltags] = newtagset; selmon->tagset[selmon->seltags] = newtagset;
@ -1950,18 +1948,33 @@ togglescratch(const Arg *arg)
fprintf(stderr, "we should move to selmon\n"); fprintf(stderr, "we should move to selmon\n");
//move client from cfound->mon to selmon but still in scratchtag //move client from cfound->mon to selmon but still in scratchtag
// remove scratchtag from tagset of cfound->mon -> // 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) 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 //add scratchtag to monitor where client is sent to
selmon->tagset[selmon->seltags] |= scratchtag; selmon->tagset[selmon->seltags] |= scratchtag;
sendmontags(cfound, selmon, scratchtag); sendmontags(c, selmon, scratchtag);
fprintf(stderr, "tags of scratchpad: %d\n", cfound->tags); fprintf(stderr, "tags of scratchpad: %d\n", c->tags);
fprintf(stderr, "num of monitor: %d\n", cfound->mon->num); 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 { else {
fprintf(stderr, "Did not find client"); fprintf(stderr, "Did not find client\n");
selmon->tagset[selmon->seltags] |= scratchtag; selmon->tagset[selmon->seltags] |= scratchtag;
spawn(&sparg); spawn(&sparg);
} }