Fix for dwm randomly crashing when the first systray application starts

The crash error was:

dwm: fatal error: request code=12, error code=11
X Error of failed request:  BadAlloc (insufficient resources for operation)
  Major opcode of failed request:  12 (X_ConfigureWindow)
  Serial number of failed request:  3333
  Current serial number in output stream:  3338

This was backtracked to function updatesystray where XConfigureWindow was
called with large negative X positions (e.g. -836585). The large number
coming from the width of the systray icon.

w += i->w;

The systray icon width is set through the updatesystrayicongeom function
and this is called by resizerequest, clientmessage and propertynotify.

The height and width would appear to come from the X window attributes and
sometimes have random values (e.g. height 32708 and width 1369918222).

updatesystrayicongeom restricts the height of the icon to that of the bar,
but did not have any restictions on the icon width. This fix limits the
icon width to that of the bar height if it is greater than twice the bar
height, leaving room for systray icons that are slightly wider than they
are tall.
pull/19/head
bakkeby 4 years ago
parent 007979adfc
commit ee81c6572d

@ -296,7 +296,7 @@ index 4465af1..20f8309 100644
2.19.1
From 1a36b6c4952bd1e9a6d86deef96996fbea1e481e Mon Sep 17 00:00:00 2001
From 514943eba37cd2f9d62d47157dc3088e31711529 Mon Sep 17 00:00:00 2001
From: bakkeby <bakkeby@gmail.com>
Date: Tue, 7 Apr 2020 10:53:35 +0200
Subject: [PATCH 2/2] Adding systray patch
@ -304,8 +304,8 @@ Subject: [PATCH 2/2] Adding systray patch
Refer to https://dwm.suckless.org/patches/systray/
---
config.def.h | 4 +
dwm.c | 421 +++++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 399 insertions(+), 26 deletions(-)
dwm.c | 423 +++++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 401 insertions(+), 26 deletions(-)
diff --git a/config.def.h b/config.def.h
index 4f68fe8..1952613 100644
@ -323,7 +323,7 @@ index 4f68fe8..1952613 100644
static const char dmenufont[] = "monospace:size=10";
static const char col_gray1[] = "#222222";
diff --git a/dwm.c b/dwm.c
index 20f8309..6e57ef8 100644
index 20f8309..c3ecbef 100644
--- a/dwm.c
+++ b/dwm.c
@@ -59,12 +59,30 @@
@ -887,7 +887,7 @@ index 20f8309..6e57ef8 100644
XMapRaised(dpy, m->barwin);
XSetClassHint(dpy, m->barwin, &ch);
}
@@ -2001,6 +2227,139 @@ updatestatus(void)
@@ -2001,6 +2227,141 @@ updatestatus(void)
if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
strcpy(stext, "dwm-"VERSION);
drawbar(selmon);
@ -995,6 +995,8 @@ index 20f8309..6e57ef8 100644
+ i->w = (int) ((float)bh * ((float)i->w / (float)i->h));
+ i->h = bh;
+ }
+ if (i->w > 2*bh)
+ i->w = bh;
+ }
+}
+
@ -1027,7 +1029,7 @@ index 20f8309..6e57ef8 100644
}
void
@@ -2085,6 +2444,16 @@ wintomon(Window w)
@@ -2085,6 +2446,16 @@ wintomon(Window w)
return selmon;
}

@ -1,4 +1,4 @@
From 555cd85ea1d3b555a0523f87cf718f7ee0227cab Mon Sep 17 00:00:00 2001
From bf9f15f792dd00b172c9a5094a5455de0a60ff4a Mon Sep 17 00:00:00 2001
From: bakkeby <bakkeby@gmail.com>
Date: Tue, 7 Apr 2020 11:32:02 +0200
Subject: [PATCH] Adding systray patch
@ -6,8 +6,8 @@ Subject: [PATCH] Adding systray patch
Refer to https://dwm.suckless.org/patches/systray/
---
config.def.h | 4 +
dwm.c | 404 +++++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 380 insertions(+), 28 deletions(-)
dwm.c | 406 +++++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 382 insertions(+), 28 deletions(-)
diff --git a/config.def.h b/config.def.h
index 1c0b587..dd8e07a 100644
@ -25,7 +25,7 @@ index 1c0b587..dd8e07a 100644
static const int topbar = 1; /* 0 means bottom bar */
static const char *fonts[] = { "monospace:size=10" };
diff --git a/dwm.c b/dwm.c
index 4465af1..ba7fae3 100644
index 4465af1..7f3cc51 100644
--- a/dwm.c
+++ b/dwm.c
@@ -57,12 +57,30 @@
@ -573,7 +573,7 @@ index 4465af1..ba7fae3 100644
XMapRaised(dpy, m->barwin);
XSetClassHint(dpy, m->barwin, &ch);
}
@@ -1990,6 +2195,123 @@ updatestatus(void)
@@ -1990,6 +2195,125 @@ updatestatus(void)
if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
strcpy(stext, "dwm-"VERSION);
drawbar(selmon);
@ -600,6 +600,8 @@ index 4465af1..ba7fae3 100644
+ i->w = (int) ((float)bh * ((float)i->w / (float)i->h));
+ i->h = bh;
+ }
+ if (i->w > 2*bh)
+ i->w = bh;
+ }
+}
+
@ -697,7 +699,7 @@ index 4465af1..ba7fae3 100644
}
void
@@ -2057,6 +2379,16 @@ wintoclient(Window w)
@@ -2057,6 +2381,16 @@ wintoclient(Window w)
return NULL;
}
@ -714,7 +716,7 @@ index 4465af1..ba7fae3 100644
Monitor *
wintomon(Window w)
{
@@ -2110,6 +2442,22 @@ xerrorstart(Display *dpy, XErrorEvent *ee)
@@ -2110,6 +2444,22 @@ xerrorstart(Display *dpy, XErrorEvent *ee)
return -1;
}

Loading…
Cancel
Save