win32_window.c
Go to the documentation of this file.
1 //========================================================================
2 // GLFW 3.1 Win32 - www.glfw.org
3 //------------------------------------------------------------------------
4 // Copyright (c) 2002-2006 Marcus Geelnard
5 // Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.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 #include "internal.h"
29 
30 #include <stdlib.h>
31 #include <malloc.h>
32 #include <string.h>
33 #include <windowsx.h>
34 #include <shellapi.h>
35 
36 #define _GLFW_KEY_INVALID -2
37 
38 #define _GLFW_WNDCLASSNAME L"GLFW30"
39 
40 
41 // Returns the window style for the specified window
42 //
43 static DWORD getWindowStyle(const _GLFWwindow* window)
44 {
45  DWORD style = WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
46 
47  if (window->decorated && !window->monitor)
48  {
49  style |= WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
50 
51  if (window->resizable)
52  style |= WS_MAXIMIZEBOX | WS_SIZEBOX;
53  }
54  else
55  style |= WS_POPUP;
56 
57  return style;
58 }
59 
60 // Returns the extended window style for the specified window
61 //
62 static DWORD getWindowExStyle(const _GLFWwindow* window)
63 {
64  DWORD style = WS_EX_APPWINDOW;
65 
66  if (window->decorated && !window->monitor)
67  style |= WS_EX_WINDOWEDGE;
68 
69  return style;
70 }
71 
72 // Updates the cursor clip rect
73 //
74 static void updateClipRect(_GLFWwindow* window)
75 {
76  RECT clipRect;
77  GetClientRect(window->win32.handle, &clipRect);
78  ClientToScreen(window->win32.handle, (POINT*) &clipRect.left);
79  ClientToScreen(window->win32.handle, (POINT*) &clipRect.right);
80  ClipCursor(&clipRect);
81 }
82 
83 // Hide the mouse cursor
84 //
85 static void hideCursor(_GLFWwindow* window)
86 {
87  POINT pos;
88 
89  ClipCursor(NULL);
90 
91  if (GetCursorPos(&pos))
92  {
93  if (WindowFromPoint(pos) == window->win32.handle)
94  SetCursor(NULL);
95  }
96 }
97 
98 // Disable the mouse cursor
99 //
100 static void disableCursor(_GLFWwindow* window)
101 {
102  POINT pos;
103 
104  updateClipRect(window);
105 
106  if (GetCursorPos(&pos))
107  {
108  if (WindowFromPoint(pos) == window->win32.handle)
109  SetCursor(NULL);
110  }
111 }
112 
113 // Restores the mouse cursor
114 //
115 static void restoreCursor(_GLFWwindow* window)
116 {
117  POINT pos;
118 
119  ClipCursor(NULL);
120 
121  if (GetCursorPos(&pos))
122  {
123  if (WindowFromPoint(pos) == window->win32.handle)
124  {
125  if (window->cursor)
126  SetCursor(window->cursor->win32.handle);
127  else
128  SetCursor(LoadCursorW(NULL, IDC_ARROW));
129  }
130  }
131 }
132 
133 // Translates a GLFW standard cursor to a resource ID
134 //
135 static LPWSTR translateCursorShape(int shape)
136 {
137  switch (shape)
138  {
139  case GLFW_ARROW_CURSOR:
140  return IDC_ARROW;
141  case GLFW_IBEAM_CURSOR:
142  return IDC_IBEAM;
144  return IDC_CROSS;
145  case GLFW_HAND_CURSOR:
146  return IDC_HAND;
147  case GLFW_HRESIZE_CURSOR:
148  return IDC_SIZEWE;
149  case GLFW_VRESIZE_CURSOR:
150  return IDC_SIZENS;
151  }
152 
153  return NULL;
154 }
155 
156 // Retrieves and translates modifier keys
157 //
158 static int getKeyMods(void)
159 {
160  int mods = 0;
161 
162  if (GetKeyState(VK_SHIFT) & (1 << 31))
163  mods |= GLFW_MOD_SHIFT;
164  if (GetKeyState(VK_CONTROL) & (1 << 31))
165  mods |= GLFW_MOD_CONTROL;
166  if (GetKeyState(VK_MENU) & (1 << 31))
167  mods |= GLFW_MOD_ALT;
168  if ((GetKeyState(VK_LWIN) | GetKeyState(VK_RWIN)) & (1 << 31))
169  mods |= GLFW_MOD_SUPER;
170 
171  return mods;
172 }
173 
174 // Retrieves and translates modifier keys
175 //
176 static int getAsyncKeyMods(void)
177 {
178  int mods = 0;
179 
180  if (GetAsyncKeyState(VK_SHIFT) & (1 << 31))
181  mods |= GLFW_MOD_SHIFT;
182  if (GetAsyncKeyState(VK_CONTROL) & (1 << 31))
183  mods |= GLFW_MOD_CONTROL;
184  if (GetAsyncKeyState(VK_MENU) & (1 << 31))
185  mods |= GLFW_MOD_ALT;
186  if ((GetAsyncKeyState(VK_LWIN) | GetAsyncKeyState(VK_RWIN)) & (1 << 31))
187  mods |= GLFW_MOD_SUPER;
188 
189  return mods;
190 }
191 
192 // Translates a Windows key to the corresponding GLFW key
193 //
194 static int translateKey(WPARAM wParam, LPARAM lParam)
195 {
196  if (wParam == VK_CONTROL)
197  {
198  // The CTRL keys require special handling
199 
200  MSG next;
201  DWORD time;
202 
203  // Is this an extended key (i.e. right key)?
204  if (lParam & 0x01000000)
205  return GLFW_KEY_RIGHT_CONTROL;
206 
207  // Here is a trick: "Alt Gr" sends LCTRL, then RALT. We only
208  // want the RALT message, so we try to see if the next message
209  // is a RALT message. In that case, this is a false LCTRL!
210  time = GetMessageTime();
211 
212  if (PeekMessageW(&next, NULL, 0, 0, PM_NOREMOVE))
213  {
214  if (next.message == WM_KEYDOWN ||
215  next.message == WM_SYSKEYDOWN ||
216  next.message == WM_KEYUP ||
217  next.message == WM_SYSKEYUP)
218  {
219  if (next.wParam == VK_MENU &&
220  (next.lParam & 0x01000000) &&
221  next.time == time)
222  {
223  // Next message is a RALT down message, which
224  // means that this is not a proper LCTRL message
225  return _GLFW_KEY_INVALID;
226  }
227  }
228  }
229 
230  return GLFW_KEY_LEFT_CONTROL;
231  }
232 
233  return _glfw.win32.publicKeys[HIWORD(lParam) & 0x1FF];
234 }
235 
236 // Enter full screen mode
237 //
239 {
241  GLboolean status;
242  int xpos, ypos;
243 
244  status = _glfwSetVideoMode(window->monitor, &window->videoMode);
245 
246  _glfwPlatformGetVideoMode(window->monitor, &mode);
247  _glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);
248 
249  SetWindowPos(window->win32.handle, HWND_TOPMOST,
250  xpos, ypos, mode.width, mode.height, SWP_NOCOPYBITS);
251 
252  return status;
253 }
254 
255 // Leave full screen mode
256 //
257 static void leaveFullscreenMode(_GLFWwindow* window)
258 {
260 }
261 
262 // Window callback function (handles window events)
263 //
264 static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
265  WPARAM wParam, LPARAM lParam)
266 {
267  _GLFWwindow* window = (_GLFWwindow*) GetWindowLongPtrW(hWnd, 0);
268 
269  switch (uMsg)
270  {
271  case WM_NCCREATE:
272  {
273  CREATESTRUCTW* cs = (CREATESTRUCTW*) lParam;
274  SetWindowLongPtrW(hWnd, 0, (LONG_PTR) cs->lpCreateParams);
275  break;
276  }
277 
278  case WM_SETFOCUS:
279  {
280  if (window->cursorMode != GLFW_CURSOR_NORMAL)
282 
283  _glfwInputWindowFocus(window, GL_TRUE);
284  return 0;
285  }
286 
287  case WM_KILLFOCUS:
288  {
289  if (window->cursorMode != GLFW_CURSOR_NORMAL)
290  restoreCursor(window);
291 
292  if (window->monitor && window->autoIconify)
294 
295  _glfwInputWindowFocus(window, GL_FALSE);
296  return 0;
297  }
298 
299  case WM_SYSCOMMAND:
300  {
301  switch (wParam & 0xfff0)
302  {
303  case SC_SCREENSAVE:
304  case SC_MONITORPOWER:
305  {
306  if (window->monitor)
307  {
308  // We are running in full screen mode, so disallow
309  // screen saver and screen blanking
310  return 0;
311  }
312  else
313  break;
314  }
315 
316  // User trying to access application menu using ALT?
317  case SC_KEYMENU:
318  return 0;
319  }
320  break;
321  }
322 
323  case WM_CLOSE:
324  {
326  return 0;
327  }
328 
329  case WM_KEYDOWN:
330  case WM_SYSKEYDOWN:
331  {
332  const int scancode = (lParam >> 16) & 0x1ff;
333  const int key = translateKey(wParam, lParam);
334  if (key == _GLFW_KEY_INVALID)
335  break;
336 
337  _glfwInputKey(window, key, scancode, GLFW_PRESS, getKeyMods());
338  break;
339  }
340 
341  case WM_CHAR:
342  {
343  _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), GL_TRUE);
344  return 0;
345  }
346 
347  case WM_SYSCHAR:
348  {
349  _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), GL_FALSE);
350  return 0;
351  }
352 
353  case WM_UNICHAR:
354  {
355  // This message is not sent by Windows, but is sent by some
356  // third-party input method engines
357 
358  if (wParam == UNICODE_NOCHAR)
359  {
360  // Returning TRUE here announces support for this message
361  return TRUE;
362  }
363 
364  _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), GL_TRUE);
365  return FALSE;
366  }
367 
368  case WM_KEYUP:
369  case WM_SYSKEYUP:
370  {
371  const int mods = getKeyMods();
372  const int scancode = (lParam >> 16) & 0x1ff;
373  const int key = translateKey(wParam, lParam);
374  if (key == _GLFW_KEY_INVALID)
375  break;
376 
377  if (wParam == VK_SHIFT)
378  {
379  // Release both Shift keys on Shift up event, as only one event
380  // is sent even if both keys are released
381  _glfwInputKey(window, GLFW_KEY_LEFT_SHIFT, scancode, GLFW_RELEASE, mods);
382  _glfwInputKey(window, GLFW_KEY_RIGHT_SHIFT, scancode, GLFW_RELEASE, mods);
383  }
384  else if (wParam == VK_SNAPSHOT)
385  {
386  // Key down is not reported for the print screen key
387  _glfwInputKey(window, key, scancode, GLFW_PRESS, mods);
388  _glfwInputKey(window, key, scancode, GLFW_RELEASE, mods);
389  }
390  else
391  _glfwInputKey(window, key, scancode, GLFW_RELEASE, mods);
392 
393  break;
394  }
395 
396  case WM_LBUTTONDOWN:
397  case WM_RBUTTONDOWN:
398  case WM_MBUTTONDOWN:
399  case WM_XBUTTONDOWN:
400  {
401  const int mods = getKeyMods();
402 
403  SetCapture(hWnd);
404 
405  if (uMsg == WM_LBUTTONDOWN)
407  else if (uMsg == WM_RBUTTONDOWN)
409  else if (uMsg == WM_MBUTTONDOWN)
411  else
412  {
413  if (HIWORD(wParam) == XBUTTON1)
415  else if (HIWORD(wParam) == XBUTTON2)
417 
418  return TRUE;
419  }
420 
421  return 0;
422  }
423 
424  case WM_LBUTTONUP:
425  case WM_RBUTTONUP:
426  case WM_MBUTTONUP:
427  case WM_XBUTTONUP:
428  {
429  const int mods = getKeyMods();
430 
431  ReleaseCapture();
432 
433  if (uMsg == WM_LBUTTONUP)
435  else if (uMsg == WM_RBUTTONUP)
437  else if (uMsg == WM_MBUTTONUP)
439  else
440  {
441  if (HIWORD(wParam) == XBUTTON1)
443  else if (HIWORD(wParam) == XBUTTON2)
445 
446  return TRUE;
447  }
448 
449  return 0;
450  }
451 
452  case WM_MOUSEMOVE:
453  {
454  const int x = GET_X_LPARAM(lParam);
455  const int y = GET_Y_LPARAM(lParam);
456 
457  if (window->cursorMode == GLFW_CURSOR_DISABLED)
458  {
459  if (_glfw.cursorWindow != window)
460  break;
461 
462  _glfwInputCursorMotion(window,
463  x - window->win32.cursorPosX,
464  y - window->win32.cursorPosY);
465  }
466  else
467  _glfwInputCursorMotion(window, x, y);
468 
469  window->win32.cursorPosX = x;
470  window->win32.cursorPosY = y;
471 
472  if (!window->win32.cursorTracked)
473  {
474  TRACKMOUSEEVENT tme;
475  ZeroMemory(&tme, sizeof(tme));
476  tme.cbSize = sizeof(tme);
477  tme.dwFlags = TME_LEAVE;
478  tme.hwndTrack = window->win32.handle;
479  TrackMouseEvent(&tme);
480 
481  window->win32.cursorTracked = GL_TRUE;
482  _glfwInputCursorEnter(window, GL_TRUE);
483  }
484 
485  return 0;
486  }
487 
488  case WM_MOUSELEAVE:
489  {
490  window->win32.cursorTracked = GL_FALSE;
491  _glfwInputCursorEnter(window, GL_FALSE);
492  return 0;
493  }
494 
495  case WM_MOUSEWHEEL:
496  {
497  _glfwInputScroll(window, 0.0, (SHORT) HIWORD(wParam) / (double) WHEEL_DELTA);
498  return 0;
499  }
500 
501  case WM_MOUSEHWHEEL:
502  {
503  // This message is only sent on Windows Vista and later
504  // NOTE: The X-axis is inverted for consistency with OS X and X11.
505  _glfwInputScroll(window, -((SHORT) HIWORD(wParam) / (double) WHEEL_DELTA), 0.0);
506  return 0;
507  }
508 
509  case WM_SIZE:
510  {
511  if (_glfw.cursorWindow == window)
512  {
513  if (window->cursorMode == GLFW_CURSOR_DISABLED)
514  updateClipRect(window);
515  }
516 
517  if (!window->win32.iconified && wParam == SIZE_MINIMIZED)
518  {
519  window->win32.iconified = GL_TRUE;
520  if (window->monitor)
521  leaveFullscreenMode(window);
522 
523  _glfwInputWindowIconify(window, GL_TRUE);
524  }
525  else if (window->win32.iconified &&
526  (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED))
527  {
528  window->win32.iconified = GL_FALSE;
529  if (window->monitor)
530  enterFullscreenMode(window);
531 
532  _glfwInputWindowIconify(window, GL_FALSE);
533  }
534 
535  _glfwInputFramebufferSize(window, LOWORD(lParam), HIWORD(lParam));
536  _glfwInputWindowSize(window, LOWORD(lParam), HIWORD(lParam));
537  return 0;
538  }
539 
540  case WM_MOVE:
541  {
542  if (_glfw.cursorWindow == window)
543  {
544  if (window->cursorMode == GLFW_CURSOR_DISABLED)
545  updateClipRect(window);
546  }
547 
548  // NOTE: This cannot use LOWORD/HIWORD recommended by MSDN, as
549  // those macros do not handle negative window positions correctly
550  _glfwInputWindowPos(window,
551  GET_X_LPARAM(lParam),
552  GET_Y_LPARAM(lParam));
553  return 0;
554  }
555 
556  case WM_PAINT:
557  {
558  _glfwInputWindowDamage(window);
559  break;
560  }
561 
562  case WM_ERASEBKGND:
563  {
564  return TRUE;
565  }
566 
567  case WM_SETCURSOR:
568  {
569  if (_glfw.cursorWindow == window && LOWORD(lParam) == HTCLIENT)
570  {
571  if (window->cursorMode == GLFW_CURSOR_HIDDEN ||
572  window->cursorMode == GLFW_CURSOR_DISABLED)
573  {
574  SetCursor(NULL);
575  return TRUE;
576  }
577  else if (window->cursor)
578  {
579  SetCursor(window->cursor->win32.handle);
580  return TRUE;
581  }
582  }
583 
584  break;
585  }
586 
587  case WM_DEVICECHANGE:
588  {
589  if (DBT_DEVNODES_CHANGED == wParam)
590  {
592  return TRUE;
593  }
594  break;
595  }
596 
597  case WM_DROPFILES:
598  {
599  HDROP drop = (HDROP) wParam;
600  POINT pt;
601  int i;
602 
603  const int count = DragQueryFileW(drop, 0xffffffff, NULL, 0);
604  char** paths = calloc(count, sizeof(char*));
605 
606  // Move the mouse to the position of the drop
607  DragQueryPoint(drop, &pt);
608  _glfwInputCursorMotion(window, pt.x, pt.y);
609 
610  for (i = 0; i < count; i++)
611  {
612  const UINT length = DragQueryFileW(drop, i, NULL, 0);
613  WCHAR* buffer = calloc(length + 1, sizeof(WCHAR));
614 
615  DragQueryFileW(drop, i, buffer, length + 1);
616  paths[i] = _glfwCreateUTF8FromWideString(buffer);
617 
618  free(buffer);
619  }
620 
621  _glfwInputDrop(window, count, (const char**) paths);
622 
623  for (i = 0; i < count; i++)
624  free(paths[i]);
625  free(paths);
626 
627  DragFinish(drop);
628  return 0;
629  }
630  }
631 
632  return DefWindowProc(hWnd, uMsg, wParam, lParam);
633 }
634 
635 // Translate client window size to full window size (including window borders)
636 //
637 static void getFullWindowSize(_GLFWwindow* window,
638  int clientWidth, int clientHeight,
639  int* fullWidth, int* fullHeight)
640 {
641  RECT rect = { 0, 0, clientWidth, clientHeight };
642  AdjustWindowRectEx(&rect, getWindowStyle(window),
643  FALSE, getWindowExStyle(window));
644  *fullWidth = rect.right - rect.left;
645  *fullHeight = rect.bottom - rect.top;
646 }
647 
648 // Creates the GLFW window and rendering context
649 //
650 static int createWindow(_GLFWwindow* window,
651  const _GLFWwndconfig* wndconfig,
652  const _GLFWctxconfig* ctxconfig,
653  const _GLFWfbconfig* fbconfig)
654 {
655  int xpos, ypos, fullWidth, fullHeight;
656  WCHAR* wideTitle;
657 
658  if (wndconfig->monitor)
659  {
661 
662  // NOTE: This window placement is temporary and approximate, as the
663  // correct position and size cannot be known until the monitor
664  // video mode has been set
665  _glfwPlatformGetMonitorPos(wndconfig->monitor, &xpos, &ypos);
666  _glfwPlatformGetVideoMode(wndconfig->monitor, &mode);
667  fullWidth = mode.width;
668  fullHeight = mode.height;
669  }
670  else
671  {
672  xpos = CW_USEDEFAULT;
673  ypos = CW_USEDEFAULT;
674 
675  getFullWindowSize(window,
676  wndconfig->width, wndconfig->height,
677  &fullWidth, &fullHeight);
678  }
679 
680  wideTitle = _glfwCreateWideStringFromUTF8(wndconfig->title);
681  if (!wideTitle)
682  {
684  "Win32: Failed to convert window title to UTF-16");
685  return GL_FALSE;
686  }
687 
688  window->win32.handle = CreateWindowExW(getWindowExStyle(window),
690  wideTitle,
691  getWindowStyle(window),
692  xpos, ypos,
693  fullWidth, fullHeight,
694  NULL, // No parent window
695  NULL, // No window menu
696  GetModuleHandleW(NULL),
697  window); // Pass object to WM_CREATE
698 
699  free(wideTitle);
700 
701  if (!window->win32.handle)
702  {
703  _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to create window");
704  return GL_FALSE;
705  }
706 
708  {
709  _glfw_ChangeWindowMessageFilterEx(window->win32.handle,
710  WM_DROPFILES, MSGFLT_ALLOW, NULL);
711  _glfw_ChangeWindowMessageFilterEx(window->win32.handle,
712  WM_COPYDATA, MSGFLT_ALLOW, NULL);
713  _glfw_ChangeWindowMessageFilterEx(window->win32.handle,
715  }
716 
717  if (wndconfig->floating && !wndconfig->monitor)
718  {
719  SetWindowPos(window->win32.handle,
720  HWND_TOPMOST,
721  0, 0, 0, 0,
722  SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
723  }
724 
725  DragAcceptFiles(window->win32.handle, TRUE);
726 
727  if (!_glfwCreateContext(window, ctxconfig, fbconfig))
728  return GL_FALSE;
729 
730  return GL_TRUE;
731 }
732 
733 // Destroys the GLFW window and rendering context
734 //
735 static void destroyWindow(_GLFWwindow* window)
736 {
737  _glfwDestroyContext(window);
738 
739  if (window->win32.handle)
740  {
741  DestroyWindow(window->win32.handle);
742  window->win32.handle = NULL;
743  }
744 }
745 
746 
750 
751 // Registers the GLFW window class
752 //
754 {
755  WNDCLASSW wc;
756 
757  wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
758  wc.lpfnWndProc = (WNDPROC) windowProc;
759  wc.cbClsExtra = 0; // No extra class data
760  wc.cbWndExtra = sizeof(void*) + sizeof(int); // Make room for one pointer
761  wc.hInstance = GetModuleHandleW(NULL);
762  wc.hCursor = LoadCursorW(NULL, IDC_ARROW);
763  wc.hbrBackground = NULL; // No background
764  wc.lpszMenuName = NULL; // No menu
765  wc.lpszClassName = _GLFW_WNDCLASSNAME;
766 
767  // Load user-provided icon if available
768  wc.hIcon = LoadIconW(GetModuleHandleW(NULL), L"GLFW_ICON");
769  if (!wc.hIcon)
770  {
771  // No user-provided icon found, load default icon
772  wc.hIcon = LoadIconW(NULL, IDI_WINLOGO);
773  }
774 
775  if (!RegisterClassW(&wc))
776  {
778  "Win32: Failed to register window class");
779  return GL_FALSE;
780  }
781 
782  return GL_TRUE;
783 }
784 
785 // Unregisters the GLFW window class
786 //
788 {
789  UnregisterClassW(_GLFW_WNDCLASSNAME, GetModuleHandleW(NULL));
790 }
791 
792 
796 
798  const _GLFWwndconfig* wndconfig,
799  const _GLFWctxconfig* ctxconfig,
800  const _GLFWfbconfig* fbconfig)
801 {
802  int status;
803 
804  if (!createWindow(window, wndconfig, ctxconfig, fbconfig))
805  return GL_FALSE;
806 
807  status = _glfwAnalyzeContext(window, ctxconfig, fbconfig);
808 
809  if (status == _GLFW_RECREATION_IMPOSSIBLE)
810  return GL_FALSE;
811 
812  if (status == _GLFW_RECREATION_REQUIRED)
813  {
814  // Some window hints require us to re-create the context using WGL
815  // extensions retrieved through the current context, as we cannot check
816  // for WGL extensions or retrieve WGL entry points before we have a
817  // current context (actually until we have implicitly loaded the ICD)
818 
819  // Yes, this is strange, and yes, this is the proper way on Win32
820 
821  // As Windows only allows you to set the pixel format once for a
822  // window, we need to destroy the current window and create a new one
823  // to be able to use the new pixel format
824 
825  // Technically, it may be possible to keep the old window around if
826  // we're just creating an OpenGL 3.0+ context with the same pixel
827  // format, but it's not worth the added code complexity
828 
829  // First we clear the current context (the one we just created)
830  // This is usually done by glfwDestroyWindow, but as we're not doing
831  // full GLFW window destruction, it's duplicated here
833 
834  // Next destroy the Win32 window and WGL context (without resetting or
835  // destroying the GLFW window object)
836  destroyWindow(window);
837 
838  // ...and then create them again, this time with better APIs
839  if (!createWindow(window, wndconfig, ctxconfig, fbconfig))
840  return GL_FALSE;
841  }
842 
843  if (window->monitor)
844  {
845  _glfwPlatformShowWindow(window);
846  if (!enterFullscreenMode(window))
847  return GL_FALSE;
848  }
849 
850  return GL_TRUE;
851 }
852 
854 {
855  if (window->monitor)
856  leaveFullscreenMode(window);
857 
858  destroyWindow(window);
859 }
860 
861 void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
862 {
863  WCHAR* wideTitle = _glfwCreateWideStringFromUTF8(title);
864  if (!wideTitle)
865  {
867  "Win32: Failed to convert window title to UTF-16");
868  return;
869  }
870 
871  SetWindowTextW(window->win32.handle, wideTitle);
872  free(wideTitle);
873 }
874 
875 void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
876 {
877  POINT pos = { 0, 0 };
878  ClientToScreen(window->win32.handle, &pos);
879 
880  if (xpos)
881  *xpos = pos.x;
882  if (ypos)
883  *ypos = pos.y;
884 }
885 
886 void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
887 {
888  RECT rect = { xpos, ypos, xpos, ypos };
889  AdjustWindowRectEx(&rect, getWindowStyle(window),
890  FALSE, getWindowExStyle(window));
891  SetWindowPos(window->win32.handle, NULL, rect.left, rect.top, 0, 0,
892  SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE);
893 }
894 
896 {
897  RECT area;
898  GetClientRect(window->win32.handle, &area);
899 
900  if (width)
901  *width = area.right;
902  if (height)
903  *height = area.bottom;
904 }
905 
907 {
908  if (window->monitor)
909  enterFullscreenMode(window);
910  else
911  {
912  int fullWidth, fullHeight;
913  getFullWindowSize(window, width, height, &fullWidth, &fullHeight);
914 
915  SetWindowPos(window->win32.handle, HWND_TOP,
916  0, 0, fullWidth, fullHeight,
917  SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOZORDER);
918  }
919 }
920 
922 {
923  _glfwPlatformGetWindowSize(window, width, height);
924 }
925 
927  int* left, int* top,
928  int* right, int* bottom)
929 {
930  RECT rect;
931  int width, height;
932 
933  _glfwPlatformGetWindowSize(window, &width, &height);
934  SetRect(&rect, 0, 0, width, height);
935  AdjustWindowRectEx(&rect, getWindowStyle(window),
936  FALSE, getWindowExStyle(window));
937 
938  if (left)
939  *left = -rect.left;
940  if (top)
941  *top = -rect.top;
942  if (right)
943  *right = rect.right - width;
944  if (bottom)
945  *bottom = rect.bottom - height;
946 }
947 
949 {
950  ShowWindow(window->win32.handle, SW_MINIMIZE);
951 }
952 
954 {
955  ShowWindow(window->win32.handle, SW_RESTORE);
956 }
957 
959 {
960  ShowWindow(window->win32.handle, SW_SHOW);
961  BringWindowToTop(window->win32.handle);
962  SetForegroundWindow(window->win32.handle);
963  SetFocus(window->win32.handle);
964 }
965 
967 {
968  ShowWindow(window->win32.handle, SW_SHOW);
969 }
970 
972 {
973  ShowWindow(window->win32.handle, SW_HIDE);
974 }
975 
977 {
978  return window->win32.handle == GetActiveWindow();
979 }
980 
982 {
983  return IsIconic(window->win32.handle);
984 }
985 
987 {
988  return IsWindowVisible(window->win32.handle);
989 }
990 
992 {
993  MSG msg;
994 
995  while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
996  {
997  if (msg.message == WM_QUIT)
998  {
999  // Treat WM_QUIT as a close on all windows
1000  // While GLFW does not itself post WM_QUIT, other processes may post
1001  // it to this one, for example Task Manager
1002 
1003  _GLFWwindow* window = _glfw.windowListHead;
1004  while (window)
1005  {
1007  window = window->next;
1008  }
1009  }
1010  else
1011  {
1012  TranslateMessage(&msg);
1013  DispatchMessageW(&msg);
1014  }
1015  }
1016 
1017  if (_glfw.cursorWindow)
1018  {
1019  _GLFWwindow* window = _glfw.cursorWindow;
1020 
1021  // LSHIFT/RSHIFT fixup (keys tend to "stick" without this fix)
1022  // This is the only async event handling in GLFW, but it solves some
1023  // nasty problems
1024  {
1025  const int mods = getAsyncKeyMods();
1026 
1027  // Get current state of left and right shift keys
1028  const int lshiftDown = (GetAsyncKeyState(VK_LSHIFT) >> 15) & 1;
1029  const int rshiftDown = (GetAsyncKeyState(VK_RSHIFT) >> 15) & 1;
1030 
1031  // See if this differs from our belief of what has happened
1032  // (we only have to check for lost key up events)
1033  if (!lshiftDown && window->keys[GLFW_KEY_LEFT_SHIFT] == 1)
1034  _glfwInputKey(window, GLFW_KEY_LEFT_SHIFT, 0, GLFW_RELEASE, mods);
1035 
1036  if (!rshiftDown && window->keys[GLFW_KEY_RIGHT_SHIFT] == 1)
1037  _glfwInputKey(window, GLFW_KEY_RIGHT_SHIFT, 0, GLFW_RELEASE, mods);
1038  }
1039 
1040  if (window->cursorMode == GLFW_CURSOR_DISABLED)
1041  {
1042  int width, height;
1043  _glfwPlatformGetWindowSize(window, &width, &height);
1044 
1045  // NOTE: Re-center the cursor only if it has moved since the last
1046  // call, to avoid breaking glfwWaitEvents with WM_MOUSEMOVE
1047  if (window->win32.cursorPosX != width / 2 ||
1048  window->win32.cursorPosY != height / 2)
1049  {
1050  _glfwPlatformSetCursorPos(window, width / 2, height / 2);
1051  }
1052  }
1053  }
1054 }
1055 
1057 {
1058  WaitMessage();
1059 
1061 }
1062 
1064 {
1065  _GLFWwindow* window = _glfw.windowListHead;
1066  PostMessage(window->win32.handle, WM_NULL, 0, 0);
1067 }
1068 
1069 void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
1070 {
1071  POINT pos;
1072 
1073  if (GetCursorPos(&pos))
1074  {
1075  ScreenToClient(window->win32.handle, &pos);
1076 
1077  if (xpos)
1078  *xpos = pos.x;
1079  if (ypos)
1080  *ypos = pos.y;
1081  }
1082 }
1083 
1084 void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos)
1085 {
1086  POINT pos = { (int) xpos, (int) ypos };
1087 
1088  // Store the new position so it can be recognized later
1089  window->win32.cursorPosX = pos.x;
1090  window->win32.cursorPosY = pos.y;
1091 
1092  ClientToScreen(window->win32.handle, &pos);
1093  SetCursorPos(pos.x, pos.y);
1094 }
1095 
1097 {
1098  switch (window->cursorMode)
1099  {
1100  case GLFW_CURSOR_NORMAL:
1101  restoreCursor(window);
1102  break;
1103  case GLFW_CURSOR_HIDDEN:
1104  hideCursor(window);
1105  break;
1106  case GLFW_CURSOR_DISABLED:
1107  disableCursor(window);
1108  break;
1109  }
1110 }
1111 
1113  const GLFWimage* image,
1114  int xhot, int yhot)
1115 {
1116  HDC dc;
1117  HBITMAP bitmap, mask;
1118  BITMAPV5HEADER bi;
1119  ICONINFO ii;
1120  DWORD* target = 0;
1121  BYTE* source = (BYTE*) image->pixels;
1122  int i;
1123 
1124  ZeroMemory(&bi, sizeof(bi));
1125  bi.bV5Size = sizeof(BITMAPV5HEADER);
1126  bi.bV5Width = image->width;
1127  bi.bV5Height = -image->height;
1128  bi.bV5Planes = 1;
1129  bi.bV5BitCount = 32;
1130  bi.bV5Compression = BI_BITFIELDS;
1131  bi.bV5RedMask = 0x00ff0000;
1132  bi.bV5GreenMask = 0x0000ff00;
1133  bi.bV5BlueMask = 0x000000ff;
1134  bi.bV5AlphaMask = 0xff000000;
1135 
1136  dc = GetDC(NULL);
1137  bitmap = CreateDIBSection(dc, (BITMAPINFO*) &bi, DIB_RGB_COLORS,
1138  (void**) &target, NULL, (DWORD) 0);
1139  ReleaseDC(NULL, dc);
1140 
1141  if (!bitmap)
1142  return GL_FALSE;
1143 
1144  mask = CreateBitmap(image->width, image->height, 1, 1, NULL);
1145  if (!mask)
1146  {
1147  DeleteObject(bitmap);
1148  return GL_FALSE;
1149  }
1150 
1151  for (i = 0; i < image->width * image->height; i++, target++, source += 4)
1152  {
1153  *target = (source[3] << 24) |
1154  (source[0] << 16) |
1155  (source[1] << 8) |
1156  source[2];
1157  }
1158 
1159  ZeroMemory(&ii, sizeof(ii));
1160  ii.fIcon = FALSE;
1161  ii.xHotspot = xhot;
1162  ii.yHotspot = yhot;
1163  ii.hbmMask = mask;
1164  ii.hbmColor = bitmap;
1165 
1166  cursor->win32.handle = (HCURSOR) CreateIconIndirect(&ii);
1167 
1168  DeleteObject(bitmap);
1169  DeleteObject(mask);
1170 
1171  if (!cursor->win32.handle)
1172  return GL_FALSE;
1173 
1174  return GL_TRUE;
1175 }
1176 
1178 {
1179  cursor->win32.handle =
1180  CopyCursor(LoadCursorW(NULL, translateCursorShape(shape)));
1181  if (!cursor->win32.handle)
1182  {
1184  "Win32: Failed to create standard cursor");
1185  return GL_FALSE;
1186  }
1187 
1188  return GL_TRUE;
1189 }
1190 
1192 {
1193  if (cursor->win32.handle)
1194  DestroyIcon((HICON) cursor->win32.handle);
1195 }
1196 
1198 {
1199  POINT pos;
1200 
1201  if (_glfw.cursorWindow != window)
1202  return;
1203 
1204  if (window->cursorMode != GLFW_CURSOR_NORMAL)
1205  return;
1206 
1207  if (!GetCursorPos(&pos))
1208  return;
1209 
1210  if (WindowFromPoint(pos) != window->win32.handle)
1211  return;
1212 
1213  if (cursor)
1214  SetCursor(cursor->win32.handle);
1215  else
1216  SetCursor(LoadCursorW(NULL, IDC_ARROW));
1217 }
1218 
1219 void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
1220 {
1221  WCHAR* wideString;
1222  HANDLE stringHandle;
1223  size_t wideSize;
1224 
1225  wideString = _glfwCreateWideStringFromUTF8(string);
1226  if (!wideString)
1227  {
1229  "Win32: Failed to convert string to UTF-16");
1230  return;
1231  }
1232 
1233  wideSize = (wcslen(wideString) + 1) * sizeof(WCHAR);
1234 
1235  stringHandle = GlobalAlloc(GMEM_MOVEABLE, wideSize);
1236  if (!stringHandle)
1237  {
1238  free(wideString);
1239 
1241  "Win32: Failed to allocate global handle for clipboard");
1242  return;
1243  }
1244 
1245  memcpy(GlobalLock(stringHandle), wideString, wideSize);
1246  GlobalUnlock(stringHandle);
1247 
1248  if (!OpenClipboard(window->win32.handle))
1249  {
1250  GlobalFree(stringHandle);
1251  free(wideString);
1252 
1253  _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to open clipboard");
1254  return;
1255  }
1256 
1257  EmptyClipboard();
1258  SetClipboardData(CF_UNICODETEXT, stringHandle);
1259  CloseClipboard();
1260 
1261  free(wideString);
1262 }
1263 
1265 {
1266  HANDLE stringHandle;
1267 
1268  if (!OpenClipboard(window->win32.handle))
1269  {
1270  _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to open clipboard");
1271  return NULL;
1272  }
1273 
1274  stringHandle = GetClipboardData(CF_UNICODETEXT);
1275  if (!stringHandle)
1276  {
1277  CloseClipboard();
1278 
1280  "Win32: Failed to convert clipboard to string");
1281  return NULL;
1282  }
1283 
1284  free(_glfw.win32.clipboardString);
1285  _glfw.win32.clipboardString =
1286  _glfwCreateUTF8FromWideString(GlobalLock(stringHandle));
1287 
1288  GlobalUnlock(stringHandle);
1289  CloseClipboard();
1290 
1291  if (!_glfw.win32.clipboardString)
1292  {
1294  "Win32: Failed to convert wide string to UTF-8");
1295  return NULL;
1296  }
1297 
1298  return _glfw.win32.clipboardString;
1299 }
1300 
1301 
1305 
1307 {
1308  _GLFWwindow* window = (_GLFWwindow*) handle;
1310  return window->win32.handle;
1311 }
1312 
void _glfwInputChar(_GLFWwindow *window, unsigned int codepoint, int mods, int plain)
Notifies shared code of a Unicode character input event.
Definition: input.c:159
static DWORD getWindowStyle(const _GLFWwindow *window)
Definition: win32_window.c:43
#define GLFW_KEY_RIGHT_CONTROL
Definition: glfw3.h:387
int height
Definition: glfw3.h:990
#define UNICODE_NOCHAR
Cursor structure.
Definition: internal.h:320
void _glfwPlatformGetVideoMode(_GLFWmonitor *monitor, GLFWvidmode *mode)
#define GLFW_MOD_CONTROL
If this bit is set one or more Control keys were held down.
Definition: glfw3.h:407
int _glfwPlatformCreateStandardCursor(_GLFWcursor *cursor, int shape)
Creates a cursor with a standard shape.
void _glfwPlatformGetWindowSize(_GLFWwindow *window, int *width, int *height)
Retrieves the size of the client area of the specified window.
Definition: win32_window.c:895
unsigned char * pixels
Definition: glfw3.h:1041
static int translateKey(WPARAM wParam, LPARAM lParam)
Definition: win32_window.c:194
#define GLFWAPI
Definition: glfw3.h:185
int _glfwPlatformWindowFocused(_GLFWwindow *window)
Returns whether the window is focused.
Definition: win32_window.c:976
int _glfwAnalyzeContext(const _GLFWwindow *window, const _GLFWctxconfig *ctxconfig, const _GLFWfbconfig *fbconfig)
Definition: wgl_context.c:497
GLsizei const GLuint * paths
Definition: glext.h:9577
void _glfwInputWindowIconify(_GLFWwindow *window, int iconified)
Notifies shared code of a window iconification event.
Definition: window.c:85
GLint GLint GLsizei GLsizei height
Definition: glext.h:112
GLboolean _glfwSetVideoMode(_GLFWmonitor *monitor, const GLFWvidmode *desired)
Definition: win32_monitor.c:50
static void updateClipRect(_GLFWwindow *window)
Definition: win32_window.c:74
GLint GLint GLint GLint GLint GLint y
Definition: glext.h:114
void _glfwInputWindowSize(_GLFWwindow *window, int width, int height)
Notifies shared code of a window resize event.
Definition: window.c:79
int width
Definition: glfw3.h:987
Window configuration.
Definition: internal.h:164
void _glfwPlatformApplyCursorMode(_GLFWwindow *window)
Applies the cursor mode of the specified window to the system.
#define GLFW_MOUSE_BUTTON_RIGHT
Definition: glfw3.h:433
void _glfwPlatformGetWindowPos(_GLFWwindow *window, int *xpos, int *ypos)
Retrieves the position of the client area of the specified window.
Definition: win32_window.c:875
GLenum GLenum GLsizei void * image
Definition: glext.h:2716
typedef HANDLE(WINAPI *PFNWGLCREATEBUFFERREGIONARBPROC)(HDC hDC
int height
Definition: glfw3.h:1038
GLenum GLint GLuint mask
Definition: glext.h:652
#define GLFW_KEY_LEFT_SHIFT
Definition: glfw3.h:382
#define GLFW_MOUSE_BUTTON_LEFT
Definition: glfw3.h:432
void _glfwPlatformGetWindowFrameSize(_GLFWwindow *window, int *left, int *top, int *right, int *bottom)
Retrieves the size of the frame of the window.
Definition: win32_window.c:926
#define GLFW_CROSSHAIR_CURSOR
The crosshair shape.
Definition: glfw3.h:671
static GLboolean enterFullscreenMode(_GLFWwindow *window)
Definition: win32_window.c:238
void _glfwInputWindowFocus(_GLFWwindow *window, GLboolean focused)
Notifies shared code of a window focus event.
Definition: window.c:39
void _glfwPlatformPostEmptyEvent(void)
Posts an empty event to the event queue.
#define GLFW_FORMAT_UNAVAILABLE
The requested format is not supported or available.
Definition: glfw3.h:589
void _glfwPlatformPollEvents(void)
Processes all pending events.
Definition: win32_window.c:991
int _glfwPlatformCreateCursor(_GLFWcursor *cursor, const GLFWimage *image, int xhot, int yhot)
Creates a custom cursor.
#define GLFW_ARROW_CURSOR
The regular arrow cursor shape.
Definition: glfw3.h:661
static int getAsyncKeyMods(void)
Definition: win32_window.c:176
_GLFWwindow * windowListHead
Definition: internal.h:343
_GLFWlibrary _glfw
All global data protected by _glfwInitialized. This should only be touched after a call to glfwInit t...
void _glfwPlatformSetWindowSize(_GLFWwindow *window, int width, int height)
Sets the size of the client area of the specified window.
Definition: win32_window.c:906
#define GLFW_MOUSE_BUTTON_5
Definition: glfw3.h:427
GLuint buffer
Definition: glext.h:528
void _glfwPlatformDestroyWindow(_GLFWwindow *window)
Definition: win32_window.c:853
GLboolean autoIconify
Definition: internal.h:239
const char * title
Definition: internal.h:168
void _glfwInputWindowDamage(_GLFWwindow *window)
Notifies shared code of a window damage event.
Definition: window.c:97
#define MSGFLT_ALLOW
struct GLFWwindow GLFWwindow
Opaque window object.
Definition: glfw3.h:722
GLFWvidmode videoMode
Definition: internal.h:243
void _glfwInputWindowCloseRequest(_GLFWwindow *window)
Notifies shared code of a window close request event.
Definition: window.c:103
void _glfwInputDrop(_GLFWwindow *window, int count, const char **paths)
Notifies dropped object over window.
Definition: input.c:219
#define GLFW_RELEASE
The key or mouse button was released.
Definition: glfw3.h:225
#define GLFW_CURSOR_DISABLED
Definition: glfw3.h:644
void _glfwPlatformGetFramebufferSize(_GLFWwindow *window, int *width, int *height)
Retrieves the size of the framebuffer of the specified window.
Definition: win32_window.c:921
void _glfwPlatformSetWindowPos(_GLFWwindow *window, int xpos, int ypos)
Sets the position of the client area of the specified window.
Definition: win32_window.c:886
int _glfwPlatformWindowIconified(_GLFWwindow *window)
Returns whether the window is iconified.
Definition: win32_window.c:981
#define GLFW_VRESIZE_CURSOR
The vertical resize arrow shape.
Definition: glfw3.h:686
void _glfwDestroyContext(_GLFWwindow *window)
Definition: wgl_context.c:480
#define _GLFW_REQUIRE_INIT_OR_RETURN(x)
Definition: internal.h:137
char keys[GLFW_KEY_LAST+1]
Definition: internal.h:253
#define WM_COPYGLOBALDATA
#define GLFW_MOUSE_BUTTON_MIDDLE
Definition: glfw3.h:434
_GLFWwindow * cursorWindow
Definition: internal.h:344
typedef GLboolean(APIENTRYP PFNGLISQUERYPROC)(GLuint id)
GLint GLint bottom
Definition: glext.h:1947
#define GLFW_CURSOR_NORMAL
Definition: glfw3.h:642
#define GLFW_PLATFORM_ERROR
A platform-specific error occurred that does not match any of the more specific categories.
Definition: glfw3.h:569
double cursorPosY
Definition: internal.h:250
GLuint GLuint GLsizei count
Definition: glext.h:111
#define GLFW_MOD_SUPER
If this bit is set one or more Super keys were held down.
Definition: glfw3.h:413
void _glfwPlatformIconifyWindow(_GLFWwindow *window)
Iconifies the specified window.
Definition: win32_window.c:948
#define GLFW_HAND_CURSOR
The hand shape.
Definition: glfw3.h:676
_GLFWmonitor * monitor
Definition: internal.h:175
void _glfwPlatformSetCursorPos(_GLFWwindow *window, double xpos, double ypos)
Sets the position of the cursor, relative to the client area of the window.
int cursorMode
Definition: internal.h:251
#define GLFW_MOD_SHIFT
If this bit is set one or more Shift keys were held down.
Definition: glfw3.h:404
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
static void destroyWindow(_GLFWwindow *window)
Definition: win32_window.c:735
void _glfwRestoreVideoMode(_GLFWmonitor *monitor)
Definition: win32_monitor.c:89
#define _GLFW_RECREATION_REQUIRED
#define _GLFW_WNDCLASSNAME
Definition: win32_window.c:38
struct _GLFWwindow * next
Definition: internal.h:234
int _glfwPlatformWindowVisible(_GLFWwindow *window)
Returns whether the window is visible.
Definition: win32_window.c:986
GLenum target
Definition: glext.h:1549
void _glfwPlatformDestroyCursor(_GLFWcursor *cursor)
Destroys a cursor.
GLint left
Definition: glext.h:1947
#define WM_UNICHAR
void _glfwPlatformGetMonitorPos(_GLFWmonitor *monitor, int *xpos, int *ypos)
Returns the position of the monitor&#39;s viewport on the virtual screen.
GLdouble GLdouble right
Definition: glext.h:6472
void _glfwInputMouseClick(_GLFWwindow *window, int button, int action, int mods)
Notifies shared code of a mouse button click event.
Definition: input.c:180
typedef HDC(WINAPI *PFNWGLGETCURRENTREADDCARBPROC)(void)
void _glfwPlatformSetClipboardString(_GLFWwindow *window, const char *string)
Sets the clipboard to the specified string.
void _glfwInputWindowPos(_GLFWwindow *window, int xpos, int ypos)
Notifies shared code of a window movement event.
Definition: window.c:73
#define GLFW_MOD_ALT
If this bit is set one or more Alt keys were held down.
Definition: glfw3.h:410
GLenum mode
Definition: glext.h:1117
void _glfwPlatformShowWindow(_GLFWwindow *window)
Makes the specified window visible.
Definition: win32_window.c:958
int _glfwCreateContext(_GLFWwindow *window, const _GLFWctxconfig *ctxconfig, const _GLFWfbconfig *fbconfig)
Definition: wgl_context.c:329
static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: win32_window.c:264
GLboolean resizable
Definition: internal.h:237
void _glfwInputScroll(_GLFWwindow *window, double xoffset, double yoffset)
Notifies shared code of a scroll event.
Definition: input.c:174
static DWORD getWindowExStyle(const _GLFWwindow *window)
Definition: win32_window.c:62
double cursorPosX
Definition: internal.h:250
int width
Definition: glfw3.h:1035
GLboolean floating
Definition: internal.h:174
#define _glfw_ChangeWindowMessageFilterEx
#define WM_MOUSEHWHEEL
void _glfwPlatformUnhideWindow(_GLFWwindow *window)
Definition: win32_window.c:966
void _glfwInputCursorEnter(_GLFWwindow *window, int entered)
Notifies shared code of a cursor enter/leave event.
Definition: input.c:213
static void hideCursor(_GLFWwindow *window)
Definition: win32_window.c:85
#define GLFW_CURSOR_HIDDEN
Definition: glfw3.h:643
void _glfwPlatformMakeContextCurrent(_GLFWwindow *window)
Makes the context of the specified window current for the calling thread.
Definition: wgl_context.c:590
void _glfwInputCursorMotion(_GLFWwindow *window, double x, double y)
Notifies shared code of a cursor motion event.
Definition: input.c:195
void _glfwPlatformGetCursorPos(_GLFWwindow *window, double *xpos, double *ypos)
Retrieves the position of the cursor relative to the client area of the window.
Video mode type.
Definition: glfw3.h:983
void _glfwInputMonitorChange(void)
Definition: monitor.c:89
static void restoreCursor(_GLFWwindow *window)
Definition: win32_window.c:115
GLint GLint GLsizei width
Definition: glext.h:112
#define GLFW_HRESIZE_CURSOR
The horizontal resize arrow shape.
Definition: glfw3.h:681
GLsizei GLsizei GLchar * source
Definition: glext.h:672
void _glfwInputKey(_GLFWwindow *window, int key, int scancode, int action, int mods)
Notifies shared code of a physical key event.
Definition: input.c:134
void _glfwPlatformSetCursor(_GLFWwindow *window, _GLFWcursor *cursor)
Sets the cursor for the window.
#define GLFW_IBEAM_CURSOR
The text input I-beam cursor shape.
Definition: glfw3.h:666
void _glfwPlatformHideWindow(_GLFWwindow *window)
Hides the specified window.
Definition: win32_window.c:971
#define GLFW_KEY_LEFT_CONTROL
Definition: glfw3.h:383
GLuint GLsizei GLsizei * length
Definition: glext.h:664
void _glfwPlatformWaitEvents(void)
Waits until events are queued and processes them.
static void leaveFullscreenMode(_GLFWwindow *window)
Definition: win32_window.c:257
_GLFWcursor * cursor
Definition: internal.h:245
#define _GLFW_RECREATION_IMPOSSIBLE
GLboolean _glfwRegisterWindowClass(void)
Definition: win32_window.c:753
void _glfwInputError(int error, const char *format,...)
Notifies shared code of an error.
void _glfwInputFramebufferSize(_GLFWwindow *window, int width, int height)
Notifies shared code of a framebuffer resize event.
Definition: window.c:91
GLsizei GLfixed GLfixed GLfixed GLfixed const GLubyte * bitmap
Definition: glext.h:4903
typedef UINT(WINAPI *PFNWGLGETGPUIDSAMDPROC)(UINT maxCount
const char * _glfwPlatformGetClipboardString(_GLFWwindow *window)
Returns the contents of the clipboard as a string.
Image data.
Definition: glfw3.h:1031
static LPWSTR translateCursorShape(int shape)
Definition: win32_window.c:135
#define _GLFW_KEY_INVALID
Definition: win32_window.c:36
Context configuration.
Definition: internal.h:185
Window and context structure.
Definition: internal.h:232
Framebuffer configuration.
Definition: internal.h:207
#define GLFW_KEY_RIGHT_SHIFT
Definition: glfw3.h:386
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:6472
char * _glfwCreateUTF8FromWideString(const WCHAR *source)
Definition: win32_init.c:299
static void getFullWindowSize(_GLFWwindow *window, int clientWidth, int clientHeight, int *fullWidth, int *fullHeight)
Definition: win32_window.c:637
#define GLFW_PRESS
The key or mouse button was pressed.
Definition: glfw3.h:232
_GLFWmonitor * monitor
Definition: internal.h:244
void _glfwPlatformSetWindowTitle(_GLFWwindow *window, const char *title)
Sets the title of the specified window.
Definition: win32_window.c:861
GLint GLint GLint GLint GLint x
Definition: glext.h:114
static int getKeyMods(void)
Definition: win32_window.c:158
void _glfwUnregisterWindowClass(void)
Definition: win32_window.c:787
void _glfwPlatformRestoreWindow(_GLFWwindow *window)
Restores the specified window.
Definition: win32_window.c:953
#define GLFW_MOUSE_BUTTON_4
Definition: glfw3.h:426
WCHAR * _glfwCreateWideStringFromUTF8(const char *source)
Definition: win32_init.c:277
GLboolean decorated
Definition: internal.h:238
static int createWindow(_GLFWwindow *window, const _GLFWwndconfig *wndconfig, const _GLFWctxconfig *ctxconfig, const _GLFWfbconfig *fbconfig)
Definition: win32_window.c:650
int _glfwPlatformCreateWindow(_GLFWwindow *window, const _GLFWwndconfig *wndconfig, const _GLFWctxconfig *ctxconfig, const _GLFWfbconfig *fbconfig)
Definition: win32_window.c:797
GLFWAPI HWND glfwGetWin32Window(GLFWwindow *handle)
static void disableCursor(_GLFWwindow *window)
Definition: win32_window.c:100


librealsense
Author(s): Sergey Dorodnicov , Mark Horn , Reagan Lopez
autogenerated on Fri Mar 13 2020 03:16:18