1 #include "ecore_xcb_private.h"
4 * @defgroup Ecore_X_DPMS_Group X DPMS Extension Functions
6 * Functions related to the X DPMS extension.
10 static int _dpms_available = 0;
11 static xcb_dpms_get_version_cookie_t _ecore_xcb_dpms_init_cookie;
12 #endif /* ECORE_XCB_DPMS */
14 /* To avoid round trips, the initialization is separated in 2
15 functions: _ecore_xcb_dpms_init and
16 _ecore_xcb_dpms_init_finalize. The first one gets the cookies and
17 the second one gets the replies. */
20 _ecore_x_dpms_init(const xcb_query_extension_reply_t *reply)
23 if (reply && (reply->present))
24 _ecore_xcb_dpms_init_cookie = xcb_dpms_get_version_unchecked(_ecore_xcb_conn, 0, 0);
26 #endif /* ECORE_XCB_DPMS */
27 } /* _ecore_x_dpms_init */
30 _ecore_x_dpms_init_finalize(void)
33 xcb_dpms_get_version_reply_t *reply;
35 reply = xcb_dpms_get_version_reply(_ecore_xcb_conn,
36 _ecore_xcb_dpms_init_cookie, NULL);
40 if (reply->server_major_version >= 1)
46 #endif /* ECORE_XCB_DPMS */
47 } /* _ecore_x_dpms_init_finalize */
50 * Checks if the DPMS extension is available or not.
51 * @return @c 1 if the DPMS extension is available, @c 0 otherwise.
53 * Return 1 if the X server supports the DPMS Extension version 1.0,
55 * @ingroup Ecore_X_DPMS_Group
58 ecore_x_dpms_query(void)
61 return _dpms_available;
62 #else /* ifdef ECORE_XCB_DPMS */
64 #endif /* ECORE_XCB_DPMS */
65 } /* ecore_x_dpms_query */
68 * Sends the DPMSCapable request.
69 * @ingroup Ecore_X_DPMS_Group
72 ecore_x_dpms_capable_get_prefetch(void)
75 xcb_dpms_capable_cookie_t cookie;
77 cookie = xcb_dpms_capable_unchecked(_ecore_xcb_conn);
78 _ecore_xcb_cookie_cache(cookie.sequence);
79 #endif /* ECORE_XCB_DPMS */
80 } /* ecore_x_dpms_capable_get_prefetch */
83 * Gets the reply of the DPMSCapable request sent by ecore_x_dpms_capable_get_prefetch().
84 * @ingroup Ecore_X_DPMS_Group
87 ecore_x_dpms_capable_get_fetch(void)
90 xcb_dpms_capable_cookie_t cookie;
91 xcb_dpms_capable_reply_t *reply;
93 cookie.sequence = _ecore_xcb_cookie_get();
94 reply = xcb_dpms_capable_reply(_ecore_xcb_conn, cookie, NULL);
95 _ecore_xcb_reply_cache(reply);
96 #endif /* ECORE_XCB_DPMS */
97 } /* ecore_x_dpms_capable_get_fetch */
100 * Checks if the X server is capable of DPMS.
101 * @return @c 1 if the X server is capable of DPMS, @c 0 otherwise.
103 * To use this function, you must call before, and in order,
104 * ecore_x_dpms_capable_get_prefetch(), which sends the DPMSCapable request,
105 * then ecore_x_dpms_capable_get_fetch(), which gets the reply.
106 * @ingroup Ecore_X_DPMS_Group
109 ecore_x_dpms_capable_get(void)
112 #ifdef ECORE_XCB_DPMS
113 xcb_dpms_capable_reply_t *reply;
115 reply = _ecore_xcb_reply_get();
119 capable = reply->capable;
120 #endif /* ECORE_XCB_DPMS */
123 } /* ecore_x_dpms_capable_get */
126 * Sends the DPMSInfo request.
127 * @ingroup Ecore_X_DPMS_Group
130 ecore_x_dpms_enable_get_prefetch(void)
132 #ifdef ECORE_XCB_DPMS
133 xcb_dpms_info_cookie_t cookie;
135 cookie = xcb_dpms_info_unchecked(_ecore_xcb_conn);
136 _ecore_xcb_cookie_cache(cookie.sequence);
137 #endif /* ECORE_XCB_DPMS */
138 } /* ecore_x_dpms_enable_get_prefetch */
141 * Gets the reply of the DPMSInfo request sent by ecore_x_dpms_enable_get_prefetch().
142 * @ingroup Ecore_X_DPMS_Group
145 ecore_x_dpms_enable_get_fetch(void)
147 #ifdef ECORE_XCB_DPMS
148 xcb_dpms_info_cookie_t cookie;
149 xcb_dpms_info_reply_t *reply;
151 cookie.sequence = _ecore_xcb_cookie_get();
152 reply = xcb_dpms_info_reply(_ecore_xcb_conn, cookie, NULL);
153 _ecore_xcb_reply_cache(reply);
154 #endif /* ECORE_XCB_DPMS */
155 } /* ecore_x_dpms_enable_get_fetch */
158 * Checks the DPMS state of the display.
159 * @return @c 1 if DPMS is enabled, @c 0 otherwise.
161 * To use this function, you must call before, and in order,
162 * ecore_x_dpms_enapable_get_prefetch(), which sends the DPMSInfo request,
163 * then ecore_x_dpms_enapable_get_fetch(), which gets the reply.
164 * @ingroup Ecore_X_DPMS_Group
167 ecore_x_dpms_enable_get(void)
170 #ifdef ECORE_XCB_DPMS
171 xcb_dpms_info_reply_t *reply;
173 reply = _ecore_xcb_reply_get();
177 enable = reply->state;
178 #endif /* ECORE_XCB_DPMS */
181 } /* ecore_x_dpms_enable_get */
184 * Sets the DPMS state of the display.
185 * @param enabled @c 0 to disable DPMS characteristics of the server, enable it otherwise.
186 * @ingroup Ecore_X_DPMS_Group
189 ecore_x_dpms_enabled_set(int enabled)
191 #ifdef ECORE_XCB_DPMS
193 xcb_dpms_enable(_ecore_xcb_conn);
195 xcb_dpms_disable(_ecore_xcb_conn);
197 #endif /* ECORE_XCB_DPMS */
198 } /* ecore_x_dpms_enabled_set */
201 * Sets the timeouts. The values are in unit of seconds.
202 * @param standby Amount of time of inactivity before standby mode will be invoked.
203 * @param suspend Amount of time of inactivity before the screen is placed into suspend mode.
204 * @param off Amount of time of inactivity before the monitor is shut off.
205 * @return Returns always 1.
206 * @ingroup Ecore_X_DPMS_Group
209 ecore_x_dpms_timeouts_set(unsigned int standby,
210 unsigned int suspend,
213 #ifdef ECORE_XCB_DPMS
214 xcb_dpms_set_timeouts(_ecore_xcb_conn, standby, suspend, off);
215 #endif /* ECORE_XCB_DPMS */
218 } /* ecore_x_dpms_timeouts_set */
221 * Sends the DPMSGetTimeouts request.
222 * @ingroup Ecore_X_DPMS_Group
225 ecore_x_dpms_timeouts_get_prefetch(void)
227 #ifdef ECORE_XCB_DPMS
228 xcb_dpms_get_timeouts_cookie_t cookie;
230 cookie = xcb_dpms_get_timeouts_unchecked(_ecore_xcb_conn);
231 _ecore_xcb_cookie_cache(cookie.sequence);
232 #endif /* ECORE_XCB_DPMS */
233 } /* ecore_x_dpms_timeouts_get_prefetch */
236 * Gets the reply of the DPMSGetTimeouts request sent by ecore_x_dpms_timeouts_get_prefetch().
237 * @ingroup Ecore_X_DPMS_Group
240 ecore_x_dpms_timeouts_get_fetch(void)
242 #ifdef ECORE_XCB_DPMS
243 xcb_dpms_get_timeouts_cookie_t cookie;
244 xcb_dpms_get_timeouts_reply_t *reply;
246 cookie.sequence = _ecore_xcb_cookie_get();
247 reply = xcb_dpms_get_timeouts_reply(_ecore_xcb_conn, cookie, NULL);
248 _ecore_xcb_reply_cache(reply);
249 #endif /* ECORE_XCB_DPMS */
250 } /* ecore_x_dpms_timeouts_get_fetch */
253 * Gets the timeouts. The values are in unit of seconds.
254 * @param standby Amount of time of inactivity before standby mode will be invoked.
255 * @param suspend Amount of time of inactivity before the screen is placed into suspend mode.
256 * @param off Amount of time of inactivity before the monitor is shut off.
257 * @ingroup Ecore_X_DPMS_Group
260 ecore_x_dpms_timeouts_get(unsigned int *standby,
261 unsigned int *suspend,
264 #ifdef ECORE_XCB_DPMS
265 xcb_dpms_get_timeouts_reply_t *reply;
267 reply = _ecore_xcb_reply_get();
271 *standby = reply->standby_timeout;
274 *suspend = reply->suspend_timeout;
280 #endif /* ECORE_XCB_DPMS */
291 } /* ecore_x_dpms_timeouts_get */
294 * Returns the amount of time of inactivity before standby mode is invoked.
295 * @return The standby timeout value.
297 * To use this function, you must call before, and in order,
298 * ecore_x_dpms_timeouts_get_prefetch(), which sends the DPMSGetTimeouts request,
299 * then ecore_x_dpms_timeouts_get_fetch(), which gets the reply.
300 * @ingroup Ecore_X_DPMS_Group
303 ecore_x_dpms_timeout_standby_get(void)
306 #ifdef ECORE_XCB_DPMS
307 xcb_dpms_get_timeouts_reply_t *reply;
309 reply = _ecore_xcb_reply_get();
313 standby = reply->standby_timeout;
314 #endif /* ECORE_XCB_DPMS */
317 } /* ecore_x_dpms_timeout_standby_get */
320 * Returns the amount of time of inactivity before the second level of
321 * power saving is invoked.
322 * @return The suspend timeout value.
324 * To use this function, you must call before, and in order,
325 * ecore_x_dpms_timeouts_get_prefetch(), which sends the DPMSGetTimeouts request,
326 * then ecore_x_dpms_timeouts_get_fetch(), which gets the reply.
327 * @ingroup Ecore_X_DPMS_Group
330 ecore_x_dpms_timeout_suspend_get(void)
333 #ifdef ECORE_XCB_DPMS
334 xcb_dpms_get_timeouts_reply_t *reply;
336 reply = _ecore_xcb_reply_get();
340 suspend = reply->suspend_timeout;
341 #endif /* ECORE_XCB_DPMS */
344 } /* ecore_x_dpms_timeout_suspend_get */
347 * Returns the amount of time of inactivity before the third and final
348 * level of power saving is invoked.
349 * @return The off timeout value.
351 * To use this function, you must call before, and in order,
352 * ecore_x_dpms_timeouts_get_prefetch(), which sends the DPMSGetTimeouts request,
353 * then ecore_x_dpms_timeouts_get_fetch(), which gets the reply.
354 * @ingroup Ecore_X_DPMS_Group
357 ecore_x_dpms_timeout_off_get(void)
360 #ifdef ECORE_XCB_DPMS
361 xcb_dpms_get_timeouts_reply_t *reply;
363 reply = _ecore_xcb_reply_get();
367 off = reply->off_timeout;
368 #endif /* ECORE_XCB_DPMS */
371 } /* ecore_x_dpms_timeout_off_get */
374 * Sets the standby timeout (in unit of seconds).
375 * @param new_standby Amount of time of inactivity before standby mode will be invoked.
377 * To use this function, you must call before, and in order,
378 * ecore_x_dpms_timeouts_get_prefetch(), which sends the DPMSGetTimeouts request,
379 * then ecore_x_dpms_timeouts_get_fetch(), which gets the reply.
380 * @ingroup Ecore_X_DPMS_Group
383 ecore_x_dpms_timeout_standby_set(unsigned int new_standby)
385 #ifdef ECORE_XCB_DPMS
386 xcb_dpms_get_timeouts_reply_t *reply;
388 reply = _ecore_xcb_reply_get();
392 xcb_dpms_set_timeouts(_ecore_xcb_conn,
394 reply->suspend_timeout,
396 #endif /* ECORE_XCB_DPMS */
397 } /* ecore_x_dpms_timeout_standby_set */
400 * Sets the suspend timeout (in unit of seconds).
401 * @param suspend Amount of time of inactivity before the screen is placed into suspend mode.
403 * To use this function, you must call before, and in order,
404 * ecore_x_dpms_timeouts_get_prefetch(), which sends the DPMSGetTimeouts request,
405 * then ecore_x_dpms_timeouts_get_fetch(), which gets the reply.
406 * @ingroup Ecore_X_DPMS_Group
409 ecore_x_dpms_timeout_suspend_set(unsigned int new_suspend)
411 #ifdef ECORE_XCB_DPMS
412 xcb_dpms_get_timeouts_reply_t *reply;
414 reply = _ecore_xcb_reply_get();
418 xcb_dpms_set_timeouts(_ecore_xcb_conn,
419 reply->standby_timeout,
422 #endif /* ECORE_XCB_DPMS */
423 } /* ecore_x_dpms_timeout_suspend_set */
426 * Sets the off timeout (in unit of seconds).
427 * @param off Amount of time of inactivity before the monitor is shut off.
429 * To use this function, you must call before, and in order,
430 * ecore_x_dpms_timeouts_get_prefetch(), which sends the DPMSGetTimeouts request,
431 * then ecore_x_dpms_timeouts_get_fetch(), which gets the reply.
432 * @ingroup Ecore_X_DPMS_Group
435 ecore_x_dpms_timeout_off_set(unsigned int new_off)
437 #ifdef ECORE_XCB_DPMS
438 xcb_dpms_get_timeouts_reply_t *reply;
440 reply = _ecore_xcb_reply_get();
444 xcb_dpms_set_timeouts(_ecore_xcb_conn,
445 reply->standby_timeout,
446 reply->suspend_timeout,
448 #endif /* ECORE_XCB_DPMS */
449 } /* ecore_x_dpms_timeout_off_set */