scratchpad_alt_1.c (1362B)
1 static Client * scratchpad_last_showed = NULL; 2 3 void 4 scratchpad_hide() 5 { 6 if (selmon->sel) { 7 selmon->sel->tags = SCRATCHPAD_MASK; 8 selmon->sel->isfloating = 1; 9 arrange(selmon); 10 focus(NULL); 11 } 12 } 13 14 _Bool 15 scratchpad_last_showed_is_killed(void) 16 { 17 Client *c; 18 for (c = selmon->clients; c && c != scratchpad_last_showed; c = c->next); 19 return (c == NULL); 20 } 21 22 void 23 scratchpad_remove() 24 { 25 if (selmon->sel && scratchpad_last_showed != NULL && selmon->sel == scratchpad_last_showed) 26 scratchpad_last_showed = NULL; 27 } 28 29 void 30 scratchpad_show() 31 { 32 if (scratchpad_last_showed == NULL || scratchpad_last_showed_is_killed()) { 33 scratchpad_show_first(); 34 return; 35 } 36 37 if (scratchpad_last_showed->tags != SCRATCHPAD_MASK) { 38 scratchpad_last_showed->tags = SCRATCHPAD_MASK; 39 arrange(selmon); 40 focus(NULL); 41 return; 42 } 43 44 Client *c; 45 46 for (c = selmon->clients; c && c != scratchpad_last_showed; c = c->next); 47 for (c = (c ? c->next : NULL); c && c->tags != SCRATCHPAD_MASK; c = c->next); 48 49 if (c) 50 scratchpad_show_client(c); 51 else 52 scratchpad_show_first(); 53 } 54 55 void 56 scratchpad_show_client(Client* c) 57 { 58 scratchpad_last_showed = c; 59 c->tags = selmon->tagset[selmon->seltags]; 60 focus(c); 61 arrange(selmon); 62 } 63 64 void 65 scratchpad_show_first(void) 66 { 67 Client *c; 68 for (c = selmon->clients; c && c->tags != SCRATCHPAD_MASK; c = c->next); 69 if (c) 70 scratchpad_show_client(c); 71 } 72