From 9acb573ea4f19b26e7cd4ef49fe8eaad9d674038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= Date: Fri, 29 Dec 2023 02:23:18 +0000 Subject: [PATCH] update hide-behind-monocle patch 1ba8580 no one noticed, right? --- hide-behind-monocle/hide-behind-monocle.patch | 418 +++++++++++++----- 1 file changed, 296 insertions(+), 122 deletions(-) diff --git a/hide-behind-monocle/hide-behind-monocle.patch b/hide-behind-monocle/hide-behind-monocle.patch index a3f306a..7bed579 100644 --- a/hide-behind-monocle/hide-behind-monocle.patch +++ b/hide-behind-monocle/hide-behind-monocle.patch @@ -1,154 +1,328 @@ -From c2e65831770a54eebe6eef6e36bfa4716c7e1ada Mon Sep 17 00:00:00 2001 +From 1ba8580b2596c14b9305f1e7cb8d88f54367af59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= -Date: Sat, 8 Jul 2023 17:11:36 -0600 -Subject: [PATCH] port autostart patch from dwm +Date: Sat, 8 Jul 2023 17:25:16 -0600 +Subject: [PATCH] hide behind monocle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -https://dwm.suckless.org/patches/cool_autostart/ Signed-off-by: Leonardo Hernández Hernández --- - config.def.h | 7 +++++++ - dwl.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++----- - 2 files changed, 61 insertions(+), 5 deletions(-) + dwl.c | 84 ++++++++++++++++++++++++++++++++++++----------------------- + 1 file changed, 52 insertions(+), 32 deletions(-) -diff --git a/config.def.h b/config.def.h -index a8ed61d..3585711 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -20,6 +20,13 @@ static const float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0}; /* You can al - /* logging */ - static int log_level = WLR_ERROR; - -+/* Autostart */ -+static const char *const autostart[] = { -+ "wbg", "/path/to/your/image", NULL, -+ NULL /* terminate */ -+}; -+ -+ - static const Rule rules[] = { - /* app_id title tags mask isfloating monitor */ - /* examples: diff --git a/dwl.c b/dwl.c -index edf0cf1..4b7adc8 100644 +index 10d5a5b..07659ea 100644 --- a/dwl.c +++ b/dwl.c -@@ -236,6 +236,7 @@ static void arrange(Monitor *m); - static void arrangelayer(Monitor *m, struct wl_list *list, - struct wlr_box *usable_area, int exclusive); - static void arrangelayers(Monitor *m); -+static void autostartexec(void); - static void axisnotify(struct wl_listener *listener, void *data); - static void buttonpress(struct wl_listener *listener, void *data); - static void chvt(const Arg *arg); -@@ -403,6 +404,9 @@ static xcb_atom_t netatom[NetLast]; - /* attempt to encapsulate suck into one file */ - #include "client.h" +@@ -267,9 +267,10 @@ static Monitor *dirtomon(enum wlr_direction dir); + static void focusclient(Client *c, int lift); + static void focusmon(const Arg *arg); + static void focusstack(const Arg *arg); +-static Client *focustop(Monitor *m); ++static Client *focustop(Monitor *m, int onlytiled); + static void fullscreennotify(struct wl_listener *listener, void *data); + static void handlesig(int signo); ++static void hidebehindmonocle(Monitor *m); + static void incnmaster(const Arg *arg); + static void inputdevice(struct wl_listener *listener, void *data); + static int keybinding(uint32_t mods, xkb_keysym_t sym); +@@ -464,7 +465,7 @@ arrange(Monitor *m) + } + + wlr_scene_node_set_enabled(&m->fullscreen_bg->node, +- (c = focustop(m)) && c->isfullscreen); ++ (c = focustop(m, 0)) && c->isfullscreen); + + strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol)); + +@@ -700,7 +701,7 @@ closemon(Monitor *m) + if (c->mon == m) + setmon(c, selmon, c->tags); + } +- focusclient(focustop(selmon), 1); ++ focusclient(focustop(selmon, 0), 1); + printstatus(); + } + +@@ -1030,7 +1031,7 @@ void + destroydragicon(struct wl_listener *listener, void *data) + { + /* Focus enter isn't sent during drag, so refocus the focused node. */ +- focusclient(focustop(selmon), 1); ++ focusclient(focustop(selmon, 0), 1); + motionnotify(0); + } + +@@ -1066,7 +1067,7 @@ destroylock(SessionLock *lock, int unlock) + + wlr_scene_node_set_enabled(&locked_bg->node, 0); + +- focusclient(focustop(selmon), 0); ++ focusclient(focustop(selmon, 0), 0); + motionnotify(0); + + destroy: +@@ -1095,7 +1096,7 @@ destroylocksurface(struct wl_listener *listener, void *data) + surface = wl_container_of(cur_lock->surfaces.next, surface, link); + client_notify_enter(surface->surface, wlr_seat_get_keyboard(seat)); + } else if (!locked) { +- focusclient(focustop(selmon), 1); ++ focusclient(focustop(selmon, 0), 1); + } else { + wlr_seat_keyboard_clear_focus(seat); + } +@@ -1186,6 +1187,7 @@ focusclient(Client *c, int lift) + wl_list_insert(&fstack, &c->flink); + selmon = c->mon; + c->isurgent = 0; ++ hidebehindmonocle(c->mon); + client_restack_surface(c); + + /* Don't change border color if there is an exclusive focus or we are +@@ -1240,14 +1242,14 @@ focusmon(const Arg *arg) + selmon = dirtomon(arg->i); + while (!selmon->wlr_output->enabled && i++ < nmons); + } +- focusclient(focustop(selmon), 1); ++ focusclient(focustop(selmon, 0), 1); + } -+static pid_t *autostart_pids; -+static size_t autostart_len; -+ - /* function implementations */ void - applybounds(Client *c, struct wlr_box *bbox) -@@ -533,6 +537,27 @@ arrangelayers(Monitor *m) + focusstack(const Arg *arg) + { + /* Focus the next or previous client (in tiling order) on selmon */ +- Client *c, *sel = focustop(selmon); ++ Client *c, *sel = focustop(selmon, 0); + if (!sel || sel->isfullscreen) + return; + if (arg->i > 0) { +@@ -1273,12 +1275,15 @@ focusstack(const Arg *arg) + * will focus the topmost client of this mon, when actually will + * only return that client */ + Client * +-focustop(Monitor *m) ++focustop(Monitor *m, int onlytiled) + { + Client *c; + wl_list_for_each(c, &fstack, flink) { +- if (VISIBLEON(c, m)) ++ if (VISIBLEON(c, m)) { ++ if (onlytiled && c->isfloating) ++ continue; + return c; ++ } + } + return NULL; + } +@@ -1311,6 +1316,22 @@ handlesig(int signo) } } +void -+autostartexec(void) { -+ const char *const *p; -+ size_t i = 0; ++hidebehindmonocle(Monitor *m) ++{ ++ Client *c; ++ if (m && m->lt[m->sellt]->arrange == monocle) { ++ wl_list_for_each(c, &clients, link) ++ wlr_scene_node_set_enabled(&c->scene->node, VISIBLEON(c, m) && c->isfloating); + -+ /* count entries */ -+ for (p = autostart; *p; autostart_len++, p++) -+ while (*++p); ++ c = NULL; + -+ autostart_pids = calloc(autostart_len, sizeof(pid_t)); -+ for (p = autostart; *p; i++, p++) { -+ if ((autostart_pids[i] = fork()) == 0) { -+ setsid(); -+ execvp(*p, (char *const *)p); -+ die("dwl: execvp %s:", *p); -+ } -+ /* skip arguments */ -+ while (*++p); ++ /* Enable top tiled client, fullscreen is considered tiled */ ++ if ((c = focustop(m, 1))) ++ wlr_scene_node_set_enabled(&c->scene->node, 1); + } +} + void - axisnotify(struct wl_listener *listener, void *data) + incnmaster(const Arg *arg) { -@@ -630,11 +655,21 @@ checkidleinhibitor(struct wlr_surface *exclude) +@@ -1449,7 +1470,7 @@ keyrepeat(void *data) void - cleanup(void) + killclient(const Arg *arg) { -+ size_t i; - #ifdef XWAYLAND - wlr_xwayland_destroy(xwayland); - xwayland = NULL; - #endif - wl_display_destroy_clients(dpy); -+ -+ /* kill child processes */ -+ for (i = 0; i < autostart_len; i++) { -+ if (0 < autostart_pids[i]) { -+ kill(autostart_pids[i], SIGTERM); -+ waitpid(autostart_pids[i], NULL, 0); -+ } -+ } -+ - if (child_pid > 0) { - kill(child_pid, SIGTERM); - waitpid(child_pid, NULL, 0); -@@ -1295,18 +1330,31 @@ void - handlesig(int signo) - { - if (signo == SIGCHLD) { --#ifdef XWAYLAND - siginfo_t in; - /* wlroots expects to reap the XWayland process itself, so we - * use WNOWAIT to keep the child waitable until we know it's not - * XWayland. - */ - while (!waitid(P_ALL, 0, &in, WEXITED|WNOHANG|WNOWAIT) && in.si_pid -- && (!xwayland || in.si_pid != xwayland->server->pid)) -- waitpid(in.si_pid, NULL, 0); --#else -- while (waitpid(-1, NULL, WNOHANG) > 0); -+#ifdef XWAYLAND -+ && (!xwayland || in.si_pid != xwayland->server->pid) - #endif -+ ) { -+ pid_t *p, *lim; -+ waitpid(in.si_pid, NULL, 0); -+ if (in.si_pid == child_pid) -+ child_pid = -1; -+ if (!(p = autostart_pids)) -+ continue; -+ lim = &p[autostart_len]; -+ -+ for (; p < lim; p++) { -+ if (*p == in.si_pid) { -+ *p = -1; -+ break; -+ } -+ } -+ } - } else if (signo == SIGINT || signo == SIGTERM) { - quit(NULL); +- Client *sel = focustop(selmon); ++ Client *sel = focustop(selmon, 0); + if (sel) + client_send_close(sel); + } +@@ -1584,8 +1605,7 @@ monocle(Monitor *m) } -@@ -1966,6 +2014,7 @@ run(char *startup_cmd) - die("startup: backend_start"); + if (n) + snprintf(m->ltsymbol, LENGTH(m->ltsymbol), "[%d]", n); +- if ((c = focustop(m))) +- wlr_scene_node_raise_to_top(&c->scene->node); ++ hidebehindmonocle(m); + } - /* Now that the socket exists and the backend is started, run the startup command */ -+ autostartexec(); - if (startup_cmd) { - int piperw[2]; - if (pipe(piperw) < 0) + void +@@ -1813,7 +1833,7 @@ printstatus(void) + if (c->isurgent) + urg |= c->tags; + } +- if ((c = focustop(m))) { ++ if ((c = focustop(m, 0))) { + title = client_get_title(c); + appid = client_get_appid(c); + printf("%s title %s\n", m->wlr_output->name, title ? title : broken); +@@ -2129,7 +2149,7 @@ setmon(Client *c, Monitor *m, uint32_t newtags) + setfullscreen(c, c->isfullscreen); /* This will call arrange(c->mon) */ + setfloating(c, c->isfloating); + } +- focusclient(focustop(selmon), 1); ++ focusclient(focustop(selmon, 0), 1); + } + + void +@@ -2431,12 +2451,12 @@ startdrag(struct wl_listener *listener, void *data) + void + tag(const Arg *arg) + { +- Client *sel = focustop(selmon); ++ Client *sel = focustop(selmon, 0); + if (!sel || (arg->ui & TAGMASK) == 0) + return; + + sel->tags = arg->ui & TAGMASK; +- focusclient(focustop(selmon), 1); ++ focusclient(focustop(selmon, 0), 1); + arrange(selmon); + printstatus(); + } +@@ -2444,7 +2464,7 @@ tag(const Arg *arg) + void + tagmon(const Arg *arg) + { +- Client *sel = focustop(selmon); ++ Client *sel = focustop(selmon, 0); + if (sel) + setmon(sel, dirtomon(arg->i), 0); + } +@@ -2485,7 +2505,7 @@ tile(Monitor *m) + void + togglefloating(const Arg *arg) + { +- Client *sel = focustop(selmon); ++ Client *sel = focustop(selmon, 0); + /* return if fullscreen */ + if (sel && !sel->isfullscreen) + setfloating(sel, !sel->isfloating); +@@ -2494,7 +2514,7 @@ togglefloating(const Arg *arg) + void + togglefullscreen(const Arg *arg) + { +- Client *sel = focustop(selmon); ++ Client *sel = focustop(selmon, 0); + if (sel) + setfullscreen(sel, !sel->isfullscreen); + } +@@ -2503,12 +2523,12 @@ void + toggletag(const Arg *arg) + { + uint32_t newtags; +- Client *sel = focustop(selmon); ++ Client *sel = focustop(selmon, 0); + if (!sel || !(newtags = sel->tags ^ (arg->ui & TAGMASK))) + return; + + sel->tags = newtags; +- focusclient(focustop(selmon), 1); ++ focusclient(focustop(selmon, 0), 1); + arrange(selmon); + printstatus(); + } +@@ -2521,7 +2541,7 @@ toggleview(const Arg *arg) + return; + + selmon->tagset[selmon->seltags] = newtagset; +- focusclient(focustop(selmon), 1); ++ focusclient(focustop(selmon, 0), 1); + arrange(selmon); + printstatus(); + } +@@ -2545,7 +2565,7 @@ unmaplayersurfacenotify(struct wl_listener *listener, void *data) + if (l->layer_surface->output && (l->mon = l->layer_surface->output->data)) + arrangelayers(l->mon); + if (l->layer_surface->surface == seat->keyboard_state.focused_surface) +- focusclient(focustop(selmon), 1); ++ focusclient(focustop(selmon, 0), 1); + motionnotify(0); + } + +@@ -2562,7 +2582,7 @@ unmapnotify(struct wl_listener *listener, void *data) + if (client_is_unmanaged(c)) { + if (c == exclusive_focus) { + exclusive_focus = NULL; +- focusclient(focustop(selmon), 1); ++ focusclient(focustop(selmon, 0), 1); + } + } else { + wl_list_remove(&c->link); +@@ -2643,7 +2663,7 @@ updatemons(struct wl_listener *listener, void *data) + /* Don't move clients to the left output when plugging monitors */ + arrange(m); + /* make sure fullscreen clients have the right size */ +- if ((c = focustop(m)) && c->isfullscreen) ++ if ((c = focustop(m, 0)) && c->isfullscreen) + resize(c, m->m, 0); + + /* Try to re-set the gamma LUT when updating monitors, +@@ -2659,7 +2679,7 @@ updatemons(struct wl_listener *listener, void *data) + if (!c->mon && client_surface(c)->mapped) + setmon(c, selmon, c->tags); + } +- focusclient(focustop(selmon), 1); ++ focusclient(focustop(selmon, 0), 1); + if (selmon->lock_surface) { + client_notify_enter(selmon->lock_surface->surface, + wlr_seat_get_keyboard(seat)); +@@ -2681,7 +2701,7 @@ void + updatetitle(struct wl_listener *listener, void *data) + { + Client *c = wl_container_of(listener, c, set_title); +- if (c == focustop(c->mon)) ++ if (c == focustop(c->mon, 0)) + printstatus(); + } + +@@ -2691,7 +2711,7 @@ urgent(struct wl_listener *listener, void *data) + struct wlr_xdg_activation_v1_request_activate_event *event = data; + Client *c = NULL; + toplevel_from_wlr_surface(event->surface, &c, NULL); +- if (!c || c == focustop(selmon)) ++ if (!c || c == focustop(selmon, 0)) + return; + + c->isurgent = 1; +@@ -2709,7 +2729,7 @@ view(const Arg *arg) + selmon->seltags ^= 1; /* toggle sel tagset */ + if (arg->ui & TAGMASK) + selmon->tagset[selmon->seltags] = arg->ui & TAGMASK; +- focusclient(focustop(selmon), 1); ++ focusclient(focustop(selmon, 0), 1); + arrange(selmon); + printstatus(); + } +@@ -2767,7 +2787,7 @@ xytonode(double x, double y, struct wlr_surface **psurface, + void + zoom(const Arg *arg) + { +- Client *c, *sel = focustop(selmon); ++ Client *c, *sel = focustop(selmon, 0); + + if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange || sel->isfloating) + return; +@@ -2880,7 +2900,7 @@ sethints(struct wl_listener *listener, void *data) + { + Client *c = wl_container_of(listener, c, set_hints); + struct wlr_surface *surface = client_surface(c); +- if (c == focustop(selmon)) ++ if (c == focustop(selmon, 0)) + return; + + c->isurgent = xcb_icccm_wm_hints_get_urgency(c->surface.xwayland->hints); -- 2.43.0