X11: Fixed message boxes not responding to click on titlebar close button.
authorRyan C. Gordon <icculus@icculus.org>
Sun, 31 May 2015 22:48:26 -0400
changeset 9695363a7880b4f7
parent 9694 b847b89f4a64
child 9696 a7e9b75ec1c9
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.
src/video/x11/SDL_x11messagebox.c
     1.1 --- a/src/video/x11/SDL_x11messagebox.c	Sun May 31 22:27:46 2015 -0400
     1.2 +++ b/src/video/x11/SDL_x11messagebox.c	Sun May 31 22:48:26 2015 -0400
     1.3 @@ -548,6 +548,13 @@
     1.4  #endif
     1.5  }
     1.6  
     1.7 +static Bool
     1.8 +X11_MessageBoxEventTest(Display *display, XEvent *event, XPointer arg)
     1.9 +{
    1.10 +    const SDL_MessageBoxDataX11 *data = (const SDL_MessageBoxDataX11 *) arg;
    1.11 +    return ((event->xany.display == data->display) && (event->xany.window == data->window)) ? True : False;
    1.12 +}
    1.13 +
    1.14  /* Loop and handle message box event messages until something kills it. */
    1.15  static int
    1.16  X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data )
    1.17 @@ -580,7 +587,9 @@
    1.18          XEvent e;
    1.19          SDL_bool draw = SDL_TRUE;
    1.20  
    1.21 -        X11_XWindowEvent( data->display, data->window, data->event_mask, &e );
    1.22 +        /* can't use XWindowEvent() because it can't handle ClientMessage events. */
    1.23 +        /* can't use XNextEvent() because we only want events for this window. */
    1.24 +        X11_XIfEvent( data->display, &e, X11_MessageBoxEventTest, (XPointer) data );
    1.25  
    1.26          /* If X11_XFilterEvent returns True, then some input method has filtered the
    1.27             event, and the client should discard the event. */