X11: Fixed message boxes not responding to click on titlebar close button.

The window needs to catch ClientMessage events for one specific window, but
XNextEvent() catches everything, and XWindowEvent doesn't catch ClientMessage,
so we need predicate procedure and XIfEvent() here.

Fixes Bugzilla #2980.
Ryan C. Gordon 2015-05-31 22:48:26 -04:00
parent cb60f2dfc2
commit 554b2b0e36
1 changed files with 10 additions and 1 deletions

View File

@ -548,6 +548,13 @@ X11_MessageBoxDraw( SDL_MessageBoxDataX11 *data, GC ctx )
#endif
}
static Bool
X11_MessageBoxEventTest(Display *display, XEvent *event, XPointer arg)
{
const SDL_MessageBoxDataX11 *data = (const SDL_MessageBoxDataX11 *) arg;
return ((event->xany.display == data->display) && (event->xany.window == data->window)) ? True : False;
}
/* Loop and handle message box event messages until something kills it. */
static int
X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data )
@ -580,7 +587,9 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data )
XEvent e;
SDL_bool draw = SDL_TRUE;
X11_XWindowEvent( data->display, data->window, data->event_mask, &e );
/* can't use XWindowEvent() because it can't handle ClientMessage events. */
/* can't use XNextEvent() because we only want events for this window. */
X11_XIfEvent( data->display, &e, X11_MessageBoxEventTest, (XPointer) data );
/* If X11_XFilterEvent returns True, then some input method has filtered the
event, and the client should discard the event. */