src/video/x11/SDL_x11messagebox.c
changeset 7522 b186724247dd
parent 7191 75360622e65f
child 7827 a03ec8de0426
     1.1 --- a/src/video/x11/SDL_x11messagebox.c	Fri Jul 26 13:30:24 2013 -0700
     1.2 +++ b/src/video/x11/SDL_x11messagebox.c	Sat Jul 27 00:49:34 2013 -0700
     1.3 @@ -78,11 +78,11 @@
     1.4      const char *text;                   /* Text for this line */
     1.5  } TextLineData;
     1.6  
     1.7 -typedef struct SDL_MessageBoxDataX11 {
     1.8 -    XFontSet font_set;                  /* for UTF-8 systems */
     1.9 -    XFontStruct *font_struct;            /* Latin1 (ASCII) fallback. */
    1.10 +typedef struct SDL_MessageBoxDataX11
    1.11 +{
    1.12 +    Display *display;
    1.13 +    int screen;
    1.14      Window window;
    1.15 -    Display *display;
    1.16      long event_mask;
    1.17      Atom wm_protocols;
    1.18      Atom wm_delete_message;
    1.19 @@ -90,6 +90,8 @@
    1.20      int dialog_width;                   /* Dialog box width. */
    1.21      int dialog_height;                  /* Dialog box height. */
    1.22  
    1.23 +    XFontSet font_set;                  /* for UTF-8 systems */
    1.24 +    XFontStruct *font_struct;           /* Latin1 (ASCII) fallback. */
    1.25      int xtext, ytext;                   /* Text position to start drawing at. */
    1.26      int numlines;                       /* Count of Text lines. */
    1.27      int text_height;                    /* Height for text lines. */
    1.28 @@ -347,7 +349,7 @@
    1.29  
    1.30      if ( data->display ) {
    1.31          if ( data->window != None ) {
    1.32 -            XUnmapWindow( data->display, data->window );
    1.33 +            XWithdrawWindow( data->display, data->window, data->screen );
    1.34              XDestroyWindow( data->display, data->window );
    1.35              data->window = None;
    1.36          }
    1.37 @@ -369,7 +371,12 @@
    1.38      const SDL_MessageBoxData *messageboxdata = data->messageboxdata;
    1.39  
    1.40      if ( messageboxdata->window ) {
    1.41 +        SDL_DisplayData *displaydata =
    1.42 +            (SDL_DisplayData *) SDL_GetDisplayForWindow(messageboxdata->window)->driverdata;
    1.43          windowdata = (SDL_WindowData *)messageboxdata->window->driverdata;
    1.44 +        data->screen = displaydata->screen;
    1.45 +    } else {
    1.46 +        data->screen = DefaultScreen( display );
    1.47      }
    1.48  
    1.49      data->event_mask = ExposureMask |
    1.50 @@ -378,7 +385,7 @@
    1.51      wnd_attr.event_mask = data->event_mask;
    1.52  
    1.53      data->window = XCreateWindow(
    1.54 -                       display, DefaultRootWindow( display ),
    1.55 +                       display, RootWindow(display, data->screen),
    1.56                         0, 0,
    1.57                         data->dialog_width, data->dialog_height,
    1.58                         0, CopyFromParent, InputOutput, CopyFromParent,
    1.59 @@ -406,11 +413,10 @@
    1.60          XGetWindowAttributes(display, windowdata->xwindow, &attrib);
    1.61          x = attrib.x + ( attrib.width - data->dialog_width ) / 2;
    1.62          y = attrib.y + ( attrib.height - data->dialog_height ) / 3 ;
    1.63 -        XTranslateCoordinates(display, windowdata->xwindow, DefaultRootWindow( display ), x, y, &x, &y, &dummy);
    1.64 +        XTranslateCoordinates(display, windowdata->xwindow, RootWindow(display, data->screen), x, y, &x, &y, &dummy);
    1.65      } else {
    1.66 -        int screen = DefaultScreen( display );
    1.67 -        x = ( DisplayWidth( display, screen ) - data->dialog_width ) / 2;
    1.68 -        y = ( DisplayHeight( display, screen ) - data->dialog_height ) / 3 ;
    1.69 +        x = ( DisplayWidth( display, data->screen ) - data->dialog_width ) / 2;
    1.70 +        y = ( DisplayHeight( display, data->screen ) - data->dialog_height ) / 3 ;
    1.71      }
    1.72      XMoveWindow( display, data->window, x, y );
    1.73