Skip to content

Commit

Permalink
X11: Fixed message boxes not responding to click on titlebar close bu…
Browse files Browse the repository at this point in the history
…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 554b2b0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/video/x11/SDL_x11messagebox.c
Expand Up @@ -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 )
Expand Down Expand Up @@ -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. */
Expand Down

0 comments on commit 554b2b0

Please sign in to comment.