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;
18 if (DPMSGetVersion(_ecore_x_disp, &_dpms_major, &_dpms_minor))
19 _dpms_available = EINA_TRUE;
21 _dpms_available = EINA_FALSE;
23 #else /* ifdef ECORE_XDPMS */
24 _dpms_available = EINA_FALSE;
25 #endif /* ifdef ECORE_XDPMS */
26 } /* _ecore_x_dpms_init */
29 * @defgroup Ecore_X_DPMS_Group X DPMS Extension Functions
31 * Functions related to the X DPMS extension.
35 * Checks if the X DPMS extension is available on the server.
36 * @return @c 1 if the X DPMS extension is available, @c 0 otherwise.
37 * @ingroup Ecore_X_DPMS_Group
40 ecore_x_dpms_query(void)
42 return _dpms_available;
43 } /* ecore_x_dpms_query */
46 * Checks if the X server is capable of DPMS.
47 * @return @c 1 if the X server is capable of DPMS, @c 0 otherwise.
48 * @ingroup Ecore_X_DPMS_Group
51 ecore_x_dpms_capable_get(void)
54 LOGFN(__FILE__, __LINE__, __FUNCTION__);
55 return DPMSCapable(_ecore_x_disp) ? EINA_TRUE : EINA_FALSE;
56 #else /* ifdef ECORE_XDPMS */
58 #endif /* ifdef ECORE_XDPMS */
59 } /* ecore_x_dpms_capable_get */
62 * Checks the DPMS state of the display.
63 * @return @c 1 if DPMS is enabled, @c 0 otherwise.
64 * @ingroup Ecore_X_DPMS_Group
67 ecore_x_dpms_enabled_get(void)
71 unsigned short power_lvl;
73 LOGFN(__FILE__, __LINE__, __FUNCTION__);
74 DPMSInfo(_ecore_x_disp, &power_lvl, &state);
75 return state ? EINA_TRUE : EINA_FALSE;
76 #else /* ifdef ECORE_XDPMS */
78 #endif /* ifdef ECORE_XDPMS */
79 } /* ecore_x_dpms_enabled_get */
82 * Sets the DPMS state of the display.
83 * @param enabled @c 0 to disable DPMS characteristics of the server, enable it otherwise.
84 * @ingroup Ecore_X_DPMS_Group
87 ecore_x_dpms_enabled_set(int enabled)
90 LOGFN(__FILE__, __LINE__, __FUNCTION__);
92 DPMSEnable(_ecore_x_disp);
94 DPMSDisable(_ecore_x_disp);
96 #endif /* ifdef ECORE_XDPMS */
97 } /* ecore_x_dpms_enabled_set */
100 * Gets the timeouts. The values are in unit of seconds.
101 * @param standby Amount of time of inactivity before standby mode will be invoked.
102 * @param suspend Amount of time of inactivity before the screen is placed into suspend mode.
103 * @param off Amount of time of inactivity before the monitor is shut off.
104 * @ingroup Ecore_X_DPMS_Group
107 ecore_x_dpms_timeouts_get(unsigned int *standby,
108 unsigned int *suspend,
112 LOGFN(__FILE__, __LINE__, __FUNCTION__);
113 DPMSGetTimeouts(_ecore_x_disp, (unsigned short *)standby,
114 (unsigned short *)suspend, (unsigned short *)off);
115 #endif /* ifdef ECORE_XDPMS */
116 } /* ecore_x_dpms_timeouts_get */
119 * Sets the timeouts. The values are in unit of seconds.
120 * @param standby Amount of time of inactivity before standby mode will be invoked.
121 * @param suspend Amount of time of inactivity before the screen is placed into suspend mode.
122 * @param off Amount of time of inactivity before the monitor is shut off.
123 * @ingroup Ecore_X_DPMS_Group
126 ecore_x_dpms_timeouts_set(unsigned int standby,
127 unsigned int suspend,
131 LOGFN(__FILE__, __LINE__, __FUNCTION__);
132 return DPMSSetTimeouts(_ecore_x_disp, standby, suspend, off) ? EINA_TRUE : EINA_FALSE;
133 #else /* ifdef ECORE_XDPMS */
135 #endif /* ifdef ECORE_XDPMS */
136 } /* ecore_x_dpms_timeouts_set */
139 * Returns the amount of time of inactivity before standby mode is invoked.
140 * @return The standby timeout value.
141 * @ingroup Ecore_X_DPMS_Group
144 ecore_x_dpms_timeout_standby_get(void)
147 unsigned short standby, suspend, off;
149 LOGFN(__FILE__, __LINE__, __FUNCTION__);
150 DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
152 #else /* ifdef ECORE_XDPMS */
154 #endif /* ifdef ECORE_XDPMS */
155 } /* ecore_x_dpms_timeout_standby_get */
158 * Returns the amount of time of inactivity before the second level of
159 * power saving is invoked.
160 * @return The suspend timeout value.
161 * @ingroup Ecore_X_DPMS_Group
164 ecore_x_dpms_timeout_suspend_get(void)
167 unsigned short standby, suspend, off;
169 LOGFN(__FILE__, __LINE__, __FUNCTION__);
170 DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
172 #else /* ifdef ECORE_XDPMS */
174 #endif /* ifdef ECORE_XDPMS */
175 } /* ecore_x_dpms_timeout_suspend_get */
178 * Returns the amount of time of inactivity before the third and final
179 * level of power saving is invoked.
180 * @return The off timeout value.
181 * @ingroup Ecore_X_DPMS_Group
184 ecore_x_dpms_timeout_off_get(void)
187 unsigned short standby, suspend, off;
189 LOGFN(__FILE__, __LINE__, __FUNCTION__);
190 DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
192 #else /* ifdef ECORE_XDPMS */
194 #endif /* ifdef ECORE_XDPMS */
195 } /* ecore_x_dpms_timeout_off_get */
198 * Sets the standby timeout (in unit of seconds).
199 * @param new_standby Amount of time of inactivity before standby mode will be invoked.
200 * @ingroup Ecore_X_DPMS_Group
203 ecore_x_dpms_timeout_standby_set(unsigned int new_timeout)
206 unsigned short standby, suspend, off;
208 LOGFN(__FILE__, __LINE__, __FUNCTION__);
209 DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
210 DPMSSetTimeouts(_ecore_x_disp, new_timeout, suspend, off);
211 #endif /* ifdef ECORE_XDPMS */
212 } /* ecore_x_dpms_timeout_standby_set */
215 * Sets the suspend timeout (in unit of seconds).
216 * @param suspend Amount of time of inactivity before the screen is placed into suspend mode.
217 * @ingroup Ecore_X_DPMS_Group
220 ecore_x_dpms_timeout_suspend_set(unsigned int new_timeout)
223 unsigned short standby, suspend, off;
225 LOGFN(__FILE__, __LINE__, __FUNCTION__);
226 DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
227 DPMSSetTimeouts(_ecore_x_disp, standby, new_timeout, off);
228 #endif /* ifdef ECORE_XDPMS */
229 } /* ecore_x_dpms_timeout_suspend_set */
232 * Sets the off timeout (in unit of seconds).
233 * @param off Amount of time of inactivity before the monitor is shut off.
234 * @ingroup Ecore_X_DPMS_Group
237 ecore_x_dpms_timeout_off_set(unsigned int new_timeout)
240 unsigned short standby, suspend, off;
242 LOGFN(__FILE__, __LINE__, __FUNCTION__);
243 DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
244 DPMSSetTimeouts(_ecore_x_disp, standby, suspend, new_timeout);
245 #endif /* ifdef ECORE_XDPMS */
246 } /* ecore_x_dpms_timeout_off_set */