| 1 |
/* |
| 2 |
* Copyright (C) 2009-2018 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#pragma once |
| 10 |
|
| 11 |
#include <vector> |
| 12 |
|
| 13 |
// This class encapsulates support for monitor power-saving features (DPMS). |
| 14 |
// An instance is connected to a Surface, provides information on which |
| 15 |
// power-saving features are available for that screen, and it is able to |
| 16 |
// turn power-saving on an off. |
| 17 |
// Note that SDL turns off DPMS timeouts at the beginning of the application. |
| 18 |
class CDPMSSupport |
| 19 |
{ |
| 20 |
public: |
| 21 |
// All known DPMS power-saving modes, on any platform. |
| 22 |
enum PowerSavingMode |
| 23 |
{ |
| 24 |
STANDBY, |
| 25 |
SUSPEND, |
| 26 |
OFF, |
| 27 |
NUM_MODES, |
| 28 |
}; |
| 29 |
|
| 30 |
CDPMSSupport(); |
| 31 |
virtual ~CDPMSSupport() = default; |
| 32 |
|
| 33 |
// Whether power-saving is supported on this screen. |
| 34 |
bool IsSupported() const { return !m_supportedModes.empty(); } |
| 35 |
|
| 36 |
// Which power-saving modes are supported, in the order of preference (i.e. |
| 37 |
// the first mode should be the best choice). |
| 38 |
const std::vector<PowerSavingMode>& GetSupportedModes() const |
| 39 |
{ |
| 40 |
return m_supportedModes; |
| 41 |
} |
| 42 |
|
| 43 |
// Whether a given mode is supported. |
| 44 |
bool IsModeSupported(PowerSavingMode mode) const; |
| 45 |
|
| 46 |
// Turns on the specified power-saving mode, which must be valid |
| 47 |
// and supported. Returns false if this failed. |
| 48 |
virtual bool EnablePowerSaving(PowerSavingMode mode) = 0; |
| 49 |
|
| 50 |
// Turns off power-saving mode. You should only call this if the display |
| 51 |
// is currently in a power-saving mode, to avoid visual artifacts. |
| 52 |
virtual bool DisablePowerSaving() = 0; |
| 53 |
|
| 54 |
protected: |
| 55 |
std::vector<PowerSavingMode> m_supportedModes; |
| 56 |
}; |