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.
This commit is contained in:
UnknownShadow200 2019-08-27 22:20:40 +10:00
parent f18fcf4f67
commit ad6c247154

View File

@ -1355,6 +1355,7 @@ static int X11Button_Contains(X11Button* b, int x, int y) {
y >= b->Y && y < (b->Y + b->Height); 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) { static void X11_MessageBox(const char* title, const char* text, X11Window* w) {
X11Button ok = { 0 }; X11Button ok = { 0 };
X11Textbox body = { 0 }; X11Textbox body = { 0 };
@ -1408,7 +1409,11 @@ static void X11_MessageBox(const char* title, const char* text, X11Window* w) {
XFlush(dpy); XFlush(dpy);
for (;;) { 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) switch (e.type)
{ {