Mercurial > sdl-ios-xcode
annotate src/video/wincommon/SDL_sysevents.c @ 648:12a21d82a060
Exposed SDL_LoadObject(), SDL_LoadFunction(), and SDL_UnloadObject() APIs
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 10 Jul 2003 07:46:19 +0000 |
parents | 7d7e19b59866 |
children | 77bca0665b69 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
3 Copyright (C) 1997, 1998, 1999 Sam Lantinga | |
4 | |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Library General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2 of the License, or (at your option) any later version. | |
9 | |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 Library General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Library General Public | |
16 License along with this library; if not, write to the Free | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
179
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
22 | |
23 #ifdef SAVE_RCSID | |
24 static char rcsid = | |
25 "@(#) $Id$"; | |
26 #endif | |
27 | |
28 #include <stdlib.h> | |
29 #include <stdio.h> | |
30 #include <windows.h> | |
31 | |
32 #include "SDL_getenv.h" | |
33 #include "SDL_events.h" | |
34 #include "SDL_video.h" | |
35 #include "SDL_error.h" | |
36 #include "SDL_syswm.h" | |
37 #include "SDL_sysevents.h" | |
38 #include "SDL_events_c.h" | |
39 #include "SDL_sysvideo.h" | |
40 #include "SDL_lowvideo.h" | |
41 #include "SDL_syswm_c.h" | |
42 #include "SDL_main.h" | |
43 | |
44 #ifdef WMMSG_DEBUG | |
45 #include "wmmsg.h" | |
46 #endif | |
47 | |
48 #ifdef _WIN32_WCE | |
49 #define NO_GETKEYBOARDSTATE | |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
50 #define NO_CHANGEDISPLAYSETTINGS |
0 | 51 #endif |
52 | |
53 /* The window we use for everything... */ | |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
54 #ifdef _WIN32_WCE |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
55 LPWSTR SDL_Appname = NULL; |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
56 #else |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
57 LPSTR SDL_Appname = NULL; |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
58 #endif |
0 | 59 HINSTANCE SDL_Instance = NULL; |
60 HWND SDL_Window = NULL; | |
61 RECT SDL_bounds = {0, 0, 0, 0}; | |
62 int SDL_resizing = 0; | |
63 int mouse_relative = 0; | |
64 int posted = 0; | |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
65 #ifndef NO_CHANGEDISPLAYSETTINGS |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
66 DEVMODE SDL_fullscreen_mode; |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
67 #endif |
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
68 WORD *gamma_saved = NULL; |
0 | 69 |
70 | |
71 /* Functions called by the message processing function */ | |
72 LONG | |
73 (*HandleMessage)(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)=NULL; | |
74 void (*WIN_RealizePalette)(_THIS); | |
75 void (*WIN_PaletteChanged)(_THIS, HWND window); | |
76 void (*WIN_WinPAINT)(_THIS, HDC hdc); | |
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
77 extern void DIB_SwapGamma(_THIS); |
0 | 78 |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
79 static void SDL_RestoreGameMode(void) |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
80 { |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
81 #ifndef NO_CHANGEDISPLAYSETTINGS |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
82 ShowWindow(SDL_Window, SW_RESTORE); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
83 ChangeDisplaySettings(&SDL_fullscreen_mode, CDS_FULLSCREEN); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
84 #endif |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
85 } |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
86 static void SDL_RestoreDesktopMode(void) |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
87 { |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
88 #ifndef NO_CHANGEDISPLAYSETTINGS |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
89 ShowWindow(SDL_Window, SW_MINIMIZE); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
90 ChangeDisplaySettings(NULL, 0); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
91 #endif |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
92 } |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
93 |
0 | 94 #ifdef WM_MOUSELEAVE |
95 /* | |
96 Special code to handle mouse leave events - this sucks... | |
97 http://support.microsoft.com/support/kb/articles/q183/1/07.asp | |
98 | |
99 TrackMouseEvent() is only available on Win98 and WinNT. | |
100 _TrackMouseEvent() is available on Win95, but isn't yet in the mingw32 | |
101 development environment, and only works on systems that have had IE 3.0 | |
102 or newer installed on them (which is not the case with the base Win95). | |
103 Therefore, we implement our own version of _TrackMouseEvent() which | |
104 uses our own implementation if TrackMouseEvent() is not available. | |
105 */ | |
106 static BOOL (WINAPI *_TrackMouseEvent)(TRACKMOUSEEVENT *ptme) = NULL; | |
107 | |
108 static VOID CALLBACK | |
109 TrackMouseTimerProc(HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime) | |
110 { | |
111 RECT rect; | |
112 POINT pt; | |
113 | |
114 GetClientRect(hWnd, &rect); | |
115 MapWindowPoints(hWnd, NULL, (LPPOINT)&rect, 2); | |
116 GetCursorPos(&pt); | |
117 if ( !PtInRect(&rect, pt) || (WindowFromPoint(pt) != hWnd) ) { | |
118 if ( !KillTimer(hWnd, idEvent) ) { | |
119 /* Error killing the timer! */ | |
120 } | |
121 PostMessage(hWnd, WM_MOUSELEAVE, 0, 0); | |
122 } | |
123 } | |
124 static BOOL WINAPI WIN_TrackMouseEvent(TRACKMOUSEEVENT *ptme) | |
125 { | |
126 if ( ptme->dwFlags == TME_LEAVE ) { | |
127 return SetTimer(ptme->hwndTrack, ptme->dwFlags, 100, | |
128 (TIMERPROC)TrackMouseTimerProc); | |
129 } | |
130 return FALSE; | |
131 } | |
132 #endif /* WM_MOUSELEAVE */ | |
133 | |
134 /* Function to retrieve the current keyboard modifiers */ | |
135 static void WIN_GetKeyboardState(void) | |
136 { | |
137 #ifndef NO_GETKEYBOARDSTATE | |
138 SDLMod state; | |
139 BYTE keyboard[256]; | |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
140 Uint8 *kstate = SDL_GetKeyState(NULL); |
0 | 141 |
142 state = KMOD_NONE; | |
143 if ( GetKeyboardState(keyboard) ) { | |
144 if ( keyboard[VK_LSHIFT] & 0x80) { | |
145 state |= KMOD_LSHIFT; | |
146 } | |
147 if ( keyboard[VK_RSHIFT] & 0x80) { | |
148 state |= KMOD_RSHIFT; | |
149 } | |
150 if ( keyboard[VK_LCONTROL] & 0x80) { | |
151 state |= KMOD_LCTRL; | |
152 } | |
153 if ( keyboard[VK_RCONTROL] & 0x80) { | |
154 state |= KMOD_RCTRL; | |
155 } | |
156 if ( keyboard[VK_LMENU] & 0x80) { | |
157 state |= KMOD_LALT; | |
158 } | |
159 if ( keyboard[VK_RMENU] & 0x80) { | |
160 state |= KMOD_RALT; | |
161 } | |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
162 if ( keyboard[VK_NUMLOCK] & 0x01) { |
0 | 163 state |= KMOD_NUM; |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
164 kstate[SDLK_NUMLOCK] = SDL_PRESSED; |
0 | 165 } |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
166 if ( keyboard[VK_CAPITAL] & 0x01) { |
0 | 167 state |= KMOD_CAPS; |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
168 kstate[SDLK_CAPSLOCK] = SDL_PRESSED; |
0 | 169 } |
170 } | |
171 SDL_SetModState(state); | |
172 #endif /* !NO_GETKEYBOARDSTATE */ | |
173 } | |
174 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
175 /* The main Win32 event handler |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
176 DJM: This is no longer static as (DX5/DIB)_CreateWindow needs it |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
177 */ |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
178 LONG CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) |
0 | 179 { |
180 SDL_VideoDevice *this = current_video; | |
181 static int mouse_pressed = 0; | |
182 static int in_window = 0; | |
183 #ifdef WMMSG_DEBUG | |
184 fprintf(stderr, "Received windows message: "); | |
185 if ( msg > MAX_WMMSG ) { | |
186 fprintf(stderr, "%d", msg); | |
187 } else { | |
188 fprintf(stderr, "%s", wmtab[msg]); | |
189 } | |
190 fprintf(stderr, " -- 0x%X, 0x%X\n", wParam, lParam); | |
191 #endif | |
192 switch (msg) { | |
193 | |
194 case WM_ACTIVATE: { | |
195 SDL_VideoDevice *this = current_video; | |
196 BOOL minimized; | |
197 Uint8 appstate; | |
198 | |
199 minimized = HIWORD(wParam); | |
200 if ( !minimized && (LOWORD(wParam) != WA_INACTIVE) ) { | |
201 /* Gain the following states */ | |
202 appstate = SDL_APPACTIVE|SDL_APPINPUTFOCUS; | |
203 if ( this->input_grab != SDL_GRAB_OFF ) { | |
204 WIN_GrabInput(this, SDL_GRAB_ON); | |
205 } | |
206 if ( !(SDL_GetAppState()&SDL_APPINPUTFOCUS) ) { | |
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
207 if ( ! DDRAW_FULLSCREEN() ) { |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
208 DIB_SwapGamma(this); |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
209 } |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
210 if ( WINDIB_FULLSCREEN() ) { |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
211 SDL_RestoreGameMode(); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
212 } |
0 | 213 } |
214 posted = SDL_PrivateAppActive(1, appstate); | |
215 WIN_GetKeyboardState(); | |
216 } else { | |
217 /* Lose the following states */ | |
218 appstate = SDL_APPINPUTFOCUS; | |
219 if ( minimized ) { | |
220 appstate |= SDL_APPACTIVE; | |
221 } | |
222 if ( this->input_grab != SDL_GRAB_OFF ) { | |
223 WIN_GrabInput(this, SDL_GRAB_OFF); | |
224 } | |
225 if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) { | |
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
226 if ( ! DDRAW_FULLSCREEN() ) { |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
227 DIB_SwapGamma(this); |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
228 } |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
229 if ( WINDIB_FULLSCREEN() ) { |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
230 SDL_RestoreDesktopMode(); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
231 } |
0 | 232 } |
233 posted = SDL_PrivateAppActive(0, appstate); | |
234 } | |
235 return(0); | |
236 } | |
237 break; | |
238 | |
239 case WM_MOUSEMOVE: { | |
240 | |
241 /* Mouse is handled by DirectInput when fullscreen */ | |
13
e30a8ce27c22
Fixed double-mouse event bug on Windows using OpenGL
Sam Lantinga <slouken@lokigames.com>
parents:
1
diff
changeset
|
242 if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) { |
0 | 243 Sint16 x, y; |
244 | |
245 /* mouse has entered the window */ | |
246 if ( ! in_window ) { | |
247 #ifdef WM_MOUSELEAVE | |
248 TRACKMOUSEEVENT tme; | |
249 | |
250 tme.cbSize = sizeof(tme); | |
251 tme.dwFlags = TME_LEAVE; | |
252 tme.hwndTrack = SDL_Window; | |
253 _TrackMouseEvent(&tme); | |
254 #endif /* WM_MOUSELEAVE */ | |
255 in_window = TRUE; | |
256 | |
257 posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); | |
258 } | |
259 | |
260 /* mouse has moved within the window */ | |
261 x = LOWORD(lParam); | |
262 y = HIWORD(lParam); | |
263 if ( mouse_relative ) { | |
264 POINT center; | |
265 center.x = (SDL_VideoSurface->w/2); | |
266 center.y = (SDL_VideoSurface->h/2); | |
267 x -= (Sint16)center.x; | |
268 y -= (Sint16)center.y; | |
269 if ( x || y ) { | |
270 ClientToScreen(SDL_Window, ¢er); | |
271 SetCursorPos(center.x, center.y); | |
272 posted = SDL_PrivateMouseMotion(0, 1, x, y); | |
273 } | |
274 } else { | |
275 posted = SDL_PrivateMouseMotion(0, 0, x, y); | |
276 } | |
277 } | |
278 } | |
279 return(0); | |
280 | |
281 #ifdef WM_MOUSELEAVE | |
282 case WM_MOUSELEAVE: { | |
283 | |
284 /* Mouse is handled by DirectInput when fullscreen */ | |
13
e30a8ce27c22
Fixed double-mouse event bug on Windows using OpenGL
Sam Lantinga <slouken@lokigames.com>
parents:
1
diff
changeset
|
285 if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) { |
0 | 286 /* mouse has left the window */ |
287 /* or */ | |
288 /* Elvis has left the building! */ | |
289 in_window = FALSE; | |
290 posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); | |
291 } | |
292 } | |
293 return(0); | |
294 #endif /* WM_MOUSELEAVE */ | |
295 | |
296 case WM_LBUTTONDOWN: | |
297 case WM_LBUTTONUP: | |
298 case WM_MBUTTONDOWN: | |
299 case WM_MBUTTONUP: | |
300 case WM_RBUTTONDOWN: | |
301 case WM_RBUTTONUP: { | |
302 /* Mouse is handled by DirectInput when fullscreen */ | |
13
e30a8ce27c22
Fixed double-mouse event bug on Windows using OpenGL
Sam Lantinga <slouken@lokigames.com>
parents:
1
diff
changeset
|
303 if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) { |
0 | 304 Sint16 x, y; |
305 Uint8 button, state; | |
306 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
307 /* DJM: |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
308 We want the SDL window to take focus so that |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
309 it acts like a normal windows "component" |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
310 (e.g. gains keyboard focus on a mouse click). |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
311 */ |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
312 SetFocus(SDL_Window); |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
313 |
0 | 314 /* Figure out which button to use */ |
315 switch (msg) { | |
316 case WM_LBUTTONDOWN: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
317 button = SDL_BUTTON_LEFT; |
0 | 318 state = SDL_PRESSED; |
319 break; | |
320 case WM_LBUTTONUP: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
321 button = SDL_BUTTON_LEFT; |
0 | 322 state = SDL_RELEASED; |
323 break; | |
324 case WM_MBUTTONDOWN: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
325 button = SDL_BUTTON_MIDDLE; |
0 | 326 state = SDL_PRESSED; |
327 break; | |
328 case WM_MBUTTONUP: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
329 button = SDL_BUTTON_MIDDLE; |
0 | 330 state = SDL_RELEASED; |
331 break; | |
332 case WM_RBUTTONDOWN: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
333 button = SDL_BUTTON_RIGHT; |
0 | 334 state = SDL_PRESSED; |
335 break; | |
336 case WM_RBUTTONUP: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
337 button = SDL_BUTTON_RIGHT; |
0 | 338 state = SDL_RELEASED; |
339 break; | |
340 default: | |
341 /* Eh? Unknown button? */ | |
342 return(0); | |
343 } | |
344 if ( state == SDL_PRESSED ) { | |
345 /* Grab mouse so we get up events */ | |
346 if ( ++mouse_pressed > 0 ) { | |
347 SetCapture(hwnd); | |
348 } | |
349 } else { | |
350 /* Release mouse after all up events */ | |
351 if ( --mouse_pressed <= 0 ) { | |
352 ReleaseCapture(); | |
353 mouse_pressed = 0; | |
354 } | |
355 } | |
356 if ( mouse_relative ) { | |
357 /* RJR: March 28, 2000 | |
358 report internal mouse position if in relative mode */ | |
359 x = 0; y = 0; | |
360 } else { | |
361 x = (Sint16)LOWORD(lParam); | |
362 y = (Sint16)HIWORD(lParam); | |
363 } | |
364 posted = SDL_PrivateMouseButton( | |
365 state, button, x, y); | |
366 } | |
367 } | |
368 return(0); | |
369 | |
61
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
370 |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
371 #if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400) |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
372 case WM_MOUSEWHEEL: |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
373 if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) { |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
374 int move = (short)HIWORD(wParam); |
162
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
375 if ( move ) { |
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
376 Uint8 button; |
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
377 if ( move > 0 ) |
451
24edec3cafe4
Added SDL_BUTTON_WHEELUP (4) and SDL_BUTTON_WHEELDOWN (5)
Sam Lantinga <slouken@libsdl.org>
parents:
447
diff
changeset
|
378 button = SDL_BUTTON_WHEELUP; |
162
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
379 else |
451
24edec3cafe4
Added SDL_BUTTON_WHEELUP (4) and SDL_BUTTON_WHEELDOWN (5)
Sam Lantinga <slouken@libsdl.org>
parents:
447
diff
changeset
|
380 button = SDL_BUTTON_WHEELDOWN; |
61
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
381 posted = SDL_PrivateMouseButton( |
162
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
382 SDL_PRESSED, button, 0, 0); |
332 | 383 posted |= SDL_PrivateMouseButton( |
384 SDL_RELEASED, button, 0, 0); | |
61
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
385 } |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
386 } |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
387 return(0); |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
388 #endif |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
389 |
0 | 390 #ifdef WM_GETMINMAXINFO |
391 /* This message is sent as a way for us to "check" the values | |
392 * of a position change. If we don't like it, we can adjust | |
393 * the values before they are changed. | |
394 */ | |
395 case WM_GETMINMAXINFO: { | |
396 MINMAXINFO *info; | |
397 RECT size; | |
398 int x, y; | |
565
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
399 int style; |
0 | 400 int width; |
401 int height; | |
402 | |
403 /* We don't want to clobber an internal resize */ | |
404 if ( SDL_resizing ) | |
405 return(0); | |
406 | |
407 /* We allow resizing with the SDL_RESIZABLE flag */ | |
408 if ( SDL_PublicSurface && | |
409 (SDL_PublicSurface->flags & SDL_RESIZABLE) ) { | |
410 return(0); | |
411 } | |
412 | |
413 /* Get the current position of our window */ | |
414 GetWindowRect(SDL_Window, &size); | |
415 x = size.left; | |
416 y = size.top; | |
417 | |
418 /* Calculate current width and height of our window */ | |
419 size.top = 0; | |
420 size.left = 0; | |
421 if ( SDL_PublicSurface != NULL ) { | |
422 size.bottom = SDL_PublicSurface->h; | |
423 size.right = SDL_PublicSurface->w; | |
424 } else { | |
425 size.bottom = 0; | |
426 size.right = 0; | |
427 } | |
565
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
428 |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
429 /* DJM - according to the docs for GetMenu(), the |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
430 return value is undefined if hwnd is a child window. |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
431 Aparently it's too difficult for MS to check |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
432 inside their function, so I have to do it here. |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
433 */ |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
434 style = GetWindowLong(hwnd, GWL_STYLE); |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
435 AdjustWindowRect( |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
436 &size, |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
437 style, |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
438 style & WS_CHILDWINDOW ? FALSE |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
439 : GetMenu(hwnd) != NULL); |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
440 |
0 | 441 width = size.right - size.left; |
442 height = size.bottom - size.top; | |
443 | |
444 /* Fix our size to the current size */ | |
445 info = (MINMAXINFO *)lParam; | |
446 info->ptMaxSize.x = width; | |
447 info->ptMaxSize.y = height; | |
448 info->ptMaxPosition.x = x; | |
449 info->ptMaxPosition.y = y; | |
450 info->ptMinTrackSize.x = width; | |
451 info->ptMinTrackSize.y = height; | |
452 info->ptMaxTrackSize.x = width; | |
453 info->ptMaxTrackSize.y = height; | |
454 } | |
455 return(0); | |
456 #endif /* WM_GETMINMAXINFO */ | |
457 | |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
458 case WM_WINDOWPOSCHANGED: { |
0 | 459 SDL_VideoDevice *this = current_video; |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
460 int w, h; |
0 | 461 |
462 GetClientRect(SDL_Window, &SDL_bounds); | |
463 ClientToScreen(SDL_Window, (LPPOINT)&SDL_bounds); | |
464 ClientToScreen(SDL_Window, (LPPOINT)&SDL_bounds+1); | |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
465 w = SDL_bounds.right-SDL_bounds.left; |
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
466 h = SDL_bounds.bottom-SDL_bounds.top; |
0 | 467 if ( this->input_grab != SDL_GRAB_OFF ) { |
468 ClipCursor(&SDL_bounds); | |
469 } | |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
470 if ( SDL_PublicSurface && |
0 | 471 (SDL_PublicSurface->flags & SDL_RESIZABLE) ) { |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
472 SDL_PrivateResize(w, h); |
0 | 473 } |
474 } | |
475 break; | |
476 | |
477 /* We need to set the cursor */ | |
478 case WM_SETCURSOR: { | |
479 Uint16 hittest; | |
480 | |
481 hittest = LOWORD(lParam); | |
482 if ( hittest == HTCLIENT ) { | |
483 SetCursor(SDL_hcursor); | |
484 return(TRUE); | |
485 } | |
486 } | |
487 break; | |
488 | |
489 /* We are about to get palette focus! */ | |
490 case WM_QUERYNEWPALETTE: { | |
491 WIN_RealizePalette(current_video); | |
492 return(TRUE); | |
493 } | |
494 break; | |
495 | |
496 /* Another application changed the palette */ | |
497 case WM_PALETTECHANGED: { | |
498 WIN_PaletteChanged(current_video, (HWND)wParam); | |
499 } | |
500 break; | |
501 | |
502 /* We were occluded, refresh our display */ | |
503 case WM_PAINT: { | |
504 HDC hdc; | |
505 PAINTSTRUCT ps; | |
506 | |
507 hdc = BeginPaint(SDL_Window, &ps); | |
508 if ( current_video->screen && | |
509 !(current_video->screen->flags & SDL_OPENGL) ) { | |
510 WIN_WinPAINT(current_video, hdc); | |
511 } | |
512 EndPaint(SDL_Window, &ps); | |
513 } | |
514 return(0); | |
515 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
516 /* DJM: Send an expose event in this case */ |
0 | 517 case WM_ERASEBKGND: { |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
518 posted = SDL_PrivateExpose(); |
0 | 519 } |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
520 return(0); |
0 | 521 |
522 case WM_CLOSE: { | |
523 if ( (posted = SDL_PrivateQuit()) ) | |
524 PostQuitMessage(0); | |
525 } | |
526 return(0); | |
527 | |
528 case WM_DESTROY: { | |
529 PostQuitMessage(0); | |
530 } | |
531 return(0); | |
532 | |
533 default: { | |
534 /* Special handling by the video driver */ | |
535 if (HandleMessage) { | |
536 return(HandleMessage(current_video, | |
537 hwnd, msg, wParam, lParam)); | |
538 } | |
539 } | |
540 break; | |
541 } | |
542 return(DefWindowProc(hwnd, msg, wParam, lParam)); | |
543 } | |
544 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
545 /* Allow the application handle to be stored and retrieved later */ |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
546 static void *SDL_handle = NULL; |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
547 |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
548 void SDL_SetModuleHandle(void *handle) |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
549 { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
550 SDL_handle = handle; |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
551 } |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
552 void *SDL_GetModuleHandle(void) |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
553 { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
554 void *handle; |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
555 |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
556 if ( SDL_handle ) { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
557 handle = SDL_handle; |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
558 } else { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
559 /* Warning: |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
560 If SDL is built as a DLL, this will return a handle to |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
561 the DLL, not the application, and DirectInput may fail |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
562 to initialize. |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
563 */ |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
564 handle = GetModuleHandle(NULL); |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
565 } |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
566 return(handle); |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
567 } |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
568 |
0 | 569 /* This allows the SDL_WINDOWID hack */ |
570 const char *SDL_windowid = NULL; | |
571 | |
572 /* Register the class for this application -- exported for winmain.c */ | |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
573 int SDL_RegisterApp(char *name, Uint32 style, void *hInst) |
0 | 574 { |
575 static int initialized = 0; | |
576 WNDCLASS class; | |
577 #ifdef WM_MOUSELEAVE | |
578 HMODULE handle; | |
579 #endif | |
580 | |
581 /* Only do this once... */ | |
582 if ( initialized ) { | |
583 return(0); | |
584 } | |
585 | |
586 /* This function needs to be passed the correct process handle | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
587 by the application. |
0 | 588 */ |
589 if ( ! hInst ) { | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
590 hInst = SDL_GetModuleHandle(); |
0 | 591 } |
592 | |
593 /* Register the application class */ | |
594 class.hCursor = NULL; | |
595 #ifdef _WIN32_WCE | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
596 { |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
597 /* WinCE uses the UNICODE version */ |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
598 int nLen = strlen(name)+1; |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
599 SDL_Appname = malloc(nLen*2); |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
600 MultiByteToWideChar(CP_ACP, 0, name, -1, SDL_Appname, nLen); |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
601 } |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
602 #else |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
603 { |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
604 int nLen = strlen(name)+1; |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
605 SDL_Appname = malloc(nLen); |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
606 strcpy(SDL_Appname, name); |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
607 } |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
608 #endif /* _WIN32_WCE */ |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
609 class.hIcon = LoadImage(hInst, SDL_Appname, IMAGE_ICON, |
0 | 610 0, 0, LR_DEFAULTCOLOR); |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
13
diff
changeset
|
611 class.lpszMenuName = NULL; |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
612 class.lpszClassName = SDL_Appname; |
0 | 613 class.hbrBackground = NULL; |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
614 class.hInstance = hInst; |
0 | 615 class.style = style; |
616 #ifdef HAVE_OPENGL | |
617 class.style |= CS_OWNDC; | |
618 #endif | |
619 class.lpfnWndProc = WinMessage; | |
620 class.cbWndExtra = 0; | |
621 class.cbClsExtra = 0; | |
622 if ( ! RegisterClass(&class) ) { | |
623 SDL_SetError("Couldn't register application class"); | |
624 return(-1); | |
625 } | |
626 SDL_Instance = hInst; | |
627 | |
628 #ifdef WM_MOUSELEAVE | |
629 /* Get the version of TrackMouseEvent() we use */ | |
630 _TrackMouseEvent = NULL; | |
631 handle = GetModuleHandle("USER32.DLL"); | |
632 if ( handle ) { | |
633 _TrackMouseEvent = (BOOL (WINAPI *)(TRACKMOUSEEVENT *))GetProcAddress(handle, "TrackMouseEvent"); | |
634 } | |
635 if ( _TrackMouseEvent == NULL ) { | |
636 _TrackMouseEvent = WIN_TrackMouseEvent; | |
637 } | |
638 #endif /* WM_MOUSELEAVE */ | |
639 | |
640 /* Check for SDL_WINDOWID hack */ | |
641 SDL_windowid = getenv("SDL_WINDOWID"); | |
642 | |
643 initialized = 1; | |
644 return(0); | |
645 } | |
646 |