3 #endif /* ifdef HAVE_CONFIG_H */
5 #include "ecore_x_private.h"
7 static Eina_Bool _dpms_available = EINA_FALSE;
10 _ecore_x_dpms_init(void)
13 int _dpms_major, _dpms_minor;
15 EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
20 if (DPMSGetVersion(_ecore_x_disp, &_dpms_major, &_dpms_minor))
21 _dpms_available = EINA_TRUE;
23 _dpms_available = EINA_FALSE;
25 #else /* ifdef ECORE_XDPMS */
26 _dpms_available = EINA_FALSE;
27 #endif /* ifdef ECORE_XDPMS */
31 * @defgroup Ecore_X_DPMS_Group X DPMS Extension Functions
32 * @ingroup Ecore_X_Group
34 * Functions related to the X DPMS extension.
38 * Checks if the X DPMS extension is available on the server.
39 * @return @c 1 if the X DPMS extension is available, @c 0 otherwise.
40 * @ingroup Ecore_X_DPMS_Group
43 ecore_x_dpms_query(void)
45 return _dpms_available;
49 * Checks if the X server is capable of DPMS.
50 * @return @c 1 if the X server is capable of DPMS, @c 0 otherwise.
51 * @ingroup Ecore_X_DPMS_Group
54 ecore_x_dpms_capable_get(void)
57 LOGFN(__FILE__, __LINE__, __FUNCTION__);
58 EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, EINA_FALSE);
59 return DPMSCapable(_ecore_x_disp) ? EINA_TRUE : EINA_FALSE;
60 #else /* ifdef ECORE_XDPMS */
62 #endif /* ifdef ECORE_XDPMS */
66 * Checks the DPMS state of the display.
67 * @return @c 1 if DPMS is enabled, @c 0 otherwise.
68 * @ingroup Ecore_X_DPMS_Group
71 ecore_x_dpms_enabled_get(void)
75 unsigned short power_lvl;
77 LOGFN(__FILE__, __LINE__, __FUNCTION__);
78 EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, EINA_FALSE);
79 DPMSInfo(_ecore_x_disp, &power_lvl, &state);
80 return state ? EINA_TRUE : EINA_FALSE;
81 #else /* ifdef ECORE_XDPMS */
83 #endif /* ifdef ECORE_XDPMS */
87 * Check the DPMS power level.
88 * @return @c 0 if DPMS is :In Use
89 * @return @c 1 if DPMS is :Blanked, low power
90 * @return @c 2 if DPMS is :Blanked, lower power
91 * @return @c 3 if DPMS is :Shut off, awaiting activity
92 * @return @c -1 othwhise.
95 EAPI Ecore_X_Dpms_Mode
96 ecore_x_dpms_power_level_get(void)
100 unsigned short power_lvl;
102 LOGFN(__FILE__, __LINE__, __FUNCTION__);
103 EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, -1);
104 DPMSInfo(_ecore_x_disp, &power_lvl, &state);
105 return (int)power_lvl;
112 * Sets the DPMS state of the display.
113 * @param enabled @c 0 to disable DPMS characteristics of the server, enable it otherwise.
114 * @ingroup Ecore_X_DPMS_Group
117 ecore_x_dpms_enabled_set(int enabled)
120 LOGFN(__FILE__, __LINE__, __FUNCTION__);
121 EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
123 DPMSEnable(_ecore_x_disp);
125 DPMSDisable(_ecore_x_disp);
127 #endif /* ifdef ECORE_XDPMS */
131 * Gets the timeouts. The values are in unit of seconds.
132 * @param standby Amount of time of inactivity before standby mode will be invoked.
133 * @param suspend Amount of time of inactivity before the screen is placed into suspend mode.
134 * @param off Amount of time of inactivity before the monitor is shut off.
135 * @ingroup Ecore_X_DPMS_Group
138 ecore_x_dpms_timeouts_get(unsigned int *standby,
139 unsigned int *suspend,
143 LOGFN(__FILE__, __LINE__, __FUNCTION__);
144 EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
145 DPMSGetTimeouts(_ecore_x_disp, (unsigned short *)standby,
146 (unsigned short *)suspend, (unsigned short *)off);
147 #endif /* ifdef ECORE_XDPMS */
151 * Sets the timeouts. The values are in unit of seconds.
152 * @param standby Amount of time of inactivity before standby mode will be invoked.
153 * @param suspend Amount of time of inactivity before the screen is placed into suspend mode.
154 * @param off Amount of time of inactivity before the monitor is shut off.
155 * @ingroup Ecore_X_DPMS_Group
158 ecore_x_dpms_timeouts_set(unsigned int standby,
159 unsigned int suspend,
163 LOGFN(__FILE__, __LINE__, __FUNCTION__);
164 EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, EINA_FALSE);
165 return DPMSSetTimeouts(_ecore_x_disp, standby, suspend, off) ? EINA_TRUE : EINA_FALSE;
166 #else /* ifdef ECORE_XDPMS */
168 #endif /* ifdef ECORE_XDPMS */
172 * Returns the amount of time of inactivity before standby mode is invoked.
173 * @return The standby timeout value.
174 * @ingroup Ecore_X_DPMS_Group
177 ecore_x_dpms_timeout_standby_get(void)
180 unsigned short standby, suspend, off;
182 LOGFN(__FILE__, __LINE__, __FUNCTION__);
183 EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, 0);
184 DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
186 #else /* ifdef ECORE_XDPMS */
188 #endif /* ifdef ECORE_XDPMS */
192 * Returns the amount of time of inactivity before the second level of
193 * power saving is invoked.
194 * @return The suspend timeout value.
195 * @ingroup Ecore_X_DPMS_Group
198 ecore_x_dpms_timeout_suspend_get(void)
201 unsigned short standby, suspend, off;
203 LOGFN(__FILE__, __LINE__, __FUNCTION__);
204 EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, 0);
205 DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
207 #else /* ifdef ECORE_XDPMS */
209 #endif /* ifdef ECORE_XDPMS */
213 * Returns the amount of time of inactivity before the third and final
214 * level of power saving is invoked.
215 * @return The off timeout value.
216 * @ingroup Ecore_X_DPMS_Group
219 ecore_x_dpms_timeout_off_get(void)
222 unsigned short standby, suspend, off;
224 LOGFN(__FILE__, __LINE__, __FUNCTION__);
225 EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, 0);
226 DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
228 #else /* ifdef ECORE_XDPMS */
230 #endif /* ifdef ECORE_XDPMS */
234 * Sets the standby timeout (in unit of seconds).
235 * @param new_timeout Amount of time of inactivity before standby mode will be invoked.
236 * @ingroup Ecore_X_DPMS_Group
239 ecore_x_dpms_timeout_standby_set(unsigned int new_timeout)
242 unsigned short standby, suspend, off;
244 LOGFN(__FILE__, __LINE__, __FUNCTION__);
245 EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
246 DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
247 DPMSSetTimeouts(_ecore_x_disp, new_timeout, suspend, off);
248 #endif /* ifdef ECORE_XDPMS */
252 * Sets the suspend timeout (in unit of seconds).
253 * @param new_timeout Amount of time of inactivity before the screen is placed into suspend mode.
254 * @ingroup Ecore_X_DPMS_Group
257 ecore_x_dpms_timeout_suspend_set(unsigned int new_timeout)
260 unsigned short standby, suspend, off;
262 LOGFN(__FILE__, __LINE__, __FUNCTION__);
263 EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
264 DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
265 DPMSSetTimeouts(_ecore_x_disp, standby, new_timeout, off);
266 #endif /* ifdef ECORE_XDPMS */
270 * Sets the off timeout (in unit of seconds).
271 * @param new_timeout Amount of time of inactivity before the monitor is shut off.
272 * @ingroup Ecore_X_DPMS_Group
275 ecore_x_dpms_timeout_off_set(unsigned int new_timeout)
278 unsigned short standby, suspend, off;
280 LOGFN(__FILE__, __LINE__, __FUNCTION__);
281 EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
282 DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
283 DPMSSetTimeouts(_ecore_x_disp, standby, suspend, new_timeout);
284 #endif /* ifdef ECORE_XDPMS */