diff options
Diffstat (limited to 'libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_11.c')
-rw-r--r-- | libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_11.c | 335 |
1 files changed, 0 insertions, 335 deletions
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_11.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_11.c deleted file mode 100644 index 816f8d5..0000000 --- a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_11.c +++ /dev/null | |||
@@ -1,335 +0,0 @@ | |||
1 | /* | ||
2 | * vim:ts=8:sw=3:sts=8:expandtab:cino=>5n-3f0^-2{2 | ||
3 | */ | ||
4 | |||
5 | #ifdef HAVE_CONFIG_H | ||
6 | # include <config.h> | ||
7 | #endif /* ifdef HAVE_CONFIG_H */ | ||
8 | |||
9 | #include "ecore_x_private.h" | ||
10 | #include "ecore_x_randr.h" | ||
11 | #include <stdio.h> | ||
12 | #include <stdlib.h> | ||
13 | #include <unistd.h> | ||
14 | #include <string.h> | ||
15 | |||
16 | #define Ecore_X_Randr_None 0 | ||
17 | #ifdef ECORE_XRANDR | ||
18 | |||
19 | #define RANDR_1_1 ((1 << 16) | 1) | ||
20 | |||
21 | #define RANDR_VALIDATE_ROOT(screen, \ | ||
22 | root) ((screen = \ | ||
23 | XRRRootToScreen(_ecore_x_disp, \ | ||
24 | root)) != -1) | ||
25 | #define RANDR_CHECK_1_1_RET(ret) if (_randr_version < RANDR_1_1) \ | ||
26 | return ret | ||
27 | |||
28 | extern XRRScreenResources *(*_ecore_x_randr_get_screen_resources)(Display * | ||
29 | dpy, | ||
30 | Window | ||
31 | window); | ||
32 | extern int _randr_version; | ||
33 | #endif /* ifdef ECORE_XRANDR */ | ||
34 | |||
35 | /* | ||
36 | * @param root window which's primary output will be queried | ||
37 | */ | ||
38 | EAPI Ecore_X_Randr_Orientation | ||
39 | ecore_x_randr_screen_primary_output_orientations_get(Ecore_X_Window root) | ||
40 | { | ||
41 | #ifdef ECORE_XRANDR | ||
42 | Rotation rot = Ecore_X_Randr_None, crot; | ||
43 | |||
44 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
45 | rot = | ||
46 | XRRRotations(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp, | ||
47 | root), &crot); | ||
48 | return rot; | ||
49 | #else /* ifdef ECORE_XRANDR */ | ||
50 | return Ecore_X_Randr_None; | ||
51 | #endif /* ifdef ECORE_XRANDR */ | ||
52 | } | ||
53 | |||
54 | /* | ||
55 | * @param root window which's primary output will be queried | ||
56 | * @return the current orientation of the root window's screen primary output | ||
57 | */ | ||
58 | EAPI Ecore_X_Randr_Orientation | ||
59 | ecore_x_randr_screen_primary_output_orientation_get(Ecore_X_Window root) | ||
60 | { | ||
61 | #ifdef ECORE_XRANDR | ||
62 | Rotation crot = Ecore_X_Randr_None; | ||
63 | XRRRotations(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp, | ||
64 | root), &crot); | ||
65 | return crot; | ||
66 | #else /* ifdef ECORE_XRANDR */ | ||
67 | return Ecore_X_Randr_None; | ||
68 | #endif /* ifdef ECORE_XRANDR */ | ||
69 | } | ||
70 | |||
71 | /* | ||
72 | * @brief sets a given screen's primary output's orientation | ||
73 | * @param root window which's screen's primary output will be queried | ||
74 | * @param orientation orientation which should be set for the root window's screen primary output | ||
75 | * @return EINA_TRUE if the primary output's orientation could be successfully altered | ||
76 | */ | ||
77 | EAPI Eina_Bool | ||
78 | ecore_x_randr_screen_primary_output_orientation_set( | ||
79 | Ecore_X_Window root, | ||
80 | Ecore_X_Randr_Orientation | ||
81 | orientation) | ||
82 | { | ||
83 | #ifdef ECORE_XRANDR | ||
84 | XRRScreenConfiguration *xrr_screen_cfg = NULL; | ||
85 | int sizeid; | ||
86 | Rotation crot; | ||
87 | Eina_Bool ret = EINA_FALSE; | ||
88 | if (!(xrr_screen_cfg = XRRGetScreenInfo(_ecore_x_disp, root))) | ||
89 | return EINA_FALSE; | ||
90 | |||
91 | sizeid = XRRConfigCurrentConfiguration(xrr_screen_cfg, &crot); | ||
92 | if (!XRRSetScreenConfig(_ecore_x_disp, xrr_screen_cfg, root, sizeid, | ||
93 | orientation, CurrentTime)) | ||
94 | ret = EINA_TRUE; | ||
95 | |||
96 | if (xrr_screen_cfg) | ||
97 | XRRFreeScreenConfigInfo(xrr_screen_cfg); | ||
98 | |||
99 | return ret; | ||
100 | #else /* ifdef ECORE_XRANDR */ | ||
101 | return EINA_FALSE; | ||
102 | #endif /* ifdef ECORE_XRANDR */ | ||
103 | } | ||
104 | |||
105 | /* | ||
106 | * @brief gets a screen's primary output's possible sizes | ||
107 | * @param root window which's primary output will be queried | ||
108 | * @param num number of sizes reported as supported by the screen's primary output | ||
109 | * @return an array of sizes reported as supported by the screen's primary output or - if query failed - NULL | ||
110 | */ | ||
111 | EAPI Ecore_X_Randr_Screen_Size_MM * | ||
112 | ecore_x_randr_screen_primary_output_sizes_get(Ecore_X_Window root, | ||
113 | int *num) | ||
114 | { | ||
115 | #ifdef ECORE_XRANDR | ||
116 | Ecore_X_Randr_Screen_Size_MM *ret = NULL; | ||
117 | XRRScreenSize *sizes; | ||
118 | int i, n; | ||
119 | |||
120 | /* we don't have to free sizes, because they're hold in a cache inside X*/ | ||
121 | sizes = | ||
122 | XRRSizes(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp, | ||
123 | root), &n); | ||
124 | if ((!sizes) || (n <= 0)) return NULL; | ||
125 | ret = calloc(n, sizeof(Ecore_X_Randr_Screen_Size_MM)); | ||
126 | if (!ret) | ||
127 | return NULL; | ||
128 | |||
129 | if (num) | ||
130 | *num = n; | ||
131 | |||
132 | for (i = 0; i < n; i++) | ||
133 | { | ||
134 | ret[i].width = sizes[i].width; | ||
135 | ret[i].height = sizes[i].height; | ||
136 | ret[i].width_mm = sizes[i].mwidth; | ||
137 | ret[i].height_mm = sizes[i].mheight; | ||
138 | } | ||
139 | return ret; | ||
140 | #else /* ifdef ECORE_XRANDR */ | ||
141 | return NULL; | ||
142 | #endif /* ifdef ECORE_XRANDR */ | ||
143 | } | ||
144 | |||
145 | /* | ||
146 | * @brief get the current set size of a given screen's primary output | ||
147 | * @param root window which's primary output will be queried | ||
148 | * @param w the current size's width | ||
149 | * @param h the current size's height | ||
150 | * @param w_mm the current size's width in mm | ||
151 | * @param h_mm the current size's height in mm | ||
152 | * @param size_index of current set size to be used with ecore_x_randr_primary_output_size_set() | ||
153 | */ | ||
154 | EAPI void | ||
155 | ecore_x_randr_screen_primary_output_current_size_get(Ecore_X_Window root, | ||
156 | int *w, | ||
157 | int *h, | ||
158 | int *w_mm, | ||
159 | int *h_mm, | ||
160 | int *size_index) | ||
161 | { | ||
162 | #ifdef ECORE_XRANDR | ||
163 | XRRScreenSize *sizes; | ||
164 | XRRScreenConfiguration *sc = NULL; | ||
165 | int idx; | ||
166 | Rotation orientation; | ||
167 | int n; | ||
168 | |||
169 | if (!(sc = XRRGetScreenInfo(_ecore_x_disp, root))) | ||
170 | { | ||
171 | ERR("Couldn't get screen information for %d", root); | ||
172 | return; | ||
173 | } | ||
174 | |||
175 | idx = XRRConfigCurrentConfiguration(sc, &orientation); | ||
176 | |||
177 | sizes = | ||
178 | XRRSizes(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp, | ||
179 | root), &n); | ||
180 | if ((idx < n) && (idx >= 0)) | ||
181 | { | ||
182 | if (w) | ||
183 | *w = sizes[idx].width; | ||
184 | |||
185 | if (h) | ||
186 | *h = sizes[idx].height; | ||
187 | |||
188 | if (w_mm) | ||
189 | *w_mm = sizes[idx].mwidth; | ||
190 | |||
191 | if (h_mm) | ||
192 | *h_mm = sizes[idx].mheight; | ||
193 | |||
194 | if (size_index) | ||
195 | *size_index = idx; | ||
196 | } | ||
197 | |||
198 | XRRFreeScreenConfigInfo(sc); | ||
199 | #endif /* ifdef ECORE_XRANDR */ | ||
200 | } | ||
201 | |||
202 | /* | ||
203 | * @brief sets a given screen's primary output size, but disables all other outputs at the same time | ||
204 | * @param root window which's primary output will be queried | ||
205 | * @param size_index within the list of sizes reported as supported by the root window's screen primary output | ||
206 | * @return EINA_TRUE on success, EINA_FALSE on failure due to e.g. invalid times | ||
207 | */ | ||
208 | EAPI Eina_Bool | ||
209 | ecore_x_randr_screen_primary_output_size_set(Ecore_X_Window root, | ||
210 | int size_index) | ||
211 | { | ||
212 | #ifdef ECORE_XRANDR | ||
213 | XRRScreenConfiguration *sc = NULL; | ||
214 | Eina_Bool ret = EINA_FALSE; | ||
215 | int nsizes = 0; | ||
216 | |||
217 | if (size_index >= 0 && _ecore_x_randr_root_validate(root)) | ||
218 | { | ||
219 | XRRSizes(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp, | ||
220 | root), &nsizes); | ||
221 | |||
222 | if (size_index < nsizes) | ||
223 | { | ||
224 | sc = XRRGetScreenInfo(_ecore_x_disp, root); | ||
225 | if (!XRRSetScreenConfig(_ecore_x_disp, sc, | ||
226 | root, size_index, | ||
227 | ECORE_X_RANDR_ORIENTATION_ROT_0, CurrentTime)) | ||
228 | { | ||
229 | ret = EINA_TRUE; | ||
230 | } | ||
231 | |||
232 | if (sc) | ||
233 | XRRFreeScreenConfigInfo(sc); | ||
234 | } | ||
235 | } | ||
236 | |||
237 | return ret; | ||
238 | #else /* ifdef ECORE_XRANDR */ | ||
239 | return EINA_FALSE; | ||
240 | #endif /* ifdef ECORE_XRANDR */ | ||
241 | } | ||
242 | |||
243 | /* | ||
244 | * @param root window which's primary output will be queried | ||
245 | * @return currently used refresh rate or - if request failed or RandRR is not available - 0.0 | ||
246 | */ | ||
247 | EAPI Ecore_X_Randr_Refresh_Rate | ||
248 | ecore_x_randr_screen_primary_output_current_refresh_rate_get( | ||
249 | Ecore_X_Window root) | ||
250 | { | ||
251 | #ifdef ECORE_XRANDR | ||
252 | Ecore_X_Randr_Refresh_Rate ret = 0.0; | ||
253 | XRRScreenConfiguration *sc = NULL; | ||
254 | |||
255 | if (!_ecore_x_randr_root_validate(root) || | ||
256 | !(sc = XRRGetScreenInfo(_ecore_x_disp, root))) | ||
257 | return ret; | ||
258 | |||
259 | ret = XRRConfigCurrentRate(sc); | ||
260 | if (sc) | ||
261 | XRRFreeScreenConfigInfo(sc); | ||
262 | |||
263 | return ret; | ||
264 | #else /* ifdef ECORE_XRANDR */ | ||
265 | return 0.0; | ||
266 | #endif /* ifdef ECORE_XRANDR */ | ||
267 | } | ||
268 | |||
269 | /* | ||
270 | * @param root window which's primary output will be queried | ||
271 | * @param size_index referencing the size to query valid refresh rates for | ||
272 | * @return currently used refresh rate or - if request failed or RandRR is not available - NULL | ||
273 | */ | ||
274 | EAPI Ecore_X_Randr_Refresh_Rate * | ||
275 | ecore_x_randr_screen_primary_output_refresh_rates_get(Ecore_X_Window root, | ||
276 | int size_index, | ||
277 | int *num) | ||
278 | { | ||
279 | #ifdef ECORE_XRANDR | ||
280 | Ecore_X_Randr_Refresh_Rate *ret = NULL, *rates = NULL; | ||
281 | Ecore_X_Randr_Screen scr; | ||
282 | int n; | ||
283 | |||
284 | if (num | ||
285 | && RANDR_VALIDATE_ROOT(scr, root) | ||
286 | && (rates = XRRRates(_ecore_x_disp, scr, size_index, &n))) | ||
287 | { | ||
288 | if (rates && (ret = malloc(sizeof(Ecore_X_Randr_Refresh_Rate) * n))) | ||
289 | { | ||
290 | memcpy(ret, rates, (sizeof(Ecore_X_Randr_Refresh_Rate) * n)); | ||
291 | *num = n; | ||
292 | } | ||
293 | } | ||
294 | |||
295 | return ret; | ||
296 | #else /* ifdef ECORE_XRANDR */ | ||
297 | return NULL; | ||
298 | #endif /* ifdef ECORE_XRANDR */ | ||
299 | } | ||
300 | |||
301 | //>= 1.1 | ||
302 | /* | ||
303 | * @brief sets the current primary output's refresh rate | ||
304 | * @param root window which's primary output will be queried | ||
305 | * @param size_index referencing the size to be set | ||
306 | * @param rate the refresh rate to be set | ||
307 | * @return EINA_TRUE on success else EINA_FALSE | ||
308 | */ | ||
309 | EAPI Eina_Bool | ||
310 | ecore_x_randr_screen_primary_output_refresh_rate_set( | ||
311 | Ecore_X_Window root, | ||
312 | int size_index, | ||
313 | Ecore_X_Randr_Refresh_Rate | ||
314 | rate) | ||
315 | { | ||
316 | #ifdef ECORE_XRANDR | ||
317 | RANDR_CHECK_1_1_RET(EINA_FALSE); | ||
318 | Eina_Bool ret = EINA_FALSE; | ||
319 | XRRScreenConfiguration *sc = NULL; | ||
320 | |||
321 | if (!(sc = XRRGetScreenInfo(_ecore_x_disp, root))) | ||
322 | return ret; | ||
323 | |||
324 | if (!XRRSetScreenConfigAndRate(_ecore_x_disp, sc, | ||
325 | root, size_index, | ||
326 | RR_Rotate_0, rate, CurrentTime)) | ||
327 | ret = EINA_TRUE; | ||
328 | |||
329 | XRRFreeScreenConfigInfo(sc); | ||
330 | return ret; | ||
331 | #else /* ifdef ECORE_XRANDR */ | ||
332 | return EINA_FALSE; | ||
333 | #endif /* ifdef ECORE_XRANDR */ | ||
334 | } | ||
335 | |||