diff --git a/README.md b/README.md index 0f631dd..1137046 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t ### Changelog: +2020-08-11 - Added decoration hints patch + 2020-08-10 - Added cool autostart, insets and steam patches 2020-08-02 - Added reorganizetags patch @@ -208,6 +210,11 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t - [cyclelayouts](https://dwm.suckless.org/patches/cyclelayouts/) - lets you cycle through all your layouts + - [decoration_hints](https://dwm.suckless.org/patches/decoration_hints/) + - make dwm respect \_MOTIF\_WM\_HINTS property, and not draw borders around windows requesting for it + - some applications use this property to notify window managers to not draw window decorations + - not respecting this property leads to issues with applications that draw their own borders, like chromium (with "Use system title bar and borders" turned off) or vlc in fullscreen mode + - [dmenumatchtop](https://dwm.suckless.org/patches/dmenumatchtop) - updates the position of dmenu to match that of the bar - i.e. if topbar is 0 then dmenu will appear at the bottom and if 1 then dmenu will appear at the top diff --git a/config.def.h b/config.def.h index 4e98ff0..72d08ab 100644 --- a/config.def.h +++ b/config.def.h @@ -654,6 +654,9 @@ static const int nmaster = 1; /* number of clients in master area */ static const int nstack = 0; /* number of clients in primary stack area */ #endif // FLEXTILE_DELUXE_LAYOUT static const int resizehints = 0; /* 1 means respect size hints in tiled resizals */ +#if DECORATION_HINTS_PATCH +static const int decorhints = 1; /* 1 means respect decoration hints */ +#endif // DECORATION_HINTS_PATCH #if NROWGRID_LAYOUT #define FORCE_VSPLIT 1 diff --git a/dwm.c b/dwm.c index 014ade0..e887a65 100644 --- a/dwm.c +++ b/dwm.c @@ -2033,6 +2033,9 @@ manage(Window w, XWindowAttributes *wa) if (getatomprop(c, netatom[NetWMState]) == netatom[NetWMFullscreen]) setfullscreen(c, 1); updatewmhints(c); + #if DECORATION_HINTS_PATCH + updatemotifhints(c); + #endif // DECORATION_HINTS_PATCH #if CENTER_PATCH if (c->iscentered) { c->x = c->mon->wx + (c->mon->ww - WIDTH(c)) / 2; @@ -2300,6 +2303,10 @@ propertynotify(XEvent *e) if (c == c->mon->sel) drawbar(c->mon); } + #if DECORATION_HINTS_PATCH + if (ev->atom == motifatom) + updatemotifhints(c); + #endif // DECORATION_HINTS_PATCH } } @@ -2933,6 +2940,9 @@ setup(void) netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False); netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False); + #if DECORATION_HINTS_PATCH + motifatom = XInternAtom(dpy, "_MOTIF_WM_HINTS", False); + #endif // DECORATION_HINTS_PATCH /* init cursors */ cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr); cursor[CurResize] = drw_cur_create(drw, XC_sizing); diff --git a/patch/decorationhints.c b/patch/decorationhints.c new file mode 100644 index 0000000..a7498ee --- /dev/null +++ b/patch/decorationhints.c @@ -0,0 +1,34 @@ +static Atom motifatom; + +void +updatemotifhints(Client *c) +{ + Atom real; + int format; + unsigned char *p = NULL; + unsigned long n, extra; + unsigned long *motif; + int width, height; + + if (!decorhints) + return; + + if (XGetWindowProperty(dpy, c->win, motifatom, 0L, 5L, False, motifatom, + &real, &format, &n, &extra, &p) == Success && p != NULL) { + motif = (unsigned long*)p; + if (motif[MWM_HINTS_FLAGS_FIELD] & MWM_HINTS_DECORATIONS) { + width = WIDTH(c); + height = HEIGHT(c); + + if (motif[MWM_HINTS_DECORATIONS_FIELD] & MWM_DECOR_ALL || + motif[MWM_HINTS_DECORATIONS_FIELD] & MWM_DECOR_BORDER || + motif[MWM_HINTS_DECORATIONS_FIELD] & MWM_DECOR_TITLE) + c->bw = c->oldbw = borderpx; + else + c->bw = c->oldbw = 0; + + resize(c, c->x, c->y, width - (2*c->bw), height - (2*c->bw), 0); + } + XFree(p); + } +} \ No newline at end of file diff --git a/patch/decorationhints.h b/patch/decorationhints.h new file mode 100644 index 0000000..3a9c641 --- /dev/null +++ b/patch/decorationhints.h @@ -0,0 +1,8 @@ +#define MWM_HINTS_FLAGS_FIELD 0 +#define MWM_HINTS_DECORATIONS_FIELD 2 +#define MWM_HINTS_DECORATIONS (1 << 1) +#define MWM_DECOR_ALL (1 << 0) +#define MWM_DECOR_BORDER (1 << 1) +#define MWM_DECOR_TITLE (1 << 3) + +static void updatemotifhints(Client *c); \ No newline at end of file diff --git a/patch/include.c b/patch/include.c index 81901a1..68ff0c1 100644 --- a/patch/include.c +++ b/patch/include.c @@ -82,6 +82,9 @@ #if CYCLELAYOUTS_PATCH #include "cyclelayouts.c" #endif +#if DECORATION_HINTS_PATCH +#include "decorationhints.c" +#endif #if DRAGCFACT_PATCH && CFACTS_PATCH #include "dragcfact.c" #endif diff --git a/patch/include.h b/patch/include.h index a556964..6b695a1 100644 --- a/patch/include.h +++ b/patch/include.h @@ -79,6 +79,9 @@ #if CYCLELAYOUTS_PATCH #include "cyclelayouts.h" #endif +#if DECORATION_HINTS_PATCH +#include "decorationhints.h" +#endif #if DRAGCFACT_PATCH && CFACTS_PATCH #include "dragcfact.h" #endif diff --git a/patches.def.h b/patches.def.h index c595516..797a14f 100644 --- a/patches.def.h +++ b/patches.def.h @@ -348,6 +348,15 @@ */ #define CYCLELAYOUTS_PATCH 0 +/* Make dwm respect _MOTIF_WM_HINTS property, and not draw borders around windows requesting + * for it. Some applications use this property to notify window managers to not draw window + * decorations. + * Not respecting this property leads to issues with applications that draw their own borders, + * like chromium (with "Use system title bar and borders" turned off) or vlc in fullscreen mode. + * https://dwm.suckless.org/patches/decoration_hints/ + */ +#define DECORATION_HINTS_PATCH 0 + /* Similarly to the dragmfact patch this allows you to click and drag clients to change the * cfact to adjust the client's size in the stack. This patch depends on the cfacts patch. */