From 5c3e67b987ead6efb6201850012c5bad7120d26c Mon Sep 17 00:00:00 2001 From: mac Date: Tue, 26 Aug 2025 22:46:29 -0400 Subject: add simple_scratchpad-v0.7.patch --- simple_scratchpad.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 simple_scratchpad.c (limited to 'simple_scratchpad.c') diff --git a/simple_scratchpad.c b/simple_scratchpad.c new file mode 100644 index 0000000..26d6b66 --- /dev/null +++ b/simple_scratchpad.c @@ -0,0 +1,68 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* simple_scratchpad.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jmakkone +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/12/19 19:35:02 by jmakkone #+# #+# */ +/* Updated: 2025/01/04 13:35:50 by jmakkone ### ########.fr */ +/* */ +/* ************************************************************************** */ + +void +addscratchpad(const Arg *arg) +{ + Client *cc, *c = focustop(selmon); + + if (!c) + return; + /* Check if the added client is already a scratchpad client */ + wl_list_for_each(cc, &scratchpad_clients, link_temp) { + if (cc == c) + return; + } + if (!c->isfloating) { + setfloating(c, 1); + } + wl_list_insert(&scratchpad_clients, &c->link_temp); +} + +void +togglescratchpad(const Arg *arg) +{ + Client *c; + Monitor *m = selmon; + + scratchpad_visible = !scratchpad_visible; + if (scratchpad_visible) { + wl_list_for_each(c, &scratchpad_clients, link_temp) { + c->mon = m; + c->tags = m->tagset[m->seltags]; + arrange(m); + focusclient(c, 1); + } + } else { + wl_list_for_each(c, &scratchpad_clients, link_temp) { + c->tags = 0; + focusclient(focustop(m), 1); + arrange(m); + } + } +} + +void +removescratchpad(const Arg *arg) +{ + Client *sc, *c = focustop(selmon); + + if (c && wl_list_length(&scratchpad_clients) > 0) { + /* Check if c is in scratchpad_clients */ + wl_list_for_each(sc, &scratchpad_clients, link_temp) { + if (sc == c) { + wl_list_remove(&c->link_temp); + break; + } + } + } +} -- cgit v1.2.3