[wiki] [sites] [dwm][patch] Respect decoration hints || Jakub Leszczak

From: <git_AT_suckless.org>
Date: Wed, 13 May 2020 18:32:53 +0200

commit 276d3486cef2752268131d132f0996c941a4005c
Author: Jakub Leszczak <szatan_AT_gecc.xyz>
Date: Wed May 13 18:32:50 2020 +0200

    [dwm][patch] Respect decoration hints
    
    Make dwm respect _MOTIF_WM_HINTS property. 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) and vlc in fullscreen mode.

diff --git a/dwm.suckless.org/patches/decoration_hints/dwm-decorhints-6.2.diff b/dwm.suckless.org/patches/decoration_hints/dwm-decorhints-6.2.diff
new file mode 100644
index 00000000..98d872a7
--- /dev/null
+++ b/dwm.suckless.org/patches/decoration_hints/dwm-decorhints-6.2.diff
_AT_@ -0,0 +1,131 @@
+From 3875094925f817e047049635514034a75275d269 Mon Sep 17 00:00:00 2001
+From: Jakub Leszczak <szatan_AT_gecc.xyz>
+Date: Sat, 18 Apr 2020 19:17:46 +0200
+Subject: [PATCH] Respect decoration hints
+
+Make dwm respect _MOTIF_WM_HINTS property. 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) and vlc in fullscreen mode.
+---
+ config.def.h | 1 +
+ dwm.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
+ 2 files changed, 47 insertions(+), 1 deletion(-)
+
+diff --git a/config.def.h b/config.def.h
+index 1c0b587..2a32635 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -35,6 +35,7 @@ static const Rule rules[] = {
+ static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
+ static const int nmaster = 1; /* number of clients in master area */
+ static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
++static const int decorhints = 1; /* 1 means respect decoration hints */
+
+ static const Layout layouts[] = {
+ /* symbol arrange function */
+diff --git a/dwm.c b/dwm.c
+index 4465af1..95873c7 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -57,6 +57,13 @@
+ #define TAGMASK ((1 << LENGTH(tags)) - 1)
+ #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
+
++#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)
++
+ /* enums */
+ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
+ enum { SchemeNorm, SchemeSel }; /* color schemes */
+_AT_@ -220,6 +227,7 @@ static void updatebarpos(Monitor *m);
+ static void updatebars(void);
+ static void updateclientlist(void);
+ static int updategeom(void);
++static void updatemotifhints(Client *c);
+ static void updatenumlockmask(void);
+ static void updatesizehints(Client *c);
+ static void updatestatus(void);
+_AT_@ -259,7 +267,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
+ [PropertyNotify] = propertynotify,
+ [UnmapNotify] = unmapnotify
+ };
+-static Atom wmatom[WMLast], netatom[NetLast];
++static Atom wmatom[WMLast], netatom[NetLast], motifatom;
+ static int running = 1;
+ static Cur *cursor[CurLast];
+ static Clr **scheme;
+_AT_@ -1056,6 +1064,7 @@ manage(Window w, XWindowAttributes *wa)
+ updatewindowtype(c);
+ updatesizehints(c);
+ updatewmhints(c);
++ updatemotifhints(c);
+ XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
+ grabbuttons(c, 0);
+ if (!c->isfloating)
+_AT_@ -1242,6 +1251,8 @@ propertynotify(XEvent *e)
+ }
+ if (ev->atom == netatom[NetWMWindowType])
+ updatewindowtype(c);
++ if (ev->atom == motifatom)
++ updatemotifhints(c);
+ }
+ }
+
+_AT_@ -1562,6 +1573,7 @@ setup(void)
+ netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
+ netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
+ netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
++ motifatom = XInternAtom(dpy, "_MOTIF_WM_HINTS", False);
+ /* init cursors */
+ cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
+ cursor[CurResize] = drw_cur_create(drw, XC_sizing);
+_AT_@ -1925,6 +1937,39 @@ updategeom(void)
+ return dirty;
+ }
+
++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);
++ }
++}
++
+ void
+ updatenumlockmask(void)
+ {
+--
+2.26.2
+
diff --git a/dwm.suckless.org/patches/decoration_hints/index.md b/dwm.suckless.org/patches/decoration_hints/index.md
new file mode 100644
index 00000000..594587bc
--- /dev/null
+++ b/dwm.suckless.org/patches/decoration_hints/index.md
_AT_@ -0,0 +1,23 @@
+decoration hints
+================
+
+Description
+-----------
+
+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.
+
+Download
+--------
+
+* [dwm-decorhints-6.2.diff](dwm-decorhints-6.2.diff)
+
+Authors
+-------
+
+* Jakub Leszczak - <szatan_AT_gecc.xyz>
Received on Wed May 13 2020 - 18:32:53 CEST

This archive was generated by hypermail 2.3.0 : Wed May 13 2020 - 18:36:50 CEST