diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/ecore/src/lib/ecore_x/xlib/ecore_x_screensaver.c | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_screensaver.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_screensaver.c new file mode 100644 index 0000000..a3bca67 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_screensaver.c | |||
@@ -0,0 +1,173 @@ | |||
1 | /* | ||
2 | * Screensaver code | ||
3 | */ | ||
4 | |||
5 | #ifdef HAVE_CONFIG_H | ||
6 | # include <config.h> | ||
7 | #endif /* ifdef HAVE_CONFIG_H */ | ||
8 | |||
9 | #include "Ecore.h" | ||
10 | #include "ecore_x_private.h" | ||
11 | #include "Ecore_X.h" | ||
12 | #include "Ecore_X_Atoms.h" | ||
13 | |||
14 | static int _screensaver_available = -1; | ||
15 | |||
16 | EAPI Eina_Bool | ||
17 | ecore_x_screensaver_event_available_get(void) | ||
18 | { | ||
19 | if (_screensaver_available >= 0) | ||
20 | return _screensaver_available; | ||
21 | |||
22 | #ifdef ECORE_XSS | ||
23 | int _screensaver_major, _screensaver_minor; | ||
24 | |||
25 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
26 | _screensaver_major = 1; | ||
27 | _screensaver_minor = 0; | ||
28 | |||
29 | if (XScreenSaverQueryVersion(_ecore_x_disp, &_screensaver_major, | ||
30 | &_screensaver_minor)) | ||
31 | _screensaver_available = 1; | ||
32 | else | ||
33 | _screensaver_available = 0; | ||
34 | |||
35 | #else /* ifdef ECORE_XSS */ | ||
36 | _screensaver_available = 0; | ||
37 | #endif /* ifdef ECORE_XSS */ | ||
38 | return _screensaver_available; | ||
39 | } /* ecore_x_screensaver_event_available_get */ | ||
40 | |||
41 | EAPI int | ||
42 | ecore_x_screensaver_idle_time_get(void) | ||
43 | { | ||
44 | #ifdef ECORE_XSS | ||
45 | XScreenSaverInfo *xss; | ||
46 | int idle; | ||
47 | |||
48 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
49 | xss = XScreenSaverAllocInfo(); | ||
50 | XScreenSaverQueryInfo(_ecore_x_disp, | ||
51 | RootWindow(_ecore_x_disp, DefaultScreen( | ||
52 | _ecore_x_disp)), xss); | ||
53 | idle = xss->idle / 1000; | ||
54 | XFree(xss); | ||
55 | |||
56 | return idle; | ||
57 | #else | ||
58 | return 0; | ||
59 | #endif /* ifdef ECORE_XSS */ | ||
60 | } /* ecore_x_screensaver_idle_time_get */ | ||
61 | |||
62 | EAPI void | ||
63 | ecore_x_screensaver_set(int timeout, | ||
64 | int interval, | ||
65 | int prefer_blanking, | ||
66 | int allow_exposures) | ||
67 | { | ||
68 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
69 | XSetScreenSaver(_ecore_x_disp, | ||
70 | timeout, | ||
71 | interval, | ||
72 | prefer_blanking, | ||
73 | allow_exposures); | ||
74 | } /* ecore_x_screensaver_set */ | ||
75 | |||
76 | EAPI void | ||
77 | ecore_x_screensaver_timeout_set(int timeout) | ||
78 | { | ||
79 | int pto, pint, pblank, pexpo; | ||
80 | |||
81 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
82 | XGetScreenSaver(_ecore_x_disp, &pto, &pint, &pblank, &pexpo); | ||
83 | XSetScreenSaver(_ecore_x_disp, timeout, pint, pblank, pexpo); | ||
84 | } /* ecore_x_screensaver_timeout_set */ | ||
85 | |||
86 | EAPI int | ||
87 | ecore_x_screensaver_timeout_get(void) | ||
88 | { | ||
89 | int pto, pint, pblank, pexpo; | ||
90 | |||
91 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
92 | XGetScreenSaver(_ecore_x_disp, &pto, &pint, &pblank, &pexpo); | ||
93 | return pto; | ||
94 | } /* ecore_x_screensaver_timeout_get */ | ||
95 | |||
96 | EAPI void | ||
97 | ecore_x_screensaver_blank_set(int blank) | ||
98 | { | ||
99 | int pto, pint, pblank, pexpo; | ||
100 | |||
101 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
102 | XGetScreenSaver(_ecore_x_disp, &pto, &pint, &pblank, &pexpo); | ||
103 | XSetScreenSaver(_ecore_x_disp, pto, pint, blank, pexpo); | ||
104 | } /* ecore_x_screensaver_blank_set */ | ||
105 | |||
106 | EAPI int | ||
107 | ecore_x_screensaver_blank_get(void) | ||
108 | { | ||
109 | int pto, pint, pblank, pexpo; | ||
110 | |||
111 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
112 | XGetScreenSaver(_ecore_x_disp, &pto, &pint, &pblank, &pexpo); | ||
113 | return pblank; | ||
114 | } /* ecore_x_screensaver_blank_get */ | ||
115 | |||
116 | EAPI void | ||
117 | ecore_x_screensaver_expose_set(int expose) | ||
118 | { | ||
119 | int pto, pint, pblank, pexpo; | ||
120 | |||
121 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
122 | XGetScreenSaver(_ecore_x_disp, &pto, &pint, &pblank, &pexpo); | ||
123 | XSetScreenSaver(_ecore_x_disp, pto, pint, pblank, expose); | ||
124 | } /* ecore_x_screensaver_expose_set */ | ||
125 | |||
126 | EAPI int | ||
127 | ecore_x_screensaver_expose_get(void) | ||
128 | { | ||
129 | int pto, pint, pblank, pexpo; | ||
130 | |||
131 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
132 | XGetScreenSaver(_ecore_x_disp, &pto, &pint, &pblank, &pexpo); | ||
133 | return pexpo; | ||
134 | } /* ecore_x_screensaver_expose_get */ | ||
135 | |||
136 | EAPI void | ||
137 | ecore_x_screensaver_interval_set(int interval) | ||
138 | { | ||
139 | int pto, pint, pblank, pexpo; | ||
140 | |||
141 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
142 | XGetScreenSaver(_ecore_x_disp, &pto, &pint, &pblank, &pexpo); | ||
143 | XSetScreenSaver(_ecore_x_disp, pto, interval, pblank, pexpo); | ||
144 | } /* ecore_x_screensaver_interval_set */ | ||
145 | |||
146 | EAPI int | ||
147 | ecore_x_screensaver_interval_get(void) | ||
148 | { | ||
149 | int pto, pint, pblank, pexpo; | ||
150 | |||
151 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
152 | XGetScreenSaver(_ecore_x_disp, &pto, &pint, &pblank, &pexpo); | ||
153 | return pint; | ||
154 | } /* ecore_x_screensaver_interval_get */ | ||
155 | |||
156 | EAPI void | ||
157 | ecore_x_screensaver_event_listen_set(Eina_Bool on) | ||
158 | { | ||
159 | #ifdef ECORE_XSS | ||
160 | Ecore_X_Window root; | ||
161 | |||
162 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
163 | root = DefaultRootWindow(_ecore_x_disp); | ||
164 | if (on) | ||
165 | XScreenSaverSelectInput(_ecore_x_disp, root, ScreenSaverNotifyMask); | ||
166 | else | ||
167 | XScreenSaverSelectInput(_ecore_x_disp, root, 0); | ||
168 | #else | ||
169 | return; | ||
170 | on = EINA_FALSE; | ||
171 | #endif /* ifdef ECORE_XSS */ | ||
172 | } /* ecore_x_screensaver_event_listen_set */ | ||
173 | |||