src/video/wincommon/SDL_sysevents.c
branchSDL-1.2
changeset 5988 bf927e528813
parent 5983 1361a12b2e58
child 6110 676a54593bc4
     1.1 --- a/src/video/wincommon/SDL_sysevents.c	Thu Oct 13 16:35:25 2011 -0400
     1.2 +++ b/src/video/wincommon/SDL_sysevents.c	Thu Oct 13 16:38:05 2011 -0400
     1.3 @@ -220,13 +220,13 @@
     1.4  static VOID CALLBACK
     1.5  TrackMouseTimerProc(HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime)
     1.6  {
     1.7 -	RECT rect;
     1.8 +	union { RECT rect; POINT pt; } rectpt;  /* prevent type-punning issue. */
     1.9  	POINT pt;
    1.10  
    1.11 -	GetClientRect(hWnd, &rect);
    1.12 -	MapWindowPoints(hWnd, NULL, (LPPOINT)&rect, 2);
    1.13 +	GetClientRect(hWnd, &rectpt.rect);
    1.14 +	MapWindowPoints(hWnd, NULL, &rectpt.pt, 2);
    1.15  	GetCursorPos(&pt);
    1.16 -	if ( !PtInRect(&rect, pt) || (WindowFromPoint(pt) != hWnd) ) {
    1.17 +	if ( !PtInRect(&rectpt.rect, pt) || (WindowFromPoint(pt) != hWnd) ) {
    1.18  		if ( !KillTimer(hWnd, idEvent) ) {
    1.19  			/* Error killing the timer! */
    1.20  		}
    1.21 @@ -572,11 +572,24 @@
    1.22  
    1.23  		case WM_WINDOWPOSCHANGED: {
    1.24  			SDL_VideoDevice *this = current_video;
    1.25 +			POINT pt;
    1.26  			int w, h;
    1.27  
    1.28  			GetClientRect(SDL_Window, &SDL_bounds);
    1.29 -			ClientToScreen(SDL_Window, (LPPOINT)&SDL_bounds);
    1.30 -			ClientToScreen(SDL_Window, (LPPOINT)&SDL_bounds+1);
    1.31 +
    1.32 +			/* avoiding type-punning here... */
    1.33 +			pt.x = SDL_bounds.left;
    1.34 +			pt.y = SDL_bounds.top;
    1.35 +			ClientToScreen(SDL_Window, &pt);
    1.36 +			SDL_bounds.left = pt.x;
    1.37 +			SDL_bounds.top = pt.y;
    1.38 +
    1.39 +			pt.x = SDL_bounds.right;
    1.40 +			pt.y = SDL_bounds.bottom;
    1.41 +			ClientToScreen(SDL_Window, &pt);
    1.42 +			SDL_bounds.right = pt.x;
    1.43 +			SDL_bounds.bottom = pt.y;
    1.44 +
    1.45  			if ( !SDL_resizing && !IsZoomed(SDL_Window) &&
    1.46  			     SDL_PublicSurface &&
    1.47  				!(SDL_PublicSurface->flags & SDL_FULLSCREEN) ) {
    1.48 @@ -831,7 +844,7 @@
    1.49  
    1.50  	/* arg #3 should be const BYTE *, but cygwin lists it as PBYTE. */
    1.51  	if (ToAsciiEx(vkey, scancode, (PBYTE) keystate, (WORD*)chars, 0, GetKeyboardLayout(0)) == 1) {
    1.52 -		return MultiByteToWideChar(codepage, 0, chars, 1, wchars, wsize);
    1.53 +		return MultiByteToWideChar(codepage, 0, (LPCSTR) chars, 1, wchars, wsize);
    1.54  	}
    1.55  	return 0;
    1.56  }