From ad6c2471546f2822a697615f0abf56d7024de5c6 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 27 Aug 2019 22:20:40 +1000 Subject: [PATCH] Filter events in the X11 message box to only apply to to the message box window This fixes launcher window being resized incorrectly with i3 WM if the 'initing fonts cache' message box appears, but without breaking any other WMs. --- src/Window.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Window.c b/src/Window.c index 87a9f4326..cb19ed4b4 100644 --- a/src/Window.c +++ b/src/Window.c @@ -1355,6 +1355,7 @@ static int X11Button_Contains(X11Button* b, int x, int y) { y >= b->Y && y < (b->Y + b->Height); } +static Bool X11_FilterEvent(Display* d, XEvent* e, XPointer w) { return e->xany.window == (Window)w; } static void X11_MessageBox(const char* title, const char* text, X11Window* w) { X11Button ok = { 0 }; X11Textbox body = { 0 }; @@ -1408,7 +1409,11 @@ static void X11_MessageBox(const char* title, const char* text, X11Window* w) { XFlush(dpy); for (;;) { - XNextEvent(dpy, &e); + /* The naive solution is to use XNextEvent(dpy, &e) here. */ + /* However this causes issues as that removes events that */ + /* should have been delivered to the main game window. */ + /* (e.g. breaks initial window resize with i3 WM) */ + XIfEvent(dpy, &e, X11_FilterEvent, w->win); switch (e.type) {