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;
70 drop_target_(nullptr),
74 preferred_device_(preferred_device),
75 has_mouse_captured_(false),
76 has_grab_mouse_(false),
77 n_pressed_buttons_(0),
81 last_pointer_tablet_data_(GHOST_TABLET_DATA_NONE),
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;
105 RECT win_rect = {left, top, long(left + width), long(top + height)};
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 if (type == GHOST_kDrawingContextTypeOpenGL) {
134 const char *title =
"Blender - Unsupported Graphics Card Configuration";
135 const char *text =
"";
141 "A driver with support for OpenGL 4.3 or higher is required.\n\n"
142 "Qualcomm devices require the \"OpenCL™, OpenGL®, and Vulkan® Compatibility Pack\" "
143 "from the Microsoft Store.\n\n"
144 "Devices using processors older than a Qualcomm Snapdragon 8cx Gen3 are incompatible, "
145 "but may be able to run an emulated x64 copy of Blender, such as a 3.x LTS release.";
151 "A graphics card and driver with support for OpenGL 4.3 or higher is "
152 "required.\n\nInstalling the latest driver for your graphics card might resolve the "
154 if (GetSystemMetrics(SM_CMONITORS) > 1) {
156 "A graphics card and driver with support for OpenGL 4.3 or higher is "
157 "required.\n\nPlugging all monitors into your primary graphics card might resolve "
158 "this issue. Installing the latest driver for your graphics card could also help.";
161 MessageBox(h_wnd_, text, title, MB_OK | MB_ICONERROR);
163 ::ReleaseDC(h_wnd_, h_DC_);
164 ::DestroyWindow(h_wnd_);
169 RegisterTouchWindow(h_wnd_, 0);
173 ::RegisterDragDrop(h_wnd_, drop_target_);
176 ::SetWindowLongPtr(h_wnd_, GWLP_USERDATA, (LONG_PTR)
this);
178 if (!system_->window_focus_) {
180 ::SetWindowPos(h_wnd_, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
194 nCmdShow = SW_SHOWMAXIMIZED;
197 nCmdShow = (system_->window_focus_) ? SW_SHOWMINIMIZED : SW_SHOWMINNOACTIVE;
201 nCmdShow = (system_->window_focus_) ? SW_SHOWNORMAL : SW_SHOWNOACTIVATE;
207 ::ShowWindow(h_wnd_, nCmdShow);
216 CLSID_TaskbarList,
nullptr, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, (LPVOID *)&bar_);
227 if (!direct_manipulation_helper_) {
231 direct_manipulation_helper_->update();
238 if (!direct_manipulation_helper_) {
243 POINTER_INPUT_TYPE pointerType;
244 if (GetPointerType(pointerId, &pointerType) && pointerType == PT_TOUCHPAD) {
245 direct_manipulation_helper_->onPointerHitTest(pointerId);
251 if (!direct_manipulation_helper_) {
255 return direct_manipulation_helper_->getTrackpadInfo();
261 unregisterWindowAppUserModelProperties();
273 FreeLibrary(user32_);
277 if (custom_cursor_) {
278 DestroyCursor(custom_cursor_);
279 custom_cursor_ =
nullptr;
283 ::ReleaseDC(h_wnd_, h_DC_);
290 for (
GHOST_IWindow *iter_win : system_->getWindowManager()->getWindows()) {
292 if (iter_winwin->parent_window_hwnd_ == h_wnd_) {
293 ::SetWindowLongPtr(iter_winwin->h_wnd_, GWLP_HWNDPARENT, 0);
294 iter_winwin->parent_window_hwnd_ = 0;
300 RevokeDragDrop(h_wnd_);
302 drop_target_->Release();
303 drop_target_ =
nullptr;
305 ::SetWindowLongPtr(h_wnd_, GWLP_USERDATA, 0);
306 ::DestroyWindow(h_wnd_);
310 delete direct_manipulation_helper_;
311 direct_manipulation_helper_ =
nullptr;
319 HMONITOR hmonitor = MonitorFromRect(win_rect, MONITOR_DEFAULTTONEAREST);
320 MONITORINFOEX monitor;
321 monitor.cbSize =
sizeof(MONITORINFOEX);
323 GetMonitorInfo(hmonitor, &monitor);
326 LONG width = std::min(monitor.rcWork.right - monitor.rcWork.left,
327 win_rect->right - win_rect->left);
328 LONG height = std::min(monitor.rcWork.bottom - monitor.rcWork.top,
329 win_rect->bottom - win_rect->top);
330 win_rect->left = std::min(std::max(monitor.rcWork.left, win_rect->left),
331 monitor.rcWork.right - width);
332 win_rect->right = win_rect->left + width;
333 win_rect->top = std::min(std::max(monitor.rcWork.top, win_rect->top),
334 monitor.rcWork.bottom - height);
335 win_rect->bottom = win_rect->top + height;
341 user32_,
"AdjustWindowRectExForDpi");
346 if (fpAdjustWindowRectExForDpi) {
348 GetDpiForMonitor(hmonitor, MDT_EFFECTIVE_DPI, &dpiX, &dpiY);
349 fpAdjustWindowRectExForDpi(win_rect, dwStyle & ~WS_OVERLAPPED, FALSE, dwExStyle, dpiX);
352 AdjustWindowRectEx(win_rect, dwStyle & ~WS_OVERLAPPED, FALSE, dwExStyle);
356 win_rect->top = std::max(monitor.rcWork.top, win_rect->top);
371 return (
void *)h_wnd_;
377 ::SetWindowTextW(h_wnd_, (
wchar_t *)title_16);
383 std::wstring wtitle(::GetWindowTextLengthW(h_wnd_) + 1,
L'\0');
384 ::GetWindowTextW(h_wnd_, &wtitle[0], wtitle.capacity());
395 constexpr DWORD caption_color_attr = 35;
399 const COLORREF colorref = RGB(
400 char(color[0] * 255.0f),
char(color[1] * 255.0f),
char(color[2] * 255.0f));
401 if (!SUCCEEDED(DwmSetWindowAttribute(h_wnd_, caption_color_attr, &colorref,
sizeof(colorref))))
412 ::GetWindowRect(h_wnd_, &rect);
413 bounds.
b_ = rect.bottom;
414 bounds.
l_ = rect.left;
415 bounds.
r_ = rect.right;
416 bounds.
t_ = rect.top;
423 if (!IsIconic(h_wnd_)) {
424 ::GetClientRect(h_wnd_, &rect);
428 ::ClientToScreen(h_wnd_, &coord);
433 coord.x = rect.right;
434 coord.y = rect.bottom;
435 ::ClientToScreen(h_wnd_, &coord);
457 success = ::SetWindowPos(h_wnd_, HWND_TOP, 0, 0, cx, cy, SWP_NOMOVE | SWP_NOZORDER) ?
476 success = ::SetWindowPos(h_wnd_, HWND_TOP, 0, 0, cx, cy, SWP_NOMOVE | SWP_NOZORDER) ?
495 success = ::SetWindowPos(h_wnd_, HWND_TOP, 0, 0, cx, cy, SWP_NOMOVE | SWP_NOZORDER) ?
507 if (::IsIconic(h_wnd_)) {
510 else if (::IsZoomed(h_wnd_)) {
511 LONG_PTR result = ::GetWindowLongPtr(h_wnd_, GWL_STYLE);
522 POINT point = {inX, inY};
523 ::ScreenToClient(h_wnd_, &point);
533 POINT point = {inX, inY};
534 ::ClientToScreen(h_wnd_, &point);
542 LONG_PTR style = GetWindowLongPtr(h_wnd_, GWL_STYLE) | WS_CAPTION;
544 wp.length =
sizeof(WINDOWPLACEMENT);
545 ::GetWindowPlacement(h_wnd_, &wp);
549 wp.showCmd = SW_MINIMIZE;
552 wp.showCmd = SW_SHOWMAXIMIZED;
556 normal_state_ = curstate;
558 wp.showCmd = SW_SHOWMAXIMIZED;
559 wp.ptMaxPosition.x = 0;
560 wp.ptMaxPosition.y = 0;
561 style &= ~(WS_CAPTION | WS_MAXIMIZE);
567 wp.showCmd = SW_SHOWMAXIMIZED;
571 wp.showCmd = SW_SHOWNORMAL;
575 ::SetWindowLongPtr(h_wnd_, GWL_STYLE, style);
578 ::SetWindowPos(h_wnd_, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
584 HWND hWndInsertAfter, hWndToRaise;
587 hWndInsertAfter = HWND_BOTTOM;
588 hWndToRaise = ::GetWindow(h_wnd_, GW_HWNDNEXT);
594 hWndInsertAfter = HWND_TOP;
595 hWndToRaise =
nullptr;
598 if (::SetWindowPos(h_wnd_, hWndInsertAfter, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE) == FALSE) {
603 ::SetWindowPos(hWndToRaise, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE) == FALSE)
625#ifdef WITH_VULKAN_BACKEND
626 case GHOST_kDrawingContextTypeVulkan: {
629 if (context->initializeDrawingContext()) {
637#ifdef WITH_OPENGL_BACKEND
638 case GHOST_kDrawingContextTypeOpenGL: {
639 for (
int minor = 6; minor >= 3; --minor) {
645 WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
651 if (
context->initializeDrawingContext()) {
660 case GHOST_kDrawingContextTypeD3D: {
663 if (
context->initializeDrawingContext()) {
678 if (has_mouse_captured_) {
679 has_grab_mouse_ =
false;
680 n_pressed_buttons_ = 0;
681 has_mouse_captured_ =
false;
694 n_pressed_buttons_++;
697 if (n_pressed_buttons_) {
698 n_pressed_buttons_--;
702 has_grab_mouse_ =
true;
705 has_grab_mouse_ =
false;
709 if (!n_pressed_buttons_ && !has_grab_mouse_ && has_mouse_captured_) {
711 has_mouse_captured_ =
false;
713 else if ((n_pressed_buttons_ || has_grab_mouse_) && !has_mouse_captured_) {
714 ::SetCapture(h_wnd_);
715 has_mouse_captured_ =
true;
722 HANDLE cursor =
nullptr;
723 uint32_t flags = LR_SHARED | LR_DEFAULTSIZE;
728 if (custom_cursor_) {
729 return custom_cursor_;
735 cursor = ::LoadImage(
nullptr, IDC_SIZEALL, IMAGE_CURSOR, cx, cy, flags);
738 cursor = ::LoadImage(
nullptr, IDC_HELP, IMAGE_CURSOR, cx, cy, flags);
741 cursor = ::LoadImage(
nullptr, IDC_WAIT, IMAGE_CURSOR, cx, cy, flags);
744 cursor = ::LoadImage(
nullptr, IDC_IBEAM, IMAGE_CURSOR, cx, cy, flags);
747 cursor = ::LoadImage(
nullptr, IDC_UPARROW, IMAGE_CURSOR, cx, cy, flags);
750 cursor = ::LoadImage(
nullptr, IDC_SIZENWSE, IMAGE_CURSOR, cx, cy, flags);
753 cursor = ::LoadImage(
nullptr, IDC_SIZENESW, IMAGE_CURSOR, cx, cy, flags);
756 cursor = ::LoadImage(
nullptr, IDC_SIZENWSE, IMAGE_CURSOR, cx, cy, flags);
759 cursor = ::LoadImage(
nullptr, IDC_SIZENESW, IMAGE_CURSOR, cx, cy, flags);
768 if (cursor ==
nullptr) {
769 cursor = ::LoadImage(
nullptr, IDC_ARROW, IMAGE_CURSOR, cx, cy, flags);
772 return (HCURSOR)cursor;
778 while (::ShowCursor(FALSE) >= 0) {
783 while (::ShowCursor(TRUE) < 0) {
789 if (cursor ==
nullptr) {
795GHOST_TSuccess GHOST_WindowWin32::setWindowCursorVisibility(
bool visible)
797 if (::GetForegroundWindow() == h_wnd_) {
812 setWindowCursorVisibility(
false);
820 setWindowCursorVisibility(
true);
827 system_->getCursorPosition(pos[0], pos[1]);
828 system_->setCursorPosition(pos[0], pos[1]);
843 if (::GetForegroundWindow() == h_wnd_) {
856 std::vector<GHOST_PointerInfoWin32> &outPointerInfo, WPARAM wParam, LPARAM )
859 int32_t isPrimary = IS_POINTER_PRIMARY_WPARAM(wParam);
861 uint32_t outCount = 0;
863 if (!(GetPointerPenInfoHistory(pointerId, &outCount,
nullptr))) {
867 std::vector<POINTER_PEN_INFO> pointerPenInfo(outCount);
868 outPointerInfo.resize(outCount);
870 if (!(GetPointerPenInfoHistory(pointerId, &outCount, pointerPenInfo.data()))) {
874 for (uint32_t i = 0; i < outCount; i++) {
875 POINTER_INFO pointerApiInfo = pointerPenInfo[i].pointerInfo;
877 outPointerInfo[i].pointerId = pointerId;
878 outPointerInfo[i].isPrimary = isPrimary;
880 switch (pointerApiInfo.ButtonChangeType) {
881 case POINTER_CHANGE_FIRSTBUTTON_DOWN:
882 case POINTER_CHANGE_FIRSTBUTTON_UP:
885 case POINTER_CHANGE_SECONDBUTTON_DOWN:
886 case POINTER_CHANGE_SECONDBUTTON_UP:
889 case POINTER_CHANGE_THIRDBUTTON_DOWN:
890 case POINTER_CHANGE_THIRDBUTTON_UP:
893 case POINTER_CHANGE_FOURTHBUTTON_DOWN:
894 case POINTER_CHANGE_FOURTHBUTTON_UP:
897 case POINTER_CHANGE_FIFTHBUTTON_DOWN:
898 case POINTER_CHANGE_FIFTHBUTTON_UP:
905 outPointerInfo[i].pixelLocation = pointerApiInfo.ptPixelLocation;
907 outPointerInfo[i].tabletData.Pressure = 1.0f;
908 outPointerInfo[i].tabletData.Xtilt = 0.0f;
909 outPointerInfo[i].tabletData.Ytilt = 0.0f;
912 if (pointerPenInfo[i].penMask & PEN_MASK_PRESSURE) {
913 outPointerInfo[i].tabletData.Pressure = pointerPenInfo[i].pressure / 1024.0f;
916 if (pointerPenInfo[i].penFlags & PEN_FLAG_ERASER) {
920 if (pointerPenInfo[i].penMask & PEN_MASK_TILT_X) {
924 outPointerInfo[i].tabletData.Xtilt = std::clamp(
925 pointerPenInfo[i].tiltX / 90.0f, -1.0f, 1.0f);
928 if (pointerPenInfo[i].penMask & PEN_MASK_TILT_Y) {
932 outPointerInfo[i].tabletData.Ytilt = std::clamp(
933 pointerPenInfo[i].tiltY / 90.0f, -1.0f, 1.0f);
937 if (!outPointerInfo.empty()) {
938 last_pointer_tablet_data_ = outPointerInfo.back().tabletData;
946 last_pointer_tablet_data_ = GHOST_TABLET_DATA_NONE;
965 if (system_->getCursorPosition(
x,
y)) {
970 wintab_->gainFocus();
987 if (system_->getTabletAPI() == api) {
991 if (wintab_ && wintab_->devicesPresent()) {
1006 return wintab_ ? wintab_->getLastTabletData() : GHOST_TABLET_DATA_NONE;
1009 return last_pointer_tablet_data_;
1016 DWORD pcbData =
sizeof(lightMode);
1017 if (RegGetValueW(HKEY_CURRENT_USER,
1018 L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize\\",
1019 L"AppsUseLightTheme",
1023 &pcbData) == ERROR_SUCCESS)
1025 BOOL DarkMode = !lightMode;
1030 DwmSetWindowAttribute(this->h_wnd_, 20, &DarkMode,
sizeof(DarkMode));
1036 if (direct_manipulation_helper_) {
1037 direct_manipulation_helper_->setDPI(
getDPIHint());
1043 if (user32_ && system_->native_pixel_) {
1045 user32_,
"GetDpiForWindow");
1047 if (fpGetDpiForWindow) {
1048 return fpGetDpiForWindow(this->h_wnd_);
1052 return USER_DEFAULT_SCREEN_DPI;
1058 ch = ((ch >> 1) & 0x55) | ((ch << 1) & 0xAA);
1059 ch = ((ch >> 2) & 0x33) | ((ch << 2) & 0xCC);
1060 ch = ((ch >> 4) & 0x0F) | ((ch << 4) & 0xF0);
1066static uint16_t uns16ReverseBits(uint16_t shrt)
1068 shrt = ((shrt >> 1) & 0x5555) | ((shrt << 1) & 0xAAAA);
1069 shrt = ((shrt >> 2) & 0x3333) | ((shrt << 2) & 0xCCCC);
1070 shrt = ((shrt >> 4) & 0x0F0F) | ((shrt << 4) & 0xF0F0);
1071 shrt = ((shrt >> 8) & 0x00FF) | ((shrt << 8) & 0xFF00);
1076GHOST_TSuccess GHOST_WindowWin32::setWindowCustomCursorShape(
const uint8_t *bitmap,
1077 const uint8_t *
mask,
1079 const int hot_spot[2],
1094 HCURSOR previous_cursor = custom_cursor_;
1096 memset(&andData, 0xFF,
sizeof(andData));
1097 memset(&xorData, 0,
sizeof(xorData));
1099 for (
y = 0;
y <
size[1];
y++) {
1102 for (
x = cols - 1;
x >= 0;
x--) {
1108 xorData[
y] = fullBitRow & fullMaskRow;
1109 andData[
y] = ~fullMaskRow;
1112 custom_cursor_ = ::CreateCursor(
1113 ::GetModuleHandle(0), hot_spot[0], hot_spot[1], 32, 32, andData, xorData);
1115 if (!custom_cursor_) {
1119 if (::GetForegroundWindow() == h_wnd_) {
1123 if (previous_cursor) {
1124 DestroyCursor(previous_cursor);
1134 BITMAPV5HEADER header;
1135 memset(&header, 0,
sizeof(BITMAPV5HEADER));
1136 header.bV5Size =
sizeof(BITMAPV5HEADER);
1137 header.bV5Width = (LONG)size[0];
1138 header.bV5Height = (LONG)size[1];
1139 header.bV5Planes = 1;
1140 header.bV5BitCount = 32;
1141 header.bV5Compression = BI_BITFIELDS;
1142 header.bV5RedMask = 0x00FF0000;
1143 header.bV5GreenMask = 0x0000FF00;
1144 header.bV5BlueMask = 0x000000FF;
1145 header.bV5AlphaMask = 0xFF000000;
1147 HDC hdc = GetDC(h_wnd_);
1148 void *bits =
nullptr;
1149 HBITMAP bmp = CreateDIBSection(
1150 hdc, (BITMAPINFO *)&header, DIB_RGB_COLORS, (
void **)&bits, NULL, (DWORD)0);
1151 ReleaseDC(NULL, hdc);
1156 for (
int y = h - 1;
y >= 0;
y--) {
1157 for (
int x = 0;
x <
w;
x++) {
1158 int i = (
y *
w * 4) + (
x * 4);
1163 *ptr++ = (a << 24) | (r << 16) | (g << 8) |
b;
1167 HBITMAP empty_mask = CreateBitmap(size[0], size[1], 1, 1, NULL);
1169 icon_info.fIcon = FALSE;
1170 icon_info.xHotspot = (DWORD)hot_spot[0];
1171 icon_info.yHotspot = (DWORD)hot_spot[1];
1172 icon_info.hbmMask = empty_mask;
1173 icon_info.hbmColor = bmp;
1175 HCURSOR previous_cursor = custom_cursor_;
1177 custom_cursor_ = CreateIconIndirect(&icon_info);
1179 DeleteObject(empty_mask);
1181 if (!custom_cursor_) {
1185 if (::GetForegroundWindow() == h_wnd_) {
1189 if (previous_cursor) {
1190 DestroyCursor(previous_cursor);
1199 if (bar_ && S_OK == bar_->SetProgressValue(h_wnd_, 10000 * progress, 10000)) {
1208 if (bar_ && S_OK == bar_->SetProgressState(h_wnd_,
TBPF_NOPROGRESS)) {
1215#ifdef WITH_INPUT_IME
1218 ime_input_.BeginIME(h_wnd_,
GHOST_Rect(
x,
y - h,
x,
y), completed);
1221void GHOST_WindowWin32::endIME()
1223 ime_input_.EndIME(h_wnd_);
1227void GHOST_WindowWin32::registerWindowAppUserModelProperties()
1229 IPropertyStore *pstore;
1230 char blender_path[MAX_PATH];
1231 wchar_t shell_command[MAX_PATH];
1234 GetModuleFileName(0, blender_path,
sizeof(blender_path));
1235 char *blender_app = strstr(blender_path,
"blender.exe");
1240 HRESULT hr = SHGetPropertyStoreForWindow(h_wnd_, IID_PPV_ARGS(&pstore));
1241 if (!SUCCEEDED(hr)) {
1247 strcpy(blender_app,
"blender-launcher.exe");
1248 wsprintfW(shell_command,
L"\"%S\"", blender_path);
1251 PROPVARIANT propvar;
1252 hr = InitPropVariantFromString(BLENDER_WIN_APPID_16, &propvar);
1253 hr = pstore->SetValue(PKEY_AppUserModel_ID, propvar);
1254 hr = InitPropVariantFromString(shell_command, &propvar);
1255 hr = pstore->SetValue(PKEY_AppUserModel_RelaunchCommand, propvar);
1256 hr = InitPropVariantFromString(BLENDER_WIN_APPID_FRIENDLY_NAME_16, &propvar);
1257 hr = pstore->SetValue(PKEY_AppUserModel_RelaunchDisplayNameResource, propvar);
1265void GHOST_WindowWin32::unregisterWindowAppUserModelProperties()
1267 IPropertyStore *pstore;
1268 HRESULT hr = SHGetPropertyStoreForWindow(h_wnd_, IID_PPV_ARGS(&pstore));
1269 if (SUCCEEDED(hr)) {
1271 PropVariantInit(&value);
1272 pstore->SetValue(PKEY_AppUserModel_ID, value);
1273 pstore->SetValue(PKEY_AppUserModel_RelaunchCommand, value);
1274 pstore->SetValue(PKEY_AppUserModel_RelaunchDisplayNameResource, value);
1285 HMONITOR hmonitor = ::MonitorFromWindow(h_wnd_, MONITOR_DEFAULTTONEAREST);
1290 MONITORINFOEXW monitor_info = {};
1291 monitor_info.cbSize =
sizeof(MONITORINFOEXW);
1292 if (!::GetMonitorInfoW(hmonitor, &monitor_info)) {
1297 UINT32 path_count = 0;
1298 UINT32 mode_count = 0;
1299 if (::GetDisplayConfigBufferSizes(QDC_ONLY_ACTIVE_PATHS, &path_count, &mode_count) !=
1305 std::vector<DISPLAYCONFIG_PATH_INFO> paths(path_count);
1306 std::vector<DISPLAYCONFIG_MODE_INFO> modes(mode_count);
1307 if (::QueryDisplayConfig(
1308 QDC_ONLY_ACTIVE_PATHS, &path_count, paths.data(), &mode_count, modes.data(),
nullptr) !=
1317 for (
const DISPLAYCONFIG_PATH_INFO &path : paths) {
1318 DISPLAYCONFIG_SOURCE_DEVICE_NAME device_name = {};
1319 device_name.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME;
1320 device_name.header.size =
sizeof(device_name);
1321 device_name.header.adapterId = path.sourceInfo.adapterId;
1322 device_name.header.id = path.sourceInfo.id;
1324 if (::DisplayConfigGetDeviceInfo(&device_name.header) != ERROR_SUCCESS) {
1327 if (wcscmp(monitor_info.szDevice, device_name.viewGdiDeviceName) != 0) {
1332 DISPLAYCONFIG_GET_ADVANCED_COLOR_INFO color_info = {};
1333 color_info.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_ADVANCED_COLOR_INFO;
1334 color_info.header.size =
sizeof(color_info);
1335 color_info.header.adapterId = path.targetInfo.adapterId;
1336 color_info.header.id = path.targetInfo.id;
1338 if (::DisplayConfigGetDeviceInfo(&color_info.header) == ERROR_SUCCESS) {
1342 color_info.advancedColorEnabled;
1348 DISPLAYCONFIG_SDR_WHITE_LEVEL white_level = {};
1349 white_level.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_SDR_WHITE_LEVEL;
1350 white_level.header.size =
sizeof(white_level);
1351 white_level.header.adapterId = path.targetInfo.adapterId;
1352 white_level.header.id = path.targetInfo.id;
1354 if (::DisplayConfigGetDeviceInfo(&white_level.header) == ERROR_SUCCESS) {
1355 if (white_level.SDRWhiteLevel > 0) {
1358 info.
sdr_white_level =
static_cast<float>(white_level.SDRWhiteLevel) / 1000.0f;
#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
@ GHOST_kTabletModeEraser
@ GHOST_kTabletModeStylus
GHOST_TDrawingContextType
@ GHOST_kWindowOrderBottom
#define GHOST_WINDOW_HDR_INFO_NONE
@ GHOST_kButtonMaskButton4
@ GHOST_kButtonMaskButton5
@ GHOST_kButtonMaskMiddle
@ GHOST_kTabletWinPointer
@ GHOST_kDecorationColoredTitleBar
#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)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
GHOST_ContextD3D(const GHOST_ContextParams &context_params, HWND hWnd)
GHOST_ContextVK(const GHOST_ContextParams &context_params, GHOST_TVulkanPlatformType platform, Window window, Display *display, wl_surface *wayland_surface, wl_display *wayland_display, const GHOST_ContextVK_WindowInfo *wayland_window_info, int contextMajorVersion, int contextMinorVersion, const GHOST_GPUDevice &preferred_device, const GHOST_WindowHDRInfo *hdr_info_=nullptr)
GHOST_ContextWGL(const GHOST_ContextParams &context_params, bool alphaBackground, HWND hWnd, HDC hDC, int contextProfileMask, int contextMajorVersion, int contextMinorVersion, int contextFlags, int contextResetNotificationStrategy)
static GHOST_DirectManipulationHelper * create(HWND hWnd, uint16_t dpi)
GHOST_DropTargetWin32(GHOST_WindowWin32 *window, GHOST_SystemWin32 *system)
static GHOST_ISystem * getSystem()
virtual bool getCursorVisibility() const =0
virtual bool isInside(int32_t x, int32_t y) const
virtual int32_t getHeight() const
virtual int32_t getWidth() const
GHOST_Rect(int32_t l=0, int32_t t=0, int32_t r=0, int32_t b=0)
uint64_t performanceCounterToMillis(__int64 perf_ticks) const
GHOST_TTabletAPI getTabletAPI()
GHOST_TSuccess setClientSize(uint32_t width, uint32_t height) override
void resetPointerPenInfo()
std::string getTitle() const override
GHOST_TSuccess setState(GHOST_TWindowState state) override
uint16_t getDPIHint() override
GHOST_TTrackpadInfo getTrackpadInfo()
void updateDirectManipulation()
GHOST_TSuccess setOrder(GHOST_TWindowOrder order) override
bool getValid() const override
GHOST_TSuccess invalidate() override
GHOST_TSuccess applyWindowDecorationStyle() override
void getClientBounds(GHOST_Rect &bounds) const override
GHOST_TSuccess endProgressBar() override
void clientToScreen(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const override
bool usingTabletAPI(GHOST_TTabletAPI api) const
GHOST_TSuccess getPointerInfo(std::vector< GHOST_PointerInfoWin32 > &outPointerInfo, WPARAM wParam, LPARAM lParam)
void screenToClient(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const override
void setTitle(const char *title) override
void loadWintab(bool enable)
GHOST_TabletData getTabletData()
GHOST_Wintab * getWintab() const
HCURSOR getStandardCursor(GHOST_TStandardCursor shape) const
void updateMouseCapture(GHOST_MouseCaptureEventWin32 event)
GHOST_TWindowState getState() const override
GHOST_TSuccess setProgressBar(float progress) override
void onPointerHitTest(WPARAM wParam)
void getWindowBounds(GHOST_Rect &bounds) const override
void * getOSWindow() const override
GHOST_TSuccess setClientHeight(uint32_t height) override
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)
bool isDialog() const override
void loadCursor(bool visible, GHOST_TStandardCursor cursor_shape) const
GHOST_TSuccess setClientWidth(uint32_t width) override
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
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 size(const AssetLibraryReference *library_reference)
int context(const bContext *C, const char *member, bContextDataResult *result)
const char * BLI_getenv(const char *env) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
float colored_titlebar_bg_color[3]
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)