1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
/* ************************************************************************** */
/* @@@ @@@@@@@@ */
/* @@@ @@@@@@@@@@ */
/* @@! @@! @@@@ */
/* !@! !@! @!@!@ */
/* simple_scratchpad.c @!! @!@ @! !@! */
/* !!! !@!!! !!! */
/* By: julmajustus <julmajustus@tutanota.com> !!: !!:! !!! */
/* ::! :!: !:! */
/* Created: 2024/12/19 19:35:02 by jmakkone :: ::::::: :: */
/* Updated: 2026/05/20 23:58:16 by julmajustus : : : : : : */
/* */
/* ************************************************************************** */
void draw_scratchpad(void) {
Client *c;
Monitor *m = selmon;
if (scratchpad_visible[scratchpad_sel]) {
wl_list_for_each(c, &scratchpad_clients[scratchpad_sel], link_temp) {
c->mon = m;
c->tags = m->tagset[m->seltags];
arrange(m);
focusclient(c, 1);
}
} else {
wl_list_for_each(c, &scratchpad_clients[scratchpad_sel], link_temp) {
c->tags = 0;
focusclient(focustop(m), 1);
arrange(m);
}
}
}
void
addscratchpad(const Arg *arg)
{
Client *cc, *c = focustop(selmon);
Monitor *m = selmon;
if (!c)
return;
/* Check if the added client is already a scratchpad client */
for (int i = 0; i < SCRATCHPAD_COUNT; i++) {
wl_list_for_each(cc, &scratchpad_clients[i], link_temp) {
if (cc == c)
return;
}
}
if (!c->isfloating) {
setfloating(c, 1);
}
scratchpad_visible[scratchpad_sel] = 0;
draw_scratchpad();
wl_list_insert(&scratchpad_clients[scratchpad_sel], &c->link_temp);
c->tags = 0;
arrange(m);
focusclient(focustop(m), 1);
arrange(m);
}
void
togglescratchpad(const Arg *arg)
{
scratchpad_visible[scratchpad_sel] = !scratchpad_visible[scratchpad_sel];
draw_scratchpad();
}
void
removescratchpad(const Arg *arg)
{
Client *sc, *c = focustop(selmon);
Monitor *m = selmon;
if (!c)
return;
for (int i = 0; i < SCRATCHPAD_COUNT; i++) {
/* Check if c is in scratchpad_clients */
wl_list_for_each(sc, &scratchpad_clients[i], link_temp) {
if (sc == c) {
wl_list_remove(&sc->link_temp);
setfloating(sc, 0);
arrange(m);
focusclient(sc, 1);
return;
}
}
}
}
void
setscratchpad(const Arg *arg)
{
int idx = arg->i;
if (idx < 0)
idx = 0;
else if (idx >= SCRATCHPAD_COUNT)
idx = SCRATCHPAD_COUNT - 1;
scratchpad_sel = idx;
}
|