Skip to content

Commit

Permalink
events: Don't send SDL_VIDEOEXPOSE events during window creation.
Browse files Browse the repository at this point in the history
SDL 1.2 doesn't do so either, at least on X11, and doing so triggers a bug
in Bloboats, so we'll avoid it to try to maximize compatibility.

Fixes #229.
  • Loading branch information
icculus committed Oct 7, 2022
1 parent eba13ef commit f388224
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/SDL12_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,7 @@ static SDL12_PixelFormat VideoInfoVfmt12;
static SDL_PixelFormat *VideoInfoVfmt20 = NULL;
static SDL_bool VideoWindowGrabbed = SDL_FALSE;
static SDL_bool VideoCursorHidden = SDL_FALSE;
static SDL_bool SetVideoModeInProgress = SDL_FALSE;
static SDL_Window *VideoWindow20 = NULL;
static SDL_Renderer *VideoRenderer20 = NULL;
static SDL_mutex *VideoRendererLock = NULL;
Expand Down Expand Up @@ -4334,7 +4335,10 @@ EventFilter20to12(void *data, SDL_Event *event20)

case SDL_WINDOWEVENT_SHOWN:
case SDL_WINDOWEVENT_EXPOSED:
event12.type = SDL12_VIDEOEXPOSE;
/* drop these during window creation (see issue #229) */
if (!SetVideoModeInProgress) {
event12.type = SDL12_VIDEOEXPOSE;
}
break;

case SDL_WINDOWEVENT_RESIZED: {
Expand Down Expand Up @@ -5695,8 +5699,8 @@ UnlockVideoRenderer(void)

static void HandleInputGrab(SDL12_GrabMode mode);

DECLSPEC12 SDL12_Surface * SDLCALL
SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags12)
static SDL12_Surface *
SetVideoModeImpl(int width, int height, int bpp, Uint32 flags12)
{
SDL_DisplayMode dmode;
Uint32 fullscreen_flags20 = 0;
Expand Down Expand Up @@ -6130,9 +6134,21 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags12)
UnlockVideoRenderer();
}

SDL_PumpEvents(); /* run this once at startup. */

return VideoSurface12;
}

DECLSPEC12 SDL12_Surface * SDLCALL
SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags12)
{
SDL12_Surface *retval;
SetVideoModeInProgress = SDL_TRUE;
retval = SetVideoModeImpl(width, height, bpp, flags12);
SetVideoModeInProgress = SDL_FALSE;
return retval;
}

DECLSPEC12 SDL12_Surface * SDLCALL
SDL_GetVideoSurface(void)
{
Expand Down

0 comments on commit f388224

Please sign in to comment.