src/video/x11/SDL_x11messagebox.c
changeset 9657 fbc01731d914
parent 9619 b94b6d0bff0f
child 9695 363a7880b4f7
equal deleted inserted replaced
9656:8a4bcbdeba1c 9657:fbc01731d914
    81 typedef struct SDL_MessageBoxDataX11
    81 typedef struct SDL_MessageBoxDataX11
    82 {
    82 {
    83     Display *display;
    83     Display *display;
    84     int screen;
    84     int screen;
    85     Window window;
    85     Window window;
       
    86 #if SDL_VIDEO_DRIVER_X11_XDBE
       
    87     XdbeBackBuffer buf;
       
    88     SDL_bool xdbe;                      /* Whether Xdbe is present or not */
       
    89 #endif
    86     long event_mask;
    90     long event_mask;
    87     Atom wm_protocols;
    91     Atom wm_protocols;
    88     Atom wm_delete_message;
    92     Atom wm_delete_message;
    89 
    93 
    90     int dialog_width;                   /* Dialog box width. */
    94     int dialog_width;                   /* Dialog box width. */
   345     if ( data->font_struct != NULL ) {
   349     if ( data->font_struct != NULL ) {
   346         X11_XFreeFont( data->display, data->font_struct );
   350         X11_XFreeFont( data->display, data->font_struct );
   347         data->font_struct = NULL;
   351         data->font_struct = NULL;
   348     }
   352     }
   349 
   353 
       
   354 #if SDL_VIDEO_DRIVER_X11_XDBE
       
   355     if ( SDL_X11_HAVE_XDBE && data->xdbe ) {
       
   356         X11_XdbeDeallocateBackBufferName(data->display, data->buf);
       
   357     }
       
   358 #endif
       
   359 
   350     if ( data->display ) {
   360     if ( data->display ) {
   351         if ( data->window != None ) {
   361         if ( data->window != None ) {
   352             X11_XWithdrawWindow( data->display, data->window, data->screen );
   362             X11_XWithdrawWindow( data->display, data->window, data->screen );
   353             X11_XDestroyWindow( data->display, data->window );
   363             X11_XDestroyWindow( data->display, data->window );
   354             data->window = None;
   364             data->window = None;
   443 
   453 
   444         X11_XFree( sizehints );
   454         X11_XFree( sizehints );
   445     }
   455     }
   446 
   456 
   447     X11_XMapRaised( display, data->window );
   457     X11_XMapRaised( display, data->window );
       
   458 
       
   459 #if SDL_VIDEO_DRIVER_X11_XDBE
       
   460     /* Initialise a back buffer for double buffering */
       
   461     if (SDL_X11_HAVE_XDBE) {
       
   462         int xdbe_major, xdbe_minor;
       
   463         if (X11_XdbeQueryExtension(display, &xdbe_major, &xdbe_minor) != 0) {
       
   464             data->xdbe = SDL_TRUE;
       
   465             data->buf = X11_XdbeAllocateBackBufferName(display, data->window, XdbeUndefined);
       
   466         } else {
       
   467             data->xdbe = SDL_FALSE;
       
   468         }
       
   469     }
       
   470 #endif
       
   471 
   448     return 0;
   472     return 0;
   449 }
   473 }
   450 
   474 
   451 /* Draw our message box. */
   475 /* Draw our message box. */
   452 static void
   476 static void
   453 X11_MessageBoxDraw( SDL_MessageBoxDataX11 *data, GC ctx )
   477 X11_MessageBoxDraw( SDL_MessageBoxDataX11 *data, GC ctx )
   454 {
   478 {
   455     int i;
   479     int i;
   456     Window window = data->window;
   480     Drawable window = data->window;
   457     Display *display = data->display;
   481     Display *display = data->display;
       
   482 
       
   483 #if SDL_VIDEO_DRIVER_X11_XDBE
       
   484     if (SDL_X11_HAVE_XDBE && data->xdbe) {
       
   485         window = data->buf;
       
   486         X11_XdbeBeginIdiom(data->display);
       
   487     }
       
   488 #endif
   458 
   489 
   459     X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ] );
   490     X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ] );
   460     X11_XFillRectangle( display, window, ctx, 0, 0, data->dialog_width, data->dialog_height );
   491     X11_XFillRectangle( display, window, ctx, 0, 0, data->dialog_width, data->dialog_height );
   461 
   492 
   462     X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] );
   493     X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] );
   503             X11_XDrawString( display, window, ctx,
   534             X11_XDrawString( display, window, ctx,
   504                          buttondatax11->x + offset, buttondatax11->y + offset,
   535                          buttondatax11->x + offset, buttondatax11->y + offset,
   505                          buttondata->text, buttondatax11->length );
   536                          buttondata->text, buttondatax11->length );
   506         }
   537         }
   507     }
   538     }
       
   539 
       
   540 #if SDL_VIDEO_DRIVER_X11_XDBE
       
   541     if (SDL_X11_HAVE_XDBE && data->xdbe) {
       
   542         XdbeSwapInfo swap_info;
       
   543         swap_info.swap_window = data->window;
       
   544         swap_info.swap_action = XdbeUndefined;
       
   545         X11_XdbeSwapBuffers(data->display, &swap_info, 1);
       
   546         X11_XdbeEndIdiom(data->display);
       
   547     }
       
   548 #endif
   508 }
   549 }
   509 
   550 
   510 /* Loop and handle message box event messages until something kills it. */
   551 /* Loop and handle message box event messages until something kills it. */
   511 static int
   552 static int
   512 X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data )
   553 X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data )
   566             break;
   607             break;
   567 
   608 
   568         case MotionNotify:
   609         case MotionNotify:
   569             if ( has_focus ) {
   610             if ( has_focus ) {
   570                 /* Mouse moved... */
   611                 /* Mouse moved... */
   571                 int previndex = data->mouse_over_index;
   612                 const int previndex = data->mouse_over_index;
   572                 data->mouse_over_index = GetHitButtonIndex( data, e.xbutton.x, e.xbutton.y );
   613                 data->mouse_over_index = GetHitButtonIndex( data, e.xbutton.x, e.xbutton.y );
   573                 if (data->mouse_over_index == previndex) {
   614                 if (data->mouse_over_index == previndex) {
   574                     draw = SDL_FALSE;
   615                     draw = SDL_FALSE;
   575                 }
   616                 }
   576             }
   617             }