blob: 9d89ac93d042de984c7e18093f4449cb9a5cb761 (
plain)
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
|
static Client * scratchpad_last_showed = NULL;
static void scratchpad_hide ()
{
if (selmon -> sel)
{
selmon -> sel -> tags = scratchpad_mask;
focus(NULL);
arrange(selmon);
}
}
static _Bool scratchpad_last_showed_is_killed (void)
{
_Bool killed = 1;
for (Client * c = selmon -> clients; c != NULL; c = c -> next)
{
if (c == scratchpad_last_showed)
{
killed = 0;
break;
}
}
return killed;
}
static void scratchpad_remove ()
{
if (selmon -> sel && scratchpad_last_showed != NULL && selmon -> sel == scratchpad_last_showed)
scratchpad_last_showed = NULL;
}
static void scratchpad_show ()
{
if (scratchpad_last_showed == NULL || scratchpad_last_showed_is_killed ())
scratchpad_show_first ();
else
{
if (scratchpad_last_showed -> tags != scratchpad_mask)
{
scratchpad_last_showed -> tags = scratchpad_mask;
focus(NULL);
arrange(selmon);
}
else
{
_Bool found_current = 0;
_Bool found_next = 0;
for (Client * c = selmon -> clients; c != NULL; c = c -> next)
{
if (found_current == 0)
{
if (c == scratchpad_last_showed)
{
found_current = 1;
continue;
}
}
else
{
if (c -> tags == scratchpad_mask)
{
found_next = 1;
scratchpad_show_client (c);
break;
}
}
}
if (found_next == 0) scratchpad_show_first ();
}
}
}
static void scratchpad_show_client (Client * c)
{
scratchpad_last_showed = c;
c -> tags = selmon->tagset[selmon->seltags];
focus(c);
arrange(selmon);
}
static void scratchpad_show_first (void)
{
for (Client * c = selmon -> clients; c != NULL; c = c -> next)
{
if (c -> tags == scratchpad_mask)
{
scratchpad_show_client (c);
break;
}
}
}
|