GAPI fixes from Stefan Klug SDL-1.2
authorSam Lantinga <slouken@libsdl.org>
Mon, 16 Feb 2009 22:32:34 +0000
branchSDL-1.2
changeset 41623b7fc3416601
parent 4161 bd91db0b0b5d
child 4163 bec67d0b6645
GAPI fixes from Stefan Klug
src/events/SDL_keyboard.c
src/video/gapi/SDL_gapivideo.c
src/video/gapi/SDL_gapivideo.h
src/video/wincommon/SDL_sysevents.c
src/video/windib/SDL_dibevents.c
src/video/windib/SDL_dibvideo.c
src/video/windib/SDL_dibvideo.h
src/video/windib/SDL_gapidibvideo.h
     1.1 --- a/src/events/SDL_keyboard.c	Fri Jan 30 01:40:44 2009 +0000
     1.2 +++ b/src/events/SDL_keyboard.c	Mon Feb 16 22:32:34 2009 +0000
     1.3 @@ -73,7 +73,7 @@
     1.4  	SDL_EnableKeyRepeat(0, 0);
     1.5  
     1.6  	/* Allow environment override to disable special lock-key behavior */
     1.7 -	env = getenv("SDL_NO_LOCK_KEYS");
     1.8 +	env = SDL_getenv("SDL_NO_LOCK_KEYS");
     1.9  	SDL_NoLockKeys = 0;
    1.10  	if (env) {
    1.11  		switch (SDL_atoi(env)) {
     2.1 --- a/src/video/gapi/SDL_gapivideo.c	Fri Jan 30 01:40:44 2009 +0000
     2.2 +++ b/src/video/gapi/SDL_gapivideo.c	Mon Feb 16 22:32:34 2009 +0000
     2.3 @@ -52,8 +52,11 @@
     2.4  #include "../wincommon/SDL_sysmouse_c.h"
     2.5  #include "../windib/SDL_dibevents_c.h" 
     2.6  
     2.7 +#include "../windib/SDL_gapidibvideo.h"
     2.8  #include "SDL_gapivideo.h"
     2.9  
    2.10 +#define gapi this->hidden->gapiInfo
    2.11 +
    2.12  #define GAPIVID_DRIVER_NAME "gapi"
    2.13  
    2.14  #if defined(DEBUG) || defined (_DEBUG) || defined(NDEBUG)
    2.15 @@ -98,6 +101,7 @@
    2.16  static void GAPI_FreeHWSurface(_THIS, SDL_Surface *surface);
    2.17  
    2.18  /* Windows message handling functions, will not be processed */
    2.19 +static void GAPI_Activate(_THIS, BOOL active, BOOL minimized);
    2.20  static void GAPI_RealizePalette(_THIS);
    2.21  static void GAPI_PaletteChanged(_THIS, HWND window);
    2.22  static void GAPI_WinPAINT(_THIS, HDC hdc); 
    2.23 @@ -160,6 +164,11 @@
    2.24  	ReleaseDC(NULL, hdc);
    2.25  	g_bRawBufferAvailable = result > 0;
    2.26  
    2.27 +	//My Asus MyPAL 696 reports the RAWFRAMEBUFFER as available, but with a size of 0 x 0
    2.28 +	if(g_RawFrameBufferInfo.cxPixels <= 0 || g_RawFrameBufferInfo.cyPixels <= 0){
    2.29 +		g_bRawBufferAvailable = 0;
    2.30 +	}
    2.31 +
    2.32  #if WITHOUT_GAPI
    2.33  	return g_bRawBufferAvailable;
    2.34  #endif
    2.35 @@ -247,6 +256,7 @@
    2.36  		FreeLibrary(g_hGapiLib);
    2.37  		g_hGapiLib = 0;
    2.38  	}
    2.39 +	SDL_free(device->hidden->gapiInfo);
    2.40  	SDL_free(device->hidden);
    2.41  	SDL_free(device);
    2.42  }
    2.43 @@ -270,6 +280,15 @@
    2.44  		SDL_memset(device, 0, (sizeof *device));
    2.45  		device->hidden = (struct SDL_PrivateVideoData *)
    2.46  				SDL_malloc((sizeof *device->hidden));
    2.47 +		if(device->hidden){
    2.48 +			SDL_memset(device->hidden, 0, (sizeof *device->hidden));
    2.49 +			device->hidden->gapiInfo = (GapiInfo *)SDL_malloc((sizeof(GapiInfo)));
    2.50 +			if(device->hidden->gapiInfo == NULL)
    2.51 +			{
    2.52 +				SDL_free(device->hidden);
    2.53 +				device->hidden = NULL;
    2.54 +			}
    2.55 +		}
    2.56  	}
    2.57  	if ( (device == NULL) || (device->hidden == NULL) ) {
    2.58  		SDL_OutOfMemory();
    2.59 @@ -278,7 +297,7 @@
    2.60  		}
    2.61  		return(0);
    2.62  	}
    2.63 -	SDL_memset(device->hidden, 0, (sizeof *device->hidden));
    2.64 +	SDL_memset(device->hidden->gapiInfo, 0, (sizeof *device->hidden->gapiInfo));
    2.65  
    2.66  	/* Set the function pointers */
    2.67  	device->VideoInit = GAPI_VideoInit;
    2.68 @@ -312,6 +331,7 @@
    2.69  	device->PumpEvents = DIB_PumpEvents;
    2.70  
    2.71  	/* Set up the windows message handling functions */
    2.72 +	WIN_Activate = GAPI_Activate;
    2.73  	WIN_RealizePalette = GAPI_RealizePalette;
    2.74  	WIN_PaletteChanged = GAPI_PaletteChanged;
    2.75  	WIN_WinPAINT = GAPI_WinPAINT;
    2.76 @@ -320,7 +340,7 @@
    2.77  	device->free = GAPI_DeleteDevice;
    2.78  
    2.79  	/* Load gapi library */
    2.80 -#define gx device->hidden->gxFunc
    2.81 +#define gx device->hidden->gapiInfo->gxFunc
    2.82  
    2.83      LINK( GXOpenDisplay, gx.GXOpenDisplay,         "?GXOpenDisplay@@YAHPAUHWND__@@K@Z" )
    2.84      LINK( GXCloseDisplay, gx.GXCloseDisplay,        "?GXCloseDisplay@@YAHXZ" )
    2.85 @@ -369,23 +389,23 @@
    2.86  
    2.87  	if( !useVga )
    2.88  	{
    2.89 -		this->hidden->gxProperties = this->hidden->gxFunc.GXGetDisplayProperties();
    2.90 -		this->hidden->needUpdate = 1;
    2.91 -		this->hidden->hiresFix = 0;
    2.92 -		this->hidden->useVga = 0;
    2.93 -		this->hidden->useGXOpenDisplay = 1;
    2.94 +		gapi->gxProperties = gapi->gxFunc.GXGetDisplayProperties();
    2.95 +		gapi->needUpdate = 1;
    2.96 +		gapi->hiresFix = 0;
    2.97 +		gapi->useVga = 0;
    2.98 +		gapi->useGXOpenDisplay = 1;
    2.99  
   2.100  #ifdef _ARM_
   2.101  		/* check some devices and extract addition info */
   2.102  		SystemParametersInfo( SPI_GETOEMINFO, sizeof( oemstr ), oemstr, 0 );
   2.103  
   2.104  		// buggy iPaq38xx
   2.105 -		if ((oemstr[12] == 'H') && (oemstr[13] == '3') && (oemstr[14] == '8') && (this->hidden->gxProperties.cbxPitch > 0)) 
   2.106 +		if ((oemstr[12] == 'H') && (oemstr[13] == '3') && (oemstr[14] == '8') && (gapi->gxProperties.cbxPitch > 0)) 
   2.107  		{
   2.108 -			this->hidden->videoMem = (PIXEL*)0xac0755a0;
   2.109 -			this->hidden->gxProperties.cbxPitch = -640;
   2.110 -			this->hidden->gxProperties.cbyPitch = 2;
   2.111 -			this->hidden->needUpdate = 0;
   2.112 +			gapi->videoMem = (PIXEL*)0xac0755a0;
   2.113 +			gapi->gxProperties.cbxPitch = -640;
   2.114 +			gapi->gxProperties.cbyPitch = 2;
   2.115 +			gapi->needUpdate = 0;
   2.116  		}
   2.117  #if (EMULATE_AXIM_X30 == 0)
   2.118  		// buggy Dell Axim X30
   2.119 @@ -400,36 +420,36 @@
   2.120  			result = ExtEscape(hdc, GETGXINFO, 0, NULL, sizeof(gxInfo), (char *)&gxInfo);
   2.121  			if( result > 0 )
   2.122  			{
   2.123 -				this->hidden->useGXOpenDisplay = 0;
   2.124 -				this->hidden->videoMem = gxInfo.pvFrameBuffer;
   2.125 -				this->hidden->needUpdate = 0;
   2.126 -				this->hidden->gxProperties.cbxPitch = 2;
   2.127 -				this->hidden->gxProperties.cbyPitch = 480;
   2.128 -				this->hidden->gxProperties.cxWidth = gxInfo.cxWidth;
   2.129 -				this->hidden->gxProperties.cyHeight = gxInfo.cyHeight;
   2.130 -				this->hidden->gxProperties.ffFormat = gxInfo.ffFormat;
   2.131 +				gapi->useGXOpenDisplay = 0;
   2.132 +				gapi->videoMem = gxInfo.pvFrameBuffer;
   2.133 +				gapi->needUpdate = 0;
   2.134 +				gapi->gxProperties.cbxPitch = 2;
   2.135 +				gapi->gxProperties.cbyPitch = 480;
   2.136 +				gapi->gxProperties.cxWidth = gxInfo.cxWidth;
   2.137 +				gapi->gxProperties.cyHeight = gxInfo.cyHeight;
   2.138 +				gapi->gxProperties.ffFormat = gxInfo.ffFormat;
   2.139  			}
   2.140  		}
   2.141  #endif
   2.142  	} else
   2.143  	{
   2.144 -	    this->hidden->needUpdate = 0;		
   2.145 -		this->hidden->hiresFix = 0;
   2.146 -		this->hidden->gxProperties.cBPP = g_RawFrameBufferInfo.wBPP;
   2.147 -		this->hidden->gxProperties.cbxPitch = g_RawFrameBufferInfo.cxStride;
   2.148 -		this->hidden->gxProperties.cbyPitch = g_RawFrameBufferInfo.cyStride;
   2.149 -		this->hidden->gxProperties.cxWidth = g_RawFrameBufferInfo.cxPixels;
   2.150 -		this->hidden->gxProperties.cyHeight = g_RawFrameBufferInfo.cyPixels;
   2.151 -		this->hidden->videoMem = g_RawFrameBufferInfo.pFramePointer;
   2.152 -		this->hidden->useVga = 1;
   2.153 +		gapi->needUpdate = 0;		
   2.154 +		gapi->hiresFix = 0;
   2.155 +		gapi->gxProperties.cBPP = g_RawFrameBufferInfo.wBPP;
   2.156 +		gapi->gxProperties.cbxPitch = g_RawFrameBufferInfo.cxStride;
   2.157 +		gapi->gxProperties.cbyPitch = g_RawFrameBufferInfo.cyStride;
   2.158 +		gapi->gxProperties.cxWidth = g_RawFrameBufferInfo.cxPixels;
   2.159 +		gapi->gxProperties.cyHeight = g_RawFrameBufferInfo.cyPixels;
   2.160 +		gapi->videoMem = g_RawFrameBufferInfo.pFramePointer;
   2.161 +		gapi->useVga = 1;
   2.162  
   2.163  		switch( g_RawFrameBufferInfo.wFormat )
   2.164  		{
   2.165  		case FORMAT_565:
   2.166 -			this->hidden->gxProperties.ffFormat = kfDirect565;
   2.167 +			gapi->gxProperties.ffFormat = kfDirect565;
   2.168  			break;
   2.169  		case FORMAT_555:
   2.170 -			this->hidden->gxProperties.ffFormat = kfDirect555;
   2.171 +			gapi->gxProperties.ffFormat = kfDirect555;
   2.172  			break;
   2.173  		default:
   2.174  			/* unknown pixel format, try define by BPP! */
   2.175 @@ -437,31 +457,31 @@
   2.176  			{
   2.177  			case 4:
   2.178  			case 8:
   2.179 -				this->hidden->gxProperties.ffFormat = kfDirect;
   2.180 +				gapi->gxProperties.ffFormat = kfDirect;
   2.181  			case 16:
   2.182 -				this->hidden->gxProperties.ffFormat = kfDirect565;
   2.183 +				gapi->gxProperties.ffFormat = kfDirect565;
   2.184  			default:
   2.185 -				this->hidden->gxProperties.ffFormat = kfDirect;
   2.186 +				gapi->gxProperties.ffFormat = kfDirect;
   2.187  				break;
   2.188  			}
   2.189  		}
   2.190  	}
   2.191  
   2.192 -	if( this->hidden->gxProperties.cBPP != 16 )
   2.193 +	if( gapi->gxProperties.cBPP != 16 )
   2.194  	{
   2.195 -		this->hidden->gapiOrientation = SDL_ORIENTATION_UP;
   2.196 +		gapi->gapiOrientation = SDL_ORIENTATION_UP;
   2.197  	} else
   2.198 -	if( (this->hidden->gxProperties.cbxPitch > 0) && (this->hidden->gxProperties.cbyPitch > 0 ))
   2.199 +	if( (gapi->gxProperties.cbxPitch > 0) && (gapi->gxProperties.cbyPitch > 0 ))
   2.200  	{
   2.201 -		this->hidden->gapiOrientation = SDL_ORIENTATION_UP;
   2.202 +		gapi->gapiOrientation = SDL_ORIENTATION_UP;
   2.203  	} else
   2.204 -	if( (this->hidden->gxProperties.cbxPitch > 0) && (this->hidden->gxProperties.cbyPitch < 0 ))
   2.205 +	if( (gapi->gxProperties.cbxPitch > 0) && (gapi->gxProperties.cbyPitch < 0 ))
   2.206  	{
   2.207 -		this->hidden->gapiOrientation = SDL_ORIENTATION_RIGHT; // ipaq 3660
   2.208 +		gapi->gapiOrientation = SDL_ORIENTATION_RIGHT; // ipaq 3660
   2.209  	} else
   2.210 -	if( (this->hidden->gxProperties.cbxPitch < 0) && (this->hidden->gxProperties.cbyPitch > 0 ))
   2.211 +	if( (gapi->gxProperties.cbxPitch < 0) && (gapi->gxProperties.cbyPitch > 0 ))
   2.212  	{
   2.213 -		this->hidden->gapiOrientation = SDL_ORIENTATION_LEFT; // ipaq 3800
   2.214 +		gapi->gapiOrientation = SDL_ORIENTATION_LEFT; // ipaq 3800
   2.215  	}
   2.216  }
   2.217  
   2.218 @@ -537,9 +557,11 @@
   2.219  		GAPI_AddMode(this, bpp, gapi->gxProperties.cxWidth, gapi->gxProperties.cyHeight);	
   2.220  	}
   2.221  
   2.222 -	/* Determine the current screen size */
   2.223 -	this->info.current_w = gapi->gxProperties.cxWidth;
   2.224 -	this->info.current_h = gapi->gxProperties.cyHeight;
   2.225 +	/* Determine the current screen size.
   2.226 +	 * This is NOT necessarily the size of the Framebuffer or GAPI, as they return
   2.227 +	 * the displaysize in ORIENTATION_UP */
   2.228 +	this->info.current_w = GetSystemMetrics(SM_CXSCREEN);
   2.229 +	this->info.current_h = GetSystemMetrics(SM_CYSCREEN);
   2.230  
   2.231  	/* Sort the mode lists */
   2.232  	for ( i=0; i<NUM_MODELISTS; ++i ) {
   2.233 @@ -548,39 +570,39 @@
   2.234  		}
   2.235  	}
   2.236  
   2.237 -	vformat->BitsPerPixel = this->hidden->gxProperties.cBPP < 8 ? 16 : (unsigned char)this->hidden->gxProperties.cBPP;
   2.238 +	vformat->BitsPerPixel = gapi->gxProperties.cBPP < 8 ? 16 : (unsigned char)gapi->gxProperties.cBPP;
   2.239  
   2.240  	// Get color mask
   2.241 -	if (this->hidden->gxProperties.ffFormat & kfDirect565) {
   2.242 +	if (gapi->gxProperties.ffFormat & kfDirect565) {
   2.243  		vformat->BitsPerPixel = 16;
   2.244  		vformat->Rmask = 0x0000f800;
   2.245  		vformat->Gmask = 0x000007e0;
   2.246  		vformat->Bmask = 0x0000001f;
   2.247 -		this->hidden->videoMode = GAPI_DIRECT_565;
   2.248 +		gapi->videoMode = GAPI_DIRECT_565;
   2.249  	}
   2.250  	else
   2.251 -	if (this->hidden->gxProperties.ffFormat & kfDirect555) {
   2.252 +	if (gapi->gxProperties.ffFormat & kfDirect555) {
   2.253  		vformat->BitsPerPixel = 16;
   2.254  		vformat->Rmask = 0x00007c00;
   2.255  		vformat->Gmask = 0x000003e0;
   2.256  		vformat->Bmask = 0x0000001f;
   2.257 -		this->hidden->videoMode = GAPI_DIRECT_555;
   2.258 +		gapi->videoMode = GAPI_DIRECT_555;
   2.259  	}
   2.260  	else
   2.261 -	if ((this->hidden->gxProperties.ffFormat & kfDirect) && (this->hidden->gxProperties.cBPP < 8)) {
   2.262 +	if ((gapi->gxProperties.ffFormat & kfDirect) && (gapi->gxProperties.cBPP < 8)) {
   2.263  		// We'll perform the conversion
   2.264  		vformat->BitsPerPixel = 16;
   2.265  		vformat->Rmask = 0x0000f800; // 16 bit 565
   2.266  		vformat->Gmask = 0x000007e0;
   2.267  		vformat->Bmask = 0x0000001f;
   2.268 -		if (this->hidden->gxProperties.ffFormat & kfDirectInverted)
   2.269 -			this->hidden->invert = (1 << this->hidden->gxProperties.cBPP) - 1;
   2.270 -		this->hidden->colorscale = this->hidden->gxProperties.cBPP < 8 ? 8 - this->hidden->gxProperties.cBPP : 0;
   2.271 -		this->hidden->videoMode = GAPI_MONO;
   2.272 +		if (gapi->gxProperties.ffFormat & kfDirectInverted)
   2.273 +			gapi->invert = (1 << gapi->gxProperties.cBPP) - 1;
   2.274 +		gapi->colorscale = gapi->gxProperties.cBPP < 8 ? 8 - gapi->gxProperties.cBPP : 0;
   2.275 +		gapi->videoMode = GAPI_MONO;
   2.276  	}
   2.277  	else
   2.278 -	if (this->hidden->gxProperties.ffFormat & kfPalette) {
   2.279 -		this->hidden->videoMode = GAPI_PALETTE;
   2.280 +	if (gapi->gxProperties.ffFormat & kfPalette) {
   2.281 +		gapi->videoMode = GAPI_PALETTE;
   2.282  	} 
   2.283  
   2.284  	/* We're done! */
   2.285 @@ -589,7 +611,7 @@
   2.286  
   2.287  SDL_Rect **GAPI_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
   2.288  {
   2.289 -	return(this->hidden->SDL_modelist[((format->BitsPerPixel+7)/8)-1]);
   2.290 +	return(gapi->SDL_modelist[((format->BitsPerPixel+7)/8)-1]);
   2.291  //  	 return (SDL_Rect **) -1;
   2.292  }
   2.293  
   2.294 @@ -600,6 +622,7 @@
   2.295  	Uint32 Rmask, Gmask, Bmask; 
   2.296  	DWORD style; 
   2.297  	SDL_Rect allScreen;
   2.298 +	SDL_ScreenOrientation systemOrientation;
   2.299  
   2.300  	if( bpp < 4 )
   2.301  	{
   2.302 @@ -621,7 +644,7 @@
   2.303  			case 15:				
   2.304  			case 16:
   2.305  				/* Default is 565 unless the display is specifically 555 */
   2.306 -				if (this->hidden->gxProperties.ffFormat & kfDirect555) {
   2.307 +				if (gapi->gxProperties.ffFormat & kfDirect555) {
   2.308  					Rmask = 0x00007c00;
   2.309  					Gmask = 0x000003e0;
   2.310  					Bmask = 0x0000001f;
   2.311 @@ -651,7 +674,7 @@
   2.312  	}
   2.313  
   2.314  	gapi->userOrientation = SDL_ORIENTATION_UP;
   2.315 -       gapi->systemOrientation = SDL_ORIENTATION_UP;
   2.316 +	systemOrientation = SDL_ORIENTATION_UP;
   2.317  	video->flags = SDL_FULLSCREEN;	/* Clear flags, GAPI supports fullscreen only */
   2.318  
   2.319  	/* GAPI or VGA? */
   2.320 @@ -664,7 +687,7 @@
   2.321  	} else
   2.322  		FillStructs(this, 1);
   2.323  
   2.324 -	if ( !this->hidden->needUpdate && !this->hidden->videoMem) {
   2.325 +	if ( !gapi->needUpdate && !gapi->videoMem) {
   2.326  		SDL_SetError("Couldn't get address of video memory, may be unsupported device or bug");
   2.327  		return(NULL);
   2.328  	}
   2.329 @@ -674,11 +697,11 @@
   2.330  		gapi->userOrientation = SDL_ORIENTATION_RIGHT;
   2.331  
   2.332         if(GetSystemMetrics(SM_CYSCREEN) < GetSystemMetrics(SM_CXSCREEN))
   2.333 -               gapi->systemOrientation = SDL_ORIENTATION_RIGHT;
   2.334 +		systemOrientation = SDL_ORIENTATION_RIGHT;
   2.335  
   2.336  	/* shall we apply hires fix? for example when we do not use hires resource */
   2.337  	gapi->hiresFix = 0;
   2.338 -       if( gapi->systemOrientation == gapi->userOrientation )
   2.339 +	if( systemOrientation == gapi->userOrientation )
   2.340  	{
   2.341                 if( (width > GetSystemMetrics(SM_CXSCREEN)) || (height > GetSystemMetrics(SM_CYSCREEN)))
   2.342  			gapi->hiresFix = 1;
   2.343 @@ -700,7 +723,7 @@
   2.344  		case SDL_ORIENTATION_UP:
   2.345  		case SDL_ORIENTATION_RIGHT:
   2.346  		case SDL_ORIENTATION_LEFT:
   2.347 -			if( (this->hidden->videoMode == GAPI_MONO) )
   2.348 +			if( (gapi->videoMode == GAPI_MONO) )
   2.349  				gapi->startOffset = -gapi->gxProperties.cbxPitch + 1; // monochrome mode
   2.350  			else
   2.351  				gapi->startOffset = gapi->gxProperties.cbyPitch * (gapi->gxProperties.cyHeight - 1);
   2.352 @@ -711,8 +734,8 @@
   2.353  		}
   2.354  	}
   2.355  
   2.356 -	video->w = this->hidden->w = width;
   2.357 -	video->h = this->hidden->h = height;
   2.358 +	video->w = gapi->w = width;
   2.359 +	video->h = gapi->h = height;
   2.360  	video->pitch = SDL_CalculatePitch(video); 
   2.361  
   2.362  	/* Small fix for WinCE/Win32 - when activating window
   2.363 @@ -729,20 +752,20 @@
   2.364  		SetWindowLong(SDL_Window, GWL_STYLE, style);
   2.365  
   2.366  	/* Allocate bitmap */
   2.367 -	if(gapiBuffer) 
   2.368 +	if( gapi->buffer ) 
   2.369  	{
   2.370 -		SDL_free(gapiBuffer);
   2.371 -		gapiBuffer = NULL;
   2.372 +		SDL_free( gapi->buffer );
   2.373 +		gapi->buffer = NULL;
   2.374  	}
   2.375 -	gapiBuffer = SDL_malloc(video->h * video->pitch);
   2.376 -	video->pixels = gapiBuffer; 
   2.377 +	gapi->buffer = SDL_malloc(video->h * video->pitch);
   2.378 +	video->pixels = gapi->buffer; 
   2.379  
   2.380 -	if ( ! this->hidden->buffer ) {
   2.381 +	if ( ! gapi->buffer ) {
   2.382  		SDL_SetError("Couldn't allocate buffer for requested mode");
   2.383  		return(NULL);
   2.384  	}
   2.385  
   2.386 -	SDL_memset(gapiBuffer, 255, video->h * video->pitch);
   2.387 +	SDL_memset(gapi->buffer, 255, video->h * video->pitch);
   2.388  	MoveWindow(SDL_Window, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), FALSE);
   2.389  	ShowWindow(SDL_Window, SW_SHOW);
   2.390  	SetForegroundWindow(SDL_Window);
   2.391 @@ -754,9 +777,9 @@
   2.392  	WIN_FlushMessageQueue();
   2.393  
   2.394  	/* Open GAPI display */
   2.395 -       if( !gapi->useVga && this->hidden->useGXOpenDisplay && !this->hidden->alreadyGXOpened )
   2.396 +       if( !gapi->useVga && gapi->useGXOpenDisplay && !gapi->alreadyGXOpened )
   2.397         {
   2.398 -               this->hidden->alreadyGXOpened = 1;
   2.399 +               gapi->alreadyGXOpened = 1;
   2.400  		if( !gapi->gxFunc.GXOpenDisplay(SDL_Window, GX_FULLSCREEN) )
   2.401  		{
   2.402  			SDL_SetError("Couldn't initialize GAPI");
   2.403 @@ -764,6 +787,11 @@
   2.404  		}
   2.405         }
   2.406  
   2.407 +	if(gapi->useVga)
   2.408 +		gapi->coordinateTransform = (4 - systemOrientation + gapi->userOrientation) % 4;
   2.409 +	else
   2.410 +		gapi->coordinateTransform = gapi->userOrientation;
   2.411 +
   2.412  #if REPORT_VIDEO_INFO
   2.413  	printf("Video properties:\n");
   2.414  	printf("display bpp: %d\n", gapi->gxProperties.cBPP);
   2.415 @@ -775,11 +803,11 @@
   2.416  	printf("y pitch: %d\n", gapi->gxProperties.cbyPitch);
   2.417  	printf("gapi flags: 0x%x\n", gapi->gxProperties.ffFormat);
   2.418         printf("user orientation: %d\n", gapi->userOrientation);
   2.419 -       printf("system orientation: %d\n", gapi->userOrientation);
   2.420 +	printf("system orientation: %d\n", systemOrientation);
   2.421         printf("gapi orientation: %d\n", gapi->gapiOrientation);
   2.422  
   2.423  
   2.424 -	if( !gapi->useVga && this->hidden->useGXOpenDisplay && gapi->needUpdate)
   2.425 +	if( !gapi->useVga && gapi->useGXOpenDisplay && gapi->needUpdate)
   2.426  	{
   2.427  		gapi->videoMem = gapi->gxFunc.GXBeginDraw(); 
   2.428  		gapi->gxFunc.GXEndDraw();
   2.429 @@ -793,6 +821,7 @@
   2.430  	printf("video surface bpp: %d\n", video->format->BitsPerPixel);
   2.431  	printf("video surface width: %d\n", video->w);
   2.432  	printf("video surface height: %d\n", video->h);
   2.433 +	printf("mouse/arrows transformation angle: %d\n", gapi->coordinateTransform);
   2.434  #endif
   2.435  
   2.436  
   2.437 @@ -1143,8 +1172,8 @@
   2.438  	/* Destroy the window and everything associated with it */
   2.439  	if ( SDL_Window ) 
   2.440  	{
   2.441 -	    if ((g_hGapiLib != 0) && this && this->hidden && this->hidden->gxFunc.GXCloseDisplay && !this->hidden->useVga)
   2.442 -			this->hidden->gxFunc.GXCloseDisplay(); 
   2.443 +	    if ((g_hGapiLib != 0) && this && gapi && gapi->gxFunc.GXCloseDisplay && !gapi->useVga)
   2.444 +			gapi->gxFunc.GXCloseDisplay(); 
   2.445  
   2.446  		if (this->screen->pixels != NULL)
   2.447  		{
   2.448 @@ -1184,6 +1213,11 @@
   2.449  
   2.450  }
   2.451  
   2.452 +static void GAPI_Activate(_THIS, BOOL active, BOOL minimized)
   2.453 +{
   2.454 +	//Nothing to do here (as far as I know)
   2.455 +}
   2.456 +
   2.457  static void GAPI_RealizePalette(_THIS)
   2.458  {
   2.459  	OutputDebugString(TEXT("GAPI_RealizePalette NOT IMPLEMENTED !\r\n"));
   2.460 @@ -1215,12 +1249,12 @@
   2.461  
   2.462      // DIB Header
   2.463      pHeader->biSize            = sizeof(BITMAPINFOHEADER);
   2.464 -    pHeader->biWidth           = this->hidden->w;
   2.465 -    pHeader->biHeight          = -this->hidden->h;
   2.466 +    pHeader->biWidth           = gapi->w;
   2.467 +    pHeader->biHeight          = -gapi->h;
   2.468      pHeader->biPlanes          = 1;
   2.469      pHeader->biBitCount        = bpp;
   2.470      pHeader->biCompression     = BI_RGB;
   2.471 -    pHeader->biSizeImage       = (this->hidden->w * this->hidden->h * bpp) / 8;
   2.472 +    pHeader->biSizeImage       = (gapi->w * gapi->h * bpp) / 8;
   2.473  	
   2.474      // Color masks
   2.475  	if( bpp == 16 )
   2.476 @@ -1235,11 +1269,11 @@
   2.477  
   2.478  	// copy data
   2.479  	// FIXME: prevent misalignment, but I've never seen non aligned width of screen
   2.480 -	memcpy(bitmapData, this->hidden->buffer, pHeader->biSizeImage);
   2.481 +	memcpy(bitmapData, gapi->buffer, pHeader->biSizeImage);
   2.482  	srcDC = CreateCompatibleDC(hdc);
   2.483  	prevObject = SelectObject(srcDC, hb);
   2.484  
   2.485 -	BitBlt(hdc, 0, 0, this->hidden->w, this->hidden->h, srcDC, 0, 0, SRCCOPY);
   2.486 +	BitBlt(hdc, 0, 0, gapi->w, gapi->h, srcDC, 0, 0, SRCCOPY);
   2.487  
   2.488  	SelectObject(srcDC, prevObject);
   2.489  	DeleteObject(hb);
     3.1 --- a/src/video/gapi/SDL_gapivideo.h	Fri Jan 30 01:40:44 2009 +0000
     3.2 +++ b/src/video/gapi/SDL_gapivideo.h	Mon Feb 16 22:32:34 2009 +0000
     3.3 @@ -27,6 +27,7 @@
     3.4  #include "SDL_mouse.h"
     3.5  #include "SDL_mutex.h"
     3.6  #include "../SDL_sysvideo.h"
     3.7 +#include "../windib/SDL_gapidibvideo.h"
     3.8  
     3.9  /* From gx.h, since it's not really C compliant */
    3.10  
    3.11 @@ -100,13 +101,6 @@
    3.12  #define GX_NORMALKEYS   0x02
    3.13  #define GX_LANDSCAPEKEYS        0x03
    3.14  
    3.15 -typedef enum
    3.16 -{
    3.17 -	SDL_ORIENTATION_UP,
    3.18 -	SDL_ORIENTATION_DOWN,
    3.19 -	SDL_ORIENTATION_LEFT,
    3.20 -	SDL_ORIENTATION_RIGHT
    3.21 -} SDL_ScreenOrientation;
    3.22  
    3.23  /* GAPI video mode */
    3.24  typedef enum {
    3.25 @@ -117,26 +111,26 @@
    3.26  	GAPI_PALETTE
    3.27  } GAPIVideoMode; 
    3.28  
    3.29 -/* Hidden "this" pointer for the video functions */
    3.30 -#define _THIS	SDL_VideoDevice *this
    3.31 -
    3.32  typedef unsigned short PIXEL;
    3.33  
    3.34  /* Private display data 
    3.35     begin with DIB private structure to allow DIB events code sharing
    3.36  */
    3.37 -struct SDL_PrivateVideoData {
    3.38 -	HBITMAP screen_bmp;
    3.39 -	HPALETTE screen_pal;
    3.40 +struct GapiInfo {
    3.41 +	/* Rotation which has to be applied to the key (arrow keys) and mouse events measured in quarters of a circle
    3.42 +	 * counter clockwise */
    3.43 +	int coordinateTransform; 
    3.44 +	char hiresFix; /* using hires mode without defining hires resource */
    3.45 +	int invert; //TODO this is only written but never read, so it should be removed
    3.46  
    3.47  #define NUM_MODELISTS	4		/* 8, 16, 24, and 32 bits-per-pixel */
    3.48  	int SDL_nummodes[NUM_MODELISTS];
    3.49  	SDL_Rect **SDL_modelist[NUM_MODELISTS];
    3.50 +	
    3.51 +
    3.52  	// The orientation of the video mode user wants to get
    3.53  	// Probably restricted to UP and RIGHT
    3.54  	SDL_ScreenOrientation userOrientation;
    3.55 -	int invert;
    3.56 -	char hiresFix; // using hires mode without defining hires resource
    3.57  // --------------
    3.58  	int useGXOpenDisplay; /* use GXOpenDispplay */
    3.59  	int alreadyGXOpened;
    3.60 @@ -158,14 +152,8 @@
    3.61  	int startOffset; // in bytes
    3.62  	int useVga;
    3.63  	int suspended; // do not pu anything into video memory
    3.64 -	// The orientation of the system, as defined by SM_CXSCREEN and SM_CYSCREEN
    3.65 -	// User can change it by using 'screen layout' in system options
    3.66 -	// Restricted to UP or RIGHT
    3.67 -	enum SDL_ScreenOrientation systemOrientation;
    3.68  };
    3.69  
    3.70  
    3.71 -#define gapiBuffer this->hidden->buffer
    3.72 -#define gapi this->hidden
    3.73  
    3.74  #endif /* _SDL_gapivideo_h */
     4.1 --- a/src/video/wincommon/SDL_sysevents.c	Fri Jan 30 01:40:44 2009 +0000
     4.2 +++ b/src/video/wincommon/SDL_sysevents.c	Mon Feb 16 22:32:34 2009 +0000
     4.3 @@ -50,9 +50,13 @@
     4.4  #include "wmmsg.h"
     4.5  #endif
     4.6  
     4.7 +#include "../windib/SDL_gapidibvideo.h"
     4.8 +
     4.9 +#ifdef SDL_VIDEO_DRIVER_GAPI
    4.10 +#include "../gapi/SDL_gapivideo.h"
    4.11 +#endif
    4.12 +
    4.13  #ifdef _WIN32_WCE
    4.14 -#include "../gapi/SDL_gapivideo.h"
    4.15 -
    4.16  #define IsZoomed(HWND) 1
    4.17  #define NO_GETKEYBOARDSTATE
    4.18  #if _WIN32_WCE < 420
    4.19 @@ -103,6 +107,9 @@
    4.20  
    4.21  #if defined(_WIN32_WCE)
    4.22  
    4.23 +//AdjustWindowRect is not available under WinCE 2003
    4.24 +#define AdjustWindowRect(a,b,c) (AdjustWindowRectEx((a),(b),(c),0))
    4.25 +
    4.26  // dynamically load aygshell dll because we want SDL to work on HPC and be300
    4.27  HINSTANCE aygshell = NULL;
    4.28  BOOL (WINAPI *SHFullScreen)(HWND hwndRequester, DWORD dwState) = 0;
    4.29 @@ -211,15 +218,19 @@
    4.30  
    4.31  static void SDL_RestoreGameMode(void)
    4.32  {
    4.33 -#ifdef _WIN32_WCE
    4.34 +#ifdef _WIN32_WCE //Under ce we don't minimize, therefore no restore
    4.35 +	
    4.36 +#ifdef SDL_VIDEO_DRIVER_GAPI
    4.37  	SDL_VideoDevice *this = current_video;
    4.38  	if(SDL_strcmp(this->name, "gapi") == 0)
    4.39  	{
    4.40 -		if( this->hidden->suspended )
    4.41 +		if( this->hidden->gapiInfo->suspended )
    4.42  		{
    4.43 -			this->hidden->suspended = 0;
    4.44 +			this->hidden->gapiInfo->suspended = 0;
    4.45  		}
    4.46  	}
    4.47 +#endif
    4.48 +	
    4.49  #else
    4.50  	ShowWindow(SDL_Window, SW_RESTORE);
    4.51  #endif
    4.52 @@ -234,14 +245,18 @@
    4.53  {
    4.54  
    4.55  #ifdef _WIN32_WCE
    4.56 +	
    4.57 +#ifdef SDL_VIDEO_DRIVER_GAPI
    4.58  	SDL_VideoDevice *this = current_video;
    4.59  	if(SDL_strcmp(this->name, "gapi") == 0)
    4.60  	{
    4.61 -		if( !this->hidden->suspended )
    4.62 +		if( !this->hidden->gapiInfo->suspended )
    4.63  		{
    4.64 -			this->hidden->suspended = 1;
    4.65 +			this->hidden->gapiInfo->suspended = 1;
    4.66  		}
    4.67  	}
    4.68 +#endif
    4.69 +	
    4.70  #else
    4.71  	/* WinCE does not have a taskbar, so minimizing is not convenient */
    4.72  	ShowWindow(SDL_Window, SW_MINIMIZE);
    4.73 @@ -459,9 +474,9 @@
    4.74  						posted = SDL_PrivateMouseMotion(0, 1, x, y);
    4.75  					}
    4.76  				} else {
    4.77 -#ifdef _WIN32_WCE
    4.78 -					if (SDL_VideoSurface)
    4.79 -						GapiTransform(this->hidden->userOrientation, this->hidden->hiresFix, &x, &y);
    4.80 +#ifdef SDL_VIDEO_DRIVER_GAPI
    4.81 +					if (SDL_VideoSurface && this->hidden->gapiInfo)
    4.82 +						GapiTransform(this->hidden->gapiInfo->coordinateTransform, this->hidden->gapiInfo->hiresFix, &x, &y);
    4.83  #endif
    4.84  					posted = SDL_PrivateMouseMotion(0, 0, x, y);
    4.85  				}
    4.86 @@ -564,9 +579,9 @@
    4.87  				} else {
    4.88  					x = (Sint16)LOWORD(lParam);
    4.89  					y = (Sint16)HIWORD(lParam);
    4.90 -#ifdef _WIN32_WCE
    4.91 -					if (SDL_VideoSurface)
    4.92 -						GapiTransform(this->hidden->userOrientation, this->hidden->hiresFix, &x, &y);
    4.93 +#ifdef SDL_VIDEO_DRIVER_GAPI
    4.94 +					if (SDL_VideoSurface && this->hidden->gapiInfo)
    4.95 +						GapiTransform(this->hidden->gapiInfo->coordinateTransform, this->hidden->gapiInfo->hiresFix, &x, &y);
    4.96  #endif
    4.97  				}
    4.98  				posted = SDL_PrivateMouseButton(
     5.1 --- a/src/video/windib/SDL_dibevents.c	Fri Jan 30 01:40:44 2009 +0000
     5.2 +++ b/src/video/windib/SDL_dibevents.c	Mon Feb 16 22:32:34 2009 +0000
     5.3 @@ -30,8 +30,16 @@
     5.4  #include "../../events/SDL_sysevents.h"
     5.5  #include "../../events/SDL_events_c.h"
     5.6  #include "../wincommon/SDL_lowvideo.h"
     5.7 +#include "SDL_gapidibvideo.h"
     5.8 +#include "SDL_vkeys.h"
     5.9 +
    5.10 +#ifdef SDL_VIDEO_DRIVER_GAPI
    5.11 +#include "../gapi/SDL_gapivideo.h"
    5.12 +#endif
    5.13 +
    5.14 +#ifdef SDL_VIDEO_DRIVER_WINDIB
    5.15  #include "SDL_dibvideo.h"
    5.16 -#include "SDL_vkeys.h"
    5.17 +#endif
    5.18  
    5.19  #ifndef WM_APP
    5.20  #define WM_APP	0x8000
    5.21 @@ -44,6 +52,7 @@
    5.22  /* The translation table from a Microsoft VK keysym to a SDL keysym */
    5.23  static SDLKey VK_keymap[SDLK_LAST];
    5.24  static SDL_keysym *TranslateKey(WPARAM vkey, UINT scancode, SDL_keysym *keysym, int pressed);
    5.25 +static SDLKey Arrows_keymap[4];
    5.26  
    5.27  /* Masks for processing the windows KEYDOWN and KEYUP messages */
    5.28  #define REPEATED_KEYMASK	(1<<30)
    5.29 @@ -59,22 +68,21 @@
    5.30  static WNDPROCTYPE userWindowProc = NULL;
    5.31  
    5.32  
    5.33 -#ifdef _WIN32_WCE
    5.34 +#ifdef SDL_VIDEO_DRIVER_GAPI
    5.35  
    5.36 -WPARAM rotateKey(WPARAM key,SDL_ScreenOrientation direction) 
    5.37 +WPARAM rotateKey(WPARAM key,int direction) 
    5.38  {
    5.39 -	if (direction != SDL_ORIENTATION_LEFT)
    5.40 -		return key;
    5.41 -
    5.42 +	if(direction ==0 ) return key;
    5.43 +	
    5.44  	switch (key) {
    5.45  		case 0x26: /* up */
    5.46 -			return 0x27;
    5.47 +			return Arrows_keymap[(2 + direction) % 4];
    5.48  		case 0x27: /* right */
    5.49 -			return 0x28;
    5.50 +			return Arrows_keymap[(1 + direction) % 4];
    5.51  		case 0x28: /* down */
    5.52 -			return 0x25;
    5.53 +			return Arrows_keymap[direction % 4];
    5.54  		case 0x25: /* left */
    5.55 -			return 0x26;
    5.56 +			return Arrows_keymap[(3 + direction) % 4];
    5.57  	}
    5.58  
    5.59  	return key;
    5.60 @@ -93,14 +101,15 @@
    5.61  		case WM_KEYDOWN: {
    5.62  			SDL_keysym keysym;
    5.63  
    5.64 -#ifdef _WIN32_WCE
    5.65 -			// Drop GAPI artefacts
    5.66 -			if (wParam == 0x84 || wParam == 0x5B)
    5.67 -				return 0;
    5.68 +#ifdef SDL_VIDEO_DRIVER_GAPI
    5.69 +			if(this->hidden->gapiInfo)
    5.70 +			{
    5.71 +				// Drop GAPI artefacts
    5.72 +				if (wParam == 0x84 || wParam == 0x5B)
    5.73 +					return 0;
    5.74  
    5.75 -			// Rotate key if necessary
    5.76 -			if (this->hidden->orientation != SDL_ORIENTATION_UP)
    5.77 -				wParam = rotateKey(wParam, this->hidden->orientation);	
    5.78 +				wParam = rotateKey(wParam, this->hidden->gapiInfo->coordinateTransform);
    5.79 +			}
    5.80  #endif 
    5.81  			/* Ignore repeated keys */
    5.82  			if ( lParam&REPEATED_KEYMASK ) {
    5.83 @@ -167,14 +176,15 @@
    5.84  		case WM_KEYUP: {
    5.85  			SDL_keysym keysym;
    5.86  
    5.87 -#ifdef _WIN32_WCE
    5.88 -			// Drop GAPI artifacts
    5.89 -			if (wParam == 0x84 || wParam == 0x5B)
    5.90 -				return 0;
    5.91 -
    5.92 -			// Rotate key if necessary
    5.93 -			if (this->hidden->orientation != SDL_ORIENTATION_UP)
    5.94 -				wParam = rotateKey(wParam, this->hidden->orientation);	
    5.95 +#ifdef SDL_VIDEO_DRIVER_GAPI
    5.96 +			if(this->hidden->gapiInfo)
    5.97 +			{
    5.98 +				// Drop GAPI artifacts
    5.99 +				if (wParam == 0x84 || wParam == 0x5B)
   5.100 +					return 0;
   5.101 +	
   5.102 +				wParam = rotateKey(wParam, this->hidden->gapiInfo->coordinateTransform);
   5.103 +			}
   5.104  #endif
   5.105  
   5.106  			switch (wParam) {
   5.107 @@ -222,12 +232,11 @@
   5.108  				TranslateKey(wParam,HIWORD(lParam),&keysym,0));
   5.109  		}
   5.110  		return(0);
   5.111 -
   5.112  #if defined(SC_SCREENSAVE) && defined(SC_MONITORPOWER)
   5.113  		case WM_SYSCOMMAND: {
   5.114  			const DWORD val = (DWORD) (wParam & 0xFFF0);
   5.115  			if ((val == SC_SCREENSAVE) || (val == SC_MONITORPOWER)) {
   5.116 -				if (!allow_screensaver) {
   5.117 +				if (this->hidden->dibInfo && !allow_screensaver) {
   5.118  					/* Note that this doesn't stop anything on Vista
   5.119  					   if the screensaver has a password. */
   5.120  					return(0);
   5.121 @@ -430,6 +439,11 @@
   5.122  	VK_keymap[VK_SNAPSHOT] = SDLK_PRINT;
   5.123  	VK_keymap[VK_CANCEL] = SDLK_BREAK;
   5.124  	VK_keymap[VK_APPS] = SDLK_MENU;
   5.125 +
   5.126 +	Arrows_keymap[3] = 0x25;
   5.127 +	Arrows_keymap[2] = 0x26;
   5.128 +	Arrows_keymap[1] = 0x27;
   5.129 +	Arrows_keymap[0] = 0x28;
   5.130  }
   5.131  
   5.132  #define EXTKEYPAD(keypad) ((scancode & 0x100)?(mvke):(keypad))
   5.133 @@ -485,9 +499,19 @@
   5.134  	keysym->scancode = (unsigned char) scancode;
   5.135  	keysym->mod = KMOD_NONE;
   5.136  	keysym->unicode = 0;
   5.137 +	
   5.138 +	if ((vkey == VK_RETURN) && (scancode & 0x100)) {
   5.139 +		/* No VK_ code for the keypad enter key */
   5.140 +		keysym->sym = SDLK_KP_ENTER;
   5.141 +	}
   5.142 +	else {
   5.143 +		keysym->sym = VK_keymap[SDL_MapVirtualKey(scancode, vkey)];
   5.144 +	}
   5.145 +
   5.146  	if ( pressed && SDL_TranslateUNICODE ) {
   5.147  #ifdef NO_GETKEYBOARDSTATE
   5.148  		/* Uh oh, better hope the vkey is close enough.. */
   5.149 +		if((keysym->sym == vkey) || (vkey > 0x7f))
   5.150  		keysym->unicode = vkey;
   5.151  #else
   5.152  		BYTE	keystate[256];
   5.153 @@ -501,14 +525,6 @@
   5.154  #endif /* NO_GETKEYBOARDSTATE */
   5.155  	}
   5.156  
   5.157 -	if ((vkey == VK_RETURN) && (scancode & 0x100)) {
   5.158 -		/* No VK_ code for the keypad enter key */
   5.159 -		keysym->sym = SDLK_KP_ENTER;
   5.160 -	}
   5.161 -	else {
   5.162 -		keysym->sym = VK_keymap[SDL_MapVirtualKey(scancode, vkey)];
   5.163 -	}
   5.164 -
   5.165  #if 0
   5.166  	{
   5.167  		HKL     hLayoutCurrent = GetKeyboardLayout(0);
     6.1 --- a/src/video/windib/SDL_dibvideo.c	Fri Jan 30 01:40:44 2009 +0000
     6.2 +++ b/src/video/windib/SDL_dibvideo.c	Mon Feb 16 22:32:34 2009 +0000
     6.3 @@ -34,6 +34,7 @@
     6.4  #include "../SDL_pixels_c.h"
     6.5  #include "../../events/SDL_sysevents.h"
     6.6  #include "../../events/SDL_events_c.h"
     6.7 +#include "SDL_gapidibvideo.h"
     6.8  #include "SDL_dibvideo.h"
     6.9  #include "../wincommon/SDL_syswm_c.h"
    6.10  #include "../wincommon/SDL_sysmouse_c.h"
    6.11 @@ -128,6 +129,9 @@
    6.12  {
    6.13  	if ( device ) {
    6.14  		if ( device->hidden ) {
    6.15 +			if ( device->hidden->dibInfo ) {
    6.16 +				SDL_free( device->hidden->dibInfo );
    6.17 +			}
    6.18  			SDL_free(device->hidden);
    6.19  		}
    6.20  		if ( device->gl_data ) {
    6.21 @@ -147,6 +151,16 @@
    6.22  		SDL_memset(device, 0, (sizeof *device));
    6.23  		device->hidden = (struct SDL_PrivateVideoData *)
    6.24  				SDL_malloc((sizeof *device->hidden));
    6.25 +		if(device->hidden){
    6.26 +			SDL_memset(device->hidden, 0, (sizeof *device->hidden));
    6.27 +			device->hidden->dibInfo = (DibInfo *)SDL_malloc((sizeof(DibInfo)));
    6.28 +			if(device->hidden->dibInfo == NULL)
    6.29 +			{
    6.30 +				SDL_free(device->hidden);
    6.31 +				device->hidden = NULL;
    6.32 +			}
    6.33 +		}
    6.34 +		
    6.35  		device->gl_data = (struct SDL_PrivateGLData *)
    6.36  				SDL_malloc((sizeof *device->gl_data));
    6.37  	}
    6.38 @@ -156,7 +170,7 @@
    6.39  		DIB_DeleteDevice(device);
    6.40  		return(NULL);
    6.41  	}
    6.42 -	SDL_memset(device->hidden, 0, (sizeof *device->hidden));
    6.43 +	SDL_memset(device->hidden->dibInfo, 0, (sizeof *device->hidden->dibInfo));
    6.44  	SDL_memset(device->gl_data, 0, (sizeof *device->gl_data));
    6.45  
    6.46  	/* Set the function pointers */
    6.47 @@ -347,6 +361,8 @@
    6.48  	this->hidden->supportRotation = ChangeDisplaySettingsEx(NULL, &settings, NULL, CDS_TEST, NULL) == DISP_CHANGE_SUCCESSFUL;
    6.49  #endif
    6.50  	/* Query for the desktop resolution */
    6.51 +	SDL_desktop_mode.dmSize = sizeof(SDL_desktop_mode);
    6.52 +	SDL_desktop_mode.dmDriverExtra = 0;
    6.53  	EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &SDL_desktop_mode);
    6.54  	this->info.current_w = SDL_desktop_mode.dmPelsWidth;
    6.55  	this->info.current_h = SDL_desktop_mode.dmPelsHeight;
    6.56 @@ -744,7 +760,7 @@
    6.57  				video->flags |= SDL_RESIZABLE;
    6.58  			}
    6.59  		}
    6.60 -#if WS_MAXIMIZE
    6.61 +#if WS_MAXIMIZE && !defined(_WIN32_WCE)
    6.62  		if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE;
    6.63  #endif
    6.64  	}
    6.65 @@ -1006,7 +1022,7 @@
    6.66  			entry->peBlue  = colors[i].b;
    6.67  			entry->peFlags = PC_NOCOLLAPSE;
    6.68  		}
    6.69 -#ifdef SYSPAL_NOSTATIC
    6.70 +#if defined(SYSPAL_NOSTATIC) && !defined(_WIN32_WCE)
    6.71  		/* Check to make sure black and white are in position */
    6.72  		if ( GetSystemPaletteUse(hdc) != SYSPAL_NOSTATIC256 ) {
    6.73  			moved_entries += CheckPaletteEntry(screen_logpal, 0, 0x00, 0x00, 0x00);
    6.74 @@ -1227,7 +1243,7 @@
    6.75  /* Exported for the windows message loop only */
    6.76  static void DIB_GrabStaticColors(HWND window)
    6.77  {
    6.78 -#ifdef SYSPAL_NOSTATIC
    6.79 +#if defined(SYSPAL_NOSTATIC) && !defined(_WIN32_WCE)
    6.80  	HDC hdc;
    6.81  
    6.82  	hdc = GetDC(window);
    6.83 @@ -1240,7 +1256,7 @@
    6.84  }
    6.85  static void DIB_ReleaseStaticColors(HWND window)
    6.86  {
    6.87 -#ifdef SYSPAL_NOSTATIC
    6.88 +#if defined(SYSPAL_NOSTATIC) && !defined(_WIN32_WCE)
    6.89  	HDC hdc;
    6.90  
    6.91  	hdc = GetDC(window);
     7.1 --- a/src/video/windib/SDL_dibvideo.h	Fri Jan 30 01:40:44 2009 +0000
     7.2 +++ b/src/video/windib/SDL_dibvideo.h	Mon Feb 16 22:32:34 2009 +0000
     7.3 @@ -27,18 +27,10 @@
     7.4  #define WIN32_LEAN_AND_MEAN
     7.5  #include <windows.h>
     7.6  
     7.7 -/* for PDA */
     7.8 -typedef enum
     7.9 -{
    7.10 -	SDL_ORIENTATION_UP,
    7.11 -	SDL_ORIENTATION_DOWN,
    7.12 -	SDL_ORIENTATION_LEFT,
    7.13 -	SDL_ORIENTATION_RIGHT
    7.14 -} SDL_ScreenOrientation;
    7.15  
    7.16  /* Private display data */
    7.17 -struct SDL_PrivateVideoData {
    7.18 -    HBITMAP screen_bmp;
    7.19 +struct DibInfo {
    7.20 +	HBITMAP screen_bmp;
    7.21      HPALETTE screen_pal;
    7.22      LOGPALETTE *screen_logpal;
    7.23      BOOL grab_palette;
    7.24 @@ -46,11 +38,8 @@
    7.25  #define NUM_MODELISTS	4		/* 8, 16, 24, and 32 bits-per-pixel */
    7.26      int SDL_nummodes[NUM_MODELISTS];
    7.27      SDL_Rect **SDL_modelist[NUM_MODELISTS];
    7.28 -
    7.29 -	SDL_ScreenOrientation orientation;
    7.30 +        
    7.31  #ifdef _WIN32_WCE
    7.32 -	int invert; /* do to remove, used by GAPI driver! */
    7.33 -	char hiresFix; /* using hires mode without defining hires resource */
    7.34  	int supportRotation; /* for Pocket PC devices */
    7.35  	DWORD origRotation; /* for Pocket PC devices */
    7.36  #endif
    7.37 @@ -59,12 +48,12 @@
    7.38      int allow_screensaver;
    7.39  };
    7.40  /* Old variable names */
    7.41 -#define screen_bmp		(this->hidden->screen_bmp)
    7.42 -#define screen_pal		(this->hidden->screen_pal)
    7.43 -#define screen_logpal		(this->hidden->screen_logpal)
    7.44 -#define grab_palette		(this->hidden->grab_palette)
    7.45 -#define SDL_nummodes		(this->hidden->SDL_nummodes)
    7.46 -#define SDL_modelist		(this->hidden->SDL_modelist)
    7.47 -#define allow_screensaver	(this->hidden->allow_screensaver)
    7.48 +#define screen_bmp		(this->hidden->dibInfo->screen_bmp)
    7.49 +#define screen_pal		(this->hidden->dibInfo->screen_pal)
    7.50 +#define screen_logpal		(this->hidden->dibInfo->screen_logpal)
    7.51 +#define grab_palette		(this->hidden->dibInfo->grab_palette)
    7.52 +#define SDL_nummodes		(this->hidden->dibInfo->SDL_nummodes)
    7.53 +#define SDL_modelist		(this->hidden->dibInfo->SDL_modelist)
    7.54 +#define allow_screensaver	(this->hidden->dibInfo->allow_screensaver)
    7.55  
    7.56  #endif /* _SDL_dibvideo_h */
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/src/video/windib/SDL_gapidibvideo.h	Mon Feb 16 22:32:34 2009 +0000
     8.3 @@ -0,0 +1,56 @@
     8.4 +/*
     8.5 +    SDL - Simple DirectMedia Layer
     8.6 +    Copyright (C) 1997-2009 Sam Lantinga
     8.7 +
     8.8 +    This library is free software; you can redistribute it and/or
     8.9 +    modify it under the terms of the GNU Lesser General Public
    8.10 +    License as published by the Free Software Foundation; either
    8.11 +    version 2.1 of the License, or (at your option) any later version.
    8.12 +
    8.13 +    This library is distributed in the hope that it will be useful,
    8.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    8.16 +    Lesser General Public License for more details.
    8.17 +
    8.18 +    You should have received a copy of the GNU Lesser General Public
    8.19 +    License along with this library; if not, write to the Free Software
    8.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    8.21 +
    8.22 +    Sam Lantinga
    8.23 +    slouken@libsdl.org
    8.24 +*/
    8.25 +#include "SDL_config.h"
    8.26 +
    8.27 +#ifndef _SDL_gapidibvideo_h
    8.28 +#define _SDL_gapidibvideo_h
    8.29 +
    8.30 +#define WIN32_LEAN_AND_MEAN
    8.31 +#include <windows.h>
    8.32 +
    8.33 +/* Hidden "this" pointer for the video functions */
    8.34 +#define _THIS	SDL_VideoDevice *this
    8.35 +
    8.36 +/* typedef these to be able to define pointers, but still force everybody who
    8.37 + * wants to access them to include the corresponding header */
    8.38 +typedef struct GapiInfo GapiInfo;
    8.39 +typedef struct DibInfo DibInfo;
    8.40 +
    8.41 +/* for PDA */
    8.42 +typedef enum
    8.43 +{
    8.44 +	SDL_ORIENTATION_UP,
    8.45 +	SDL_ORIENTATION_DOWN,
    8.46 +	SDL_ORIENTATION_LEFT,
    8.47 +	SDL_ORIENTATION_RIGHT
    8.48 +} SDL_ScreenOrientation;
    8.49 +
    8.50 +/* Private display data shared by gapi and windib*/
    8.51 +struct SDL_PrivateVideoData {
    8.52 +	int supportRotation; /* for Pocket PC devices */
    8.53 +	DWORD origRotation; /* for Pocket PC devices */
    8.54 +	
    8.55 +	GapiInfo* gapiInfo;
    8.56 +	DibInfo* dibInfo;
    8.57 +};
    8.58 +
    8.59 +#endif