aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_dpms.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-04 18:41:13 +1000
committerDavid Walter Seikel2012-01-04 18:41:13 +1000
commitdd7595a3475407a7fa96a97393bae8c5220e8762 (patch)
treee341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_dpms.c
parentAdd the skeleton. (diff)
downloadSledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to '')
-rw-r--r--libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_dpms.c318
1 files changed, 318 insertions, 0 deletions
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_dpms.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_dpms.c
new file mode 100644
index 0000000..63b7f1e
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_dpms.c
@@ -0,0 +1,318 @@
1#include "ecore_xcb_private.h"
2#ifdef ECORE_XCB_DAMAGE
3# include <xcb/dpms.h>
4#endif
5
6/* local variables */
7static Eina_Bool _dpms_avail = EINA_FALSE;
8
9void
10_ecore_xcb_dpms_init(void)
11{
12 LOGFN(__FILE__, __LINE__, __FUNCTION__);
13
14#ifdef ECORE_XCB_DPMS
15 xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_dpms_id);
16#endif
17}
18
19void
20_ecore_xcb_dpms_finalize(void)
21{
22#ifdef ECORE_XCB_DPMS
23 const xcb_query_extension_reply_t *ext_reply;
24#endif
25
26 LOGFN(__FILE__, __LINE__, __FUNCTION__);
27
28#ifdef ECORE_XCB_DPMS
29 ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_dpms_id);
30 if ((ext_reply) && (ext_reply->present))
31 {
32 xcb_dpms_get_version_cookie_t cookie;
33 xcb_dpms_get_version_reply_t *reply;
34
35 cookie =
36 xcb_dpms_get_version_unchecked(_ecore_xcb_conn,
37 XCB_DPMS_MAJOR_VERSION,
38 XCB_DPMS_MINOR_VERSION);
39 reply = xcb_dpms_get_version_reply(_ecore_xcb_conn, cookie, NULL);
40 if (reply)
41 {
42 if (reply->server_major_version >= 1)
43 _dpms_avail = EINA_TRUE;
44 free(reply);
45 }
46 }
47#endif
48}
49
50/**
51 * @defgroup Ecore_X_DPMS_Group X DPMS Extension Functions
52 *
53 * Functions related to the X DPMS Extension
54 */
55
56/**
57 * Checks if the DPMS extension is available or not.
58 *
59 * @return @c EINA_TRUE if the DPMS extension is available,
60 * @c EINA_FALSE otherwise.
61 *
62 * Return EINA_TRUE if the X server supports the DPMS Extension version 1.0,
63 * EINA_FALSE otherwise.
64 *
65 * @ingroup Ecore_X_DPMS_Group
66 */
67EAPI Eina_Bool
68ecore_x_dpms_query(void)
69{
70// LOGFN(__FILE__, __LINE__, __FUNCTION__);
71
72 return _dpms_avail;
73}
74
75/**
76 * Checks if the X server is capable of DPMS.
77 * @return @c 1 if the X server is capable of DPMS, @c 0 otherwise.
78 * @ingroup Ecore_X_DPMS_Group
79 */
80EAPI Eina_Bool
81ecore_x_dpms_capable_get(void)
82{
83 Eina_Bool ret = EINA_FALSE;
84#ifdef ECORE_XCB_DPMS
85 xcb_dpms_capable_cookie_t cookie;
86 xcb_dpms_capable_reply_t *reply;
87#endif
88
89 LOGFN(__FILE__, __LINE__, __FUNCTION__);
90 CHECK_XCB_CONN;
91
92 if (!_dpms_avail) return EINA_FALSE;
93
94#ifdef ECORE_XCB_DPMS
95 cookie = xcb_dpms_capable_unchecked(_ecore_xcb_conn);
96 reply = xcb_dpms_capable_reply(_ecore_xcb_conn, cookie, NULL);
97 if (reply)
98 {
99 ret = reply->capable;
100 free(reply);
101 }
102#endif
103
104 return ret;
105}
106
107/**
108 * Checks the DPMS state of the display.
109 * @return @c EINA_TRUE if DPMS is enabled, @c EINA_FALSE otherwise.
110 * @ingroup Ecore_X_DPMS_Group
111 */
112EAPI Eina_Bool
113ecore_x_dpms_enabled_get(void)
114{
115 Eina_Bool ret = EINA_FALSE;
116#ifdef ECORE_XCB_DPMS
117 xcb_dpms_info_cookie_t cookie;
118 xcb_dpms_info_reply_t *reply;
119#endif
120
121 LOGFN(__FILE__, __LINE__, __FUNCTION__);
122 CHECK_XCB_CONN;
123
124 if (!_dpms_avail) return EINA_FALSE;
125
126#ifdef ECORE_XCB_DPMS
127 cookie = xcb_dpms_info_unchecked(_ecore_xcb_conn);
128 reply = xcb_dpms_info_reply(_ecore_xcb_conn, cookie, NULL);
129 if (!reply) return EINA_FALSE;
130 if (reply->state) ret = EINA_TRUE;
131 free(reply);
132#endif
133
134 return ret;
135}
136
137/**
138 * Sets the DPMS state of the display.
139 * @param enabled @c 0 to disable DPMS characteristics of the server, enable it otherwise.
140 * @ingroup Ecore_X_DPMS_Group
141 */
142EAPI void
143ecore_x_dpms_enabled_set(int enabled)
144{
145 LOGFN(__FILE__, __LINE__, __FUNCTION__);
146 CHECK_XCB_CONN;
147
148 if (!_dpms_avail) return;
149
150#ifdef ECORE_XCB_DPMS
151 if (enabled)
152 xcb_dpms_enable(_ecore_xcb_conn);
153 else
154 xcb_dpms_disable(_ecore_xcb_conn);
155#endif
156}
157
158/**
159 * Gets the timeouts. The values are in unit of seconds.
160 * @param standby Amount of time of inactivity before standby mode will be invoked.
161 * @param suspend Amount of time of inactivity before the screen is placed into suspend mode.
162 * @param off Amount of time of inactivity before the monitor is shut off.
163 * @ingroup Ecore_X_DPMS_Group
164 */
165EAPI void
166ecore_x_dpms_timeouts_get(unsigned int *standby,
167 unsigned int *suspend,
168 unsigned int *off)
169{
170#ifdef ECORE_XCB_DPMS
171 xcb_dpms_get_timeouts_cookie_t cookie;
172 xcb_dpms_get_timeouts_reply_t *reply;
173#endif
174
175 LOGFN(__FILE__, __LINE__, __FUNCTION__);
176 CHECK_XCB_CONN;
177
178 if (standby) *standby = 0;
179 if (suspend) *suspend = 0;
180 if (off) *off = 0;
181
182 if (!_dpms_avail) return;
183
184#ifdef ECORE_XCB_DPMS
185 cookie = xcb_dpms_get_timeouts_unchecked(_ecore_xcb_conn);
186 reply = xcb_dpms_get_timeouts_reply(_ecore_xcb_conn, cookie, NULL);
187 if (!reply) return;
188 if (standby) *standby = reply->standby_timeout;
189 if (suspend) *suspend = reply->suspend_timeout;
190 if (off) *off = reply->off_timeout;
191 free(reply);
192#endif
193}
194
195/**
196 * Sets the timeouts. The values are in unit of seconds.
197 * @param standby Amount of time of inactivity before standby mode will be invoked.
198 * @param suspend Amount of time of inactivity before the screen is placed into suspend mode.
199 * @param off Amount of time of inactivity before the monitor is shut off.
200 * @ingroup Ecore_X_DPMS_Group
201 */
202EAPI Eina_Bool
203ecore_x_dpms_timeouts_set(unsigned int standby,
204 unsigned int suspend,
205 unsigned int off)
206{
207 LOGFN(__FILE__, __LINE__, __FUNCTION__);
208 CHECK_XCB_CONN;
209
210 if (!_dpms_avail) return EINA_FALSE;
211
212#ifdef ECORE_XCB_DPMS
213 // FIXME: Add request check
214 xcb_dpms_set_timeouts(_ecore_xcb_conn, standby, suspend, off);
215 return EINA_TRUE;
216#endif
217
218 return EINA_FALSE;
219}
220
221/**
222 * Returns the amount of time of inactivity before standby mode is invoked.
223 * @return The standby timeout value.
224 * @ingroup Ecore_X_DPMS_Group
225 */
226EAPI unsigned int
227ecore_x_dpms_timeout_standby_get(void)
228{
229 unsigned int standby = 0;
230
231 LOGFN(__FILE__, __LINE__, __FUNCTION__);
232
233 ecore_x_dpms_timeouts_get(&standby, NULL, NULL);
234 return standby;
235}
236
237/**
238 * Returns the amount of time of inactivity before the second level of
239 * power saving is invoked.
240 * @return The suspend timeout value.
241 * @ingroup Ecore_X_DPMS_Group
242 */
243EAPI unsigned int
244ecore_x_dpms_timeout_suspend_get(void)
245{
246 unsigned int suspend = 0;
247
248 LOGFN(__FILE__, __LINE__, __FUNCTION__);
249
250 ecore_x_dpms_timeouts_get(NULL, &suspend, NULL);
251 return suspend;
252}
253
254/**
255 * Returns the amount of time of inactivity before the third and final
256 * level of power saving is invoked.
257 * @return The off timeout value.
258 * @ingroup Ecore_X_DPMS_Group
259 */
260EAPI unsigned int
261ecore_x_dpms_timeout_off_get(void)
262{
263 unsigned int off = 0;
264
265 LOGFN(__FILE__, __LINE__, __FUNCTION__);
266
267 ecore_x_dpms_timeouts_get(NULL, NULL, &off);
268 return off;
269}
270
271/**
272 * Sets the standby timeout (in unit of seconds).
273 * @param new_standby Amount of time of inactivity before standby mode will be invoked.
274 * @ingroup Ecore_X_DPMS_Group
275 */
276EAPI void
277ecore_x_dpms_timeout_standby_set(unsigned int new_timeout)
278{
279 unsigned int standby = 0, suspend = 0, off = 0;
280
281 LOGFN(__FILE__, __LINE__, __FUNCTION__);
282
283 ecore_x_dpms_timeouts_get(&standby, &suspend, &off);
284 ecore_x_dpms_timeouts_set(new_timeout, suspend, off);
285}
286
287/**
288 * Sets the suspend timeout (in unit of seconds).
289 * @param suspend Amount of time of inactivity before the screen is placed into suspend mode.
290 * @ingroup Ecore_X_DPMS_Group
291 */
292EAPI void
293ecore_x_dpms_timeout_suspend_set(unsigned int new_timeout)
294{
295 unsigned int standby = 0, suspend = 0, off = 0;
296
297 LOGFN(__FILE__, __LINE__, __FUNCTION__);
298
299 ecore_x_dpms_timeouts_get(&standby, &suspend, &off);
300 ecore_x_dpms_timeouts_set(standby, new_timeout, off);
301}
302
303/**
304 * Sets the off timeout (in unit of seconds).
305 * @param off Amount of time of inactivity before the monitor is shut off.
306 * @ingroup Ecore_X_DPMS_Group
307 */
308EAPI void
309ecore_x_dpms_timeout_off_set(unsigned int new_timeout)
310{
311 unsigned int standby = 0, suspend = 0, off = 0;
312
313 LOGFN(__FILE__, __LINE__, __FUNCTION__);
314
315 ecore_x_dpms_timeouts_get(&standby, &suspend, &off);
316 ecore_x_dpms_timeouts_set(standby, suspend, new_timeout);
317}
318