src/video/wincommon/SDL_sysevents.c
branchSDL-1.2
changeset 5988 bf927e528813
parent 5983 1361a12b2e58
child 6110 676a54593bc4
equal deleted inserted replaced
5987:825e1072eac6 5988:bf927e528813
   218 static BOOL (WINAPI *_TrackMouseEvent)(TRACKMOUSEEVENT *ptme) = NULL;
   218 static BOOL (WINAPI *_TrackMouseEvent)(TRACKMOUSEEVENT *ptme) = NULL;
   219 
   219 
   220 static VOID CALLBACK
   220 static VOID CALLBACK
   221 TrackMouseTimerProc(HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime)
   221 TrackMouseTimerProc(HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime)
   222 {
   222 {
   223 	RECT rect;
   223 	union { RECT rect; POINT pt; } rectpt;  /* prevent type-punning issue. */
   224 	POINT pt;
   224 	POINT pt;
   225 
   225 
   226 	GetClientRect(hWnd, &rect);
   226 	GetClientRect(hWnd, &rectpt.rect);
   227 	MapWindowPoints(hWnd, NULL, (LPPOINT)&rect, 2);
   227 	MapWindowPoints(hWnd, NULL, &rectpt.pt, 2);
   228 	GetCursorPos(&pt);
   228 	GetCursorPos(&pt);
   229 	if ( !PtInRect(&rect, pt) || (WindowFromPoint(pt) != hWnd) ) {
   229 	if ( !PtInRect(&rectpt.rect, pt) || (WindowFromPoint(pt) != hWnd) ) {
   230 		if ( !KillTimer(hWnd, idEvent) ) {
   230 		if ( !KillTimer(hWnd, idEvent) ) {
   231 			/* Error killing the timer! */
   231 			/* Error killing the timer! */
   232 		}
   232 		}
   233 		PostMessage(hWnd, WM_MOUSELEAVE, 0, 0);
   233 		PostMessage(hWnd, WM_MOUSELEAVE, 0, 0);
   234 	}
   234 	}
   570 		}
   570 		}
   571 		return(0);
   571 		return(0);
   572 
   572 
   573 		case WM_WINDOWPOSCHANGED: {
   573 		case WM_WINDOWPOSCHANGED: {
   574 			SDL_VideoDevice *this = current_video;
   574 			SDL_VideoDevice *this = current_video;
       
   575 			POINT pt;
   575 			int w, h;
   576 			int w, h;
   576 
   577 
   577 			GetClientRect(SDL_Window, &SDL_bounds);
   578 			GetClientRect(SDL_Window, &SDL_bounds);
   578 			ClientToScreen(SDL_Window, (LPPOINT)&SDL_bounds);
   579 
   579 			ClientToScreen(SDL_Window, (LPPOINT)&SDL_bounds+1);
   580 			/* avoiding type-punning here... */
       
   581 			pt.x = SDL_bounds.left;
       
   582 			pt.y = SDL_bounds.top;
       
   583 			ClientToScreen(SDL_Window, &pt);
       
   584 			SDL_bounds.left = pt.x;
       
   585 			SDL_bounds.top = pt.y;
       
   586 
       
   587 			pt.x = SDL_bounds.right;
       
   588 			pt.y = SDL_bounds.bottom;
       
   589 			ClientToScreen(SDL_Window, &pt);
       
   590 			SDL_bounds.right = pt.x;
       
   591 			SDL_bounds.bottom = pt.y;
       
   592 
   580 			if ( !SDL_resizing && !IsZoomed(SDL_Window) &&
   593 			if ( !SDL_resizing && !IsZoomed(SDL_Window) &&
   581 			     SDL_PublicSurface &&
   594 			     SDL_PublicSurface &&
   582 				!(SDL_PublicSurface->flags & SDL_FULLSCREEN) ) {
   595 				!(SDL_PublicSurface->flags & SDL_FULLSCREEN) ) {
   583 				SDL_windowX = SDL_bounds.left;
   596 				SDL_windowX = SDL_bounds.left;
   584 				SDL_windowY = SDL_bounds.top;
   597 				SDL_windowY = SDL_bounds.top;
   829 {
   842 {
   830 	BYTE	chars[2];
   843 	BYTE	chars[2];
   831 
   844 
   832 	/* arg #3 should be const BYTE *, but cygwin lists it as PBYTE. */
   845 	/* arg #3 should be const BYTE *, but cygwin lists it as PBYTE. */
   833 	if (ToAsciiEx(vkey, scancode, (PBYTE) keystate, (WORD*)chars, 0, GetKeyboardLayout(0)) == 1) {
   846 	if (ToAsciiEx(vkey, scancode, (PBYTE) keystate, (WORD*)chars, 0, GetKeyboardLayout(0)) == 1) {
   834 		return MultiByteToWideChar(codepage, 0, chars, 1, wchars, wsize);
   847 		return MultiByteToWideChar(codepage, 0, (LPCSTR) chars, 1, wchars, wsize);
   835 	}
   848 	}
   836 	return 0;
   849 	return 0;
   837 }
   850 }
   838 #endif
   851 #endif
   839 #endif /* !NO_GETKEYBOARDSTATE */
   852 #endif /* !NO_GETKEYBOARDSTATE */