Adding unmanaged patch ref. #365

This commit is contained in:
bakkeby 2023-06-27 17:24:36 +02:00
parent ab7d28ff0f
commit 74abea7c70
3 changed files with 40 additions and 1 deletions

View File

@ -19,7 +19,7 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/X9IiSSM6
### Changelog:
2023-06-27 - Added the focusfollowmouse patch
2023-06-27 - Added the focusfollowmouse and unmanaged patches
2023-06-25 - Added the toggletopbar patch
@ -808,6 +808,10 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/X9IiSSM6
- resets isfloating on any visible windows that have it set and optionally also applies a
layout
- [unmanaged](https://github.com/bakkeby/patches/wiki/unmanaged)
- adds a client rule that allows for windows to not be managed by the window manager
- this can be useful for external bars, widgets, launchers, docks, desktop icons and more
- [~urgentborder~](https://dwm.suckless.org/patches/urgentborder/)
- ~this patch makes "urgent" windows have different colors~

28
dwm.c
View File

@ -568,6 +568,9 @@ typedef struct {
#if RENAMED_SCRATCHPADS_PATCH
const char scratchkey;
#endif // RENAMED_SCRATCHPADS_PATCH
#if UNMANAGED_PATCH
int unmanaged;
#endif // UNMANAGED_PATCH
#if XKB_PATCH
int xkb_layout;
#endif // XKB_PATCH
@ -775,6 +778,9 @@ static int xkbEventType = 0;
static int screen;
static int sw, sh; /* X display screen geometry width, height */
static int bh; /* bar geometry */
#if UNMANAGED_PATCH
static int unmanaged = 0; /* whether the window manager should manage the new window or not */
#endif // UNMANAGED_PATCH
static int lrpad; /* sum of left and right padding for text */
/* Some clients (e.g. alacritty) helpfully send configure requests with a new size or position
* when they detect that they have been moved to another monitor. This can cause visual glitches
@ -932,6 +938,9 @@ applyrules(Client *c)
c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
}
#endif // SCRATCHPADS_PATCH
#if UNMANAGED_PATCH
unmanaged = r->unmanaged;
#endif // UNMANAGED_PATCH
for (m = mons; m && m->num != r->monitor; m = m->next);
if (m)
c->mon = m;
@ -2502,6 +2511,25 @@ manage(Window w, XWindowAttributes *wa)
#endif // SWALLOW_PATCH
}
#if UNMANAGED_PATCH
if (unmanaged) {
XMapWindow(dpy, c->win);
if (unmanaged == 1)
XRaiseWindow(dpy, c->win);
else if (unmanaged == 2)
XLowerWindow(dpy, c->win);
updatewmhints(c);
if (!c->neverfocus)
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
sendevent(c, wmatom[WMTakeFocus]);
free(c);
unmanaged = 0;
return;
}
#endif // UNMANAGED_PATCH
if (c->x + WIDTH(c) > c->mon->wx + c->mon->ww)
c->x = c->mon->wx + c->mon->ww - WIDTH(c);
if (c->y + HEIGHT(c) > c->mon->wy + c->mon->wh)

View File

@ -1309,6 +1309,13 @@
*/
#define UNFLOATVISIBLE_PATCH 0
/* This patch adds a client rule that allows for windows that do not specify the override-redirect
* to not be managed by the window manager. This can be useful for external bars, widgets,
* launchers, docks, desktop icons and more.
* https://github.com/bakkeby/patches/wiki/unmanaged
*/
#define UNMANAGED_PATCH 0
/* This patch adds configurable gaps between windows differentiating between outer, inner,
* horizontal and vertical gaps.
* https://github.com/bakkeby/patches/blob/master/dwm/dwm-vanitygaps-6.2.diff