dwm

dynamic window manager

git clone https://9o.is/git/dwm.git

commit dc1a72dc6f0c9d2e235963f2d6b9ce4828274832
parent 0be9ada01efc9b588de5af0564e792315b32c6fe
Author: Jul <jul@9o.is>
Date:   Tue,  3 Feb 2026 05:28:01 -0500

add simple foregrounded windows

Diffstat:
Mconfig.def.h | 3+++
Mconfig.h | 3+++
Mdwm.c | 28++++++++++++++++++++++++++++
3 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -38,6 +38,8 @@ static const int resizehints = 1; /* 1 means respect size hints in tiled resi static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */ static const int refreshrate = 120; /* refresh rate (per second) for client move/resize */ +static const float fgw = .8, fgh = .8; /* foregrounded size */ + static const Layout layouts[] = { /* symbol arrange function */ { "[]=", tile }, /* first entry is default */ @@ -89,6 +91,7 @@ static const Key keys[] = { { MODKEY, XK_r, setlayout, {.v = &layouts[3]} }, { MODKEY, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, + { MODKEY, XK_minus, fgtoggle, {0} }, { MODKEY, XK_0, view, {.ui = ~0 } }, { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, { MODKEY, XK_comma, focusmon, {.i = -1 } }, diff --git a/config.h b/config.h @@ -32,6 +32,8 @@ static const int resizehints = 1; /* 1 means respect size hints in tiled resi static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */ static const int refreshrate = 120; /* refresh rate (per second) for client move/resize */ +static const float fgw = .8, fgh = .8; /* foregrounded size */ + static const Layout layouts[] = { /* symbol arrange function */ { "[]D", deck }, @@ -84,6 +86,7 @@ static const Key keys[] = { { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XK_f, setlayout, {.v = &layouts[3]} }, { MODKEY, XK_space, setlayout, {0} }, + { MODKEY, XK_minus, fgtoggle, {0} }, { MODKEY|ShiftMask, XK_0, view, {.ui = ~0 } }, { MODKEY|Mod1Mask, XK_0, tag, {.ui = ~0 } }, NUMKEYS( XK_1, 0) diff --git a/dwm.c b/dwm.c @@ -131,6 +131,7 @@ struct Monitor { Client *clients; Client *sel; Client *stack; + Client *fg; Monitor *next; Window barwin; const Layout *lt[2]; @@ -150,6 +151,7 @@ typedef struct { static void applyrules(Client *c); static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int *bw, int interact); static void arrange(Monitor *m); +static void arrangeforegrounded(Monitor *m); static void arrangemon(Monitor *m); static void attach(Client *c); static void attachstack(Client *c); @@ -171,6 +173,7 @@ static void drawbar(Monitor *m); static void drawbars(void); static void enternotify(XEvent *e); static void expose(XEvent *e); +static void fgtoggle(const Arg *arg); static void focus(Client *c); static void focusin(XEvent *e); //static void focusmon(const Arg *arg); @@ -408,6 +411,18 @@ arrange(Monitor *m) } void +arrangeforegrounded (Monitor *m) +{ + unsigned int x,y,w,h; + if (!selmon->fg) return; + x = m->mx + (m->mw - m->mw * fgw) / 2; + y = m->my + (m->mh - m->mh * fgh) / 2; + w = (m->mw * fgw) - (2 * (m->fg->bw)); + h = (m->mh * fgh) - (2 * (m->fg->bw)); + resize(selmon->fg, x, y, w, h, borderpx, 0); +} + +void arrangemon(Monitor *m) { Client *c; @@ -420,6 +435,9 @@ arrangemon(Monitor *m) for (c = selmon->clients; c; c = c->next) if (ISVISIBLE(c) && c->bw == 0) resize(c, c->x, c->y, c->w - 2*borderpx, c->h - 2*borderpx, borderpx, 0); + + if (m->fg) + arrangeforegrounded(m); } void @@ -903,6 +921,16 @@ expose(XEvent *e) } void +fgtoggle(const Arg *arg) +{ + if (selmon->fg) + selmon->fg = NULL; + else + selmon->fg = selmon->sel; + arrange(selmon); +} + +void focus(Client *c) { if (!c || !ISVISIBLE(c))