mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-28 05:58:29 +00:00
X11: Add Xdbe support to message boxes (thanks, Melker!).
Without this, message boxes with a lot of text will noticibly flicker as you mouse over buttons. Fixes Bugzilla #2343.
This commit is contained in:
@@ -50,6 +50,9 @@
|
||||
#if SDL_VIDEO_DRIVER_X11_XCURSOR
|
||||
#include <X11/Xcursor/Xcursor.h>
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_X11_XDBE
|
||||
#include <X11/extensions/Xdbe.h>
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_X11_XINERAMA
|
||||
#include <X11/extensions/Xinerama.h>
|
||||
#endif
|
||||
|
@@ -83,6 +83,10 @@ typedef struct SDL_MessageBoxDataX11
|
||||
Display *display;
|
||||
int screen;
|
||||
Window window;
|
||||
#if SDL_VIDEO_DRIVER_X11_XDBE
|
||||
XdbeBackBuffer buf;
|
||||
SDL_bool xdbe; /* Whether Xdbe is present or not */
|
||||
#endif
|
||||
long event_mask;
|
||||
Atom wm_protocols;
|
||||
Atom wm_delete_message;
|
||||
@@ -347,6 +351,12 @@ X11_MessageBoxShutdown( SDL_MessageBoxDataX11 *data )
|
||||
data->font_struct = NULL;
|
||||
}
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XDBE
|
||||
if ( SDL_X11_HAVE_XDBE && data->xdbe ) {
|
||||
X11_XdbeDeallocateBackBufferName(data->display, data->buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( data->display ) {
|
||||
if ( data->window != None ) {
|
||||
X11_XWithdrawWindow( data->display, data->window, data->screen );
|
||||
@@ -445,6 +455,20 @@ X11_MessageBoxCreateWindow( SDL_MessageBoxDataX11 *data )
|
||||
}
|
||||
|
||||
X11_XMapRaised( display, data->window );
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XDBE
|
||||
/* Initialise a back buffer for double buffering */
|
||||
if (SDL_X11_HAVE_XDBE) {
|
||||
int xdbe_major, xdbe_minor;
|
||||
if (X11_XdbeQueryExtension(display, &xdbe_major, &xdbe_minor) != 0) {
|
||||
data->xdbe = SDL_TRUE;
|
||||
data->buf = X11_XdbeAllocateBackBufferName(display, data->window, XdbeUndefined);
|
||||
} else {
|
||||
data->xdbe = SDL_FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -453,9 +477,16 @@ static void
|
||||
X11_MessageBoxDraw( SDL_MessageBoxDataX11 *data, GC ctx )
|
||||
{
|
||||
int i;
|
||||
Window window = data->window;
|
||||
Drawable window = data->window;
|
||||
Display *display = data->display;
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XDBE
|
||||
if (SDL_X11_HAVE_XDBE && data->xdbe) {
|
||||
window = data->buf;
|
||||
X11_XdbeBeginIdiom(data->display);
|
||||
}
|
||||
#endif
|
||||
|
||||
X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ] );
|
||||
X11_XFillRectangle( display, window, ctx, 0, 0, data->dialog_width, data->dialog_height );
|
||||
|
||||
@@ -505,6 +536,16 @@ X11_MessageBoxDraw( SDL_MessageBoxDataX11 *data, GC ctx )
|
||||
buttondata->text, buttondatax11->length );
|
||||
}
|
||||
}
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XDBE
|
||||
if (SDL_X11_HAVE_XDBE && data->xdbe) {
|
||||
XdbeSwapInfo swap_info;
|
||||
swap_info.swap_window = data->window;
|
||||
swap_info.swap_action = XdbeUndefined;
|
||||
X11_XdbeSwapBuffers(data->display, &swap_info, 1);
|
||||
X11_XdbeEndIdiom(data->display);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Loop and handle message box event messages until something kills it. */
|
||||
@@ -568,7 +609,7 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data )
|
||||
case MotionNotify:
|
||||
if ( has_focus ) {
|
||||
/* Mouse moved... */
|
||||
int previndex = data->mouse_over_index;
|
||||
const int previndex = data->mouse_over_index;
|
||||
data->mouse_over_index = GetHitButtonIndex( data, e.xbutton.x, e.xbutton.y );
|
||||
if (data->mouse_over_index == previndex) {
|
||||
draw = SDL_FALSE;
|
||||
|
@@ -230,6 +230,20 @@ SDL_X11_SYM(void,XcursorImageDestroy,(XcursorImage *a),(a),)
|
||||
SDL_X11_SYM(Cursor,XcursorImageLoadCursor,(Display *a,const XcursorImage *b),(a,b),return)
|
||||
#endif
|
||||
|
||||
/* Xdbe support */
|
||||
#if SDL_VIDEO_DRIVER_X11_XDBE
|
||||
SDL_X11_MODULE(XDBE)
|
||||
SDL_X11_SYM(Status,XdbeQueryExtension,(Display *dpy,int *major_version_return,int *minor_version_return),(dpy,major_version_return,minor_version_return),return)
|
||||
SDL_X11_SYM(XdbeBackBuffer,XdbeAllocateBackBufferName,(Display *dpy,Window window,XdbeSwapAction swap_action),(dpy,window,swap_action),return)
|
||||
SDL_X11_SYM(Status,XdbeDeallocateBackBufferName,(Display *dpy,XdbeBackBuffer buffer),(dpy,buffer),return)
|
||||
SDL_X11_SYM(Status,XdbeSwapBuffers,(Display *dpy,XdbeSwapInfo *swap_info,int num_windows),(dpy,swap_info,num_windows),return)
|
||||
SDL_X11_SYM(Status,XdbeBeginIdiom,(Display *dpy),(dpy),return)
|
||||
SDL_X11_SYM(Status,XdbeEndIdiom,(Display *dpy),(dpy),return)
|
||||
SDL_X11_SYM(XdbeScreenVisualInfo*,XdbeGetVisualInfo,(Display *dpy,Drawable *screen_specifiers,int *num_screens),(dpy,screen_specifiers,num_screens),return)
|
||||
SDL_X11_SYM(void,XdbeFreeVisualInfo,(XdbeScreenVisualInfo *visual_info),(visual_info),)
|
||||
SDL_X11_SYM(XdbeBackBufferAttributes*,XdbeGetBackBufferAttributes,(Display *dpy,XdbeBackBuffer buffer),(dpy,buffer),return)
|
||||
#endif
|
||||
|
||||
/* Xinerama support */
|
||||
#if SDL_VIDEO_DRIVER_X11_XINERAMA
|
||||
SDL_X11_MODULE(XINERAMA)
|
||||
|
@@ -34,6 +34,9 @@
|
||||
#if SDL_VIDEO_DRIVER_X11_XCURSOR
|
||||
#include <X11/Xcursor/Xcursor.h>
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_X11_XDBE
|
||||
#include <X11/extensions/Xdbe.h>
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_X11_XINERAMA
|
||||
#include <X11/extensions/Xinerama.h>
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user