2020-02-09 14:55:40 +01:00
|
|
|
static Client * scratchpad_last_showed = NULL;
|
|
|
|
|
|
|
|
static void scratchpad_hide ()
|
|
|
|
{
|
2020-06-05 11:23:02 +02:00
|
|
|
if (selmon->sel)
|
2020-02-09 14:55:40 +01:00
|
|
|
{
|
2020-06-05 11:23:02 +02:00
|
|
|
selmon->sel->tags = SCRATCHPAD_MASK;
|
2020-02-09 14:55:40 +01:00
|
|
|
focus(NULL);
|
|
|
|
arrange(selmon);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static _Bool scratchpad_last_showed_is_killed (void)
|
|
|
|
{
|
|
|
|
_Bool killed = 1;
|
2020-06-05 11:23:02 +02:00
|
|
|
for (Client * c = selmon->clients; c != NULL; c = c->next)
|
2020-02-09 14:55:40 +01:00
|
|
|
{
|
|
|
|
if (c == scratchpad_last_showed)
|
|
|
|
{
|
|
|
|
killed = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return killed;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void scratchpad_remove ()
|
|
|
|
{
|
2020-06-05 11:23:02 +02:00
|
|
|
if (selmon->sel && scratchpad_last_showed != NULL && selmon->sel == scratchpad_last_showed)
|
2020-02-09 14:55:40 +01:00
|
|
|
scratchpad_last_showed = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void scratchpad_show ()
|
|
|
|
{
|
|
|
|
if (scratchpad_last_showed == NULL || scratchpad_last_showed_is_killed ())
|
|
|
|
scratchpad_show_first ();
|
|
|
|
else
|
|
|
|
{
|
2020-06-05 11:23:02 +02:00
|
|
|
if (scratchpad_last_showed->tags != SCRATCHPAD_MASK)
|
2020-02-09 14:55:40 +01:00
|
|
|
{
|
2020-06-05 11:23:02 +02:00
|
|
|
scratchpad_last_showed->tags = SCRATCHPAD_MASK;
|
2020-02-09 14:55:40 +01:00
|
|
|
focus(NULL);
|
|
|
|
arrange(selmon);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_Bool found_current = 0;
|
|
|
|
_Bool found_next = 0;
|
2020-06-05 11:23:02 +02:00
|
|
|
for (Client * c = selmon->clients; c != NULL; c = c->next)
|
2020-02-09 14:55:40 +01:00
|
|
|
{
|
|
|
|
if (found_current == 0)
|
|
|
|
{
|
|
|
|
if (c == scratchpad_last_showed)
|
|
|
|
{
|
|
|
|
found_current = 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-06-05 11:23:02 +02:00
|
|
|
if (c->tags == SCRATCHPAD_MASK)
|
2020-02-09 14:55:40 +01:00
|
|
|
{
|
|
|
|
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;
|
2020-06-05 11:23:02 +02:00
|
|
|
c->tags = selmon->tagset[selmon->seltags];
|
2020-02-09 14:55:40 +01:00
|
|
|
focus(c);
|
|
|
|
arrange(selmon);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void scratchpad_show_first (void)
|
|
|
|
{
|
2020-06-05 11:23:02 +02:00
|
|
|
for (Client * c = selmon->clients; c != NULL; c = c->next)
|
2020-02-09 14:55:40 +01:00
|
|
|
{
|
2020-06-05 11:23:02 +02:00
|
|
|
if (c->tags == SCRATCHPAD_MASK)
|
2020-02-09 14:55:40 +01:00
|
|
|
{
|
|
|
|
scratchpad_show_client (c);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|