2020-02-09 13:55:40 +00:00
|
|
|
static Client * scratchpad_last_showed = NULL;
|
|
|
|
|
2021-05-06 09:05:48 +00:00
|
|
|
void
|
|
|
|
scratchpad_hide()
|
2020-02-09 13:55:40 +00:00
|
|
|
{
|
2021-05-06 09:05:48 +00:00
|
|
|
if (selmon->sel) {
|
2020-06-05 09:23:02 +00:00
|
|
|
selmon->sel->tags = SCRATCHPAD_MASK;
|
2021-05-06 09:05:48 +00:00
|
|
|
selmon->sel->isfloating = 1;
|
2020-02-09 13:55:40 +00:00
|
|
|
arrange(selmon);
|
2023-06-27 14:07:13 +00:00
|
|
|
focus(NULL);
|
2020-02-09 13:55:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-06 09:05:48 +00:00
|
|
|
_Bool
|
|
|
|
scratchpad_last_showed_is_killed(void)
|
2020-02-09 13:55:40 +00:00
|
|
|
{
|
2021-05-06 09:05:48 +00:00
|
|
|
Client *c;
|
|
|
|
for (c = selmon->clients; c && c != scratchpad_last_showed; c = c->next);
|
|
|
|
return (c == NULL);
|
2020-02-09 13:55:40 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 09:05:48 +00:00
|
|
|
void
|
|
|
|
scratchpad_remove()
|
2020-02-09 13:55:40 +00:00
|
|
|
{
|
2020-06-05 09:23:02 +00:00
|
|
|
if (selmon->sel && scratchpad_last_showed != NULL && selmon->sel == scratchpad_last_showed)
|
2020-02-09 13:55:40 +00:00
|
|
|
scratchpad_last_showed = NULL;
|
|
|
|
}
|
|
|
|
|
2021-05-06 09:05:48 +00:00
|
|
|
void
|
|
|
|
scratchpad_show()
|
2020-02-09 13:55:40 +00:00
|
|
|
{
|
2021-05-06 09:05:48 +00:00
|
|
|
if (scratchpad_last_showed == NULL || scratchpad_last_showed_is_killed()) {
|
|
|
|
scratchpad_show_first();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scratchpad_last_showed->tags != SCRATCHPAD_MASK) {
|
|
|
|
scratchpad_last_showed->tags = SCRATCHPAD_MASK;
|
|
|
|
arrange(selmon);
|
2023-06-27 14:07:13 +00:00
|
|
|
focus(NULL);
|
2021-05-06 09:05:48 +00:00
|
|
|
return;
|
2020-02-09 13:55:40 +00:00
|
|
|
}
|
2021-05-06 09:05:48 +00:00
|
|
|
|
|
|
|
Client *c;
|
|
|
|
|
|
|
|
for (c = selmon->clients; c && c != scratchpad_last_showed; c = c->next);
|
|
|
|
for (c = (c ? c->next : NULL); c && c->tags != SCRATCHPAD_MASK; c = c->next);
|
|
|
|
|
|
|
|
if (c)
|
|
|
|
scratchpad_show_client(c);
|
|
|
|
else
|
|
|
|
scratchpad_show_first();
|
2020-02-09 13:55:40 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 09:05:48 +00:00
|
|
|
void
|
|
|
|
scratchpad_show_client(Client* c)
|
2020-02-09 13:55:40 +00:00
|
|
|
{
|
|
|
|
scratchpad_last_showed = c;
|
2020-06-05 09:23:02 +00:00
|
|
|
c->tags = selmon->tagset[selmon->seltags];
|
2020-02-09 13:55:40 +00:00
|
|
|
focus(c);
|
|
|
|
arrange(selmon);
|
|
|
|
}
|
|
|
|
|
2021-05-06 09:05:48 +00:00
|
|
|
void
|
|
|
|
scratchpad_show_first(void)
|
2020-02-09 13:55:40 +00:00
|
|
|
{
|
2021-05-06 09:05:48 +00:00
|
|
|
Client *c;
|
|
|
|
for (c = selmon->clients; c && c->tags != SCRATCHPAD_MASK; c = c->next);
|
|
|
|
if (c)
|
|
|
|
scratchpad_show_client(c);
|
2021-06-14 05:16:17 +00:00
|
|
|
}
|
|
|
|
|