From 79ebbf68f8a4c8bf246762a86fe738c8d91afc55 Mon Sep 17 00:00:00 2001 From: Anton Fedchin Date: Tue, 11 Dec 2018 15:40:32 +0300 Subject: [win10] forcible change resolution (if required) on application starts --- xbmc/windowing/win10/WinSystemWin10.cpp | 15 ++++++--------- xbmc/windowing/win10/WinSystemWin10.h | 1 + xbmc/windowing/win10/WinSystemWin10DX.cpp | 3 +-- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/xbmc/windowing/win10/WinSystemWin10.cpp b/xbmc/windowing/win10/WinSystemWin10.cpp index d2e2e8d90e..0ca1b684c9 100644 --- a/xbmc/windowing/win10/WinSystemWin10.cpp +++ b/xbmc/windowing/win10/WinSystemWin10.cpp @@ -119,11 +119,6 @@ bool CWinSystemWin10::CreateNewWindow(const std::string& name, bool fullScreen, // and hide UWP splash, without this the Kodi's splash will not be shown m_coreWindow.Dispatcher().ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending); - // in some cases CoreWindow::SizeChanged isn't fired - // it causes mismatch between window actual size and UI - winrt::Rect winRect = m_coreWindow.Bounds(); - dynamic_cast(*m_winEvents).OnResize(winRect.Width, winRect.Height); - return true; } @@ -209,10 +204,8 @@ bool CWinSystemWin10::SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool bool forceChange = false; // resolution/display is changed but window state isn't changed bool stereoChange = IsStereoEnabled() != (CServiceBroker::GetWinSystem()->GetGfxContext().GetStereoMode() == RENDER_STEREO_MODE_HARDWAREBASED); - if ( m_nWidth != res.iWidth - || m_nHeight != res.iHeight - || m_fRefreshRate != res.fRefreshRate - || stereoChange) + if ( m_nWidth != res.iWidth || m_nHeight != res.iHeight || m_fRefreshRate != res.fRefreshRate || + stereoChange || m_bFirstResChange) { forceChange = true; } @@ -239,6 +232,7 @@ bool CWinSystemWin10::SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool m_IsAlteringWindow = true; ReleaseBackBuffer(); + m_bFirstResChange = false; m_bFullScreen = fullScreen; m_nWidth = res.iWidth; m_nHeight = res.iHeight; @@ -348,6 +342,9 @@ bool CWinSystemWin10::ChangeResolution(const RESOLUTION_INFO& res, bool forceCha // changing display mode doesn't fire CoreWindow::SizeChanged event if (changed && m_bWindowCreated) { + // dispatch all events currently pending in the queue to change window's content + m_coreWindow.Dispatcher().ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending); + float dpi = DisplayInformation::GetForCurrentView().LogicalDpi(); float dipsW = DX::ConvertPixelsToDips(m_nWidth, dpi); float dipsH = DX::ConvertPixelsToDips(m_nHeight, dpi); diff --git a/xbmc/windowing/win10/WinSystemWin10.h b/xbmc/windowing/win10/WinSystemWin10.h index af3d7d3631..7e99e7e23c 100644 --- a/xbmc/windowing/win10/WinSystemWin10.h +++ b/xbmc/windowing/win10/WinSystemWin10.h @@ -143,6 +143,7 @@ protected: WINDOW_WINDOW_STATE m_windowState; // the state of the window when in windowed bool m_inFocus; bool m_bMinimized; + bool m_bFirstResChange = true; winrt::Windows::UI::Core::CoreWindow m_coreWindow = nullptr; }; diff --git a/xbmc/windowing/win10/WinSystemWin10DX.cpp b/xbmc/windowing/win10/WinSystemWin10DX.cpp index 928e57a4d0..2ac39b1d81 100644 --- a/xbmc/windowing/win10/WinSystemWin10DX.cpp +++ b/xbmc/windowing/win10/WinSystemWin10DX.cpp @@ -52,8 +52,7 @@ bool CWinSystemWin10DX::CreateNewWindow(const std::string& name, bool fullScreen if (CWinSystemWin10::CreateNewWindow(name, fullScreen, res) && m_deviceResources->HasValidDevice()) { CGenericTouchInputHandler::GetInstance().RegisterHandler(&CGenericTouchActionHandler::GetInstance()); - CGenericTouchInputHandler::GetInstance().SetScreenDPI(DX::DisplayMetrics::Dpi100); - ChangeResolution(res, true); + CGenericTouchInputHandler::GetInstance().SetScreenDPI(m_deviceResources->GetDpi()); return true; } return false; -- cgit v1.2.3