mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
scratchpad_alt_1: upgrading and simplifying patch ref. #124
This commit is contained in:
parent
df9533f1eb
commit
9edce6b606
5
dwm.c
5
dwm.c
@ -4155,6 +4155,11 @@ unmanage(Client *c, int destroyed)
|
|||||||
}
|
}
|
||||||
#endif // XKB_PATCH
|
#endif // XKB_PATCH
|
||||||
|
|
||||||
|
#if SCRATCHPAD_ALT_1_PATCH
|
||||||
|
if (scratchpad_last_showed == c)
|
||||||
|
scratchpad_last_showed = NULL;
|
||||||
|
#endif // SCRATCHPAD_ALT_1_PATCH
|
||||||
|
|
||||||
free(c);
|
free(c);
|
||||||
#if SWALLOW_PATCH
|
#if SWALLOW_PATCH
|
||||||
if (s)
|
if (s)
|
||||||
|
@ -1,77 +1,59 @@
|
|||||||
static Client * scratchpad_last_showed = NULL;
|
static Client * scratchpad_last_showed = NULL;
|
||||||
|
|
||||||
static void scratchpad_hide ()
|
void
|
||||||
|
scratchpad_hide()
|
||||||
{
|
{
|
||||||
if (selmon->sel)
|
if (selmon->sel) {
|
||||||
{
|
|
||||||
selmon->sel->tags = SCRATCHPAD_MASK;
|
selmon->sel->tags = SCRATCHPAD_MASK;
|
||||||
|
selmon->sel->isfloating = 1;
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static _Bool scratchpad_last_showed_is_killed (void)
|
_Bool
|
||||||
|
scratchpad_last_showed_is_killed(void)
|
||||||
{
|
{
|
||||||
_Bool killed = 1;
|
Client *c;
|
||||||
for (Client * c = selmon->clients; c != NULL; c = c->next)
|
for (c = selmon->clients; c && c != scratchpad_last_showed; c = c->next);
|
||||||
{
|
return (c == NULL);
|
||||||
if (c == scratchpad_last_showed)
|
|
||||||
{
|
|
||||||
killed = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return killed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void scratchpad_remove ()
|
void
|
||||||
|
scratchpad_remove()
|
||||||
{
|
{
|
||||||
if (selmon->sel && scratchpad_last_showed != NULL && selmon->sel == scratchpad_last_showed)
|
if (selmon->sel && scratchpad_last_showed != NULL && selmon->sel == scratchpad_last_showed)
|
||||||
scratchpad_last_showed = NULL;
|
scratchpad_last_showed = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void scratchpad_show ()
|
void
|
||||||
|
scratchpad_show()
|
||||||
{
|
{
|
||||||
if (scratchpad_last_showed == NULL || scratchpad_last_showed_is_killed ())
|
if (scratchpad_last_showed == NULL || scratchpad_last_showed_is_killed()) {
|
||||||
scratchpad_show_first ();
|
scratchpad_show_first();
|
||||||
else
|
return;
|
||||||
{
|
|
||||||
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 ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (scratchpad_last_showed->tags != SCRATCHPAD_MASK) {
|
||||||
|
scratchpad_last_showed->tags = SCRATCHPAD_MASK;
|
||||||
|
focus(NULL);
|
||||||
|
arrange(selmon);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void scratchpad_show_client (Client * c)
|
void
|
||||||
|
scratchpad_show_client(Client* c)
|
||||||
{
|
{
|
||||||
scratchpad_last_showed = c;
|
scratchpad_last_showed = c;
|
||||||
c->tags = selmon->tagset[selmon->seltags];
|
c->tags = selmon->tagset[selmon->seltags];
|
||||||
@ -79,14 +61,11 @@ static void scratchpad_show_client (Client * c)
|
|||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void scratchpad_show_first (void)
|
void
|
||||||
|
scratchpad_show_first(void)
|
||||||
{
|
{
|
||||||
for (Client * c = selmon->clients; c != NULL; c = c->next)
|
Client *c;
|
||||||
{
|
for (c = selmon->clients; c && c->tags != SCRATCHPAD_MASK; c = c->next);
|
||||||
if (c->tags == SCRATCHPAD_MASK)
|
if (c)
|
||||||
{
|
scratchpad_show_client(c);
|
||||||
scratchpad_show_client (c);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
#define SCRATCHPAD_MASK (1u << NUMTAGS)
|
#define SCRATCHPAD_MASK (1u << NUMTAGS)
|
||||||
|
|
||||||
static void scratchpad_hide ();
|
static void scratchpad_hide();
|
||||||
static _Bool scratchpad_last_showed_is_killed (void);
|
static _Bool scratchpad_last_showed_is_killed(void);
|
||||||
static void scratchpad_remove ();
|
static void scratchpad_remove();
|
||||||
static void scratchpad_show ();
|
static void scratchpad_show();
|
||||||
static void scratchpad_show_client (Client * c);
|
static void scratchpad_show_client(Client *c);
|
||||||
static void scratchpad_show_first (void);
|
static void scratchpad_show_first(void);
|
Loading…
Reference in New Issue
Block a user