mirror of
https://github.com/bakkeby/patches
synced 2024-11-17 15:29:53 +00:00
87 lines
2.2 KiB
Diff
87 lines
2.2 KiB
Diff
From b96acc617397db2b2aee3a4f8ad14d61eabe335a Mon Sep 17 00:00:00 2001
|
|
From: bakkeby <bakkeby@gmail.com>
|
|
Date: Mon, 23 Aug 2021 09:17:18 +0200
|
|
Subject: [PATCH] Zero depth safeguard for dwm
|
|
|
|
The colour depth attribute of an X window represents the number of bits
|
|
that are used to represent the colour.
|
|
|
|
A window that has a depth of 0 suggests that it does not support colours
|
|
and is therefore not intended to be displayed.
|
|
|
|
Mapping a window that has a depth of 0 will result in dwm crashing and
|
|
this safeguard will avoid that.
|
|
|
|
An example of this would be one of the hidden windows that the firefox
|
|
browser manages.
|
|
|
|
$ xdotool search firefox
|
|
Defaulting to search window name, class, classname, and role
|
|
77594627
|
|
77594625
|
|
77594681
|
|
77594684
|
|
|
|
Two of the windows listed above should have a depth of 0, this can be
|
|
checked using xwininfo like this:
|
|
|
|
$ xwininfo -id 77594625
|
|
|
|
xwininfo: Window id: 0x4a00001 "Firefox"
|
|
|
|
Absolute upper-left X: 10
|
|
Absolute upper-left Y: 10
|
|
Relative upper-left X: 10
|
|
Relative upper-left Y: 10
|
|
Width: 10
|
|
Height: 10
|
|
Depth: 0
|
|
Visual: 0x506
|
|
Visual Class: TrueColor
|
|
Border width: 0
|
|
Class: InputOnly
|
|
Colormap: 0x0 (not installed)
|
|
Bit Gravity State: ForgetGravity
|
|
Window Gravity State: NorthWestGravity
|
|
Backing Store State: NotUseful
|
|
Save Under State: no
|
|
Map State: IsUnMapped
|
|
Override Redirect State: no
|
|
Corners: +10+10 -6180+10 -6180-1900 +10-1900
|
|
-geometry 10x10+10+10
|
|
|
|
The window can then be explicitly mapped using xdotool.
|
|
|
|
$ xdotool windowmap 77594625
|
|
|
|
Without the safeguard dwm should crash following the above command.
|
|
|
|
It should be noted that these kind of windows are not intended to
|
|
be explicitly mapped like this and they won't be under normal
|
|
circumstances.
|
|
|
|
If you are trying to write a script that uses tools like mapw or
|
|
xdotool to map and unmap windows then you may want to add some
|
|
checks to avoid that you don't include windows that have a depth
|
|
of 0.
|
|
---
|
|
dwm.c | 2 ++
|
|
1 file changed, 2 insertions(+)
|
|
|
|
diff --git a/dwm.c b/dwm.c
|
|
index 4465af1..0c064bd 100644
|
|
--- a/dwm.c
|
|
+++ b/dwm.c
|
|
@@ -1094,6 +1094,8 @@ maprequest(XEvent *e)
|
|
|
|
if (!XGetWindowAttributes(dpy, ev->window, &wa))
|
|
return;
|
|
+ if (!wa.depth)
|
|
+ return;
|
|
if (wa.override_redirect)
|
|
return;
|
|
if (!wintoclient(ev->window))
|
|
--
|
|
2.19.1
|
|
|