Madness I say.

This commit is contained in:
Michael Niksa 2020-03-05 16:57:33 -08:00
parent fbb7334c5c
commit 6cf04176e9
2 changed files with 9 additions and 5 deletions

View file

@ -201,6 +201,14 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"
THROW_HR_IF(E_ABORT, !base::MakeCheckedNum(height()).AssignIfValid(&ret));
return ret;
}
template <typename T, typename... Args>
auto capture(T&& func, Args&&... args) -> decltype(func(args..., static_cast<RECT*>(nullptr))) {
RECT r{};
auto rv = func(std::forward<Args>(args)..., &r);
*this = static_cast<rectangle>(r);
return rv;
}
constexpr point origin() const noexcept
{

View file

@ -429,11 +429,7 @@ void DxEngine::_ComputePixelShaderSettings() noexcept
{
// use the HWND's dimensions for the swap chain dimensions.
til::rectangle clientRect;
{
RECT rect = { 0 };
RETURN_IF_WIN32_BOOL_FALSE(GetClientRect(_hwndTarget, &rect));
clientRect = rect;
}
RETURN_IF_WIN32_BOOL_FALSE(clientRect.capture(&::GetClientRect, _hwndTarget));
SwapChainDesc.Width = clientRect.width<UINT>();
SwapChainDesc.Height = clientRect.height<UINT>();