Fix alt-enter

This commit is contained in:
elasota
2020-04-06 03:34:31 -04:00
parent ffd9d9cc1f
commit 0335dd7786
7 changed files with 40 additions and 27 deletions

View File

@@ -94,9 +94,9 @@ void GpAppEnvironment::Render()
GpAppInterface_Get()->PL_Render(m_displayDriver); 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) void GpAppEnvironment::SetDisplayDriver(IGpDisplayDriver *displayDriver)

View File

@@ -28,7 +28,7 @@ public:
GpDisplayDriverTickStatus_t Tick(IGpFiber *vosFiber); GpDisplayDriverTickStatus_t Tick(IGpFiber *vosFiber);
void Render(); void Render();
void AdjustRequestedResolution(unsigned int &width, unsigned int &height); bool AdjustRequestedResolution(unsigned int &width, unsigned int &height);
void SetDisplayDriver(IGpDisplayDriver *displayDriver); void SetDisplayDriver(IGpDisplayDriver *displayDriver);
void SetAudioDriver(IGpAudioDriver *audioDriver); void SetAudioDriver(IGpAudioDriver *audioDriver);

View File

@@ -28,9 +28,9 @@ namespace
static_cast<GpAppEnvironment*>(context)->Render(); static_cast<GpAppEnvironment*>(context)->Render();
} }
void AdjustRequestedResolution(void *context, unsigned int &width, unsigned int &height) bool AdjustRequestedResolution(void *context, unsigned int &width, unsigned int &height)
{ {
static_cast<GpAppEnvironment*>(context)->AdjustRequestedResolution(width, height); return static_cast<GpAppEnvironment*>(context)->AdjustRequestedResolution(width, height);
} }
} }

View File

@@ -25,7 +25,7 @@ public:
void PL_HostFontHandler_SetInstance(PortabilityLayer::HostFontHandler *instance) override; void PL_HostFontHandler_SetInstance(PortabilityLayer::HostFontHandler *instance) override;
void PL_HostVOSEventQueue_SetInstance(PortabilityLayer::HostVOSEventQueue *instance) override; void PL_HostVOSEventQueue_SetInstance(PortabilityLayer::HostVOSEventQueue *instance) override;
void PL_InstallHostSuspendHook(PortabilityLayer::HostSuspendHook_t hook, void *context) 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); 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 w32 = width;
uint32_t h32 = height; uint32_t h32 = height;
PortabilityLayer::DisplayDeviceManager::GetInstance()->GetResolutionChangeHandler()->AdjustRequestedResolution(w32, h32); handler->AdjustRequestedResolution(w32, h32);
width = w32; width = w32;
height = h32; height = h32;
return true;
} }

View File

@@ -11,7 +11,7 @@ struct GpDisplayDriverProperties
{ {
typedef GpDisplayDriverTickStatus_t (*TickFunc_t)(void *context, IGpFiber *vosFiber); typedef GpDisplayDriverTickStatus_t (*TickFunc_t)(void *context, IGpFiber *vosFiber);
typedef void(*RenderFunc_t)(void *context); 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; EGpDisplayDriverType m_type;

View File

@@ -102,9 +102,11 @@ bool InitSwapChainForWindow(HWND hWnd, ID3D11Device *device, GpComPtr<IDXGISwapC
if (result != S_OK) if (result != S_OK)
return false; return false;
#if 0
result = dxgiFactory->MakeWindowAssociation(hWnd, DXGI_MWA_NO_ALT_ENTER); result = dxgiFactory->MakeWindowAssociation(hWnd, DXGI_MWA_NO_ALT_ENTER);
if (result != S_OK) if (result != S_OK)
return false; return false;
#endif
outSwapChain = swapChain; outSwapChain = swapChain;
@@ -173,7 +175,10 @@ bool ResizeD3DWindow(HWND hWnd, DWORD &windowWidth, DWORD &windowHeight, LONG de
GetClientRect(hWnd, &windowRect); GetClientRect(hWnd, &windowRect);
windowRect.right = windowRect.left + desiredWidth; windowRect.right = windowRect.left + desiredWidth;
windowRect.bottom = windowRect.top + desiredHeight; windowRect.bottom = windowRect.top + desiredHeight;
if (!AdjustWindowRect(&windowRect, windowStyle, menus != nullptr))
LONG_PTR style = GetWindowLongPtrA(hWnd, GWL_STYLE);
if (!AdjustWindowRect(&windowRect, static_cast<DWORD>(style), menus != nullptr))
return false; return false;
SetWindowPos(hWnd, HWND_TOP, windowRect.left, windowRect.top, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, SWP_NOZORDER | SWP_NOMOVE); SetWindowPos(hWnd, HWND_TOP, windowRect.left, windowRect.top, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, SWP_NOZORDER | SWP_NOMOVE);
@@ -692,8 +697,8 @@ void GpDisplayDriverD3D11::Run()
uint32_t prevWidth = m_windowWidth; uint32_t prevWidth = m_windowWidth;
uint32_t prevHeight = m_windowHeight; uint32_t prevHeight = m_windowHeight;
m_properties.m_adjustRequestedResolutionFunc(m_properties.m_adjustRequestedResolutionFuncContext, desiredWidth, desiredHeight); if (m_properties.m_adjustRequestedResolutionFunc(m_properties.m_adjustRequestedResolutionFuncContext, desiredWidth, desiredHeight))
{
bool resizedOK = ResizeD3DWindow(m_hwnd, m_windowWidth, m_windowHeight, desiredWidth, desiredHeight, windowStyle, menus); bool resizedOK = ResizeD3DWindow(m_hwnd, m_windowWidth, m_windowHeight, desiredWidth, desiredHeight, windowStyle, menus);
resizedOK = resizedOK && DetachSwapChain(); resizedOK = resizedOK && DetachSwapChain();
resizedOK = resizedOK && ResizeSwapChain(m_swapChain, m_windowWidth, m_windowHeight); resizedOK = resizedOK && ResizeSwapChain(m_swapChain, m_windowWidth, m_windowHeight);
@@ -711,6 +716,7 @@ void GpDisplayDriverD3D11::Run()
resizeEvent->m_event.m_resolutionChangedEvent.m_newHeight = m_windowHeight; resizeEvent->m_event.m_resolutionChangedEvent.m_newHeight = m_windowHeight;
} }
} }
}
GpDisplayDriverTickStatus_t tickStatus = PresentFrameAndSync(); GpDisplayDriverTickStatus_t tickStatus = PresentFrameAndSync();
if (tickStatus == GpDisplayDriverTickStatuses::kFatalFault || tickStatus == GpDisplayDriverTickStatuses::kApplicationTerminated) if (tickStatus == GpDisplayDriverTickStatuses::kFatalFault || tickStatus == GpDisplayDriverTickStatuses::kApplicationTerminated)

View File

@@ -46,7 +46,7 @@ public:
virtual void PL_HostVOSEventQueue_SetInstance(PortabilityLayer::HostVOSEventQueue *instance) = 0; virtual void PL_HostVOSEventQueue_SetInstance(PortabilityLayer::HostVOSEventQueue *instance) = 0;
virtual void PL_InstallHostSuspendHook(PortabilityLayer::HostSuspendHook_t hook, void *context) = 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(); GP_APP_DLL_EXPORT_API GpAppInterface *GpAppInterface_Get();