Skip to content

Commit 1c8c21c

Browse files
committed
Adding the alwaysontop patch ref. #452
1 parent 4b6e402 commit 1c8c21c

File tree

9 files changed

+76
-1
lines changed

9 files changed

+76
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/X9IiSSM6
1919
2020
### Changelog:
2121
22+
2025-06-15 - Added the always on top patch
23+
2224
2025-02-25 - Added the xresources patch
2325
2426
2024-10-30 - Added the border rule patch
@@ -268,6 +270,9 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/X9IiSSM6
268270
- [~alwaysfullscreen~](https://dwm.suckless.org/patches/alwaysfullscreen/)
269271
- ~prevents the focus to drift from the active fullscreen client when using focusstack\(\)~
270272
273+
- [alwaysontop](https://dwm.suckless.org/patches/alwaysontop/)
274+
- allows for floating windows to be toggled to be always on top of other windows
275+
271276
- [anybar](https://dwm.suckless.org/patches/anybar/)
272277
- enables dwm to manage external status bars such as lemonbar and polybar
273278
- dwm treats the external bar as it would its own, so all regular dwm commands such as

config.def.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ static int floatindicatortype = INDICATOR_TOP_LEFT_SQUARE;
150150
static int fakefsindicatortype = INDICATOR_PLUS;
151151
static int floatfakefsindicatortype = INDICATOR_PLUS_AND_LARGER_SQUARE;
152152
#endif // FAKEFULLSCREEN_CLIENT_PATCH
153+
#if ALWAYSONTOP_PATCH
154+
static int aotindicatortype = INDICATOR_TOP_LEFT_LARGER_SQUARE;
155+
#endif // ALWAYSONTOP_PATCH
153156
#if ONLYQUITONEMPTY_PATCH
154157
static const int quit_empty_window_count = 0; /* only allow dwm to quit if no (<= count) windows are open */
155158
#endif // ONLYQUITONEMPTY_PATCH
@@ -1209,6 +1212,9 @@ static const Key keys[] = {
12091212
#endif // FLEXTILE_DELUXE_LAYOUT
12101213
{ MODKEY, XK_space, setlayout, {0} },
12111214
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
1215+
#if ALWAYSONTOP_PATCH
1216+
{ MODKEY|ShiftMask, XK_space, togglealwaysontop, {0} },
1217+
#endif // ALWAYSONTOP_PATCH
12121218
#if MAXIMIZE_PATCH
12131219
{ MODKEY|ControlMask|ShiftMask, XK_h, togglehorizontalmax, {0} },
12141220
{ MODKEY|ControlMask|ShiftMask, XK_l, togglehorizontalmax, {0} },

dwm.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,9 @@ struct Client {
363363
unsigned int switchtag;
364364
#endif // SWITCHTAG_PATCH
365365
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
366+
#if ALWAYSONTOP_PATCH
367+
int alwaysontop;
368+
#endif // ALWAYSONTOP_PATCH
366369
#if !FAKEFULLSCREEN_PATCH && FAKEFULLSCREEN_CLIENT_PATCH
367370
int fakefullscreen;
368371
#endif // FAKEFULLSCREEN_CLIENT_PATCH
@@ -3244,6 +3247,9 @@ restack(Monitor *m)
32443247
#if WARP_PATCH && FLEXTILE_DELUXE_LAYOUT
32453248
int n;
32463249
#endif // WARP_PATCH
3250+
#if ALWAYSONTOP_PATCH
3251+
Monitor *mon;
3252+
#endif // ALWAYSONTOP_PATCH
32473253

32483254
drawbar(m);
32493255
#if TAB_PATCH
@@ -3253,6 +3259,18 @@ restack(Monitor *m)
32533259
return;
32543260
if (m->sel->isfloating || !m->lt[m->sellt]->arrange)
32553261
XRaiseWindow(dpy, m->sel->win);
3262+
3263+
#if ALWAYSONTOP_PATCH
3264+
/* raise the aot windows */
3265+
for (mon = mons; mon; mon = mon->next) {
3266+
for (c = mon->clients; c; c = c->next) {
3267+
if (c->alwaysontop) {
3268+
XRaiseWindow(dpy, c->win);
3269+
}
3270+
}
3271+
}
3272+
#endif // ALWAYSONTOP_PATCH
3273+
32563274
if (m->lt[m->sellt]->arrange) {
32573275
wc.stack_mode = Below;
32583276
if (m->bar) {
@@ -4324,7 +4342,13 @@ togglefloating(const Arg *arg)
43244342
c->sfy = c->y;
43254343
c->sfw = c->w;
43264344
c->sfh = c->h;
4327-
#endif // SAVEFLOATS_PATCH / EXRESIZE_PATCH
4345+
#if ALWAYSONTOP_PATCH
4346+
c->alwaysontop = 0;
4347+
#endif // ALWAYSONTOP_PATCH
4348+
#elif ALWAYSONTOP_PATCH
4349+
} else {
4350+
c->alwaysontop = 0;
4351+
#endif // SAVEFLOATS_PATCH | EXRESIZE_PATCH | ALWAYSONTOP_PATCH
43284352
}
43294353
arrange(c->mon);
43304354

patch/alwaysontop.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
void
2+
togglealwaysontop(const Arg *arg)
3+
{
4+
Client *c = selmon->sel;
5+
6+
if (!c)
7+
return;
8+
#if !FAKEFULLSCREEN_PATCH
9+
#if FAKEFULLSCREEN_CLIENT_PATCH
10+
if (c->isfullscreen && !c->fakefullscreen)
11+
return;
12+
#else
13+
if (c->isfullscreen)
14+
return;
15+
#endif // FAKEFULLSCREEN_CLIENT_PATCH
16+
#endif // FAKEFULLSCREEN_PATCH
17+
18+
c->alwaysontop = !c->alwaysontop;
19+
restack(selmon);
20+
}

patch/alwaysontop.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
static void togglealwaysontop(const Arg *arg);

patch/bar_indicators.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,9 @@ drawstateindicator(Monitor *m, Client *c, unsigned int occ, int x, int y, int w,
107107
drawindicator(m, c, occ, x, y, w, h, tag, filled, invert, floatindicatortype);
108108
else
109109
drawindicator(m, c, occ, x, y, w, h, tag, filled, invert, tiledindicatortype);
110+
#if ALWAYSONTOP_PATCH
111+
if (c->isfloating && c->alwaysontop)
112+
drawindicator(m, c, occ, x, y, w, h, tag, filled, invert, aotindicatortype);
113+
#endif // ALWAYSONTOP_PATCH
110114
}
111115

patch/include.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@
104104
#if ALT_TAB_PATCH
105105
#include "alttab.c"
106106
#endif
107+
#if ALWAYSONTOP_PATCH
108+
#include "alwaysontop.c"
109+
#endif
107110
#if ASPECTRESIZE_PATCH
108111
#include "aspectresize.c"
109112
#endif

patch/include.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@
104104
#if ALT_TAB_PATCH
105105
#include "alttab.h"
106106
#endif
107+
#if ALWAYSONTOP_PATCH
108+
#include "alwaysontop.h"
109+
#endif
107110
#if ASPECTRESIZE_PATCH
108111
#include "aspectresize.h"
109112
#endif

patches.def.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,15 @@
461461
*/
462462
#define ALWAYSCENTER_PATCH 0
463463

464+
/* Allows for floating windows to be toggled to be always on top (aot).
465+
*
466+
* Disclaimer: Some flickering may be expected with this patch when floating and aot
467+
* windows overlap.
468+
*
469+
* https://dwm.suckless.org/patches/alwaysontop/
470+
*/
471+
#define ALWAYSONTOP_PATCH 0
472+
464473
/* This patch allows windows to be resized with its aspect ratio remaining constant.
465474
* https://dwm.suckless.org/patches/aspectresize/
466475
*/

0 commit comments

Comments
 (0)