2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
5 #include "ecore_xcb_private.h"
9 * @defgroup Ecore_X_DPMS_Group X DPMS Extension Functions
11 * Functions related to the X DPMS extension.
16 static int _dpms_available = 0;
17 static xcb_dpms_get_version_cookie_t _ecore_xcb_dpms_init_cookie;
18 #endif /* ECORE_XCB_DPMS */
20 /* To avoid round trips, the initialization is separated in 2
21 functions: _ecore_xcb_dpms_init and
22 _ecore_xcb_dpms_init_finalize. The first one gets the cookies and
23 the second one gets the replies. */
26 _ecore_x_dpms_init(const xcb_query_extension_reply_t *reply)
29 if (reply && (reply->present))
30 _ecore_xcb_dpms_init_cookie = xcb_dpms_get_version_unchecked(_ecore_xcb_conn, 0, 0);
31 #endif /* ECORE_XCB_DPMS */
35 _ecore_x_dpms_init_finalize(void)
38 xcb_dpms_get_version_reply_t *reply;
40 reply = xcb_dpms_get_version_reply(_ecore_xcb_conn,
41 _ecore_xcb_dpms_init_cookie, NULL);
45 if (reply->server_major_version >= 1)
49 #endif /* ECORE_XCB_DPMS */
54 * Checks if the DPMS extension is available or not.
55 * @return @c 1 if the DPMS extension is available, @c 0 otherwise.
57 * Return 1 if the X server supports the DPMS Extension version 1.0,
59 * @ingroup Ecore_X_DPMS_Group
62 ecore_x_dpms_query(void)
65 return _dpms_available;
68 #endif /* ECORE_XCB_DPMS */
73 * Sends the DPMSCapable request.
74 * @ingroup Ecore_X_DPMS_Group
77 ecore_x_dpms_capable_get_prefetch(void)
80 xcb_dpms_capable_cookie_t cookie;
82 cookie = xcb_dpms_capable_unchecked(_ecore_xcb_conn);
83 _ecore_xcb_cookie_cache(cookie.sequence);
84 #endif /* ECORE_XCB_DPMS */
89 * Gets the reply of the DPMSCapable request sent by ecore_x_dpms_capable_get_prefetch().
90 * @ingroup Ecore_X_DPMS_Group
93 ecore_x_dpms_capable_get_fetch(void)
96 xcb_dpms_capable_cookie_t cookie;
97 xcb_dpms_capable_reply_t *reply;
99 cookie.sequence = _ecore_xcb_cookie_get();
100 reply = xcb_dpms_capable_reply(_ecore_xcb_conn, cookie, NULL);
101 _ecore_xcb_reply_cache(reply);
102 #endif /* ECORE_XCB_DPMS */
107 * Checks if the X server is capable of DPMS.
108 * @return @c 1 if the X server is capable of DPMS, @c 0 otherwise.
110 * To use this function, you must call before, and in order,
111 * ecore_x_dpms_capable_get_prefetch(), which sends the DPMSCapable request,
112 * then ecore_x_dpms_capable_get_fetch(), which gets the reply.
113 * @ingroup Ecore_X_DPMS_Group
116 ecore_x_dpms_capable_get(void)
119 #ifdef ECORE_XCB_DPMS
120 xcb_dpms_capable_reply_t *reply;
122 reply = _ecore_xcb_reply_get();
123 if (!reply) return 0;
125 capable = reply->capable;
126 #endif /* ECORE_XCB_DPMS */
133 * Sends the DPMSInfo request.
134 * @ingroup Ecore_X_DPMS_Group
137 ecore_x_dpms_enable_get_prefetch(void)
139 #ifdef ECORE_XCB_DPMS
140 xcb_dpms_info_cookie_t cookie;
142 cookie = xcb_dpms_info_unchecked(_ecore_xcb_conn);
143 _ecore_xcb_cookie_cache(cookie.sequence);
144 #endif /* ECORE_XCB_DPMS */
149 * Gets the reply of the DPMSInfo request sent by ecore_x_dpms_enable_get_prefetch().
150 * @ingroup Ecore_X_DPMS_Group
153 ecore_x_dpms_enable_get_fetch(void)
155 #ifdef ECORE_XCB_DPMS
156 xcb_dpms_info_cookie_t cookie;
157 xcb_dpms_info_reply_t *reply;
159 cookie.sequence = _ecore_xcb_cookie_get();
160 reply = xcb_dpms_info_reply(_ecore_xcb_conn, cookie, NULL);
161 _ecore_xcb_reply_cache(reply);
162 #endif /* ECORE_XCB_DPMS */
167 * Checks the DPMS state of the display.
168 * @return @c 1 if DPMS is enabled, @c 0 otherwise.
170 * To use this function, you must call before, and in order,
171 * ecore_x_dpms_enapable_get_prefetch(), which sends the DPMSInfo request,
172 * then ecore_x_dpms_enapable_get_fetch(), which gets the reply.
173 * @ingroup Ecore_X_DPMS_Group
176 ecore_x_dpms_enable_get(void)
179 #ifdef ECORE_XCB_DPMS
180 xcb_dpms_info_reply_t *reply;
182 reply = _ecore_xcb_reply_get();
183 if (!reply) return 0;
185 enable = reply->state;
186 #endif /* ECORE_XCB_DPMS */
193 * Sets the DPMS state of the display.
194 * @param enabled @c 0 to disable DPMS characteristics of the server, enable it otherwise.
195 * @ingroup Ecore_X_DPMS_Group
198 ecore_x_dpms_enabled_set(int enabled)
200 #ifdef ECORE_XCB_DPMS
202 xcb_dpms_enable(_ecore_xcb_conn);
204 xcb_dpms_disable(_ecore_xcb_conn);
205 #endif /* ECORE_XCB_DPMS */
210 * Sets the timeouts. The values are in unit of seconds.
211 * @param standby Amount of time of inactivity before standby mode will be invoked.
212 * @param suspend Amount of time of inactivity before the screen is placed into suspend mode.
213 * @param off Amount of time of inactivity before the monitor is shut off.
214 * @return Returns always 1.
215 * @ingroup Ecore_X_DPMS_Group
218 ecore_x_dpms_timeouts_set(unsigned int standby,
219 unsigned int suspend,
222 #ifdef ECORE_XCB_DPMS
223 xcb_dpms_set_timeouts(_ecore_xcb_conn, standby, suspend, off);
224 #endif /* ECORE_XCB_DPMS */
231 * Sends the DPMSGetTimeouts request.
232 * @ingroup Ecore_X_DPMS_Group
235 ecore_x_dpms_timeouts_get_prefetch(void)
237 #ifdef ECORE_XCB_DPMS
238 xcb_dpms_get_timeouts_cookie_t cookie;
240 cookie = xcb_dpms_get_timeouts_unchecked(_ecore_xcb_conn);
241 _ecore_xcb_cookie_cache(cookie.sequence);
242 #endif /* ECORE_XCB_DPMS */
247 * Gets the reply of the DPMSGetTimeouts request sent by ecore_x_dpms_timeouts_get_prefetch().
248 * @ingroup Ecore_X_DPMS_Group
251 ecore_x_dpms_timeouts_get_fetch(void)
253 #ifdef ECORE_XCB_DPMS
254 xcb_dpms_get_timeouts_cookie_t cookie;
255 xcb_dpms_get_timeouts_reply_t *reply;
257 cookie.sequence = _ecore_xcb_cookie_get();
258 reply = xcb_dpms_get_timeouts_reply(_ecore_xcb_conn, cookie, NULL);
259 _ecore_xcb_reply_cache(reply);
260 #endif /* ECORE_XCB_DPMS */
265 * Gets the timeouts. The values are in unit of seconds.
266 * @param standby Amount of time of inactivity before standby mode will be invoked.
267 * @param suspend Amount of time of inactivity before the screen is placed into suspend mode.
268 * @param off Amount of time of inactivity before the monitor is shut off.
269 * @ingroup Ecore_X_DPMS_Group
272 ecore_x_dpms_timeouts_get(unsigned int *standby,
273 unsigned int *suspend,
276 #ifdef ECORE_XCB_DPMS
277 xcb_dpms_get_timeouts_reply_t *reply;
279 reply = _ecore_xcb_reply_get();
282 if (standby) *standby = reply->standby_timeout;
283 if (suspend) *suspend = reply->suspend_timeout;
287 #endif /* ECORE_XCB_DPMS */
289 if (standby) *standby = 0;
290 if (suspend) *suspend = 0;
297 * Returns the amount of time of inactivity before standby mode is invoked.
298 * @return The standby timeout value.
300 * To use this function, you must call before, and in order,
301 * ecore_x_dpms_timeouts_get_prefetch(), which sends the DPMSGetTimeouts request,
302 * then ecore_x_dpms_timeouts_get_fetch(), which gets the reply.
303 * @ingroup Ecore_X_DPMS_Group
306 ecore_x_dpms_timeout_standby_get(void)
309 #ifdef ECORE_XCB_DPMS
310 xcb_dpms_get_timeouts_reply_t *reply;
312 reply = _ecore_xcb_reply_get();
313 if (!reply) return 0;
315 standby = reply->standby_timeout;
316 #endif /* ECORE_XCB_DPMS */
323 * Returns the amount of time of inactivity before the second level of
324 * power saving is invoked.
325 * @return The suspend timeout value.
327 * To use this function, you must call before, and in order,
328 * ecore_x_dpms_timeouts_get_prefetch(), which sends the DPMSGetTimeouts request,
329 * then ecore_x_dpms_timeouts_get_fetch(), which gets the reply.
330 * @ingroup Ecore_X_DPMS_Group
333 ecore_x_dpms_timeout_suspend_get(void)
336 #ifdef ECORE_XCB_DPMS
337 xcb_dpms_get_timeouts_reply_t *reply;
339 reply = _ecore_xcb_reply_get();
340 if (!reply) return 0;
342 suspend = reply->suspend_timeout;
343 #endif /* ECORE_XCB_DPMS */
350 * Returns the amount of time of inactivity before the third and final
351 * level of power saving is invoked.
352 * @return The off timeout value.
354 * To use this function, you must call before, and in order,
355 * ecore_x_dpms_timeouts_get_prefetch(), which sends the DPMSGetTimeouts request,
356 * then ecore_x_dpms_timeouts_get_fetch(), which gets the reply.
357 * @ingroup Ecore_X_DPMS_Group
360 ecore_x_dpms_timeout_off_get(void)
363 #ifdef ECORE_XCB_DPMS
364 xcb_dpms_get_timeouts_reply_t *reply;
366 reply = _ecore_xcb_reply_get();
367 if (!reply) return 0;
369 off = reply->off_timeout;
370 #endif /* ECORE_XCB_DPMS */
377 * Sets the standby timeout (in unit of seconds).
378 * @param new_standby Amount of time of inactivity before standby mode will be invoked.
380 * To use this function, you must call before, and in order,
381 * ecore_x_dpms_timeouts_get_prefetch(), which sends the DPMSGetTimeouts request,
382 * then ecore_x_dpms_timeouts_get_fetch(), which gets the reply.
383 * @ingroup Ecore_X_DPMS_Group
386 ecore_x_dpms_timeout_standby_set(unsigned int new_standby)
388 #ifdef ECORE_XCB_DPMS
389 xcb_dpms_get_timeouts_reply_t *reply;
391 reply = _ecore_xcb_reply_get();
394 xcb_dpms_set_timeouts(_ecore_xcb_conn,
396 reply->suspend_timeout,
398 #endif /* ECORE_XCB_DPMS */
403 * Sets the suspend timeout (in unit of seconds).
404 * @param suspend Amount of time of inactivity before the screen is placed into suspend mode.
406 * To use this function, you must call before, and in order,
407 * ecore_x_dpms_timeouts_get_prefetch(), which sends the DPMSGetTimeouts request,
408 * then ecore_x_dpms_timeouts_get_fetch(), which gets the reply.
409 * @ingroup Ecore_X_DPMS_Group
412 ecore_x_dpms_timeout_suspend_set(unsigned int new_suspend)
414 #ifdef ECORE_XCB_DPMS
415 xcb_dpms_get_timeouts_reply_t *reply;
417 reply = _ecore_xcb_reply_get();
420 xcb_dpms_set_timeouts(_ecore_xcb_conn,
421 reply->standby_timeout,
424 #endif /* ECORE_XCB_DPMS */
429 * Sets the off timeout (in unit of seconds).
430 * @param off Amount of time of inactivity before the monitor is shut off.
432 * To use this function, you must call before, and in order,
433 * ecore_x_dpms_timeouts_get_prefetch(), which sends the DPMSGetTimeouts request,
434 * then ecore_x_dpms_timeouts_get_fetch(), which gets the reply.
435 * @ingroup Ecore_X_DPMS_Group
438 ecore_x_dpms_timeout_off_set(unsigned int new_off)
440 #ifdef ECORE_XCB_DPMS
441 xcb_dpms_get_timeouts_reply_t *reply;
443 reply = _ecore_xcb_reply_get();
446 xcb_dpms_set_timeouts(_ecore_xcb_conn,
447 reply->standby_timeout,
448 reply->suspend_timeout,
450 #endif /* ECORE_XCB_DPMS */