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 static xcb_randr_get_screen_resources_reply_t *_ecore_xcb_randr_12_get_resources(Ecore_X_Window win);
78 static xcb_randr_get_screen_resources_current_reply_t *_ecore_xcb_randr_13_get_resources(Ecore_X_Window win);
79 static xcb_timestamp_t _ecore_xcb_randr_12_get_resource_timestamp(Ecore_X_Window win);
80 static xcb_timestamp_t _ecore_xcb_randr_13_get_resource_timestamp(Ecore_X_Window win);
82 static Ecore_X_Randr_Mode *_ecore_xcb_randr_12_output_modes_get(Ecore_X_Window root,
83 Ecore_X_Randr_Output output,
86 static Ecore_X_Randr_Mode *_ecore_xcb_randr_13_output_modes_get(Ecore_X_Window root,
87 Ecore_X_Randr_Output output,
90 static Ecore_X_Randr_Mode_Info *_ecore_xcb_randr_12_mode_info_get(Ecore_X_Window root,
91 Ecore_X_Randr_Mode mode);
92 static Ecore_X_Randr_Mode_Info *_ecore_xcb_randr_13_mode_info_get(Ecore_X_Window root,
93 Ecore_X_Randr_Mode mode);
94 static Ecore_X_Randr_Mode_Info **_ecore_xcb_randr_12_modes_info_get(Ecore_X_Window root,
96 static Ecore_X_Randr_Mode_Info **_ecore_xcb_randr_13_modes_info_get(Ecore_X_Window root,
98 static void _ecore_xcb_randr_12_mode_size_get(Ecore_X_Window root,
99 Ecore_X_Randr_Mode mode,
102 static void _ecore_xcb_randr_13_mode_size_get(Ecore_X_Window root,
103 Ecore_X_Randr_Mode mode,
106 static Ecore_X_Randr_Output *_ecore_xcb_randr_12_output_clones_get(Ecore_X_Window root,
107 Ecore_X_Randr_Output output,
109 static Ecore_X_Randr_Output *_ecore_xcb_randr_13_output_clones_get(Ecore_X_Window root,
110 Ecore_X_Randr_Output output,
112 static Ecore_X_Randr_Crtc *_ecore_xcb_randr_12_output_possible_crtcs_get(Ecore_X_Window root,
113 Ecore_X_Randr_Output output,
115 static Ecore_X_Randr_Crtc *_ecore_xcb_randr_13_output_possible_crtcs_get(Ecore_X_Window root,
116 Ecore_X_Randr_Output output,
118 static char *_ecore_xcb_randr_12_output_name_get(Ecore_X_Window root,
119 Ecore_X_Randr_Output output,
121 static char *_ecore_xcb_randr_13_output_name_get(Ecore_X_Window root,
122 Ecore_X_Randr_Output output,
124 static Ecore_X_Randr_Connection_Status _ecore_xcb_randr_12_output_connection_status_get(Ecore_X_Window root,
125 Ecore_X_Randr_Output output);
126 static Ecore_X_Randr_Connection_Status _ecore_xcb_randr_13_output_connection_status_get(Ecore_X_Window root,
127 Ecore_X_Randr_Output output);
128 static Ecore_X_Randr_Output *_ecore_xcb_randr_12_outputs_get(Ecore_X_Window root,
130 static Ecore_X_Randr_Output *_ecore_xcb_randr_13_outputs_get(Ecore_X_Window root,
132 static Ecore_X_Randr_Crtc _ecore_xcb_randr_12_output_crtc_get(Ecore_X_Window root,
133 Ecore_X_Randr_Output output);
134 static Ecore_X_Randr_Crtc _ecore_xcb_randr_13_output_crtc_get(Ecore_X_Window root,
135 Ecore_X_Randr_Output output);
137 /* local variables */
138 static Eina_Bool _randr_avail = EINA_FALSE;
139 static int _randr_version = -1;
141 /* external variables */
142 int _ecore_xcb_event_randr = -1;
145 _ecore_xcb_randr_init(void)
147 LOGFN(__FILE__, __LINE__, __FUNCTION__);
149 #ifdef ECORE_XCB_RANDR
150 xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_randr_id);
155 _ecore_xcb_randr_finalize(void)
157 #ifdef ECORE_XCB_RANDR
158 const xcb_query_extension_reply_t *ext_reply;
161 LOGFN(__FILE__, __LINE__, __FUNCTION__);
163 #ifdef ECORE_XCB_RANDR
164 ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_randr_id);
165 if ((ext_reply) && (ext_reply->present))
167 xcb_randr_query_version_cookie_t cookie;
168 xcb_randr_query_version_reply_t *reply;
171 xcb_randr_query_version_unchecked(_ecore_xcb_conn,
172 XCB_RANDR_MAJOR_VERSION,
173 XCB_RANDR_MINOR_VERSION);
174 reply = xcb_randr_query_version_reply(_ecore_xcb_conn, cookie, NULL);
177 if ((reply->major_version >= XCB_RANDR_MAJOR_VERSION) &&
178 (reply->minor_version >= XCB_RANDR_MINOR_VERSION))
179 _randr_avail = EINA_TRUE;
182 ((reply->major_version << 16) | reply->minor_version);
188 _ecore_xcb_event_randr = ext_reply->first_event;
194 _ecore_xcb_randr_root_validate(Ecore_X_Window root)
196 #ifdef ECORE_XCB_RANDR
197 Ecore_X_Randr_Screen scr = -1;
198 # define RANDR_VALIDATE_ROOT(screen, root) \
199 ((screen == _ecore_xcb_randr_root_to_screen(root)) != -1)
202 LOGFN(__FILE__, __LINE__, __FUNCTION__);
204 #ifdef ECORE_XCB_RANDR
205 if ((root) && RANDR_VALIDATE_ROOT(scr, root))
213 _ecore_xcb_randr_root_to_screen(Ecore_X_Window root)
215 int count = 0, num = 0;
219 count = xcb_setup_roots_length(xcb_get_setup(_ecore_xcb_conn));
220 for (num = 0; num < count; num++)
221 if (_ecore_xcb_window_root_of_screen_get(num) == root)
227 /* public functions */
230 * @brief Query whether RandR is available or not.
232 * @return @c EINA_TRUE if extension is available, @c EINA_FALSE otherwise.
235 ecore_x_randr_query(void)
241 * @return version of the RandRR extension supported by the server or,
242 * in case RandRR extension is not available, Ecore_X_Randr_Unset (=-1).
243 * bit version information: 31 MAJOR 16 | 15 MINOR 0
246 ecore_x_randr_version_get(void)
248 return _randr_version;
252 * @param root window which's primary output will be queried
254 EAPI Ecore_X_Randr_Orientation
255 ecore_x_randr_screen_primary_output_orientations_get(Ecore_X_Window root)
257 int ret = Ecore_X_Randr_None;
258 #ifdef ECORE_XCB_RANDR
259 xcb_randr_get_screen_info_cookie_t cookie;
260 xcb_randr_get_screen_info_reply_t *reply;
263 LOGFN(__FILE__, __LINE__, __FUNCTION__);
266 #ifdef ECORE_XCB_RANDR
267 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root);
268 reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL);
271 ret = reply->rotations;
280 * @param root window which's primary output will be queried
281 * @return the current orientation of the root window's screen primary output
283 EAPI Ecore_X_Randr_Orientation
284 ecore_x_randr_screen_primary_output_orientation_get(Ecore_X_Window root)
286 int ret = Ecore_X_Randr_None;
287 #ifdef ECORE_XCB_RANDR
288 xcb_randr_get_screen_info_cookie_t cookie;
289 xcb_randr_get_screen_info_reply_t *reply;
292 LOGFN(__FILE__, __LINE__, __FUNCTION__);
295 #ifdef ECORE_XCB_RANDR
296 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root);
297 reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL);
300 ret = reply->rotation;
309 * @brief Sets a given screen's primary output's orientation.
311 * @param root Window which's screen's primary output will be queried.
312 * @param orientation Orientation which should be set for the root window's
313 * screen primary output.
314 * @return @c EINA_TRUE if the primary output's orientation could be
315 * successfully altered.
318 ecore_x_randr_screen_primary_output_orientation_set(Ecore_X_Window root,
319 Ecore_X_Randr_Orientation orientation)
321 int ret = EINA_FALSE;
322 #ifdef ECORE_XCB_RANDR
323 xcb_randr_get_screen_info_cookie_t cookie;
324 xcb_randr_get_screen_info_reply_t *reply;
327 LOGFN(__FILE__, __LINE__, __FUNCTION__);
330 #ifdef ECORE_XCB_RANDR
331 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root);
332 reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL);
335 xcb_randr_set_screen_config_cookie_t scookie;
336 xcb_randr_set_screen_config_reply_t *sreply;
339 xcb_randr_set_screen_config_unchecked(_ecore_xcb_conn, root,
341 reply->config_timestamp,
342 reply->sizeID, orientation,
345 xcb_randr_set_screen_config_reply(_ecore_xcb_conn, scookie, NULL);
350 ret = (sreply->status == XCB_RANDR_SET_CONFIG_SUCCESS) ?
351 EINA_TRUE : EINA_FALSE;
362 * @brief gets a screen's primary output's possible sizes
363 * @param root window which's primary output will be queried
364 * @param num number of sizes reported as supported by the screen's primary output
365 * @return an array of sizes reported as supported by the screen's primary output or - if query failed - NULL
367 EAPI Ecore_X_Randr_Screen_Size_MM *
368 ecore_x_randr_screen_primary_output_sizes_get(Ecore_X_Window root,
371 #ifdef ECORE_XCB_RANDR
372 xcb_randr_get_screen_info_cookie_t cookie;
373 xcb_randr_get_screen_info_reply_t *reply;
374 Ecore_X_Randr_Screen_Size_MM *ret = NULL;
377 LOGFN(__FILE__, __LINE__, __FUNCTION__);
380 #ifdef ECORE_XCB_RANDR
381 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root);
382 reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL);
386 xcb_randr_screen_size_t *sizes;
388 len = xcb_randr_get_screen_info_sizes_length(reply);
389 sizes = xcb_randr_get_screen_info_sizes(reply);
390 if ((!sizes) || (len <= 0))
396 ret = calloc(len, sizeof(Ecore_X_Randr_Screen_Size_MM));
402 for (i = 0; i < len; i++)
404 ret[i].width = sizes[i].width;
405 ret[i].height = sizes[i].height;
406 ret[i].width_mm = sizes[i].mwidth;
407 ret[i].height_mm = sizes[i].mheight;
420 * @brief get the current set size of a given screen's primary output
421 * @param root window which's primary output will be queried
422 * @param w the current size's width
423 * @param h the current size's height
424 * @param w_mm the current size's width in mm
425 * @param h_mm the current size's height in mm
426 * @param size_index of current set size to be used with ecore_x_randr_primary_output_size_set()
429 ecore_x_randr_screen_primary_output_current_size_get(Ecore_X_Window root,
436 #ifdef ECORE_XCB_RANDR
437 xcb_randr_get_screen_info_cookie_t cookie;
438 xcb_randr_get_screen_info_reply_t *reply;
441 LOGFN(__FILE__, __LINE__, __FUNCTION__);
444 #ifdef ECORE_XCB_RANDR
445 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root);
446 reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL);
449 int len = 0, idx = 0;
450 xcb_randr_screen_size_t *sizes;
452 len = xcb_randr_get_screen_info_sizes_length(reply);
453 sizes = xcb_randr_get_screen_info_sizes(reply);
454 if ((!sizes) || (len <= 0))
460 if ((idx < len) && (idx >= 0))
462 if (w) *w = sizes[idx].width;
463 if (h) *h = sizes[idx].height;
464 if (w_mm) *w_mm = sizes[idx].mwidth;
465 if (h_mm) *h_mm = sizes[idx].mheight;
466 if (size_index) *size_index = idx;
475 * @brief Sets a given screen's primary output size, but disables all other
476 * outputs at the same time.
478 * @param root Window which's primary output will be queried.
479 * @param size_index Within the list of sizes reported as supported by the root
480 * window's screen primary output.
481 * @return @c EINA_TRUE on success, @c EINA_FALSE on failure due to e.g.
485 ecore_x_randr_screen_primary_output_size_set(Ecore_X_Window root,
488 Eina_Bool ret = EINA_FALSE;
489 #ifdef ECORE_XCB_RANDR
490 xcb_randr_get_screen_info_cookie_t cookie;
491 xcb_randr_get_screen_info_reply_t *reply;
494 LOGFN(__FILE__, __LINE__, __FUNCTION__);
497 #ifdef ECORE_XCB_RANDR
498 if (!((size_index >= 0) && (_ecore_xcb_randr_root_validate(root))))
501 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root);
502 reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL);
507 len = xcb_randr_get_screen_info_sizes_length(reply);
513 if ((size_index < len) && (size_index >= 0))
515 xcb_randr_set_screen_config_cookie_t scookie;
516 xcb_randr_set_screen_config_reply_t *sreply;
519 xcb_randr_set_screen_config_unchecked(_ecore_xcb_conn, root,
521 reply->config_timestamp,
526 xcb_randr_set_screen_config_reply(_ecore_xcb_conn,
532 ret = (sreply->status == XCB_RANDR_SET_CONFIG_SUCCESS) ?
533 EINA_TRUE : EINA_FALSE;
545 * @param root window which's primary output will be queried
546 * @return currently used refresh rate or - if request failed or RandRR is not available - 0.0
548 EAPI Ecore_X_Randr_Refresh_Rate
549 ecore_x_randr_screen_primary_output_current_refresh_rate_get(Ecore_X_Window root)
551 #ifdef ECORE_XCB_RANDR
552 xcb_randr_get_screen_info_cookie_t cookie;
553 xcb_randr_get_screen_info_reply_t *reply;
554 Ecore_X_Randr_Refresh_Rate ret = 0.0;
557 LOGFN(__FILE__, __LINE__, __FUNCTION__);
560 #ifdef ECORE_XCB_RANDR
561 if (!_ecore_xcb_randr_root_validate(root)) return ret;
563 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root);
564 reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL);
578 * @param root window which's primary output will be queried
579 * @param size_index referencing the size to query valid refresh rates for
580 * @return currently used refresh rate or - if request failed or RandRR is not available - NULL
582 EAPI Ecore_X_Randr_Refresh_Rate *
583 ecore_x_randr_screen_primary_output_refresh_rates_get(Ecore_X_Window root,
587 #ifdef ECORE_XCB_RANDR
588 xcb_randr_get_screen_info_cookie_t cookie;
589 xcb_randr_get_screen_info_reply_t *reply;
590 Ecore_X_Randr_Refresh_Rate *ret = NULL;
593 LOGFN(__FILE__, __LINE__, __FUNCTION__);
596 #ifdef ECORE_XCB_RANDR
597 if (!_ecore_xcb_randr_root_validate(root)) return ret;
599 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root);
600 reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL);
605 len = xcb_randr_get_screen_info_rates_length(reply);
608 ret = malloc(sizeof(Ecore_X_Randr_Refresh_Rate) * len);
611 xcb_randr_refresh_rates_iterator_t iter;
614 iter = xcb_randr_get_screen_info_rates_iterator(reply);
615 while (i++ < size_index)
616 xcb_randr_refresh_rates_next(&iter);
618 memcpy(ret, xcb_randr_refresh_rates_rates(iter.data),
619 sizeof(Ecore_X_Randr_Refresh_Rate) * len);
631 * @brief Sets the current primary output's refresh rate.
633 * @param root Window which's primary output will be queried.
634 * @param size_index Referencing the size to be set.
635 * @param rate The refresh rate to be set.
636 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
639 ecore_x_randr_screen_primary_output_refresh_rate_set(Ecore_X_Window root,
641 Ecore_X_Randr_Refresh_Rate rate)
643 Eina_Bool ret = EINA_FALSE;
644 #ifdef ECORE_XCB_RANDR
645 xcb_randr_get_screen_info_cookie_t cookie;
646 xcb_randr_get_screen_info_reply_t *reply;
649 LOGFN(__FILE__, __LINE__, __FUNCTION__);
652 #ifdef ECORE_XCB_RANDR
653 if (_randr_version < RANDR_1_1) return EINA_FALSE;
655 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root);
656 reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL);
659 xcb_randr_set_screen_config_cookie_t scookie;
660 xcb_randr_set_screen_config_reply_t *sreply;
663 xcb_randr_set_screen_config_unchecked(_ecore_xcb_conn, root,
665 reply->config_timestamp,
667 reply->rotation, rate);
669 xcb_randr_set_screen_config_reply(_ecore_xcb_conn,
675 ret = (sreply->status == XCB_RANDR_SET_CONFIG_SUCCESS) ?
676 EINA_TRUE : EINA_FALSE;
687 * @brief Free detailed mode information. The pointer handed in will be set to
688 * @c NULL after freeing the memory.
690 * @param mode_info The mode information that should be freed.
693 ecore_x_randr_mode_info_free(Ecore_X_Randr_Mode_Info *mode_info)
695 LOGFN(__FILE__, __LINE__, __FUNCTION__);
698 RANDR_CHECK_1_2_RET();
700 if (!mode_info) return;
702 if (mode_info->name) free(mode_info->name);
708 * @param root window which's screen should be queried
709 * @return Ecore_X_Randr_Ouptut_Id or - if query failed or none is set - Ecore_X_Randr_None
711 EAPI Ecore_X_Randr_Output
712 ecore_x_randr_primary_output_get(Ecore_X_Window root)
714 Ecore_X_Randr_Output ret = Ecore_X_Randr_None;
715 #ifdef ECORE_XCB_RANDR
716 xcb_randr_get_output_primary_cookie_t cookie;
717 xcb_randr_get_output_primary_reply_t *reply;
720 LOGFN(__FILE__, __LINE__, __FUNCTION__);
723 #ifdef ECORE_XCB_RANDR
724 RANDR_CHECK_1_3_RET(Ecore_X_Randr_None);
726 if (!_ecore_xcb_randr_root_validate(root))
727 return Ecore_X_Randr_None;
729 cookie = xcb_randr_get_output_primary_unchecked(_ecore_xcb_conn, root);
730 reply = xcb_randr_get_output_primary_reply(_ecore_xcb_conn, cookie, NULL);
741 * @param root window which's screen should be queried
742 * @param output that should be set as given root window's screen primary output
745 ecore_x_randr_primary_output_set(Ecore_X_Window root,
746 Ecore_X_Randr_Output output)
748 LOGFN(__FILE__, __LINE__, __FUNCTION__);
751 #ifdef ECORE_XCB_RANDR
752 RANDR_CHECK_1_3_RET();
754 if ((output) && (_ecore_xcb_randr_root_validate(root)))
755 xcb_randr_set_output_primary(_ecore_xcb_conn, root, output);
759 EAPI Ecore_X_Randr_Mode *
760 ecore_x_randr_output_modes_get(Ecore_X_Window root,
761 Ecore_X_Randr_Output output,
765 Ecore_X_Randr_Mode *modes = NULL;
767 LOGFN(__FILE__, __LINE__, __FUNCTION__);
770 #ifdef ECORE_XCB_RANDR
771 RANDR_CHECK_1_2_RET(NULL);
773 if (_randr_version >= RANDR_1_3)
776 _ecore_xcb_randr_13_output_modes_get(root, output, num, npreferred);
778 else if (_randr_version == RANDR_1_2)
781 _ecore_xcb_randr_12_output_modes_get(root, output, num, npreferred);
789 ecore_x_randr_output_mode_add(Ecore_X_Randr_Output output, Ecore_X_Randr_Mode mode)
791 LOGFN(__FILE__, __LINE__, __FUNCTION__);
794 #ifdef ECORE_XCB_RANDR
795 RANDR_CHECK_1_2_RET(EINA_FALSE);
797 if ((output == Ecore_X_Randr_None) || (mode == Ecore_X_Randr_None))
800 xcb_randr_add_output_mode(_ecore_xcb_conn, output, mode);
807 * @brief get detailed information for a given mode id
808 * @param root window which's screen's ressources are queried
809 * @param mode the XID which identifies the mode of interest
810 * @return mode's detailed information
812 EAPI Ecore_X_Randr_Mode_Info *
813 ecore_x_randr_mode_info_get(Ecore_X_Window root,
814 Ecore_X_Randr_Mode mode)
816 Ecore_X_Randr_Mode_Info *ret = NULL;
818 LOGFN(__FILE__, __LINE__, __FUNCTION__);
821 #ifdef ECORE_XCB_RANDR
822 RANDR_CHECK_1_2_RET(NULL);
824 if (!_ecore_xcb_randr_root_validate(root)) return NULL;
826 if (_randr_version >= RANDR_1_3)
827 ret = _ecore_xcb_randr_13_mode_info_get(root, mode);
828 else if (_randr_version == RANDR_1_2)
829 ret = _ecore_xcb_randr_12_mode_info_get(root, mode);
835 * @brief add a mode to a display
836 * @param root window to which's screen's ressources are added
838 * @return Ecore_X_Randr_Mode of the added mode. Ecore_X_Randr_None if mode
842 EAPI Ecore_X_Randr_Mode
843 ecore_x_randr_mode_info_add(Ecore_X_Window root, Ecore_X_Randr_Mode_Info *mode_info)
845 #ifdef ECORE_XCB_RANDR
846 Ecore_X_Randr_Mode mode = Ecore_X_Randr_None;
847 xcb_randr_create_mode_cookie_t cookie;
848 xcb_randr_create_mode_reply_t *reply;
849 xcb_randr_mode_info_t info;
853 LOGFN(__FILE__, __LINE__, __FUNCTION__);
856 #ifdef ECORE_XCB_RANDR
857 RANDR_CHECK_1_2_RET(EINA_FALSE);
859 if (!mode_info) return Ecore_X_Randr_None;
860 if (!_ecore_xcb_randr_root_validate(root)) return Ecore_X_Randr_None;
862 namelen = strlen(mode_info->name);
864 memset(&info, 0, sizeof(info));
865 info.width = mode_info->width;
866 info.height = mode_info->height;
867 info.dot_clock = mode_info->dotClock;
868 info.hsync_start = mode_info->hSyncStart;
869 info.hsync_end = mode_info->hSyncEnd;
870 info.htotal = mode_info->hTotal;
871 info.hskew = mode_info->hSkew;
872 info.vsync_start = mode_info->vSyncStart;
873 info.vsync_end = mode_info->vSyncEnd;
874 info.vtotal = mode_info->vTotal;
875 info.mode_flags = mode_info->modeFlags;
876 info.name_len = namelen;
879 xcb_randr_create_mode_unchecked(_ecore_xcb_conn, root, info,
880 namelen, mode_info->name);
881 reply = xcb_randr_create_mode_reply(_ecore_xcb_conn, cookie, NULL);
884 mode = mode_info->xid;
892 * @brief get detailed information for all modes related to a root window's screen
893 * @param root window which's screen's ressources are queried
894 * @param num number of modes returned
895 * @return modes' information
897 EAPI Ecore_X_Randr_Mode_Info **
898 ecore_x_randr_modes_info_get(Ecore_X_Window root,
901 Ecore_X_Randr_Mode_Info **ret = NULL;
903 LOGFN(__FILE__, __LINE__, __FUNCTION__);
908 #ifdef ECORE_XCB_RANDR
909 RANDR_CHECK_1_2_RET(NULL);
911 if (!_ecore_xcb_randr_root_validate(root)) return NULL;
913 if (_randr_version >= RANDR_1_3)
914 ret = _ecore_xcb_randr_13_modes_info_get(root, num);
915 else if (_randr_version == RANDR_1_2)
916 ret = _ecore_xcb_randr_12_modes_info_get(root, num);
922 * @brief Gets the width and hight of a given mode.
924 * @param root Window which's screen's ressources are queried.
925 * @param mode The mode which's size is to be looked up.
926 * @param w Width of given mode in px.
927 * @param h Height of given mode in px.
930 ecore_x_randr_mode_size_get(Ecore_X_Window root,
931 Ecore_X_Randr_Mode mode,
935 LOGFN(__FILE__, __LINE__, __FUNCTION__);
938 #ifdef ECORE_XCB_RANDR
939 RANDR_CHECK_1_2_RET();
941 if (mode == Ecore_X_Randr_None) return;
943 if (_randr_version >= RANDR_1_3)
944 _ecore_xcb_randr_13_mode_size_get(root, mode, w, h);
945 else if (_randr_version == RANDR_1_2)
946 _ecore_xcb_randr_12_mode_size_get(root, mode, w, h);
951 * @brief Gets the EDID information of an attached output if available.
952 * Note that this information is not to be compared using ordinary string
953 * comparison functions, since it includes 0-bytes.
955 * @param root Window this information should be queried from.
956 * @param output The XID of the output.
957 * @param length Length of the byte-array. If @c NULL, request will fail.
958 * @return EDID information of the output.
961 ecore_x_randr_output_edid_get(Ecore_X_Window root,
962 Ecore_X_Randr_Output output,
963 unsigned long *length)
965 unsigned char *ret = NULL;
966 #ifdef ECORE_XCB_RANDR
967 xcb_randr_get_output_property_cookie_t cookie;
968 xcb_randr_get_output_property_reply_t *reply;
972 LOGFN(__FILE__, __LINE__, __FUNCTION__);
975 #ifdef ECORE_XCB_RANDR
976 RANDR_CHECK_1_2_RET(NULL);
978 if ((!length) || (!_ecore_xcb_randr_output_validate(root, output)))
981 atom = ecore_x_atom_get("EDID");
983 xcb_randr_get_output_property_unchecked(_ecore_xcb_conn, output, atom,
984 XCB_GET_PROPERTY_TYPE_ANY,
987 xcb_randr_get_output_property_reply(_ecore_xcb_conn, cookie, NULL);
990 if ((reply->type == XCB_ATOM_INTEGER) && (reply->format == 8))
992 if (length) *length = reply->num_items;
993 if ((ret = malloc(reply->num_items * sizeof(unsigned char))))
995 memcpy(ret, xcb_randr_get_output_property_data(reply),
996 (reply->num_items * sizeof(unsigned char)));
1006 * @brief Gets the outputs which might be used simultaneously on the same CRTC.
1008 * @param root Window that this information should be queried for.
1009 * @param output The output which's clones we concern.
1010 * @param num Number of possible clones.
1011 * @return The existing outputs, @c NULL otherwise.
1013 EAPI Ecore_X_Randr_Output *
1014 ecore_x_randr_output_clones_get(Ecore_X_Window root,
1015 Ecore_X_Randr_Output output,
1018 Ecore_X_Randr_Output *outputs = NULL;
1020 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1023 #ifdef ECORE_XCB_RANDR
1024 RANDR_CHECK_1_2_RET(NULL);
1026 if (output == Ecore_X_Randr_None) return NULL;
1028 if (_randr_version >= RANDR_1_3)
1029 outputs = _ecore_xcb_randr_13_output_clones_get(root, output, num);
1030 else if (_randr_version == RANDR_1_2)
1031 outputs = _ecore_xcb_randr_12_output_clones_get(root, output, num);
1036 EAPI Ecore_X_Randr_Crtc *
1037 ecore_x_randr_output_possible_crtcs_get(Ecore_X_Window root,
1038 Ecore_X_Randr_Output output,
1041 Ecore_X_Randr_Crtc *crtcs = NULL;
1043 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1046 #ifdef ECORE_XCB_RANDR
1047 RANDR_CHECK_1_2_RET(NULL);
1049 if (output == Ecore_X_Randr_None) return NULL;
1051 if (_randr_version >= RANDR_1_3)
1052 crtcs = _ecore_xcb_randr_13_output_possible_crtcs_get(root, output, num);
1053 else if (_randr_version == RANDR_1_2)
1054 crtcs = _ecore_xcb_randr_12_output_possible_crtcs_get(root, output, num);
1060 * @brief gets the given output's name as reported by X
1061 * @param root the window which's screen will be queried
1062 * @param output The output name given to be reported.
1063 * @param len length of returned c-string.
1064 * @return name of the output as reported by X
1067 ecore_x_randr_output_name_get(Ecore_X_Window root,
1068 Ecore_X_Randr_Output output,
1071 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1074 #ifdef ECORE_XCB_RANDR
1075 RANDR_CHECK_1_2_RET(NULL);
1077 if (output == Ecore_X_Randr_None) return NULL;
1079 if (_randr_version >= RANDR_1_3)
1080 return _ecore_xcb_randr_13_output_name_get(root, output, len);
1081 else if (_randr_version == RANDR_1_2)
1082 return _ecore_xcb_randr_12_output_name_get(root, output, len);
1088 EAPI Ecore_X_Randr_Connection_Status
1089 ecore_x_randr_output_connection_status_get(Ecore_X_Window root,
1090 Ecore_X_Randr_Output output)
1092 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1095 #ifdef ECORE_XCB_RANDR
1096 RANDR_CHECK_1_2_RET(ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN);
1098 if (output == Ecore_X_Randr_None)
1099 return ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN;
1101 if (_randr_version >= RANDR_1_3)
1102 return _ecore_xcb_randr_13_output_connection_status_get(root, output);
1103 else if (_randr_version == RANDR_1_2)
1104 return _ecore_xcb_randr_12_output_connection_status_get(root, output);
1107 return ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN;
1110 EAPI Ecore_X_Randr_Output *
1111 ecore_x_randr_outputs_get(Ecore_X_Window root,
1114 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1117 #ifdef ECORE_XCB_RANDR
1118 RANDR_CHECK_1_2_RET(NULL);
1120 if (_randr_version >= RANDR_1_3)
1121 return _ecore_xcb_randr_13_outputs_get(root, num);
1122 else if (_randr_version == RANDR_1_2)
1123 return _ecore_xcb_randr_12_outputs_get(root, num);
1129 EAPI Ecore_X_Randr_Crtc
1130 ecore_x_randr_output_crtc_get(Ecore_X_Window root,
1131 Ecore_X_Randr_Output output)
1133 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1136 #ifdef ECORE_XCB_RANDR
1137 RANDR_CHECK_1_2_RET(Ecore_X_Randr_None);
1139 if (output == Ecore_X_Randr_None) return Ecore_X_Randr_None;
1141 if (_randr_version >= RANDR_1_3)
1142 return _ecore_xcb_randr_13_output_crtc_get(root, output);
1143 else if (_randr_version == RANDR_1_2)
1144 return _ecore_xcb_randr_12_output_crtc_get(root, output);
1147 return Ecore_X_Randr_None;
1151 ecore_x_randr_output_size_mm_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *w_mm, int *h_mm)
1153 #ifdef ECORE_XCB_RANDR
1154 xcb_randr_get_output_info_cookie_t ocookie;
1155 xcb_randr_get_output_info_reply_t *oreply;
1156 xcb_timestamp_t timestamp = 0;
1159 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1162 if (w_mm) *w_mm = 0;
1163 if (h_mm) *h_mm = 0;
1165 #ifdef ECORE_XCB_RANDR
1166 RANDR_CHECK_1_2_RET();
1168 if ((output != Ecore_X_Randr_None) && (_randr_version >= RANDR_1_3))
1170 xcb_randr_get_screen_resources_current_reply_t *reply;
1172 reply = _ecore_xcb_randr_13_get_resources(root);
1173 timestamp = reply->config_timestamp;
1176 else if ((output != Ecore_X_Randr_None) && (_randr_version == RANDR_1_2))
1178 xcb_randr_get_screen_resources_reply_t *reply;
1180 reply = _ecore_xcb_randr_12_get_resources(root);
1181 timestamp = reply->config_timestamp;
1186 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output, timestamp);
1187 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn, ocookie, NULL);
1190 if (w_mm) *w_mm = oreply->mm_width;
1191 if (h_mm) *h_mm = oreply->mm_height;
1198 * @brief Sets the demanded parameters for a given CRTC. Note that the CRTC is
1199 * auto enabled in it's preferred mode, when it was disabled before.
1201 * @param root The root window which's default display will be queried.
1202 * @param crtc The CRTC which's configuration should be altered.
1203 * @param outputs An array of outputs, that should display this CRTC's content.
1204 * @param noutputs Number of outputs in the array of outputs. If set to
1205 * Ecore_X_Randr_Unset, current outputs and number of outputs will be used. If
1206 * set to Ecore_X_Randr_None, CRTC will be disabled.
1207 * @param x New x coordinate. If <0 (e.g. Ecore_X_Randr_Unset) the current x
1208 * coordinate will be assumed.
1209 * @param y New y coordinate. If <0 (e.g. Ecore_X_Randr_Unset) the current y
1210 * coordinate will be assumed.
1211 * @param mode The new mode to be set. If Ecore_X_Randr_None is passed, the
1212 * CRTC will be disabled. If Ecore_X_Randr_Unset is passed, the current mode is
1214 * @param orientation The new orientation to be set. If Ecore_X_Randr_Unset is
1215 * used, the current mode is assumed.
1216 * @return @c EINA_TRUE if the configuration alteration was successful,
1217 * @c EINA_FALSE otherwise.
1220 ecore_x_randr_crtc_settings_set(Ecore_X_Window root,
1221 Ecore_X_Randr_Crtc crtc,
1222 Ecore_X_Randr_Output *outputs,
1226 Ecore_X_Randr_Mode mode,
1227 Ecore_X_Randr_Orientation orientation)
1229 Eina_Bool ret = EINA_FALSE;
1230 #ifdef ECORE_XCB_RANDR
1231 xcb_timestamp_t stamp = 0;
1232 xcb_randr_get_crtc_info_cookie_t ccookie;
1233 xcb_randr_get_crtc_info_reply_t *creply;
1236 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1239 #ifdef ECORE_XCB_RANDR
1240 RANDR_CHECK_1_2_RET(EINA_FALSE);
1242 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret;
1244 if (_randr_version >= RANDR_1_3)
1245 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
1246 else if (_randr_version == RANDR_1_2)
1247 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
1250 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp);
1252 xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ccookie, NULL);
1255 xcb_randr_set_crtc_config_cookie_t scookie;
1256 xcb_randr_set_crtc_config_reply_t *sreply;
1258 if ((mode == Ecore_X_Randr_None) ||
1259 (noutputs == Ecore_X_Randr_None))
1264 else if (noutputs == (int)Ecore_X_Randr_Unset)
1266 outputs = xcb_randr_get_crtc_info_outputs(creply);
1267 noutputs = creply->num_outputs;
1269 if ((int)mode == Ecore_X_Randr_Unset) mode = creply->mode;
1270 if (x < 0) x = creply->x;
1271 if (y < 0) y = creply->y;
1272 if ((int)orientation == Ecore_X_Randr_Unset)
1273 orientation = creply->rotation;
1276 xcb_randr_set_crtc_config_unchecked(_ecore_xcb_conn,
1277 crtc, XCB_CURRENT_TIME, stamp,
1278 x, y, mode, orientation,
1281 xcb_randr_set_crtc_config_reply(_ecore_xcb_conn, scookie, NULL);
1284 ret = (sreply->status == XCB_RANDR_SET_CONFIG_SUCCESS) ?
1285 EINA_TRUE : EINA_FALSE;
1296 * @brief Sets a mode for a CRTC and the outputs attached to it.
1298 * @param root The window's screen to be queried
1299 * @param crtc The CRTC which shall be set
1300 * @param outputs Array of outputs which have to be compatible with the mode. If
1301 * @c NULL CRTC will be disabled.
1302 * @param noutputs Number of outputs in array to be used. Use
1303 * Ecore_X_Randr_Unset (or @c -1) to use currently used outputs.
1304 * @param mode XID of the mode to be set. If set to @c 0 the CRTC will be
1305 * disabled. If set to @c -1 the call will fail.
1306 * @return @c EINA_TRUE if mode setting was successful, @c EINA_FALSE
1310 ecore_x_randr_crtc_mode_set(Ecore_X_Window root,
1311 Ecore_X_Randr_Crtc crtc,
1312 Ecore_X_Randr_Output *outputs,
1314 Ecore_X_Randr_Mode mode)
1316 Eina_Bool ret = EINA_FALSE;
1318 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1321 #ifdef ECORE_XCB_RANDR
1322 RANDR_CHECK_1_2_RET(EINA_FALSE);
1324 if ((int)mode == Ecore_X_Randr_Unset) return ret;
1326 ecore_x_randr_crtc_settings_set(root, crtc, outputs, noutputs,
1327 Ecore_X_Randr_Unset, Ecore_X_Randr_Unset,
1328 mode, Ecore_X_Randr_Unset);
1335 * @brief Get the current set mode of a given CRTC
1336 * @param root the window's screen to be queried
1337 * @param crtc the CRTC which's should be queried
1338 * @return currently set mode or - in case parameters are invalid -
1339 * Ecore_X_Randr_Unset
1341 EAPI Ecore_X_Randr_Mode
1342 ecore_x_randr_crtc_mode_get(Ecore_X_Window root,
1343 Ecore_X_Randr_Crtc crtc)
1345 Ecore_X_Randr_Mode ret = Ecore_X_Randr_Unset;
1346 #ifdef ECORE_XCB_RANDR
1347 xcb_timestamp_t stamp = 0;
1348 xcb_randr_get_crtc_info_cookie_t ocookie;
1349 xcb_randr_get_crtc_info_reply_t *oreply;
1352 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1355 #ifdef ECORE_XCB_RANDR
1356 RANDR_CHECK_1_2_RET(Ecore_X_Randr_Unset);
1358 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret;
1360 if (_randr_version >= RANDR_1_3)
1361 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
1362 else if (_randr_version == RANDR_1_2)
1363 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
1366 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp);
1367 oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL);
1378 EAPI Ecore_X_Randr_Orientation
1379 ecore_x_randr_crtc_orientation_get(Ecore_X_Window root,
1380 Ecore_X_Randr_Crtc crtc)
1382 Ecore_X_Randr_Orientation ret = Ecore_X_Randr_None;
1383 #ifdef ECORE_XCB_RANDR
1384 xcb_timestamp_t stamp = 0;
1385 xcb_randr_get_crtc_info_cookie_t ocookie;
1386 xcb_randr_get_crtc_info_reply_t *oreply;
1389 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1392 #ifdef ECORE_XCB_RANDR
1393 RANDR_CHECK_1_2_RET(Ecore_X_Randr_None);
1395 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret;
1397 if (_randr_version >= RANDR_1_3)
1398 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
1399 else if (_randr_version == RANDR_1_2)
1400 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
1403 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp);
1404 oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL);
1407 ret = oreply->rotation;
1416 ecore_x_randr_crtc_orientation_set(Ecore_X_Window root,
1417 Ecore_X_Randr_Crtc crtc,
1418 Ecore_X_Randr_Orientation orientation)
1420 Eina_Bool ret = EINA_FALSE;
1422 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1425 #ifdef ECORE_XCB_RANDR
1426 RANDR_CHECK_1_2_RET(EINA_FALSE);
1428 if (orientation != Ecore_X_Randr_None)
1431 ecore_x_randr_crtc_settings_set(root, crtc, NULL,
1432 Ecore_X_Randr_Unset, Ecore_X_Randr_Unset,
1433 Ecore_X_Randr_Unset, Ecore_X_Randr_Unset,
1440 EAPI Ecore_X_Randr_Orientation
1441 ecore_x_randr_crtc_orientations_get(Ecore_X_Window root,
1442 Ecore_X_Randr_Crtc crtc)
1444 Ecore_X_Randr_Orientation ret = Ecore_X_Randr_None;
1445 #ifdef ECORE_XCB_RANDR
1446 xcb_timestamp_t stamp = 0;
1447 xcb_randr_get_crtc_info_cookie_t ocookie;
1448 xcb_randr_get_crtc_info_reply_t *oreply;
1451 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1454 #ifdef ECORE_XCB_RANDR
1455 RANDR_CHECK_1_2_RET(Ecore_X_Randr_None);
1457 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret;
1459 if (_randr_version >= RANDR_1_3)
1460 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
1461 else if (_randr_version == RANDR_1_2)
1462 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
1465 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp);
1467 xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL);
1470 ret = oreply->rotations;
1479 * @brief get a CRTC's possible outputs.
1480 * @param root the root window which's screen will be queried
1481 * @param num number of possible outputs referenced by given CRTC
1483 EAPI Ecore_X_Randr_Output *
1484 ecore_x_randr_crtc_possible_outputs_get(Ecore_X_Window root,
1485 Ecore_X_Randr_Crtc crtc,
1488 Ecore_X_Randr_Output *ret = NULL;
1489 #ifdef ECORE_XCB_RANDR
1490 xcb_timestamp_t stamp = 0;
1491 xcb_randr_get_crtc_info_cookie_t ocookie;
1492 xcb_randr_get_crtc_info_reply_t *oreply;
1495 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1498 #ifdef ECORE_XCB_RANDR
1499 RANDR_CHECK_1_2_RET(NULL);
1501 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret;
1503 if (_randr_version >= RANDR_1_3)
1504 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
1505 else if (_randr_version == RANDR_1_2)
1506 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
1509 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp);
1510 oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL);
1513 if (num) *num = oreply->num_possible_outputs;
1514 ret = malloc(sizeof(Ecore_X_Randr_Output) *
1515 oreply->num_possible_outputs);
1518 memcpy(ret, xcb_randr_get_crtc_info_possible(oreply),
1519 sizeof(Ecore_X_Randr_Output) *
1520 oreply->num_possible_outputs);
1530 * @brief get all known CRTCs related to a root window's screen
1531 * @param root window which's screen's ressources are queried
1532 * @param num number of CRTCs returned
1535 EAPI Ecore_X_Randr_Crtc *
1536 ecore_x_randr_crtcs_get(Ecore_X_Window root,
1539 Ecore_X_Randr_Crtc *ret = NULL;
1541 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1544 #ifdef ECORE_XCB_RANDR
1545 RANDR_CHECK_1_2_RET(NULL);
1547 if (_randr_version >= RANDR_1_3)
1549 xcb_randr_get_screen_resources_current_reply_t *reply;
1551 reply = _ecore_xcb_randr_13_get_resources(root);
1554 if (num) *num = reply->num_crtcs;
1555 ret = malloc(sizeof(Ecore_X_Randr_Crtc) * reply->num_crtcs);
1557 memcpy(ret, xcb_randr_get_screen_resources_current_crtcs(reply),
1558 sizeof(Ecore_X_Randr_Crtc) * reply->num_crtcs);
1562 else if (_randr_version == RANDR_1_2)
1564 xcb_randr_get_screen_resources_reply_t *reply;
1566 reply = _ecore_xcb_randr_12_get_resources(root);
1569 if (num) *num = reply->num_crtcs;
1570 ret = malloc(sizeof(Ecore_X_Randr_Crtc) * reply->num_crtcs);
1572 memcpy(ret, xcb_randr_get_screen_resources_crtcs(reply),
1573 sizeof(Ecore_X_Randr_Crtc) * reply->num_crtcs);
1583 * @deprecated bad naming. Use ecore_x_randr_window_crtcs_get instead.
1584 * @brief Get the CRTCs, which display a certain window.
1586 * @param window Window the displaying CRTCs shall be found for.
1587 * @param num The number of CRTCs displaying the window.
1588 * @return Array of CRTCs that display a certain window. @c NULL if no CRTCs
1589 * was found that displays the specified window.
1591 EAPI Ecore_X_Randr_Crtc *
1592 ecore_x_randr_current_crtc_get(Ecore_X_Window window,
1595 return ecore_x_randr_window_crtcs_get(window, num);
1599 * @brief Get the CRTCs, which display a certain window.
1601 * @param window Window the displaying crtcs shall be found for.
1602 * @param num The number of crtcs displaying the window.
1603 * @return Array of crtcs that display a certain window. @c NULL if no crtcs
1604 * was found that displays the specified window.
1607 EAPI Ecore_X_Randr_Crtc *
1608 ecore_x_randr_window_crtcs_get(Ecore_X_Window window,
1611 #ifdef ECORE_XCB_RANDR
1612 Ecore_X_Window root;
1613 Eina_Rectangle w_geo, c_geo;
1614 Ecore_X_Randr_Crtc *crtcs, *ret = NULL;
1615 Ecore_X_Randr_Mode mode;
1616 int ncrtcs, i, nret = 0;
1617 xcb_translate_coordinates_cookie_t cookie;
1618 xcb_translate_coordinates_reply_t *trans;
1621 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1624 #ifdef ECORE_XCB_RANDR
1625 RANDR_CHECK_1_2_RET(NULL);
1627 ecore_x_window_geometry_get(window, &w_geo.x, &w_geo.y, &w_geo.w, &w_geo.h);
1629 root = ecore_x_window_root_get(window);
1630 crtcs = ecore_x_randr_crtcs_get(root, &ncrtcs);
1631 if (!crtcs) goto _ecore_x_randr_window_crtcs_get_fail;
1633 /* now get window RELATIVE to root window - thats what matters. */
1634 cookie = xcb_translate_coordinates(_ecore_xcb_conn, window, root, 0, 0);
1635 trans = xcb_translate_coordinates_reply(_ecore_xcb_conn, cookie, NULL);
1636 w_geo.x = trans->dst_x;
1637 w_geo.y = trans->dst_y;
1640 ret = calloc(1, ncrtcs * sizeof(Ecore_X_Randr_Crtc));
1644 goto _ecore_x_randr_window_crtcs_get_fail;
1646 for (i = 0, nret = 0; i < ncrtcs; i++)
1648 /* if crtc is not enabled, don't bother about it any further */
1649 mode = ecore_x_randr_crtc_mode_get(root, crtcs[i]);
1650 if (mode == Ecore_X_Randr_None) continue;
1652 ecore_x_randr_crtc_geometry_get(root, crtcs[i], &c_geo.x, &c_geo.y,
1653 &c_geo.w, &c_geo.h);
1654 if (eina_rectangles_intersect(&w_geo, &c_geo))
1656 ret[nret] = crtcs[i];
1662 if (num) *num = nret;
1665 _ecore_x_randr_window_crtcs_get_fail:
1672 * @brief get a CRTC's outputs.
1673 * @param root the root window which's screen will be queried
1674 * @param num number of outputs referenced by given CRTC
1676 EAPI Ecore_X_Randr_Output *
1677 ecore_x_randr_crtc_outputs_get(Ecore_X_Window root,
1678 Ecore_X_Randr_Crtc crtc,
1681 Ecore_X_Randr_Output *ret = NULL;
1682 #ifdef ECORE_XCB_RANDR
1683 xcb_timestamp_t stamp = 0;
1684 xcb_randr_get_crtc_info_cookie_t ocookie;
1685 xcb_randr_get_crtc_info_reply_t *oreply;
1688 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1691 #ifdef ECORE_XCB_RANDR
1692 RANDR_CHECK_1_2_RET(NULL);
1694 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret;
1696 if (_randr_version >= RANDR_1_3)
1697 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
1698 else if (_randr_version == RANDR_1_2)
1699 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
1702 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp);
1703 oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL);
1706 if (num) *num = oreply->num_outputs;
1707 ret = malloc(sizeof(Ecore_X_Randr_Output) * oreply->num_outputs);
1709 memcpy(ret, xcb_randr_get_crtc_info_outputs(oreply),
1710 sizeof(Ecore_X_Randr_Output) * oreply->num_outputs);
1719 ecore_x_randr_crtc_geometry_get(Ecore_X_Window root,
1720 Ecore_X_Randr_Crtc crtc,
1726 #ifdef ECORE_XCB_RANDR
1727 xcb_timestamp_t stamp = 0;
1728 xcb_randr_get_crtc_info_cookie_t ocookie;
1729 xcb_randr_get_crtc_info_reply_t *oreply;
1732 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1735 #ifdef ECORE_XCB_RANDR
1736 RANDR_CHECK_1_2_RET();
1738 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return;
1740 if (_randr_version >= RANDR_1_3)
1741 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
1742 else if (_randr_version == RANDR_1_2)
1743 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
1746 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp);
1747 oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL);
1750 if (x) *x = oreply->x;
1751 if (y) *y = oreply->y;
1752 if (w) *w = oreply->width;
1753 if (h) *h = oreply->height;
1760 * @brief Sets a CRTC relative to another one.
1762 * @param root The window on which CRTC's position will be set.
1763 * @param crtc_r1 The CRTC to be positioned.
1764 * @param crtc_r2 The CRTC the position should be relative to.
1765 * @param policy The relation between the crtcs.
1766 * @param alignment In case CRTCs size differ, aligns CRTC1 accordingly at
1768 * @return @c EINA_TRUE if crtc could be successfully positioned, @c EINA_FALSE
1769 * if repositioning failed or if position of new crtc would be out of given
1770 * screen's min/max bounds.
1773 ecore_x_randr_crtc_pos_relative_set(Ecore_X_Window root,
1774 Ecore_X_Randr_Crtc crtc_r1,
1775 Ecore_X_Randr_Crtc crtc_r2,
1776 Ecore_X_Randr_Output_Policy policy,
1777 Ecore_X_Randr_Relative_Alignment alignment)
1779 #ifdef ECORE_XCB_RANDR
1780 Eina_Rectangle r1, r2;
1781 int w_max = 0, h_max = 0, cw = 0, ch = 0, xn = -1, yn = -1;
1784 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1787 #ifdef ECORE_XCB_RANDR
1788 RANDR_CHECK_1_2_RET(EINA_FALSE);
1790 if ((ecore_x_randr_crtc_mode_get(root, crtc_r1) == 0) ||
1791 (ecore_x_randr_crtc_mode_get(root, crtc_r2) == 0))
1794 if ((!_ecore_xcb_randr_crtc_validate(root, crtc_r1) ||
1795 (!(crtc_r1 != crtc_r2) && (!_ecore_xcb_randr_crtc_validate(root, crtc_r2)))))
1798 ecore_x_randr_crtc_geometry_get(root, crtc_r1, &r1.x, &r1.y, &r1.w, &r1.h);
1799 ecore_x_randr_crtc_geometry_get(root, crtc_r2, &r2.x, &r2.y, &r2.w, &r2.h);
1800 ecore_x_randr_screen_size_range_get(root, NULL, NULL, &w_max, &h_max);
1801 ecore_x_randr_screen_current_size_get(root, &cw, &ch, NULL, NULL);
1805 case ECORE_X_RANDR_OUTPUT_POLICY_RIGHT:
1807 if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_NONE)
1809 else if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_REL)
1810 yn = ((int)(((double)r2.h / 2.0) + (double)r2.y - ((double)r1.h / 2.0)));
1811 else if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_SCR)
1812 yn = ((int)((double)ch / 2.0) - ((double)r1.h / 2.0));
1815 case ECORE_X_RANDR_OUTPUT_POLICY_LEFT:
1817 if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_NONE)
1819 else if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_REL)
1820 yn = ((int)(((double)r2.h / 2.0) + (double)r2.y - ((double)r1.h / 2.0)));
1821 else if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_SCR)
1822 yn = ((int)((double)ch / 2.0) - ((double)r1.h / 2.0));
1825 case ECORE_X_RANDR_OUTPUT_POLICY_BELOW:
1827 if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_NONE)
1829 else if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_REL)
1830 xn = ((int)((((double)r2.x + (double)r2.w) / 2.0) - ((double)r1.w / 2.0)));
1831 else if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_SCR)
1832 xn = ((int)((double)cw / 2.0));
1835 case ECORE_X_RANDR_OUTPUT_POLICY_ABOVE:
1837 if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_NONE)
1839 else if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_REL)
1840 xn = ((int)((((double)r2.x + (double)r2.w) / 2.0) - ((double)r1.w / 2.0)));
1841 else if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_SCR)
1842 xn = ((int)((double)cw / 2.0));
1845 case ECORE_X_RANDR_OUTPUT_POLICY_CLONE:
1846 return ecore_x_randr_crtc_pos_set(root, crtc_r1, r2.x, r2.y);
1849 case ECORE_X_RANDR_OUTPUT_POLICY_NONE:
1853 if ((xn == r1.x) && (yn == r1.x)) return EINA_TRUE;
1854 if (((yn + r1.h) > h_max) || ((xn + r1.w) > w_max))
1857 return ecore_x_randr_crtc_pos_set(root, crtc_r1, xn, yn);
1864 ecore_x_randr_move_all_crtcs_but(Ecore_X_Window root,
1865 const Ecore_X_Randr_Crtc *not_moved,
1870 Eina_Bool ret = EINA_FALSE;
1871 #ifdef ECORE_XCB_RANDR
1872 Ecore_X_Randr_Crtc *crtcs = NULL, *move = NULL;
1873 int i = 0, j = 0, k = 0, n = 0, total = 0;
1876 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1879 #ifdef ECORE_XCB_RANDR
1880 if ((num <= 0) || (!not_moved) || (!_ecore_xcb_randr_root_validate(root)))
1883 crtcs = ecore_x_randr_crtcs_get(root, &total);
1885 move = malloc(sizeof(Ecore_X_Randr_Crtc) * n);
1888 for (i = 0, k = 0; (i < total) && (k < n); i++)
1890 for (j = 0; j < num; j++)
1891 if (crtcs[i] == not_moved[j]) break;
1893 move[k++] = crtcs[i];
1895 ret = ecore_x_randr_move_crtcs(root, move, n, dx, dy);
1905 ecore_x_randr_crtc_pos_get(Ecore_X_Window root,
1906 Ecore_X_Randr_Crtc crtc,
1910 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1913 #ifdef ECORE_XCB_RANDR
1914 RANDR_CHECK_1_2_RET();
1916 ecore_x_randr_crtc_geometry_get(root, crtc, x, y, NULL, NULL);
1921 * @brief Sets the position of given CRTC within root window's screen.
1923 * @param root The window's screen to be queried.
1924 * @param crtc The CRTC which's position within the mentioned screen is to be
1926 * @param x Position on the x-axis (0 == left) of the screen. if x < 0 current
1927 * value will be kept.
1928 * @param y Position on the y-ayis (0 == top) of the screen. if y < 0, current
1929 * value will be kept.
1930 * @return @c EINA_TRUE if position could be successfully be altered.
1933 ecore_x_randr_crtc_pos_set(Ecore_X_Window root,
1934 Ecore_X_Randr_Crtc crtc,
1938 Eina_Bool ret = EINA_FALSE;
1939 #ifdef ECORE_XCB_RANDR
1940 int w = 0, h = 0, nw = 0, nh = 0;
1941 Eina_Rectangle rect;
1944 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1947 #ifdef ECORE_XCB_RANDR
1948 RANDR_CHECK_1_2_RET(EINA_FALSE);
1950 ecore_x_randr_crtc_geometry_get(root, crtc,
1951 &rect.x, &rect.y, &rect.w, &rect.h);
1952 ecore_x_randr_screen_current_size_get(root, &w, &h, NULL, NULL);
1953 if (x < 0) x = rect.x;
1954 if (y < 0) y = rect.y;
1955 if ((x + rect.w) > w)
1957 if ((y + rect.h) > h)
1960 if ((nw != 0) || (nh != 0))
1962 if (!ecore_x_randr_screen_current_size_set(root, nw, nh, 0, 0))
1966 ret = ecore_x_randr_crtc_settings_set(root, crtc, NULL, -1, x, y, -1, -1);
1973 ecore_x_randr_crtc_size_get(Ecore_X_Window root,
1974 Ecore_X_Randr_Crtc crtc,
1978 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1981 #ifdef ECORE_XCB_RANDR
1982 RANDR_CHECK_1_2_RET();
1983 ecore_x_randr_crtc_geometry_get(root, crtc, NULL, NULL, w, h);
1987 EAPI Ecore_X_Randr_Refresh_Rate
1988 ecore_x_randr_crtc_refresh_rate_get(Ecore_X_Window root,
1989 Ecore_X_Randr_Crtc crtc,
1990 Ecore_X_Randr_Mode mode)
1992 Ecore_X_Randr_Refresh_Rate ret = 0.0;
1994 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1997 #ifdef ECORE_XCB_RANDR
1998 RANDR_CHECK_1_2_RET(0.0);
2000 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return 0.0;
2002 if (_randr_version >= RANDR_1_3)
2004 xcb_randr_get_screen_resources_current_reply_t *reply;
2006 reply = _ecore_xcb_randr_13_get_resources(root);
2009 xcb_randr_mode_info_iterator_t miter;
2012 xcb_randr_get_screen_resources_current_modes_iterator(reply);
2015 xcb_randr_mode_info_t *minfo;
2018 if (minfo->id == mode)
2020 if ((minfo->htotal) && (minfo->vtotal))
2022 ret = ((double)minfo->dot_clock /
2023 ((double)minfo->htotal *
2024 (double)minfo->vtotal));
2028 xcb_randr_mode_info_next(&miter);
2033 else if (_randr_version == RANDR_1_2)
2035 xcb_randr_get_screen_resources_reply_t *reply;
2037 reply = _ecore_xcb_randr_12_get_resources(root);
2040 xcb_randr_mode_info_iterator_t miter;
2042 miter = xcb_randr_get_screen_resources_modes_iterator(reply);
2045 xcb_randr_mode_info_t *minfo;
2048 if (minfo->id == mode)
2050 if ((minfo->htotal) && (minfo->vtotal))
2052 ret = ((double)minfo->dot_clock /
2053 ((double)minfo->htotal *
2054 (double)minfo->vtotal));
2058 xcb_randr_mode_info_next(&miter);
2068 * @brief Move given CRTCs belonging to the given root window's screen dx/dy
2069 * pixels relative to their current position. The screen size will be
2070 * automatically adjusted if necessary and possible.
2072 * @param root Window which's screen's resources are used.
2073 * @param crtcs List of CRTCs to be moved.
2074 * @param ncrtc Number of CRTCs in array.
2075 * @param dx Amount of pixels the CRTCs should be moved in x direction.
2076 * @param dy Amount of pixels the CRTCs should be moved in y direction.
2077 * @return @c EINA_TRUE if all crtcs could be moved successfully.
2080 ecore_x_randr_move_crtcs(Ecore_X_Window root,
2081 const Ecore_X_Randr_Crtc *crtcs,
2086 Eina_Bool ret = EINA_TRUE;
2087 #ifdef ECORE_XCB_RANDR
2088 xcb_timestamp_t stamp = 0;
2089 xcb_randr_get_crtc_info_reply_t *oreply[num];
2090 int i = 0, cw = 0, ch = 0;
2091 int mw = 0, mh = 0, nw = 0, nh = 0;
2094 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2097 #ifdef ECORE_XCB_RANDR
2098 RANDR_CHECK_1_2_RET(EINA_FALSE);
2100 if (!_ecore_xcb_randr_root_validate(root)) return EINA_FALSE;
2102 if (_randr_version >= RANDR_1_3)
2103 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
2104 else if (_randr_version == RANDR_1_2)
2105 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
2107 ecore_x_randr_screen_size_range_get(root, NULL, NULL, &mw, &mh);
2108 ecore_x_randr_screen_current_size_get(root, &cw, &ch, NULL, NULL);
2112 for (i = 0; i < num; i++)
2114 xcb_randr_get_crtc_info_cookie_t ocookie;
2117 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtcs[i],
2119 oreply[i] = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn,
2123 if (((oreply[i]->x + dx) < 0) ||
2124 ((oreply[i]->y + dy) < 0) ||
2125 ((oreply[i]->x + oreply[i]->width + dx) > mw) ||
2126 ((oreply[i]->y + oreply[i]->height + dy) > mh))
2130 nw = MAX((int)(oreply[i]->x + oreply[i]->width + dx), nw);
2131 nh = MAX((int)(oreply[i]->y + oreply[i]->height + dy), nh);
2135 if ((nw > cw) || (nh > ch))
2137 if (!ecore_x_randr_screen_current_size_set(root, nw, nh, -1, -1))
2139 for (i = 0; i < num; i++)
2140 if (oreply[i]) free(oreply[i]);
2146 for (i = 0; ((i < num) && (oreply[i])); i++)
2148 if (!oreply[i]) continue;
2149 if (!ecore_x_randr_crtc_settings_set(root, crtcs[i], NULL, -1,
2150 (oreply[i]->x + dx),
2151 (oreply[i]->y + dy),
2153 oreply[i]->rotation))
2165 ecore_x_randr_crtc_settings_set(root, crtcs[i], NULL, -1,
2166 (oreply[i]->x - dx),
2167 (oreply[i]->y - dy),
2169 oreply[i]->rotation);
2173 for (i = 0; i < num; i++)
2174 if (oreply[i]) free(oreply[i]);
2181 * @brief enable event selection. This enables basic interaction with
2182 * output/crtc events and requires RRandR >= 1.2.
2183 * @param win select this window's properties for RandRR events
2184 * @param on enable/disable selecting
2187 ecore_x_randr_events_select(Ecore_X_Window win,
2190 #ifdef ECORE_XCB_RANDR
2194 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2197 #ifdef ECORE_XCB_RANDR
2200 mask = XCB_RANDR_NOTIFY_MASK_SCREEN_CHANGE;
2201 if (_randr_version >= ((1 << 16) | 2))
2203 mask |= (XCB_RANDR_NOTIFY_MASK_CRTC_CHANGE |
2204 XCB_RANDR_NOTIFY_MASK_OUTPUT_CHANGE |
2205 XCB_RANDR_NOTIFY_MASK_OUTPUT_PROPERTY);
2209 xcb_randr_select_input(_ecore_xcb_conn, win, mask);
2214 * @brief removes unused screen space. The most upper left CRTC is set to 0x0
2215 * and all other CRTCs dx,dy respectively.
2216 * @param root the window's screen which will be reset.
2219 ecore_x_randr_screen_reset(Ecore_X_Window root)
2221 #ifdef ECORE_XCB_RANDR
2222 xcb_timestamp_t stamp = 0;
2223 Ecore_X_Randr_Crtc *crtcs = NULL;
2224 int total = 0, i = 0, w = 0, h = 0;
2225 int dx = 100000, dy = 100000, num = 0;
2228 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2231 #ifdef ECORE_XCB_RANDR
2232 if (!_ecore_xcb_randr_root_validate(root)) return;
2233 crtcs = ecore_x_randr_crtcs_get(root, &total);
2235 if (_randr_version >= RANDR_1_3)
2236 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
2237 else if (_randr_version == RANDR_1_2)
2238 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
2240 /* I hate declaring variables inside code like this, but we need the
2241 * value of 'total' before we can */
2242 Ecore_X_Randr_Crtc enabled[total];
2244 for (i = 0; i < total; i++)
2246 xcb_randr_get_crtc_info_cookie_t ocookie;
2247 xcb_randr_get_crtc_info_reply_t *oreply;
2250 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtcs[i], stamp);
2251 oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn,
2253 if (!oreply) continue;
2254 if ((oreply->mode <= 0) || (oreply->num_outputs == 0))
2260 enabled[num++] = crtcs[i];
2261 if ((int)(oreply->x + oreply->width) > w)
2262 w = (oreply->x + oreply->width);
2263 if ((int)(oreply->y + oreply->height) > h)
2264 h = (oreply->y + oreply->height);
2266 if (oreply->x < dx) dx = oreply->x;
2267 if (oreply->y < dy) dy = oreply->y;
2273 if ((dx > 0) || (dy > 0))
2275 if (ecore_x_randr_move_crtcs(root, enabled, num, -dx, -dy))
2282 ecore_x_randr_screen_current_size_set(root, w, h, -1, -1);
2287 * @param root window which's screen will be queried
2288 * @param wmin minimum width the screen can be set to
2289 * @param hmin minimum height the screen can be set to
2290 * @param wmax maximum width the screen can be set to
2291 * @param hmax maximum height the screen can be set to
2294 ecore_x_randr_screen_size_range_get(Ecore_X_Window root,
2300 #ifdef ECORE_XCB_RANDR
2301 xcb_randr_get_screen_size_range_cookie_t cookie;
2302 xcb_randr_get_screen_size_range_reply_t *reply;
2305 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2308 #ifdef ECORE_XCB_RANDR
2309 RANDR_CHECK_1_2_RET();
2311 cookie = xcb_randr_get_screen_size_range_unchecked(_ecore_xcb_conn, root);
2312 reply = xcb_randr_get_screen_size_range_reply(_ecore_xcb_conn, cookie, NULL);
2315 if (minw) *minw = reply->min_width;
2316 if (minh) *minh = reply->min_height;
2317 if (maxw) *maxw = reply->max_width;
2318 if (maxh) *maxh = reply->max_height;
2325 * @param w width of screen in px
2326 * @param h height of screen in px
2329 ecore_x_randr_screen_current_size_get(Ecore_X_Window root,
2335 #ifdef ECORE_XCB_RANDR
2336 Ecore_X_Randr_Screen scr = 0;
2338 # define RANDR_VALIDATE_ROOT(screen, root) \
2339 ((screen == _ecore_xcb_randr_root_to_screen(root)) != -1)
2342 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2345 #ifdef ECORE_XCB_RANDR
2346 RANDR_CHECK_1_2_RET();
2348 if (!RANDR_VALIDATE_ROOT(scr, root)) return;
2350 s = ecore_x_screen_get(scr);
2351 if (w) *w = s->width_in_pixels;
2352 if (h) *h = s->height_in_pixels;
2353 if (w_mm) *w_mm = s->width_in_millimeters;
2354 if (h_mm) *h_mm = s->height_in_millimeters;
2359 * @param root Window which's screen's size should be set. If invalid (e.g.
2360 * @c NULL) no action is taken.
2361 * @param w Width in px the screen should be set to. If out of valid
2362 * boundaries, current value is assumed.
2363 * @param h Height in px the screen should be set to. If out of valid
2364 * boundaries, current value is assumed.
2365 * @param w_mm Width in mm the screen should be set to. If @c 0, current
2366 * aspect is assumed.
2367 * @param h_mm Height in mm the screen should be set to. If @c 0, current
2368 * aspect is assumed.
2369 * @return @c EINA_TRUE if request was successfully sent or screen is already
2370 * in requested size, @c EINA_FALSE if parameters are invalid.
2373 ecore_x_randr_screen_current_size_set(Ecore_X_Window root,
2379 Eina_Bool ret = EINA_TRUE;
2380 #ifdef ECORE_XCB_RANDR
2381 Ecore_X_Randr_Screen scr;
2382 int wc = 0, hc = 0, w_mm_c = 0, h_mm_c = 0;
2383 int mw = 0, mh = 0, xw = 0, xh = 0;
2384 # define RANDR_VALIDATE_ROOT(screen, root) \
2385 ((screen == _ecore_xcb_randr_root_to_screen(root)) != -1)
2388 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2391 #ifdef ECORE_XCB_RANDR
2392 RANDR_CHECK_1_2_RET(EINA_FALSE);
2394 if (!RANDR_VALIDATE_ROOT(scr, root)) return EINA_FALSE;
2395 ecore_x_randr_screen_current_size_get(root, &wc, &hc, &w_mm_c, &h_mm_c);
2396 if ((w == wc) && (h == hc) && (w_mm == w_mm_c) && (h_mm == h_mm_c))
2398 ecore_x_randr_screen_size_range_get(root, &mw, &mh, &xw, &xh);
2399 if (((w != 1) && ((w < mw) || (w > xw))) ||
2400 ((h != -1) && ((h < mh) || (h > xh)))) return EINA_FALSE;
2403 w = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_pixels;
2405 h = ((xcb_screen_t *)_ecore_xcb_screen)->height_in_pixels;
2407 /* NB: Hmmmm, xlib version divides w_mm by width ... that seems wrong */
2409 w_mm = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_millimeters;
2411 h_mm = ((xcb_screen_t *)_ecore_xcb_screen)->height_in_millimeters;
2413 xcb_randr_set_screen_size(_ecore_xcb_conn, root, w, h, w_mm, h_mm);
2420 * @deprecated bad naming. Use ecore_x_randr_window_outputs_get instead.
2421 * @brief Get the outputs, which display a certain window.
2423 * @param window Window the displaying outputs shall be found for.
2424 * @param num The number of outputs displaying the window.
2425 * @return Array of outputs that display a certain window. @c NULL if no
2426 * outputs was found that displays the specified window.
2429 Ecore_X_Randr_Output *
2430 ecore_x_randr_current_output_get(Ecore_X_Window window,
2433 return ecore_x_randr_window_outputs_get(window, num);
2437 * @brief Get the outputs, which display a certain window.
2439 * @param window Window the displaying outputs shall be found for.
2440 * @param num The number of outputs displaying the window.
2441 * @return Array of outputs that display a certain window. @c NULL if no
2442 * outputs was found that displays the specified window.
2444 EAPI Ecore_X_Randr_Output *
2445 ecore_x_randr_window_outputs_get(Ecore_X_Window window,
2448 #ifdef ECORE_XCB_RANDR
2449 Ecore_X_Window root;
2450 Ecore_X_Randr_Crtc *crtcs;
2451 Ecore_X_Randr_Output *outputs, *ret = NULL, *tret;
2452 int ncrtcs, noutputs, i, nret = 0;
2455 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2460 #ifdef ECORE_XCB_RANDR
2461 if (_randr_version < RANDR_1_2) goto _ecore_x_randr_current_output_get_fail;
2463 root = ecore_x_window_root_get(window);
2464 if (!(crtcs = ecore_x_randr_window_crtcs_get(window, &ncrtcs)))
2465 goto _ecore_x_randr_current_output_get_fail;
2467 for (i = 0, nret = 0; i < ncrtcs; i++)
2470 outputs = ecore_x_randr_crtc_outputs_get(root, crtcs[i],
2473 goto _ecore_x_randr_current_output_get_fail_free;
2474 tret = realloc(ret, ((nret + noutputs) * sizeof(Ecore_X_Randr_Output)));
2475 if (!tret) goto _ecore_x_randr_current_output_get_fail_free;
2477 memcpy(&ret[nret], outputs, (noutputs * sizeof(Ecore_X_Randr_Output)));
2489 _ecore_x_randr_current_output_get_fail_free:
2493 _ecore_x_randr_current_output_get_fail:
2500 * @brief get the backlight level of the given output
2501 * @param root window which's screen should be queried
2502 * @param output from which the backlight level should be retrieved
2503 * @return the backlight level
2506 ecore_x_randr_output_backlight_level_get(Ecore_X_Window root,
2507 Ecore_X_Randr_Output output)
2509 #ifdef ECORE_XCB_RANDR
2510 Ecore_X_Atom _backlight;
2511 xcb_intern_atom_cookie_t acookie;
2512 xcb_intern_atom_reply_t *areply;
2513 xcb_randr_get_output_property_cookie_t cookie;
2514 xcb_randr_get_output_property_reply_t *reply;
2515 xcb_randr_query_output_property_cookie_t qcookie;
2516 xcb_randr_query_output_property_reply_t *qreply;
2518 long value, max, min;
2521 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2524 #ifdef ECORE_XCB_RANDR
2525 RANDR_CHECK_1_2_RET(-1);
2528 xcb_intern_atom_unchecked(_ecore_xcb_conn, 1,
2529 strlen("Backlight"), "Backlight");
2530 areply = xcb_intern_atom_reply(_ecore_xcb_conn, acookie, NULL);
2534 ERR("Backlight property is not suppported on this server or driver");
2539 _backlight = areply->atom;
2543 if (!_ecore_xcb_randr_output_validate(root, output))
2545 ERR("Invalid output");
2550 xcb_randr_get_output_property_unchecked(_ecore_xcb_conn,
2552 XCB_ATOM_NONE, 0, 4, 0, 0);
2554 xcb_randr_get_output_property_reply(_ecore_xcb_conn, cookie, NULL);
2557 WRN("Backlight not supported on this output");
2561 if ((reply->format != 32) || (reply->num_items != 1) ||
2562 (reply->type != XCB_ATOM_INTEGER))
2568 value = *((long *)xcb_randr_get_output_property_data(reply));
2571 /* I have the current value of the backlight */
2572 /* Now retrieve the min and max intensities of the output */
2574 xcb_randr_query_output_property_unchecked(_ecore_xcb_conn,
2575 output, _backlight);
2577 xcb_randr_query_output_property_reply(_ecore_xcb_conn, qcookie, NULL);
2581 if ((qreply->range) &&
2582 (xcb_randr_query_output_property_valid_values_length(qreply) == 2))
2586 vals = xcb_randr_query_output_property_valid_values(qreply);
2587 /* finally convert the current value in the interval [0..1] */
2590 dvalue = ((double)(value - min)) / ((double)(max - min));
2600 * @brief Set the backlight level of a given output.
2602 * @param root Window which's screen should be queried.
2603 * @param output That should be set.
2604 * @param level For which the backlight should be set.
2605 * @return @c EINA_TRUE in case of success.
2608 ecore_x_randr_output_backlight_level_set(Ecore_X_Window root,
2609 Ecore_X_Randr_Output output,
2612 #ifdef ECORE_XCB_RANDR
2613 Ecore_X_Atom _backlight;
2614 xcb_intern_atom_cookie_t acookie;
2615 xcb_intern_atom_reply_t *areply;
2616 xcb_randr_query_output_property_cookie_t qcookie;
2617 xcb_randr_query_output_property_reply_t *qreply;
2620 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2623 #ifdef ECORE_XCB_RANDR
2624 RANDR_CHECK_1_2_RET(EINA_FALSE);
2626 if ((level < 0) || (level > 1))
2628 ERR("Backlight level should be between 0 and 1");
2632 if (!_ecore_xcb_randr_output_validate(root, output))
2634 ERR("Wrong output value");
2639 xcb_intern_atom_unchecked(_ecore_xcb_conn, 1,
2640 strlen("Backlight"), "Backlight");
2641 areply = xcb_intern_atom_reply(_ecore_xcb_conn, acookie, NULL);
2644 WRN("Backlight property is not suppported on this server or driver");
2649 _backlight = areply->atom;
2654 xcb_randr_query_output_property_unchecked(_ecore_xcb_conn,
2655 output, _backlight);
2657 xcb_randr_query_output_property_reply(_ecore_xcb_conn, qcookie, NULL);
2660 if ((qreply->range) && (qreply->length == 2))
2663 double min, max, tmp;
2666 vals = xcb_randr_query_output_property_valid_values(qreply);
2669 tmp = (level * (max - min)) + min;
2671 if (n > max) n = max;
2672 if (n < min) n = min;
2673 xcb_randr_change_output_property(_ecore_xcb_conn, output,
2674 _backlight, XCB_ATOM_INTEGER,
2675 32, XCB_PROP_MODE_REPLACE,
2676 1, (unsigned char *)&n);
2677 ecore_x_flush(); // needed
2688 * @brief Check if a backlight is available.
2690 * @return Whether a backlight is available.
2693 ecore_x_randr_output_backlight_available(void)
2695 #ifdef ECORE_XCB_RANDR
2696 Ecore_X_Atom _backlight;
2697 xcb_intern_atom_cookie_t acookie;
2698 xcb_intern_atom_reply_t *areply;
2701 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2704 #ifdef ECORE_XCB_RANDR
2705 RANDR_CHECK_1_2_RET(EINA_FALSE);
2708 xcb_intern_atom_unchecked(_ecore_xcb_conn, 1,
2709 strlen("Backlight"), "Backlight");
2710 areply = xcb_intern_atom_reply(_ecore_xcb_conn, acookie, NULL);
2714 ERR("Backlight property is not suppported on this server or driver");
2719 _backlight = areply->atom;
2728 ecore_x_randr_edid_version_get(unsigned char *edid, unsigned long edid_length)
2730 if ((edid_length > _ECORE_X_RANDR_EDID_OFFSET_VERSION_MINOR) &&
2731 (ecore_x_randr_edid_has_valid_header(edid, edid_length)))
2732 return (edid[_ECORE_X_RANDR_EDID_OFFSET_VERSION_MAJOR] << 8) |
2733 edid[_ECORE_X_RANDR_EDID_OFFSET_VERSION_MINOR];
2734 return ECORE_X_RANDR_EDID_UNKNOWN_VALUE;
2738 ecore_x_randr_edid_display_name_get(unsigned char *edid, unsigned long edid_length)
2740 unsigned char *block = NULL;
2743 version = ecore_x_randr_edid_version_get(edid, edid_length);
2744 if (version < ECORE_X_RANDR_EDID_VERSION_13) return NULL;
2746 _ECORE_X_RANDR_EDID_FOR_EACH_NON_PIXEL_DESCRIPTOR_BLOCK(edid, block)
2748 if (block[_ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_TYPE] == 0xfc)
2751 const char *edid_name;
2753 edid_name = (const char *)block +
2754 _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_CONTENT;
2756 malloc(sizeof(char) *
2757 _ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX);
2758 if (!name) return NULL;
2760 strncpy(name, edid_name,
2761 (_ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX - 1));
2762 name[_ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX] = 0;
2763 for (p = name; *p; p++)
2764 if ((*p < ' ') || (*p > '~')) *p = 0;
2773 ecore_x_randr_edid_has_valid_header(unsigned char *edid, unsigned long edid_length)
2775 const unsigned char header[] =
2777 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00
2780 if ((!edid) || (edid_length < 8)) return EINA_FALSE;
2781 if (!memcmp(edid, header, 8)) return EINA_TRUE;
2785 /* local functions */
2787 _ecore_xcb_randr_output_validate(Ecore_X_Window root,
2788 Ecore_X_Randr_Output output)
2790 Eina_Bool ret = EINA_FALSE;
2792 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2795 #ifdef ECORE_XCB_RANDR
2796 RANDR_CHECK_1_2_RET(EINA_FALSE);
2798 if ((output) && (_ecore_xcb_randr_root_validate(root)))
2800 if (_randr_version >= RANDR_1_3)
2802 xcb_randr_get_screen_resources_current_reply_t *reply;
2804 reply = _ecore_xcb_randr_13_get_resources(root);
2808 xcb_randr_output_t *outputs;
2811 xcb_randr_get_screen_resources_current_outputs_length(reply);
2813 xcb_randr_get_screen_resources_current_outputs(reply);
2814 for (i = 0; i < len; i++)
2816 if (outputs[i] == output)
2825 else if (_randr_version == RANDR_1_2)
2827 xcb_randr_get_screen_resources_reply_t *reply;
2829 reply = _ecore_xcb_randr_12_get_resources(root);
2833 xcb_randr_output_t *outputs;
2835 len = xcb_randr_get_screen_resources_outputs_length(reply);
2836 outputs = xcb_randr_get_screen_resources_outputs(reply);
2837 for (i = 0; i < len; i++)
2839 if (outputs[i] == output)
2854 * @brief Validates a CRTC for a given root window's screen.
2856 * @param root The window which's default display will be queried.
2857 * @param crtc The CRTC to be validated.
2858 * @return In case it is found @c EINA_TRUE will be returned, else
2859 * @c EINA_FALSE is returned.
2862 _ecore_xcb_randr_crtc_validate(Ecore_X_Window root,
2863 Ecore_X_Randr_Crtc crtc)
2865 Eina_Bool ret = EINA_FALSE;
2867 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2870 #ifdef ECORE_XCB_RANDR
2871 RANDR_CHECK_1_2_RET(EINA_FALSE);
2873 if (((int)crtc == Ecore_X_Randr_None) || ((int)crtc == Ecore_X_Randr_Unset))
2876 if ((crtc) && (_ecore_xcb_randr_root_validate(root)))
2878 if (_randr_version >= RANDR_1_3)
2880 xcb_randr_get_screen_resources_current_reply_t *reply;
2882 reply = _ecore_xcb_randr_13_get_resources(root);
2886 xcb_randr_crtc_t *crtcs;
2888 crtcs = xcb_randr_get_screen_resources_current_crtcs(reply);
2889 for (i = 0; i < reply->num_crtcs; i++)
2891 if (crtcs[i] == crtc)
2900 else if (_randr_version == RANDR_1_2)
2902 xcb_randr_get_screen_resources_reply_t *reply;
2904 reply = _ecore_xcb_randr_12_get_resources(root);
2908 xcb_randr_crtc_t *crtcs;
2910 crtcs = xcb_randr_get_screen_resources_crtcs(reply);
2911 for (i = 0; i < reply->num_crtcs; i++)
2913 if (crtcs[i] == crtc)
2928 static Ecore_X_Randr_Mode *
2929 _ecore_xcb_randr_12_output_modes_get(Ecore_X_Window root,
2930 Ecore_X_Randr_Output output,
2934 Ecore_X_Randr_Mode *modes = NULL;
2935 xcb_randr_get_screen_resources_reply_t *reply;
2937 reply = _ecore_xcb_randr_12_get_resources(root);
2940 xcb_randr_get_output_info_cookie_t ocookie;
2941 xcb_randr_get_output_info_reply_t *oreply;
2944 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
2945 reply->config_timestamp);
2946 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
2950 if (num) *num = oreply->num_modes;
2951 if (npreferred) *npreferred = oreply->num_preferred;
2953 modes = malloc(sizeof(Ecore_X_Randr_Mode) *
2957 xcb_randr_mode_t *rmodes;
2960 len = xcb_randr_get_output_info_modes_length(oreply);
2961 rmodes = xcb_randr_get_output_info_modes(oreply);
2962 memcpy(modes, rmodes, sizeof(Ecore_X_Randr_Mode) * len);
2972 static Ecore_X_Randr_Mode *
2973 _ecore_xcb_randr_13_output_modes_get(Ecore_X_Window root,
2974 Ecore_X_Randr_Output output,
2978 Ecore_X_Randr_Mode *modes = NULL;
2979 xcb_timestamp_t stamp = 0;
2980 xcb_randr_get_output_info_cookie_t ocookie;
2981 xcb_randr_get_output_info_reply_t *oreply;
2983 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
2986 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output, stamp);
2987 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn, ocookie, NULL);
2990 if (num) *num = oreply->num_modes;
2991 if (npreferred) *npreferred = oreply->num_preferred;
2993 modes = malloc(sizeof(Ecore_X_Randr_Mode) * oreply->num_modes);
2996 xcb_randr_mode_t *rmodes;
2999 len = xcb_randr_get_output_info_modes_length(oreply);
3000 rmodes = xcb_randr_get_output_info_modes(oreply);
3001 memcpy(modes, rmodes, sizeof(Ecore_X_Randr_Mode) * len);
3009 static Ecore_X_Randr_Mode_Info *
3010 _ecore_xcb_randr_12_mode_info_get(Ecore_X_Window root,
3011 Ecore_X_Randr_Mode mode)
3013 Ecore_X_Randr_Mode_Info *ret = NULL;
3014 xcb_randr_get_screen_resources_reply_t *reply;
3016 reply = _ecore_xcb_randr_12_get_resources(root);
3019 if ((ret = malloc(sizeof(Ecore_X_Randr_Mode_Info))))
3022 xcb_randr_mode_info_iterator_t miter;
3024 nbuf = xcb_randr_get_screen_resources_names(reply);
3025 miter = xcb_randr_get_screen_resources_modes_iterator(reply);
3028 xcb_randr_mode_info_t *minfo;
3031 nbuf += minfo->name_len;
3033 if (minfo->id == mode)
3035 ret->xid = minfo->id;
3036 ret->width = minfo->width;
3037 ret->height = minfo->height;
3038 ret->dotClock = minfo->dot_clock;
3039 ret->hSyncStart = minfo->hsync_start;
3040 ret->hSyncEnd = minfo->hsync_end;
3041 ret->hTotal = minfo->htotal;
3042 ret->vSyncStart = minfo->vsync_start;
3043 ret->vSyncEnd = minfo->vsync_end;
3044 ret->vTotal = minfo->vtotal;
3045 ret->modeFlags = minfo->mode_flags;
3048 ret->nameLength = minfo->name_len;
3049 if (ret->nameLength > 0)
3051 ret->name = malloc(ret->nameLength + 1);
3053 memcpy(ret->name, nbuf, ret->nameLength + 1);
3058 xcb_randr_mode_info_next(&miter);
3067 static Ecore_X_Randr_Mode_Info *
3068 _ecore_xcb_randr_13_mode_info_get(Ecore_X_Window root,
3069 Ecore_X_Randr_Mode mode)
3071 Ecore_X_Randr_Mode_Info *ret = NULL;
3072 xcb_randr_get_screen_resources_current_reply_t *reply;
3074 reply = _ecore_xcb_randr_13_get_resources(root);
3077 if ((ret = malloc(sizeof(Ecore_X_Randr_Mode_Info))))
3080 xcb_randr_mode_info_iterator_t miter;
3082 nbuf = xcb_randr_get_screen_resources_current_names(reply);
3084 xcb_randr_get_screen_resources_current_modes_iterator(reply);
3087 xcb_randr_mode_info_t *minfo;
3090 nbuf += minfo->name_len;
3092 if (minfo->id == mode)
3094 ret->xid = minfo->id;
3095 ret->width = minfo->width;
3096 ret->height = minfo->height;
3097 ret->dotClock = minfo->dot_clock;
3098 ret->hSyncStart = minfo->hsync_start;
3099 ret->hSyncEnd = minfo->hsync_end;
3100 ret->hTotal = minfo->htotal;
3101 ret->vSyncStart = minfo->vsync_start;
3102 ret->vSyncEnd = minfo->vsync_end;
3103 ret->vTotal = minfo->vtotal;
3104 ret->modeFlags = minfo->mode_flags;
3107 ret->nameLength = minfo->name_len;
3108 if (ret->nameLength > 0)
3110 ret->name = malloc(ret->nameLength + 1);
3112 memcpy(ret->name, nbuf, ret->nameLength + 1);
3117 xcb_randr_mode_info_next(&miter);
3126 static Ecore_X_Randr_Mode_Info **
3127 _ecore_xcb_randr_12_modes_info_get(Ecore_X_Window root,
3130 Ecore_X_Randr_Mode_Info **ret = NULL;
3131 xcb_randr_get_screen_resources_reply_t *reply;
3133 reply = _ecore_xcb_randr_12_get_resources(root);
3136 if (num) *num = reply->num_modes;
3137 ret = malloc(sizeof(Ecore_X_Randr_Mode_Info *) * reply->num_modes);
3140 xcb_randr_mode_info_iterator_t miter;
3144 nbuf = xcb_randr_get_screen_resources_names(reply);
3145 miter = xcb_randr_get_screen_resources_modes_iterator(reply);
3148 xcb_randr_mode_info_t *minfo;
3151 nbuf += minfo->name_len;
3152 if ((ret[i] = malloc(sizeof(Ecore_X_Randr_Mode_Info))))
3154 ret[i]->xid = minfo->id;
3155 ret[i]->width = minfo->width;
3156 ret[i]->height = minfo->height;
3157 ret[i]->dotClock = minfo->dot_clock;
3158 ret[i]->hSyncStart = minfo->hsync_start;
3159 ret[i]->hSyncEnd = minfo->hsync_end;
3160 ret[i]->hTotal = minfo->htotal;
3161 ret[i]->vSyncStart = minfo->vsync_start;
3162 ret[i]->vSyncEnd = minfo->vsync_end;
3163 ret[i]->vTotal = minfo->vtotal;
3164 ret[i]->modeFlags = minfo->mode_flags;
3166 ret[i]->name = NULL;
3167 ret[i]->nameLength = minfo->name_len;
3168 if (ret[i]->nameLength > 0)
3170 ret[i]->name = malloc(ret[i]->nameLength + 1);
3172 memcpy(ret[i]->name, nbuf,
3173 ret[i]->nameLength + 1);
3185 xcb_randr_mode_info_next(&miter);
3193 static Ecore_X_Randr_Mode_Info **
3194 _ecore_xcb_randr_13_modes_info_get(Ecore_X_Window root,
3197 Ecore_X_Randr_Mode_Info **ret = NULL;
3198 xcb_randr_get_screen_resources_current_reply_t *reply;
3200 reply = _ecore_xcb_randr_13_get_resources(root);
3203 if (num) *num = reply->num_modes;
3204 ret = malloc(sizeof(Ecore_X_Randr_Mode_Info *) * reply->num_modes);
3207 xcb_randr_mode_info_iterator_t miter;
3211 nbuf = xcb_randr_get_screen_resources_current_names(reply);
3213 xcb_randr_get_screen_resources_current_modes_iterator(reply);
3216 xcb_randr_mode_info_t *minfo;
3219 nbuf += minfo->name_len;
3220 if ((ret[i] = malloc(sizeof(Ecore_X_Randr_Mode_Info))))
3222 ret[i]->xid = minfo->id;
3223 ret[i]->width = minfo->width;
3224 ret[i]->height = minfo->height;
3225 ret[i]->dotClock = minfo->dot_clock;
3226 ret[i]->hSyncStart = minfo->hsync_start;
3227 ret[i]->hSyncEnd = minfo->hsync_end;
3228 ret[i]->hTotal = minfo->htotal;
3229 ret[i]->vSyncStart = minfo->vsync_start;
3230 ret[i]->vSyncEnd = minfo->vsync_end;
3231 ret[i]->vTotal = minfo->vtotal;
3232 ret[i]->modeFlags = minfo->mode_flags;
3234 ret[i]->name = NULL;
3235 ret[i]->nameLength = minfo->name_len;
3236 if (ret[i]->nameLength > 0)
3238 ret[i]->name = malloc(ret[i]->nameLength + 1);
3240 memcpy(ret[i]->name, nbuf,
3241 ret[i]->nameLength + 1);
3253 xcb_randr_mode_info_next(&miter);
3262 _ecore_xcb_randr_12_mode_size_get(Ecore_X_Window root,
3263 Ecore_X_Randr_Mode mode,
3267 xcb_randr_get_screen_resources_reply_t *reply;
3269 reply = _ecore_xcb_randr_12_get_resources(root);
3272 xcb_randr_mode_info_iterator_t miter;
3274 miter = xcb_randr_get_screen_resources_modes_iterator(reply);
3277 xcb_randr_mode_info_t *minfo;
3280 if (minfo->id == mode)
3282 if (w) *w = minfo->width;
3283 if (h) *h = minfo->height;
3286 xcb_randr_mode_info_next(&miter);
3293 _ecore_xcb_randr_13_mode_size_get(Ecore_X_Window root,
3294 Ecore_X_Randr_Mode mode,
3298 xcb_randr_get_screen_resources_current_reply_t *reply;
3300 reply = _ecore_xcb_randr_13_get_resources(root);
3303 xcb_randr_mode_info_iterator_t miter;
3305 miter = xcb_randr_get_screen_resources_current_modes_iterator(reply);
3308 xcb_randr_mode_info_t *minfo;
3311 if (minfo->id == mode)
3313 if (w) *w = minfo->width;
3314 if (h) *h = minfo->height;
3317 xcb_randr_mode_info_next(&miter);
3323 static Ecore_X_Randr_Output *
3324 _ecore_xcb_randr_12_output_clones_get(Ecore_X_Window root,
3325 Ecore_X_Randr_Output output,
3328 Ecore_X_Randr_Output *outputs = NULL;
3329 xcb_randr_get_screen_resources_reply_t *reply;
3331 reply = _ecore_xcb_randr_12_get_resources(root);
3334 xcb_randr_get_output_info_cookie_t ocookie;
3335 xcb_randr_get_output_info_reply_t *oreply;
3338 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
3339 reply->config_timestamp);
3340 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
3344 if (num) *num = oreply->num_clones;
3347 malloc(sizeof(Ecore_X_Randr_Output) * oreply->num_clones);
3350 memcpy(outputs, xcb_randr_get_output_info_clones(oreply),
3351 sizeof(Ecore_X_Randr_Output) * oreply->num_clones);
3360 static Ecore_X_Randr_Output *
3361 _ecore_xcb_randr_13_output_clones_get(Ecore_X_Window root,
3362 Ecore_X_Randr_Output output,
3365 Ecore_X_Randr_Output *outputs = NULL;
3366 xcb_randr_get_screen_resources_current_reply_t *reply;
3368 reply = _ecore_xcb_randr_13_get_resources(root);
3371 xcb_randr_get_output_info_cookie_t ocookie;
3372 xcb_randr_get_output_info_reply_t *oreply;
3375 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
3376 reply->config_timestamp);
3377 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
3381 if (num) *num = oreply->num_clones;
3384 malloc(sizeof(Ecore_X_Randr_Output) * oreply->num_clones);
3387 memcpy(outputs, xcb_randr_get_output_info_clones(oreply),
3388 sizeof(Ecore_X_Randr_Output) * oreply->num_clones);
3397 static Ecore_X_Randr_Crtc *
3398 _ecore_xcb_randr_12_output_possible_crtcs_get(Ecore_X_Window root,
3399 Ecore_X_Randr_Output output,
3402 Ecore_X_Randr_Crtc *crtcs = NULL;
3403 xcb_randr_get_screen_resources_reply_t *reply;
3405 reply = _ecore_xcb_randr_12_get_resources(root);
3408 xcb_randr_get_output_info_cookie_t ocookie;
3409 xcb_randr_get_output_info_reply_t *oreply;
3412 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
3413 reply->config_timestamp);
3414 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
3418 if (num) *num = oreply->num_crtcs;
3420 crtcs = malloc(sizeof(Ecore_X_Randr_Crtc) * oreply->num_crtcs);
3423 memcpy(crtcs, xcb_randr_get_output_info_crtcs(oreply),
3424 sizeof(Ecore_X_Randr_Crtc) * oreply->num_crtcs);
3433 static Ecore_X_Randr_Crtc *
3434 _ecore_xcb_randr_13_output_possible_crtcs_get(Ecore_X_Window root,
3435 Ecore_X_Randr_Output output,
3438 Ecore_X_Randr_Crtc *crtcs = NULL;
3439 xcb_randr_get_screen_resources_current_reply_t *reply;
3441 reply = _ecore_xcb_randr_13_get_resources(root);
3444 xcb_randr_get_output_info_cookie_t ocookie;
3445 xcb_randr_get_output_info_reply_t *oreply;
3448 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
3449 reply->config_timestamp);
3450 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
3454 if (num) *num = oreply->num_crtcs;
3456 crtcs = malloc(sizeof(Ecore_X_Randr_Crtc) * oreply->num_crtcs);
3459 memcpy(crtcs, xcb_randr_get_output_info_crtcs(oreply),
3460 sizeof(Ecore_X_Randr_Crtc) * oreply->num_crtcs);
3470 _ecore_xcb_randr_12_output_name_get(Ecore_X_Window root,
3471 Ecore_X_Randr_Output output,
3475 xcb_randr_get_screen_resources_reply_t *reply;
3477 reply = _ecore_xcb_randr_12_get_resources(root);
3480 xcb_randr_get_output_info_cookie_t ocookie;
3481 xcb_randr_get_output_info_reply_t *oreply;
3484 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
3485 reply->config_timestamp);
3486 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
3492 nbuf = xcb_randr_get_output_info_name(oreply);
3493 nbuf += oreply->name_len;
3495 if (len) *len = oreply->name_len;
3496 if (oreply->name_len > 0)
3498 ret = malloc(oreply->name_len + 1);
3500 memcpy(ret, nbuf, oreply->name_len + 1);
3511 _ecore_xcb_randr_13_output_name_get(Ecore_X_Window root,
3512 Ecore_X_Randr_Output output,
3516 xcb_randr_get_screen_resources_current_reply_t *reply;
3518 reply = _ecore_xcb_randr_13_get_resources(root);
3521 xcb_randr_get_output_info_cookie_t ocookie;
3522 xcb_randr_get_output_info_reply_t *oreply;
3525 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
3526 reply->config_timestamp);
3527 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
3533 nbuf = xcb_randr_get_output_info_name(oreply);
3534 nbuf += oreply->name_len;
3536 if (len) *len = oreply->name_len;
3537 if (oreply->name_len > 0)
3539 ret = malloc(oreply->name_len + 1);
3541 memcpy(ret, nbuf, oreply->name_len + 1);
3551 static Ecore_X_Randr_Connection_Status
3552 _ecore_xcb_randr_12_output_connection_status_get(Ecore_X_Window root,
3553 Ecore_X_Randr_Output output)
3555 Ecore_X_Randr_Connection_Status ret = ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN;
3556 xcb_randr_get_screen_resources_reply_t *reply;
3558 reply = _ecore_xcb_randr_12_get_resources(root);
3561 xcb_randr_get_output_info_cookie_t ocookie;
3562 xcb_randr_get_output_info_reply_t *oreply;
3565 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
3566 reply->config_timestamp);
3567 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
3571 ret = oreply->connection;
3579 static Ecore_X_Randr_Connection_Status
3580 _ecore_xcb_randr_13_output_connection_status_get(Ecore_X_Window root,
3581 Ecore_X_Randr_Output output)
3583 Ecore_X_Randr_Connection_Status ret = ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN;
3584 xcb_randr_get_screen_resources_current_reply_t *reply;
3586 reply = _ecore_xcb_randr_13_get_resources(root);
3589 xcb_randr_get_output_info_cookie_t ocookie;
3590 xcb_randr_get_output_info_reply_t *oreply;
3593 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
3594 reply->config_timestamp);
3595 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
3599 ret = oreply->connection;
3607 static Ecore_X_Randr_Output *
3608 _ecore_xcb_randr_12_outputs_get(Ecore_X_Window root,
3611 Ecore_X_Randr_Output *ret = NULL;
3612 xcb_randr_get_screen_resources_reply_t *reply;
3614 reply = _ecore_xcb_randr_12_get_resources(root);
3617 if (num) *num = reply->num_outputs;
3618 ret = malloc(sizeof(Ecore_X_Randr_Output) * reply->num_outputs);
3620 memcpy(ret, xcb_randr_get_screen_resources_outputs(reply),
3621 sizeof(Ecore_X_Randr_Output) * reply->num_outputs);
3627 static Ecore_X_Randr_Output *
3628 _ecore_xcb_randr_13_outputs_get(Ecore_X_Window root,
3631 Ecore_X_Randr_Output *ret = NULL;
3632 xcb_randr_get_screen_resources_current_reply_t *reply;
3634 reply = _ecore_xcb_randr_13_get_resources(root);
3637 if (num) *num = reply->num_outputs;
3638 ret = malloc(sizeof(Ecore_X_Randr_Output) * reply->num_outputs);
3640 memcpy(ret, xcb_randr_get_screen_resources_current_outputs(reply),
3641 sizeof(Ecore_X_Randr_Output) * reply->num_outputs);
3647 static Ecore_X_Randr_Crtc
3648 _ecore_xcb_randr_12_output_crtc_get(Ecore_X_Window root,
3649 Ecore_X_Randr_Output output)
3651 Ecore_X_Randr_Crtc ret = Ecore_X_Randr_None;
3652 xcb_randr_get_screen_resources_reply_t *reply;
3654 reply = _ecore_xcb_randr_12_get_resources(root);
3657 xcb_randr_get_output_info_cookie_t ocookie;
3658 xcb_randr_get_output_info_reply_t *oreply;
3661 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
3662 reply->config_timestamp);
3663 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
3675 static Ecore_X_Randr_Crtc
3676 _ecore_xcb_randr_13_output_crtc_get(Ecore_X_Window root,
3677 Ecore_X_Randr_Output output)
3679 Ecore_X_Randr_Crtc ret = Ecore_X_Randr_None;
3680 xcb_randr_get_screen_resources_current_reply_t *reply;
3682 reply = _ecore_xcb_randr_13_get_resources(root);
3685 xcb_randr_get_output_info_cookie_t ocookie;
3686 xcb_randr_get_output_info_reply_t *oreply;
3689 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
3690 reply->config_timestamp);
3691 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
3703 static xcb_randr_get_screen_resources_reply_t *
3704 _ecore_xcb_randr_12_get_resources(Ecore_X_Window win)
3706 xcb_randr_get_screen_resources_cookie_t cookie;
3707 xcb_randr_get_screen_resources_reply_t *reply;
3709 cookie = xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, win);
3710 reply = xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL);
3714 static xcb_randr_get_screen_resources_current_reply_t *
3715 _ecore_xcb_randr_13_get_resources(Ecore_X_Window win)
3717 xcb_randr_get_screen_resources_current_cookie_t cookie;
3718 xcb_randr_get_screen_resources_current_reply_t *reply;
3721 xcb_randr_get_screen_resources_current_unchecked(_ecore_xcb_conn, win);
3723 xcb_randr_get_screen_resources_current_reply(_ecore_xcb_conn,
3728 static xcb_timestamp_t
3729 _ecore_xcb_randr_12_get_resource_timestamp(Ecore_X_Window win)
3731 xcb_timestamp_t stamp = 0;
3732 xcb_randr_get_screen_resources_reply_t *reply;
3734 reply = _ecore_xcb_randr_12_get_resources(win);
3735 stamp = reply->config_timestamp;
3740 static xcb_timestamp_t
3741 _ecore_xcb_randr_13_get_resource_timestamp(Ecore_X_Window win)
3743 xcb_timestamp_t stamp = 0;
3744 xcb_randr_get_screen_resources_current_reply_t *reply;
3746 reply = _ecore_xcb_randr_13_get_resources(win);
3747 stamp = reply->config_timestamp;