# HG changeset patch
# User Sam Lantinga <slouken@libsdl.org>
# Date 1055575120 0
# Node ID 44d574ed4780f3fe795a3d9d9e36dc83f3b2e64c
# Parent  873c2598f96983bb565c32637eba6a358e31faa8
Date: Thu, 05 Jun 2003 09:36:40 +0100
From: "alan buckley" <alan_baa@hotmail.com>
Subject: Modification for RISC OS SDL port

My name is Alan Buckley and I have been working on the RISC OS SDL port.

I've attached a modification to SDL_WimpVideo.c to this email that ensures
the Window is displayed immediately when the video mode is set to a windowed
mode.

diff -r 873c2598f969 -r 44d574ed4780 src/video/riscos/SDL_wimpvideo.c
--- a/src/video/riscos/SDL_wimpvideo.c	Tue Jun 03 19:35:10 2003 +0000
+++ b/src/video/riscos/SDL_wimpvideo.c	Sat Jun 14 07:18:40 2003 +0000
@@ -80,6 +80,9 @@
 extern int mouseInWindow;
 extern int riscos_closeaction;
 
+/* Following needed to ensure window is shown immediately */
+extern int hasFocus;
+extern void WIMP_Poll(_THIS, int waitTime);
 
 SDL_Surface *WIMP_SetVideoMode(_THIS, SDL_Surface *current,
 				int width, int height, int bpp, Uint32 flags)
@@ -177,9 +180,21 @@
 	/* Reset device functions for the wimp */
 	WIMP_SetDeviceMode(this);
 
-    /* Needs to set up plot info after window has been created */
-    /* Not sure why, but plots don't work if I do it earlier */
-    WIMP_SetupPlotInfo(this);
+	/* Needs to set up plot info after window has been created */
+	/* Not sure why, but plots don't work if I do it earlier */
+	WIMP_SetupPlotInfo(this);
+
+	/* Poll until window is shown */
+	{
+	   /* We wait until it gets the focus, but give up after 5 seconds
+	      in case the focus is prevented in any way.
+	   */
+	   Uint32 now = SDL_GetTicks();
+	   while (!hasFocus && SDL_GetTicks() - now < 5000)
+	   {
+	      WIMP_Poll(this, 0);
+	   }
+	}
 
 	/* We're done */
 	return(current);