1 /* TODO: List of missing functions
3 * ecore_x_randr_crtc_clone_set
4 * ecore_x_randr_output_crtc_set
5 * ecore_x_randr_edid_version_get
6 * ecore_x_randr_edid_info_has_valid_checksum
7 * ecore_x_randr_edid_manufacturer_name_get
8 * ecore_x_randr_edid_display_ascii_get
9 * ecore_x_randr_edid_display_serial_get
10 * ecore_x_randr_edid_model_get
11 * ecore_x_randr_edid_manufacturer_serial_number_get
12 * ecore_x_randr_edid_manufacturer_model_get
13 * ecore_x_randr_edid_dpms_available_get
14 * ecore_x_randr_edid_dpms_standby_available_get
15 * ecore_x_randr_edid_dpms_suspend_available_get
16 * ecore_x_randr_edid_dpms_off_available_get
17 * ecore_x_randr_edid_display_aspect_ratio_preferred_get
18 * ecore_x_randr_edid_display_aspect_ratios_get
19 * ecore_x_randr_edid_display_colorscheme_get
20 * ecore_x_randr_edid_display_type_digital_get
21 * ecore_x_randr_edid_display_interface_type_get
22 * ecore_x_randr_screen_backlight_level_set
23 * ecore_x_randr_output_subpixel_order_get
24 * ecore_x_randr_output_wired_clones_get
25 * ecore_x_randr_output_compatibility_list_get
26 * ecore_x_randr_output_signal_formats_get
27 * ecore_x_randr_output_signal_format_set
28 * ecore_x_randr_output_signal_properties_get
29 * ecore_x_randr_output_connector_number_get
30 * ecore_x_randr_output_connector_type_get
31 * ecore_x_randr_crtc_panning_area_get
32 * ecore_x_randr_crtc_panning_area_set
33 * ecore_x_randr_crtc_tracking_area_get
34 * ecore_x_randr_crtc_tracking_area_set
35 * ecore_x_randr_crtc_border_area_get
36 * ecore_x_randr_crtc_border_area_set
39 #include "ecore_xcb_private.h"
40 # ifdef ECORE_XCB_RANDR
41 # include <xcb/randr.h>
44 #define Ecore_X_Randr_None 0
45 #define Ecore_X_Randr_Unset -1
47 #define RANDR_1_1 ((1 << 16) | 1)
48 #define RANDR_1_2 ((1 << 16) | 2)
49 #define RANDR_1_3 ((1 << 16) | 3)
51 #define RANDR_CHECK_1_1_RET(ret) if (_randr_version < RANDR_1_1) return ret
52 #define RANDR_CHECK_1_2_RET(ret) if (_randr_version < RANDR_1_2) return ret
53 #define RANDR_CHECK_1_3_RET(ret) if (_randr_version < RANDR_1_3) return ret
55 #define ECORE_X_RANDR_EDID_VERSION_13 ((1 << 8) | 3)
56 #define _ECORE_X_RANDR_EDID_OFFSET_VERSION_MAJOR 0x12
57 #define _ECORE_X_RANDR_EDID_OFFSET_VERSION_MINOR 0x13
58 #define _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK 0x36
59 #define _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_TYPE 3
60 #define _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_CONTENT 5
61 #define _ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX 13
63 #define _ECORE_X_RANDR_EDID_FOR_EACH_DESCRIPTOR_BLOCK(edid, block) \
64 for (block = edid + _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK; block <= (edid + _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK + (3 * 18)); block += 18)
66 #define _ECORE_X_RANDR_EDID_FOR_EACH_NON_PIXEL_DESCRIPTOR_BLOCK(edid, block) \
67 _ECORE_X_RANDR_EDID_FOR_EACH_DESCRIPTOR_BLOCK(edid, block) \
68 if ((block[0] == 0) && (block[1] == 0))
70 /* local function prototypes */
71 static Eina_Bool _ecore_xcb_randr_output_validate(Ecore_X_Window root,
72 Ecore_X_Randr_Output output);
73 static Eina_Bool _ecore_xcb_randr_crtc_validate(Ecore_X_Window root,
74 Ecore_X_Randr_Crtc crtc);
75 static Eina_Bool _ecore_xcb_randr_root_validate(Ecore_X_Window root);
76 static int _ecore_xcb_randr_root_to_screen(Ecore_X_Window root);
77 #ifdef ECORE_XCB_RANDR
78 static xcb_randr_get_screen_resources_reply_t *_ecore_xcb_randr_12_get_resources(Ecore_X_Window win);
79 static xcb_randr_get_screen_resources_current_reply_t *_ecore_xcb_randr_13_get_resources(Ecore_X_Window win);
81 static xcb_timestamp_t _ecore_xcb_randr_12_get_resource_timestamp(Ecore_X_Window win);
82 static xcb_timestamp_t _ecore_xcb_randr_13_get_resource_timestamp(Ecore_X_Window win);
84 static Ecore_X_Randr_Mode *_ecore_xcb_randr_12_output_modes_get(Ecore_X_Window root,
85 Ecore_X_Randr_Output output,
88 static Ecore_X_Randr_Mode *_ecore_xcb_randr_13_output_modes_get(Ecore_X_Window root,
89 Ecore_X_Randr_Output output,
92 static Ecore_X_Randr_Mode_Info *_ecore_xcb_randr_12_mode_info_get(Ecore_X_Window root,
93 Ecore_X_Randr_Mode mode);
94 static Ecore_X_Randr_Mode_Info *_ecore_xcb_randr_13_mode_info_get(Ecore_X_Window root,
95 Ecore_X_Randr_Mode mode);
96 static Ecore_X_Randr_Mode_Info **_ecore_xcb_randr_12_modes_info_get(Ecore_X_Window root,
98 static Ecore_X_Randr_Mode_Info **_ecore_xcb_randr_13_modes_info_get(Ecore_X_Window root,
100 static void _ecore_xcb_randr_12_mode_size_get(Ecore_X_Window root,
101 Ecore_X_Randr_Mode mode,
104 static void _ecore_xcb_randr_13_mode_size_get(Ecore_X_Window root,
105 Ecore_X_Randr_Mode mode,
108 static Ecore_X_Randr_Output *_ecore_xcb_randr_12_output_clones_get(Ecore_X_Window root,
109 Ecore_X_Randr_Output output,
111 static Ecore_X_Randr_Output *_ecore_xcb_randr_13_output_clones_get(Ecore_X_Window root,
112 Ecore_X_Randr_Output output,
114 static Ecore_X_Randr_Crtc *_ecore_xcb_randr_12_output_possible_crtcs_get(Ecore_X_Window root,
115 Ecore_X_Randr_Output output,
117 static Ecore_X_Randr_Crtc *_ecore_xcb_randr_13_output_possible_crtcs_get(Ecore_X_Window root,
118 Ecore_X_Randr_Output output,
120 static char *_ecore_xcb_randr_12_output_name_get(Ecore_X_Window root,
121 Ecore_X_Randr_Output output,
123 static char *_ecore_xcb_randr_13_output_name_get(Ecore_X_Window root,
124 Ecore_X_Randr_Output output,
126 static Ecore_X_Randr_Connection_Status _ecore_xcb_randr_12_output_connection_status_get(Ecore_X_Window root,
127 Ecore_X_Randr_Output output);
128 static Ecore_X_Randr_Connection_Status _ecore_xcb_randr_13_output_connection_status_get(Ecore_X_Window root,
129 Ecore_X_Randr_Output output);
130 static Ecore_X_Randr_Output *_ecore_xcb_randr_12_outputs_get(Ecore_X_Window root,
132 static Ecore_X_Randr_Output *_ecore_xcb_randr_13_outputs_get(Ecore_X_Window root,
134 static Ecore_X_Randr_Crtc _ecore_xcb_randr_12_output_crtc_get(Ecore_X_Window root,
135 Ecore_X_Randr_Output output);
136 static Ecore_X_Randr_Crtc _ecore_xcb_randr_13_output_crtc_get(Ecore_X_Window root,
137 Ecore_X_Randr_Output output);
139 /* local variables */
140 static Eina_Bool _randr_avail = EINA_FALSE;
141 static int _randr_version = -1;
143 /* external variables */
144 int _ecore_xcb_event_randr = -1;
147 _ecore_xcb_randr_init(void)
149 LOGFN(__FILE__, __LINE__, __FUNCTION__);
151 #ifdef ECORE_XCB_RANDR
152 xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_randr_id);
157 _ecore_xcb_randr_finalize(void)
159 #ifdef ECORE_XCB_RANDR
160 const xcb_query_extension_reply_t *ext_reply;
163 LOGFN(__FILE__, __LINE__, __FUNCTION__);
165 #ifdef ECORE_XCB_RANDR
166 ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_randr_id);
167 if ((ext_reply) && (ext_reply->present))
169 xcb_randr_query_version_cookie_t cookie;
170 xcb_randr_query_version_reply_t *reply;
173 xcb_randr_query_version_unchecked(_ecore_xcb_conn,
174 XCB_RANDR_MAJOR_VERSION,
175 XCB_RANDR_MINOR_VERSION);
176 reply = xcb_randr_query_version_reply(_ecore_xcb_conn, cookie, NULL);
179 if ((reply->major_version >= XCB_RANDR_MAJOR_VERSION) &&
180 (reply->minor_version >= XCB_RANDR_MINOR_VERSION))
181 _randr_avail = EINA_TRUE;
184 ((reply->major_version << 16) | reply->minor_version);
190 _ecore_xcb_event_randr = ext_reply->first_event;
196 #ifdef ECORE_XCB_RANDR
197 _ecore_xcb_randr_root_validate(Ecore_X_Window root)
199 _ecore_xcb_randr_root_validate(Ecore_X_Window root __UNUSED__)
202 #ifdef ECORE_XCB_RANDR
203 Ecore_X_Randr_Screen scr = -1;
204 # define RANDR_VALIDATE_ROOT(screen, root) \
205 ((screen == _ecore_xcb_randr_root_to_screen(root)) != -1)
208 LOGFN(__FILE__, __LINE__, __FUNCTION__);
210 #ifdef ECORE_XCB_RANDR
211 if ((root) && RANDR_VALIDATE_ROOT(scr, root))
219 _ecore_xcb_randr_root_to_screen(Ecore_X_Window root)
221 int count = 0, num = 0;
225 count = xcb_setup_roots_length(xcb_get_setup(_ecore_xcb_conn));
226 for (num = 0; num < count; num++)
227 if (_ecore_xcb_window_root_of_screen_get(num) == root)
233 /* public functions */
236 * @brief Query whether RandR is available or not.
238 * @return @c EINA_TRUE if extension is available, @c EINA_FALSE otherwise.
241 ecore_x_randr_query(void)
247 * @return version of the RandRR extension supported by the server or,
248 * in case RandRR extension is not available, Ecore_X_Randr_Unset (=-1).
249 * bit version information: 31 MAJOR 16 | 15 MINOR 0
252 ecore_x_randr_version_get(void)
254 return _randr_version;
258 * @param root window which's primary output will be queried
260 EAPI Ecore_X_Randr_Orientation
261 ecore_x_randr_screen_primary_output_orientations_get(Ecore_X_Window root)
263 int ret = Ecore_X_Randr_None;
264 #ifdef ECORE_XCB_RANDR
265 xcb_randr_get_screen_info_cookie_t cookie;
266 xcb_randr_get_screen_info_reply_t *reply;
269 LOGFN(__FILE__, __LINE__, __FUNCTION__);
272 #ifdef ECORE_XCB_RANDR
273 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root);
274 reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL);
277 ret = reply->rotations;
286 * @param root window which's primary output will be queried
287 * @return the current orientation of the root window's screen primary output
289 EAPI Ecore_X_Randr_Orientation
290 ecore_x_randr_screen_primary_output_orientation_get(Ecore_X_Window root)
292 int ret = Ecore_X_Randr_None;
293 #ifdef ECORE_XCB_RANDR
294 xcb_randr_get_screen_info_cookie_t cookie;
295 xcb_randr_get_screen_info_reply_t *reply;
298 LOGFN(__FILE__, __LINE__, __FUNCTION__);
301 #ifdef ECORE_XCB_RANDR
302 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root);
303 reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL);
306 ret = reply->rotation;
315 * @brief Sets a given screen's primary output's orientation.
317 * @param root Window which's screen's primary output will be queried.
318 * @param orientation Orientation which should be set for the root window's
319 * screen primary output.
320 * @return @c EINA_TRUE if the primary output's orientation could be
321 * successfully altered.
324 ecore_x_randr_screen_primary_output_orientation_set(Ecore_X_Window root,
325 Ecore_X_Randr_Orientation orientation)
327 int ret = EINA_FALSE;
328 #ifdef ECORE_XCB_RANDR
329 xcb_randr_get_screen_info_cookie_t cookie;
330 xcb_randr_get_screen_info_reply_t *reply;
333 LOGFN(__FILE__, __LINE__, __FUNCTION__);
336 #ifdef ECORE_XCB_RANDR
337 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root);
338 reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL);
341 xcb_randr_set_screen_config_cookie_t scookie;
342 xcb_randr_set_screen_config_reply_t *sreply;
345 xcb_randr_set_screen_config_unchecked(_ecore_xcb_conn, root,
347 reply->config_timestamp,
348 reply->sizeID, orientation,
351 xcb_randr_set_screen_config_reply(_ecore_xcb_conn, scookie, NULL);
356 ret = (sreply->status == XCB_RANDR_SET_CONFIG_SUCCESS) ?
357 EINA_TRUE : EINA_FALSE;
368 * @brief gets a screen's primary output's possible sizes
369 * @param root window which's primary output will be queried
370 * @param num number of sizes reported as supported by the screen's primary output
371 * @return an array of sizes reported as supported by the screen's primary output or - if query failed - NULL
373 EAPI Ecore_X_Randr_Screen_Size_MM *
374 ecore_x_randr_screen_primary_output_sizes_get(Ecore_X_Window root,
377 #ifdef ECORE_XCB_RANDR
378 xcb_randr_get_screen_info_cookie_t cookie;
379 xcb_randr_get_screen_info_reply_t *reply;
380 Ecore_X_Randr_Screen_Size_MM *ret = NULL;
383 LOGFN(__FILE__, __LINE__, __FUNCTION__);
386 #ifdef ECORE_XCB_RANDR
387 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root);
388 reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL);
392 xcb_randr_screen_size_t *sizes;
394 len = xcb_randr_get_screen_info_sizes_length(reply);
395 sizes = xcb_randr_get_screen_info_sizes(reply);
396 if ((!sizes) || (len <= 0))
402 ret = calloc(len, sizeof(Ecore_X_Randr_Screen_Size_MM));
408 for (i = 0; i < len; i++)
410 ret[i].width = sizes[i].width;
411 ret[i].height = sizes[i].height;
412 ret[i].width_mm = sizes[i].mwidth;
413 ret[i].height_mm = sizes[i].mheight;
426 * @brief get the current set size of a given screen's primary output
427 * @param root window which's primary output will be queried
428 * @param w the current size's width
429 * @param h the current size's height
430 * @param w_mm the current size's width in mm
431 * @param h_mm the current size's height in mm
432 * @param size_index of current set size to be used with ecore_x_randr_primary_output_size_set()
435 ecore_x_randr_screen_primary_output_current_size_get(Ecore_X_Window root,
442 #ifdef ECORE_XCB_RANDR
443 xcb_randr_get_screen_info_cookie_t cookie;
444 xcb_randr_get_screen_info_reply_t *reply;
447 LOGFN(__FILE__, __LINE__, __FUNCTION__);
450 #ifdef ECORE_XCB_RANDR
451 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root);
452 reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL);
455 int len = 0, idx = 0;
456 xcb_randr_screen_size_t *sizes;
458 len = xcb_randr_get_screen_info_sizes_length(reply);
459 sizes = xcb_randr_get_screen_info_sizes(reply);
460 if ((!sizes) || (len <= 0))
466 if ((idx < len) && (idx >= 0))
468 if (w) *w = sizes[idx].width;
469 if (h) *h = sizes[idx].height;
470 if (w_mm) *w_mm = sizes[idx].mwidth;
471 if (h_mm) *h_mm = sizes[idx].mheight;
472 if (size_index) *size_index = idx;
481 * @brief Sets a given screen's primary output size, but disables all other
482 * outputs at the same time.
484 * @param root Window which's primary output will be queried.
485 * @param size_index Within the list of sizes reported as supported by the root
486 * window's screen primary output.
487 * @return @c EINA_TRUE on success, @c EINA_FALSE on failure due to e.g.
491 ecore_x_randr_screen_primary_output_size_set(Ecore_X_Window root,
494 Eina_Bool ret = EINA_FALSE;
495 #ifdef ECORE_XCB_RANDR
496 xcb_randr_get_screen_info_cookie_t cookie;
497 xcb_randr_get_screen_info_reply_t *reply;
500 LOGFN(__FILE__, __LINE__, __FUNCTION__);
503 #ifdef ECORE_XCB_RANDR
504 if (!((size_index >= 0) && (_ecore_xcb_randr_root_validate(root))))
507 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root);
508 reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL);
513 len = xcb_randr_get_screen_info_sizes_length(reply);
519 if ((size_index < len) && (size_index >= 0))
521 xcb_randr_set_screen_config_cookie_t scookie;
522 xcb_randr_set_screen_config_reply_t *sreply;
525 xcb_randr_set_screen_config_unchecked(_ecore_xcb_conn, root,
527 reply->config_timestamp,
532 xcb_randr_set_screen_config_reply(_ecore_xcb_conn,
538 ret = (sreply->status == XCB_RANDR_SET_CONFIG_SUCCESS) ?
539 EINA_TRUE : EINA_FALSE;
551 * @param root window which's primary output will be queried
552 * @return currently used refresh rate or - if request failed or RandRR is not available - 0.0
554 EAPI Ecore_X_Randr_Refresh_Rate
555 ecore_x_randr_screen_primary_output_current_refresh_rate_get(Ecore_X_Window root)
557 #ifdef ECORE_XCB_RANDR
558 xcb_randr_get_screen_info_cookie_t cookie;
559 xcb_randr_get_screen_info_reply_t *reply;
560 Ecore_X_Randr_Refresh_Rate ret = 0.0;
563 LOGFN(__FILE__, __LINE__, __FUNCTION__);
566 #ifdef ECORE_XCB_RANDR
567 if (!_ecore_xcb_randr_root_validate(root)) return ret;
569 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root);
570 reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL);
584 * @param root window which's primary output will be queried
585 * @param size_index referencing the size to query valid refresh rates for
586 * @return currently used refresh rate or - if request failed or RandRR is not available - NULL
588 EAPI Ecore_X_Randr_Refresh_Rate *
589 ecore_x_randr_screen_primary_output_refresh_rates_get(Ecore_X_Window root,
593 #ifdef ECORE_XCB_RANDR
594 xcb_randr_get_screen_info_cookie_t cookie;
595 xcb_randr_get_screen_info_reply_t *reply;
596 Ecore_X_Randr_Refresh_Rate *ret = NULL;
599 LOGFN(__FILE__, __LINE__, __FUNCTION__);
602 #ifdef ECORE_XCB_RANDR
603 if (!_ecore_xcb_randr_root_validate(root)) return ret;
605 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root);
606 reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL);
611 len = xcb_randr_get_screen_info_rates_length(reply);
614 ret = malloc(sizeof(Ecore_X_Randr_Refresh_Rate) * len);
617 xcb_randr_refresh_rates_iterator_t iter;
620 iter = xcb_randr_get_screen_info_rates_iterator(reply);
621 while (i++ < size_index)
622 xcb_randr_refresh_rates_next(&iter);
624 memcpy(ret, xcb_randr_refresh_rates_rates(iter.data),
625 sizeof(Ecore_X_Randr_Refresh_Rate) * len);
637 * @brief Sets the current primary output's refresh rate.
639 * @param root Window which's primary output will be queried.
640 * @param size_index Referencing the size to be set.
641 * @param rate The refresh rate to be set.
642 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
645 ecore_x_randr_screen_primary_output_refresh_rate_set(Ecore_X_Window root,
647 Ecore_X_Randr_Refresh_Rate rate)
649 Eina_Bool ret = EINA_FALSE;
650 #ifdef ECORE_XCB_RANDR
651 xcb_randr_get_screen_info_cookie_t cookie;
652 xcb_randr_get_screen_info_reply_t *reply;
655 LOGFN(__FILE__, __LINE__, __FUNCTION__);
658 #ifdef ECORE_XCB_RANDR
659 if (_randr_version < RANDR_1_1) return EINA_FALSE;
661 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root);
662 reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL);
665 xcb_randr_set_screen_config_cookie_t scookie;
666 xcb_randr_set_screen_config_reply_t *sreply;
669 xcb_randr_set_screen_config_unchecked(_ecore_xcb_conn, root,
671 reply->config_timestamp,
673 reply->rotation, rate);
675 xcb_randr_set_screen_config_reply(_ecore_xcb_conn,
681 ret = (sreply->status == XCB_RANDR_SET_CONFIG_SUCCESS) ?
682 EINA_TRUE : EINA_FALSE;
693 * @brief Free detailed mode information. The pointer handed in will be set to
694 * @c NULL after freeing the memory.
696 * @param mode_info The mode information that should be freed.
699 ecore_x_randr_mode_info_free(Ecore_X_Randr_Mode_Info *mode_info)
701 LOGFN(__FILE__, __LINE__, __FUNCTION__);
704 RANDR_CHECK_1_2_RET();
706 if (!mode_info) return;
708 if (mode_info->name) free(mode_info->name);
714 * @param root window which's screen should be queried
715 * @return Ecore_X_Randr_Ouptut_Id or - if query failed or none is set - Ecore_X_Randr_None
717 EAPI Ecore_X_Randr_Output
718 ecore_x_randr_primary_output_get(Ecore_X_Window root)
720 Ecore_X_Randr_Output ret = Ecore_X_Randr_None;
721 #ifdef ECORE_XCB_RANDR
722 xcb_randr_get_output_primary_cookie_t cookie;
723 xcb_randr_get_output_primary_reply_t *reply;
726 LOGFN(__FILE__, __LINE__, __FUNCTION__);
729 #ifdef ECORE_XCB_RANDR
730 RANDR_CHECK_1_3_RET(Ecore_X_Randr_None);
732 if (!_ecore_xcb_randr_root_validate(root))
733 return Ecore_X_Randr_None;
735 cookie = xcb_randr_get_output_primary_unchecked(_ecore_xcb_conn, root);
736 reply = xcb_randr_get_output_primary_reply(_ecore_xcb_conn, cookie, NULL);
747 * @param root window which's screen should be queried
748 * @param output that should be set as given root window's screen primary output
751 ecore_x_randr_primary_output_set(Ecore_X_Window root,
752 Ecore_X_Randr_Output output)
754 LOGFN(__FILE__, __LINE__, __FUNCTION__);
757 #ifdef ECORE_XCB_RANDR
758 RANDR_CHECK_1_3_RET();
760 if ((output) && (_ecore_xcb_randr_root_validate(root)))
761 xcb_randr_set_output_primary(_ecore_xcb_conn, root, output);
765 EAPI Ecore_X_Randr_Mode *
766 ecore_x_randr_output_modes_get(Ecore_X_Window root,
767 Ecore_X_Randr_Output output,
771 Ecore_X_Randr_Mode *modes = NULL;
773 LOGFN(__FILE__, __LINE__, __FUNCTION__);
776 #ifdef ECORE_XCB_RANDR
777 RANDR_CHECK_1_2_RET(NULL);
779 if (_randr_version >= RANDR_1_3)
782 _ecore_xcb_randr_13_output_modes_get(root, output, num, npreferred);
784 else if (_randr_version == RANDR_1_2)
787 _ecore_xcb_randr_12_output_modes_get(root, output, num, npreferred);
795 ecore_x_randr_output_mode_add(Ecore_X_Randr_Output output, Ecore_X_Randr_Mode mode)
797 LOGFN(__FILE__, __LINE__, __FUNCTION__);
800 #ifdef ECORE_XCB_RANDR
801 RANDR_CHECK_1_2_RET(EINA_FALSE);
803 if ((output == Ecore_X_Randr_None) || (mode == Ecore_X_Randr_None))
806 xcb_randr_add_output_mode(_ecore_xcb_conn, output, mode);
813 * @brief get detailed information for a given mode id
814 * @param root window which's screen's ressources are queried
815 * @param mode the XID which identifies the mode of interest
816 * @return mode's detailed information
818 EAPI Ecore_X_Randr_Mode_Info *
819 ecore_x_randr_mode_info_get(Ecore_X_Window root,
820 Ecore_X_Randr_Mode mode)
822 Ecore_X_Randr_Mode_Info *ret = NULL;
824 LOGFN(__FILE__, __LINE__, __FUNCTION__);
827 #ifdef ECORE_XCB_RANDR
828 RANDR_CHECK_1_2_RET(NULL);
830 if (!_ecore_xcb_randr_root_validate(root)) return NULL;
832 if (_randr_version >= RANDR_1_3)
833 ret = _ecore_xcb_randr_13_mode_info_get(root, mode);
834 else if (_randr_version == RANDR_1_2)
835 ret = _ecore_xcb_randr_12_mode_info_get(root, mode);
841 * @brief add a mode to a display
842 * @param root window to which's screen's ressources are added
844 * @return Ecore_X_Randr_Mode of the added mode. Ecore_X_Randr_None if mode
848 EAPI Ecore_X_Randr_Mode
849 ecore_x_randr_mode_info_add(Ecore_X_Window root, Ecore_X_Randr_Mode_Info *mode_info)
851 Ecore_X_Randr_Mode mode = Ecore_X_Randr_None;
852 #ifdef ECORE_XCB_RANDR
853 xcb_randr_create_mode_cookie_t cookie;
854 xcb_randr_create_mode_reply_t *reply;
855 xcb_randr_mode_info_t info;
859 LOGFN(__FILE__, __LINE__, __FUNCTION__);
862 #ifdef ECORE_XCB_RANDR
863 RANDR_CHECK_1_2_RET(EINA_FALSE);
865 if (!mode_info) return Ecore_X_Randr_None;
866 if (!_ecore_xcb_randr_root_validate(root)) return Ecore_X_Randr_None;
868 namelen = strlen(mode_info->name);
870 memset(&info, 0, sizeof(info));
871 info.width = mode_info->width;
872 info.height = mode_info->height;
873 info.dot_clock = mode_info->dotClock;
874 info.hsync_start = mode_info->hSyncStart;
875 info.hsync_end = mode_info->hSyncEnd;
876 info.htotal = mode_info->hTotal;
877 info.hskew = mode_info->hSkew;
878 info.vsync_start = mode_info->vSyncStart;
879 info.vsync_end = mode_info->vSyncEnd;
880 info.vtotal = mode_info->vTotal;
881 info.mode_flags = mode_info->modeFlags;
882 info.name_len = namelen;
885 xcb_randr_create_mode_unchecked(_ecore_xcb_conn, root, info,
886 namelen, mode_info->name);
887 reply = xcb_randr_create_mode_reply(_ecore_xcb_conn, cookie, NULL);
890 mode = mode_info->xid;
898 * @brief get detailed information for all modes related to a root window's screen
899 * @param root window which's screen's ressources are queried
900 * @param num number of modes returned
901 * @return modes' information
903 EAPI Ecore_X_Randr_Mode_Info **
904 ecore_x_randr_modes_info_get(Ecore_X_Window root,
907 Ecore_X_Randr_Mode_Info **ret = NULL;
909 LOGFN(__FILE__, __LINE__, __FUNCTION__);
914 #ifdef ECORE_XCB_RANDR
915 RANDR_CHECK_1_2_RET(NULL);
917 if (!_ecore_xcb_randr_root_validate(root)) return NULL;
919 if (_randr_version >= RANDR_1_3)
920 ret = _ecore_xcb_randr_13_modes_info_get(root, num);
921 else if (_randr_version == RANDR_1_2)
922 ret = _ecore_xcb_randr_12_modes_info_get(root, num);
928 * @brief Gets the width and hight of a given mode.
930 * @param root Window which's screen's ressources are queried.
931 * @param mode The mode which's size is to be looked up.
932 * @param w Width of given mode in px.
933 * @param h Height of given mode in px.
936 ecore_x_randr_mode_size_get(Ecore_X_Window root,
937 Ecore_X_Randr_Mode mode,
941 LOGFN(__FILE__, __LINE__, __FUNCTION__);
944 #ifdef ECORE_XCB_RANDR
945 RANDR_CHECK_1_2_RET();
947 if (mode == Ecore_X_Randr_None) return;
949 if (_randr_version >= RANDR_1_3)
950 _ecore_xcb_randr_13_mode_size_get(root, mode, w, h);
951 else if (_randr_version == RANDR_1_2)
952 _ecore_xcb_randr_12_mode_size_get(root, mode, w, h);
957 * @brief Gets the EDID information of an attached output if available.
958 * Note that this information is not to be compared using ordinary string
959 * comparison functions, since it includes 0-bytes.
961 * @param root Window this information should be queried from.
962 * @param output The XID of the output.
963 * @param length Length of the byte-array. If @c NULL, request will fail.
964 * @return EDID information of the output.
967 ecore_x_randr_output_edid_get(Ecore_X_Window root,
968 Ecore_X_Randr_Output output,
969 unsigned long *length)
971 unsigned char *ret = NULL;
972 #ifdef ECORE_XCB_RANDR
973 xcb_randr_get_output_property_cookie_t cookie;
974 xcb_randr_get_output_property_reply_t *reply;
978 LOGFN(__FILE__, __LINE__, __FUNCTION__);
981 #ifdef ECORE_XCB_RANDR
982 RANDR_CHECK_1_2_RET(NULL);
984 if ((!length) || (!_ecore_xcb_randr_output_validate(root, output)))
987 atom = ecore_x_atom_get("EDID");
989 xcb_randr_get_output_property_unchecked(_ecore_xcb_conn, output, atom,
990 XCB_GET_PROPERTY_TYPE_ANY,
993 xcb_randr_get_output_property_reply(_ecore_xcb_conn, cookie, NULL);
996 if ((reply->type == XCB_ATOM_INTEGER) && (reply->format == 8))
998 if (length) *length = reply->num_items;
999 if ((ret = malloc(reply->num_items * sizeof(unsigned char))))
1001 memcpy(ret, xcb_randr_get_output_property_data(reply),
1002 (reply->num_items * sizeof(unsigned char)));
1012 * @brief Gets the outputs which might be used simultaneously on the same CRTC.
1014 * @param root Window that this information should be queried for.
1015 * @param output The output which's clones we concern.
1016 * @param num Number of possible clones.
1017 * @return The existing outputs, @c NULL otherwise.
1019 EAPI Ecore_X_Randr_Output *
1020 ecore_x_randr_output_clones_get(Ecore_X_Window root,
1021 Ecore_X_Randr_Output output,
1024 Ecore_X_Randr_Output *outputs = NULL;
1026 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1029 #ifdef ECORE_XCB_RANDR
1030 RANDR_CHECK_1_2_RET(NULL);
1032 if (output == Ecore_X_Randr_None) return NULL;
1034 if (_randr_version >= RANDR_1_3)
1035 outputs = _ecore_xcb_randr_13_output_clones_get(root, output, num);
1036 else if (_randr_version == RANDR_1_2)
1037 outputs = _ecore_xcb_randr_12_output_clones_get(root, output, num);
1042 EAPI Ecore_X_Randr_Crtc *
1043 ecore_x_randr_output_possible_crtcs_get(Ecore_X_Window root,
1044 Ecore_X_Randr_Output output,
1047 Ecore_X_Randr_Crtc *crtcs = NULL;
1049 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1052 #ifdef ECORE_XCB_RANDR
1053 RANDR_CHECK_1_2_RET(NULL);
1055 if (output == Ecore_X_Randr_None) return NULL;
1057 if (_randr_version >= RANDR_1_3)
1058 crtcs = _ecore_xcb_randr_13_output_possible_crtcs_get(root, output, num);
1059 else if (_randr_version == RANDR_1_2)
1060 crtcs = _ecore_xcb_randr_12_output_possible_crtcs_get(root, output, num);
1066 * @brief gets the given output's name as reported by X
1067 * @param root the window which's screen will be queried
1068 * @param output The output name given to be reported.
1069 * @param len length of returned c-string.
1070 * @return name of the output as reported by X
1073 ecore_x_randr_output_name_get(Ecore_X_Window root,
1074 Ecore_X_Randr_Output output,
1077 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1080 #ifdef ECORE_XCB_RANDR
1081 RANDR_CHECK_1_2_RET(NULL);
1083 if (output == Ecore_X_Randr_None) return NULL;
1085 if (_randr_version >= RANDR_1_3)
1086 return _ecore_xcb_randr_13_output_name_get(root, output, len);
1087 else if (_randr_version == RANDR_1_2)
1088 return _ecore_xcb_randr_12_output_name_get(root, output, len);
1094 EAPI Ecore_X_Randr_Connection_Status
1095 ecore_x_randr_output_connection_status_get(Ecore_X_Window root,
1096 Ecore_X_Randr_Output output)
1098 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1101 #ifdef ECORE_XCB_RANDR
1102 RANDR_CHECK_1_2_RET(ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN);
1104 if (output == Ecore_X_Randr_None)
1105 return ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN;
1107 if (_randr_version >= RANDR_1_3)
1108 return _ecore_xcb_randr_13_output_connection_status_get(root, output);
1109 else if (_randr_version == RANDR_1_2)
1110 return _ecore_xcb_randr_12_output_connection_status_get(root, output);
1113 return ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN;
1116 EAPI Ecore_X_Randr_Output *
1117 ecore_x_randr_outputs_get(Ecore_X_Window root,
1120 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1123 #ifdef ECORE_XCB_RANDR
1124 RANDR_CHECK_1_2_RET(NULL);
1126 if (_randr_version >= RANDR_1_3)
1127 return _ecore_xcb_randr_13_outputs_get(root, num);
1128 else if (_randr_version == RANDR_1_2)
1129 return _ecore_xcb_randr_12_outputs_get(root, num);
1135 EAPI Ecore_X_Randr_Crtc
1136 ecore_x_randr_output_crtc_get(Ecore_X_Window root,
1137 Ecore_X_Randr_Output output)
1139 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1142 #ifdef ECORE_XCB_RANDR
1143 RANDR_CHECK_1_2_RET(Ecore_X_Randr_None);
1145 if (output == Ecore_X_Randr_None) return Ecore_X_Randr_None;
1147 if (_randr_version >= RANDR_1_3)
1148 return _ecore_xcb_randr_13_output_crtc_get(root, output);
1149 else if (_randr_version == RANDR_1_2)
1150 return _ecore_xcb_randr_12_output_crtc_get(root, output);
1153 return Ecore_X_Randr_None;
1157 ecore_x_randr_output_size_mm_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *w_mm, int *h_mm)
1159 #ifdef ECORE_XCB_RANDR
1160 xcb_randr_get_output_info_cookie_t ocookie;
1161 xcb_randr_get_output_info_reply_t *oreply;
1162 xcb_timestamp_t timestamp = 0;
1165 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1168 if (w_mm) *w_mm = 0;
1169 if (h_mm) *h_mm = 0;
1171 #ifdef ECORE_XCB_RANDR
1172 RANDR_CHECK_1_2_RET();
1174 if ((output != Ecore_X_Randr_None) && (_randr_version >= RANDR_1_3))
1176 xcb_randr_get_screen_resources_current_reply_t *reply;
1178 reply = _ecore_xcb_randr_13_get_resources(root);
1179 timestamp = reply->config_timestamp;
1182 else if ((output != Ecore_X_Randr_None) && (_randr_version == RANDR_1_2))
1184 xcb_randr_get_screen_resources_reply_t *reply;
1186 reply = _ecore_xcb_randr_12_get_resources(root);
1187 timestamp = reply->config_timestamp;
1192 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output, timestamp);
1193 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn, ocookie, NULL);
1196 if (w_mm) *w_mm = oreply->mm_width;
1197 if (h_mm) *h_mm = oreply->mm_height;
1204 * @brief Sets the demanded parameters for a given CRTC. Note that the CRTC is
1205 * auto enabled in it's preferred mode, when it was disabled before.
1207 * @param root The root window which's default display will be queried.
1208 * @param crtc The CRTC which's configuration should be altered.
1209 * @param outputs An array of outputs, that should display this CRTC's content.
1210 * @param noutputs Number of outputs in the array of outputs. If set to
1211 * Ecore_X_Randr_Unset, current outputs and number of outputs will be used. If
1212 * set to Ecore_X_Randr_None, CRTC will be disabled.
1213 * @param x New x coordinate. If <0 (e.g. Ecore_X_Randr_Unset) the current x
1214 * coordinate will be assumed.
1215 * @param y New y coordinate. If <0 (e.g. Ecore_X_Randr_Unset) the current y
1216 * coordinate will be assumed.
1217 * @param mode The new mode to be set. If Ecore_X_Randr_None is passed, the
1218 * CRTC will be disabled. If Ecore_X_Randr_Unset is passed, the current mode is
1220 * @param orientation The new orientation to be set. If Ecore_X_Randr_Unset is
1221 * used, the current mode is assumed.
1222 * @return @c EINA_TRUE if the configuration alteration was successful,
1223 * @c EINA_FALSE otherwise.
1226 ecore_x_randr_crtc_settings_set(Ecore_X_Window root,
1227 Ecore_X_Randr_Crtc crtc,
1228 Ecore_X_Randr_Output *outputs,
1232 Ecore_X_Randr_Mode mode,
1233 Ecore_X_Randr_Orientation orientation)
1235 Eina_Bool ret = EINA_FALSE;
1236 #ifdef ECORE_XCB_RANDR
1237 xcb_timestamp_t stamp = 0;
1238 xcb_randr_get_crtc_info_cookie_t ccookie;
1239 xcb_randr_get_crtc_info_reply_t *creply;
1242 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1245 #ifdef ECORE_XCB_RANDR
1246 RANDR_CHECK_1_2_RET(EINA_FALSE);
1248 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret;
1250 if (_randr_version >= RANDR_1_3)
1251 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
1252 else if (_randr_version == RANDR_1_2)
1253 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
1256 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp);
1258 xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ccookie, NULL);
1261 xcb_randr_set_crtc_config_cookie_t scookie;
1262 xcb_randr_set_crtc_config_reply_t *sreply;
1264 if ((mode == Ecore_X_Randr_None) ||
1265 (noutputs == Ecore_X_Randr_None))
1270 else if (noutputs == (int)Ecore_X_Randr_Unset)
1272 outputs = xcb_randr_get_crtc_info_outputs(creply);
1273 noutputs = creply->num_outputs;
1275 if ((int)mode == Ecore_X_Randr_Unset) mode = creply->mode;
1276 if (x < 0) x = creply->x;
1277 if (y < 0) y = creply->y;
1278 if ((int)orientation == Ecore_X_Randr_Unset)
1279 orientation = creply->rotation;
1282 xcb_randr_set_crtc_config_unchecked(_ecore_xcb_conn,
1283 crtc, XCB_CURRENT_TIME, stamp,
1284 x, y, mode, orientation,
1287 xcb_randr_set_crtc_config_reply(_ecore_xcb_conn, scookie, NULL);
1290 ret = (sreply->status == XCB_RANDR_SET_CONFIG_SUCCESS) ?
1291 EINA_TRUE : EINA_FALSE;
1302 * @brief Sets a mode for a CRTC and the outputs attached to it.
1304 * @param root The window's screen to be queried
1305 * @param crtc The CRTC which shall be set
1306 * @param outputs Array of outputs which have to be compatible with the mode. If
1307 * @c NULL CRTC will be disabled.
1308 * @param noutputs Number of outputs in array to be used. Use
1309 * Ecore_X_Randr_Unset (or @c -1) to use currently used outputs.
1310 * @param mode XID of the mode to be set. If set to @c 0 the CRTC will be
1311 * disabled. If set to @c -1 the call will fail.
1312 * @return @c EINA_TRUE if mode setting was successful, @c EINA_FALSE
1316 ecore_x_randr_crtc_mode_set(Ecore_X_Window root,
1317 Ecore_X_Randr_Crtc crtc,
1318 Ecore_X_Randr_Output *outputs,
1320 Ecore_X_Randr_Mode mode)
1322 Eina_Bool ret = EINA_FALSE;
1324 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1327 #ifdef ECORE_XCB_RANDR
1328 RANDR_CHECK_1_2_RET(EINA_FALSE);
1330 if ((int)mode == Ecore_X_Randr_Unset) return ret;
1332 ecore_x_randr_crtc_settings_set(root, crtc, outputs, noutputs,
1333 Ecore_X_Randr_Unset, Ecore_X_Randr_Unset,
1334 mode, Ecore_X_Randr_Unset);
1341 * @brief Get the current set mode of a given CRTC
1342 * @param root the window's screen to be queried
1343 * @param crtc the CRTC which's should be queried
1344 * @return currently set mode or - in case parameters are invalid -
1345 * Ecore_X_Randr_Unset
1347 EAPI Ecore_X_Randr_Mode
1348 ecore_x_randr_crtc_mode_get(Ecore_X_Window root,
1349 Ecore_X_Randr_Crtc crtc)
1351 Ecore_X_Randr_Mode ret = Ecore_X_Randr_Unset;
1352 #ifdef ECORE_XCB_RANDR
1353 xcb_timestamp_t stamp = 0;
1354 xcb_randr_get_crtc_info_cookie_t ocookie;
1355 xcb_randr_get_crtc_info_reply_t *oreply;
1358 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1361 #ifdef ECORE_XCB_RANDR
1362 RANDR_CHECK_1_2_RET(Ecore_X_Randr_Unset);
1364 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret;
1366 if (_randr_version >= RANDR_1_3)
1367 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
1368 else if (_randr_version == RANDR_1_2)
1369 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
1372 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp);
1373 oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL);
1384 EAPI Ecore_X_Randr_Orientation
1385 ecore_x_randr_crtc_orientation_get(Ecore_X_Window root,
1386 Ecore_X_Randr_Crtc crtc)
1388 Ecore_X_Randr_Orientation ret = Ecore_X_Randr_None;
1389 #ifdef ECORE_XCB_RANDR
1390 xcb_timestamp_t stamp = 0;
1391 xcb_randr_get_crtc_info_cookie_t ocookie;
1392 xcb_randr_get_crtc_info_reply_t *oreply;
1395 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1398 #ifdef ECORE_XCB_RANDR
1399 RANDR_CHECK_1_2_RET(Ecore_X_Randr_None);
1401 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret;
1403 if (_randr_version >= RANDR_1_3)
1404 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
1405 else if (_randr_version == RANDR_1_2)
1406 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
1409 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp);
1410 oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL);
1413 ret = oreply->rotation;
1422 ecore_x_randr_crtc_orientation_set(Ecore_X_Window root,
1423 Ecore_X_Randr_Crtc crtc,
1424 Ecore_X_Randr_Orientation orientation)
1426 Eina_Bool ret = EINA_FALSE;
1428 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1431 #ifdef ECORE_XCB_RANDR
1432 RANDR_CHECK_1_2_RET(EINA_FALSE);
1434 if (orientation != Ecore_X_Randr_None)
1437 ecore_x_randr_crtc_settings_set(root, crtc, NULL,
1438 Ecore_X_Randr_Unset, Ecore_X_Randr_Unset,
1439 Ecore_X_Randr_Unset, Ecore_X_Randr_Unset,
1446 EAPI Ecore_X_Randr_Orientation
1447 ecore_x_randr_crtc_orientations_get(Ecore_X_Window root,
1448 Ecore_X_Randr_Crtc crtc)
1450 Ecore_X_Randr_Orientation ret = Ecore_X_Randr_None;
1451 #ifdef ECORE_XCB_RANDR
1452 xcb_timestamp_t stamp = 0;
1453 xcb_randr_get_crtc_info_cookie_t ocookie;
1454 xcb_randr_get_crtc_info_reply_t *oreply;
1457 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1460 #ifdef ECORE_XCB_RANDR
1461 RANDR_CHECK_1_2_RET(Ecore_X_Randr_None);
1463 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret;
1465 if (_randr_version >= RANDR_1_3)
1466 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
1467 else if (_randr_version == RANDR_1_2)
1468 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
1471 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp);
1473 xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL);
1476 ret = oreply->rotations;
1485 * @brief get a CRTC's possible outputs.
1486 * @param root the root window which's screen will be queried
1487 * @param num number of possible outputs referenced by given CRTC
1489 EAPI Ecore_X_Randr_Output *
1490 ecore_x_randr_crtc_possible_outputs_get(Ecore_X_Window root,
1491 Ecore_X_Randr_Crtc crtc,
1494 Ecore_X_Randr_Output *ret = NULL;
1495 #ifdef ECORE_XCB_RANDR
1496 xcb_timestamp_t stamp = 0;
1497 xcb_randr_get_crtc_info_cookie_t ocookie;
1498 xcb_randr_get_crtc_info_reply_t *oreply;
1501 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1504 #ifdef ECORE_XCB_RANDR
1505 RANDR_CHECK_1_2_RET(NULL);
1507 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret;
1509 if (_randr_version >= RANDR_1_3)
1510 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
1511 else if (_randr_version == RANDR_1_2)
1512 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
1515 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp);
1516 oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL);
1519 if (num) *num = oreply->num_possible_outputs;
1520 ret = malloc(sizeof(Ecore_X_Randr_Output) *
1521 oreply->num_possible_outputs);
1524 memcpy(ret, xcb_randr_get_crtc_info_possible(oreply),
1525 sizeof(Ecore_X_Randr_Output) *
1526 oreply->num_possible_outputs);
1536 * @brief get all known CRTCs related to a root window's screen
1537 * @param root window which's screen's ressources are queried
1538 * @param num number of CRTCs returned
1541 EAPI Ecore_X_Randr_Crtc *
1542 ecore_x_randr_crtcs_get(Ecore_X_Window root,
1545 Ecore_X_Randr_Crtc *ret = NULL;
1547 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1550 #ifdef ECORE_XCB_RANDR
1551 RANDR_CHECK_1_2_RET(NULL);
1553 if (_randr_version >= RANDR_1_3)
1555 xcb_randr_get_screen_resources_current_reply_t *reply;
1557 reply = _ecore_xcb_randr_13_get_resources(root);
1560 if (num) *num = reply->num_crtcs;
1561 ret = malloc(sizeof(Ecore_X_Randr_Crtc) * reply->num_crtcs);
1563 memcpy(ret, xcb_randr_get_screen_resources_current_crtcs(reply),
1564 sizeof(Ecore_X_Randr_Crtc) * reply->num_crtcs);
1568 else if (_randr_version == RANDR_1_2)
1570 xcb_randr_get_screen_resources_reply_t *reply;
1572 reply = _ecore_xcb_randr_12_get_resources(root);
1575 if (num) *num = reply->num_crtcs;
1576 ret = malloc(sizeof(Ecore_X_Randr_Crtc) * reply->num_crtcs);
1578 memcpy(ret, xcb_randr_get_screen_resources_crtcs(reply),
1579 sizeof(Ecore_X_Randr_Crtc) * reply->num_crtcs);
1589 * @deprecated bad naming. Use ecore_x_randr_window_crtcs_get instead.
1590 * @brief Get the CRTCs, which display a certain window.
1592 * @param window Window the displaying CRTCs shall be found for.
1593 * @param num The number of CRTCs displaying the window.
1594 * @return Array of CRTCs that display a certain window. @c NULL if no CRTCs
1595 * was found that displays the specified window.
1597 EAPI Ecore_X_Randr_Crtc *
1598 ecore_x_randr_current_crtc_get(Ecore_X_Window window,
1601 return ecore_x_randr_window_crtcs_get(window, num);
1605 * @brief Get the CRTCs, which display a certain window.
1607 * @param window Window the displaying crtcs shall be found for.
1608 * @param num The number of crtcs displaying the window.
1609 * @return Array of crtcs that display a certain window. @c NULL if no crtcs
1610 * was found that displays the specified window.
1613 EAPI Ecore_X_Randr_Crtc *
1614 ecore_x_randr_window_crtcs_get(Ecore_X_Window window,
1617 #ifdef ECORE_XCB_RANDR
1618 Ecore_X_Window root;
1619 Eina_Rectangle w_geo, c_geo;
1620 Ecore_X_Randr_Crtc *crtcs, *ret = NULL;
1621 Ecore_X_Randr_Mode mode;
1622 int ncrtcs, i, nret = 0;
1623 xcb_translate_coordinates_cookie_t cookie;
1624 xcb_translate_coordinates_reply_t *trans;
1627 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1630 #ifdef ECORE_XCB_RANDR
1631 RANDR_CHECK_1_2_RET(NULL);
1633 ecore_x_window_geometry_get(window, &w_geo.x, &w_geo.y, &w_geo.w, &w_geo.h);
1635 root = ecore_x_window_root_get(window);
1636 crtcs = ecore_x_randr_crtcs_get(root, &ncrtcs);
1637 if (!crtcs) goto _ecore_x_randr_window_crtcs_get_fail;
1639 /* now get window RELATIVE to root window - thats what matters. */
1640 cookie = xcb_translate_coordinates(_ecore_xcb_conn, window, root, 0, 0);
1641 trans = xcb_translate_coordinates_reply(_ecore_xcb_conn, cookie, NULL);
1642 w_geo.x = trans->dst_x;
1643 w_geo.y = trans->dst_y;
1646 ret = calloc(1, ncrtcs * sizeof(Ecore_X_Randr_Crtc));
1650 goto _ecore_x_randr_window_crtcs_get_fail;
1652 for (i = 0, nret = 0; i < ncrtcs; i++)
1654 /* if crtc is not enabled, don't bother about it any further */
1655 mode = ecore_x_randr_crtc_mode_get(root, crtcs[i]);
1656 if (mode == Ecore_X_Randr_None) continue;
1658 ecore_x_randr_crtc_geometry_get(root, crtcs[i], &c_geo.x, &c_geo.y,
1659 &c_geo.w, &c_geo.h);
1660 if (eina_rectangles_intersect(&w_geo, &c_geo))
1662 ret[nret] = crtcs[i];
1668 if (num) *num = nret;
1671 _ecore_x_randr_window_crtcs_get_fail:
1678 * @brief get a CRTC's outputs.
1679 * @param root the root window which's screen will be queried
1680 * @param num number of outputs referenced by given CRTC
1682 EAPI Ecore_X_Randr_Output *
1683 ecore_x_randr_crtc_outputs_get(Ecore_X_Window root,
1684 Ecore_X_Randr_Crtc crtc,
1687 Ecore_X_Randr_Output *ret = NULL;
1688 #ifdef ECORE_XCB_RANDR
1689 xcb_timestamp_t stamp = 0;
1690 xcb_randr_get_crtc_info_cookie_t ocookie;
1691 xcb_randr_get_crtc_info_reply_t *oreply;
1694 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1697 #ifdef ECORE_XCB_RANDR
1698 RANDR_CHECK_1_2_RET(NULL);
1700 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret;
1702 if (_randr_version >= RANDR_1_3)
1703 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
1704 else if (_randr_version == RANDR_1_2)
1705 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
1708 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp);
1709 oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL);
1712 if (num) *num = oreply->num_outputs;
1713 ret = malloc(sizeof(Ecore_X_Randr_Output) * oreply->num_outputs);
1715 memcpy(ret, xcb_randr_get_crtc_info_outputs(oreply),
1716 sizeof(Ecore_X_Randr_Output) * oreply->num_outputs);
1725 ecore_x_randr_crtc_geometry_get(Ecore_X_Window root,
1726 Ecore_X_Randr_Crtc crtc,
1732 #ifdef ECORE_XCB_RANDR
1733 xcb_timestamp_t stamp = 0;
1734 xcb_randr_get_crtc_info_cookie_t ocookie;
1735 xcb_randr_get_crtc_info_reply_t *oreply;
1738 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1741 #ifdef ECORE_XCB_RANDR
1742 RANDR_CHECK_1_2_RET();
1744 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return;
1746 if (_randr_version >= RANDR_1_3)
1747 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
1748 else if (_randr_version == RANDR_1_2)
1749 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
1752 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp);
1753 oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL);
1756 if (x) *x = oreply->x;
1757 if (y) *y = oreply->y;
1758 if (w) *w = oreply->width;
1759 if (h) *h = oreply->height;
1766 * @brief Sets a CRTC relative to another one.
1768 * @param root The window on which CRTC's position will be set.
1769 * @param crtc_r1 The CRTC to be positioned.
1770 * @param crtc_r2 The CRTC the position should be relative to.
1771 * @param policy The relation between the crtcs.
1772 * @param alignment In case CRTCs size differ, aligns CRTC1 accordingly at
1774 * @return @c EINA_TRUE if crtc could be successfully positioned, @c EINA_FALSE
1775 * if repositioning failed or if position of new crtc would be out of given
1776 * screen's min/max bounds.
1779 ecore_x_randr_crtc_pos_relative_set(Ecore_X_Window root,
1780 Ecore_X_Randr_Crtc crtc_r1,
1781 Ecore_X_Randr_Crtc crtc_r2,
1782 Ecore_X_Randr_Output_Policy policy,
1783 Ecore_X_Randr_Relative_Alignment alignment)
1785 #ifdef ECORE_XCB_RANDR
1786 Eina_Rectangle r1, r2;
1787 int w_max = 0, h_max = 0, cw = 0, ch = 0, xn = -1, yn = -1;
1790 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1793 #ifdef ECORE_XCB_RANDR
1794 RANDR_CHECK_1_2_RET(EINA_FALSE);
1796 if ((ecore_x_randr_crtc_mode_get(root, crtc_r1) == 0) ||
1797 (ecore_x_randr_crtc_mode_get(root, crtc_r2) == 0))
1800 if ((!_ecore_xcb_randr_crtc_validate(root, crtc_r1) ||
1801 (!(crtc_r1 != crtc_r2) && (!_ecore_xcb_randr_crtc_validate(root, crtc_r2)))))
1804 ecore_x_randr_crtc_geometry_get(root, crtc_r1, &r1.x, &r1.y, &r1.w, &r1.h);
1805 ecore_x_randr_crtc_geometry_get(root, crtc_r2, &r2.x, &r2.y, &r2.w, &r2.h);
1806 ecore_x_randr_screen_size_range_get(root, NULL, NULL, &w_max, &h_max);
1807 ecore_x_randr_screen_current_size_get(root, &cw, &ch, NULL, NULL);
1811 case ECORE_X_RANDR_OUTPUT_POLICY_RIGHT:
1813 if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_NONE)
1815 else if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_REL)
1816 yn = ((int)(((double)r2.h / 2.0) + (double)r2.y - ((double)r1.h / 2.0)));
1817 else if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_SCR)
1818 yn = ((int)((double)ch / 2.0) - ((double)r1.h / 2.0));
1821 case ECORE_X_RANDR_OUTPUT_POLICY_LEFT:
1823 if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_NONE)
1825 else if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_REL)
1826 yn = ((int)(((double)r2.h / 2.0) + (double)r2.y - ((double)r1.h / 2.0)));
1827 else if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_SCR)
1828 yn = ((int)((double)ch / 2.0) - ((double)r1.h / 2.0));
1831 case ECORE_X_RANDR_OUTPUT_POLICY_BELOW:
1833 if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_NONE)
1835 else if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_REL)
1836 xn = ((int)((((double)r2.x + (double)r2.w) / 2.0) - ((double)r1.w / 2.0)));
1837 else if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_SCR)
1838 xn = ((int)((double)cw / 2.0));
1841 case ECORE_X_RANDR_OUTPUT_POLICY_ABOVE:
1843 if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_NONE)
1845 else if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_REL)
1846 xn = ((int)((((double)r2.x + (double)r2.w) / 2.0) - ((double)r1.w / 2.0)));
1847 else if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_SCR)
1848 xn = ((int)((double)cw / 2.0));
1851 case ECORE_X_RANDR_OUTPUT_POLICY_CLONE:
1852 return ecore_x_randr_crtc_pos_set(root, crtc_r1, r2.x, r2.y);
1855 case ECORE_X_RANDR_OUTPUT_POLICY_NONE:
1861 if ((xn == r1.x) && (yn == r1.x)) return EINA_TRUE;
1862 if (((yn + r1.h) > h_max) || ((xn + r1.w) > w_max))
1865 return ecore_x_randr_crtc_pos_set(root, crtc_r1, xn, yn);
1872 ecore_x_randr_move_all_crtcs_but(Ecore_X_Window root,
1873 const Ecore_X_Randr_Crtc *not_moved,
1878 Eina_Bool ret = EINA_FALSE;
1879 #ifdef ECORE_XCB_RANDR
1880 Ecore_X_Randr_Crtc *crtcs = NULL, *move = NULL;
1881 int i = 0, j = 0, k = 0, n = 0, total = 0;
1884 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1887 #ifdef ECORE_XCB_RANDR
1888 if ((num <= 0) || (!not_moved) || (!_ecore_xcb_randr_root_validate(root)))
1891 crtcs = ecore_x_randr_crtcs_get(root, &total);
1893 move = malloc(sizeof(Ecore_X_Randr_Crtc) * n);
1896 for (i = 0, k = 0; (i < total) && (k < n); i++)
1898 for (j = 0; j < num; j++)
1899 if (crtcs[i] == not_moved[j]) break;
1901 move[k++] = crtcs[i];
1903 ret = ecore_x_randr_move_crtcs(root, move, n, dx, dy);
1913 ecore_x_randr_crtc_pos_get(Ecore_X_Window root,
1914 Ecore_X_Randr_Crtc crtc,
1918 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1921 #ifdef ECORE_XCB_RANDR
1922 RANDR_CHECK_1_2_RET();
1924 ecore_x_randr_crtc_geometry_get(root, crtc, x, y, NULL, NULL);
1929 * @brief Sets the position of given CRTC within root window's screen.
1931 * @param root The window's screen to be queried.
1932 * @param crtc The CRTC which's position within the mentioned screen is to be
1934 * @param x Position on the x-axis (0 == left) of the screen. if x < 0 current
1935 * value will be kept.
1936 * @param y Position on the y-ayis (0 == top) of the screen. if y < 0, current
1937 * value will be kept.
1938 * @return @c EINA_TRUE if position could be successfully be altered.
1941 ecore_x_randr_crtc_pos_set(Ecore_X_Window root,
1942 Ecore_X_Randr_Crtc crtc,
1946 Eina_Bool ret = EINA_FALSE;
1947 #ifdef ECORE_XCB_RANDR
1948 int w = 0, h = 0, nw = 0, nh = 0;
1949 Eina_Rectangle rect;
1952 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1955 #ifdef ECORE_XCB_RANDR
1956 RANDR_CHECK_1_2_RET(EINA_FALSE);
1958 ecore_x_randr_crtc_geometry_get(root, crtc,
1959 &rect.x, &rect.y, &rect.w, &rect.h);
1960 ecore_x_randr_screen_current_size_get(root, &w, &h, NULL, NULL);
1961 if (x < 0) x = rect.x;
1962 if (y < 0) y = rect.y;
1963 if ((x + rect.w) > w)
1965 if ((y + rect.h) > h)
1968 if ((nw != 0) || (nh != 0))
1970 if (!ecore_x_randr_screen_current_size_set(root, nw, nh, 0, 0))
1974 ret = ecore_x_randr_crtc_settings_set(root, crtc, NULL, -1, x, y, -1, -1);
1981 ecore_x_randr_crtc_size_get(Ecore_X_Window root,
1982 Ecore_X_Randr_Crtc crtc,
1986 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1989 #ifdef ECORE_XCB_RANDR
1990 RANDR_CHECK_1_2_RET();
1991 ecore_x_randr_crtc_geometry_get(root, crtc, NULL, NULL, w, h);
1995 EAPI Ecore_X_Randr_Refresh_Rate
1996 ecore_x_randr_crtc_refresh_rate_get(Ecore_X_Window root,
1997 Ecore_X_Randr_Crtc crtc,
1998 Ecore_X_Randr_Mode mode)
2000 Ecore_X_Randr_Refresh_Rate ret = 0.0;
2002 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2005 #ifdef ECORE_XCB_RANDR
2006 RANDR_CHECK_1_2_RET(0.0);
2008 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return 0.0;
2010 if (_randr_version >= RANDR_1_3)
2012 xcb_randr_get_screen_resources_current_reply_t *reply;
2014 reply = _ecore_xcb_randr_13_get_resources(root);
2017 xcb_randr_mode_info_iterator_t miter;
2020 xcb_randr_get_screen_resources_current_modes_iterator(reply);
2023 xcb_randr_mode_info_t *minfo;
2026 if (minfo->id == mode)
2028 if ((minfo->htotal) && (minfo->vtotal))
2030 ret = ((double)minfo->dot_clock /
2031 ((double)minfo->htotal *
2032 (double)minfo->vtotal));
2036 xcb_randr_mode_info_next(&miter);
2041 else if (_randr_version == RANDR_1_2)
2043 xcb_randr_get_screen_resources_reply_t *reply;
2045 reply = _ecore_xcb_randr_12_get_resources(root);
2048 xcb_randr_mode_info_iterator_t miter;
2050 miter = xcb_randr_get_screen_resources_modes_iterator(reply);
2053 xcb_randr_mode_info_t *minfo;
2056 if (minfo->id == mode)
2058 if ((minfo->htotal) && (minfo->vtotal))
2060 ret = ((double)minfo->dot_clock /
2061 ((double)minfo->htotal *
2062 (double)minfo->vtotal));
2066 xcb_randr_mode_info_next(&miter);
2076 * @brief Move given CRTCs belonging to the given root window's screen dx/dy
2077 * pixels relative to their current position. The screen size will be
2078 * automatically adjusted if necessary and possible.
2080 * @param root Window which's screen's resources are used.
2081 * @param crtcs List of CRTCs to be moved.
2082 * @param ncrtc Number of CRTCs in array.
2083 * @param dx Amount of pixels the CRTCs should be moved in x direction.
2084 * @param dy Amount of pixels the CRTCs should be moved in y direction.
2085 * @return @c EINA_TRUE if all crtcs could be moved successfully.
2088 ecore_x_randr_move_crtcs(Ecore_X_Window root,
2089 const Ecore_X_Randr_Crtc *crtcs,
2094 Eina_Bool ret = EINA_TRUE;
2095 #ifdef ECORE_XCB_RANDR
2096 xcb_timestamp_t stamp = 0;
2097 xcb_randr_get_crtc_info_reply_t *oreply[num];
2098 int i = 0, cw = 0, ch = 0;
2099 int mw = 0, mh = 0, nw = 0, nh = 0;
2102 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2105 #ifdef ECORE_XCB_RANDR
2106 RANDR_CHECK_1_2_RET(EINA_FALSE);
2108 if (!_ecore_xcb_randr_root_validate(root)) return EINA_FALSE;
2110 if (_randr_version >= RANDR_1_3)
2111 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
2112 else if (_randr_version == RANDR_1_2)
2113 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
2115 ecore_x_randr_screen_size_range_get(root, NULL, NULL, &mw, &mh);
2116 ecore_x_randr_screen_current_size_get(root, &cw, &ch, NULL, NULL);
2120 for (i = 0; i < num; i++)
2122 xcb_randr_get_crtc_info_cookie_t ocookie;
2125 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtcs[i],
2127 oreply[i] = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn,
2131 if (((oreply[i]->x + dx) < 0) ||
2132 ((oreply[i]->y + dy) < 0) ||
2133 ((oreply[i]->x + oreply[i]->width + dx) > mw) ||
2134 ((oreply[i]->y + oreply[i]->height + dy) > mh))
2138 nw = MAX((int)(oreply[i]->x + oreply[i]->width + dx), nw);
2139 nh = MAX((int)(oreply[i]->y + oreply[i]->height + dy), nh);
2143 if ((nw > cw) || (nh > ch))
2145 if (!ecore_x_randr_screen_current_size_set(root, nw, nh, -1, -1))
2147 for (i = 0; i < num; i++)
2148 if (oreply[i]) free(oreply[i]);
2154 for (i = 0; ((i < num) && (oreply[i])); i++)
2156 if (!oreply[i]) continue;
2157 if (!ecore_x_randr_crtc_settings_set(root, crtcs[i], NULL, -1,
2158 (oreply[i]->x + dx),
2159 (oreply[i]->y + dy),
2161 oreply[i]->rotation))
2173 ecore_x_randr_crtc_settings_set(root, crtcs[i], NULL, -1,
2174 (oreply[i]->x - dx),
2175 (oreply[i]->y - dy),
2177 oreply[i]->rotation);
2181 for (i = 0; i < num; i++)
2182 if (oreply[i]) free(oreply[i]);
2189 * @brief enable event selection. This enables basic interaction with
2190 * output/crtc events and requires RRandR >= 1.2.
2191 * @param win select this window's properties for RandRR events
2192 * @param on enable/disable selecting
2195 ecore_x_randr_events_select(Ecore_X_Window win,
2198 #ifdef ECORE_XCB_RANDR
2202 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2205 #ifdef ECORE_XCB_RANDR
2208 mask = XCB_RANDR_NOTIFY_MASK_SCREEN_CHANGE;
2209 if (_randr_version >= ((1 << 16) | 2))
2211 mask |= (XCB_RANDR_NOTIFY_MASK_CRTC_CHANGE |
2212 XCB_RANDR_NOTIFY_MASK_OUTPUT_CHANGE |
2213 XCB_RANDR_NOTIFY_MASK_OUTPUT_PROPERTY);
2217 xcb_randr_select_input(_ecore_xcb_conn, win, mask);
2222 * @brief removes unused screen space. The most upper left CRTC is set to 0x0
2223 * and all other CRTCs dx,dy respectively.
2224 * @param root the window's screen which will be reset.
2227 ecore_x_randr_screen_reset(Ecore_X_Window root)
2229 #ifdef ECORE_XCB_RANDR
2230 xcb_timestamp_t stamp = 0;
2231 Ecore_X_Randr_Crtc *crtcs = NULL;
2232 int total = 0, i = 0, w = 0, h = 0;
2233 int dx = 100000, dy = 100000, num = 0;
2236 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2239 #ifdef ECORE_XCB_RANDR
2240 if (!_ecore_xcb_randr_root_validate(root)) return;
2241 crtcs = ecore_x_randr_crtcs_get(root, &total);
2243 if (_randr_version >= RANDR_1_3)
2244 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
2245 else if (_randr_version == RANDR_1_2)
2246 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
2248 /* I hate declaring variables inside code like this, but we need the
2249 * value of 'total' before we can */
2250 Ecore_X_Randr_Crtc enabled[total];
2252 for (i = 0; i < total; i++)
2254 xcb_randr_get_crtc_info_cookie_t ocookie;
2255 xcb_randr_get_crtc_info_reply_t *oreply;
2258 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtcs[i], stamp);
2259 oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn,
2261 if (!oreply) continue;
2262 if ((oreply->mode <= 0) || (oreply->num_outputs == 0))
2268 enabled[num++] = crtcs[i];
2269 if ((int)(oreply->x + oreply->width) > w)
2270 w = (oreply->x + oreply->width);
2271 if ((int)(oreply->y + oreply->height) > h)
2272 h = (oreply->y + oreply->height);
2274 if (oreply->x < dx) dx = oreply->x;
2275 if (oreply->y < dy) dy = oreply->y;
2281 if ((dx > 0) || (dy > 0))
2283 if (ecore_x_randr_move_crtcs(root, enabled, num, -dx, -dy))
2290 ecore_x_randr_screen_current_size_set(root, w, h, -1, -1);
2295 * @param root window which's screen will be queried
2296 * @param wmin minimum width the screen can be set to
2297 * @param hmin minimum height the screen can be set to
2298 * @param wmax maximum width the screen can be set to
2299 * @param hmax maximum height the screen can be set to
2302 ecore_x_randr_screen_size_range_get(Ecore_X_Window root,
2308 #ifdef ECORE_XCB_RANDR
2309 xcb_randr_get_screen_size_range_cookie_t cookie;
2310 xcb_randr_get_screen_size_range_reply_t *reply;
2313 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2316 #ifdef ECORE_XCB_RANDR
2317 RANDR_CHECK_1_2_RET();
2319 cookie = xcb_randr_get_screen_size_range_unchecked(_ecore_xcb_conn, root);
2320 reply = xcb_randr_get_screen_size_range_reply(_ecore_xcb_conn, cookie, NULL);
2323 if (minw) *minw = reply->min_width;
2324 if (minh) *minh = reply->min_height;
2325 if (maxw) *maxw = reply->max_width;
2326 if (maxh) *maxh = reply->max_height;
2333 * @param w width of screen in px
2334 * @param h height of screen in px
2337 ecore_x_randr_screen_current_size_get(Ecore_X_Window root,
2343 #ifdef ECORE_XCB_RANDR
2344 Ecore_X_Randr_Screen scr = 0;
2346 # define RANDR_VALIDATE_ROOT(screen, root) \
2347 ((screen == _ecore_xcb_randr_root_to_screen(root)) != -1)
2350 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2353 #ifdef ECORE_XCB_RANDR
2354 RANDR_CHECK_1_2_RET();
2356 if (!RANDR_VALIDATE_ROOT(scr, root)) return;
2358 s = ecore_x_screen_get(scr);
2359 if (w) *w = s->width_in_pixels;
2360 if (h) *h = s->height_in_pixels;
2361 if (w_mm) *w_mm = s->width_in_millimeters;
2362 if (h_mm) *h_mm = s->height_in_millimeters;
2367 * @param root Window which's screen's size should be set. If invalid (e.g.
2368 * @c NULL) no action is taken.
2369 * @param w Width in px the screen should be set to. If out of valid
2370 * boundaries, current value is assumed.
2371 * @param h Height in px the screen should be set to. If out of valid
2372 * boundaries, current value is assumed.
2373 * @param w_mm Width in mm the screen should be set to. If @c 0, current
2374 * aspect is assumed.
2375 * @param h_mm Height in mm the screen should be set to. If @c 0, current
2376 * aspect is assumed.
2377 * @return @c EINA_TRUE if request was successfully sent or screen is already
2378 * in requested size, @c EINA_FALSE if parameters are invalid.
2381 ecore_x_randr_screen_current_size_set(Ecore_X_Window root,
2387 Eina_Bool ret = EINA_TRUE;
2388 #ifdef ECORE_XCB_RANDR
2389 Ecore_X_Randr_Screen scr;
2390 int wc = 0, hc = 0, w_mm_c = 0, h_mm_c = 0;
2391 int mw = 0, mh = 0, xw = 0, xh = 0;
2392 # define RANDR_VALIDATE_ROOT(screen, root) \
2393 ((screen == _ecore_xcb_randr_root_to_screen(root)) != -1)
2396 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2399 #ifdef ECORE_XCB_RANDR
2400 RANDR_CHECK_1_2_RET(EINA_FALSE);
2402 if (!RANDR_VALIDATE_ROOT(scr, root)) return EINA_FALSE;
2403 ecore_x_randr_screen_current_size_get(root, &wc, &hc, &w_mm_c, &h_mm_c);
2404 if ((w == wc) && (h == hc) && (w_mm == w_mm_c) && (h_mm == h_mm_c))
2406 ecore_x_randr_screen_size_range_get(root, &mw, &mh, &xw, &xh);
2407 if (((w != 1) && ((w < mw) || (w > xw))) ||
2408 ((h != -1) && ((h < mh) || (h > xh)))) return EINA_FALSE;
2411 w = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_pixels;
2413 h = ((xcb_screen_t *)_ecore_xcb_screen)->height_in_pixels;
2415 /* NB: Hmmmm, xlib version divides w_mm by width ... that seems wrong */
2417 w_mm = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_millimeters;
2419 h_mm = ((xcb_screen_t *)_ecore_xcb_screen)->height_in_millimeters;
2421 xcb_randr_set_screen_size(_ecore_xcb_conn, root, w, h, w_mm, h_mm);
2428 * @deprecated bad naming. Use ecore_x_randr_window_outputs_get instead.
2429 * @brief Get the outputs, which display a certain window.
2431 * @param window Window the displaying outputs shall be found for.
2432 * @param num The number of outputs displaying the window.
2433 * @return Array of outputs that display a certain window. @c NULL if no
2434 * outputs was found that displays the specified window.
2437 Ecore_X_Randr_Output *
2438 ecore_x_randr_current_output_get(Ecore_X_Window window,
2441 return ecore_x_randr_window_outputs_get(window, num);
2445 * @brief Get the outputs, which display a certain window.
2447 * @param window Window the displaying outputs shall be found for.
2448 * @param num The number of outputs displaying the window.
2449 * @return Array of outputs that display a certain window. @c NULL if no
2450 * outputs was found that displays the specified window.
2452 EAPI Ecore_X_Randr_Output *
2453 ecore_x_randr_window_outputs_get(Ecore_X_Window window,
2456 #ifdef ECORE_XCB_RANDR
2457 Ecore_X_Window root;
2458 Ecore_X_Randr_Crtc *crtcs;
2459 Ecore_X_Randr_Output *outputs, *ret = NULL, *tret;
2460 int ncrtcs, noutputs, i, nret = 0;
2463 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2468 #ifdef ECORE_XCB_RANDR
2469 if (_randr_version < RANDR_1_2) goto _ecore_x_randr_current_output_get_fail;
2471 root = ecore_x_window_root_get(window);
2472 if (!(crtcs = ecore_x_randr_window_crtcs_get(window, &ncrtcs)))
2473 goto _ecore_x_randr_current_output_get_fail;
2475 for (i = 0, nret = 0; i < ncrtcs; i++)
2478 outputs = ecore_x_randr_crtc_outputs_get(root, crtcs[i],
2481 goto _ecore_x_randr_current_output_get_fail_free;
2482 tret = realloc(ret, ((nret + noutputs) * sizeof(Ecore_X_Randr_Output)));
2483 if (!tret) goto _ecore_x_randr_current_output_get_fail_free;
2485 memcpy(&ret[nret], outputs, (noutputs * sizeof(Ecore_X_Randr_Output)));
2497 _ecore_x_randr_current_output_get_fail_free:
2501 _ecore_x_randr_current_output_get_fail:
2508 * @brief get the backlight level of the given output
2509 * @param root window which's screen should be queried
2510 * @param output from which the backlight level should be retrieved
2511 * @return the backlight level
2514 ecore_x_randr_output_backlight_level_get(Ecore_X_Window root,
2515 Ecore_X_Randr_Output output)
2517 #ifdef ECORE_XCB_RANDR
2518 Ecore_X_Atom _backlight;
2519 xcb_intern_atom_cookie_t acookie;
2520 xcb_intern_atom_reply_t *areply;
2521 xcb_randr_get_output_property_cookie_t cookie;
2522 xcb_randr_get_output_property_reply_t *reply;
2523 xcb_randr_query_output_property_cookie_t qcookie;
2524 xcb_randr_query_output_property_reply_t *qreply;
2526 long value, max, min;
2529 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2532 #ifdef ECORE_XCB_RANDR
2533 RANDR_CHECK_1_2_RET(-1);
2536 xcb_intern_atom_unchecked(_ecore_xcb_conn, 1,
2537 strlen("Backlight"), "Backlight");
2538 areply = xcb_intern_atom_reply(_ecore_xcb_conn, acookie, NULL);
2542 ERR("Backlight property is not suppported on this server or driver");
2547 _backlight = areply->atom;
2551 if (!_ecore_xcb_randr_output_validate(root, output))
2553 ERR("Invalid output");
2558 xcb_randr_get_output_property_unchecked(_ecore_xcb_conn,
2560 XCB_ATOM_NONE, 0, 4, 0, 0);
2562 xcb_randr_get_output_property_reply(_ecore_xcb_conn, cookie, NULL);
2565 WRN("Backlight not supported on this output");
2569 if ((reply->format != 32) || (reply->num_items != 1) ||
2570 (reply->type != XCB_ATOM_INTEGER))
2576 value = *((long *)xcb_randr_get_output_property_data(reply));
2579 /* I have the current value of the backlight */
2580 /* Now retrieve the min and max intensities of the output */
2582 xcb_randr_query_output_property_unchecked(_ecore_xcb_conn,
2583 output, _backlight);
2585 xcb_randr_query_output_property_reply(_ecore_xcb_conn, qcookie, NULL);
2589 if ((qreply->range) &&
2590 (xcb_randr_query_output_property_valid_values_length(qreply) == 2))
2594 vals = xcb_randr_query_output_property_valid_values(qreply);
2595 /* finally convert the current value in the interval [0..1] */
2598 dvalue = ((double)(value - min)) / ((double)(max - min));
2608 * @brief Set the backlight level of a given output.
2610 * @param root Window which's screen should be queried.
2611 * @param output That should be set.
2612 * @param level For which the backlight should be set.
2613 * @return @c EINA_TRUE in case of success.
2616 ecore_x_randr_output_backlight_level_set(Ecore_X_Window root,
2617 Ecore_X_Randr_Output output,
2620 #ifdef ECORE_XCB_RANDR
2621 Ecore_X_Atom _backlight;
2622 xcb_intern_atom_cookie_t acookie;
2623 xcb_intern_atom_reply_t *areply;
2624 xcb_randr_query_output_property_cookie_t qcookie;
2625 xcb_randr_query_output_property_reply_t *qreply;
2628 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2631 #ifdef ECORE_XCB_RANDR
2632 RANDR_CHECK_1_2_RET(EINA_FALSE);
2634 if ((level < 0) || (level > 1))
2636 ERR("Backlight level should be between 0 and 1");
2640 if (!_ecore_xcb_randr_output_validate(root, output))
2642 ERR("Wrong output value");
2647 xcb_intern_atom_unchecked(_ecore_xcb_conn, 1,
2648 strlen("Backlight"), "Backlight");
2649 areply = xcb_intern_atom_reply(_ecore_xcb_conn, acookie, NULL);
2652 WRN("Backlight property is not suppported on this server or driver");
2657 _backlight = areply->atom;
2662 xcb_randr_query_output_property_unchecked(_ecore_xcb_conn,
2663 output, _backlight);
2665 xcb_randr_query_output_property_reply(_ecore_xcb_conn, qcookie, NULL);
2668 if ((qreply->range) && (qreply->length == 2))
2671 double min, max, tmp;
2674 vals = xcb_randr_query_output_property_valid_values(qreply);
2677 tmp = (level * (max - min)) + min;
2679 if (n > max) n = max;
2680 if (n < min) n = min;
2681 xcb_randr_change_output_property(_ecore_xcb_conn, output,
2682 _backlight, XCB_ATOM_INTEGER,
2683 32, XCB_PROP_MODE_REPLACE,
2684 1, (unsigned char *)&n);
2685 ecore_x_flush(); // needed
2696 * @brief Check if a backlight is available.
2698 * @return Whether a backlight is available.
2701 ecore_x_randr_output_backlight_available(void)
2703 #ifdef ECORE_XCB_RANDR
2704 Ecore_X_Atom _backlight;
2705 xcb_intern_atom_cookie_t acookie;
2706 xcb_intern_atom_reply_t *areply;
2709 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2712 #ifdef ECORE_XCB_RANDR
2713 RANDR_CHECK_1_2_RET(EINA_FALSE);
2716 xcb_intern_atom_unchecked(_ecore_xcb_conn, 1,
2717 strlen("Backlight"), "Backlight");
2718 areply = xcb_intern_atom_reply(_ecore_xcb_conn, acookie, NULL);
2722 ERR("Backlight property is not suppported on this server or driver");
2727 _backlight = areply->atom;
2736 ecore_x_randr_edid_version_get(unsigned char *edid, unsigned long edid_length)
2738 if ((edid_length > _ECORE_X_RANDR_EDID_OFFSET_VERSION_MINOR) &&
2739 (ecore_x_randr_edid_has_valid_header(edid, edid_length)))
2740 return (edid[_ECORE_X_RANDR_EDID_OFFSET_VERSION_MAJOR] << 8) |
2741 edid[_ECORE_X_RANDR_EDID_OFFSET_VERSION_MINOR];
2742 return ECORE_X_RANDR_EDID_UNKNOWN_VALUE;
2746 ecore_x_randr_edid_display_name_get(unsigned char *edid, unsigned long edid_length)
2748 unsigned char *block = NULL;
2751 version = ecore_x_randr_edid_version_get(edid, edid_length);
2752 if (version < ECORE_X_RANDR_EDID_VERSION_13) return NULL;
2754 _ECORE_X_RANDR_EDID_FOR_EACH_NON_PIXEL_DESCRIPTOR_BLOCK(edid, block)
2756 if (block[_ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_TYPE] == 0xfc)
2759 const char *edid_name;
2761 edid_name = (const char *)block +
2762 _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_CONTENT;
2764 malloc(sizeof(char) *
2765 _ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX);
2766 if (!name) return NULL;
2768 strncpy(name, edid_name,
2769 (_ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX - 1));
2770 name[_ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX] = 0;
2771 for (p = name; *p; p++)
2772 if ((*p < ' ') || (*p > '~')) *p = 0;
2781 ecore_x_randr_edid_has_valid_header(unsigned char *edid, unsigned long edid_length)
2783 const unsigned char header[] =
2785 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00
2788 if ((!edid) || (edid_length < 8)) return EINA_FALSE;
2789 if (!memcmp(edid, header, 8)) return EINA_TRUE;
2793 /* local functions */
2795 _ecore_xcb_randr_output_validate(Ecore_X_Window root,
2796 Ecore_X_Randr_Output output)
2798 Eina_Bool ret = EINA_FALSE;
2800 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2803 #ifdef ECORE_XCB_RANDR
2804 RANDR_CHECK_1_2_RET(EINA_FALSE);
2806 if ((output) && (_ecore_xcb_randr_root_validate(root)))
2808 if (_randr_version >= RANDR_1_3)
2810 xcb_randr_get_screen_resources_current_reply_t *reply;
2812 reply = _ecore_xcb_randr_13_get_resources(root);
2816 xcb_randr_output_t *outputs;
2819 xcb_randr_get_screen_resources_current_outputs_length(reply);
2821 xcb_randr_get_screen_resources_current_outputs(reply);
2822 for (i = 0; i < len; i++)
2824 if (outputs[i] == output)
2833 else if (_randr_version == RANDR_1_2)
2835 xcb_randr_get_screen_resources_reply_t *reply;
2837 reply = _ecore_xcb_randr_12_get_resources(root);
2841 xcb_randr_output_t *outputs;
2843 len = xcb_randr_get_screen_resources_outputs_length(reply);
2844 outputs = xcb_randr_get_screen_resources_outputs(reply);
2845 for (i = 0; i < len; i++)
2847 if (outputs[i] == output)
2862 * @brief Validates a CRTC for a given root window's screen.
2864 * @param root The window which's default display will be queried.
2865 * @param crtc The CRTC to be validated.
2866 * @return In case it is found @c EINA_TRUE will be returned, else
2867 * @c EINA_FALSE is returned.
2870 _ecore_xcb_randr_crtc_validate(Ecore_X_Window root,
2871 Ecore_X_Randr_Crtc crtc)
2873 Eina_Bool ret = EINA_FALSE;
2875 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2878 #ifdef ECORE_XCB_RANDR
2879 RANDR_CHECK_1_2_RET(EINA_FALSE);
2881 if (((int)crtc == Ecore_X_Randr_None) || ((int)crtc == Ecore_X_Randr_Unset))
2884 if ((crtc) && (_ecore_xcb_randr_root_validate(root)))
2886 if (_randr_version >= RANDR_1_3)
2888 xcb_randr_get_screen_resources_current_reply_t *reply;
2890 reply = _ecore_xcb_randr_13_get_resources(root);
2894 xcb_randr_crtc_t *crtcs;
2896 crtcs = xcb_randr_get_screen_resources_current_crtcs(reply);
2897 for (i = 0; i < reply->num_crtcs; i++)
2899 if (crtcs[i] == crtc)
2908 else if (_randr_version == RANDR_1_2)
2910 xcb_randr_get_screen_resources_reply_t *reply;
2912 reply = _ecore_xcb_randr_12_get_resources(root);
2916 xcb_randr_crtc_t *crtcs;
2918 crtcs = xcb_randr_get_screen_resources_crtcs(reply);
2919 for (i = 0; i < reply->num_crtcs; i++)
2921 if (crtcs[i] == crtc)
2936 static Ecore_X_Randr_Mode *
2937 _ecore_xcb_randr_12_output_modes_get(Ecore_X_Window root,
2938 Ecore_X_Randr_Output output,
2942 Ecore_X_Randr_Mode *modes = NULL;
2943 #ifdef ECORE_XCB_RANDR
2944 xcb_randr_get_screen_resources_reply_t *reply;
2946 reply = _ecore_xcb_randr_12_get_resources(root);
2949 xcb_randr_get_output_info_cookie_t ocookie;
2950 xcb_randr_get_output_info_reply_t *oreply;
2953 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
2954 reply->config_timestamp);
2955 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
2959 if (num) *num = oreply->num_modes;
2960 if (npreferred) *npreferred = oreply->num_preferred;
2962 modes = malloc(sizeof(Ecore_X_Randr_Mode) *
2966 xcb_randr_mode_t *rmodes;
2969 len = xcb_randr_get_output_info_modes_length(oreply);
2970 rmodes = xcb_randr_get_output_info_modes(oreply);
2971 memcpy(modes, rmodes, sizeof(Ecore_X_Randr_Mode) * len);
2981 static Ecore_X_Randr_Mode *
2982 _ecore_xcb_randr_13_output_modes_get(Ecore_X_Window root,
2983 Ecore_X_Randr_Output output,
2987 Ecore_X_Randr_Mode *modes = NULL;
2988 #ifdef ECORE_XCB_RANDR
2989 xcb_timestamp_t stamp = 0;
2990 xcb_randr_get_output_info_cookie_t ocookie;
2991 xcb_randr_get_output_info_reply_t *oreply;
2993 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
2996 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output, stamp);
2997 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn, ocookie, NULL);
3000 if (num) *num = oreply->num_modes;
3001 if (npreferred) *npreferred = oreply->num_preferred;
3003 modes = malloc(sizeof(Ecore_X_Randr_Mode) * oreply->num_modes);
3006 xcb_randr_mode_t *rmodes;
3009 len = xcb_randr_get_output_info_modes_length(oreply);
3010 rmodes = xcb_randr_get_output_info_modes(oreply);
3011 memcpy(modes, rmodes, sizeof(Ecore_X_Randr_Mode) * len);
3019 static Ecore_X_Randr_Mode_Info *
3020 _ecore_xcb_randr_12_mode_info_get(Ecore_X_Window root,
3021 Ecore_X_Randr_Mode mode)
3023 Ecore_X_Randr_Mode_Info *ret = NULL;
3024 #ifdef ECORE_XCB_RANDR
3025 xcb_randr_get_screen_resources_reply_t *reply;
3027 reply = _ecore_xcb_randr_12_get_resources(root);
3030 if ((ret = malloc(sizeof(Ecore_X_Randr_Mode_Info))))
3033 xcb_randr_mode_info_iterator_t miter;
3035 nbuf = xcb_randr_get_screen_resources_names(reply);
3036 miter = xcb_randr_get_screen_resources_modes_iterator(reply);
3039 xcb_randr_mode_info_t *minfo;
3042 nbuf += minfo->name_len;
3044 if (minfo->id == mode)
3046 ret->xid = minfo->id;
3047 ret->width = minfo->width;
3048 ret->height = minfo->height;
3049 ret->dotClock = minfo->dot_clock;
3050 ret->hSyncStart = minfo->hsync_start;
3051 ret->hSyncEnd = minfo->hsync_end;
3052 ret->hTotal = minfo->htotal;
3053 ret->vSyncStart = minfo->vsync_start;
3054 ret->vSyncEnd = minfo->vsync_end;
3055 ret->vTotal = minfo->vtotal;
3056 ret->modeFlags = minfo->mode_flags;
3059 ret->nameLength = minfo->name_len;
3060 if (ret->nameLength > 0)
3062 ret->name = malloc(ret->nameLength + 1);
3064 memcpy(ret->name, nbuf, ret->nameLength + 1);
3069 xcb_randr_mode_info_next(&miter);
3079 static Ecore_X_Randr_Mode_Info *
3080 _ecore_xcb_randr_13_mode_info_get(Ecore_X_Window root,
3081 Ecore_X_Randr_Mode mode)
3083 Ecore_X_Randr_Mode_Info *ret = NULL;
3084 #ifdef ECORE_XCB_RANDR
3085 xcb_randr_get_screen_resources_current_reply_t *reply;
3087 reply = _ecore_xcb_randr_13_get_resources(root);
3090 if ((ret = malloc(sizeof(Ecore_X_Randr_Mode_Info))))
3093 xcb_randr_mode_info_iterator_t miter;
3095 nbuf = xcb_randr_get_screen_resources_current_names(reply);
3097 xcb_randr_get_screen_resources_current_modes_iterator(reply);
3100 xcb_randr_mode_info_t *minfo;
3103 nbuf += minfo->name_len;
3105 if (minfo->id == mode)
3107 ret->xid = minfo->id;
3108 ret->width = minfo->width;
3109 ret->height = minfo->height;
3110 ret->dotClock = minfo->dot_clock;
3111 ret->hSyncStart = minfo->hsync_start;
3112 ret->hSyncEnd = minfo->hsync_end;
3113 ret->hTotal = minfo->htotal;
3114 ret->vSyncStart = minfo->vsync_start;
3115 ret->vSyncEnd = minfo->vsync_end;
3116 ret->vTotal = minfo->vtotal;
3117 ret->modeFlags = minfo->mode_flags;
3120 ret->nameLength = minfo->name_len;
3121 if (ret->nameLength > 0)
3123 ret->name = malloc(ret->nameLength + 1);
3125 memcpy(ret->name, nbuf, ret->nameLength + 1);
3130 xcb_randr_mode_info_next(&miter);
3140 static Ecore_X_Randr_Mode_Info **
3141 _ecore_xcb_randr_12_modes_info_get(Ecore_X_Window root,
3144 Ecore_X_Randr_Mode_Info **ret = NULL;
3145 #ifdef ECORE_XCB_RANDR
3146 xcb_randr_get_screen_resources_reply_t *reply;
3148 reply = _ecore_xcb_randr_12_get_resources(root);
3151 if (num) *num = reply->num_modes;
3152 ret = malloc(sizeof(Ecore_X_Randr_Mode_Info *) * reply->num_modes);
3155 xcb_randr_mode_info_iterator_t miter;
3159 nbuf = xcb_randr_get_screen_resources_names(reply);
3160 miter = xcb_randr_get_screen_resources_modes_iterator(reply);
3163 xcb_randr_mode_info_t *minfo;
3166 nbuf += minfo->name_len;
3167 if ((ret[i] = malloc(sizeof(Ecore_X_Randr_Mode_Info))))
3169 ret[i]->xid = minfo->id;
3170 ret[i]->width = minfo->width;
3171 ret[i]->height = minfo->height;
3172 ret[i]->dotClock = minfo->dot_clock;
3173 ret[i]->hSyncStart = minfo->hsync_start;
3174 ret[i]->hSyncEnd = minfo->hsync_end;
3175 ret[i]->hTotal = minfo->htotal;
3176 ret[i]->vSyncStart = minfo->vsync_start;
3177 ret[i]->vSyncEnd = minfo->vsync_end;
3178 ret[i]->vTotal = minfo->vtotal;
3179 ret[i]->modeFlags = minfo->mode_flags;
3181 ret[i]->name = NULL;
3182 ret[i]->nameLength = minfo->name_len;
3183 if (ret[i]->nameLength > 0)
3185 ret[i]->name = malloc(ret[i]->nameLength + 1);
3187 memcpy(ret[i]->name, nbuf,
3188 ret[i]->nameLength + 1);
3200 xcb_randr_mode_info_next(&miter);
3209 static Ecore_X_Randr_Mode_Info **
3210 _ecore_xcb_randr_13_modes_info_get(Ecore_X_Window root,
3213 Ecore_X_Randr_Mode_Info **ret = NULL;
3214 #ifdef ECORE_XCB_RANDR
3215 xcb_randr_get_screen_resources_current_reply_t *reply;
3217 reply = _ecore_xcb_randr_13_get_resources(root);
3220 if (num) *num = reply->num_modes;
3221 ret = malloc(sizeof(Ecore_X_Randr_Mode_Info *) * reply->num_modes);
3224 xcb_randr_mode_info_iterator_t miter;
3228 nbuf = xcb_randr_get_screen_resources_current_names(reply);
3230 xcb_randr_get_screen_resources_current_modes_iterator(reply);
3233 xcb_randr_mode_info_t *minfo;
3236 nbuf += minfo->name_len;
3237 if ((ret[i] = malloc(sizeof(Ecore_X_Randr_Mode_Info))))
3239 ret[i]->xid = minfo->id;
3240 ret[i]->width = minfo->width;
3241 ret[i]->height = minfo->height;
3242 ret[i]->dotClock = minfo->dot_clock;
3243 ret[i]->hSyncStart = minfo->hsync_start;
3244 ret[i]->hSyncEnd = minfo->hsync_end;
3245 ret[i]->hTotal = minfo->htotal;
3246 ret[i]->vSyncStart = minfo->vsync_start;
3247 ret[i]->vSyncEnd = minfo->vsync_end;
3248 ret[i]->vTotal = minfo->vtotal;
3249 ret[i]->modeFlags = minfo->mode_flags;
3251 ret[i]->name = NULL;
3252 ret[i]->nameLength = minfo->name_len;
3253 if (ret[i]->nameLength > 0)
3255 ret[i]->name = malloc(ret[i]->nameLength + 1);
3257 memcpy(ret[i]->name, nbuf,
3258 ret[i]->nameLength + 1);
3270 xcb_randr_mode_info_next(&miter);
3280 _ecore_xcb_randr_12_mode_size_get(Ecore_X_Window root,
3281 Ecore_X_Randr_Mode mode,
3288 #ifdef ECORE_XCB_RANDR
3289 xcb_randr_get_screen_resources_reply_t *reply;
3291 reply = _ecore_xcb_randr_12_get_resources(root);
3294 xcb_randr_mode_info_iterator_t miter;
3296 miter = xcb_randr_get_screen_resources_modes_iterator(reply);
3299 xcb_randr_mode_info_t *minfo;
3302 if (minfo->id == mode)
3304 if (w) *w = minfo->width;
3305 if (h) *h = minfo->height;
3308 xcb_randr_mode_info_next(&miter);
3316 _ecore_xcb_randr_13_mode_size_get(Ecore_X_Window root,
3317 Ecore_X_Randr_Mode mode,
3324 #ifdef ECORE_XCB_RANDR
3325 xcb_randr_get_screen_resources_current_reply_t *reply;
3327 reply = _ecore_xcb_randr_13_get_resources(root);
3330 xcb_randr_mode_info_iterator_t miter;
3332 miter = xcb_randr_get_screen_resources_current_modes_iterator(reply);
3335 xcb_randr_mode_info_t *minfo;
3338 if (minfo->id == mode)
3340 if (w) *w = minfo->width;
3341 if (h) *h = minfo->height;
3344 xcb_randr_mode_info_next(&miter);
3351 static Ecore_X_Randr_Output *
3352 _ecore_xcb_randr_12_output_clones_get(Ecore_X_Window root,
3353 Ecore_X_Randr_Output output,
3356 Ecore_X_Randr_Output *outputs = NULL;
3357 #ifdef ECORE_XCB_RANDR
3358 xcb_randr_get_screen_resources_reply_t *reply;
3360 reply = _ecore_xcb_randr_12_get_resources(root);
3363 xcb_randr_get_output_info_cookie_t ocookie;
3364 xcb_randr_get_output_info_reply_t *oreply;
3367 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
3368 reply->config_timestamp);
3369 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
3373 if (num) *num = oreply->num_clones;
3376 malloc(sizeof(Ecore_X_Randr_Output) * oreply->num_clones);
3379 memcpy(outputs, xcb_randr_get_output_info_clones(oreply),
3380 sizeof(Ecore_X_Randr_Output) * oreply->num_clones);
3390 static Ecore_X_Randr_Output *
3391 _ecore_xcb_randr_13_output_clones_get(Ecore_X_Window root,
3392 Ecore_X_Randr_Output output,
3395 Ecore_X_Randr_Output *outputs = NULL;
3396 #ifdef ECORE_XCB_RANDR
3397 xcb_randr_get_screen_resources_current_reply_t *reply;
3399 reply = _ecore_xcb_randr_13_get_resources(root);
3402 xcb_randr_get_output_info_cookie_t ocookie;
3403 xcb_randr_get_output_info_reply_t *oreply;
3406 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
3407 reply->config_timestamp);
3408 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
3412 if (num) *num = oreply->num_clones;
3415 malloc(sizeof(Ecore_X_Randr_Output) * oreply->num_clones);
3418 memcpy(outputs, xcb_randr_get_output_info_clones(oreply),
3419 sizeof(Ecore_X_Randr_Output) * oreply->num_clones);
3429 static Ecore_X_Randr_Crtc *
3430 _ecore_xcb_randr_12_output_possible_crtcs_get(Ecore_X_Window root,
3431 Ecore_X_Randr_Output output,
3434 Ecore_X_Randr_Crtc *crtcs = NULL;
3435 #ifdef ECORE_XCB_RANDR
3436 xcb_randr_get_screen_resources_reply_t *reply;
3438 reply = _ecore_xcb_randr_12_get_resources(root);
3441 xcb_randr_get_output_info_cookie_t ocookie;
3442 xcb_randr_get_output_info_reply_t *oreply;
3445 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
3446 reply->config_timestamp);
3447 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
3451 if (num) *num = oreply->num_crtcs;
3453 crtcs = malloc(sizeof(Ecore_X_Randr_Crtc) * oreply->num_crtcs);
3456 memcpy(crtcs, xcb_randr_get_output_info_crtcs(oreply),
3457 sizeof(Ecore_X_Randr_Crtc) * oreply->num_crtcs);
3467 static Ecore_X_Randr_Crtc *
3468 _ecore_xcb_randr_13_output_possible_crtcs_get(Ecore_X_Window root,
3469 Ecore_X_Randr_Output output,
3472 Ecore_X_Randr_Crtc *crtcs = NULL;
3473 #ifdef ECORE_XCB_RANDR
3474 xcb_randr_get_screen_resources_current_reply_t *reply;
3476 reply = _ecore_xcb_randr_13_get_resources(root);
3479 xcb_randr_get_output_info_cookie_t ocookie;
3480 xcb_randr_get_output_info_reply_t *oreply;
3483 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
3484 reply->config_timestamp);
3485 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
3489 if (num) *num = oreply->num_crtcs;
3491 crtcs = malloc(sizeof(Ecore_X_Randr_Crtc) * oreply->num_crtcs);
3494 memcpy(crtcs, xcb_randr_get_output_info_crtcs(oreply),
3495 sizeof(Ecore_X_Randr_Crtc) * oreply->num_crtcs);
3506 _ecore_xcb_randr_12_output_name_get(Ecore_X_Window root,
3507 Ecore_X_Randr_Output output,
3511 #ifdef ECORE_XCB_RANDR
3512 xcb_randr_get_screen_resources_reply_t *reply;
3514 reply = _ecore_xcb_randr_12_get_resources(root);
3517 xcb_randr_get_output_info_cookie_t ocookie;
3518 xcb_randr_get_output_info_reply_t *oreply;
3521 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
3522 reply->config_timestamp);
3523 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
3529 nbuf = xcb_randr_get_output_info_name(oreply);
3530 nbuf += oreply->name_len;
3532 if (len) *len = oreply->name_len;
3533 if (oreply->name_len > 0)
3535 ret = malloc(oreply->name_len + 1);
3537 memcpy(ret, nbuf, oreply->name_len + 1);
3549 _ecore_xcb_randr_13_output_name_get(Ecore_X_Window root,
3550 Ecore_X_Randr_Output output,
3554 #ifdef ECORE_XCB_RANDR
3555 xcb_randr_get_screen_resources_current_reply_t *reply;
3557 reply = _ecore_xcb_randr_13_get_resources(root);
3560 xcb_randr_get_output_info_cookie_t ocookie;
3561 xcb_randr_get_output_info_reply_t *oreply;
3564 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
3565 reply->config_timestamp);
3566 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
3572 nbuf = xcb_randr_get_output_info_name(oreply);
3573 nbuf += oreply->name_len;
3575 if (len) *len = oreply->name_len;
3576 if (oreply->name_len > 0)
3578 ret = malloc(oreply->name_len + 1);
3580 memcpy(ret, nbuf, oreply->name_len + 1);
3591 static Ecore_X_Randr_Connection_Status
3592 _ecore_xcb_randr_12_output_connection_status_get(Ecore_X_Window root,
3593 Ecore_X_Randr_Output output)
3595 Ecore_X_Randr_Connection_Status ret = ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN;
3596 #ifdef ECORE_XCB_RANDR
3597 xcb_randr_get_screen_resources_reply_t *reply;
3599 reply = _ecore_xcb_randr_12_get_resources(root);
3602 xcb_randr_get_output_info_cookie_t ocookie;
3603 xcb_randr_get_output_info_reply_t *oreply;
3606 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
3607 reply->config_timestamp);
3608 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
3612 ret = oreply->connection;
3621 static Ecore_X_Randr_Connection_Status
3622 _ecore_xcb_randr_13_output_connection_status_get(Ecore_X_Window root,
3623 Ecore_X_Randr_Output output)
3625 Ecore_X_Randr_Connection_Status ret = ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN;
3626 #ifdef ECORE_XCB_RANDR
3627 xcb_randr_get_screen_resources_current_reply_t *reply;
3629 reply = _ecore_xcb_randr_13_get_resources(root);
3632 xcb_randr_get_output_info_cookie_t ocookie;
3633 xcb_randr_get_output_info_reply_t *oreply;
3636 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
3637 reply->config_timestamp);
3638 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
3642 ret = oreply->connection;
3651 static Ecore_X_Randr_Output *
3652 _ecore_xcb_randr_12_outputs_get(Ecore_X_Window root,
3655 Ecore_X_Randr_Output *ret = NULL;
3656 #ifdef ECORE_XCB_RANDR
3657 xcb_randr_get_screen_resources_reply_t *reply;
3659 reply = _ecore_xcb_randr_12_get_resources(root);
3662 if (num) *num = reply->num_outputs;
3663 ret = malloc(sizeof(Ecore_X_Randr_Output) * reply->num_outputs);
3665 memcpy(ret, xcb_randr_get_screen_resources_outputs(reply),
3666 sizeof(Ecore_X_Randr_Output) * reply->num_outputs);
3673 static Ecore_X_Randr_Output *
3674 _ecore_xcb_randr_13_outputs_get(Ecore_X_Window root,
3677 Ecore_X_Randr_Output *ret = NULL;
3678 #ifdef ECORE_XCB_RANDR
3679 xcb_randr_get_screen_resources_current_reply_t *reply;
3681 reply = _ecore_xcb_randr_13_get_resources(root);
3684 if (num) *num = reply->num_outputs;
3685 ret = malloc(sizeof(Ecore_X_Randr_Output) * reply->num_outputs);
3687 memcpy(ret, xcb_randr_get_screen_resources_current_outputs(reply),
3688 sizeof(Ecore_X_Randr_Output) * reply->num_outputs);
3695 static Ecore_X_Randr_Crtc
3696 _ecore_xcb_randr_12_output_crtc_get(Ecore_X_Window root,
3697 Ecore_X_Randr_Output output)
3699 Ecore_X_Randr_Crtc ret = Ecore_X_Randr_None;
3700 #ifdef ECORE_XCB_RANDR
3701 xcb_randr_get_screen_resources_reply_t *reply;
3703 reply = _ecore_xcb_randr_12_get_resources(root);
3706 xcb_randr_get_output_info_cookie_t ocookie;
3707 xcb_randr_get_output_info_reply_t *oreply;
3710 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
3711 reply->config_timestamp);
3712 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
3725 static Ecore_X_Randr_Crtc
3726 _ecore_xcb_randr_13_output_crtc_get(Ecore_X_Window root,
3727 Ecore_X_Randr_Output output)
3729 Ecore_X_Randr_Crtc ret = Ecore_X_Randr_None;
3730 #ifdef ECORE_XCB_RANDR
3731 xcb_randr_get_screen_resources_current_reply_t *reply;
3733 reply = _ecore_xcb_randr_13_get_resources(root);
3736 xcb_randr_get_output_info_cookie_t ocookie;
3737 xcb_randr_get_output_info_reply_t *oreply;
3740 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
3741 reply->config_timestamp);
3742 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
3755 static xcb_randr_get_screen_resources_reply_t *
3756 _ecore_xcb_randr_12_get_resources(Ecore_X_Window win)
3758 xcb_randr_get_screen_resources_cookie_t cookie;
3759 xcb_randr_get_screen_resources_reply_t *reply;
3761 cookie = xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, win);
3762 reply = xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL);
3766 static xcb_randr_get_screen_resources_current_reply_t *
3767 _ecore_xcb_randr_13_get_resources(Ecore_X_Window win)
3769 xcb_randr_get_screen_resources_current_cookie_t cookie;
3770 xcb_randr_get_screen_resources_current_reply_t *reply;
3773 xcb_randr_get_screen_resources_current_unchecked(_ecore_xcb_conn, win);
3775 xcb_randr_get_screen_resources_current_reply(_ecore_xcb_conn,
3780 static xcb_timestamp_t
3781 _ecore_xcb_randr_12_get_resource_timestamp(Ecore_X_Window win)
3783 xcb_timestamp_t stamp = 0;
3784 #ifdef ECORE_XCB_RANDR
3785 xcb_randr_get_screen_resources_reply_t *reply;
3787 reply = _ecore_xcb_randr_12_get_resources(win);
3788 stamp = reply->config_timestamp;
3794 static xcb_timestamp_t
3795 _ecore_xcb_randr_13_get_resource_timestamp(Ecore_X_Window win)
3797 xcb_timestamp_t stamp = 0;
3798 #ifdef ECORE_XCB_RANDR
3799 xcb_randr_get_screen_resources_current_reply_t *reply;
3801 reply = _ecore_xcb_randr_13_get_resources(win);
3802 stamp = reply->config_timestamp;