From 2094b25a296b4a31e2a0257d829d4e88a5f53399 Mon Sep 17 00:00:00 2001 From: Jakub Date: Thu, 11 Jul 2024 02:52:04 -0400 Subject: [PATCH] always on top patch --- config.def.h | 4 + dwm.c | 39 +++++++- patches/functions/alwaysontopall-6.2.diff | 103 ++++++++++++++++++++++ 3 files changed, 143 insertions(+), 3 deletions(-) create mode 100644 patches/functions/alwaysontopall-6.2.diff diff --git a/config.def.h b/config.def.h index 15be2bd..275acd9 100644 --- a/config.def.h +++ b/config.def.h @@ -70,6 +70,9 @@ static const Rule rules[] = { { NULL, NULL, "Event Tester", 0, 0, 0, 0, 1, -1 }, /* xev */ }; +static const char topicon[128] = "\uf435"; +/* icon to indicate always on top floating windows */ + /* window following */ #define WFACTIVE '>' #define WFINACTIVE 'v' @@ -132,6 +135,7 @@ static const Key keys[] = { { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, + { MODKEY|ShiftMask, XK_t, togglealwaysontop, {0} }, { MODKEY, XK_Down, moveresize, {.v = "0x 25y 0w 0h" } }, { MODKEY, XK_Up, moveresize, {.v = "0x -25y 0w 0h" } }, { MODKEY, XK_Right, moveresize, {.v = "25x 0y 0w 0h" } }, diff --git a/dwm.c b/dwm.c index ff994bc..f731ab6 100644 --- a/dwm.c +++ b/dwm.c @@ -102,7 +102,7 @@ struct Client { int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid; int bw, oldbw; unsigned int tags; - int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isfakefullscreen, isterminal, noswallow; + int isfixed, isfloating, isalwaysontop, isurgent, neverfocus, oldstate, isfullscreen, isfakefullscreen, isterminal, noswallow; pid_t pid; Client *next; Client *snext; @@ -262,6 +262,7 @@ static void togglefakefullscr(const Arg *arg); static void togglefullscr(const Arg *arg); static void toggleextrabar(const Arg *arg); static void togglefloating(const Arg *arg); +static void togglealwaysontop(const Arg *arg); static void togglefollow(const Arg *arg); static void toggletag(const Arg *arg); static void toggleview(const Arg *arg); @@ -1003,9 +1004,17 @@ drawbar(Monitor *m) } remainder--; } - mid = (tabw - (int)TEXTW(c->name)) / 2; + + char name[512]; + + if (c->isalwaysontop && c->isfloating) + snprintf(name, sizeof name, "%s %s", topicon, c->name); + else + snprintf(name, sizeof name, c->name); + + mid = (tabw - (int)TEXTW(name)) / 2; mid = mid >= lrpad / 2 ? mid : lrpad / 2; - drw_text(drw, x, 0, tabw - 2 * sp, bh, mid, c->name, 0); + drw_text(drw, x, 0, tabw - 2 * sp, bh, mid, name, 0); if (!HIDDEN(c)) { if (m->sel == c) { @@ -2178,6 +2187,16 @@ restack(Monitor *m) return; if (m->sel->isfloating || !m->lt[m->sellt]->arrange) XRaiseWindow(dpy, m->sel->win); + + /* raise the aot window */ + for(Monitor *m_search = mons; m_search; m_search = m_search->next){ + for(c = m_search->clients; c; c = c->next){ + if(c->isalwaysontop){ + XRaiseWindow(dpy, c->win); + } + } + } + if (m->lt[m->sellt]->arrange) { wc.stack_mode = Below; wc.sibling = m->barwin; @@ -2724,6 +2743,7 @@ togglefloating(const Arg *arg) if (selmon->sel->isfullscreen && !selmon->sel->isfakefullscreen) /* no support for fullscreen windows */ return; + selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed; if (selmon->sel->isfloating) /* restore last known float dimensions */ @@ -2743,6 +2763,19 @@ togglefloating(const Arg *arg) arrange(selmon); } +void +togglealwaysontop(const Arg *arg) +{ + Client *c; + + if (!selmon->sel) + return; + if (selmon->sel->isfullscreen) + return; + selmon->sel->isalwaysontop = !selmon->sel->isalwaysontop; + arrange(selmon); +} + void togglefakefullscr(const Arg *arg) { diff --git a/patches/functions/alwaysontopall-6.2.diff b/patches/functions/alwaysontopall-6.2.diff new file mode 100644 index 0000000..fae64d2 --- /dev/null +++ b/patches/functions/alwaysontopall-6.2.diff @@ -0,0 +1,103 @@ +From 9cd160c4ba9c345c24644a7da77cc4f04fc93c4e Mon Sep 17 00:00:00 2001 +From: Matt Quintanilla +Date: Fri, 13 Oct 2023 20:11:08 +0100 +Subject: [PATCH] alwaysontop for all + +--- + config.def.h | 1 + + dwm.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- + 2 files changed, 44 insertions(+), 2 deletions(-) + +diff --git a/config.def.h b/config.def.h +index 1c0b587..c3c7edd 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -78,6 +78,7 @@ static Key keys[] = { + { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, + { MODKEY, XK_space, setlayout, {0} }, + { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, ++ { MODKEY|ShiftMask, XK_space, togglealwaysontop, {0} }, + { MODKEY, XK_0, view, {.ui = ~0 } }, + { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, + { MODKEY, XK_comma, focusmon, {.i = -1 } }, +diff --git a/dwm.c b/dwm.c +index 4465af1..8d54b26 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -92,7 +92,7 @@ struct Client { + int basew, baseh, incw, inch, maxw, maxh, minw, minh; + int bw, oldbw; + unsigned int tags; +- int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; ++ int isfixed, iscentered, isfloating, isalwaysontop, isurgent, neverfocus, oldstate, isfullscreen; + Client *next; + Client *snext; + Monitor *mon; +@@ -211,6 +211,7 @@ static void tagmon(const Arg *arg); + static void tile(Monitor *); + static void togglebar(const Arg *arg); + static void togglefloating(const Arg *arg); ++static void togglealwaysontop(const Arg *arg); + static void toggletag(const Arg *arg); + static void toggleview(const Arg *arg); + static void unfocus(Client *c, int setfocus); +@@ -732,8 +733,11 @@ drawbar(Monitor *m) + if (m->sel) { + drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); + drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); +- if (m->sel->isfloating) ++ if (m->sel->isfloating) { + drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); ++ if (m->sel->isalwaysontop) ++ drw_rect(drw, x + boxs, bh - boxw, boxw, boxw, 0, 0); ++ } + } else { + drw_setscheme(drw, scheme[SchemeNorm]); + drw_rect(drw, x, 0, w, bh, 1, 1); +@@ -1356,6 +1360,17 @@ restack(Monitor *m) + return; + if (m->sel->isfloating || !m->lt[m->sellt]->arrange) + XRaiseWindow(dpy, m->sel->win); ++ ++ /* raise the aot window */ ++ for(Monitor *m_search = mons; m_search; m_search = m_search->next){ ++ for(c = m_search->clients; c; c = c->next){ ++ if(c->isalwaysontop){ ++ XRaiseWindow(dpy, c->win); ++ } ++ } ++ } ++ + if (m->lt[m->sellt]->arrange) { + wc.stack_mode = Below; + wc.sibling = m->barwin; +@@ -1716,6 +1731,32 @@ togglefloating(const Arg *arg) + if (selmon->sel->isfloating) + resize(selmon->sel, selmon->sel->x, selmon->sel->y, + selmon->sel->w, selmon->sel->h, 0); ++ else ++ selmon->sel->isalwaysontop = 0; /* disabled, turn this off too */ ++ arrange(selmon); ++} ++ ++void ++togglealwaysontop(const Arg *arg) ++{ ++ if (!selmon->sel) ++ return; ++ if (selmon->sel->isfullscreen) ++ return; ++ ++ if(selmon->sel->isalwaysontop){ ++ selmon->sel->isalwaysontop = 0; ++ }else{ ++ c->isalwaysontop = 0; ++ ++ } ++ + arrange(selmon); + } + +-- +2.31.1 +