src/video/x11/SDL_x11messagebox.c
changeset 9657 fbc01731d914
parent 9619 b94b6d0bff0f
child 9695 363a7880b4f7
     1.1 --- a/src/video/x11/SDL_x11messagebox.c	Wed May 27 19:00:56 2015 -0400
     1.2 +++ b/src/video/x11/SDL_x11messagebox.c	Thu May 28 00:30:21 2015 -0400
     1.3 @@ -83,6 +83,10 @@
     1.4      Display *display;
     1.5      int screen;
     1.6      Window window;
     1.7 +#if SDL_VIDEO_DRIVER_X11_XDBE
     1.8 +    XdbeBackBuffer buf;
     1.9 +    SDL_bool xdbe;                      /* Whether Xdbe is present or not */
    1.10 +#endif
    1.11      long event_mask;
    1.12      Atom wm_protocols;
    1.13      Atom wm_delete_message;
    1.14 @@ -347,6 +351,12 @@
    1.15          data->font_struct = NULL;
    1.16      }
    1.17  
    1.18 +#if SDL_VIDEO_DRIVER_X11_XDBE
    1.19 +    if ( SDL_X11_HAVE_XDBE && data->xdbe ) {
    1.20 +        X11_XdbeDeallocateBackBufferName(data->display, data->buf);
    1.21 +    }
    1.22 +#endif
    1.23 +
    1.24      if ( data->display ) {
    1.25          if ( data->window != None ) {
    1.26              X11_XWithdrawWindow( data->display, data->window, data->screen );
    1.27 @@ -445,6 +455,20 @@
    1.28      }
    1.29  
    1.30      X11_XMapRaised( display, data->window );
    1.31 +
    1.32 +#if SDL_VIDEO_DRIVER_X11_XDBE
    1.33 +    /* Initialise a back buffer for double buffering */
    1.34 +    if (SDL_X11_HAVE_XDBE) {
    1.35 +        int xdbe_major, xdbe_minor;
    1.36 +        if (X11_XdbeQueryExtension(display, &xdbe_major, &xdbe_minor) != 0) {
    1.37 +            data->xdbe = SDL_TRUE;
    1.38 +            data->buf = X11_XdbeAllocateBackBufferName(display, data->window, XdbeUndefined);
    1.39 +        } else {
    1.40 +            data->xdbe = SDL_FALSE;
    1.41 +        }
    1.42 +    }
    1.43 +#endif
    1.44 +
    1.45      return 0;
    1.46  }
    1.47  
    1.48 @@ -453,9 +477,16 @@
    1.49  X11_MessageBoxDraw( SDL_MessageBoxDataX11 *data, GC ctx )
    1.50  {
    1.51      int i;
    1.52 -    Window window = data->window;
    1.53 +    Drawable window = data->window;
    1.54      Display *display = data->display;
    1.55  
    1.56 +#if SDL_VIDEO_DRIVER_X11_XDBE
    1.57 +    if (SDL_X11_HAVE_XDBE && data->xdbe) {
    1.58 +        window = data->buf;
    1.59 +        X11_XdbeBeginIdiom(data->display);
    1.60 +    }
    1.61 +#endif
    1.62 +
    1.63      X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ] );
    1.64      X11_XFillRectangle( display, window, ctx, 0, 0, data->dialog_width, data->dialog_height );
    1.65  
    1.66 @@ -505,6 +536,16 @@
    1.67                           buttondata->text, buttondatax11->length );
    1.68          }
    1.69      }
    1.70 +
    1.71 +#if SDL_VIDEO_DRIVER_X11_XDBE
    1.72 +    if (SDL_X11_HAVE_XDBE && data->xdbe) {
    1.73 +        XdbeSwapInfo swap_info;
    1.74 +        swap_info.swap_window = data->window;
    1.75 +        swap_info.swap_action = XdbeUndefined;
    1.76 +        X11_XdbeSwapBuffers(data->display, &swap_info, 1);
    1.77 +        X11_XdbeEndIdiom(data->display);
    1.78 +    }
    1.79 +#endif
    1.80  }
    1.81  
    1.82  /* Loop and handle message box event messages until something kills it. */
    1.83 @@ -568,7 +609,7 @@
    1.84          case MotionNotify:
    1.85              if ( has_focus ) {
    1.86                  /* Mouse moved... */
    1.87 -                int previndex = data->mouse_over_index;
    1.88 +                const int previndex = data->mouse_over_index;
    1.89                  data->mouse_over_index = GetHitButtonIndex( data, e.xbutton.x, e.xbutton.y );
    1.90                  if (data->mouse_over_index == previndex) {
    1.91                      draw = SDL_FALSE;