SDL 1.x: Add SDL_SetVideoMode flag that says the library should NOT automatically redraw the window contents when the window needs repainting. For the SDL 1.x X11 driver, this flag inhibits repainting the contents of the window on the X11 Expose event, which solves the problem with the DOS screen flickering while you resize the window in Linux. When the DOS prompt has been fully redrawn, remove the flag and handle the window as normal.

This commit is contained in:
Jonathan Campbell
2018-05-12 21:15:31 -07:00
parent 33b51deb76
commit ad381da2fd
4 changed files with 15 additions and 4 deletions

View File

@@ -1708,7 +1708,8 @@ dosurface:
(unsigned int)final_width,
(unsigned int)final_height);
sdl.surface = SDL_SetVideoMode(final_width, final_height, bpp, (flags & GFX_CAN_RANDOM) ? SDL_SWSURFACE | SDL_RESIZABLE : SDL_HWSURFACE | SDL_RESIZABLE);
sdl.surface = SDL_SetVideoMode(final_width, final_height, bpp,
((flags & GFX_CAN_RANDOM) ? SDL_SWSURFACE : SDL_HWSURFACE) | SDL_HAX_NOREFRESH | SDL_RESIZABLE);
sdl.deferred_resize = false;
sdl.must_redraw_all = true;
@@ -2940,6 +2941,10 @@ void GFX_EndUpdate( const Bit16u *changedLines ) {
if (changedLines != NULL) {
sdl.must_redraw_all = false;
#if !defined(C_SDL2)
sdl.surface->flags &= ~SDL_HAX_NOREFRESH;
#endif
if (changedLines != NULL && sdl.deferred_resize) {
sdl.deferred_resize = false;
#if defined(C_SDL2)

View File

@@ -143,6 +143,7 @@ typedef struct SDL_Surface {
#define SDL_OPENGLBLIT 0x0000000A /**< Create an OpenGL rendering context and use it for blitting */
#define SDL_RESIZABLE 0x00000010 /**< This video mode may be resized */
#define SDL_NOFRAME 0x00000020 /**< No window caption or edge frame */
#define SDL_HAX_NOREFRESH 0x10000000/**< DOSBox-X specific: Disable auto-redraw of the window when repainting is needed */
/*@}*/
/** Used internally (read-only) */

View File

@@ -303,6 +303,11 @@ void X11_RefreshDisplay(_THIS)
SDL_PrivateExpose();
return;
}
/* DOSBox-X: SDL_SetVideoMode() can specify a flag not to auto-redraw (to avoid flickering) */
if (this->screen->flags & SDL_HAX_NOREFRESH)
return;
#ifndef NO_SHARED_MEMORY
if ( this->UpdateRects == X11_MITSHMUpdate ) {
XShmPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage,

View File

@@ -1260,8 +1260,8 @@ SDL_Surface *X11_SetVideoMode(_THIS, SDL_Surface *current,
}
/* Clear these flags and set them only if they are in the new set. */
current->flags &= ~(SDL_RESIZABLE|SDL_NOFRAME);
current->flags |= (flags&(SDL_RESIZABLE|SDL_NOFRAME));
current->flags &= ~(SDL_RESIZABLE|SDL_NOFRAME|SDL_HAX_NOREFRESH);
current->flags |= (flags&(SDL_RESIZABLE|SDL_NOFRAME|SDL_HAX_NOREFRESH));
done:
/* Release the event thread */