20#ifdef WITH_OPENGL_BACKEND
23#ifdef WITH_VULKAN_BACKEND
36#include <propvarutil.h>
38#include <shellscalingapi.h>
42#ifndef GET_POINTERID_WPARAM
43# define GET_POINTERID_WPARAM(wParam) (LOWORD(wParam))
46const wchar_t *GHOST_WindowWin32::s_windowClassName =
L"GHOST_WindowClass";
47const int GHOST_WindowWin32::s_maxTitleLength = 128;
51__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
74 preferred_device_(preferred_device),
75 has_mouse_captured_(
false),
76 has_grab_mouse_(
false),
77 n_pressed_buttons_(0),
83 user32_(::LoadLibrary(
"user32.dll")),
84 parent_window_hwnd_(parent_window ? parent_window->h_wnd_ : HWND_DESKTOP),
85 direct_manipulation_helper_(
nullptr)
87 DWORD style = parent_window ?
88 WS_POPUPWINDOW | WS_CAPTION | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SIZEBOX :
96 DWORD extended_style = parent_window ? WS_EX_APPWINDOW : 0;
109 h_wnd_ = ::CreateWindowExW(extended_style,
115 win_rect.right - win_rect.left,
116 win_rect.bottom - win_rect.top,
119 ::GetModuleHandle(0),
123 if (h_wnd_ ==
nullptr) {
127 registerWindowAppUserModelProperties();
130 h_DC_ = ::GetDC(h_wnd_);
133 const char *title =
"Blender - Unsupported Graphics Card Configuration";
134 const char *text =
"";
136 if (strncmp(
BLI_getenv(
"PROCESSOR_IDENTIFIER"),
"ARM", 3) == 0 &&
137 strstr(
BLI_getenv(
"PROCESSOR_IDENTIFIER"),
"Qualcomm") != NULL)
140 "A driver with support for OpenGL 4.3 or higher is required.\n\n"
141 "Qualcomm devices require the \"OpenCL™, OpenGL®, and Vulkan® Compatibility Pack\" "
142 "from the Microsoft Store.\n\n"
143 "Devices using processors older than a Qualcomm Snapdragon 8cx Gen3 are incompatible, "
144 "but may be able to run an emulated x64 copy of Blender, such as a 3.x LTS release.";
150 "A graphics card and driver with support for OpenGL 4.3 or higher is "
151 "required.\n\nInstalling the latest driver for your graphics card might resolve the "
153 if (GetSystemMetrics(SM_CMONITORS) > 1) {
155 "A graphics card and driver with support for OpenGL 4.3 or higher is "
156 "required.\n\nPlugging all monitors into your primary graphics card might resolve "
157 "this issue. Installing the latest driver for your graphics card could also help.";
160 MessageBox(h_wnd_, text, title, MB_OK | MB_ICONERROR);
161 ::ReleaseDC(h_wnd_, h_DC_);
162 ::DestroyWindow(h_wnd_);
164 if (!parent_window) {
170 RegisterTouchWindow(h_wnd_, 0);
174 ::RegisterDragDrop(h_wnd_, drop_target_);
177 ::SetWindowLongPtr(h_wnd_, GWLP_USERDATA, (LONG_PTR)
this);
179 if (!system_->window_focus_) {
181 ::SetWindowPos(h_wnd_, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
195 nCmdShow = SW_SHOWMAXIMIZED;
198 nCmdShow = (system_->window_focus_) ? SW_SHOWMINIMIZED : SW_SHOWMINNOACTIVE;
202 nCmdShow = (system_->window_focus_) ? SW_SHOWNORMAL : SW_SHOWNOACTIVATE;
208 ::ShowWindow(h_wnd_, nCmdShow);
217 CLSID_TaskbarList,
nullptr, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, (LPVOID *)&bar_);
228 if (!direct_manipulation_helper_) {
232 direct_manipulation_helper_->update();
239 if (!direct_manipulation_helper_) {
244 POINTER_INPUT_TYPE pointerType;
245 if (GetPointerType(pointerId, &pointerType) && pointerType == PT_TOUCHPAD) {
246 direct_manipulation_helper_->onPointerHitTest(pointerId);
252 if (!direct_manipulation_helper_) {
256 return direct_manipulation_helper_->getTrackpadInfo();
262 unregisterWindowAppUserModelProperties();
274 FreeLibrary(user32_);
278 if (custom_cursor_) {
279 DestroyCursor(custom_cursor_);
280 custom_cursor_ =
nullptr;
284 ::ReleaseDC(h_wnd_, h_DC_);
291 for (
GHOST_IWindow *iter_win : system_->getWindowManager()->getWindows()) {
293 if (iter_winwin->parent_window_hwnd_ == h_wnd_) {
294 ::SetWindowLongPtr(iter_winwin->h_wnd_, GWLP_HWNDPARENT, 0);
295 iter_winwin->parent_window_hwnd_ = 0;
301 RevokeDragDrop(h_wnd_);
303 drop_target_->Release();
304 drop_target_ =
nullptr;
306 ::SetWindowLongPtr(h_wnd_, GWLP_USERDATA, 0);
307 ::DestroyWindow(h_wnd_);
311 delete direct_manipulation_helper_;
312 direct_manipulation_helper_ =
nullptr;
320 HMONITOR hmonitor = MonitorFromRect(win_rect, MONITOR_DEFAULTTONEAREST);
321 MONITORINFOEX monitor;
322 monitor.cbSize =
sizeof(MONITORINFOEX);
324 GetMonitorInfo(hmonitor, &monitor);
327 LONG width =
min(monitor.rcWork.right - monitor.rcWork.left, win_rect->right - win_rect->left);
328 LONG height =
min(monitor.rcWork.bottom - monitor.rcWork.top, win_rect->bottom - win_rect->top);
329 win_rect->left =
min(
max(monitor.rcWork.left, win_rect->left), monitor.rcWork.right - width);
330 win_rect->right = win_rect->left + width;
331 win_rect->top =
min(
max(monitor.rcWork.top, win_rect->top), monitor.rcWork.bottom - height);
332 win_rect->bottom = win_rect->top + height;
338 user32_,
"AdjustWindowRectExForDpi");
343 if (fpAdjustWindowRectExForDpi) {
345 GetDpiForMonitor(hmonitor, MDT_EFFECTIVE_DPI, &dpiX, &dpiY);
346 fpAdjustWindowRectExForDpi(win_rect, dwStyle & ~WS_OVERLAPPED,
FALSE, dwExStyle, dpiX);
349 AdjustWindowRectEx(win_rect, dwStyle & ~WS_OVERLAPPED,
FALSE, dwExStyle);
353 win_rect->top =
max(monitor.rcWork.top, win_rect->top);
368 return (
void *)h_wnd_;
374 ::SetWindowTextW(h_wnd_, (
wchar_t *)title_16);
380 std::wstring wtitle(::GetWindowTextLengthW(h_wnd_) + 1,
L'\0');
381 ::GetWindowTextW(h_wnd_, &wtitle[0], wtitle.capacity());
392 constexpr DWORD caption_color_attr = 35;
396 const COLORREF colorref = RGB(
397 char(color[0] * 255.0f),
char(color[1] * 255.0f),
char(color[2] * 255.0f));
398 if (!SUCCEEDED(DwmSetWindowAttribute(h_wnd_, caption_color_attr, &colorref,
sizeof(colorref))))
409 ::GetWindowRect(h_wnd_, &rect);
420 if (!IsIconic(h_wnd_)) {
421 ::GetClientRect(h_wnd_, &rect);
425 ::ClientToScreen(h_wnd_, &coord);
430 coord.x = rect.right;
431 coord.y = rect.bottom;
432 ::ClientToScreen(h_wnd_, &coord);
454 success = ::SetWindowPos(h_wnd_, HWND_TOP, 0, 0, cx, cy, SWP_NOMOVE | SWP_NOZORDER) ?
473 success = ::SetWindowPos(h_wnd_, HWND_TOP, 0, 0, cx, cy, SWP_NOMOVE | SWP_NOZORDER) ?
492 success = ::SetWindowPos(h_wnd_, HWND_TOP, 0, 0, cx, cy, SWP_NOMOVE | SWP_NOZORDER) ?
504 if (::IsIconic(h_wnd_)) {
507 else if (::IsZoomed(h_wnd_)) {
508 LONG_PTR
result = ::GetWindowLongPtr(h_wnd_, GWL_STYLE);
519 POINT point = {inX, inY};
520 ::ScreenToClient(h_wnd_, &point);
530 POINT point = {inX, inY};
531 ::ClientToScreen(h_wnd_, &point);
539 LONG_PTR style = GetWindowLongPtr(h_wnd_, GWL_STYLE) | WS_CAPTION;
541 wp.length =
sizeof(WINDOWPLACEMENT);
542 ::GetWindowPlacement(h_wnd_, &wp);
546 wp.showCmd = SW_MINIMIZE;
549 wp.showCmd = SW_SHOWMAXIMIZED;
553 normal_state_ = curstate;
555 wp.showCmd = SW_SHOWMAXIMIZED;
556 wp.ptMaxPosition.x = 0;
557 wp.ptMaxPosition.y = 0;
558 style &= ~(WS_CAPTION | WS_MAXIMIZE);
564 wp.showCmd = SW_SHOWMAXIMIZED;
568 wp.showCmd = SW_SHOWNORMAL;
572 ::SetWindowLongPtr(h_wnd_, GWL_STYLE, style);
575 ::SetWindowPos(h_wnd_, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
581 HWND hWndInsertAfter, hWndToRaise;
584 hWndInsertAfter = HWND_BOTTOM;
585 hWndToRaise = ::GetWindow(h_wnd_, GW_HWNDNEXT);
591 hWndInsertAfter = HWND_TOP;
592 hWndToRaise =
nullptr;
595 if (::SetWindowPos(h_wnd_, hWndInsertAfter, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE) ==
FALSE) {
600 ::SetWindowPos(hWndToRaise, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE) ==
FALSE)
622#ifdef WITH_VULKAN_BACKEND
623 case GHOST_kDrawingContextTypeVulkan: {
626 if (context->initializeDrawingContext()) {
634#ifdef WITH_OPENGL_BACKEND
635 case GHOST_kDrawingContextTypeOpenGL: {
636 for (
int minor = 6; minor >= 3; --minor) {
637 GHOST_Context *
context =
new GHOST_ContextWGL(
642 WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
648 if (
context->initializeDrawingContext()) {
657 case GHOST_kDrawingContextTypeD3D: {
660 if (
context->initializeDrawingContext()) {
675 if (has_mouse_captured_) {
676 has_grab_mouse_ =
false;
677 n_pressed_buttons_ = 0;
678 has_mouse_captured_ =
false;
691 n_pressed_buttons_++;
694 if (n_pressed_buttons_) {
695 n_pressed_buttons_--;
699 has_grab_mouse_ =
true;
702 has_grab_mouse_ =
false;
706 if (!n_pressed_buttons_ && !has_grab_mouse_ && has_mouse_captured_) {
708 has_mouse_captured_ =
false;
710 else if ((n_pressed_buttons_ || has_grab_mouse_) && !has_mouse_captured_) {
711 ::SetCapture(h_wnd_);
712 has_mouse_captured_ =
true;
719 HANDLE cursor =
nullptr;
720 uint32_t flags = LR_SHARED | LR_DEFAULTSIZE;
725 if (custom_cursor_) {
726 return custom_cursor_;
732 cursor = ::LoadImage(
nullptr, IDC_SIZEALL, IMAGE_CURSOR, cx, cy, flags);
735 cursor = ::LoadImage(
nullptr, IDC_HELP, IMAGE_CURSOR, cx, cy, flags);
738 cursor = ::LoadImage(
nullptr, IDC_WAIT, IMAGE_CURSOR, cx, cy, flags);
741 cursor = ::LoadImage(
nullptr, IDC_IBEAM, IMAGE_CURSOR, cx, cy, flags);
744 cursor = ::LoadImage(
nullptr, IDC_UPARROW, IMAGE_CURSOR, cx, cy, flags);
747 cursor = ::LoadImage(
nullptr, IDC_SIZENWSE, IMAGE_CURSOR, cx, cy, flags);
750 cursor = ::LoadImage(
nullptr, IDC_SIZENESW, IMAGE_CURSOR, cx, cy, flags);
753 cursor = ::LoadImage(
nullptr, IDC_SIZENWSE, IMAGE_CURSOR, cx, cy, flags);
756 cursor = ::LoadImage(
nullptr, IDC_SIZENESW, IMAGE_CURSOR, cx, cy, flags);
765 if (cursor ==
nullptr) {
766 cursor = ::LoadImage(
nullptr, IDC_ARROW, IMAGE_CURSOR, cx, cy, flags);
769 return (HCURSOR)cursor;
775 while (::ShowCursor(
FALSE) >= 0) {
780 while (::ShowCursor(TRUE) < 0) {
786 if (cursor ==
nullptr) {
792GHOST_TSuccess GHOST_WindowWin32::setWindowCursorVisibility(
bool visible)
794 if (::GetForegroundWindow() == h_wnd_) {
809 setWindowCursorVisibility(
false);
817 setWindowCursorVisibility(
true);
824 system_->getCursorPosition(
pos[0],
pos[1]);
825 system_->setCursorPosition(
pos[0],
pos[1]);
840 if (::GetForegroundWindow() == h_wnd_) {
853 std::vector<GHOST_PointerInfoWin32> &outPointerInfo, WPARAM wParam, LPARAM )
856 int32_t isPrimary = IS_POINTER_PRIMARY_WPARAM(wParam);
858 uint32_t outCount = 0;
860 if (!(GetPointerPenInfoHistory(pointerId, &outCount,
nullptr))) {
864 std::vector<POINTER_PEN_INFO> pointerPenInfo(outCount);
865 outPointerInfo.resize(outCount);
867 if (!(GetPointerPenInfoHistory(pointerId, &outCount, pointerPenInfo.data()))) {
871 for (uint32_t
i = 0;
i < outCount;
i++) {
872 POINTER_INFO pointerApiInfo = pointerPenInfo[
i].pointerInfo;
874 outPointerInfo[
i].pointerId = pointerId;
875 outPointerInfo[
i].isPrimary = isPrimary;
877 switch (pointerApiInfo.ButtonChangeType) {
878 case POINTER_CHANGE_FIRSTBUTTON_DOWN:
879 case POINTER_CHANGE_FIRSTBUTTON_UP:
882 case POINTER_CHANGE_SECONDBUTTON_DOWN:
883 case POINTER_CHANGE_SECONDBUTTON_UP:
886 case POINTER_CHANGE_THIRDBUTTON_DOWN:
887 case POINTER_CHANGE_THIRDBUTTON_UP:
890 case POINTER_CHANGE_FOURTHBUTTON_DOWN:
891 case POINTER_CHANGE_FOURTHBUTTON_UP:
894 case POINTER_CHANGE_FIFTHBUTTON_DOWN:
895 case POINTER_CHANGE_FIFTHBUTTON_UP:
902 outPointerInfo[
i].pixelLocation = pointerApiInfo.ptPixelLocation;
904 outPointerInfo[
i].tabletData.Pressure = 1.0f;
905 outPointerInfo[
i].tabletData.Xtilt = 0.0f;
906 outPointerInfo[
i].tabletData.Ytilt = 0.0f;
909 if (pointerPenInfo[
i].penMask & PEN_MASK_PRESSURE) {
910 outPointerInfo[
i].tabletData.Pressure = pointerPenInfo[
i].pressure / 1024.0f;
913 if (pointerPenInfo[
i].penFlags & PEN_FLAG_ERASER) {
917 if (pointerPenInfo[
i].penMask & PEN_MASK_TILT_X) {
921 outPointerInfo[
i].tabletData.Xtilt = std::clamp(
922 pointerPenInfo[
i].tiltX / 90.0f, -1.0f, 1.0f);
925 if (pointerPenInfo[
i].penMask & PEN_MASK_TILT_Y) {
929 outPointerInfo[
i].tabletData.Ytilt = std::clamp(
930 pointerPenInfo[
i].tiltY / 90.0f, -1.0f, 1.0f);
934 if (!outPointerInfo.empty()) {
935 last_pointer_tablet_data_ = outPointerInfo.back().tabletData;
962 if (system_->getCursorPosition(
x,
y)) {
967 wintab_->gainFocus();
984 if (system_->getTabletAPI() == api) {
988 if (wintab_ && wintab_->devicesPresent()) {
1006 return last_pointer_tablet_data_;
1013 DWORD pcbData =
sizeof(lightMode);
1014 if (RegGetValueW(HKEY_CURRENT_USER,
1015 L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize\\",
1016 L"AppsUseLightTheme",
1020 &pcbData) == ERROR_SUCCESS)
1022 BOOL DarkMode = !lightMode;
1027 DwmSetWindowAttribute(this->h_wnd_, 20, &DarkMode,
sizeof(DarkMode));
1033 if (direct_manipulation_helper_) {
1034 direct_manipulation_helper_->setDPI(
getDPIHint());
1042 user32_,
"GetDpiForWindow");
1044 if (fpGetDpiForWindow) {
1045 return fpGetDpiForWindow(this->h_wnd_);
1049 return USER_DEFAULT_SCREEN_DPI;
1055 ch = ((ch >> 1) & 0x55) | ((ch << 1) & 0xAA);
1056 ch = ((ch >> 2) & 0x33) | ((ch << 2) & 0xCC);
1057 ch = ((ch >> 4) & 0x0F) | ((ch << 4) & 0xF0);
1065 shrt = ((shrt >> 1) & 0x5555) | ((shrt << 1) & 0xAAAA);
1066 shrt = ((shrt >> 2) & 0x3333) | ((shrt << 2) & 0xCCCC);
1067 shrt = ((shrt >> 4) & 0x0F0F) | ((shrt << 4) & 0xF0F0);
1068 shrt = ((shrt >> 8) & 0x00FF) | ((shrt << 8) & 0xFF00);
1073GHOST_TSuccess GHOST_WindowWin32::setWindowCustomCursorShape(
const uint8_t *bitmap,
1074 const uint8_t *
mask,
1076 const int hot_spot[2],
1091 HCURSOR previous_cursor = custom_cursor_;
1093 memset(&andData, 0xFF,
sizeof(andData));
1094 memset(&xorData, 0,
sizeof(xorData));
1096 for (
y = 0;
y <
size[1];
y++) {
1099 for (
x = cols - 1;
x >= 0;
x--) {
1105 xorData[
y] = fullBitRow & fullMaskRow;
1106 andData[
y] = ~fullMaskRow;
1109 custom_cursor_ = ::CreateCursor(
1110 ::GetModuleHandle(0), hot_spot[0], hot_spot[1], 32, 32, andData, xorData);
1112 if (!custom_cursor_) {
1116 if (::GetForegroundWindow() == h_wnd_) {
1120 if (previous_cursor) {
1121 DestroyCursor(previous_cursor);
1131 BITMAPV5HEADER header;
1132 memset(&header, 0,
sizeof(BITMAPV5HEADER));
1133 header.bV5Size =
sizeof(BITMAPV5HEADER);
1134 header.bV5Width = (LONG)
size[0];
1135 header.bV5Height = (LONG)
size[1];
1136 header.bV5Planes = 1;
1137 header.bV5BitCount = 32;
1138 header.bV5Compression = BI_BITFIELDS;
1139 header.bV5RedMask = 0x00FF0000;
1140 header.bV5GreenMask = 0x0000FF00;
1141 header.bV5BlueMask = 0x000000FF;
1142 header.bV5AlphaMask = 0xFF000000;
1144 HDC hdc = GetDC(h_wnd_);
1145 void *bits =
nullptr;
1146 HBITMAP bmp = CreateDIBSection(
1147 hdc, (BITMAPINFO *)&header, DIB_RGB_COLORS, (
void **)&bits, NULL, (DWORD)0);
1148 ReleaseDC(NULL, hdc);
1153 for (
int y = h - 1;
y >= 0;
y--) {
1154 for (
int x = 0;
x <
w;
x++) {
1155 int i = (
y *
w * 4) + (
x * 4);
1160 *
ptr++ = (a << 24) | (r << 16) | (g << 8) |
b;
1164 HBITMAP empty_mask = CreateBitmap(
size[0],
size[1], 1, 1, NULL);
1166 icon_info.fIcon =
FALSE;
1167 icon_info.xHotspot = (DWORD)hot_spot[0];
1168 icon_info.yHotspot = (DWORD)hot_spot[1];
1169 icon_info.hbmMask = empty_mask;
1170 icon_info.hbmColor = bmp;
1172 HCURSOR previous_cursor = custom_cursor_;
1174 custom_cursor_ = CreateIconIndirect(&icon_info);
1176 DeleteObject(empty_mask);
1178 if (!custom_cursor_) {
1182 if (::GetForegroundWindow() == h_wnd_) {
1186 if (previous_cursor) {
1187 DestroyCursor(previous_cursor);
1196 if (bar_ && S_OK == bar_->SetProgressValue(h_wnd_, 10000 * progress, 10000)) {
1205 if (bar_ && S_OK == bar_->SetProgressState(h_wnd_,
TBPF_NOPROGRESS)) {
1212#ifdef WITH_INPUT_IME
1215 ime_input_.BeginIME(h_wnd_,
GHOST_Rect(
x,
y - h,
x,
y), completed);
1218void GHOST_WindowWin32::endIME()
1220 ime_input_.EndIME(h_wnd_);
1224void GHOST_WindowWin32::registerWindowAppUserModelProperties()
1226 IPropertyStore *pstore;
1227 char blender_path[MAX_PATH];
1228 wchar_t shell_command[MAX_PATH];
1231 GetModuleFileName(0, blender_path,
sizeof(blender_path));
1232 char *blender_app = strstr(blender_path,
"blender.exe");
1237 HRESULT hr = SHGetPropertyStoreForWindow(h_wnd_, IID_PPV_ARGS(&pstore));
1238 if (!SUCCEEDED(hr)) {
1244 strcpy(blender_app,
"blender-launcher.exe");
1245 wsprintfW(shell_command,
L"\"%S\"", blender_path);
1248 PROPVARIANT propvar;
1249 hr = InitPropVariantFromString(BLENDER_WIN_APPID_16, &propvar);
1250 hr = pstore->SetValue(PKEY_AppUserModel_ID, propvar);
1251 hr = InitPropVariantFromString(shell_command, &propvar);
1252 hr = pstore->SetValue(PKEY_AppUserModel_RelaunchCommand, propvar);
1253 hr = InitPropVariantFromString(BLENDER_WIN_APPID_FRIENDLY_NAME_16, &propvar);
1254 hr = pstore->SetValue(PKEY_AppUserModel_RelaunchDisplayNameResource, propvar);
1262void GHOST_WindowWin32::unregisterWindowAppUserModelProperties()
1264 IPropertyStore *pstore;
1265 HRESULT hr = SHGetPropertyStoreForWindow(h_wnd_, IID_PPV_ARGS(&pstore));
1266 if (SUCCEEDED(hr)) {
1268 PropVariantInit(&value);
1269 pstore->SetValue(PKEY_AppUserModel_ID, value);
1270 pstore->SetValue(PKEY_AppUserModel_RelaunchCommand, value);
1271 pstore->SetValue(PKEY_AppUserModel_RelaunchDisplayNameResource, value);
1282 HMONITOR hmonitor = ::MonitorFromWindow(h_wnd_, MONITOR_DEFAULTTONEAREST);
1287 MONITORINFOEXW monitor_info = {};
1288 monitor_info.cbSize =
sizeof(MONITORINFOEXW);
1289 if (!::GetMonitorInfoW(hmonitor, &monitor_info)) {
1294 UINT32 path_count = 0;
1295 UINT32 mode_count = 0;
1296 if (::GetDisplayConfigBufferSizes(QDC_ONLY_ACTIVE_PATHS, &path_count, &mode_count) !=
1302 std::vector<DISPLAYCONFIG_PATH_INFO> paths(path_count);
1303 std::vector<DISPLAYCONFIG_MODE_INFO> modes(mode_count);
1304 if (::QueryDisplayConfig(
1305 QDC_ONLY_ACTIVE_PATHS, &path_count, paths.data(), &mode_count, modes.data(),
nullptr) !=
1314 for (
const DISPLAYCONFIG_PATH_INFO &path : paths) {
1315 DISPLAYCONFIG_SOURCE_DEVICE_NAME device_name = {};
1316 device_name.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME;
1317 device_name.header.size =
sizeof(device_name);
1318 device_name.header.adapterId = path.sourceInfo.adapterId;
1319 device_name.header.id = path.sourceInfo.id;
1321 if (::DisplayConfigGetDeviceInfo(&device_name.header) != ERROR_SUCCESS) {
1324 if (wcscmp(monitor_info.szDevice, device_name.viewGdiDeviceName) != 0) {
1329 DISPLAYCONFIG_GET_ADVANCED_COLOR_INFO color_info = {};
1330 color_info.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_ADVANCED_COLOR_INFO;
1331 color_info.header.size =
sizeof(color_info);
1332 color_info.header.adapterId = path.targetInfo.adapterId;
1333 color_info.header.id = path.targetInfo.id;
1335 if (::DisplayConfigGetDeviceInfo(&color_info.header) == ERROR_SUCCESS) {
1339 color_info.advancedColorEnabled;
1345 DISPLAYCONFIG_SDR_WHITE_LEVEL white_level = {};
1346 white_level.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_SDR_WHITE_LEVEL;
1347 white_level.header.size =
sizeof(white_level);
1348 white_level.header.adapterId = path.targetInfo.adapterId;
1349 white_level.header.id = path.targetInfo.id;
1351 if (::DisplayConfigGetDeviceInfo(&white_level.header) == ERROR_SUCCESS) {
1352 if (white_level.SDRWhiteLevel > 0) {
1355 info.
sdr_white_level =
static_cast<float>(white_level.SDRWhiteLevel) / 1000.0f;
void BLI_kdtree_nd_ free(KDTree *tree)
const char * BLI_getenv(const char *env) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
#define GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY
const GUID CLSID_TaskbarList
@ GHOST_kWindowStateMinimized
@ GHOST_kWindowStateMaximized
@ GHOST_kWindowStateNormal
@ GHOST_kWindowStateFullScreen
@ GHOST_kStandardCursorBottomLeftCorner
@ GHOST_kStandardCursorHelp
@ GHOST_kStandardCursorWait
@ GHOST_kStandardCursorTopSide
@ GHOST_kStandardCursorCustom
@ GHOST_kStandardCursorTopLeftCorner
@ GHOST_kStandardCursorMove
@ GHOST_kStandardCursorBottomRightCorner
@ GHOST_kStandardCursorDefault
@ GHOST_kStandardCursorTopRightCorner
@ GHOST_kStandardCursorText
static const GHOST_TabletData GHOST_TABLET_DATA_NONE
@ GHOST_kTabletModeEraser
@ GHOST_kTabletModeStylus
GHOST_TDrawingContextType
@ GHOST_kWindowOrderBottom
#define GHOST_WINDOW_HDR_INFO_NONE
@ GHOST_kButtonMaskButton4
@ GHOST_kButtonMaskButton5
@ GHOST_kButtonMaskMiddle
@ GHOST_kTabletWinPointer
@ GHOST_kDecorationColoredTitleBar
static uint16_t uns16ReverseBits(uint16_t shrt)
#define GET_POINTERID_WPARAM(wParam)
static uint8_t uns8ReverseBits(uint8_t ch)
__declspec(dllexport) DWORD NvOptimusEnablement=0x00000001
UINT(API * GHOST_WIN32_GetDpiForWindow)(HWND)
BOOL(API * GHOST_WIN32_AdjustWindowRectExForDpi)(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle, UINT dpi)
GHOST_MouseCaptureEventWin32
#define WINTAB_PRINTF(x,...)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
static GHOST_DirectManipulationHelper * create(HWND hWnd, uint16_t dpi)
static GHOST_ISystem * getSystem()
virtual bool isInside(int32_t x, int32_t y) const
virtual int32_t getHeight() const
virtual int32_t getWidth() const
uint64_t performanceCounterToMillis(__int64 perf_ticks) const
GHOST_TTabletAPI getTabletAPI()
GHOST_TSuccess invalidate()
void resetPointerPenInfo()
GHOST_TSuccess setOrder(GHOST_TWindowOrder order)
uint16_t getDPIHint() override
GHOST_TTrackpadInfo getTrackpadInfo()
void updateDirectManipulation()
GHOST_TSuccess setProgressBar(float progress)
GHOST_TSuccess applyWindowDecorationStyle() override
void setTitle(const char *title)
std::string getTitle() const
GHOST_TSuccess setClientSize(uint32_t width, uint32_t height)
bool usingTabletAPI(GHOST_TTabletAPI api) const
GHOST_TSuccess getPointerInfo(std::vector< GHOST_PointerInfoWin32 > &outPointerInfo, WPARAM wParam, LPARAM lParam)
GHOST_TSuccess setClientHeight(uint32_t height)
void loadWintab(bool enable)
GHOST_TabletData getTabletData()
GHOST_Wintab * getWintab() const
HCURSOR getStandardCursor(GHOST_TStandardCursor shape) const
void updateMouseCapture(GHOST_MouseCaptureEventWin32 event)
GHOST_TSuccess setClientWidth(uint32_t width)
GHOST_TSuccess setState(GHOST_TWindowState state)
void getWindowBounds(GHOST_Rect &bounds) const
void getClientBounds(GHOST_Rect &bounds) const
void onPointerHitTest(WPARAM wParam)
void clientToScreen(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const
GHOST_TSuccess endProgressBar()
GHOST_TWindowState getState() const
void * getOSWindow() const
void screenToClient(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const
GHOST_WindowWin32(GHOST_SystemWin32 *system, const char *title, int32_t left, int32_t top, uint32_t width, uint32_t height, GHOST_TWindowState state, GHOST_TDrawingContextType type, const GHOST_ContextParams &context_params, GHOST_WindowWin32 *parent_window, bool dialog, const GHOST_GPUDevice &preferred_device)
void loadCursor(bool visible, GHOST_TStandardCursor cursor_shape) const
void adjustWindowRectForClosestMonitor(LPRECT win_rect, DWORD dwStyle, DWORD dwExStyle)
GHOST_ContextParams want_context_params_
void setCursorGrabAccum(int32_t x, int32_t y)
GHOST_WindowDecorationStyleSettings window_decoration_style_settings_
GHOST_TStandardCursor getCursorShape() const override
GHOST_TSuccess setDrawingContextType(GHOST_TDrawingContextType type) override
int32_t cursor_grab_init_pos_[2]
GHOST_TSuccess releaseNativeHandles()
GHOST_TWindowDecorationStyleFlags window_decoration_style_flags_
bool getValid() const override
bool getCursorVisibility() const override
GHOST_Window(uint32_t width, uint32_t height, GHOST_TWindowState state, const GHOST_ContextParams &context_params, const bool exclusive=false)
GHOST_Rect cursor_grab_bounds_
GHOST_WindowHDRInfo hdr_info_
GHOST_TGrabCursorMode cursor_grab_
static GHOST_Wintab * loadWintab(HWND hwnd)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
int context(const bContext *C, const char *member, bContextDataResult *result)
wchar_t * alloc_utf16_from_8(const char *in8, size_t add)
size_t count_utf_8_from_16(const wchar_t *string16)
int conv_utf_16_to_8(const wchar_t *in16, char *out8, size_t size8)
#define UTF16_ENCODE(in8str)
#define UTF16_UN_ENCODE(in8str)