Skip to content
Permalink
Browse files
X11: Fixed message boxes not responding to click on titlebar close bu…
…tton.

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.
  • Loading branch information
icculus committed Jun 1, 2015
1 parent cb60f2d commit 554b2b0e36e0c5ef3fc0b482085f86679a3db3a6
Showing with 10 additions and 1 deletion.
  1. +10 −1 src/video/x11/SDL_x11messagebox.c
@@ -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. */

0 comments on commit 554b2b0

Please sign in to comment.