Changeset View
Changeset View
Standalone View
Standalone View
intern/ghost/intern/GHOST_WindowWin32.cpp
| Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | : GHOST_Window(width, height, state, wantStereoVisual, false), | ||||
| m_customCursor(0), | m_customCursor(0), | ||||
| m_wantAlphaBackground(alphaBackground), | m_wantAlphaBackground(alphaBackground), | ||||
| m_Bar(NULL), | m_Bar(NULL), | ||||
| m_wintab(NULL), | m_wintab(NULL), | ||||
| m_lastPointerTabletData(GHOST_TABLET_DATA_NONE), | m_lastPointerTabletData(GHOST_TABLET_DATA_NONE), | ||||
| m_normal_state(GHOST_kWindowStateNormal), | m_normal_state(GHOST_kWindowStateNormal), | ||||
| m_user32(::LoadLibrary("user32.dll")), | m_user32(::LoadLibrary("user32.dll")), | ||||
| m_parentWindowHwnd(parentwindow ? parentwindow->m_hWnd : HWND_DESKTOP), | m_parentWindowHwnd(parentwindow ? parentwindow->m_hWnd : HWND_DESKTOP), | ||||
| m_directManipulationHelper(NULL), | |||||
| m_debug_context(is_debug) | m_debug_context(is_debug) | ||||
| { | { | ||||
| DWORD style = parentwindow ? | DWORD style = parentwindow ? | ||||
| WS_POPUPWINDOW | WS_CAPTION | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SIZEBOX : | WS_POPUPWINDOW | WS_CAPTION | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SIZEBOX : | ||||
| WS_OVERLAPPEDWINDOW; | WS_OVERLAPPEDWINDOW; | ||||
| if (state == GHOST_kWindowStateFullScreen) { | if (state == GHOST_kWindowStateFullScreen) { | ||||
| style |= WS_MAXIMIZE; | style |= WS_MAXIMIZE; | ||||
| ▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | #endif | ||||
| /* Initialize Wintab. */ | /* Initialize Wintab. */ | ||||
| if (system->getTabletAPI() != GHOST_kTabletWinPointer) { | if (system->getTabletAPI() != GHOST_kTabletWinPointer) { | ||||
| loadWintab(GHOST_kWindowStateMinimized != state); | loadWintab(GHOST_kWindowStateMinimized != state); | ||||
| } | } | ||||
| /* Allow the showing of a progress bar on the taskbar. */ | /* Allow the showing of a progress bar on the taskbar. */ | ||||
| CoCreateInstance( | CoCreateInstance( | ||||
| CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, (LPVOID *)&m_Bar); | CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, (LPVOID *)&m_Bar); | ||||
| /* Initialize Direct Manipulation. */ | |||||
LazyDodo: Is this test still needed? it is seemingly not using `m_user32` for anything , and given our… | |||||
| m_directManipulationHelper = GHOST_DirectManipulationHelper::create(m_hWnd, getDPIHint()); | |||||
| } | |||||
| void GHOST_WindowWin32::updateDirectManipulation() | |||||
| { | |||||
| if (!m_directManipulationHelper) { | |||||
| return; | |||||
| } | |||||
| m_directManipulationHelper->update(); | |||||
| } | |||||
| void GHOST_WindowWin32::onPointerHitTest(WPARAM wParam) | |||||
| { | |||||
| /* Only DM_POINTERHITTEST can be the first message of input sequence of touchpad input. */ | |||||
| if (!m_directManipulationHelper) { | |||||
| return; | |||||
| } | |||||
| UINT32 pointerId = GET_POINTERID_WPARAM(wParam); | |||||
| POINTER_INPUT_TYPE pointerType; | |||||
| if (GetPointerType(pointerId, &pointerType) && pointerType == PT_TOUCHPAD) { | |||||
| m_directManipulationHelper->onPointerHitTest(pointerId); | |||||
| } | |||||
| } | |||||
| GHOST_TTrackpadInfo GHOST_WindowWin32::getTrackpadInfo() | |||||
| { | |||||
| if (!m_directManipulationHelper) { | |||||
| return {0, 0, 0}; | |||||
| } | |||||
| return m_directManipulationHelper->getTrackpadInfo(); | |||||
| } | } | ||||
| GHOST_WindowWin32::~GHOST_WindowWin32() | GHOST_WindowWin32::~GHOST_WindowWin32() | ||||
| { | { | ||||
| if (m_Bar) { | if (m_Bar) { | ||||
| m_Bar->SetProgressState(m_hWnd, TBPF_NOPROGRESS); | m_Bar->SetProgressState(m_hWnd, TBPF_NOPROGRESS); | ||||
| m_Bar->Release(); | m_Bar->Release(); | ||||
| m_Bar = NULL; | m_Bar = NULL; | ||||
| Show All 33 Lines | if (m_dropTarget) { | ||||
| // Release our reference of the DropTarget and it will delete itself eventually. | // Release our reference of the DropTarget and it will delete itself eventually. | ||||
| m_dropTarget->Release(); | m_dropTarget->Release(); | ||||
| m_dropTarget = NULL; | m_dropTarget = NULL; | ||||
| } | } | ||||
| ::SetWindowLongPtr(m_hWnd, GWLP_USERDATA, NULL); | ::SetWindowLongPtr(m_hWnd, GWLP_USERDATA, NULL); | ||||
| ::DestroyWindow(m_hWnd); | ::DestroyWindow(m_hWnd); | ||||
| m_hWnd = 0; | m_hWnd = 0; | ||||
| } | } | ||||
| delete m_directManipulationHelper; | |||||
| m_directManipulationHelper = NULL; | |||||
| } | } | ||||
| void GHOST_WindowWin32::adjustWindowRectForClosestMonitor(LPRECT win_rect, | void GHOST_WindowWin32::adjustWindowRectForClosestMonitor(LPRECT win_rect, | ||||
| DWORD dwStyle, | DWORD dwStyle, | ||||
| DWORD dwExStyle) | DWORD dwExStyle) | ||||
| { | { | ||||
| /* Get Details of the closest monitor. */ | /* Get Details of the closest monitor. */ | ||||
| HMONITOR hmonitor = MonitorFromRect(win_rect, MONITOR_DEFAULTTONEAREST); | HMONITOR hmonitor = MonitorFromRect(win_rect, MONITOR_DEFAULTTONEAREST); | ||||
| ▲ Show 20 Lines • Show All 142 Lines • ▼ Show 20 Lines | GHOST_TSuccess GHOST_WindowWin32::setClientSize(uint32_t width, uint32_t height) | ||||
| GHOST_TSuccess success; | GHOST_TSuccess success; | ||||
| GHOST_Rect cBnds, wBnds; | GHOST_Rect cBnds, wBnds; | ||||
| getClientBounds(cBnds); | getClientBounds(cBnds); | ||||
| if ((cBnds.getWidth() != (int32_t)width) || (cBnds.getHeight() != (int32_t)height)) { | if ((cBnds.getWidth() != (int32_t)width) || (cBnds.getHeight() != (int32_t)height)) { | ||||
| getWindowBounds(wBnds); | getWindowBounds(wBnds); | ||||
| int cx = wBnds.getWidth() + width - cBnds.getWidth(); | int cx = wBnds.getWidth() + width - cBnds.getWidth(); | ||||
| int cy = wBnds.getHeight() + height - cBnds.getHeight(); | int cy = wBnds.getHeight() + height - cBnds.getHeight(); | ||||
| success = ::SetWindowPos(m_hWnd, HWND_TOP, 0, 0, cx, cy, SWP_NOMOVE | SWP_NOZORDER) ? | success = ::SetWindowPos(m_hWnd, HWND_TOP, 0, 0, cx, cy, SWP_NOMOVE | SWP_NOZORDER) ? | ||||
| GHOST_kSuccess : | GHOST_kSuccess : | ||||
Done Inline ActionsWhat is this magic 125 number? Can it be defined just once instead of repeated? brecht: What is this magic 125 number? Can it be defined just once instead of repeated? | |||||
| GHOST_kFailure; | GHOST_kFailure; | ||||
| } | } | ||||
| else { | else { | ||||
| success = GHOST_kSuccess; | success = GHOST_kSuccess; | ||||
| } | } | ||||
| return success; | return success; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | case GHOST_kWindowStateFullScreen: | ||||
| } | } | ||||
| wp.showCmd = SW_SHOWMAXIMIZED; | wp.showCmd = SW_SHOWMAXIMIZED; | ||||
| wp.ptMaxPosition.x = 0; | wp.ptMaxPosition.x = 0; | ||||
| wp.ptMaxPosition.y = 0; | wp.ptMaxPosition.y = 0; | ||||
| style &= ~(WS_CAPTION | WS_MAXIMIZE); | style &= ~(WS_CAPTION | WS_MAXIMIZE); | ||||
| break; | break; | ||||
| case GHOST_kWindowStateNormal: | case GHOST_kWindowStateNormal: | ||||
| default: | default: | ||||
| if (curstate == GHOST_kWindowStateFullScreen && | if (curstate == GHOST_kWindowStateFullScreen && | ||||
Not Done Inline ActionsIs the concept of a gesture state needed, does that state need to be stored at all? I would expect it to send both events if both zoom and pan changes. brecht: Is the concept of a gesture state needed, does that state need to be stored at all?
I would… | |||||
Not Done Inline ActionsViewport doesn't change scale until DM recognizes pinch gesture. When it does, pan updates are incorrect (fast diagonal movement). pembem22: Viewport doesn't change scale until DM recognizes pinch gesture. When it does, pan updates are… | |||||
Not Done Inline Actions@Brecht Van Lommel (brecht) the translation components of the transformation matrix become nonsensical when scaling occurs. DM's GetCenterPoint had the same problem. This issue is documented in Chrome's source. nicholas_rishel: @brecht the translation components of the transformation matrix become nonsensical when scaling… | |||||
| m_normal_state == GHOST_kWindowStateMaximized) { | m_normal_state == GHOST_kWindowStateMaximized) { | ||||
| wp.showCmd = SW_SHOWMAXIMIZED; | wp.showCmd = SW_SHOWMAXIMIZED; | ||||
| m_normal_state = GHOST_kWindowStateNormal; | m_normal_state = GHOST_kWindowStateNormal; | ||||
| } | } | ||||
| else { | else { | ||||
| wp.showCmd = SW_SHOWNORMAL; | wp.showCmd = SW_SHOWNORMAL; | ||||
| } | } | ||||
| break; | break; | ||||
| ▲ Show 20 Lines • Show All 538 Lines • ▼ Show 20 Lines | if (RegGetValueW(HKEY_CURRENT_USER, | ||||
| BOOL DarkMode = !lightMode; | BOOL DarkMode = !lightMode; | ||||
| /* 20 == DWMWA_USE_IMMERSIVE_DARK_MODE in Windows 11 SDK. This value was undocumented for | /* 20 == DWMWA_USE_IMMERSIVE_DARK_MODE in Windows 11 SDK. This value was undocumented for | ||||
| * Windows 10 versions 2004 and later, supported for Windows 11 Build 22000 and later. */ | * Windows 10 versions 2004 and later, supported for Windows 11 Build 22000 and later. */ | ||||
| DwmSetWindowAttribute(this->m_hWnd, 20, &DarkMode, sizeof(DarkMode)); | DwmSetWindowAttribute(this->m_hWnd, 20, &DarkMode, sizeof(DarkMode)); | ||||
| } | } | ||||
| } | } | ||||
| void GHOST_WindowWin32::updateDPI() | |||||
| { | |||||
| if (m_directManipulationHelper) { | |||||
| m_directManipulationHelper->setDPI(getDPIHint()); | |||||
| } | |||||
| } | |||||
| uint16_t GHOST_WindowWin32::getDPIHint() | uint16_t GHOST_WindowWin32::getDPIHint() | ||||
| { | { | ||||
| if (m_user32) { | if (m_user32) { | ||||
| GHOST_WIN32_GetDpiForWindow fpGetDpiForWindow = (GHOST_WIN32_GetDpiForWindow)::GetProcAddress( | GHOST_WIN32_GetDpiForWindow fpGetDpiForWindow = (GHOST_WIN32_GetDpiForWindow)::GetProcAddress( | ||||
| m_user32, "GetDpiForWindow"); | m_user32, "GetDpiForWindow"); | ||||
| if (fpGetDpiForWindow) { | if (fpGetDpiForWindow) { | ||||
| return fpGetDpiForWindow(this->m_hWnd); | return fpGetDpiForWindow(this->m_hWnd); | ||||
| ▲ Show 20 Lines • Show All 100 Lines • Show Last 20 Lines | |||||
Is this test still needed? it is seemingly not using m_user32 for anything , and given our minimum requirement now is 8.1 the other test will also always be true.