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.
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());
29 if (!winSystem
->GetGfxContext().IsFullScreenRoot())
31 CLog::Log(LOGDEBUG
, "DPMS: not in fullscreen, power saving disabled");
39 return SendMessage(DX::Windowing()->GetHwnd(), WM_SYSCOMMAND
, SC_MONITORPOWER
, static_cast<LPARAM
>(2)) == 0;
41 // Set display to low power
42 return SendMessage(DX::Windowing()->GetHwnd(), WM_SYSCOMMAND
, SC_MONITORPOWER
, static_cast<LPARAM
>(1)) == 0;
48 bool CWin32DPMSSupport::DisablePowerSaving()
51 return SendMessage(DX::Windowing()->GetHwnd(), WM_SYSCOMMAND
, SC_MONITORPOWER
, static_cast<LPARAM
>(-1)) == 0;