From 6b512c3d6fcf4624693a62470ef02024fb832cdc Mon Sep 17 00:00:00 2001 From: Mariusz Brzeski Date: Sat, 27 Aug 2016 18:33:16 +0200 Subject: Ticket#16638 - No proper handling of WM_DISPLAYCHANGE and related events --- xbmc/Application.cpp | 18 ++++++++++-------- xbmc/windowing/windows/WinEventsWin32.cpp | 20 ++++++++++++++++++++ xbmc/windowing/windows/WinSystemWin32.cpp | 2 +- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp index 45cc633fcd..05ff901218 100644 --- a/xbmc/Application.cpp +++ b/xbmc/Application.cpp @@ -336,14 +336,16 @@ bool CApplication::OnEvent(XBMC_Event& newEvent) CApplicationMessenger::GetInstance().PostMsg(TMSG_QUIT); break; case XBMC_VIDEORESIZE: - if (g_windowManager.Initialized() && - !g_advancedSettings.m_fullScreen) + if (g_windowManager.Initialized()) { g_Windowing.SetWindowResolution(newEvent.resize.w, newEvent.resize.h); - g_graphicsContext.SetVideoResolution(RES_WINDOW, true); - CSettings::GetInstance().SetInt(CSettings::SETTING_WINDOW_WIDTH, newEvent.resize.w); - CSettings::GetInstance().SetInt(CSettings::SETTING_WINDOW_HEIGHT, newEvent.resize.h); - CSettings::GetInstance().Save(); + if (!g_advancedSettings.m_fullScreen) + { + g_graphicsContext.SetVideoResolution(RES_WINDOW, true); + CSettings::GetInstance().SetInt(CSettings::SETTING_WINDOW_WIDTH, newEvent.resize.w); + CSettings::GetInstance().SetInt(CSettings::SETTING_WINDOW_HEIGHT, newEvent.resize.h); + CSettings::GetInstance().Save(); + } } break; case XBMC_VIDEOMOVE: @@ -352,8 +354,8 @@ bool CApplication::OnEvent(XBMC_Event& newEvent) { // when fullscreen, remain fullscreen and resize to the dimensions of the new screen RESOLUTION newRes = (RESOLUTION) g_Windowing.DesktopResolution(g_Windowing.GetCurrentScreen()); - if (newRes != g_graphicsContext.GetVideoResolution()) - CDisplaySettings::GetInstance().SetCurrentResolution(newRes, true); + CDisplaySettings::GetInstance().SetCurrentResolution(newRes, true); + g_graphicsContext.SetVideoResolution(g_graphicsContext.GetVideoResolution(), true); } else #endif diff --git a/xbmc/windowing/windows/WinEventsWin32.cpp b/xbmc/windowing/windows/WinEventsWin32.cpp index b7f18e4b84..15f0fce275 100644 --- a/xbmc/windowing/windows/WinEventsWin32.cpp +++ b/xbmc/windowing/windows/WinEventsWin32.cpp @@ -667,6 +667,26 @@ LRESULT CALLBACK CWinEventsWin32::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, L m_pEventFunc(newEvent); } return(0); + case WM_DISPLAYCHANGE: + CLog::Log(LOGDEBUG, __FUNCTION__": display change event"); + if (g_application.GetRenderGUI() && !g_Windowing.IsAlteringWindow() && GET_X_LPARAM(lParam) > 0 && GET_Y_LPARAM(lParam) > 0) + { + g_Windowing.UpdateResolutions(); + if (g_advancedSettings.m_fullScreen) + { + newEvent.type = XBMC_VIDEOMOVE; + newEvent.move.x = 0; + newEvent.move.y = 0; + } + else + { + newEvent.type = XBMC_VIDEORESIZE; + newEvent.resize.w = GET_X_LPARAM(lParam); + newEvent.resize.h = GET_Y_LPARAM(lParam); + } + m_pEventFunc(newEvent); + } + return(0); case WM_SIZE: newEvent.type = XBMC_VIDEORESIZE; newEvent.resize.w = GET_X_LPARAM(lParam); diff --git a/xbmc/windowing/windows/WinSystemWin32.cpp b/xbmc/windowing/windows/WinSystemWin32.cpp index d62abf1f6d..9d21a058a9 100644 --- a/xbmc/windowing/windows/WinSystemWin32.cpp +++ b/xbmc/windowing/windows/WinSystemWin32.cpp @@ -558,7 +558,7 @@ bool CWinSystemWin32::ChangeResolution(const RESOLUTION_INFO& res, bool forceCha void CWinSystemWin32::UpdateResolutions() { - + m_MonitorsInfo.clear(); CWinSystemBase::UpdateResolutions(); UpdateResolutionsInternal(); -- cgit v1.2.3