37 #define _GLFW_KEY_INVALID -2 43 DWORD style = WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
49 style |= WS_SYSMENU | WS_MINIMIZEBOX;
56 style |= WS_MAXIMIZEBOX | WS_THICKFRAME;
69 DWORD style = WS_EX_APPWINDOW;
72 style |= WS_EX_TOPMOST;
82 int i, leastDiff = INT_MAX;
85 for (i = 0; i <
count; i++)
87 const int currDiff = abs(images[i].width * images[i].height -
89 if (currDiff < leastDiff)
113 ZeroMemory(&bi,
sizeof(bi));
114 bi.bV5Size =
sizeof(bi);
115 bi.bV5Width = image->
width;
116 bi.bV5Height = -image->
height;
119 bi.bV5Compression = BI_BITFIELDS;
120 bi.bV5RedMask = 0x00ff0000;
121 bi.bV5GreenMask = 0x0000ff00;
122 bi.bV5BlueMask = 0x000000ff;
123 bi.bV5AlphaMask = 0xff000000;
126 color = CreateDIBSection(dc,
137 "Win32: Failed to create RGBA bitmap");
145 "Win32: Failed to create mask bitmap");
152 target[0] = source[2];
153 target[1] = source[1];
154 target[2] = source[0];
155 target[3] = source[3];
160 ZeroMemory(&ii,
sizeof(ii));
167 handle = CreateIconIndirect(&ii);
177 "Win32: Failed to create icon");
182 "Win32: Failed to create cursor");
192 int clientWidth,
int clientHeight,
193 int* fullWidth,
int* fullHeight,
196 RECT
rect = { 0, 0, clientWidth, clientHeight };
201 AdjustWindowRectEx(&rect, style,
FALSE, exStyle);
203 *fullWidth = rect.right - rect.left;
204 *fullHeight = rect.bottom - rect.top;
213 const float ratio = (float) window->
numer / (
float) window->
denom;
219 0, 0, &xoff, &yoff, dpi);
221 if (edge == WMSZ_LEFT || edge == WMSZ_BOTTOMLEFT ||
222 edge == WMSZ_RIGHT || edge == WMSZ_BOTTOMRIGHT)
224 area->bottom = area->top + yoff +
225 (int) ((area->right - area->left - xoff) / ratio);
227 else if (edge == WMSZ_TOPLEFT || edge == WMSZ_TOPRIGHT)
229 area->top = area->bottom - yoff -
230 (int) ((area->right - area->left - xoff) / ratio);
232 else if (edge == WMSZ_TOP || edge == WMSZ_BOTTOM)
234 area->right = area->left + xoff +
235 (int) ((area->bottom - area->top - yoff) * ratio);
255 SetCursor(window->
cursor->win32.handle);
257 SetCursor(LoadCursorW(
NULL, IDC_ARROW));
270 GetClientRect(window->win32.handle, &clipRect);
271 ClientToScreen(window->win32.handle, (POINT*) &clipRect.left);
272 ClientToScreen(window->win32.handle, (POINT*) &clipRect.right);
273 ClipCursor(&clipRect);
283 const RAWINPUTDEVICE rid = { 0x01, 0x02, 0, window->win32.handle };
287 &
_glfw.win32.restoreCursorPosX,
288 &
_glfw.win32.restoreCursorPosY);
293 if (!RegisterRawInputDevices(&rid, 1,
sizeof(rid)))
296 "Win32: Failed to register raw input device");
304 const RAWINPUTDEVICE rid = { 0x01, 0x02, RIDEV_REMOVE,
NULL };
309 _glfw.win32.restoreCursorPosX,
310 _glfw.win32.restoreCursorPosY);
313 if (!RegisterRawInputDevices(&rid, 1,
sizeof(rid)))
316 "Win32: Failed to remove raw input device");
330 if (WindowFromPoint(pos) != window->win32.handle)
333 GetClientRect(window->win32.handle, &area);
334 ClientToScreen(window->win32.handle, (POINT*) &area.left);
335 ClientToScreen(window->win32.handle, (POINT*) &area.right);
337 return PtInRect(&area, pos);
345 DWORD style = GetWindowLongW(window->win32.handle, GWL_STYLE);
346 style &= ~(WS_OVERLAPPEDWINDOW | WS_POPUP);
349 GetClientRect(window->win32.handle, &rect);
360 ClientToScreen(window->win32.handle, (POINT*) &rect.left);
361 ClientToScreen(window->win32.handle, (POINT*) &rect.right);
362 SetWindowLongW(window->win32.handle, GWL_STYLE, style);
365 rect.right - rect.left, rect.bottom - rect.top,
366 SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOZORDER);
380 HRGN region = CreateRectRgn(0, 0, -1, -1);
397 LONG exStyle = GetWindowLongW(window->win32.handle, GWL_EXSTYLE);
398 exStyle |= WS_EX_LAYERED;
399 SetWindowLongW(window->win32.handle, GWL_EXSTYLE, exStyle);
404 SetLayeredWindowAttributes(window->win32.handle,
405 RGB(0, 193, 48), 255, LWA_COLORKEY);
408 DeleteObject(region);
412 LONG exStyle = GetWindowLongW(window->win32.handle, GWL_EXSTYLE);
413 exStyle &= ~WS_EX_LAYERED;
414 SetWindowLongW(window->win32.handle, GWL_EXSTYLE, exStyle);
415 RedrawWindow(window->win32.handle,
NULL,
NULL,
416 RDW_ERASE | RDW_INVALIDATE | RDW_FRAME);
426 if (GetKeyState(VK_SHIFT) & 0x8000)
428 if (GetKeyState(VK_CONTROL) & 0x8000)
430 if (GetKeyState(VK_MENU) & 0x8000)
432 if ((GetKeyState(VK_LWIN) | GetKeyState(VK_RWIN)) & 0x8000)
434 if (GetKeyState(VK_CAPITAL) & 1)
436 if (GetKeyState(VK_NUMLOCK) & 1)
448 if (GetAsyncKeyState(VK_SHIFT) & 0x8000)
450 if (GetAsyncKeyState(VK_CONTROL) & 0x8000)
452 if (GetAsyncKeyState(VK_MENU) & 0x8000)
454 if ((GetAsyncKeyState(VK_LWIN) | GetAsyncKeyState(VK_RWIN)) & 0x8000)
456 if (GetAsyncKeyState(VK_CAPITAL) & 1)
458 if (GetAsyncKeyState(VK_NUMLOCK) & 1)
469 if (wParam == VK_CONTROL)
475 if (lParam & 0x01000000)
481 time = GetMessageTime();
483 if (PeekMessageW(&next,
NULL, 0, 0, PM_NOREMOVE))
485 if (next.message == WM_KEYDOWN ||
486 next.message == WM_SYSKEYDOWN ||
487 next.message == WM_KEYUP ||
488 next.message == WM_SYSKEYUP)
490 if (next.wParam == VK_MENU &&
491 (next.lParam & 0x01000000) &&
503 if (wParam == VK_PROCESSKEY)
510 return _glfw.win32.keycodes[HIWORD(lParam) & 0x1FF];
515 MONITORINFO mi = {
sizeof(mi) };
516 GetMonitorInfo(window->
monitor->win32.handle, &mi);
520 mi.rcMonitor.right - mi.rcMonitor.left,
521 mi.rcMonitor.bottom - mi.rcMonitor.top,
522 SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS);
529 if (!
_glfw.win32.acquiredMonitorCount)
531 SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
537 SystemParametersInfo(SPI_GETMOUSETRAILS, 0, &
_glfw.win32.mouseTrailSize, 0);
538 SystemParametersInfo(SPI_SETMOUSETRAILS, 0, 0, 0);
543 _glfw.win32.acquiredMonitorCount++;
556 _glfw.win32.acquiredMonitorCount--;
557 if (!
_glfw.win32.acquiredMonitorCount)
559 SetThreadExecutionState(ES_CONTINUOUS);
563 SystemParametersInfo(SPI_SETMOUSETRAILS,
_glfw.win32.mouseTrailSize, 0, 0);
573 WPARAM wParam, LPARAM lParam)
591 case WM_DISPLAYCHANGE:
595 case WM_DEVICECHANGE:
597 if (wParam == DBT_DEVICEARRIVAL)
599 DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*) lParam;
600 if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
603 else if (wParam == DBT_DEVICEREMOVECOMPLETE)
605 DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*) lParam;
606 if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
614 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
619 case WM_MOUSEACTIVATE:
623 if (HIWORD(lParam) == WM_LBUTTONDOWN)
625 if (LOWORD(lParam) == HTCLOSE ||
626 LOWORD(lParam) == HTMINBUTTON ||
627 LOWORD(lParam) == HTMAXBUTTON)
636 case WM_CAPTURECHANGED:
640 if (lParam == 0 && window->win32.frameAction)
657 if (window->win32.frameAction)
680 switch (wParam & 0xfff0)
683 case SC_MONITORPOWER:
708 case WM_INPUTLANGCHANGE:
718 const GLFWbool plain = (uMsg != WM_SYSCHAR);
738 const int scancode = (lParam >> 16) & 0x1ff;
753 else if (wParam == VK_SNAPSHOT)
776 if (uMsg == WM_LBUTTONDOWN || uMsg == WM_LBUTTONUP)
778 else if (uMsg == WM_RBUTTONDOWN || uMsg == WM_RBUTTONUP)
780 else if (uMsg == WM_MBUTTONDOWN || uMsg == WM_MBUTTONUP)
787 if (uMsg == WM_LBUTTONDOWN || uMsg == WM_RBUTTONDOWN ||
788 uMsg == WM_MBUTTONDOWN || uMsg == WM_XBUTTONDOWN)
815 if (uMsg == WM_XBUTTONDOWN || uMsg == WM_XBUTTONUP)
823 const int x = GET_X_LPARAM(lParam);
824 const int y = GET_Y_LPARAM(lParam);
832 window->win32.lastCursorPosX =
x;
833 window->win32.lastCursorPosY =
y;
835 if (!window->win32.cursorTracked)
838 ZeroMemory(&tme,
sizeof(tme));
839 tme.cbSize =
sizeof(tme);
840 tme.dwFlags = TME_LEAVE;
841 tme.hwndTrack = window->win32.handle;
842 TrackMouseEvent(&tme);
854 HRAWINPUT ri = (HRAWINPUT) lParam;
859 if (
_glfw.win32.disabledCursorWindow != window)
862 GetRawInputData(ri, RID_INPUT,
NULL, &size,
sizeof(RAWINPUTHEADER));
863 if (size > (UINT)
_glfw.win32.rawInputSize)
865 free(
_glfw.win32.rawInput);
866 _glfw.win32.rawInput = calloc(size, 1);
870 size =
_glfw.win32.rawInputSize;
871 if (GetRawInputData(ri, RID_INPUT,
872 _glfw.win32.rawInput, &size,
873 sizeof(RAWINPUTHEADER)) == (UINT) -1)
876 "Win32: Failed to retrieve raw input data");
880 data =
_glfw.win32.rawInput;
881 if (data->data.mouse.usFlags & MOUSE_MOVE_ABSOLUTE)
883 dx = data->data.mouse.lLastX - window->win32.lastCursorPosX;
884 dy = data->data.mouse.lLastY - window->win32.lastCursorPosY;
888 dx = data->data.mouse.lLastX;
889 dy = data->data.mouse.lLastY;
896 window->win32.lastCursorPosX += dx;
897 window->win32.lastCursorPosY += dy;
910 _glfwInputScroll(window, 0.0, (SHORT) HIWORD(wParam) / (
double) WHEEL_DELTA);
918 _glfwInputScroll(window, -((SHORT) HIWORD(wParam) / (
double) WHEEL_DELTA), 0.0);
922 case WM_ENTERSIZEMOVE:
923 case WM_ENTERMENULOOP:
933 case WM_EXITSIZEMOVE:
934 case WM_EXITMENULOOP:
946 const GLFWbool iconified = wParam == SIZE_MINIMIZED;
948 (window->win32.maximized &&
949 wParam != SIZE_RESTORED);
951 if (
_glfw.win32.disabledCursorWindow == window)
954 if (window->win32.iconified != iconified)
957 if (window->win32.maximized != maximized)
963 if (window->
monitor && window->win32.iconified != iconified)
974 window->win32.iconified = iconified;
981 if (
_glfw.win32.disabledCursorWindow == window)
987 GET_X_LPARAM(lParam),
988 GET_Y_LPARAM(lParam));
1004 case WM_GETMINMAXINFO:
1008 MINMAXINFO* mmi = (MINMAXINFO*) lParam;
1017 0, 0, &xoff, &yoff, dpi);
1022 mmi->ptMinTrackSize.x = window->
minwidth + xoff;
1023 mmi->ptMinTrackSize.y = window->
minheight + yoff;
1029 mmi->ptMaxTrackSize.x = window->
maxwidth + xoff;
1030 mmi->ptMaxTrackSize.y = window->
maxheight + yoff;
1036 const HMONITOR mh = MonitorFromWindow(window->win32.handle,
1037 MONITOR_DEFAULTTONEAREST);
1039 ZeroMemory(&mi,
sizeof(mi));
1040 mi.cbSize =
sizeof(mi);
1041 GetMonitorInfo(mh, &mi);
1043 mmi->ptMaxPosition.x = mi.rcWork.left - mi.rcMonitor.left;
1044 mmi->ptMaxPosition.y = mi.rcWork.top - mi.rcMonitor.top;
1045 mmi->ptMaxSize.x = mi.rcWork.right - mi.rcWork.left;
1046 mmi->ptMaxSize.y = mi.rcWork.bottom - mi.rcWork.top;
1065 if (window->win32.transparent)
1072 if (window->win32.scaleToMonitor)
1079 SIZE*
size = (SIZE*) lParam;
1089 (source.right - source.left);
1091 (source.bottom - source.top);
1107 RECT* suggested = (RECT*) lParam;
1111 suggested->right - suggested->left,
1112 suggested->bottom - suggested->top,
1113 SWP_NOACTIVATE | SWP_NOZORDER);
1122 if (LOWORD(lParam) == HTCLIENT)
1133 HDROP drop = (HDROP) wParam;
1137 const int count = DragQueryFileW(drop, 0xffffffff,
NULL, 0);
1138 char**
paths = calloc(count,
sizeof(
char*));
1141 DragQueryPoint(drop, &pt);
1144 for (i = 0; i <
count; i++)
1146 const UINT
length = DragQueryFileW(drop, i,
NULL, 0);
1147 WCHAR*
buffer = calloc(length + 1,
sizeof(WCHAR));
1149 DragQueryFileW(drop, i, buffer, length + 1);
1157 for (i = 0; i <
count; i++)
1166 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
1175 int xpos,
ypos, fullWidth, fullHeight;
1189 fullWidth = mode.
width;
1190 fullHeight = mode.
height;
1194 xpos = CW_USEDEFAULT;
1195 ypos = CW_USEDEFAULT;
1198 style |= WS_MAXIMIZE;
1202 &fullWidth, &fullHeight,
1210 window->win32.handle = CreateWindowExW(exStyle,
1215 fullWidth, fullHeight,
1218 GetModuleHandleW(
NULL),
1223 if (!window->win32.handle)
1226 "Win32: Failed to create window");
1230 SetPropW(window->win32.handle, L
"GLFW", window);
1253 float xscale, yscale;
1255 rect.right = (int) (rect.right * xscale);
1256 rect.bottom = (int) (rect.bottom * yscale);
1259 ClientToScreen(window->win32.handle, (POINT*) &rect.left);
1260 ClientToScreen(window->win32.handle, (POINT*) &rect.right);
1268 AdjustWindowRectEx(&rect, style,
FALSE, exStyle);
1271 rect.left, rect.top,
1272 rect.right - rect.left, rect.bottom - rect.top,
1273 SWP_NOACTIVATE | SWP_NOZORDER);
1276 DragAcceptFiles(window->win32.handle,
TRUE);
1298 ZeroMemory(&wc,
sizeof(wc));
1299 wc.cbSize =
sizeof(wc);
1300 wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
1302 wc.hInstance = GetModuleHandleW(
NULL);
1303 wc.hCursor = LoadCursorW(
NULL, IDC_ARROW);
1307 wc.hIcon = LoadImageW(GetModuleHandleW(
NULL),
1308 L
"GLFW_ICON", IMAGE_ICON,
1309 0, 0, LR_DEFAULTSIZE | LR_SHARED);
1313 wc.hIcon = LoadImageW(
NULL,
1314 IDI_APPLICATION, IMAGE_ICON,
1315 0, 0, LR_DEFAULTSIZE | LR_SHARED);
1318 if (!RegisterClassExW(&wc))
1321 "Win32: Failed to register window class");
1392 if (
_glfw.win32.disabledCursorWindow == window)
1393 _glfw.win32.disabledCursorWindow =
NULL;
1395 if (window->win32.handle)
1397 RemovePropW(window->win32.handle, L
"GLFW");
1398 DestroyWindow(window->win32.handle);
1399 window->win32.handle =
NULL;
1402 if (window->win32.bigIcon)
1403 DestroyIcon(window->win32.bigIcon);
1405 if (window->win32.smallIcon)
1406 DestroyIcon(window->win32.smallIcon);
1415 SetWindowTextW(window->win32.handle, wideTitle);
1422 HICON bigIcon =
NULL, smallIcon =
NULL;
1427 GetSystemMetrics(SM_CXICON),
1428 GetSystemMetrics(SM_CYICON));
1430 GetSystemMetrics(SM_CXSMICON),
1431 GetSystemMetrics(SM_CYSMICON));
1438 bigIcon = (HICON) GetClassLongPtrW(window->win32.handle, GCLP_HICON);
1439 smallIcon = (HICON) GetClassLongPtrW(window->win32.handle, GCLP_HICONSM);
1442 SendMessage(window->win32.handle, WM_SETICON, ICON_BIG, (LPARAM) bigIcon);
1443 SendMessage(window->win32.handle, WM_SETICON, ICON_SMALL, (LPARAM) smallIcon);
1445 if (window->win32.bigIcon)
1446 DestroyIcon(window->win32.bigIcon);
1448 if (window->win32.smallIcon)
1449 DestroyIcon(window->win32.smallIcon);
1453 window->win32.bigIcon = bigIcon;
1454 window->win32.smallIcon = smallIcon;
1460 POINT
pos = { 0, 0 };
1461 ClientToScreen(window->win32.handle, &pos);
1486 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE);
1492 GetClientRect(window->win32.handle, &area);
1495 *width = area.right;
1497 *height = area.bottom;
1527 0, 0, rect.right - rect.left, rect.bottom - rect.top,
1528 SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOZORDER);
1533 int minwidth,
int minheight,
1534 int maxwidth,
int maxheight)
1544 GetWindowRect(window->win32.handle, &area);
1545 MoveWindow(window->win32.handle,
1546 area.left, area.top,
1547 area.right - area.left,
1548 area.bottom - area.top,
TRUE);
1558 GetWindowRect(window->win32.handle, &area);
1560 MoveWindow(window->win32.handle,
1561 area.left, area.top,
1562 area.right - area.left,
1563 area.bottom - area.top,
TRUE);
1579 SetRect(&rect, 0, 0, width, height);
1598 *right = rect.right -
width;
1600 *bottom = rect.bottom -
height;
1604 float* xscale,
float* yscale)
1606 const HANDLE
handle = MonitorFromWindow(window->win32.handle,
1607 MONITOR_DEFAULTTONEAREST);
1613 ShowWindow(window->win32.handle, SW_MINIMIZE);
1618 ShowWindow(window->win32.handle, SW_RESTORE);
1623 ShowWindow(window->win32.handle, SW_MAXIMIZE);
1628 ShowWindow(window->win32.handle, SW_SHOWNA);
1633 ShowWindow(window->win32.handle, SW_HIDE);
1638 FlashWindow(window->win32.handle,
TRUE);
1643 BringWindowToTop(window->win32.handle);
1644 SetForegroundWindow(window->win32.handle);
1645 SetFocus(window->win32.handle);
1654 if (window->
monitor == monitor)
1658 if (monitor->
window == window)
1681 rect.left, rect.top,
1682 rect.right - rect.left, rect.bottom - rect.top,
1683 SWP_NOCOPYBITS | SWP_NOACTIVATE | SWP_NOZORDER);
1696 MONITORINFO mi = {
sizeof(mi) };
1697 UINT
flags = SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOCOPYBITS;
1701 DWORD style = GetWindowLongW(window->win32.handle, GWL_STYLE);
1702 style &= ~WS_OVERLAPPEDWINDOW;
1704 SetWindowLongW(window->win32.handle, GWL_STYLE, style);
1705 flags |= SWP_FRAMECHANGED;
1710 GetMonitorInfo(window->
monitor->win32.handle, &mi);
1714 mi.rcMonitor.right - mi.rcMonitor.left,
1715 mi.rcMonitor.bottom - mi.rcMonitor.top,
1722 DWORD style = GetWindowLongW(window->win32.handle, GWL_STYLE);
1723 UINT
flags = SWP_NOACTIVATE | SWP_NOCOPYBITS;
1729 SetWindowLongW(window->win32.handle, GWL_STYLE, style);
1731 flags |= SWP_FRAMECHANGED;
1735 after = HWND_TOPMOST;
1737 after = HWND_NOTOPMOST;
1752 rect.left, rect.top,
1753 rect.right - rect.left, rect.bottom - rect.top,
1760 return window->win32.handle == GetActiveWindow();
1765 return IsIconic(window->win32.handle);
1770 return IsWindowVisible(window->win32.handle);
1775 return IsZoomed(window->win32.handle);
1787 if (!window->win32.transparent)
1808 const HWND after = enabled ? HWND_TOPMOST : HWND_NOTOPMOST;
1810 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1818 if ((GetWindowLongW(window->win32.handle, GWL_EXSTYLE) & WS_EX_LAYERED) &&
1819 GetLayeredWindowAttributes(window->win32.handle,
NULL, &alpha, &flags))
1821 if (flags & LWA_ALPHA)
1822 return alpha / 255.f;
1833 DWORD style = GetWindowLongW(window->win32.handle, GWL_EXSTYLE);
1834 style |= WS_EX_LAYERED;
1835 SetWindowLongW(window->win32.handle, GWL_EXSTYLE, style);
1836 SetLayeredWindowAttributes(window->win32.handle, 0, alpha, LWA_ALPHA);
1840 DWORD style = GetWindowLongW(window->win32.handle, GWL_EXSTYLE);
1841 style &= ~WS_EX_LAYERED;
1842 SetWindowLongW(window->win32.handle, GWL_EXSTYLE, style);
1852 while (PeekMessageW(&msg,
NULL, 0, 0, PM_REMOVE))
1854 if (msg.message == WM_QUIT)
1864 window = window->
next;
1869 TranslateMessage(&msg);
1870 DispatchMessageW(&msg);
1874 handle = GetActiveWindow();
1881 window = GetPropW(handle, L
"GLFW");
1884 const GLFWbool lshift = (GetAsyncKeyState(VK_LSHIFT) >> 15) & 1;
1885 const GLFWbool rshift = (GetAsyncKeyState(VK_RSHIFT) >> 15) & 1;
1902 window =
_glfw.win32.disabledCursorWindow;
1910 if (window->win32.lastCursorPosX != width / 2 ||
1911 window->win32.lastCursorPosY != height / 2)
1927 MsgWaitForMultipleObjects(0,
NULL,
FALSE, (DWORD) (timeout * 1e3), QS_ALLEVENTS);
1934 PostMessage(
_glfw.win32.helperWindowHandle, WM_NULL, 0, 0);
1943 ScreenToClient(window->win32.handle, &pos);
1954 POINT
pos = { (int) xpos, (
int) ypos };
1957 window->win32.lastCursorPosX = pos.x;
1958 window->win32.lastCursorPosY = pos.y;
1960 ClientToScreen(window->win32.handle, &pos);
1971 else if (
_glfw.win32.disabledCursorWindow == window)
1979 return _glfw.win32.keynames[
_glfw.win32.keycodes[scancode]];
1992 if (!cursor->win32.handle)
2017 cursor->win32.handle = CopyCursor(LoadCursorW(
NULL, name));
2018 if (!cursor->win32.handle)
2021 "Win32: Failed to create standard cursor");
2030 if (cursor->win32.handle)
2031 DestroyIcon((HICON) cursor->win32.handle);
2046 characterCount = MultiByteToWideChar(CP_UTF8, 0,
string, -1,
NULL, 0);
2047 if (!characterCount)
2050 object = GlobalAlloc(GMEM_MOVEABLE, characterCount *
sizeof(WCHAR));
2054 "Win32: Failed to allocate global handle for clipboard");
2058 buffer = GlobalLock(
object);
2062 "Win32: Failed to lock global handle");
2067 MultiByteToWideChar(CP_UTF8, 0,
string, -1, buffer, characterCount);
2068 GlobalUnlock(
object);
2070 if (!OpenClipboard(
_glfw.win32.helperWindowHandle))
2073 "Win32: Failed to open clipboard");
2079 SetClipboardData(CF_UNICODETEXT,
object);
2088 if (!OpenClipboard(
_glfw.win32.helperWindowHandle))
2091 "Win32: Failed to open clipboard");
2095 object = GetClipboardData(CF_UNICODETEXT);
2099 "Win32: Failed to convert clipboard to string");
2104 buffer = GlobalLock(
object);
2108 "Win32: Failed to lock global handle");
2113 free(
_glfw.win32.clipboardString);
2116 GlobalUnlock(
object);
2119 return _glfw.win32.clipboardString;
2127 extensions[0] =
"VK_KHR_surface";
2128 extensions[1] =
"VK_KHR_win32_surface";
2136 vkGetPhysicalDeviceWin32PresentationSupportKHR =
2139 if (!vkGetPhysicalDeviceWin32PresentationSupportKHR)
2142 "Win32: Vulkan instance missing VK_KHR_win32_surface extension");
2146 return vkGetPhysicalDeviceWin32PresentationSupportKHR(device, queuefamily);
2160 if (!vkCreateWin32SurfaceKHR)
2163 "Win32: Vulkan instance missing VK_KHR_win32_surface extension");
2167 memset(&sci, 0,
sizeof(sci));
2170 sci.
hwnd = window->win32.handle;
2172 err = vkCreateWin32SurfaceKHR(instance, &sci, allocator, surface);
2176 "Win32: Failed to create Vulkan surface: %s",
2192 return window->win32.handle;
static DWORD getWindowStyle(const _GLFWwindow *window)
void _glfwGetMonitorContentScaleWin32(HMONITOR handle, float *xscale, float *yscale)
void _glfwPlatformIconifyWindow(_GLFWwindow *window)
float _glfwPlatformGetWindowOpacity(_GLFWwindow *window)
#define GLFW_KEY_RIGHT_CONTROL
void _glfwRestoreVideoModeWin32(_GLFWmonitor *monitor)
WCHAR * _glfwCreateWideStringFromUTF8Win32(const char *source)
IMGUI_API ImVec2 GetCursorPos()
#define GLFW_MOD_CONTROL
If this bit is set one or more Control keys were held down.
GLuint const GLchar * name
static HICON createIcon(const GLFWimage *image, int xhot, int yhot, GLFWbool icon)
void _glfwInputWindowCloseRequest(_GLFWwindow *window)
void _glfwPlatformSetWindowSizeLimits(_GLFWwindow *window, int minwidth, int minheight, int maxwidth, int maxheight)
static int translateKey(WPARAM wParam, LPARAM lParam)
GLdouble GLdouble GLdouble top
static void enableCursor(_GLFWwindow *window)
void _glfwDetectJoystickConnectionWin32(void)
void _glfwUnregisterWindowClassWin32(void)
IMGUI_API void SetCursorPos(const ImVec2 &local_pos)
static void updateClipRect(_GLFWwindow *window)
static void updateCursorImage(_GLFWwindow *window)
static const GLFWimage * chooseImage(int count, const GLFWimage *images, int width, int height)
void _glfwPlatformGetCursorPos(_GLFWwindow *window, double *xpos, double *ypos)
static GLFWwindow * window
GLFWbool _glfwInitOSMesa(void)
static void updateWindowStyles(const _GLFWwindow *window)
void _glfwInputWindowIconify(_GLFWwindow *window, GLFWbool iconified)
const char * _glfwPlatformGetClipboardString(void)
int _glfwPlatformFramebufferTransparent(_GLFWwindow *window)
GLuint64 GLenum void * handle
_GLFWdestroycontextfun destroy
void _glfwInputFramebufferSize(_GLFWwindow *window, int width, int height)
void _glfwPlatformDestroyCursor(_GLFWcursor *cursor)
GLsizei const GLuint * paths
char * _glfwCreateUTF8FromWideStringWin32(const WCHAR *source)
void _glfwInputWindowMaximize(_GLFWwindow *window, GLFWbool maximized)
int _glfwPlatformCreateStandardCursor(_GLFWcursor *cursor, int shape)
#define GLFW_KEY_LEFT_SHIFT
const char * _glfwGetVulkanResultString(VkResult result)
struct _GLFWlibrary::@29 vk
void _glfwPlatformGetVideoMode(_GLFWmonitor *monitor, GLFWvidmode *mode)
#define GLFW_CROSSHAIR_CURSOR
The crosshair shape.
static void centerCursor(_GLFWwindow *window)
#define GLFW_API_UNAVAILABLE
GLFW could not find support for the requested API on the system.
#define GLFW_EGL_CONTEXT_API
GLFWbool _glfwCreateContextWGL(_GLFWwindow *window, const _GLFWctxconfig *ctxconfig, const _GLFWfbconfig *fbconfig)
std::array< point3d, 4 > object
#define GLFW_FORMAT_UNAVAILABLE
The requested format is not supported or available.
void _glfwPlatformGetWindowContentScale(_GLFWwindow *window, float *xscale, float *yscale)
#define GLFW_ARROW_CURSOR
The regular arrow cursor shape.
static int getAsyncKeyMods(void)
void _glfwPlatformSetWindowResizable(_GLFWwindow *window, GLFWbool enabled)
_GLFWwindow * windowListHead
void _glfwPlatformSetWindowIcon(_GLFWwindow *window, int count, const GLFWimage *images)
int _glfwPlatformWindowFocused(_GLFWwindow *window)
void _glfwInputWindowDamage(_GLFWwindow *window)
GLenum GLenum GLsizei void * image
void _glfwInputWindowPos(_GLFWwindow *window, int xpos, int ypos)
void _glfwPlatformDestroyWindow(_GLFWwindow *window)
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow *window, int numer, int denom)
void _glfwPlatformSetCursorPos(_GLFWwindow *window, double xpos, double ypos)
void _glfwPlatformSetWindowSize(_GLFWwindow *window, int width, int height)
#define GLFW_CURSOR_DISABLED
void _glfwPlatformWaitEventsTimeout(double timeout)
void _glfwPlatformShowWindow(_GLFWwindow *window)
void _glfwPlatformGetRequiredInstanceExtensions(char **extensions)
#define GLFW_VRESIZE_CURSOR
The vertical resize arrow shape.
#define _GLFW_REQUIRE_INIT_OR_RETURN(x)
char keys[GLFW_KEY_LAST+1]
GLfloat GLfloat GLfloat alpha
static int createNativeWindow(_GLFWwindow *window, const _GLFWwndconfig *wndconfig, const _GLFWfbconfig *fbconfig)
GLFWbool _glfwCreateContextEGL(_GLFWwindow *window, const _GLFWctxconfig *ctxconfig, const _GLFWfbconfig *fbconfig)
static void fitToMonitor(_GLFWwindow *window)
void _glfwPlatformHideWindow(_GLFWwindow *window)
#define GLFW_CURSOR_NORMAL
#define GLFW_PLATFORM_ERROR
A platform-specific error occurred that does not match any of the more specific categories.
int _glfwPlatformWindowVisible(_GLFWwindow *window)
#define GLFW_NATIVE_CONTEXT_API
void _glfwInputWindowFocus(_GLFWwindow *window, GLFWbool focused)
#define GLFW_MOD_SUPER
If this bit is set one or more Super keys were held down.
#define GLFW_HAND_CURSOR
The hand shape.
void _glfwInputWindowContentScale(_GLFWwindow *window, float xscale, float yscale)
#define GLFW_MOD_SHIFT
If this bit is set one or more Shift keys were held down.
void _glfwPlatformSetCursorMode(_GLFWwindow *window, int mode)
void _glfwInputErrorWin32(int error, const char *description)
GLint GLsizei GLsizei height
int _glfwPlatformCreateWindow(_GLFWwindow *window, const _GLFWwndconfig *wndconfig, const _GLFWctxconfig *ctxconfig, const _GLFWfbconfig *fbconfig)
struct _GLFWwindow * next
GLFWbool _glfwRegisterWindowClassWin32(void)
void _glfwPlatformGetMonitorPos(_GLFWmonitor *monitor, int *xpos, int *ypos)
GLenum GLenum GLsizei const GLuint GLboolean enabled
void _glfwPlatformSetWindowMonitor(_GLFWwindow *window, _GLFWmonitor *monitor, int xpos, int ypos, int width, int height, int refreshRate)
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *pName)
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily)
void _glfwPlatformGetWindowPos(_GLFWwindow *window, int *xpos, int *ypos)
void _glfwPlatformGetWindowSize(_GLFWwindow *window, int *width, int *height)
#define GLFW_OSMESA_CONTEXT_API
void _glfwInputError(int code, const char *format,...)
void _glfwPollMonitorsWin32(void)
#define GLFW_MOD_ALT
If this bit is set one or more Alt keys were held down.
void _glfwSetVideoModeWin32(_GLFWmonitor *monitor, const GLFWvidmode *desired)
void _glfwInputWindowSize(_GLFWwindow *window, int width, int height)
void _glfwPlatformSetWindowPos(_GLFWwindow *window, int xpos, int ypos)
#define GLFW_MOD_CAPS_LOCK
If this bit is set the Caps Lock key is enabled.
static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
int _glfwPlatformWindowHovered(_GLFWwindow *window)
void _glfwPlatformRequestWindowAttention(_GLFWwindow *window)
VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, _GLFWwindow *window, const VkAllocationCallbacks *allocator, VkSurfaceKHR *surface)
void _glfwPlatformSetWindowTitle(_GLFWwindow *window, const char *title)
static DWORD getWindowExStyle(const _GLFWwindow *window)
void _glfwInputWindowMonitor(_GLFWwindow *window, _GLFWmonitor *monitor)
void next(auto_any_t cur, type2type< T, C > *)
void _glfwPlatformSetWindowFloating(_GLFWwindow *window, GLFWbool enabled)
int _glfwPlatformWindowIconified(_GLFWwindow *window)
void _glfwPlatformFocusWindow(_GLFWwindow *window)
static void releaseMonitor(_GLFWwindow *window)
int _glfwPlatformGetKeyScancode(int key)
GLbitfield GLuint64 timeout
#define GLFW_HRESIZE_CURSOR
The horizontal resize arrow shape.
#define GLFW_IBEAM_CURSOR
The text input I-beam cursor shape.
GLFWbool _glfwCreateContextOSMesa(_GLFWwindow *window, const _GLFWctxconfig *ctxconfig, const _GLFWfbconfig *fbconfig)
static const char * maximized
void _glfwInputMonitorWindow(_GLFWmonitor *monitor, _GLFWwindow *window)
void _glfwDetectJoystickDisconnectionWin32(void)
#define GLFW_KEY_LEFT_CONTROL
GLFWbool _glfwInitWGL(void)
void _glfwPlatformWaitEvents(void)
static void updateFramebufferTransparency(const _GLFWwindow *window)
void _glfwPlatformPostEmptyEvent(void)
GLsizei GLsizei GLchar * source
void _glfwPlatformSetWindowOpacity(_GLFWwindow *window, float opacity)
static void applyAspectRatio(_GLFWwindow *window, int edge, RECT *area)
char mouseButtons[GLFW_MOUSE_BUTTON_LAST+1]
int _glfwPlatformCreateCursor(_GLFWcursor *cursor, const GLFWimage *image, int xhot, int yhot)
GLenum GLuint GLenum GLsizei length
void _glfwPlatformRestoreWindow(_GLFWwindow *window)
static void getFullWindowSize(DWORD style, DWORD exStyle, int clientWidth, int clientHeight, int *fullWidth, int *fullHeight, UINT dpi)
std::array< float, 3 > color
#define _GLFW_KEY_INVALID
void _glfwPlatformMaximizeWindow(_GLFWwindow *window)
void _glfwPlatformSetWindowDecorated(_GLFWwindow *window, GLFWbool enabled)
GLFWbool _glfwInitEGL(void)
static GLFWbool cursorInClientArea(_GLFWwindow *window)
void _glfwPlatformPollEvents(void)
#define GLFW_KEY_RIGHT_SHIFT
void _glfwPlatformSetCursor(_GLFWwindow *window, _GLFWcursor *cursor)
void _glfwPlatformGetWindowFrameSize(_GLFWwindow *window, int *left, int *top, int *right, int *bottom)
void _glfwPlatformGetFramebufferSize(_GLFWwindow *window, int *width, int *height)
void _glfwUpdateKeyNamesWin32(void)
static void SetWindowPos(ImGuiWindow *window, const ImVec2 &pos, ImGuiSetCond cond)
static int getKeyMods(void)
static void acquireMonitor(_GLFWwindow *window)
struct GLFWwindow GLFWwindow
int _glfwPlatformWindowMaximized(_GLFWwindow *window)
const char * _glfwPlatformGetScancodeName(int scancode)
#define GLFW_MOD_NUM_LOCK
If this bit is set the Num Lock key is enabled.
void _glfwPlatformSetClipboardString(const char *string)
GLFWAPI HWND glfwGetWin32Window(GLFWwindow *handle)
static void disableCursor(_GLFWwindow *window)