1 //========================================================================
2 // GLFW 3.5 Win32 - www.glfw.org
3 //------------------------------------------------------------------------
4 // Copyright (c) 2002-2006 Marcus Geelnard
5 // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
6 //
7 // This software is provided 'as-is', without any express or implied
8 // warranty. In no event will the authors be held liable for any damages
9 // arising from the use of this software.
10 //
11 // Permission is granted to anyone to use this software for any purpose,
12 // including commercial applications, and to alter it and redistribute it
13 // freely, subject to the following restrictions:
14 //
15 // 1. The origin of this software must not be misrepresented; you must not
16 //    claim that you wrote the original software. If you use this software
17 //    in a product, an acknowledgment in the product documentation would
18 //    be appreciated but is not required.
19 //
20 // 2. Altered source versions must be plainly marked as such, and must not
21 //    be misrepresented as being the original software.
22 //
23 // 3. This notice may not be removed or altered from any source
24 //    distribution.
25 //
26 //========================================================================
27 
28 // We don't need all the fancy stuff
29 #ifndef NOMINMAX
30  #define NOMINMAX
31 #endif
32 
33 #ifndef VC_EXTRALEAN
34  #define VC_EXTRALEAN
35 #endif
36 
37 #ifndef WIN32_LEAN_AND_MEAN
38  #define WIN32_LEAN_AND_MEAN
39 #endif
40 
41 // This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
42 // example to allow applications to correctly declare a GL_KHR_debug callback)
43 // but windows.h assumes no one will define APIENTRY before it does
44 #undef APIENTRY
45 
46 // GLFW on Windows is Unicode only and does not work in MBCS mode
47 #ifndef UNICODE
48  #define UNICODE
49 #endif
50 
51 // GLFW requires Windows XP or later
52 #if WINVER < 0x0501
53  #undef WINVER
54  #define WINVER 0x0501
55 #endif
56 #if _WIN32_WINNT < 0x0501
57  #undef _WIN32_WINNT
58  #define _WIN32_WINNT 0x0501
59 #endif
60 
61 // GLFW uses DirectInput8 interfaces
62 #define DIRECTINPUT_VERSION 0x0800
63 
64 // GLFW uses OEM cursor resources
65 #define OEMRESOURCE
66 
67 #include <wctype.h>
68 #include <windows.h>
69 #include <dinput.h>
70 #include <xinput.h>
71 #include <dbt.h>
72 
73 // HACK: Define macros that some windows.h variants don't
74 #ifndef WM_MOUSEHWHEEL
75  #define WM_MOUSEHWHEEL 0x020E
76 #endif
77 #ifndef WM_DWMCOMPOSITIONCHANGED
78  #define WM_DWMCOMPOSITIONCHANGED 0x031E
79 #endif
80 #ifndef WM_DWMCOLORIZATIONCOLORCHANGED
81  #define WM_DWMCOLORIZATIONCOLORCHANGED 0x0320
82 #endif
83 #ifndef WM_COPYGLOBALDATA
84  #define WM_COPYGLOBALDATA 0x0049
85 #endif
86 #ifndef WM_UNICHAR
87  #define WM_UNICHAR 0x0109
88 #endif
89 #ifndef UNICODE_NOCHAR
90  #define UNICODE_NOCHAR 0xFFFF
91 #endif
92 #ifndef WM_DPICHANGED
93  #define WM_DPICHANGED 0x02E0
94 #endif
95 #ifndef GET_XBUTTON_WPARAM
96  #define GET_XBUTTON_WPARAM(w) (HIWORD(w))
97 #endif
98 #ifndef EDS_ROTATEDMODE
99  #define EDS_ROTATEDMODE 0x00000004
100 #endif
101 #ifndef DISPLAY_DEVICE_ACTIVE
102  #define DISPLAY_DEVICE_ACTIVE 0x00000001
103 #endif
104 #ifndef _WIN32_WINNT_WINBLUE
105  #define _WIN32_WINNT_WINBLUE 0x0603
106 #endif
107 #ifndef _WIN32_WINNT_WIN8
108  #define _WIN32_WINNT_WIN8 0x0602
109 #endif
110 #ifndef WM_GETDPISCALEDSIZE
111  #define WM_GETDPISCALEDSIZE 0x02e4
112 #endif
113 #ifndef USER_DEFAULT_SCREEN_DPI
114  #define USER_DEFAULT_SCREEN_DPI 96
115 #endif
116 #ifndef OCR_HAND
117  #define OCR_HAND 32649
118 #endif
119 
120 #if WINVER < 0x0601
121 typedef struct
122 {
123     DWORD cbSize;
124     DWORD ExtStatus;
125 } CHANGEFILTERSTRUCT;
126 #ifndef MSGFLT_ALLOW
127  #define MSGFLT_ALLOW 1
128 #endif
129 #endif /*Windows 7*/
130 
131 #if WINVER < 0x0600
132 #define DWM_BB_ENABLE 0x00000001
133 #define DWM_BB_BLURREGION 0x00000002
134 typedef struct
135 {
136     DWORD dwFlags;
137     BOOL fEnable;
138     HRGN hRgnBlur;
139     BOOL fTransitionOnMaximized;
140 } DWM_BLURBEHIND;
141 #else
142  #include <dwmapi.h>
143 #endif /*Windows Vista*/
144 
145 #ifndef DPI_ENUMS_DECLARED
146 typedef enum
147 {
148     PROCESS_DPI_UNAWARE = 0,
149     PROCESS_SYSTEM_DPI_AWARE = 1,
150     PROCESS_PER_MONITOR_DPI_AWARE = 2
151 } PROCESS_DPI_AWARENESS;
152 typedef enum
153 {
154     MDT_EFFECTIVE_DPI = 0,
155     MDT_ANGULAR_DPI = 1,
156     MDT_RAW_DPI = 2,
157     MDT_DEFAULT = MDT_EFFECTIVE_DPI
158 } MONITOR_DPI_TYPE;
159 #endif /*DPI_ENUMS_DECLARED*/
160 
161 #ifndef DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2
162 #define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((HANDLE) -4)
163 #endif /*DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2*/
164 
165 // Replacement for versionhelpers.h macros, as we cannot rely on the
166 // application having a correct embedded manifest
167 //
168 #define IsWindowsVistaOrGreater()                                     \
169     _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_VISTA),   \
170                                         LOBYTE(_WIN32_WINNT_VISTA), 0)
171 #define IsWindows7OrGreater()                                         \
172     _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WIN7),    \
173                                         LOBYTE(_WIN32_WINNT_WIN7), 0)
174 #define IsWindows8OrGreater()                                         \
175     _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WIN8),    \
176                                         LOBYTE(_WIN32_WINNT_WIN8), 0)
177 #define IsWindows8Point1OrGreater()                                   \
178     _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WINBLUE), \
179                                         LOBYTE(_WIN32_WINNT_WINBLUE), 0)
180 
181 // Windows 10 Anniversary Update
182 #define _glfwIsWindows10Version1607OrGreaterWin32() \
183     _glfwIsWindows10BuildOrGreaterWin32(14393)
184 // Windows 10 Creators Update
185 #define _glfwIsWindows10Version1703OrGreaterWin32() \
186     _glfwIsWindows10BuildOrGreaterWin32(15063)
187 
188 // HACK: Define macros that some xinput.h variants don't
189 #ifndef XINPUT_CAPS_WIRELESS
190  #define XINPUT_CAPS_WIRELESS 0x0002
191 #endif
192 #ifndef XINPUT_DEVSUBTYPE_WHEEL
193  #define XINPUT_DEVSUBTYPE_WHEEL 0x02
194 #endif
195 #ifndef XINPUT_DEVSUBTYPE_ARCADE_STICK
196  #define XINPUT_DEVSUBTYPE_ARCADE_STICK 0x03
197 #endif
198 #ifndef XINPUT_DEVSUBTYPE_FLIGHT_STICK
199  #define XINPUT_DEVSUBTYPE_FLIGHT_STICK 0x04
200 #endif
201 #ifndef XINPUT_DEVSUBTYPE_DANCE_PAD
202  #define XINPUT_DEVSUBTYPE_DANCE_PAD 0x05
203 #endif
204 #ifndef XINPUT_DEVSUBTYPE_GUITAR
205  #define XINPUT_DEVSUBTYPE_GUITAR 0x06
206 #endif
207 #ifndef XINPUT_DEVSUBTYPE_DRUM_KIT
208  #define XINPUT_DEVSUBTYPE_DRUM_KIT 0x08
209 #endif
210 #ifndef XINPUT_DEVSUBTYPE_ARCADE_PAD
211  #define XINPUT_DEVSUBTYPE_ARCADE_PAD 0x13
212 #endif
213 #ifndef XUSER_MAX_COUNT
214  #define XUSER_MAX_COUNT 4
215 #endif
216 
217 // HACK: Define macros that some dinput.h variants don't
218 #ifndef DIDFT_OPTIONAL
219  #define DIDFT_OPTIONAL 0x80000000
220 #endif
221 
222 #define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
223 #define WGL_SUPPORT_OPENGL_ARB 0x2010
224 #define WGL_DRAW_TO_WINDOW_ARB 0x2001
225 #define WGL_PIXEL_TYPE_ARB 0x2013
226 #define WGL_TYPE_RGBA_ARB 0x202b
227 #define WGL_ACCELERATION_ARB 0x2003
228 #define WGL_NO_ACCELERATION_ARB 0x2025
229 #define WGL_RED_BITS_ARB 0x2015
230 #define WGL_RED_SHIFT_ARB 0x2016
231 #define WGL_GREEN_BITS_ARB 0x2017
232 #define WGL_GREEN_SHIFT_ARB 0x2018
233 #define WGL_BLUE_BITS_ARB 0x2019
234 #define WGL_BLUE_SHIFT_ARB 0x201a
235 #define WGL_ALPHA_BITS_ARB 0x201b
236 #define WGL_ALPHA_SHIFT_ARB 0x201c
237 #define WGL_ACCUM_BITS_ARB 0x201d
238 #define WGL_ACCUM_RED_BITS_ARB 0x201e
239 #define WGL_ACCUM_GREEN_BITS_ARB 0x201f
240 #define WGL_ACCUM_BLUE_BITS_ARB 0x2020
241 #define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
242 #define WGL_DEPTH_BITS_ARB 0x2022
243 #define WGL_STENCIL_BITS_ARB 0x2023
244 #define WGL_AUX_BUFFERS_ARB 0x2024
245 #define WGL_STEREO_ARB 0x2012
246 #define WGL_DOUBLE_BUFFER_ARB 0x2011
247 #define WGL_SAMPLES_ARB 0x2042
248 #define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20a9
249 #define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
250 #define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
251 #define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
252 #define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
253 #define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
254 #define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
255 #define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
256 #define WGL_CONTEXT_FLAGS_ARB 0x2094
257 #define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
258 #define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
259 #define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
260 #define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
261 #define WGL_NO_RESET_NOTIFICATION_ARB 0x8261
262 #define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
263 #define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
264 #define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
265 #define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31b3
266 #define WGL_COLORSPACE_EXT 0x309d
267 #define WGL_COLORSPACE_SRGB_EXT 0x3089
268 
269 #define ERROR_INVALID_VERSION_ARB 0x2095
270 #define ERROR_INVALID_PROFILE_ARB 0x2096
271 #define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
272 
273 // xinput.dll function pointer typedefs
274 typedef DWORD (WINAPI * PFN_XInputGetCapabilities)(DWORD,DWORD,XINPUT_CAPABILITIES*);
275 typedef DWORD (WINAPI * PFN_XInputGetState)(DWORD,XINPUT_STATE*);
276 #define XInputGetCapabilities _glfw.win32.xinput.GetCapabilities
277 #define XInputGetState _glfw.win32.xinput.GetState
278 
279 // dinput8.dll function pointer typedefs
280 typedef HRESULT (WINAPI * PFN_DirectInput8Create)(HINSTANCE,DWORD,REFIID,LPVOID*,LPUNKNOWN);
281 #define DirectInput8Create _glfw.win32.dinput8.Create
282 
283 // user32.dll function pointer typedefs
284 typedef BOOL (WINAPI * PFN_SetProcessDPIAware)(void);
285 typedef BOOL (WINAPI * PFN_ChangeWindowMessageFilterEx)(HWND,UINT,DWORD,CHANGEFILTERSTRUCT*);
286 typedef BOOL (WINAPI * PFN_EnableNonClientDpiScaling)(HWND);
287 typedef BOOL (WINAPI * PFN_SetProcessDpiAwarenessContext)(HANDLE);
288 typedef UINT (WINAPI * PFN_GetDpiForWindow)(HWND);
289 typedef BOOL (WINAPI * PFN_AdjustWindowRectExForDpi)(LPRECT,DWORD,BOOL,DWORD,UINT);
290 typedef int (WINAPI * PFN_GetSystemMetricsForDpi)(int,UINT);
291 #define SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware_
292 #define ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx_
293 #define EnableNonClientDpiScaling _glfw.win32.user32.EnableNonClientDpiScaling_
294 #define SetProcessDpiAwarenessContext _glfw.win32.user32.SetProcessDpiAwarenessContext_
295 #define GetDpiForWindow _glfw.win32.user32.GetDpiForWindow_
296 #define AdjustWindowRectExForDpi _glfw.win32.user32.AdjustWindowRectExForDpi_
297 #define GetSystemMetricsForDpi _glfw.win32.user32.GetSystemMetricsForDpi_
298 
299 // dwmapi.dll function pointer typedefs
300 typedef HRESULT (WINAPI * PFN_DwmIsCompositionEnabled)(BOOL*);
301 typedef HRESULT (WINAPI * PFN_DwmFlush)(VOID);
302 typedef HRESULT(WINAPI * PFN_DwmEnableBlurBehindWindow)(HWND,const DWM_BLURBEHIND*);
303 typedef HRESULT (WINAPI * PFN_DwmGetColorizationColor)(DWORD*,BOOL*);
304 #define DwmIsCompositionEnabled _glfw.win32.dwmapi.IsCompositionEnabled
305 #define DwmFlush _glfw.win32.dwmapi.Flush
306 #define DwmEnableBlurBehindWindow _glfw.win32.dwmapi.EnableBlurBehindWindow
307 #define DwmGetColorizationColor _glfw.win32.dwmapi.GetColorizationColor
308 
309 // shcore.dll function pointer typedefs
310 typedef HRESULT (WINAPI * PFN_SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS);
311 typedef HRESULT (WINAPI * PFN_GetDpiForMonitor)(HMONITOR,MONITOR_DPI_TYPE,UINT*,UINT*);
312 #define SetProcessDpiAwareness _glfw.win32.shcore.SetProcessDpiAwareness_
313 #define GetDpiForMonitor _glfw.win32.shcore.GetDpiForMonitor_
314 
315 // ntdll.dll function pointer typedefs
316 typedef LONG (WINAPI * PFN_RtlVerifyVersionInfo)(OSVERSIONINFOEXW*,ULONG,ULONGLONG);
317 #define RtlVerifyVersionInfo _glfw.win32.ntdll.RtlVerifyVersionInfo_
318 
319 // WGL extension pointer typedefs
320 typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC)(int);
321 typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC,int,int,UINT,const int*,int*);
322 typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void);
323 typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC);
324 typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC,HGLRC,const int*);
325 #define wglSwapIntervalEXT _glfw.wgl.SwapIntervalEXT
326 #define wglGetPixelFormatAttribivARB _glfw.wgl.GetPixelFormatAttribivARB
327 #define wglGetExtensionsStringEXT _glfw.wgl.GetExtensionsStringEXT
328 #define wglGetExtensionsStringARB _glfw.wgl.GetExtensionsStringARB
329 #define wglCreateContextAttribsARB _glfw.wgl.CreateContextAttribsARB
330 
331 // opengl32.dll function pointer typedefs
332 typedef HGLRC (WINAPI * PFN_wglCreateContext)(HDC);
333 typedef BOOL (WINAPI * PFN_wglDeleteContext)(HGLRC);
334 typedef PROC (WINAPI * PFN_wglGetProcAddress)(LPCSTR);
335 typedef HDC (WINAPI * PFN_wglGetCurrentDC)(void);
336 typedef HGLRC (WINAPI * PFN_wglGetCurrentContext)(void);
337 typedef BOOL (WINAPI * PFN_wglMakeCurrent)(HDC,HGLRC);
338 typedef BOOL (WINAPI * PFN_wglShareLists)(HGLRC,HGLRC);
339 #define wglCreateContext _glfw.wgl.CreateContext
340 #define wglDeleteContext _glfw.wgl.DeleteContext
341 #define wglGetProcAddress _glfw.wgl.GetProcAddress
342 #define wglGetCurrentDC _glfw.wgl.GetCurrentDC
343 #define wglGetCurrentContext _glfw.wgl.GetCurrentContext
344 #define wglMakeCurrent _glfw.wgl.MakeCurrent
345 #define wglShareLists _glfw.wgl.ShareLists
346 
347 typedef VkFlags VkWin32SurfaceCreateFlagsKHR;
348 
349 typedef struct VkWin32SurfaceCreateInfoKHR
350 {
351     VkStructureType                 sType;
352     const void*                     pNext;
353     VkWin32SurfaceCreateFlagsKHR    flags;
354     HINSTANCE                       hinstance;
355     HWND                            hwnd;
356 } VkWin32SurfaceCreateInfoKHR;
357 
358 typedef VkResult (APIENTRY *PFN_vkCreateWin32SurfaceKHR)(VkInstance,const VkWin32SurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
359 typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice,uint32_t);
360 
361 #define GLFW_WIN32_WINDOW_STATE         _GLFWwindowWin32  win32;
362 #define GLFW_WIN32_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32;
363 #define GLFW_WIN32_MONITOR_STATE        _GLFWmonitorWin32 win32;
364 #define GLFW_WIN32_CURSOR_STATE         _GLFWcursorWin32  win32;
365 
366 #define GLFW_WGL_CONTEXT_STATE          _GLFWcontextWGL wgl;
367 #define GLFW_WGL_LIBRARY_CONTEXT_STATE  _GLFWlibraryWGL wgl;
368 
369 
370 // WGL-specific per-context data
371 //
372 typedef struct _GLFWcontextWGL
373 {
374     HDC       dc;
375     HGLRC     handle;
376     int       interval;
377 } _GLFWcontextWGL;
378 
379 // WGL-specific global data
380 //
381 typedef struct _GLFWlibraryWGL
382 {
383     HINSTANCE                           instance;
384     PFN_wglCreateContext                CreateContext;
385     PFN_wglDeleteContext                DeleteContext;
386     PFN_wglGetProcAddress               GetProcAddress;
387     PFN_wglGetCurrentDC                 GetCurrentDC;
388     PFN_wglGetCurrentContext            GetCurrentContext;
389     PFN_wglMakeCurrent                  MakeCurrent;
390     PFN_wglShareLists                   ShareLists;
391 
392     PFNWGLSWAPINTERVALEXTPROC           SwapIntervalEXT;
393     PFNWGLGETPIXELFORMATATTRIBIVARBPROC GetPixelFormatAttribivARB;
394     PFNWGLGETEXTENSIONSSTRINGEXTPROC    GetExtensionsStringEXT;
395     PFNWGLGETEXTENSIONSSTRINGARBPROC    GetExtensionsStringARB;
396     PFNWGLCREATECONTEXTATTRIBSARBPROC   CreateContextAttribsARB;
397     GLFWbool                            EXT_swap_control;
398     GLFWbool                            EXT_colorspace;
399     GLFWbool                            ARB_multisample;
400     GLFWbool                            ARB_framebuffer_sRGB;
401     GLFWbool                            EXT_framebuffer_sRGB;
402     GLFWbool                            ARB_pixel_format;
403     GLFWbool                            ARB_create_context;
404     GLFWbool                            ARB_create_context_profile;
405     GLFWbool                            EXT_create_context_es2_profile;
406     GLFWbool                            ARB_create_context_robustness;
407     GLFWbool                            ARB_create_context_no_error;
408     GLFWbool                            ARB_context_flush_control;
409 } _GLFWlibraryWGL;
410 
411 // Win32-specific per-window data
412 //
413 typedef struct _GLFWwindowWin32
414 {
415     HWND                handle;
416     HICON               bigIcon;
417     HICON               smallIcon;
418 
419     GLFWbool            cursorTracked;
420     GLFWbool            frameAction;
421     GLFWbool            iconified;
422     GLFWbool            maximized;
423     // Whether to enable framebuffer transparency on DWM
424     GLFWbool            transparent;
425     GLFWbool            scaleToMonitor;
426     GLFWbool            keymenu;
427     GLFWbool            showDefault;
428 
429     // Cached size used to filter out duplicate events
430     int                 width, height;
431 
432     // The last received cursor position, regardless of source
433     int                 lastCursorPosX, lastCursorPosY;
434     // The last received high surrogate when decoding pairs of UTF-16 messages
435     WCHAR               highSurrogate;
436 } _GLFWwindowWin32;
437 
438 // Win32-specific global data
439 //
440 typedef struct _GLFWlibraryWin32
441 {
442     HINSTANCE           instance;
443     HWND                helperWindowHandle;
444     ATOM                helperWindowClass;
445     ATOM                mainWindowClass;
446     HDEVNOTIFY          deviceNotificationHandle;
447     int                 acquiredMonitorCount;
448     char*               clipboardString;
449     short int           keycodes[512];
450     short int           scancodes[GLFW_KEY_LAST + 1];
451     char                keynames[GLFW_KEY_LAST + 1][5];
452     // Where to place the cursor when re-enabled
453     double              restoreCursorPosX, restoreCursorPosY;
454     // The window whose disabled cursor mode is active
455     _GLFWwindow*        disabledCursorWindow;
456     // The window the cursor is captured in
457     _GLFWwindow*        capturedCursorWindow;
458     RAWINPUT*           rawInput;
459     int                 rawInputSize;
460     UINT                mouseTrailSize;
461     // The cursor handle to use to hide the cursor (NULL or a transparent cursor)
462     HCURSOR             blankCursor;
463 
464     struct {
465         HINSTANCE                       instance;
466         PFN_DirectInput8Create          Create;
467         IDirectInput8W*                 api;
468     } dinput8;
469 
470     struct {
471         HINSTANCE                       instance;
472         PFN_XInputGetCapabilities       GetCapabilities;
473         PFN_XInputGetState              GetState;
474     } xinput;
475 
476     struct {
477         HINSTANCE                       instance;
478         PFN_SetProcessDPIAware          SetProcessDPIAware_;
479         PFN_ChangeWindowMessageFilterEx ChangeWindowMessageFilterEx_;
480         PFN_EnableNonClientDpiScaling   EnableNonClientDpiScaling_;
481         PFN_SetProcessDpiAwarenessContext SetProcessDpiAwarenessContext_;
482         PFN_GetDpiForWindow             GetDpiForWindow_;
483         PFN_AdjustWindowRectExForDpi    AdjustWindowRectExForDpi_;
484         PFN_GetSystemMetricsForDpi      GetSystemMetricsForDpi_;
485     } user32;
486 
487     struct {
488         HINSTANCE                       instance;
489         PFN_DwmIsCompositionEnabled     IsCompositionEnabled;
490         PFN_DwmFlush                    Flush;
491         PFN_DwmEnableBlurBehindWindow   EnableBlurBehindWindow;
492         PFN_DwmGetColorizationColor     GetColorizationColor;
493     } dwmapi;
494 
495     struct {
496         HINSTANCE                       instance;
497         PFN_SetProcessDpiAwareness      SetProcessDpiAwareness_;
498         PFN_GetDpiForMonitor            GetDpiForMonitor_;
499     } shcore;
500 
501     struct {
502         HINSTANCE                       instance;
503         PFN_RtlVerifyVersionInfo        RtlVerifyVersionInfo_;
504     } ntdll;
505 } _GLFWlibraryWin32;
506 
507 // Win32-specific per-monitor data
508 //
509 typedef struct _GLFWmonitorWin32
510 {
511     HMONITOR            handle;
512     // This size matches the static size of DISPLAY_DEVICE.DeviceName
513     WCHAR               adapterName[32];
514     WCHAR               displayName[32];
515     char                publicAdapterName[32];
516     char                publicDisplayName[32];
517     GLFWbool            modesPruned;
518     GLFWbool            modeChanged;
519 } _GLFWmonitorWin32;
520 
521 // Win32-specific per-cursor data
522 //
523 typedef struct _GLFWcursorWin32
524 {
525     HCURSOR             handle;
526 } _GLFWcursorWin32;
527 
528 
529 GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform);
530 int _glfwInitWin32(void);
531 void _glfwTerminateWin32(void);
532 
533 WCHAR* _glfwCreateWideStringFromUTF8Win32(const char* source);
534 char* _glfwCreateUTF8FromWideStringWin32(const WCHAR* source);
535 BOOL _glfwIsWindowsVersionOrGreaterWin32(WORD major, WORD minor, WORD sp);
536 BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build);
537 void _glfwInputErrorWin32(int error, const char* description);
538 void _glfwUpdateKeyNamesWin32(void);
539 
540 void _glfwPollMonitorsWin32(void);
541 void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired);
542 void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor);
543 void _glfwGetHMONITORContentScaleWin32(HMONITOR handle, float* xscale, float* yscale);
544 
545 GLFWbool _glfwCreateWindowWin32(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
546 void _glfwDestroyWindowWin32(_GLFWwindow* window);
547 void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title);
548 void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* images);
549 void _glfwGetWindowPosWin32(_GLFWwindow* window, int* xpos, int* ypos);
550 void _glfwSetWindowPosWin32(_GLFWwindow* window, int xpos, int ypos);
551 void _glfwGetWindowSizeWin32(_GLFWwindow* window, int* width, int* height);
552 void _glfwSetWindowSizeWin32(_GLFWwindow* window, int width, int height);
553 void _glfwSetWindowSizeLimitsWin32(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
554 void _glfwSetWindowAspectRatioWin32(_GLFWwindow* window, int numer, int denom);
555 void _glfwGetFramebufferSizeWin32(_GLFWwindow* window, int* width, int* height);
556 void _glfwGetWindowFrameSizeWin32(_GLFWwindow* window, int* left, int* top, int* right, int* bottom);
557 void _glfwGetWindowContentScaleWin32(_GLFWwindow* window, float* xscale, float* yscale);
558 void _glfwIconifyWindowWin32(_GLFWwindow* window);
559 void _glfwRestoreWindowWin32(_GLFWwindow* window);
560 void _glfwMaximizeWindowWin32(_GLFWwindow* window);
561 void _glfwShowWindowWin32(_GLFWwindow* window);
562 void _glfwHideWindowWin32(_GLFWwindow* window);
563 void _glfwRequestWindowAttentionWin32(_GLFWwindow* window);
564 void _glfwFocusWindowWin32(_GLFWwindow* window);
565 void _glfwSetWindowMonitorWin32(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
566 GLFWbool _glfwWindowFocusedWin32(_GLFWwindow* window);
567 GLFWbool _glfwWindowIconifiedWin32(_GLFWwindow* window);
568 GLFWbool _glfwWindowVisibleWin32(_GLFWwindow* window);
569 GLFWbool _glfwWindowMaximizedWin32(_GLFWwindow* window);
570 GLFWbool _glfwWindowHoveredWin32(_GLFWwindow* window);
571 GLFWbool _glfwFramebufferTransparentWin32(_GLFWwindow* window);
572 void _glfwSetWindowResizableWin32(_GLFWwindow* window, GLFWbool enabled);
573 void _glfwSetWindowDecoratedWin32(_GLFWwindow* window, GLFWbool enabled);
574 void _glfwSetWindowFloatingWin32(_GLFWwindow* window, GLFWbool enabled);
575 void _glfwSetWindowMousePassthroughWin32(_GLFWwindow* window, GLFWbool enabled);
576 float _glfwGetWindowOpacityWin32(_GLFWwindow* window);
577 void _glfwSetWindowOpacityWin32(_GLFWwindow* window, float opacity);
578 
579 void _glfwSetRawMouseMotionWin32(_GLFWwindow *window, GLFWbool enabled);
580 GLFWbool _glfwRawMouseMotionSupportedWin32(void);
581 
582 void _glfwPollEventsWin32(void);
583 void _glfwWaitEventsWin32(void);
584 void _glfwWaitEventsTimeoutWin32(double timeout);
585 void _glfwPostEmptyEventWin32(void);
586 
587 void _glfwGetCursorPosWin32(_GLFWwindow* window, double* xpos, double* ypos);
588 void _glfwSetCursorPosWin32(_GLFWwindow* window, double xpos, double ypos);
589 void _glfwSetCursorModeWin32(_GLFWwindow* window, int mode);
590 const char* _glfwGetScancodeNameWin32(int scancode);
591 int _glfwGetKeyScancodeWin32(int key);
592 GLFWbool _glfwCreateCursorWin32(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
593 GLFWbool _glfwCreateStandardCursorWin32(_GLFWcursor* cursor, int shape);
594 void _glfwDestroyCursorWin32(_GLFWcursor* cursor);
595 void _glfwSetCursorWin32(_GLFWwindow* window, _GLFWcursor* cursor);
596 void _glfwSetClipboardStringWin32(const char* string);
597 const char* _glfwGetClipboardStringWin32(void);
598 
599 EGLenum _glfwGetEGLPlatformWin32(EGLint** attribs);
600 EGLNativeDisplayType _glfwGetEGLNativeDisplayWin32(void);
601 EGLNativeWindowType _glfwGetEGLNativeWindowWin32(_GLFWwindow* window);
602 
603 void _glfwGetRequiredInstanceExtensionsWin32(char** extensions);
604 GLFWbool _glfwGetPhysicalDevicePresentationSupportWin32(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
605 VkResult _glfwCreateWindowSurfaceWin32(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
606 
607 void _glfwFreeMonitorWin32(_GLFWmonitor* monitor);
608 void _glfwGetMonitorPosWin32(_GLFWmonitor* monitor, int* xpos, int* ypos);
609 void _glfwGetMonitorContentScaleWin32(_GLFWmonitor* monitor, float* xscale, float* yscale);
610 void _glfwGetMonitorWorkareaWin32(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
611 GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count);
612 GLFWbool _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode);
613 GLFWbool _glfwGetGammaRampWin32(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
614 void _glfwSetGammaRampWin32(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
615 
616 GLFWbool _glfwInitJoysticksWin32(void);
617 void _glfwTerminateJoysticksWin32(void);
618 GLFWbool _glfwPollJoystickWin32(_GLFWjoystick* js, int mode);
619 const char* _glfwGetMappingNameWin32(void);
620 void _glfwUpdateGamepadGUIDWin32(char* guid);
621 
622 GLFWbool _glfwInitWGL(void);
623 void _glfwTerminateWGL(void);
624 GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
625                                const _GLFWctxconfig* ctxconfig,
626                                const _GLFWfbconfig* fbconfig);
627 
628