diff --git a/Aerofoil/GpAppEnvironment.cpp b/Aerofoil/GpAppEnvironment.cpp index 20ede7a..9faec13 100644 --- a/Aerofoil/GpAppEnvironment.cpp +++ b/Aerofoil/GpAppEnvironment.cpp @@ -94,9 +94,9 @@ void GpAppEnvironment::Render() GpAppInterface_Get()->PL_Render(m_displayDriver); } -void GpAppEnvironment::AdjustRequestedResolution(unsigned int &width, unsigned int &height) +bool GpAppEnvironment::AdjustRequestedResolution(unsigned int &width, unsigned int &height) { - GpAppInterface_Get()->PL_AdjustRequestedResolution(width, height); + return GpAppInterface_Get()->PL_AdjustRequestedResolution(width, height); } void GpAppEnvironment::SetDisplayDriver(IGpDisplayDriver *displayDriver) diff --git a/Aerofoil/GpAppEnvironment.h b/Aerofoil/GpAppEnvironment.h index 5b9bd74..4b3cc3f 100644 --- a/Aerofoil/GpAppEnvironment.h +++ b/Aerofoil/GpAppEnvironment.h @@ -28,7 +28,7 @@ public: GpDisplayDriverTickStatus_t Tick(IGpFiber *vosFiber); void Render(); - void AdjustRequestedResolution(unsigned int &width, unsigned int &height); + bool AdjustRequestedResolution(unsigned int &width, unsigned int &height); void SetDisplayDriver(IGpDisplayDriver *displayDriver); void SetAudioDriver(IGpAudioDriver *audioDriver); diff --git a/Aerofoil/GpMain.cpp b/Aerofoil/GpMain.cpp index 6824738..d79cedb 100644 --- a/Aerofoil/GpMain.cpp +++ b/Aerofoil/GpMain.cpp @@ -28,9 +28,9 @@ namespace static_cast(context)->Render(); } - void AdjustRequestedResolution(void *context, unsigned int &width, unsigned int &height) + bool AdjustRequestedResolution(void *context, unsigned int &width, unsigned int &height) { - static_cast(context)->AdjustRequestedResolution(width, height); + return static_cast(context)->AdjustRequestedResolution(width, height); } } diff --git a/GpApp/GpAppInterface.cpp b/GpApp/GpAppInterface.cpp index b00209f..9c01d3b 100644 --- a/GpApp/GpAppInterface.cpp +++ b/GpApp/GpAppInterface.cpp @@ -25,7 +25,7 @@ public: void PL_HostFontHandler_SetInstance(PortabilityLayer::HostFontHandler *instance) override; void PL_HostVOSEventQueue_SetInstance(PortabilityLayer::HostVOSEventQueue *instance) override; void PL_InstallHostSuspendHook(PortabilityLayer::HostSuspendHook_t hook, void *context) override; - void PL_AdjustRequestedResolution(unsigned int &width, unsigned int &height) override; + bool PL_AdjustRequestedResolution(unsigned int &width, unsigned int &height) override; }; @@ -80,13 +80,20 @@ void GpAppInterfaceImpl::PL_InstallHostSuspendHook(PortabilityLayer::HostSuspend PortabilityLayer::InstallHostSuspendHook(hook, context); } -void GpAppInterfaceImpl::PL_AdjustRequestedResolution(unsigned int &width, unsigned int &height) +bool GpAppInterfaceImpl::PL_AdjustRequestedResolution(unsigned int &width, unsigned int &height) { + PortabilityLayer::DisplayDeviceManager::IResolutionChangeHandler *handler = PortabilityLayer::DisplayDeviceManager::GetInstance()->GetResolutionChangeHandler(); + + if (!handler) + return false; + uint32_t w32 = width; uint32_t h32 = height; - PortabilityLayer::DisplayDeviceManager::GetInstance()->GetResolutionChangeHandler()->AdjustRequestedResolution(w32, h32); + handler->AdjustRequestedResolution(w32, h32); width = w32; height = h32; + + return true; } diff --git a/GpCommon/GpDisplayDriverProperties.h b/GpCommon/GpDisplayDriverProperties.h index 6f3366f..f479420 100644 --- a/GpCommon/GpDisplayDriverProperties.h +++ b/GpCommon/GpDisplayDriverProperties.h @@ -11,7 +11,7 @@ struct GpDisplayDriverProperties { typedef GpDisplayDriverTickStatus_t (*TickFunc_t)(void *context, IGpFiber *vosFiber); typedef void(*RenderFunc_t)(void *context); - typedef void(*AdjustRequestedResolutionFunc_t)(void *context, unsigned int &width, unsigned int &height); + typedef bool(*AdjustRequestedResolutionFunc_t)(void *context, unsigned int &width, unsigned int &height); EGpDisplayDriverType m_type; diff --git a/GpDisplayDriver_D3D11/GpDisplayDriverD3D11.cpp b/GpDisplayDriver_D3D11/GpDisplayDriverD3D11.cpp index 86e86c1..7a05e6d 100644 --- a/GpDisplayDriver_D3D11/GpDisplayDriverD3D11.cpp +++ b/GpDisplayDriver_D3D11/GpDisplayDriverD3D11.cpp @@ -102,9 +102,11 @@ bool InitSwapChainForWindow(HWND hWnd, ID3D11Device *device, GpComPtrMakeWindowAssociation(hWnd, DXGI_MWA_NO_ALT_ENTER); if (result != S_OK) return false; +#endif outSwapChain = swapChain; @@ -173,7 +175,10 @@ bool ResizeD3DWindow(HWND hWnd, DWORD &windowWidth, DWORD &windowHeight, LONG de GetClientRect(hWnd, &windowRect); windowRect.right = windowRect.left + desiredWidth; windowRect.bottom = windowRect.top + desiredHeight; - if (!AdjustWindowRect(&windowRect, windowStyle, menus != nullptr)) + + LONG_PTR style = GetWindowLongPtrA(hWnd, GWL_STYLE); + + if (!AdjustWindowRect(&windowRect, static_cast(style), menus != nullptr)) return false; SetWindowPos(hWnd, HWND_TOP, windowRect.left, windowRect.top, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, SWP_NOZORDER | SWP_NOMOVE); @@ -692,23 +697,24 @@ void GpDisplayDriverD3D11::Run() uint32_t prevWidth = m_windowWidth; uint32_t prevHeight = m_windowHeight; - m_properties.m_adjustRequestedResolutionFunc(m_properties.m_adjustRequestedResolutionFuncContext, desiredWidth, desiredHeight); - - bool resizedOK = ResizeD3DWindow(m_hwnd, m_windowWidth, m_windowHeight, desiredWidth, desiredHeight, windowStyle, menus); - resizedOK = resizedOK && DetachSwapChain(); - resizedOK = resizedOK && ResizeSwapChain(m_swapChain, m_windowWidth, m_windowHeight); - resizedOK = resizedOK && InitBackBuffer(); - - if (!resizedOK) - break; // Critical video driver error, exit - - if (GpVOSEvent *resizeEvent = m_properties.m_eventQueue->QueueEvent()) + if (m_properties.m_adjustRequestedResolutionFunc(m_properties.m_adjustRequestedResolutionFuncContext, desiredWidth, desiredHeight)) { - resizeEvent->m_eventType = GpVOSEventTypes::kVideoResolutionChanged; - resizeEvent->m_event.m_resolutionChangedEvent.m_prevWidth = prevWidth; - resizeEvent->m_event.m_resolutionChangedEvent.m_prevHeight = prevHeight; - resizeEvent->m_event.m_resolutionChangedEvent.m_newWidth = m_windowWidth; - resizeEvent->m_event.m_resolutionChangedEvent.m_newHeight = m_windowHeight; + bool resizedOK = ResizeD3DWindow(m_hwnd, m_windowWidth, m_windowHeight, desiredWidth, desiredHeight, windowStyle, menus); + resizedOK = resizedOK && DetachSwapChain(); + resizedOK = resizedOK && ResizeSwapChain(m_swapChain, m_windowWidth, m_windowHeight); + resizedOK = resizedOK && InitBackBuffer(); + + if (!resizedOK) + break; // Critical video driver error, exit + + if (GpVOSEvent *resizeEvent = m_properties.m_eventQueue->QueueEvent()) + { + resizeEvent->m_eventType = GpVOSEventTypes::kVideoResolutionChanged; + resizeEvent->m_event.m_resolutionChangedEvent.m_prevWidth = prevWidth; + resizeEvent->m_event.m_resolutionChangedEvent.m_prevHeight = prevHeight; + resizeEvent->m_event.m_resolutionChangedEvent.m_newWidth = m_windowWidth; + resizeEvent->m_event.m_resolutionChangedEvent.m_newHeight = m_windowHeight; + } } } diff --git a/PortabilityLayer/GpAppInterface.h b/PortabilityLayer/GpAppInterface.h index 31a5132..301e8b4 100644 --- a/PortabilityLayer/GpAppInterface.h +++ b/PortabilityLayer/GpAppInterface.h @@ -46,7 +46,7 @@ public: virtual void PL_HostVOSEventQueue_SetInstance(PortabilityLayer::HostVOSEventQueue *instance) = 0; virtual void PL_InstallHostSuspendHook(PortabilityLayer::HostSuspendHook_t hook, void *context) = 0; - virtual void PL_AdjustRequestedResolution(unsigned int &width, unsigned int &height) = 0; + virtual bool PL_AdjustRequestedResolution(unsigned int &width, unsigned int &height) = 0; }; GP_APP_DLL_EXPORT_API GpAppInterface *GpAppInterface_Get();