[filesystem][SpecialProtocol] Removed assert from GetPath
[xbmc.git] / xbmc / windowing / windows / Win32DPMSSupport.cpp
blob99adc10a3dde42081614687476deac4fb75225eb
1 /*
2 * Copyright (C) 2009-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #include "Win32DPMSSupport.h"
11 #include "ServiceBroker.h"
12 #include "rendering/dx/RenderContext.h"
13 #include "utils/log.h"
14 #include "windowing/GraphicContext.h"
15 #include "windowing/windows/WinSystemWin32.h"
17 CWin32DPMSSupport::CWin32DPMSSupport()
19 m_supportedModes.push_back(OFF);
20 m_supportedModes.push_back(STANDBY);
23 bool CWin32DPMSSupport::EnablePowerSaving(PowerSavingMode mode)
25 auto winSystem = dynamic_cast<CWinSystemWin32*>(CServiceBroker::GetWinSystem());
26 if (!winSystem)
27 return false;
29 if (!winSystem->GetGfxContext().IsFullScreenRoot())
31 CLog::Log(LOGDEBUG, "DPMS: not in fullscreen, power saving disabled");
32 return false;
35 switch (mode)
37 case OFF:
38 // Turn off display
39 return SendMessage(DX::Windowing()->GetHwnd(), WM_SYSCOMMAND, SC_MONITORPOWER, static_cast<LPARAM>(2)) == 0;
40 case STANDBY:
41 // Set display to low power
42 return SendMessage(DX::Windowing()->GetHwnd(), WM_SYSCOMMAND, SC_MONITORPOWER, static_cast<LPARAM>(1)) == 0;
43 default:
44 return true;
48 bool CWin32DPMSSupport::DisablePowerSaving()
50 // Turn display on
51 return SendMessage(DX::Windowing()->GetHwnd(), WM_SYSCOMMAND, SC_MONITORPOWER, static_cast<LPARAM>(-1)) == 0;