SDL  2.0
SDL_windowsevents.c
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 #include "../../SDL_internal.h"
22 
23 #if SDL_VIDEO_DRIVER_WINDOWS
24 
25 #include "SDL_windowsvideo.h"
26 #include "SDL_windowsshape.h"
27 #include "SDL_system.h"
28 #include "SDL_syswm.h"
29 #include "SDL_timer.h"
30 #include "SDL_vkeys.h"
31 #include "SDL_hints.h"
32 #include "../../events/SDL_events_c.h"
33 #include "../../events/SDL_touch_c.h"
34 #include "../../events/scancodes_windows.h"
35 #include "SDL_assert.h"
36 #include "SDL_hints.h"
37 
38 /* Dropfile support */
39 #include <shellapi.h>
40 
41 /* For GET_X_LPARAM, GET_Y_LPARAM. */
42 #include <windowsx.h>
43 
44 /* #define WMMSG_DEBUG */
45 #ifdef WMMSG_DEBUG
46 #include <stdio.h>
47 #include "wmmsg.h"
48 #endif
49 
50 /* For processing mouse WM_*BUTTON* and WM_MOUSEMOVE message-data from GetMessageExtraInfo() */
51 #define MOUSEEVENTF_FROMTOUCH 0xFF515700
52 
53 /* Masks for processing the windows KEYDOWN and KEYUP messages */
54 #define REPEATED_KEYMASK (1<<30)
55 #define EXTENDED_KEYMASK (1<<24)
56 
57 #define VK_ENTER 10 /* Keypad Enter ... no VKEY defined? */
58 #ifndef VK_OEM_NEC_EQUAL
59 #define VK_OEM_NEC_EQUAL 0x92
60 #endif
61 
62 /* Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... */
63 #ifndef WM_XBUTTONDOWN
64 #define WM_XBUTTONDOWN 0x020B
65 #endif
66 #ifndef WM_XBUTTONUP
67 #define WM_XBUTTONUP 0x020C
68 #endif
69 #ifndef GET_XBUTTON_WPARAM
70 #define GET_XBUTTON_WPARAM(w) (HIWORD(w))
71 #endif
72 #ifndef WM_INPUT
73 #define WM_INPUT 0x00ff
74 #endif
75 #ifndef WM_TOUCH
76 #define WM_TOUCH 0x0240
77 #endif
78 #ifndef WM_MOUSEHWHEEL
79 #define WM_MOUSEHWHEEL 0x020E
80 #endif
81 #ifndef WM_UNICHAR
82 #define WM_UNICHAR 0x0109
83 #endif
84 
85 static SDL_Scancode
86 VKeytoScancode(WPARAM vkey)
87 {
88  switch (vkey) {
89  case VK_CLEAR: return SDL_SCANCODE_CLEAR;
90  case VK_MODECHANGE: return SDL_SCANCODE_MODE;
91  case VK_SELECT: return SDL_SCANCODE_SELECT;
92  case VK_EXECUTE: return SDL_SCANCODE_EXECUTE;
93  case VK_HELP: return SDL_SCANCODE_HELP;
94  case VK_PAUSE: return SDL_SCANCODE_PAUSE;
95  case VK_NUMLOCK: return SDL_SCANCODE_NUMLOCKCLEAR;
96 
97  case VK_F13: return SDL_SCANCODE_F13;
98  case VK_F14: return SDL_SCANCODE_F14;
99  case VK_F15: return SDL_SCANCODE_F15;
100  case VK_F16: return SDL_SCANCODE_F16;
101  case VK_F17: return SDL_SCANCODE_F17;
102  case VK_F18: return SDL_SCANCODE_F18;
103  case VK_F19: return SDL_SCANCODE_F19;
104  case VK_F20: return SDL_SCANCODE_F20;
105  case VK_F21: return SDL_SCANCODE_F21;
106  case VK_F22: return SDL_SCANCODE_F22;
107  case VK_F23: return SDL_SCANCODE_F23;
108  case VK_F24: return SDL_SCANCODE_F24;
109 
110  case VK_OEM_NEC_EQUAL: return SDL_SCANCODE_KP_EQUALS;
111  case VK_BROWSER_BACK: return SDL_SCANCODE_AC_BACK;
112  case VK_BROWSER_FORWARD: return SDL_SCANCODE_AC_FORWARD;
113  case VK_BROWSER_REFRESH: return SDL_SCANCODE_AC_REFRESH;
114  case VK_BROWSER_STOP: return SDL_SCANCODE_AC_STOP;
115  case VK_BROWSER_SEARCH: return SDL_SCANCODE_AC_SEARCH;
116  case VK_BROWSER_FAVORITES: return SDL_SCANCODE_AC_BOOKMARKS;
117  case VK_BROWSER_HOME: return SDL_SCANCODE_AC_HOME;
118  case VK_VOLUME_MUTE: return SDL_SCANCODE_AUDIOMUTE;
119  case VK_VOLUME_DOWN: return SDL_SCANCODE_VOLUMEDOWN;
120  case VK_VOLUME_UP: return SDL_SCANCODE_VOLUMEUP;
121 
122  case VK_MEDIA_NEXT_TRACK: return SDL_SCANCODE_AUDIONEXT;
123  case VK_MEDIA_PREV_TRACK: return SDL_SCANCODE_AUDIOPREV;
124  case VK_MEDIA_STOP: return SDL_SCANCODE_AUDIOSTOP;
125  case VK_MEDIA_PLAY_PAUSE: return SDL_SCANCODE_AUDIOPLAY;
126  case VK_LAUNCH_MAIL: return SDL_SCANCODE_MAIL;
127  case VK_LAUNCH_MEDIA_SELECT: return SDL_SCANCODE_MEDIASELECT;
128 
130 
131  case VK_ATTN: return SDL_SCANCODE_SYSREQ;
132  case VK_CRSEL: return SDL_SCANCODE_CRSEL;
133  case VK_EXSEL: return SDL_SCANCODE_EXSEL;
134  case VK_OEM_CLEAR: return SDL_SCANCODE_CLEAR;
135 
136  case VK_LAUNCH_APP1: return SDL_SCANCODE_APP1;
137  case VK_LAUNCH_APP2: return SDL_SCANCODE_APP2;
138 
139  default: return SDL_SCANCODE_UNKNOWN;
140  }
141 }
142 
143 static SDL_Scancode
144 WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam)
145 {
146  SDL_Scancode code;
147  int nScanCode = (lParam >> 16) & 0xFF;
148  SDL_bool bIsExtended = (lParam & (1 << 24)) != 0;
149 
150  code = VKeytoScancode(wParam);
151 
152  if (code == SDL_SCANCODE_UNKNOWN && nScanCode <= 127) {
153  code = windows_scancode_table[nScanCode];
154 
155  if (bIsExtended) {
156  switch (code) {
157  case SDL_SCANCODE_RETURN:
158  code = SDL_SCANCODE_KP_ENTER;
159  break;
160  case SDL_SCANCODE_LALT:
161  code = SDL_SCANCODE_RALT;
162  break;
163  case SDL_SCANCODE_LCTRL:
164  code = SDL_SCANCODE_RCTRL;
165  break;
166  case SDL_SCANCODE_SLASH:
167  code = SDL_SCANCODE_KP_DIVIDE;
168  break;
170  code = SDL_SCANCODE_KP_PLUS;
171  break;
172  default:
173  break;
174  }
175  } else {
176  switch (code) {
177  case SDL_SCANCODE_HOME:
178  code = SDL_SCANCODE_KP_7;
179  break;
180  case SDL_SCANCODE_UP:
181  code = SDL_SCANCODE_KP_8;
182  break;
183  case SDL_SCANCODE_PAGEUP:
184  code = SDL_SCANCODE_KP_9;
185  break;
186  case SDL_SCANCODE_LEFT:
187  code = SDL_SCANCODE_KP_4;
188  break;
189  case SDL_SCANCODE_RIGHT:
190  code = SDL_SCANCODE_KP_6;
191  break;
192  case SDL_SCANCODE_END:
193  code = SDL_SCANCODE_KP_1;
194  break;
195  case SDL_SCANCODE_DOWN:
196  code = SDL_SCANCODE_KP_2;
197  break;
199  code = SDL_SCANCODE_KP_3;
200  break;
201  case SDL_SCANCODE_INSERT:
202  code = SDL_SCANCODE_KP_0;
203  break;
204  case SDL_SCANCODE_DELETE:
205  code = SDL_SCANCODE_KP_PERIOD;
206  break;
209  break;
210  default:
211  break;
212  }
213  }
214  }
215  return code;
216 }
217 
218 static SDL_bool
219 WIN_ShouldIgnoreFocusClick()
220 {
222 }
223 
224 static void
225 WIN_CheckWParamMouseButton(SDL_bool bwParamMousePressed, SDL_bool bSDLMousePressed, SDL_WindowData *data, Uint8 button, SDL_MouseID mouseID)
226 {
227  if (data->focus_click_pending & SDL_BUTTON(button)) {
228  /* Ignore the button click for activation */
229  if (!bwParamMousePressed) {
230  data->focus_click_pending &= ~SDL_BUTTON(button);
231  if (!data->focus_click_pending) {
233  }
234  }
235  if (WIN_ShouldIgnoreFocusClick()) {
236  return;
237  }
238  }
239 
240  if (bwParamMousePressed && !bSDLMousePressed) {
241  SDL_SendMouseButton(data->window, mouseID, SDL_PRESSED, button);
242  } else if (!bwParamMousePressed && bSDLMousePressed) {
243  SDL_SendMouseButton(data->window, mouseID, SDL_RELEASED, button);
244  }
245 }
246 
247 /*
248 * Some windows systems fail to send a WM_LBUTTONDOWN sometimes, but each mouse move contains the current button state also
249 * so this funciton reconciles our view of the world with the current buttons reported by windows
250 */
251 static void
252 WIN_CheckWParamMouseButtons(WPARAM wParam, SDL_WindowData *data, SDL_MouseID mouseID)
253 {
254  if (wParam != data->mouse_button_flags) {
255  Uint32 mouseFlags = SDL_GetMouseState(NULL, NULL);
256  WIN_CheckWParamMouseButton((wParam & MK_LBUTTON), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT, mouseID);
257  WIN_CheckWParamMouseButton((wParam & MK_MBUTTON), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE, mouseID);
258  WIN_CheckWParamMouseButton((wParam & MK_RBUTTON), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT, mouseID);
259  WIN_CheckWParamMouseButton((wParam & MK_XBUTTON1), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1, mouseID);
260  WIN_CheckWParamMouseButton((wParam & MK_XBUTTON2), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2, mouseID);
261  data->mouse_button_flags = wParam;
262  }
263 }
264 
265 
266 static void
267 WIN_CheckRawMouseButtons(ULONG rawButtons, SDL_WindowData *data)
268 {
269  if (rawButtons != data->mouse_button_flags) {
270  Uint32 mouseFlags = SDL_GetMouseState(NULL, NULL);
271  if ((rawButtons & RI_MOUSE_BUTTON_1_DOWN))
272  WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_1_DOWN), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT, 0);
273  if ((rawButtons & RI_MOUSE_BUTTON_1_UP))
274  WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_1_UP), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT, 0);
275  if ((rawButtons & RI_MOUSE_BUTTON_2_DOWN))
276  WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_2_DOWN), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT, 0);
277  if ((rawButtons & RI_MOUSE_BUTTON_2_UP))
278  WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_2_UP), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT, 0);
279  if ((rawButtons & RI_MOUSE_BUTTON_3_DOWN))
280  WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_3_DOWN), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE, 0);
281  if ((rawButtons & RI_MOUSE_BUTTON_3_UP))
282  WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_3_UP), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE, 0);
283  if ((rawButtons & RI_MOUSE_BUTTON_4_DOWN))
284  WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_4_DOWN), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1, 0);
285  if ((rawButtons & RI_MOUSE_BUTTON_4_UP))
286  WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_4_UP), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1, 0);
287  if ((rawButtons & RI_MOUSE_BUTTON_5_DOWN))
288  WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_5_DOWN), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2, 0);
289  if ((rawButtons & RI_MOUSE_BUTTON_5_UP))
290  WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_5_UP), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2, 0);
291  data->mouse_button_flags = rawButtons;
292  }
293 }
294 
295 static void
296 WIN_CheckAsyncMouseRelease(SDL_WindowData *data)
297 {
298  Uint32 mouseFlags;
299  SHORT keyState;
300 
301  /* mouse buttons may have changed state here, we need to resync them,
302  but we will get a WM_MOUSEMOVE right away which will fix things up if in non raw mode also
303  */
304  mouseFlags = SDL_GetMouseState(NULL, NULL);
305 
306  keyState = GetAsyncKeyState(VK_LBUTTON);
307  if (!(keyState & 0x8000)) {
308  WIN_CheckWParamMouseButton(SDL_FALSE, (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT, 0);
309  }
310  keyState = GetAsyncKeyState(VK_RBUTTON);
311  if (!(keyState & 0x8000)) {
312  WIN_CheckWParamMouseButton(SDL_FALSE, (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT, 0);
313  }
314  keyState = GetAsyncKeyState(VK_MBUTTON);
315  if (!(keyState & 0x8000)) {
316  WIN_CheckWParamMouseButton(SDL_FALSE, (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE, 0);
317  }
318  keyState = GetAsyncKeyState(VK_XBUTTON1);
319  if (!(keyState & 0x8000)) {
320  WIN_CheckWParamMouseButton(SDL_FALSE, (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1, 0);
321  }
322  keyState = GetAsyncKeyState(VK_XBUTTON2);
323  if (!(keyState & 0x8000)) {
324  WIN_CheckWParamMouseButton(SDL_FALSE, (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2, 0);
325  }
326  data->mouse_button_flags = 0;
327 }
328 
329 static BOOL
330 WIN_ConvertUTF32toUTF8(UINT32 codepoint, char * text)
331 {
332  if (codepoint <= 0x7F) {
333  text[0] = (char) codepoint;
334  text[1] = '\0';
335  } else if (codepoint <= 0x7FF) {
336  text[0] = 0xC0 | (char) ((codepoint >> 6) & 0x1F);
337  text[1] = 0x80 | (char) (codepoint & 0x3F);
338  text[2] = '\0';
339  } else if (codepoint <= 0xFFFF) {
340  text[0] = 0xE0 | (char) ((codepoint >> 12) & 0x0F);
341  text[1] = 0x80 | (char) ((codepoint >> 6) & 0x3F);
342  text[2] = 0x80 | (char) (codepoint & 0x3F);
343  text[3] = '\0';
344  } else if (codepoint <= 0x10FFFF) {
345  text[0] = 0xF0 | (char) ((codepoint >> 18) & 0x0F);
346  text[1] = 0x80 | (char) ((codepoint >> 12) & 0x3F);
347  text[2] = 0x80 | (char) ((codepoint >> 6) & 0x3F);
348  text[3] = 0x80 | (char) (codepoint & 0x3F);
349  text[4] = '\0';
350  } else {
351  return SDL_FALSE;
352  }
353  return SDL_TRUE;
354 }
355 
356 static SDL_bool
357 ShouldGenerateWindowCloseOnAltF4(void)
358 {
360 }
361 
362 LRESULT CALLBACK
363 WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
364 {
366  LRESULT returnCode = -1;
367 
368  /* Send a SDL_SYSWMEVENT if the application wants them */
370  SDL_SysWMmsg wmmsg;
371 
372  SDL_VERSION(&wmmsg.version);
374  wmmsg.msg.win.hwnd = hwnd;
375  wmmsg.msg.win.msg = msg;
376  wmmsg.msg.win.wParam = wParam;
377  wmmsg.msg.win.lParam = lParam;
378  SDL_SendSysWMEvent(&wmmsg);
379  }
380 
381  /* Get the window data for the window */
382  data = (SDL_WindowData *) GetProp(hwnd, TEXT("SDL_WindowData"));
383  if (!data) {
384  return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam);
385  }
386 
387 #ifdef WMMSG_DEBUG
388  {
389  char message[1024];
390  if (msg > MAX_WMMSG) {
391  SDL_snprintf(message, sizeof(message), "Received windows message: %p UNKNOWN (%d) -- 0x%X, 0x%X\n", hwnd, msg, wParam, lParam);
392  } else {
393  SDL_snprintf(message, sizeof(message), "Received windows message: %p %s -- 0x%X, 0x%X\n", hwnd, wmtab[msg], wParam, lParam);
394  }
395  OutputDebugStringA(message);
396  }
397 #endif /* WMMSG_DEBUG */
398 
399  if (IME_HandleMessage(hwnd, msg, wParam, &lParam, data->videodata))
400  return 0;
401 
402  switch (msg) {
403 
404  case WM_SHOWWINDOW:
405  {
406  if (wParam) {
408  } else {
410  }
411  }
412  break;
413 
414  case WM_ACTIVATE:
415  {
416  POINT cursorPos;
417  BOOL minimized;
418 
419  minimized = HIWORD(wParam);
420  if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) {
421  if (LOWORD(wParam) == WA_CLICKACTIVE) {
422  if (GetAsyncKeyState(VK_LBUTTON)) {
424  }
425  if (GetAsyncKeyState(VK_RBUTTON)) {
427  }
428  if (GetAsyncKeyState(VK_MBUTTON)) {
430  }
431  if (GetAsyncKeyState(VK_XBUTTON1)) {
433  }
434  if (GetAsyncKeyState(VK_XBUTTON2)) {
436  }
437  }
438 
440  if (SDL_GetKeyboardFocus() != data->window) {
442  }
443 
444  GetCursorPos(&cursorPos);
445  ScreenToClient(hwnd, &cursorPos);
446  SDL_SendMouseMotion(data->window, 0, 0, cursorPos.x, cursorPos.y);
447 
448  WIN_CheckAsyncMouseRelease(data);
449 
450  /*
451  * FIXME: Update keyboard state
452  */
454 
455  SDL_ToggleModState(KMOD_CAPS, (GetKeyState(VK_CAPITAL) & 0x0001) != 0);
456  SDL_ToggleModState(KMOD_NUM, (GetKeyState(VK_NUMLOCK) & 0x0001) != 0);
457  } else {
459 
460  if (SDL_GetKeyboardFocus() == data->window) {
463  }
464 
465  ClipCursor(NULL);
466 
468  }
469  }
470  returnCode = 0;
471  break;
472 
473  case WM_MOUSEMOVE:
474  {
475  SDL_Mouse *mouse = SDL_GetMouse();
476  if (!mouse->relative_mode || mouse->relative_mode_warp) {
477  SDL_MouseID mouseID = (((GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) ? SDL_TOUCH_MOUSEID : 0);
478  SDL_SendMouseMotion(data->window, mouseID, 0, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
479  }
480  }
481  /* don't break here, fall through to check the wParam like the button presses */
482  case WM_LBUTTONUP:
483  case WM_RBUTTONUP:
484  case WM_MBUTTONUP:
485  case WM_XBUTTONUP:
486  case WM_LBUTTONDOWN:
487  case WM_LBUTTONDBLCLK:
488  case WM_RBUTTONDOWN:
489  case WM_RBUTTONDBLCLK:
490  case WM_MBUTTONDOWN:
491  case WM_MBUTTONDBLCLK:
492  case WM_XBUTTONDOWN:
493  case WM_XBUTTONDBLCLK:
494  {
495  SDL_Mouse *mouse = SDL_GetMouse();
496  if (!mouse->relative_mode || mouse->relative_mode_warp) {
497  SDL_MouseID mouseID = (((GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) ? SDL_TOUCH_MOUSEID : 0);
498  WIN_CheckWParamMouseButtons(wParam, data, mouseID);
499  }
500  }
501  break;
502 
503  case WM_INPUT:
504  {
505  SDL_Mouse *mouse = SDL_GetMouse();
506  HRAWINPUT hRawInput = (HRAWINPUT)lParam;
507  RAWINPUT inp;
508  UINT size = sizeof(inp);
509  const SDL_bool isRelative = mouse->relative_mode || mouse->relative_mode_warp;
510  const SDL_bool isCapture = ((data->window->flags & SDL_WINDOW_MOUSE_CAPTURE) != 0);
511 
512  if (!isRelative || mouse->focus != data->window) {
513  if (!isCapture) {
514  break;
515  }
516  }
517 
518  GetRawInputData(hRawInput, RID_INPUT, &inp, &size, sizeof(RAWINPUTHEADER));
519 
520  /* Mouse data */
521  if (inp.header.dwType == RIM_TYPEMOUSE) {
522  if (isRelative) {
523  RAWMOUSE* rawmouse = &inp.data.mouse;
524 
525  if ((rawmouse->usFlags & 0x01) == MOUSE_MOVE_RELATIVE) {
526  SDL_SendMouseMotion(data->window, 0, 1, (int)rawmouse->lLastX, (int)rawmouse->lLastY);
527  } else {
528  /* synthesize relative moves from the abs position */
529  static SDL_Point initialMousePoint;
530  if (initialMousePoint.x == 0 && initialMousePoint.y == 0) {
531  initialMousePoint.x = rawmouse->lLastX;
532  initialMousePoint.y = rawmouse->lLastY;
533  }
534 
535  SDL_SendMouseMotion(data->window, 0, 1, (int)(rawmouse->lLastX-initialMousePoint.x), (int)(rawmouse->lLastY-initialMousePoint.y));
536 
537  initialMousePoint.x = rawmouse->lLastX;
538  initialMousePoint.y = rawmouse->lLastY;
539  }
540  WIN_CheckRawMouseButtons(rawmouse->usButtonFlags, data);
541  } else if (isCapture) {
542  /* we check for where Windows thinks the system cursor lives in this case, so we don't really lose mouse accel, etc. */
543  POINT pt;
544  RECT hwndRect;
545  HWND currentHnd;
546 
547  GetCursorPos(&pt);
548  currentHnd = WindowFromPoint(pt);
549  ScreenToClient(hwnd, &pt);
550  GetClientRect(hwnd, &hwndRect);
551 
552  /* if in the window, WM_MOUSEMOVE, etc, will cover it. */
553  if(currentHnd != hwnd || pt.x < 0 || pt.y < 0 || pt.x > hwndRect.right || pt.y > hwndRect.right) {
554  SDL_SendMouseMotion(data->window, 0, 0, (int)pt.x, (int)pt.y);
555  SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_LBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_LEFT);
556  SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_RBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_RIGHT);
557  SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_MBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_MIDDLE);
558  SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_XBUTTON1) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_X1);
559  SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_XBUTTON2) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_X2);
560  }
561  } else {
562  SDL_assert(0 && "Shouldn't happen");
563  }
564  }
565  }
566  break;
567 
568  case WM_MOUSEWHEEL:
569  case WM_MOUSEHWHEEL:
570  {
571  short amount = GET_WHEEL_DELTA_WPARAM(wParam);
572  float fAmount = (float) amount / WHEEL_DELTA;
573  if (msg == WM_MOUSEWHEEL)
574  SDL_SendMouseWheel(data->window, 0, 0.0f, fAmount, SDL_MOUSEWHEEL_NORMAL);
575  else
576  SDL_SendMouseWheel(data->window, 0, fAmount, 0.0f, SDL_MOUSEWHEEL_NORMAL);
577  }
578  break;
579 
580 #ifdef WM_MOUSELEAVE
581  case WM_MOUSELEAVE:
582  if (SDL_GetMouseFocus() == data->window && !SDL_GetMouse()->relative_mode && !(data->window->flags & SDL_WINDOW_MOUSE_CAPTURE)) {
583  if (!IsIconic(hwnd)) {
584  POINT cursorPos;
585  GetCursorPos(&cursorPos);
586  ScreenToClient(hwnd, &cursorPos);
587  SDL_SendMouseMotion(data->window, 0, 0, cursorPos.x, cursorPos.y);
588  }
590  }
591  returnCode = 0;
592  break;
593 #endif /* WM_MOUSELEAVE */
594 
595  case WM_KEYDOWN:
596  case WM_SYSKEYDOWN:
597  {
598  SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam);
599  const Uint8 *keyboardState = SDL_GetKeyboardState(NULL);
600 
601  /* Detect relevant keyboard shortcuts */
602  if (keyboardState[SDL_SCANCODE_LALT] == SDL_PRESSED || keyboardState[SDL_SCANCODE_RALT] == SDL_PRESSED) {
603  /* ALT+F4: Close window */
604  if (code == SDL_SCANCODE_F4 && ShouldGenerateWindowCloseOnAltF4()) {
606  }
607  }
608 
609  if (code != SDL_SCANCODE_UNKNOWN) {
611  }
612  }
613 
614  returnCode = 0;
615  break;
616 
617  case WM_SYSKEYUP:
618  case WM_KEYUP:
619  {
620  SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam);
621  const Uint8 *keyboardState = SDL_GetKeyboardState(NULL);
622 
623  if (code != SDL_SCANCODE_UNKNOWN) {
624  if (code == SDL_SCANCODE_PRINTSCREEN &&
625  keyboardState[code] == SDL_RELEASED) {
627  }
629  }
630  }
631  returnCode = 0;
632  break;
633 
634  case WM_UNICHAR:
635  if ( wParam == UNICODE_NOCHAR ) {
636  returnCode = 1;
637  break;
638  }
639  /* otherwise fall through to below */
640  case WM_CHAR:
641  {
642  char text[5];
643  if ( WIN_ConvertUTF32toUTF8( (UINT32)wParam, text ) ) {
644  SDL_SendKeyboardText( text );
645  }
646  }
647  returnCode = 0;
648  break;
649 
650 #ifdef WM_INPUTLANGCHANGE
651  case WM_INPUTLANGCHANGE:
652  {
655  }
656  returnCode = 1;
657  break;
658 #endif /* WM_INPUTLANGCHANGE */
659 
660  case WM_NCLBUTTONDOWN:
661  {
662  data->in_title_click = SDL_TRUE;
663  }
664  break;
665 
666  case WM_CAPTURECHANGED:
667  {
668  data->in_title_click = SDL_FALSE;
669 
670  /* The mouse may have been released during a modal loop */
671  WIN_CheckAsyncMouseRelease(data);
672  }
673  break;
674 
675 #ifdef WM_GETMINMAXINFO
676  case WM_GETMINMAXINFO:
677  {
678  MINMAXINFO *info;
679  RECT size;
680  int x, y;
681  int w, h;
682  int min_w, min_h;
683  int max_w, max_h;
684  int style;
685  BOOL menu;
686  BOOL constrain_max_size;
687 
688  if (SDL_IsShapedWindow(data->window))
690 
691  /* If this is an expected size change, allow it */
692  if (data->expected_resize) {
693  break;
694  }
695 
696  /* Get the current position of our window */
697  GetWindowRect(hwnd, &size);
698  x = size.left;
699  y = size.top;
700 
701  /* Calculate current size of our window */
702  SDL_GetWindowSize(data->window, &w, &h);
703  SDL_GetWindowMinimumSize(data->window, &min_w, &min_h);
704  SDL_GetWindowMaximumSize(data->window, &max_w, &max_h);
705 
706  /* Store in min_w and min_h difference between current size and minimal
707  size so we don't need to call AdjustWindowRectEx twice */
708  min_w -= w;
709  min_h -= h;
710  if (max_w && max_h) {
711  max_w -= w;
712  max_h -= h;
713  constrain_max_size = TRUE;
714  } else {
715  constrain_max_size = FALSE;
716  }
717 
718  size.top = 0;
719  size.left = 0;
720  size.bottom = h;
721  size.right = w;
722 
723  style = GetWindowLong(hwnd, GWL_STYLE);
724  /* DJM - according to the docs for GetMenu(), the
725  return value is undefined if hwnd is a child window.
726  Apparently it's too difficult for MS to check
727  inside their function, so I have to do it here.
728  */
729  menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
730  AdjustWindowRectEx(&size, style, menu, 0);
731  w = size.right - size.left;
732  h = size.bottom - size.top;
733 
734  /* Fix our size to the current size */
735  info = (MINMAXINFO *) lParam;
737  info->ptMinTrackSize.x = w + min_w;
738  info->ptMinTrackSize.y = h + min_h;
739  if (constrain_max_size) {
740  info->ptMaxTrackSize.x = w + max_w;
741  info->ptMaxTrackSize.y = h + max_h;
742  }
743  } else {
744  info->ptMaxSize.x = w;
745  info->ptMaxSize.y = h;
746  info->ptMaxPosition.x = x;
747  info->ptMaxPosition.y = y;
748  info->ptMinTrackSize.x = w;
749  info->ptMinTrackSize.y = h;
750  info->ptMaxTrackSize.x = w;
751  info->ptMaxTrackSize.y = h;
752  }
753  }
754  returnCode = 0;
755  break;
756 #endif /* WM_GETMINMAXINFO */
757 
758  case WM_WINDOWPOSCHANGING:
759 
760  if (data->expected_resize) {
761  returnCode = 0;
762  }
763  break;
764 
765  case WM_WINDOWPOSCHANGED:
766  {
767  RECT rect;
768  int x, y;
769  int w, h;
770 
771  if (data->initializing || data->in_border_change) {
772  break;
773  }
774 
775  if (!GetClientRect(hwnd, &rect) || IsRectEmpty(&rect)) {
776  break;
777  }
778  ClientToScreen(hwnd, (LPPOINT) & rect);
779  ClientToScreen(hwnd, (LPPOINT) & rect + 1);
780 
782 
783  x = rect.left;
784  y = rect.top;
786 
787  w = rect.right - rect.left;
788  h = rect.bottom - rect.top;
790  h);
791 
792  /* Forces a WM_PAINT event */
793  InvalidateRect(hwnd, NULL, FALSE);
794  }
795  break;
796 
797  case WM_SIZE:
798  {
799  switch (wParam) {
800  case SIZE_MAXIMIZED:
805  break;
806  case SIZE_MINIMIZED:
809  break;
810  default:
813  break;
814  }
815  }
816  break;
817 
818  case WM_SETCURSOR:
819  {
820  Uint16 hittest;
821 
822  hittest = LOWORD(lParam);
823  if (hittest == HTCLIENT) {
824  SetCursor(SDL_cursor);
825  returnCode = TRUE;
827  SetCursor(NULL);
828  returnCode = TRUE;
829  }
830  }
831  break;
832 
833  /* We were occluded, refresh our display */
834  case WM_PAINT:
835  {
836  RECT rect;
837  if (GetUpdateRect(hwnd, &rect, FALSE)) {
838  ValidateRect(hwnd, NULL);
840  0, 0);
841  }
842  }
843  returnCode = 0;
844  break;
845 
846  /* We'll do our own drawing, prevent flicker */
847  case WM_ERASEBKGND:
848  {
849  }
850  return (1);
851 
852  case WM_SYSCOMMAND:
853  {
854  if ((wParam & 0xFFF0) == SC_KEYMENU) {
855  return (0);
856  }
857 
858 #if defined(SC_SCREENSAVE) || defined(SC_MONITORPOWER)
859  /* Don't start the screensaver or blank the monitor in fullscreen apps */
860  if ((wParam & 0xFFF0) == SC_SCREENSAVE ||
861  (wParam & 0xFFF0) == SC_MONITORPOWER) {
862  if (SDL_GetVideoDevice()->suspend_screensaver) {
863  return (0);
864  }
865  }
866 #endif /* System has screensaver support */
867  }
868  break;
869 
870  case WM_CLOSE:
871  {
873  }
874  returnCode = 0;
875  break;
876 
877  case WM_TOUCH:
878  if (data->videodata->GetTouchInputInfo && data->videodata->CloseTouchInputHandle) {
879  UINT i, num_inputs = LOWORD(wParam);
880  PTOUCHINPUT inputs = SDL_stack_alloc(TOUCHINPUT, num_inputs);
881  if (data->videodata->GetTouchInputInfo((HTOUCHINPUT)lParam, num_inputs, inputs, sizeof(TOUCHINPUT))) {
882  RECT rect;
883  float x, y;
884 
885  if (!GetClientRect(hwnd, &rect) ||
886  (rect.right == rect.left && rect.bottom == rect.top)) {
887  if (inputs) {
888  SDL_stack_free(inputs);
889  }
890  break;
891  }
892  ClientToScreen(hwnd, (LPPOINT) & rect);
893  ClientToScreen(hwnd, (LPPOINT) & rect + 1);
894  rect.top *= 100;
895  rect.left *= 100;
896  rect.bottom *= 100;
897  rect.right *= 100;
898 
899  for (i = 0; i < num_inputs; ++i) {
900  PTOUCHINPUT input = &inputs[i];
901 
902  const SDL_TouchID touchId = (SDL_TouchID)((size_t)input->hSource);
903  if (SDL_AddTouch(touchId, "") < 0) {
904  continue;
905  }
906 
907  /* Get the normalized coordinates for the window */
908  x = (float)(input->x - rect.left)/(rect.right - rect.left);
909  y = (float)(input->y - rect.top)/(rect.bottom - rect.top);
910 
911  if (input->dwFlags & TOUCHEVENTF_DOWN) {
912  SDL_SendTouch(touchId, input->dwID, SDL_TRUE, x, y, 1.0f);
913  }
914  if (input->dwFlags & TOUCHEVENTF_MOVE) {
915  SDL_SendTouchMotion(touchId, input->dwID, x, y, 1.0f);
916  }
917  if (input->dwFlags & TOUCHEVENTF_UP) {
918  SDL_SendTouch(touchId, input->dwID, SDL_FALSE, x, y, 1.0f);
919  }
920  }
921  }
922  SDL_stack_free(inputs);
923 
924  data->videodata->CloseTouchInputHandle((HTOUCHINPUT)lParam);
925  return 0;
926  }
927  break;
928 
929  case WM_DROPFILES:
930  {
931  UINT i;
932  HDROP drop = (HDROP) wParam;
933  UINT count = DragQueryFile(drop, 0xFFFFFFFF, NULL, 0);
934  for (i = 0; i < count; ++i) {
935  UINT size = DragQueryFile(drop, i, NULL, 0) + 1;
936  LPTSTR buffer = SDL_stack_alloc(TCHAR, size);
937  if (buffer) {
938  if (DragQueryFile(drop, i, buffer, size)) {
939  char *file = WIN_StringToUTF8(buffer);
940  SDL_SendDropFile(data->window, file);
941  SDL_free(file);
942  }
943  SDL_stack_free(buffer);
944  }
945  }
947  DragFinish(drop);
948  return 0;
949  }
950  break;
951 
952  case WM_NCCALCSIZE:
953  {
954  // When borderless, need to tell windows that the size of the non-client area is 0
955  if ( wParam == TRUE && SDL_GetWindowFlags( data->window ) & SDL_WINDOW_BORDERLESS )
956  return 0;
957  }
958  break;
959 
960  case WM_NCHITTEST:
961  {
962  SDL_Window *window = data->window;
963  if (window->hit_test) {
964  POINT winpoint = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
965  if (ScreenToClient(hwnd, &winpoint)) {
966  const SDL_Point point = { (int) winpoint.x, (int) winpoint.y };
967  const SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data);
968  switch (rc) {
969  #define POST_HIT_TEST(ret) { SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_HIT_TEST, 0, 0); return ret; }
970  case SDL_HITTEST_DRAGGABLE: POST_HIT_TEST(HTCAPTION);
971  case SDL_HITTEST_RESIZE_TOPLEFT: POST_HIT_TEST(HTTOPLEFT);
972  case SDL_HITTEST_RESIZE_TOP: POST_HIT_TEST(HTTOP);
973  case SDL_HITTEST_RESIZE_TOPRIGHT: POST_HIT_TEST(HTTOPRIGHT);
974  case SDL_HITTEST_RESIZE_RIGHT: POST_HIT_TEST(HTRIGHT);
975  case SDL_HITTEST_RESIZE_BOTTOMRIGHT: POST_HIT_TEST(HTBOTTOMRIGHT);
976  case SDL_HITTEST_RESIZE_BOTTOM: POST_HIT_TEST(HTBOTTOM);
977  case SDL_HITTEST_RESIZE_BOTTOMLEFT: POST_HIT_TEST(HTBOTTOMLEFT);
978  case SDL_HITTEST_RESIZE_LEFT: POST_HIT_TEST(HTLEFT);
979  #undef POST_HIT_TEST
980  case SDL_HITTEST_NORMAL: return HTCLIENT;
981  }
982  }
983  /* If we didn't return, this will call DefWindowProc below. */
984  }
985  }
986  break;
987  }
988 
989  /* If there's a window proc, assume it's going to handle messages */
990  if (data->wndproc) {
991  return CallWindowProc(data->wndproc, hwnd, msg, wParam, lParam);
992  } else if (returnCode >= 0) {
993  return returnCode;
994  } else {
995  return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam);
996  }
997 }
998 
999 /* A message hook called before TranslateMessage() */
1000 static SDL_WindowsMessageHook g_WindowsMessageHook = NULL;
1001 static void *g_WindowsMessageHookData = NULL;
1002 
1004 {
1005  g_WindowsMessageHook = callback;
1006  g_WindowsMessageHookData = userdata;
1007 }
1008 
1009 void
1011 {
1012  const Uint8 *keystate;
1013  MSG msg;
1014  DWORD start_ticks = GetTickCount();
1015 
1017  while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
1018  if (g_WindowsMessageHook) {
1019  g_WindowsMessageHook(g_WindowsMessageHookData, msg.hwnd, msg.message, msg.wParam, msg.lParam);
1020  }
1021 
1022  /* Always translate the message in case it's a non-SDL window (e.g. with Qt integration) */
1023  TranslateMessage(&msg);
1024  DispatchMessage(&msg);
1025 
1026  /* Make sure we don't busy loop here forever if there are lots of events coming in */
1027  if (SDL_TICKS_PASSED(msg.time, start_ticks)) {
1028  break;
1029  }
1030  }
1031  }
1032 
1033  /* Windows loses a shift KEYUP event when you have both pressed at once and let go of one.
1034  You won't get a KEYUP until both are released, and that keyup will only be for the second
1035  key you released. Take heroic measures and check the keystate as of the last handled event,
1036  and if we think a key is pressed when Windows doesn't, unstick it in SDL's state. */
1037  keystate = SDL_GetKeyboardState(NULL);
1038  if ((keystate[SDL_SCANCODE_LSHIFT] == SDL_PRESSED) && !(GetKeyState(VK_LSHIFT) & 0x8000)) {
1040  }
1041  if ((keystate[SDL_SCANCODE_RSHIFT] == SDL_PRESSED) && !(GetKeyState(VK_RSHIFT) & 0x8000)) {
1043  }
1044 }
1045 
1046 static int app_registered = 0;
1047 LPTSTR SDL_Appname = NULL;
1048 Uint32 SDL_Appstyle = 0;
1049 HINSTANCE SDL_Instance = NULL;
1050 
1051 /* Register the class for this application */
1052 int
1053 SDL_RegisterApp(char *name, Uint32 style, void *hInst)
1054 {
1055  const char *hint;
1056  WNDCLASSEX wcex;
1057  TCHAR path[MAX_PATH];
1058 
1059  /* Only do this once... */
1060  if (app_registered) {
1061  ++app_registered;
1062  return (0);
1063  }
1064  if (!name && !SDL_Appname) {
1065  name = "SDL_app";
1066 #if defined(CS_BYTEALIGNCLIENT) || defined(CS_OWNDC)
1067  SDL_Appstyle = (CS_BYTEALIGNCLIENT | CS_OWNDC);
1068 #endif
1069  SDL_Instance = hInst ? hInst : GetModuleHandle(NULL);
1070  }
1071 
1072  if (name) {
1073  SDL_Appname = WIN_UTF8ToString(name);
1074  SDL_Appstyle = style;
1075  SDL_Instance = hInst ? hInst : GetModuleHandle(NULL);
1076  }
1077 
1078  /* Register the application class */
1079  wcex.cbSize = sizeof(WNDCLASSEX);
1080  wcex.hCursor = NULL;
1081  wcex.hIcon = NULL;
1082  wcex.hIconSm = NULL;
1083  wcex.lpszMenuName = NULL;
1084  wcex.lpszClassName = SDL_Appname;
1085  wcex.style = SDL_Appstyle;
1086  wcex.hbrBackground = NULL;
1087  wcex.lpfnWndProc = WIN_WindowProc;
1088  wcex.hInstance = SDL_Instance;
1089  wcex.cbClsExtra = 0;
1090  wcex.cbWndExtra = 0;
1091 
1093  if (hint && *hint) {
1094  wcex.hIcon = LoadIcon(SDL_Instance, MAKEINTRESOURCE(SDL_atoi(hint)));
1095 
1097  if (hint && *hint) {
1098  wcex.hIconSm = LoadIcon(SDL_Instance, MAKEINTRESOURCE(SDL_atoi(hint)));
1099  }
1100  } else {
1101  /* Use the first icon as a default icon, like in the Explorer */
1102  GetModuleFileName(SDL_Instance, path, MAX_PATH);
1103  ExtractIconEx(path, 0, &wcex.hIcon, &wcex.hIconSm, 1);
1104  }
1105 
1106  if (!RegisterClassEx(&wcex)) {
1107  return SDL_SetError("Couldn't register application class");
1108  }
1109 
1110  app_registered = 1;
1111  return 0;
1112 }
1113 
1114 /* Unregisters the windowclass registered in SDL_RegisterApp above. */
1115 void
1117 {
1118  WNDCLASSEX wcex;
1119 
1120  /* SDL_RegisterApp might not have been called before */
1121  if (!app_registered) {
1122  return;
1123  }
1124  --app_registered;
1125  if (app_registered == 0) {
1126  /* Check for any registered window classes. */
1127  if (GetClassInfoEx(SDL_Instance, SDL_Appname, &wcex)) {
1128  UnregisterClass(SDL_Appname, SDL_Instance);
1129  if (wcex.hIcon) DestroyIcon(wcex.hIcon);
1130  if (wcex.hIconSm) DestroyIcon(wcex.hIconSm);
1131  }
1132  SDL_free(SDL_Appname);
1133  SDL_Appname = NULL;
1134  }
1135 }
1136 
1137 #endif /* SDL_VIDEO_DRIVER_WINDOWS */
1138 
1139 /* vi: set ts=4 sw=4 expandtab: */
SDL_version version
Definition: SDL_syswm.h:137
HINSTANCE SDL_Instance
#define WIN_UTF8ToString(S)
Definition: SDL_windows.h:47
SDL_Mouse * SDL_GetMouse(void)
Definition: SDL_mouse.c:112
SDL_bool g_WindowFrameUsableWhileCursorHidden
#define SDL_HINT_WINDOWS_INTRESOURCE_ICON
A variable to specify custom icon resource id from RC file on Windows platform.
Definition: SDL_hints.h:227
#define SDL_IsShapedWindow
SDL_Texture * button
void SDL_SetKeyboardFocus(SDL_Window *window)
Definition: SDL_keyboard.c:630
int Win32_ResizeWindowShape(SDL_Window *window)
#define SDL_BUTTON_RMASK
Definition: SDL_mouse.h:289
void * hit_test_data
Definition: SDL_sysvideo.h:107
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
GLuint GLsizei const GLchar * message
SDL_bool relative_mode_warp
Definition: SDL_mouse_c.h:88
SDL_Window * focus
Definition: SDL_mouse_c.h:77
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
SDL_Rect rect
Definition: testrelative.c:27
int SDL_SendDropFile(SDL_Window *window, const char *file)
#define SDL_BUTTON_X2MASK
Definition: SDL_mouse.h:291
LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
GLfloat GLfloat GLfloat GLfloat h
#define SDL_BUTTON_RIGHT
Definition: SDL_mouse.h:284
The structure that defines a point.
Definition: SDL_rect.h:48
void WIN_ResetDeadKeys(void)
#define SDL_GetHint
#define SDL_GetWindowFlags
int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_bool down, float x, float y, float pressure)
Definition: SDL_touch.c:222
SDL_bool expected_resize
#define SDL_ENABLE
Definition: SDL_events.h:722
LPTSTR SDL_Appname
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
SDL_Window * window
#define SDL_BUTTON_X1
Definition: SDL_mouse.h:285
void SDL_SetMouseFocus(SDL_Window *window)
Definition: SDL_mouse.c:151
#define SDL_GetKeyboardFocus
uint32_t Uint32
Definition: SDL_stdinc.h:181
#define SDL_TOUCH_MOUSEID
Definition: SDL_touch.h:53
union SDL_SysWMmsg::@16 msg
#define TOUCHEVENTF_MOVE
SDL_bool g_WindowsEnableMessageLoop
int SDL_SendDropComplete(SDL_Window *window)
int SDL_SendSysWMEvent(SDL_SysWMmsg *message)
Definition: SDL_events.c:934
GLuint const GLchar * name
Uint32 SDL_MouseID
Definition: SDL_mouse_c.h:28
int SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode)
Definition: SDL_keyboard.c:679
int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, float x, float y, float pressure)
Definition: SDL_touch.c:284
#define SDL_GetHintBoolean
#define SDL_VERSION(x)
Macro to determine SDL version program was compiled against.
Definition: SDL_version.h:79
SDL_HitTestResult
Possible return values from the SDL_HitTest callback.
Definition: SDL_video.h:991
int x
Definition: SDL_rect.h:50
void SDL_UnregisterApp(void)
#define SDL_GetWindowSize
SDL_bool in_border_change
GLenum GLenum GLenum input
#define SDL_GetEventState(type)
Definition: SDL_events.h:735
#define SDL_GetKeyboardState
int SDL_SendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y)
Definition: SDL_mouse.c:237
#define SDL_BUTTON_LEFT
Definition: SDL_mouse.h:282
int y
Definition: SDL_rect.h:51
#define _THIS
struct SDL_VideoData * videodata
uint8_t Uint8
Definition: SDL_stdinc.h:157
int SDL_SendKeyboardText(const char *text)
Definition: SDL_keyboard.c:789
#define SDL_free
#define SDL_stack_alloc(type, count)
Definition: SDL_stdinc.h:354
#define TRUE
Definition: edid-parse.c:33
SDL_bool relative_mode
Definition: SDL_mouse_c.h:87
#define SDL_BUTTON_X1MASK
Definition: SDL_mouse.h:290
GLubyte GLubyte GLubyte GLubyte w
void WIN_UpdateClipCursor(SDL_Window *window)
#define WIN_StringToUTF8(S)
Definition: SDL_windows.h:46
Sint64 SDL_TouchID
Definition: SDL_touch.h:41
static Uint32 callback(Uint32 interval, void *param)
Definition: testtimer.c:34
#define SDL_BUTTON_LMASK
Definition: SDL_mouse.h:287
#define SDL_BUTTON_MIDDLE
Definition: SDL_mouse.h:283
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
#define SDL_GetWindowMinimumSize
int SDL_AddTouch(SDL_TouchID touchID, const char *name)
Definition: SDL_touch.c:136
BOOL(WINAPI *CloseTouchInputHandle)(HTOUCHINPUT)
#define SDL_atoi
GLsizeiptr size
#define TOUCHEVENTF_DOWN
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
void SDL_ToggleModState(const SDL_Keymod modstate, const SDL_bool toggle)
Definition: SDL_keyboard.c:865
#define SDL_assert(condition)
Definition: SDL_assert.h:169
SDL_SYSWM_TYPE subsystem
Definition: SDL_syswm.h:138
#define NULL
Definition: begin_code.h:164
SDL_bool
Definition: SDL_stdinc.h:139
GLuint buffer
int SDL_SendMouseWheel(SDL_Window *window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction)
Definition: SDL_mouse.c:512
#define SDL_GetMouseFocus
SDL_HitTest hit_test
Definition: SDL_sysvideo.h:106
#define SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL
Definition: SDL_hints.h:228
void WIN_UpdateKeymap(void)
#define SDL_SetError
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:47
void WIN_PumpEvents(_THIS)
int SDL_SendKeymapChangedEvent(void)
Definition: SDL_events.c:951
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
static const SDL_Scancode windows_scancode_table[]
The type used to identify a window.
Definition: SDL_sysvideo.h:73
uint16_t Uint16
Definition: SDL_stdinc.h:169
void(* SDL_WindowsMessageHook)(void *userdata, void *hWnd, unsigned int message, Uint64 wParam, Sint64 lParam)
Set a function that is called for every windows message, before TranslateMessage() ...
Definition: SDL_system.h:49
SDL_VideoDevice * SDL_GetVideoDevice(void)
Definition: SDL_video.c:586
#define SDL_GetWindowMaximumSize
#define SDL_snprintf
#define SDL_BUTTON(X)
Definition: SDL_mouse.h:281
SDL_bool in_window_deactivation
#define VK_OEM_102
Definition: SDL_vkeys.h:74
GLsizei const GLchar *const * path
char * wmtab[]
Definition: wmmsg.h:24
void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata)
#define SDL_PRESSED
Definition: SDL_events.h:50
#define SDL_stack_free(data)
Definition: SDL_stdinc.h:355
void WIN_CheckClipboardUpdate(struct SDL_VideoData *data)
#define SDL_BUTTON_X2
Definition: SDL_mouse.h:286
#define FALSE
Definition: edid-parse.c:34
Uint32 flags
Definition: SDL_sysvideo.h:83
#define SDL_TICKS_PASSED(A, B)
Compare SDL ticks values, and return true if A has passed B.
Definition: SDL_timer.h:56
HCURSOR SDL_cursor
#define SDL_RELEASED
Definition: SDL_events.h:49
#define SDL_BUTTON_MMASK
Definition: SDL_mouse.h:288
#define SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH
Allow mouse click events when clicking to focus an SDL window.
Definition: SDL_hints.h:282
#define MAX_WMMSG
Definition: wmmsg.h:22
#define TOUCHEVENTF_UP
int SDL_SendMouseButton(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button)
Definition: SDL_mouse.c:506
SDL_Scancode
The SDL keyboard scancode representation.
Definition: SDL_scancode.h:43
#define SDL_GetMouseState
int SDL_RegisterApp(char *name, Uint32 style, void *hInst)
SDL_bool in_title_click
#define SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4
Tell SDL not to generate window-close events for Alt+F4 on Windows.
Definition: SDL_hints.h:755
SDL_bool IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, struct SDL_VideoData *videodata)
Uint32 SDL_Appstyle