src/video/wincommon/SDL_sysevents.c
changeset 0 74212992fb08
child 1 cf2af46e9e2a
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/video/wincommon/SDL_sysevents.c	Thu Apr 26 16:45:43 2001 +0000
     1.3 @@ -0,0 +1,547 @@
     1.4 +/*
     1.5 +    SDL - Simple DirectMedia Layer
     1.6 +    Copyright (C) 1997, 1998, 1999  Sam Lantinga
     1.7 +
     1.8 +    This library is free software; you can redistribute it and/or
     1.9 +    modify it under the terms of the GNU Library General Public
    1.10 +    License as published by the Free Software Foundation; either
    1.11 +    version 2 of the License, or (at your option) any later version.
    1.12 +
    1.13 +    This library is distributed in the hope that it will be useful,
    1.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.16 +    Library General Public License for more details.
    1.17 +
    1.18 +    You should have received a copy of the GNU Library General Public
    1.19 +    License along with this library; if not, write to the Free
    1.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.21 +
    1.22 +    Sam Lantinga
    1.23 +    slouken@devolution.com
    1.24 +*/
    1.25 +
    1.26 +#ifdef SAVE_RCSID
    1.27 +static char rcsid =
    1.28 + "@(#) $Id$";
    1.29 +#endif
    1.30 +
    1.31 +#include <stdlib.h>
    1.32 +#include <stdio.h>
    1.33 +#include <windows.h>
    1.34 +
    1.35 +#include "SDL_getenv.h"
    1.36 +#include "SDL_events.h"
    1.37 +#include "SDL_video.h"
    1.38 +#include "SDL_error.h"
    1.39 +#include "SDL_syswm.h"
    1.40 +#include "SDL_sysevents.h"
    1.41 +#include "SDL_events_c.h"
    1.42 +#include "SDL_sysvideo.h"
    1.43 +#include "SDL_lowvideo.h"
    1.44 +#include "SDL_syswm_c.h"
    1.45 +#include "SDL_main.h"
    1.46 +
    1.47 +#ifdef WMMSG_DEBUG
    1.48 +#include "wmmsg.h"
    1.49 +#endif
    1.50 +
    1.51 +#ifdef _WIN32_WCE
    1.52 +#define NO_GETKEYBOARDSTATE
    1.53 +#endif
    1.54 +
    1.55 +/* The window we use for everything... */
    1.56 +const char *SDL_Appname = NULL;
    1.57 +HINSTANCE SDL_Instance = NULL;
    1.58 +HWND SDL_Window = NULL;
    1.59 +RECT SDL_bounds = {0, 0, 0, 0};
    1.60 +int SDL_resizing = 0;
    1.61 +int mouse_relative = 0;
    1.62 +int posted = 0;
    1.63 +
    1.64 +
    1.65 +/* Functions called by the message processing function */
    1.66 +LONG
    1.67 +(*HandleMessage)(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)=NULL;
    1.68 +void (*WIN_RealizePalette)(_THIS);
    1.69 +void (*WIN_PaletteChanged)(_THIS, HWND window);
    1.70 +void (*WIN_SwapGamma)(_THIS);
    1.71 +void (*WIN_WinPAINT)(_THIS, HDC hdc);
    1.72 +
    1.73 +#ifdef WM_MOUSELEAVE
    1.74 +/* 
    1.75 +   Special code to handle mouse leave events - this sucks...
    1.76 +   http://support.microsoft.com/support/kb/articles/q183/1/07.asp
    1.77 +
    1.78 +   TrackMouseEvent() is only available on Win98 and WinNT.
    1.79 +   _TrackMouseEvent() is available on Win95, but isn't yet in the mingw32
    1.80 +   development environment, and only works on systems that have had IE 3.0
    1.81 +   or newer installed on them (which is not the case with the base Win95).
    1.82 +   Therefore, we implement our own version of _TrackMouseEvent() which
    1.83 +   uses our own implementation if TrackMouseEvent() is not available.
    1.84 +*/
    1.85 +static BOOL (WINAPI *_TrackMouseEvent)(TRACKMOUSEEVENT *ptme) = NULL;
    1.86 +
    1.87 +static VOID CALLBACK
    1.88 +TrackMouseTimerProc(HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime)
    1.89 +{
    1.90 +	RECT rect;
    1.91 +	POINT pt;
    1.92 +
    1.93 +	GetClientRect(hWnd, &rect);
    1.94 +	MapWindowPoints(hWnd, NULL, (LPPOINT)&rect, 2);
    1.95 +	GetCursorPos(&pt);
    1.96 +	if ( !PtInRect(&rect, pt) || (WindowFromPoint(pt) != hWnd) ) {
    1.97 +		if ( !KillTimer(hWnd, idEvent) ) {
    1.98 +			/* Error killing the timer! */
    1.99 +		}
   1.100 +		PostMessage(hWnd, WM_MOUSELEAVE, 0, 0);
   1.101 +	}
   1.102 +}
   1.103 +static BOOL WINAPI WIN_TrackMouseEvent(TRACKMOUSEEVENT *ptme)
   1.104 +{
   1.105 +	if ( ptme->dwFlags == TME_LEAVE ) {
   1.106 +		return SetTimer(ptme->hwndTrack, ptme->dwFlags, 100,
   1.107 +		                (TIMERPROC)TrackMouseTimerProc);
   1.108 +	}
   1.109 +	return FALSE;
   1.110 +}
   1.111 +#endif /* WM_MOUSELEAVE */
   1.112 +
   1.113 +/* Function to retrieve the current keyboard modifiers */
   1.114 +static void WIN_GetKeyboardState(void)
   1.115 +{
   1.116 +#ifndef NO_GETKEYBOARDSTATE
   1.117 +	SDLMod state;
   1.118 +	BYTE keyboard[256];
   1.119 +
   1.120 +	state = KMOD_NONE;
   1.121 +	if ( GetKeyboardState(keyboard) ) {
   1.122 +		if ( keyboard[VK_LSHIFT] & 0x80) {
   1.123 +			state |= KMOD_LSHIFT;
   1.124 +		}
   1.125 +		if ( keyboard[VK_RSHIFT] & 0x80) {
   1.126 +			state |= KMOD_RSHIFT;
   1.127 +		}
   1.128 +		if ( keyboard[VK_LCONTROL] & 0x80) {
   1.129 +			state |= KMOD_LCTRL;
   1.130 +		}
   1.131 +		if ( keyboard[VK_RCONTROL] & 0x80) {
   1.132 +			state |= KMOD_RCTRL;
   1.133 +		}
   1.134 +		if ( keyboard[VK_LMENU] & 0x80) {
   1.135 +			state |= KMOD_LALT;
   1.136 +		}
   1.137 +		if ( keyboard[VK_RMENU] & 0x80) {
   1.138 +			state |= KMOD_RALT;
   1.139 +		}
   1.140 +		if ( keyboard[VK_NUMLOCK] & 0x80) {
   1.141 +			state |= KMOD_NUM;
   1.142 +		}
   1.143 +		if ( keyboard[VK_CAPITAL] & 0x80) {
   1.144 +			state |= KMOD_CAPS;
   1.145 +		}
   1.146 +	}
   1.147 +	SDL_SetModState(state);
   1.148 +#endif /* !NO_GETKEYBOARDSTATE */
   1.149 +}
   1.150 +
   1.151 +/* The main Win32 event handler */
   1.152 +static LONG CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
   1.153 +{
   1.154 +	SDL_VideoDevice *this = current_video;
   1.155 +	static int mouse_pressed = 0;
   1.156 +	static int in_window = 0;
   1.157 +#ifdef WMMSG_DEBUG
   1.158 +	fprintf(stderr, "Received windows message:  ");
   1.159 +	if ( msg > MAX_WMMSG ) {
   1.160 +		fprintf(stderr, "%d", msg);
   1.161 +	} else {
   1.162 +		fprintf(stderr, "%s", wmtab[msg]);
   1.163 +	}
   1.164 +	fprintf(stderr, " -- 0x%X, 0x%X\n", wParam, lParam);
   1.165 +#endif
   1.166 +	switch (msg) {
   1.167 +
   1.168 +		case WM_ACTIVATE: {
   1.169 +			SDL_VideoDevice *this = current_video;
   1.170 +			BOOL minimized;
   1.171 +			Uint8 appstate;
   1.172 +
   1.173 +			minimized = HIWORD(wParam);
   1.174 +			if ( !minimized && (LOWORD(wParam) != WA_INACTIVE) ) {
   1.175 +				/* Gain the following states */
   1.176 +				appstate = SDL_APPACTIVE|SDL_APPINPUTFOCUS;
   1.177 +				if ( this->input_grab != SDL_GRAB_OFF ) {
   1.178 +					WIN_GrabInput(this, SDL_GRAB_ON);
   1.179 +				}
   1.180 +				if ( !(SDL_GetAppState()&SDL_APPINPUTFOCUS) ) {
   1.181 +					WIN_SwapGamma(this);
   1.182 +				}
   1.183 +				posted = SDL_PrivateAppActive(1, appstate);
   1.184 +				WIN_GetKeyboardState();
   1.185 +			} else {
   1.186 +				/* Lose the following states */
   1.187 +				appstate = SDL_APPINPUTFOCUS;
   1.188 +				if ( minimized ) {
   1.189 +					appstate |= SDL_APPACTIVE;
   1.190 +				}
   1.191 +				if ( this->input_grab != SDL_GRAB_OFF ) {
   1.192 +					WIN_GrabInput(this, SDL_GRAB_OFF);
   1.193 +				}
   1.194 +				if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) {
   1.195 +					WIN_SwapGamma(this);
   1.196 +				}
   1.197 +				posted = SDL_PrivateAppActive(0, appstate);
   1.198 +			}
   1.199 +			return(0);
   1.200 +		}
   1.201 +		break;
   1.202 +
   1.203 +		case WM_MOUSEMOVE: {
   1.204 +			
   1.205 +			/* Mouse is handled by DirectInput when fullscreen */
   1.206 +			if ( SDL_VideoSurface && ! DIRECTX_FULLSCREEN() ) {
   1.207 +				Sint16 x, y;
   1.208 +
   1.209 +				/* mouse has entered the window */
   1.210 +				if ( ! in_window ) {
   1.211 +#ifdef WM_MOUSELEAVE
   1.212 +					TRACKMOUSEEVENT tme;
   1.213 +
   1.214 +					tme.cbSize = sizeof(tme);
   1.215 +					tme.dwFlags = TME_LEAVE;
   1.216 +					tme.hwndTrack = SDL_Window;
   1.217 +					_TrackMouseEvent(&tme);
   1.218 +#endif /* WM_MOUSELEAVE */
   1.219 +					in_window = TRUE;
   1.220 +
   1.221 +					posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
   1.222 +				}
   1.223 +
   1.224 +				/* mouse has moved within the window */
   1.225 +				x = LOWORD(lParam);
   1.226 +				y = HIWORD(lParam);
   1.227 +				if ( mouse_relative ) {
   1.228 +					POINT center;
   1.229 +					center.x = (SDL_VideoSurface->w/2);
   1.230 +					center.y = (SDL_VideoSurface->h/2);
   1.231 +					x -= (Sint16)center.x;
   1.232 +					y -= (Sint16)center.y;
   1.233 +					if ( x || y ) {
   1.234 +						ClientToScreen(SDL_Window, &center);
   1.235 +						SetCursorPos(center.x, center.y);
   1.236 +						posted = SDL_PrivateMouseMotion(0, 1, x, y);
   1.237 +					}
   1.238 +				} else {
   1.239 +					posted = SDL_PrivateMouseMotion(0, 0, x, y);
   1.240 +				}
   1.241 +			}
   1.242 +		}
   1.243 +		return(0);
   1.244 +
   1.245 +#ifdef WM_MOUSELEAVE
   1.246 +		case WM_MOUSELEAVE: {
   1.247 +
   1.248 +			/* Mouse is handled by DirectInput when fullscreen */
   1.249 +			if ( SDL_VideoSurface && ! DIRECTX_FULLSCREEN() ) {
   1.250 +				/* mouse has left the window */
   1.251 +				/* or */
   1.252 +				/* Elvis has left the building! */
   1.253 +				in_window = FALSE;
   1.254 +				posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
   1.255 +			}
   1.256 +		}
   1.257 +		return(0);
   1.258 +#endif /* WM_MOUSELEAVE */
   1.259 +
   1.260 +		case WM_LBUTTONDOWN:
   1.261 +		case WM_LBUTTONUP:
   1.262 +		case WM_MBUTTONDOWN:
   1.263 +		case WM_MBUTTONUP:
   1.264 +		case WM_RBUTTONDOWN:
   1.265 +		case WM_RBUTTONUP: {
   1.266 +			/* Mouse is handled by DirectInput when fullscreen */
   1.267 +			if ( SDL_VideoSurface && ! DIRECTX_FULLSCREEN() ) {
   1.268 +				Sint16 x, y;
   1.269 +				Uint8 button, state;
   1.270 +
   1.271 +				/* Figure out which button to use */
   1.272 +				switch (msg) {
   1.273 +					case WM_LBUTTONDOWN:
   1.274 +						button = 1;
   1.275 +						state = SDL_PRESSED;
   1.276 +						break;
   1.277 +					case WM_LBUTTONUP:
   1.278 +						button = 1;
   1.279 +						state = SDL_RELEASED;
   1.280 +						break;
   1.281 +					case WM_MBUTTONDOWN:
   1.282 +						button = 2;
   1.283 +						state = SDL_PRESSED;
   1.284 +						break;
   1.285 +					case WM_MBUTTONUP:
   1.286 +						button = 2;
   1.287 +						state = SDL_RELEASED;
   1.288 +						break;
   1.289 +					case WM_RBUTTONDOWN:
   1.290 +						button = 3;
   1.291 +						state = SDL_PRESSED;
   1.292 +						break;
   1.293 +					case WM_RBUTTONUP:
   1.294 +						button = 3;
   1.295 +						state = SDL_RELEASED;
   1.296 +						break;
   1.297 +					default:
   1.298 +						/* Eh? Unknown button? */
   1.299 +						return(0);
   1.300 +				}
   1.301 +				if ( state == SDL_PRESSED ) {
   1.302 +					/* Grab mouse so we get up events */
   1.303 +					if ( ++mouse_pressed > 0 ) {
   1.304 +						SetCapture(hwnd);
   1.305 +					}
   1.306 +				} else {
   1.307 +					/* Release mouse after all up events */
   1.308 +					if ( --mouse_pressed <= 0 ) {
   1.309 +						ReleaseCapture();
   1.310 +						mouse_pressed = 0;
   1.311 +					}
   1.312 +				}
   1.313 +				if ( mouse_relative ) {
   1.314 +				/*	RJR: March 28, 2000
   1.315 +					report internal mouse position if in relative mode */
   1.316 +					x = 0; y = 0;
   1.317 +				} else {
   1.318 +					x = (Sint16)LOWORD(lParam);
   1.319 +					y = (Sint16)HIWORD(lParam);
   1.320 +				}
   1.321 +				posted = SDL_PrivateMouseButton(
   1.322 +							state, button, x, y);
   1.323 +			}
   1.324 +		}
   1.325 +		return(0);
   1.326 +
   1.327 +#ifdef WM_GETMINMAXINFO
   1.328 +		/* This message is sent as a way for us to "check" the values
   1.329 +		 * of a position change.  If we don't like it, we can adjust
   1.330 +		 * the values before they are changed.
   1.331 +		 */
   1.332 +		case WM_GETMINMAXINFO: {
   1.333 +			MINMAXINFO *info;
   1.334 +			RECT        size;
   1.335 +			int x, y;
   1.336 +			int width;
   1.337 +			int height;
   1.338 +
   1.339 +			/* We don't want to clobber an internal resize */
   1.340 +			if ( SDL_resizing )
   1.341 +				return(0);
   1.342 +
   1.343 +			/* We allow resizing with the SDL_RESIZABLE flag */
   1.344 +			if ( SDL_PublicSurface &&
   1.345 +				(SDL_PublicSurface->flags & SDL_RESIZABLE) ) {
   1.346 +				return(0);
   1.347 +			}
   1.348 +
   1.349 +			/* Get the current position of our window */
   1.350 +			GetWindowRect(SDL_Window, &size);
   1.351 +			x = size.left;
   1.352 +			y = size.top;
   1.353 +
   1.354 +			/* Calculate current width and height of our window */
   1.355 +			size.top = 0;
   1.356 +			size.left = 0;
   1.357 +			if ( SDL_PublicSurface != NULL ) {
   1.358 +				size.bottom = SDL_PublicSurface->h;
   1.359 +				size.right = SDL_PublicSurface->w;
   1.360 +			} else {
   1.361 +				size.bottom = 0;
   1.362 +				size.right = 0;
   1.363 +			}
   1.364 +			AdjustWindowRect(&size, GetWindowLong(hwnd, GWL_STYLE),
   1.365 +									FALSE);
   1.366 +			width = size.right - size.left;
   1.367 +			height = size.bottom - size.top;
   1.368 +
   1.369 +			/* Fix our size to the current size */
   1.370 +			info = (MINMAXINFO *)lParam;
   1.371 +			info->ptMaxSize.x = width;
   1.372 +			info->ptMaxSize.y = height;
   1.373 +			info->ptMaxPosition.x = x;
   1.374 +			info->ptMaxPosition.y = y;
   1.375 +			info->ptMinTrackSize.x = width;
   1.376 +			info->ptMinTrackSize.y = height;
   1.377 +			info->ptMaxTrackSize.x = width;
   1.378 +			info->ptMaxTrackSize.y = height;
   1.379 +		}
   1.380 +		return(0);
   1.381 +#endif /* WM_GETMINMAXINFO */
   1.382 +
   1.383 +		case WM_MOVE: {
   1.384 +			SDL_VideoDevice *this = current_video;
   1.385 +
   1.386 +			GetClientRect(SDL_Window, &SDL_bounds);
   1.387 +			ClientToScreen(SDL_Window, (LPPOINT)&SDL_bounds);
   1.388 +			ClientToScreen(SDL_Window, (LPPOINT)&SDL_bounds+1);
   1.389 +			if ( this->input_grab != SDL_GRAB_OFF ) {
   1.390 +				ClipCursor(&SDL_bounds);
   1.391 +			}
   1.392 +		}
   1.393 +		break;
   1.394 +	
   1.395 +		case WM_SIZE: {
   1.396 +			if ( SDL_PublicSurface &&
   1.397 +				(SDL_PublicSurface->flags & SDL_RESIZABLE) ) {
   1.398 +				SDL_PrivateResize(LOWORD(lParam), HIWORD(lParam));
   1.399 +			}
   1.400 +			return(0);
   1.401 +		}
   1.402 +		break;
   1.403 +
   1.404 +		/* We need to set the cursor */
   1.405 +		case WM_SETCURSOR: {
   1.406 +			Uint16 hittest;
   1.407 +
   1.408 +			hittest = LOWORD(lParam);
   1.409 +			if ( hittest == HTCLIENT ) {
   1.410 +				SetCursor(SDL_hcursor);
   1.411 +				return(TRUE);
   1.412 +			}
   1.413 +		}
   1.414 +		break;
   1.415 +
   1.416 +		/* We are about to get palette focus! */
   1.417 +		case WM_QUERYNEWPALETTE: {
   1.418 +			WIN_RealizePalette(current_video);
   1.419 +			return(TRUE);
   1.420 +		}
   1.421 +		break;
   1.422 +
   1.423 +		/* Another application changed the palette */
   1.424 +		case WM_PALETTECHANGED: {
   1.425 +			WIN_PaletteChanged(current_video, (HWND)wParam);
   1.426 +		}
   1.427 +		break;
   1.428 +
   1.429 +		/* We were occluded, refresh our display */
   1.430 +		case WM_PAINT: {
   1.431 +			HDC hdc;
   1.432 +			PAINTSTRUCT ps;
   1.433 +
   1.434 +			hdc = BeginPaint(SDL_Window, &ps);
   1.435 +			if ( current_video->screen &&
   1.436 +			     !(current_video->screen->flags & SDL_OPENGL) ) {
   1.437 +				WIN_WinPAINT(current_video, hdc);
   1.438 +			}
   1.439 +			EndPaint(SDL_Window, &ps);
   1.440 +		}
   1.441 +		return(0);
   1.442 +
   1.443 +		case WM_ERASEBKGND: {
   1.444 +			/* Just do nothing */ ;
   1.445 +		}
   1.446 +		return(1);
   1.447 +
   1.448 +		case WM_CLOSE: {
   1.449 +			if ( (posted = SDL_PrivateQuit()) )
   1.450 +				PostQuitMessage(0);
   1.451 +		}
   1.452 +		return(0);
   1.453 +
   1.454 +		case WM_DESTROY: {
   1.455 +			PostQuitMessage(0);
   1.456 +		}
   1.457 +		return(0);
   1.458 +
   1.459 +		default: {
   1.460 +			/* Special handling by the video driver */
   1.461 +			if (HandleMessage) {
   1.462 +				return(HandleMessage(current_video,
   1.463 +			                     hwnd, msg, wParam, lParam));
   1.464 +			}
   1.465 +		}
   1.466 +		break;
   1.467 +	}
   1.468 +	return(DefWindowProc(hwnd, msg, wParam, lParam));
   1.469 +}
   1.470 +
   1.471 +/* This allows the SDL_WINDOWID hack */
   1.472 +const char *SDL_windowid = NULL;
   1.473 +
   1.474 +/* Register the class for this application -- exported for winmain.c */
   1.475 +int SDL_RegisterApp(char *name, Uint32 style, void *hInst)
   1.476 +{
   1.477 +	static int initialized = 0;
   1.478 +	WNDCLASS class;
   1.479 +#ifdef WM_MOUSELEAVE
   1.480 +	HMODULE handle;
   1.481 +#endif
   1.482 +
   1.483 +	/* Only do this once... */
   1.484 +	if ( initialized ) {
   1.485 +		return(0);
   1.486 +	}
   1.487 +
   1.488 +	/* This function needs to be passed the correct process handle
   1.489 +	   by the application.  The following call just returns a handle
   1.490 +	   to the SDL DLL, which is useless for our purposes and causes
   1.491 +	   DirectInput to fail to initialize.
   1.492 +	 */
   1.493 +	if ( ! hInst ) {
   1.494 +		hInst = GetModuleHandle(NULL);
   1.495 +	}
   1.496 +
   1.497 +	/* Register the application class */
   1.498 +	class.hCursor		= NULL;
   1.499 +#ifdef _WIN32_WCE
   1.500 +    {
   1.501 +	/* WinCE uses the UNICODE version */
   1.502 +	int nLen = strlen(name);
   1.503 +	LPWSTR lpszW = alloca((nLen+1)*2);
   1.504 +	MultiByteToWideChar(CP_ACP, 0, name, -1, lpszW, nLen);
   1.505 +	class.hIcon		= LoadImage(hInst, lpszW, IMAGE_ICON,
   1.506 +	                                    0, 0, LR_DEFAULTCOLOR);
   1.507 +	class.lpszMenuName	= lpszW;
   1.508 +	class.lpszClassName	= lpszW;
   1.509 +    }
   1.510 +#else
   1.511 +	class.hIcon		= LoadImage(hInst, name, IMAGE_ICON,
   1.512 +	                                    0, 0, LR_DEFAULTCOLOR);
   1.513 +	class.lpszMenuName	= "(none)";
   1.514 +	class.lpszClassName	= name;
   1.515 +#endif /* _WIN32_WCE */
   1.516 +	class.hbrBackground	= NULL;
   1.517 +	class.hInstance		= hInst ? hInst : GetModuleHandle(0);
   1.518 +	class.style		= style;
   1.519 +#ifdef HAVE_OPENGL
   1.520 +	class.style		|= CS_OWNDC;
   1.521 +#endif
   1.522 +	class.lpfnWndProc	= WinMessage;
   1.523 +	class.cbWndExtra	= 0;
   1.524 +	class.cbClsExtra	= 0;
   1.525 +	if ( ! RegisterClass(&class) ) {
   1.526 +		SDL_SetError("Couldn't register application class");
   1.527 +		return(-1);
   1.528 +	}
   1.529 +	SDL_Appname = name;
   1.530 +	SDL_Instance = hInst;
   1.531 +
   1.532 +#ifdef WM_MOUSELEAVE
   1.533 +	/* Get the version of TrackMouseEvent() we use */
   1.534 +	_TrackMouseEvent = NULL;
   1.535 +	handle = GetModuleHandle("USER32.DLL");
   1.536 +	if ( handle ) {
   1.537 +		_TrackMouseEvent = (BOOL (WINAPI *)(TRACKMOUSEEVENT *))GetProcAddress(handle, "TrackMouseEvent");
   1.538 +	}
   1.539 +	if ( _TrackMouseEvent == NULL ) {
   1.540 +		_TrackMouseEvent = WIN_TrackMouseEvent;
   1.541 +	}
   1.542 +#endif /* WM_MOUSELEAVE */
   1.543 +
   1.544 +	/* Check for SDL_WINDOWID hack */
   1.545 +	SDL_windowid = getenv("SDL_WINDOWID");
   1.546 +
   1.547 +	initialized = 1;
   1.548 +	return(0);
   1.549 +}
   1.550 +