summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Michael <cpmichael1@comcast.net>2011-10-04 21:47:49 +0000
committerChristopher Michael <cpmichael1@comcast.net>2011-10-04 21:47:49 +0000
commited291bafe103b600b04134eb0deb8cb9fc27fe3c (patch)
treeead3917f8ee428160885fda6a7fe41ab1394654b
parente708e12fa93e86102b68da86feafc23f2e728cf1 (diff)
Ecore_X(cb): Fix randr code to work with randr 12 or 13.
NB: This fixes the slow startup times that some people have reported when using certain drivers (intel, nouveau, etc). SVN revision: 63812
Diffstat (limited to '')
-rw-r--r--legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_randr.c2222
1 files changed, 1359 insertions, 863 deletions
diff --git a/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_randr.c b/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_randr.c
index e00a8ac7c4..9dd911cefa 100644
--- a/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_randr.c
+++ b/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_randr.c
@@ -47,11 +47,44 @@
47#define Ecore_X_Randr_None 0 47#define Ecore_X_Randr_None 0
48#define Ecore_X_Randr_Unset -1 48#define Ecore_X_Randr_Unset -1
49 49
50#define RANDR_1_1 ((1 << 16) | 1)
51#define RANDR_1_2 ((1 << 16) | 2)
52#define RANDR_1_3 ((1 << 16) | 3)
53
54#define RANDR_CHECK_1_1_RET(ret) if (_randr_version < RANDR_1_1) return ret
55#define RANDR_CHECK_1_2_RET(ret) if (_randr_version < RANDR_1_2) return ret
56#define RANDR_CHECK_1_3_RET(ret) if (_randr_version < RANDR_1_3) return ret
57
50/* local function prototypes */ 58/* local function prototypes */
51static Eina_Bool _ecore_xcb_randr_output_validate(Ecore_X_Window root, Ecore_X_Randr_Output output); 59static Eina_Bool _ecore_xcb_randr_output_validate(Ecore_X_Window root, Ecore_X_Randr_Output output);
52static Eina_Bool _ecore_xcb_randr_crtc_validate(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc); 60static Eina_Bool _ecore_xcb_randr_crtc_validate(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc);
53static Eina_Bool _ecore_xcb_randr_root_validate(Ecore_X_Window root); 61static Eina_Bool _ecore_xcb_randr_root_validate(Ecore_X_Window root);
54static int _ecore_xcb_randr_root_to_screen(Ecore_X_Window root); 62static int _ecore_xcb_randr_root_to_screen(Ecore_X_Window root);
63static xcb_randr_get_screen_resources_reply_t *_ecore_xcb_randr_12_get_resources(Ecore_X_Window win);
64static xcb_randr_get_screen_resources_current_reply_t *_ecore_xcb_randr_13_get_resources(Ecore_X_Window win);
65static xcb_timestamp_t _ecore_xcb_randr_12_get_resource_timestamp(Ecore_X_Window win);
66static xcb_timestamp_t _ecore_xcb_randr_13_get_resource_timestamp(Ecore_X_Window win);
67
68static Ecore_X_Randr_Mode *_ecore_xcb_randr_12_output_modes_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *num, int *npreferred);
69static Ecore_X_Randr_Mode *_ecore_xcb_randr_13_output_modes_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *num, int *npreferred);
70static Ecore_X_Randr_Mode_Info *_ecore_xcb_randr_12_mode_info_get(Ecore_X_Window root, Ecore_X_Randr_Mode mode);
71static Ecore_X_Randr_Mode_Info *_ecore_xcb_randr_13_mode_info_get(Ecore_X_Window root, Ecore_X_Randr_Mode mode);
72static Ecore_X_Randr_Mode_Info **_ecore_xcb_randr_12_modes_info_get(Ecore_X_Window root, int *num);
73static Ecore_X_Randr_Mode_Info **_ecore_xcb_randr_13_modes_info_get(Ecore_X_Window root, int *num);
74static void _ecore_xcb_randr_12_mode_size_get(Ecore_X_Window root, Ecore_X_Randr_Mode mode, int *w, int *h);
75static void _ecore_xcb_randr_13_mode_size_get(Ecore_X_Window root, Ecore_X_Randr_Mode mode, int *w, int *h);
76static Ecore_X_Randr_Output *_ecore_xcb_randr_12_output_clones_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *num);
77static Ecore_X_Randr_Output *_ecore_xcb_randr_13_output_clones_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *num);
78static Ecore_X_Randr_Crtc *_ecore_xcb_randr_12_output_possible_crtcs_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *num);
79static Ecore_X_Randr_Crtc *_ecore_xcb_randr_13_output_possible_crtcs_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *num);
80static char *_ecore_xcb_randr_12_output_name_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *len);
81static char *_ecore_xcb_randr_13_output_name_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *len);
82static Ecore_X_Randr_Connection_Status _ecore_xcb_randr_12_output_connection_status_get(Ecore_X_Window root, Ecore_X_Randr_Output output);
83static Ecore_X_Randr_Connection_Status _ecore_xcb_randr_13_output_connection_status_get(Ecore_X_Window root, Ecore_X_Randr_Output output);
84static Ecore_X_Randr_Output *_ecore_xcb_randr_12_outputs_get(Ecore_X_Window root, int *num);
85static Ecore_X_Randr_Output *_ecore_xcb_randr_13_outputs_get(Ecore_X_Window root, int *num);
86static Ecore_X_Randr_Crtc _ecore_xcb_randr_12_output_crtc_get(Ecore_X_Window root, Ecore_X_Randr_Output output);
87static Ecore_X_Randr_Crtc _ecore_xcb_randr_13_output_crtc_get(Ecore_X_Window root, Ecore_X_Randr_Output output);
55 88
56/* local variables */ 89/* local variables */
57static Eina_Bool _randr_avail = EINA_FALSE; 90static Eina_Bool _randr_avail = EINA_FALSE;
@@ -133,8 +166,6 @@ _ecore_xcb_randr_root_to_screen(Ecore_X_Window root)
133{ 166{
134 int count = 0, num = 0; 167 int count = 0, num = 0;
135 168
136 CHECK_XCB_CONN;
137
138 count = xcb_setup_roots_length(xcb_get_setup(_ecore_xcb_conn)); 169 count = xcb_setup_roots_length(xcb_get_setup(_ecore_xcb_conn));
139 for (num = 0; num < count; num++) 170 for (num = 0; num < count; num++)
140 if (_ecore_xcb_window_root_of_screen_get(num) == root) 171 if (_ecore_xcb_window_root_of_screen_get(num) == root)
@@ -179,9 +210,6 @@ ecore_x_randr_screen_primary_output_orientations_get(Ecore_X_Window root)
179#endif 210#endif
180 211
181 LOGFN(__FILE__, __LINE__, __FUNCTION__); 212 LOGFN(__FILE__, __LINE__, __FUNCTION__);
182 CHECK_XCB_CONN;
183
184 if (!_randr_avail) return Ecore_X_Randr_None;
185 213
186#ifdef ECORE_XCB_RANDR 214#ifdef ECORE_XCB_RANDR
187 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root); 215 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root);
@@ -210,9 +238,6 @@ ecore_x_randr_screen_primary_output_orientation_get(Ecore_X_Window root)
210#endif 238#endif
211 239
212 LOGFN(__FILE__, __LINE__, __FUNCTION__); 240 LOGFN(__FILE__, __LINE__, __FUNCTION__);
213 CHECK_XCB_CONN;
214
215 if (!_randr_avail) return Ecore_X_Randr_None;
216 241
217#ifdef ECORE_XCB_RANDR 242#ifdef ECORE_XCB_RANDR
218 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root); 243 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root);
@@ -243,9 +268,6 @@ ecore_x_randr_screen_primary_output_orientation_set(Ecore_X_Window root, Ecore_X
243#endif 268#endif
244 269
245 LOGFN(__FILE__, __LINE__, __FUNCTION__); 270 LOGFN(__FILE__, __LINE__, __FUNCTION__);
246 CHECK_XCB_CONN;
247
248 if (!_randr_avail) return EINA_FALSE;
249 271
250#ifdef ECORE_XCB_RANDR 272#ifdef ECORE_XCB_RANDR
251 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root); 273 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root);
@@ -294,9 +316,6 @@ ecore_x_randr_screen_primary_output_sizes_get(Ecore_X_Window root, int *num)
294#endif 316#endif
295 317
296 LOGFN(__FILE__, __LINE__, __FUNCTION__); 318 LOGFN(__FILE__, __LINE__, __FUNCTION__);
297 CHECK_XCB_CONN;
298
299 if (!_randr_avail) return NULL;
300 319
301#ifdef ECORE_XCB_RANDR 320#ifdef ECORE_XCB_RANDR
302 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root); 321 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root);
@@ -355,9 +374,6 @@ ecore_x_randr_screen_primary_output_current_size_get(Ecore_X_Window root, int *w
355#endif 374#endif
356 375
357 LOGFN(__FILE__, __LINE__, __FUNCTION__); 376 LOGFN(__FILE__, __LINE__, __FUNCTION__);
358 CHECK_XCB_CONN;
359
360 if (!_randr_avail) return;
361 377
362#ifdef ECORE_XCB_RANDR 378#ifdef ECORE_XCB_RANDR
363 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root); 379 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root);
@@ -405,9 +421,6 @@ ecore_x_randr_screen_primary_output_size_set(Ecore_X_Window root, int size_index
405#endif 421#endif
406 422
407 LOGFN(__FILE__, __LINE__, __FUNCTION__); 423 LOGFN(__FILE__, __LINE__, __FUNCTION__);
408 CHECK_XCB_CONN;
409
410 if (!_randr_avail) return EINA_FALSE;
411 424
412#ifdef ECORE_XCB_RANDR 425#ifdef ECORE_XCB_RANDR
413 if (!((size_index >= 0) && (_ecore_xcb_randr_root_validate(root)))) 426 if (!((size_index >= 0) && (_ecore_xcb_randr_root_validate(root))))
@@ -470,9 +483,6 @@ ecore_x_randr_screen_primary_output_current_refresh_rate_get(Ecore_X_Window root
470#endif 483#endif
471 484
472 LOGFN(__FILE__, __LINE__, __FUNCTION__); 485 LOGFN(__FILE__, __LINE__, __FUNCTION__);
473 CHECK_XCB_CONN;
474
475 if (!_randr_avail) return 0.0;
476 486
477#ifdef ECORE_XCB_RANDR 487#ifdef ECORE_XCB_RANDR
478 if (!_ecore_xcb_randr_root_validate(root)) return ret; 488 if (!_ecore_xcb_randr_root_validate(root)) return ret;
@@ -506,9 +516,6 @@ ecore_x_randr_screen_primary_output_refresh_rates_get(Ecore_X_Window root, int s
506#endif 516#endif
507 517
508 LOGFN(__FILE__, __LINE__, __FUNCTION__); 518 LOGFN(__FILE__, __LINE__, __FUNCTION__);
509 CHECK_XCB_CONN;
510
511 if (!_randr_avail) return NULL;
512 519
513#ifdef ECORE_XCB_RANDR 520#ifdef ECORE_XCB_RANDR
514 if (!_ecore_xcb_randr_root_validate(root)) return ret; 521 if (!_ecore_xcb_randr_root_validate(root)) return ret;
@@ -561,11 +568,10 @@ ecore_x_randr_screen_primary_output_refresh_rate_set(Ecore_X_Window root, int si
561#endif 568#endif
562 569
563 LOGFN(__FILE__, __LINE__, __FUNCTION__); 570 LOGFN(__FILE__, __LINE__, __FUNCTION__);
564 CHECK_XCB_CONN;
565
566 if (!_randr_avail) return EINA_FALSE;
567 571
568#ifdef ECORE_XCB_RANDR 572#ifdef ECORE_XCB_RANDR
573 if (_randr_version < RANDR_1_1) return EINA_FALSE;
574
569 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root); 575 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root);
570 reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL); 576 reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL);
571 if (reply) 577 if (reply)
@@ -607,6 +613,8 @@ ecore_x_randr_mode_info_free(Ecore_X_Randr_Mode_Info *mode_info)
607{ 613{
608 LOGFN(__FILE__, __LINE__, __FUNCTION__); 614 LOGFN(__FILE__, __LINE__, __FUNCTION__);
609 615
616 RANDR_CHECK_1_2_RET();
617
610 if (!mode_info) return; 618 if (!mode_info) return;
611 619
612 if (mode_info->name) free(mode_info->name); 620 if (mode_info->name) free(mode_info->name);
@@ -628,11 +636,10 @@ ecore_x_randr_primary_output_get(Ecore_X_Window root)
628#endif 636#endif
629 637
630 LOGFN(__FILE__, __LINE__, __FUNCTION__); 638 LOGFN(__FILE__, __LINE__, __FUNCTION__);
631 CHECK_XCB_CONN;
632
633 if (!_randr_avail) return Ecore_X_Randr_None;
634 639
635#ifdef ECORE_XCB_RANDR 640#ifdef ECORE_XCB_RANDR
641 RANDR_CHECK_1_3_RET(Ecore_X_Randr_None);
642
636 if (!_ecore_xcb_randr_root_validate(root)) 643 if (!_ecore_xcb_randr_root_validate(root))
637 return Ecore_X_Randr_None; 644 return Ecore_X_Randr_None;
638 645
@@ -655,11 +662,10 @@ EAPI void
655ecore_x_randr_primary_output_set(Ecore_X_Window root, Ecore_X_Randr_Output output) 662ecore_x_randr_primary_output_set(Ecore_X_Window root, Ecore_X_Randr_Output output)
656{ 663{
657 LOGFN(__FILE__, __LINE__, __FUNCTION__); 664 LOGFN(__FILE__, __LINE__, __FUNCTION__);
658 CHECK_XCB_CONN;
659
660 if (!_randr_avail) return;
661 665
662#ifdef ECORE_XCB_RANDR 666#ifdef ECORE_XCB_RANDR
667 RANDR_CHECK_1_3_RET();
668
663 if ((output) && (_ecore_xcb_randr_root_validate(root))) 669 if ((output) && (_ecore_xcb_randr_root_validate(root)))
664 xcb_randr_set_output_primary(_ecore_xcb_conn, root, output); 670 xcb_randr_set_output_primary(_ecore_xcb_conn, root, output);
665#endif 671#endif
@@ -669,47 +675,21 @@ EAPI Ecore_X_Randr_Mode *
669ecore_x_randr_output_modes_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *num, int *npreferred) 675ecore_x_randr_output_modes_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *num, int *npreferred)
670{ 676{
671 Ecore_X_Randr_Mode *modes = NULL; 677 Ecore_X_Randr_Mode *modes = NULL;
672#ifdef ECORE_XCB_RANDR
673 xcb_randr_get_screen_info_cookie_t cookie;
674 xcb_randr_get_screen_info_reply_t *reply;
675#endif
676 678
677 LOGFN(__FILE__, __LINE__, __FUNCTION__); 679 LOGFN(__FILE__, __LINE__, __FUNCTION__);
678 CHECK_XCB_CONN;
679
680 if (!_randr_avail) return NULL;
681 680
682#ifdef ECORE_XCB_RANDR 681#ifdef ECORE_XCB_RANDR
683 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root); 682 RANDR_CHECK_1_2_RET(NULL);
684 reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL);
685 if (reply)
686 {
687 xcb_randr_get_output_info_cookie_t ocookie;
688 xcb_randr_get_output_info_reply_t *oreply;
689
690 ocookie =
691 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
692 reply->config_timestamp);
693 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
694 ocookie, NULL);
695 if (oreply)
696 {
697 if (num) *num = oreply->num_modes;
698 if (npreferred) *npreferred = oreply->num_preferred;
699
700 modes = malloc(sizeof(Ecore_X_Randr_Mode) * oreply->num_modes);
701 if (modes)
702 {
703 xcb_randr_mode_t *rmodes;
704 int len = 0;
705 683
706 len = xcb_randr_get_output_info_modes_length(oreply); 684 if (_randr_version >= RANDR_1_3)
707 rmodes = xcb_randr_get_output_info_modes(oreply); 685 {
708 memcpy(modes, rmodes, sizeof(Ecore_X_Randr_Mode) * len); 686 modes =
709 } 687 _ecore_xcb_randr_13_output_modes_get(root, output, num, npreferred);
710 free(oreply); 688 }
711 } 689 else if (_randr_version == RANDR_1_2)
712 free(reply); 690 {
691 modes =
692 _ecore_xcb_randr_12_output_modes_get(root, output, num, npreferred);
713 } 693 }
714#endif 694#endif
715 695
@@ -726,68 +706,18 @@ EAPI Ecore_X_Randr_Mode_Info *
726ecore_x_randr_mode_info_get(Ecore_X_Window root, Ecore_X_Randr_Mode mode) 706ecore_x_randr_mode_info_get(Ecore_X_Window root, Ecore_X_Randr_Mode mode)
727{ 707{
728 Ecore_X_Randr_Mode_Info *ret = NULL; 708 Ecore_X_Randr_Mode_Info *ret = NULL;
729#ifdef ECORE_XCB_RANDR
730 xcb_randr_get_screen_resources_cookie_t cookie;
731 xcb_randr_get_screen_resources_reply_t *reply;
732#endif
733 709
734 LOGFN(__FILE__, __LINE__, __FUNCTION__); 710 LOGFN(__FILE__, __LINE__, __FUNCTION__);
735 CHECK_XCB_CONN;
736
737 if (!_randr_avail) return NULL;
738 711
739#ifdef ECORE_XCB_RANDR 712#ifdef ECORE_XCB_RANDR
740 if (!_ecore_xcb_randr_root_validate(root)) return NULL; 713 RANDR_CHECK_1_2_RET(NULL);
741
742 cookie = xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, root);
743 reply = xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL);
744 if (reply)
745 {
746 if ((ret = malloc(sizeof(Ecore_X_Randr_Mode_Info))))
747 {
748 uint8_t *nbuf;
749 xcb_randr_mode_info_iterator_t miter;
750
751 nbuf = xcb_randr_get_screen_resources_names(reply);
752 miter = xcb_randr_get_screen_resources_modes_iterator(reply);
753 while (miter.rem)
754 {
755 xcb_randr_mode_info_t *minfo;
756
757 minfo = miter.data;
758 nbuf += minfo->name_len;
759 714
760 if (minfo->id == mode) 715 if (!_ecore_xcb_randr_root_validate(root)) return NULL;
761 {
762 ret->xid = minfo->id;
763 ret->width = minfo->width;
764 ret->height = minfo->height;
765 ret->dotClock = minfo->dot_clock;
766 ret->hSyncStart = minfo->hsync_start;
767 ret->hSyncEnd = minfo->hsync_end;
768 ret->hTotal = minfo->htotal;
769 ret->vSyncStart = minfo->vsync_start;
770 ret->vSyncEnd = minfo->vsync_end;
771 ret->vTotal = minfo->vtotal;
772 ret->modeFlags = minfo->mode_flags;
773
774 ret->name = NULL;
775 ret->nameLength = minfo->name_len;
776 if (ret->nameLength > 0)
777 {
778 ret->name = malloc(ret->nameLength + 1);
779 if (ret->name)
780 memcpy(ret->name, nbuf, ret->nameLength + 1);
781 }
782
783 break;
784 }
785 xcb_randr_mode_info_next(&miter);
786 }
787 }
788 716
789 free(reply); 717 if (_randr_version >= RANDR_1_3)
790 } 718 ret = _ecore_xcb_randr_13_mode_info_get(root, mode);
719 else if (_randr_version == RANDR_1_2)
720 ret = _ecore_xcb_randr_12_mode_info_get(root, mode);
791#endif 721#endif
792 return ret; 722 return ret;
793} 723}
@@ -802,77 +732,20 @@ EAPI Ecore_X_Randr_Mode_Info **
802ecore_x_randr_modes_info_get(Ecore_X_Window root, int *num) 732ecore_x_randr_modes_info_get(Ecore_X_Window root, int *num)
803{ 733{
804 Ecore_X_Randr_Mode_Info **ret = NULL; 734 Ecore_X_Randr_Mode_Info **ret = NULL;
805#ifdef ECORE_XCB_RANDR
806 xcb_randr_get_screen_resources_cookie_t cookie;
807 xcb_randr_get_screen_resources_reply_t *reply;
808#endif
809 735
810 LOGFN(__FILE__, __LINE__, __FUNCTION__); 736 LOGFN(__FILE__, __LINE__, __FUNCTION__);
811 CHECK_XCB_CONN;
812 737
813 if (num) *num = 0; 738 if (num) *num = 0;
814 if (!_randr_avail) return NULL;
815 739
816#ifdef ECORE_XCB_RANDR 740#ifdef ECORE_XCB_RANDR
817 if (!_ecore_xcb_randr_root_validate(root)) return NULL; 741 RANDR_CHECK_1_2_RET(NULL);
818
819 cookie = xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, root);
820 reply = xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL);
821 if (reply)
822 {
823 if (num) *num = reply->num_modes;
824 ret = malloc(sizeof(Ecore_X_Randr_Mode_Info *) * reply->num_modes);
825 if (ret)
826 {
827 xcb_randr_mode_info_iterator_t miter;
828 int i = 0;
829 uint8_t *nbuf;
830 742
831 nbuf = xcb_randr_get_screen_resources_names(reply); 743 if (!_ecore_xcb_randr_root_validate(root)) return NULL;
832 miter = xcb_randr_get_screen_resources_modes_iterator(reply);
833 while (miter.rem)
834 {
835 xcb_randr_mode_info_t *minfo;
836
837 minfo = miter.data;
838 nbuf += minfo->name_len;
839 if ((ret[i] = malloc(sizeof(Ecore_X_Randr_Mode_Info))))
840 {
841 ret[i]->xid = minfo->id;
842 ret[i]->width = minfo->width;
843 ret[i]->height = minfo->height;
844 ret[i]->dotClock = minfo->dot_clock;
845 ret[i]->hSyncStart = minfo->hsync_start;
846 ret[i]->hSyncEnd = minfo->hsync_end;
847 ret[i]->hTotal = minfo->htotal;
848 ret[i]->vSyncStart = minfo->vsync_start;
849 ret[i]->vSyncEnd = minfo->vsync_end;
850 ret[i]->vTotal = minfo->vtotal;
851 ret[i]->modeFlags = minfo->mode_flags;
852 744
853 ret[i]->name = NULL; 745 if (_randr_version >= RANDR_1_3)
854 ret[i]->nameLength = minfo->name_len; 746 ret = _ecore_xcb_randr_13_modes_info_get(root, num);
855 if (ret[i]->nameLength > 0) 747 else if (_randr_version == RANDR_1_2)
856 { 748 ret = _ecore_xcb_randr_12_modes_info_get(root, num);
857 ret[i]->name = malloc(ret[i]->nameLength + 1);
858 if (ret[i]->name)
859 memcpy(ret[i]->name, nbuf, ret[i]->nameLength + 1);
860 }
861 }
862 else
863 {
864 while (i > 0)
865 free(ret[--i]);
866 free(ret);
867 ret = NULL;
868 break;
869 }
870 i++;
871 xcb_randr_mode_info_next(&miter);
872 }
873 }
874 free(reply);
875 }
876#endif 749#endif
877 return ret; 750 return ret;
878} 751}
@@ -886,40 +759,17 @@ ecore_x_randr_modes_info_get(Ecore_X_Window root, int *num)
886EAPI void 759EAPI void
887ecore_x_randr_mode_size_get(Ecore_X_Window root, Ecore_X_Randr_Mode mode, int *w, int *h) 760ecore_x_randr_mode_size_get(Ecore_X_Window root, Ecore_X_Randr_Mode mode, int *w, int *h)
888{ 761{
889#ifdef ECORE_XCB_RANDR
890 xcb_randr_get_screen_resources_cookie_t cookie;
891 xcb_randr_get_screen_resources_reply_t *reply;
892#endif
893
894 LOGFN(__FILE__, __LINE__, __FUNCTION__); 762 LOGFN(__FILE__, __LINE__, __FUNCTION__);
895 CHECK_XCB_CONN;
896
897 if (!_randr_avail) return;
898 763
899#ifdef ECORE_XCB_RANDR 764#ifdef ECORE_XCB_RANDR
900 if (mode == Ecore_X_Randr_None) return; 765 RANDR_CHECK_1_2_RET();
901 cookie = xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, root);
902 reply = xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL);
903 if (reply)
904 {
905 xcb_randr_mode_info_iterator_t miter;
906 766
907 miter = xcb_randr_get_screen_resources_modes_iterator(reply); 767 if (mode == Ecore_X_Randr_None) return;
908 while (miter.rem)
909 {
910 xcb_randr_mode_info_t *minfo;
911 768
912 minfo = miter.data; 769 if (_randr_version >= RANDR_1_3)
913 if (minfo->id == mode) 770 _ecore_xcb_randr_13_mode_size_get(root, mode, w, h);
914 { 771 else if (_randr_version == RANDR_1_2)
915 if (w) *w = minfo->width; 772 _ecore_xcb_randr_12_mode_size_get(root, mode, w, h);
916 if (h) *h = minfo->height;
917 break;
918 }
919 xcb_randr_mode_info_next(&miter);
920 }
921 free(reply);
922 }
923#endif 773#endif
924} 774}
925 775
@@ -942,11 +792,10 @@ ecore_x_randr_output_edid_get(Ecore_X_Window root, Ecore_X_Randr_Output output,
942#endif 792#endif
943 793
944 LOGFN(__FILE__, __LINE__, __FUNCTION__); 794 LOGFN(__FILE__, __LINE__, __FUNCTION__);
945 CHECK_XCB_CONN;
946
947 if (!_randr_avail) return NULL;
948 795
949#ifdef ECORE_XCB_RANDR 796#ifdef ECORE_XCB_RANDR
797 RANDR_CHECK_1_2_RET(NULL);
798
950 if ((!length) || (!_ecore_xcb_randr_output_validate(root, output))) 799 if ((!length) || (!_ecore_xcb_randr_output_validate(root, output)))
951 return NULL; 800 return NULL;
952 801
@@ -985,46 +834,18 @@ EAPI Ecore_X_Randr_Output *
985ecore_x_randr_output_clones_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *num) 834ecore_x_randr_output_clones_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *num)
986{ 835{
987 Ecore_X_Randr_Output *outputs = NULL; 836 Ecore_X_Randr_Output *outputs = NULL;
988#ifdef ECORE_XCB_RANDR
989 xcb_randr_get_screen_resources_cookie_t cookie;
990 xcb_randr_get_screen_resources_reply_t *reply;
991#endif
992 837
993 LOGFN(__FILE__, __LINE__, __FUNCTION__); 838 LOGFN(__FILE__, __LINE__, __FUNCTION__);
994 CHECK_XCB_CONN;
995
996 if (!_randr_avail) return NULL;
997 839
998#ifdef ECORE_XCB_RANDR 840#ifdef ECORE_XCB_RANDR
999 if (output == Ecore_X_Randr_None) return NULL; 841 RANDR_CHECK_1_2_RET(NULL);
1000
1001 cookie = xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, root);
1002 reply = xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL);
1003 if (reply)
1004 {
1005 xcb_randr_get_output_info_cookie_t ocookie;
1006 xcb_randr_get_output_info_reply_t *oreply;
1007 842
1008 ocookie = 843 if (output == Ecore_X_Randr_None) return NULL;
1009 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
1010 reply->config_timestamp);
1011 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
1012 ocookie, NULL);
1013 if (oreply)
1014 {
1015 if (num) *num = oreply->num_clones;
1016 844
1017 outputs = 845 if (_randr_version >= RANDR_1_3)
1018 malloc(sizeof(Ecore_X_Randr_Output) * oreply->num_clones); 846 outputs = _ecore_xcb_randr_13_output_clones_get(root, output, num);
1019 if (outputs) 847 else if (_randr_version == RANDR_1_2)
1020 { 848 outputs = _ecore_xcb_randr_12_output_clones_get(root, output, num);
1021 memcpy(outputs, xcb_randr_get_output_info_clones(oreply),
1022 sizeof(Ecore_X_Randr_Output) * oreply->num_clones);
1023 }
1024 free(oreply);
1025 }
1026 free(reply);
1027 }
1028#endif 849#endif
1029 return outputs; 850 return outputs;
1030} 851}
@@ -1033,45 +854,18 @@ EAPI Ecore_X_Randr_Crtc *
1033ecore_x_randr_output_possible_crtcs_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *num) 854ecore_x_randr_output_possible_crtcs_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *num)
1034{ 855{
1035 Ecore_X_Randr_Crtc *crtcs = NULL; 856 Ecore_X_Randr_Crtc *crtcs = NULL;
1036#ifdef ECORE_XCB_RANDR
1037 xcb_randr_get_screen_resources_cookie_t cookie;
1038 xcb_randr_get_screen_resources_reply_t *reply;
1039#endif
1040 857
1041 LOGFN(__FILE__, __LINE__, __FUNCTION__); 858 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1042 CHECK_XCB_CONN;
1043
1044 if (!_randr_avail) return NULL;
1045 859
1046#ifdef ECORE_XCB_RANDR 860#ifdef ECORE_XCB_RANDR
1047 if (output == Ecore_X_Randr_None) return NULL; 861 RANDR_CHECK_1_2_RET(NULL);
1048
1049 cookie = xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, root);
1050 reply = xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL);
1051 if (reply)
1052 {
1053 xcb_randr_get_output_info_cookie_t ocookie;
1054 xcb_randr_get_output_info_reply_t *oreply;
1055 862
1056 ocookie = 863 if (output == Ecore_X_Randr_None) return NULL;
1057 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
1058 reply->config_timestamp);
1059 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
1060 ocookie, NULL);
1061 if (oreply)
1062 {
1063 if (num) *num = oreply->num_crtcs;
1064 864
1065 crtcs = malloc(sizeof(Ecore_X_Randr_Crtc) * oreply->num_crtcs); 865 if (_randr_version >= RANDR_1_3)
1066 if (crtcs) 866 crtcs = _ecore_xcb_randr_13_output_possible_crtcs_get(root, output, num);
1067 { 867 else if (_randr_version == RANDR_1_2)
1068 memcpy(crtcs, xcb_randr_get_output_info_crtcs(oreply), 868 crtcs = _ecore_xcb_randr_12_output_possible_crtcs_get(root, output, num);
1069 sizeof(Ecore_X_Randr_Crtc) * oreply->num_crtcs);
1070 }
1071 free(oreply);
1072 }
1073 free(reply);
1074 }
1075#endif 869#endif
1076 return crtcs; 870 return crtcs;
1077} 871}
@@ -1085,167 +879,76 @@ ecore_x_randr_output_possible_crtcs_get(Ecore_X_Window root, Ecore_X_Randr_Outpu
1085EAPI char * 879EAPI char *
1086ecore_x_randr_output_name_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *len) 880ecore_x_randr_output_name_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *len)
1087{ 881{
1088 char *ret = NULL;
1089#ifdef ECORE_XCB_RANDR
1090 xcb_randr_get_screen_resources_cookie_t cookie;
1091 xcb_randr_get_screen_resources_reply_t *reply;
1092#endif
1093
1094 LOGFN(__FILE__, __LINE__, __FUNCTION__); 882 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1095 CHECK_XCB_CONN;
1096
1097 if (!_randr_avail) return NULL;
1098 883
1099#ifdef ECORE_XCB_RANDR 884#ifdef ECORE_XCB_RANDR
1100 if (output == Ecore_X_Randr_None) return NULL; 885 RANDR_CHECK_1_2_RET(NULL);
1101
1102 cookie = xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, root);
1103 reply = xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL);
1104 if (reply)
1105 {
1106 xcb_randr_get_output_info_cookie_t ocookie;
1107 xcb_randr_get_output_info_reply_t *oreply;
1108
1109 ocookie =
1110 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
1111 reply->config_timestamp);
1112 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
1113 ocookie, NULL);
1114 if (oreply)
1115 {
1116 uint8_t *nbuf;
1117
1118 nbuf = xcb_randr_get_output_info_name(oreply);
1119 nbuf += oreply->name_len;
1120 886
1121 if (len) *len = oreply->name_len; 887 if (output == Ecore_X_Randr_None) return NULL;
1122 if (oreply->name_len > 0)
1123 {
1124 ret = malloc(oreply->name_len + 1);
1125 if (ret)
1126 memcpy(ret, nbuf, oreply->name_len + 1);
1127 }
1128 888
1129 free(oreply); 889 if (_randr_version >= RANDR_1_3)
1130 } 890 return _ecore_xcb_randr_13_output_name_get(root, output, len);
1131 free(reply); 891 else if (_randr_version == RANDR_1_2)
1132 } 892 return _ecore_xcb_randr_12_output_name_get(root, output, len);
1133#endif 893#endif
1134 894
1135 return ret; 895 return NULL;
1136} 896}
1137 897
1138EAPI Ecore_X_Randr_Connection_Status 898EAPI Ecore_X_Randr_Connection_Status
1139ecore_x_randr_output_connection_status_get(Ecore_X_Window root, Ecore_X_Randr_Output output) 899ecore_x_randr_output_connection_status_get(Ecore_X_Window root, Ecore_X_Randr_Output output)
1140{ 900{
1141 Ecore_X_Randr_Connection_Status ret = ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN;
1142#ifdef ECORE_XCB_RANDR
1143 xcb_randr_get_screen_resources_cookie_t cookie;
1144 xcb_randr_get_screen_resources_reply_t *reply;
1145#endif
1146
1147 LOGFN(__FILE__, __LINE__, __FUNCTION__); 901 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1148 CHECK_XCB_CONN;
1149
1150 if (!_randr_avail) return ret;
1151 902
1152#ifdef ECORE_XCB_RANDR 903#ifdef ECORE_XCB_RANDR
1153 if (output == Ecore_X_Randr_None) return ret; 904 RANDR_CHECK_1_2_RET(ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN);
1154 905
1155 cookie = xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, root); 906 if (output == Ecore_X_Randr_None)
1156 reply = xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL); 907 return ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN;
1157 if (reply)
1158 {
1159 xcb_randr_get_output_info_cookie_t ocookie;
1160 xcb_randr_get_output_info_reply_t *oreply;
1161 908
1162 ocookie = 909 if (_randr_version >= RANDR_1_3)
1163 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output, 910 return _ecore_xcb_randr_13_output_connection_status_get(root, output);
1164 reply->config_timestamp); 911 else if (_randr_version == RANDR_1_2)
1165 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn, 912 return _ecore_xcb_randr_12_output_connection_status_get(root, output);
1166 ocookie, NULL);
1167 if (oreply)
1168 {
1169 ret = oreply->connection;
1170 free(oreply);
1171 }
1172 free(reply);
1173 }
1174#endif 913#endif
1175 914
1176 return ret; 915 return ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN;
1177} 916}
1178 917
1179EAPI Ecore_X_Randr_Output * 918EAPI Ecore_X_Randr_Output *
1180ecore_x_randr_outputs_get(Ecore_X_Window root, int *num) 919ecore_x_randr_outputs_get(Ecore_X_Window root, int *num)
1181{ 920{
1182 Ecore_X_Randr_Output *ret = NULL;
1183#ifdef ECORE_XCB_RANDR
1184 xcb_randr_get_screen_resources_cookie_t cookie;
1185 xcb_randr_get_screen_resources_reply_t *reply;
1186#endif
1187
1188 LOGFN(__FILE__, __LINE__, __FUNCTION__); 921 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1189 CHECK_XCB_CONN;
1190
1191 if (!_randr_avail) return NULL;
1192 922
1193#ifdef ECORE_XCB_RANDR 923#ifdef ECORE_XCB_RANDR
1194 cookie = xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, root); 924 RANDR_CHECK_1_2_RET(NULL);
1195 reply = xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL); 925
1196 if (reply) 926 if (_randr_version >= RANDR_1_3)
1197 { 927 return _ecore_xcb_randr_13_outputs_get(root, num);
1198 if (num) *num = reply->num_outputs; 928 else if (_randr_version == RANDR_1_2)
1199 ret = malloc(sizeof(Ecore_X_Randr_Output) * reply->num_outputs); 929 return _ecore_xcb_randr_12_outputs_get(root, num);
1200 if (ret)
1201 memcpy(ret, xcb_randr_get_screen_resources_outputs(reply),
1202 sizeof(Ecore_X_Randr_Output) * reply->num_outputs);
1203 free(reply);
1204 }
1205#endif 930#endif
1206 931
1207 return ret; 932 return NULL;
1208} 933}
1209 934
1210EAPI Ecore_X_Randr_Crtc 935EAPI Ecore_X_Randr_Crtc
1211ecore_x_randr_output_crtc_get(Ecore_X_Window root, Ecore_X_Randr_Output output) 936ecore_x_randr_output_crtc_get(Ecore_X_Window root, Ecore_X_Randr_Output output)
1212{ 937{
1213 Ecore_X_Randr_Crtc ret = Ecore_X_Randr_None;
1214#ifdef ECORE_XCB_RANDR
1215 xcb_randr_get_screen_resources_cookie_t cookie;
1216 xcb_randr_get_screen_resources_reply_t *reply;
1217#endif
1218
1219 LOGFN(__FILE__, __LINE__, __FUNCTION__); 938 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1220 CHECK_XCB_CONN;
1221
1222 if (!_randr_avail) return Ecore_X_Randr_None;
1223 939
1224#ifdef ECORE_XCB_RANDR 940#ifdef ECORE_XCB_RANDR
1225 if (output == Ecore_X_Randr_None) return ret; 941 RANDR_CHECK_1_2_RET(Ecore_X_Randr_None);
1226 942
1227 cookie = xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, root); 943 if (output == Ecore_X_Randr_None) return Ecore_X_Randr_None;
1228 reply = xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL);
1229 if (reply)
1230 {
1231 xcb_randr_get_output_info_cookie_t ocookie;
1232 xcb_randr_get_output_info_reply_t *oreply;
1233 944
1234 ocookie = 945 if (_randr_version >= RANDR_1_3)
1235 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output, 946 return _ecore_xcb_randr_13_output_crtc_get(root, output);
1236 reply->config_timestamp); 947 else if (_randr_version == RANDR_1_2)
1237 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn, 948 return _ecore_xcb_randr_12_output_crtc_get(root, output);
1238 ocookie, NULL);
1239 if (oreply)
1240 {
1241 ret = oreply->crtc;
1242 free(oreply);
1243 }
1244 free(reply);
1245 }
1246#endif 949#endif
1247 950
1248 return ret; 951 return Ecore_X_Randr_None;
1249} 952}
1250 953
1251/** 954/**
@@ -1273,68 +976,63 @@ ecore_x_randr_crtc_settings_set(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc, Ec
1273{ 976{
1274 Eina_Bool ret = EINA_FALSE; 977 Eina_Bool ret = EINA_FALSE;
1275#ifdef ECORE_XCB_RANDR 978#ifdef ECORE_XCB_RANDR
1276 xcb_randr_get_screen_resources_cookie_t cookie; 979 xcb_timestamp_t stamp = 0;
1277 xcb_randr_get_screen_resources_reply_t *reply; 980 xcb_randr_get_crtc_info_cookie_t ccookie;
981 xcb_randr_get_crtc_info_reply_t *creply;
1278#endif 982#endif
1279 983
1280 LOGFN(__FILE__, __LINE__, __FUNCTION__); 984 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1281 CHECK_XCB_CONN;
1282
1283 if (!_randr_avail) return EINA_FALSE;
1284 985
1285#ifdef ECORE_XCB_RANDR 986#ifdef ECORE_XCB_RANDR
987 RANDR_CHECK_1_2_RET(EINA_FALSE);
988
1286 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret; 989 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret;
1287 990
1288 cookie = xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, root); 991 if (_randr_version >= RANDR_1_3)
1289 reply = xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL); 992 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
1290 if (reply) 993 else if (_randr_version == RANDR_1_2)
994 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
995
996 ccookie =
997 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp);
998 creply =
999 xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ccookie, NULL);
1000 if (creply)
1291 { 1001 {
1292 xcb_randr_get_crtc_info_cookie_t ccookie; 1002 xcb_randr_set_crtc_config_cookie_t scookie;
1293 xcb_randr_get_crtc_info_reply_t *creply; 1003 xcb_randr_set_crtc_config_reply_t *sreply;
1294 1004
1295 ccookie = 1005 if ((mode == Ecore_X_Randr_None) ||
1296 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, 1006 (num == Ecore_X_Randr_None))
1297 reply->config_timestamp);
1298 creply =
1299 xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ccookie, NULL);
1300 if (creply)
1301 { 1007 {
1302 xcb_randr_set_crtc_config_cookie_t scookie; 1008 outputs = NULL;
1303 xcb_randr_set_crtc_config_reply_t *sreply; 1009 num = 0;
1304 1010 }
1305 if ((mode == Ecore_X_Randr_None) || (num == Ecore_X_Randr_None)) 1011 else if (num == (int)Ecore_X_Randr_Unset)
1306 { 1012 {
1307 outputs = NULL; 1013 outputs = xcb_randr_get_crtc_info_outputs(creply);
1308 num = 0; 1014 num = creply->num_outputs;
1309 } 1015 }
1310 else if (num == (int)Ecore_X_Randr_Unset) 1016 if ((int)mode == Ecore_X_Randr_Unset) mode = creply->mode;
1311 { 1017 if (x < 0) x = creply->x;
1312 outputs = xcb_randr_get_crtc_info_outputs(creply); 1018 if (y < 0) y = creply->y;
1313 num = creply->num_outputs; 1019 if ((int)orientation == Ecore_X_Randr_Unset)
1314 } 1020 orientation = creply->rotation;
1315 if ((int)mode == Ecore_X_Randr_Unset) mode = creply->mode;
1316 if (x < 0) x = creply->x;
1317 if (y < 0) y = creply->y;
1318 if ((int)orientation == Ecore_X_Randr_Unset)
1319 orientation = creply->rotation;
1320 1021
1321 scookie = 1022 scookie =
1322 xcb_randr_set_crtc_config_unchecked(_ecore_xcb_conn, 1023 xcb_randr_set_crtc_config_unchecked(_ecore_xcb_conn,
1323 crtc, XCB_CURRENT_TIME, 1024 crtc, XCB_CURRENT_TIME, stamp,
1324 reply->config_timestamp, 1025 x, y, mode, orientation,
1325 x, y, mode, orientation, 1026 num, outputs);
1326 num, outputs); 1027 sreply =
1327 sreply = 1028 xcb_randr_set_crtc_config_reply(_ecore_xcb_conn, scookie, NULL);
1328 xcb_randr_set_crtc_config_reply(_ecore_xcb_conn, scookie, NULL); 1029 if (sreply)
1329 if (sreply) 1030 {
1330 { 1031 ret = (sreply->status == XCB_RANDR_SET_CONFIG_SUCCESS) ?
1331 ret = (sreply->status == XCB_RANDR_SET_CONFIG_SUCCESS) ? 1032 EINA_TRUE : EINA_FALSE;
1332 EINA_TRUE : EINA_FALSE; 1033 free(sreply);
1333 free(sreply);
1334 }
1335 free(creply);
1336 } 1034 }
1337 free(reply); 1035 free(creply);
1338 } 1036 }
1339#endif 1037#endif
1340 1038
@@ -1359,11 +1057,10 @@ ecore_x_randr_crtc_mode_set(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc, Ecore_
1359 Eina_Bool ret = EINA_FALSE; 1057 Eina_Bool ret = EINA_FALSE;
1360 1058
1361 LOGFN(__FILE__, __LINE__, __FUNCTION__); 1059 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1362 CHECK_XCB_CONN;
1363
1364 if (!_randr_avail) return ret;
1365 1060
1366#ifdef ECORE_XCB_RANDR 1061#ifdef ECORE_XCB_RANDR
1062 RANDR_CHECK_1_2_RET(EINA_FALSE);
1063
1367 if ((int)mode == Ecore_X_Randr_Unset) return ret; 1064 if ((int)mode == Ecore_X_Randr_Unset) return ret;
1368 ret = 1065 ret =
1369 ecore_x_randr_crtc_settings_set(root, crtc, outputs, num, 1066 ecore_x_randr_crtc_settings_set(root, crtc, outputs, num,
@@ -1386,36 +1083,30 @@ ecore_x_randr_crtc_mode_get(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc)
1386{ 1083{
1387 Ecore_X_Randr_Mode ret = Ecore_X_Randr_Unset; 1084 Ecore_X_Randr_Mode ret = Ecore_X_Randr_Unset;
1388#ifdef ECORE_XCB_RANDR 1085#ifdef ECORE_XCB_RANDR
1389 xcb_randr_get_screen_resources_cookie_t cookie; 1086 xcb_timestamp_t stamp = 0;
1390 xcb_randr_get_screen_resources_reply_t *reply; 1087 xcb_randr_get_crtc_info_cookie_t ocookie;
1088 xcb_randr_get_crtc_info_reply_t *oreply;
1391#endif 1089#endif
1392 1090
1393 LOGFN(__FILE__, __LINE__, __FUNCTION__); 1091 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1394 CHECK_XCB_CONN;
1395
1396 if (!_randr_avail) return Ecore_X_Randr_Unset;
1397 1092
1398#ifdef ECORE_XCB_RANDR 1093#ifdef ECORE_XCB_RANDR
1094 RANDR_CHECK_1_2_RET(Ecore_X_Randr_Unset);
1095
1399 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret; 1096 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret;
1400 1097
1401 cookie = xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, root); 1098 if (_randr_version >= RANDR_1_3)
1402 reply = xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL); 1099 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
1403 if (reply) 1100 else if (_randr_version == RANDR_1_2)
1404 { 1101 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
1405 xcb_randr_get_crtc_info_cookie_t ocookie;
1406 xcb_randr_get_crtc_info_reply_t *oreply;
1407 1102
1408 ocookie = 1103 ocookie =
1409 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, 1104 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp);
1410 reply->config_timestamp); 1105 oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL);
1411 oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, 1106 if (oreply)
1412 ocookie, NULL); 1107 {
1413 if (oreply) 1108 ret = oreply->mode;
1414 { 1109 free(oreply);
1415 ret = oreply->mode;
1416 free(oreply);
1417 }
1418 free(reply);
1419 } 1110 }
1420#endif 1111#endif
1421 1112
@@ -1427,36 +1118,30 @@ ecore_x_randr_crtc_orientation_get(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc)
1427{ 1118{
1428 Ecore_X_Randr_Orientation ret = Ecore_X_Randr_None; 1119 Ecore_X_Randr_Orientation ret = Ecore_X_Randr_None;
1429#ifdef ECORE_XCB_RANDR 1120#ifdef ECORE_XCB_RANDR
1430 xcb_randr_get_screen_resources_cookie_t cookie; 1121 xcb_timestamp_t stamp = 0;
1431 xcb_randr_get_screen_resources_reply_t *reply; 1122 xcb_randr_get_crtc_info_cookie_t ocookie;
1123 xcb_randr_get_crtc_info_reply_t *oreply;
1432#endif 1124#endif
1433 1125
1434 LOGFN(__FILE__, __LINE__, __FUNCTION__); 1126 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1435 CHECK_XCB_CONN;
1436
1437 if (!_randr_avail) return Ecore_X_Randr_None;
1438 1127
1439#ifdef ECORE_XCB_RANDR 1128#ifdef ECORE_XCB_RANDR
1129 RANDR_CHECK_1_2_RET(Ecore_X_Randr_None);
1130
1440 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret; 1131 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret;
1441 1132
1442 cookie = xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, root); 1133 if (_randr_version >= RANDR_1_3)
1443 reply = xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL); 1134 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
1444 if (reply) 1135 else if (_randr_version == RANDR_1_2)
1445 { 1136 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
1446 xcb_randr_get_crtc_info_cookie_t ocookie;
1447 xcb_randr_get_crtc_info_reply_t *oreply;
1448 1137
1449 ocookie = 1138 ocookie =
1450 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, 1139 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp);
1451 reply->config_timestamp); 1140 oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL);
1452 oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, 1141 if (oreply)
1453 ocookie, NULL); 1142 {
1454 if (oreply) 1143 ret = oreply->rotation;
1455 { 1144 free(oreply);
1456 ret = oreply->rotation;
1457 free(oreply);
1458 }
1459 free(reply);
1460 } 1145 }
1461#endif 1146#endif
1462 1147
@@ -1469,11 +1154,10 @@ ecore_x_randr_crtc_orientation_set(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc,
1469 Eina_Bool ret = EINA_FALSE; 1154 Eina_Bool ret = EINA_FALSE;
1470 1155
1471 LOGFN(__FILE__, __LINE__, __FUNCTION__); 1156 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1472 CHECK_XCB_CONN;
1473
1474 if (!_randr_avail) return EINA_FALSE;
1475 1157
1476#ifdef ECORE_XCB_RANDR 1158#ifdef ECORE_XCB_RANDR
1159 RANDR_CHECK_1_2_RET(EINA_FALSE);
1160
1477 if (orientation != Ecore_X_Randr_None) 1161 if (orientation != Ecore_X_Randr_None)
1478 { 1162 {
1479 ret = 1163 ret =
@@ -1491,36 +1175,31 @@ ecore_x_randr_crtc_orientations_get(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc
1491{ 1175{
1492 Ecore_X_Randr_Orientation ret = Ecore_X_Randr_None; 1176 Ecore_X_Randr_Orientation ret = Ecore_X_Randr_None;
1493#ifdef ECORE_XCB_RANDR 1177#ifdef ECORE_XCB_RANDR
1494 xcb_randr_get_screen_resources_cookie_t cookie; 1178 xcb_timestamp_t stamp = 0;
1495 xcb_randr_get_screen_resources_reply_t *reply; 1179 xcb_randr_get_crtc_info_cookie_t ocookie;
1180 xcb_randr_get_crtc_info_reply_t *oreply;
1496#endif 1181#endif
1497 1182
1498 LOGFN(__FILE__, __LINE__, __FUNCTION__); 1183 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1499 CHECK_XCB_CONN;
1500
1501 if (!_randr_avail) return Ecore_X_Randr_None;
1502 1184
1503#ifdef ECORE_XCB_RANDR 1185#ifdef ECORE_XCB_RANDR
1186 RANDR_CHECK_1_2_RET(Ecore_X_Randr_None);
1187
1504 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret; 1188 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret;
1505 1189
1506 cookie = xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, root); 1190 if (_randr_version >= RANDR_1_3)
1507 reply = xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL); 1191 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
1508 if (reply) 1192 else if (_randr_version == RANDR_1_2)
1509 { 1193 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
1510 xcb_randr_get_crtc_info_cookie_t ocookie;
1511 xcb_randr_get_crtc_info_reply_t *oreply;
1512 1194
1513 ocookie = 1195 ocookie =
1514 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, 1196 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp);
1515 reply->config_timestamp); 1197 oreply =
1516 oreply = 1198 xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL);
1517 xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL); 1199 if (oreply)
1518 if (oreply) 1200 {
1519 { 1201 ret = oreply->rotations;
1520 ret = oreply->rotations; 1202 free(oreply);
1521 free(oreply);
1522 }
1523 free(reply);
1524 } 1203 }
1525#endif 1204#endif
1526 1205
@@ -1537,44 +1216,38 @@ ecore_x_randr_crtc_possible_outputs_get(Ecore_X_Window root, Ecore_X_Randr_Crtc
1537{ 1216{
1538 Ecore_X_Randr_Output *ret = NULL; 1217 Ecore_X_Randr_Output *ret = NULL;
1539#ifdef ECORE_XCB_RANDR 1218#ifdef ECORE_XCB_RANDR
1540 xcb_randr_get_screen_resources_cookie_t cookie; 1219 xcb_timestamp_t stamp = 0;
1541 xcb_randr_get_screen_resources_reply_t *reply; 1220 xcb_randr_get_crtc_info_cookie_t ocookie;
1221 xcb_randr_get_crtc_info_reply_t *oreply;
1542#endif 1222#endif
1543 1223
1544 LOGFN(__FILE__, __LINE__, __FUNCTION__); 1224 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1545 CHECK_XCB_CONN;
1546
1547 if (!_randr_avail) return NULL;
1548 1225
1549#ifdef ECORE_XCB_RANDR 1226#ifdef ECORE_XCB_RANDR
1227 RANDR_CHECK_1_2_RET(NULL);
1228
1550 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret; 1229 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret;
1551 1230
1552 cookie = xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, root); 1231 if (_randr_version >= RANDR_1_3)
1553 reply = xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL); 1232 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
1554 if (reply) 1233 else if (_randr_version == RANDR_1_2)
1555 { 1234 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
1556 xcb_randr_get_crtc_info_cookie_t ocookie;
1557 xcb_randr_get_crtc_info_reply_t *oreply;
1558 1235
1559 ocookie = 1236 ocookie =
1560 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, 1237 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp);
1561 reply->config_timestamp); 1238 oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL);
1562 oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, 1239 if (oreply)
1563 ocookie, NULL); 1240 {
1564 if (oreply) 1241 if (num) *num = oreply->num_possible_outputs;
1242 ret = malloc(sizeof(Ecore_X_Randr_Output) *
1243 oreply->num_possible_outputs);
1244 if (ret)
1565 { 1245 {
1566 if (num) *num = oreply->num_possible_outputs; 1246 memcpy(ret, xcb_randr_get_crtc_info_possible(oreply),
1567 ret = malloc(sizeof(Ecore_X_Randr_Output) * 1247 sizeof(Ecore_X_Randr_Output) *
1568 oreply->num_possible_outputs); 1248 oreply->num_possible_outputs);
1569 if (ret)
1570 {
1571 memcpy(ret, xcb_randr_get_crtc_info_possible(oreply),
1572 sizeof(Ecore_X_Randr_Output) *
1573 oreply->num_possible_outputs);
1574 }
1575 free(oreply);
1576 } 1249 }
1577 free(reply); 1250 free(oreply);
1578 } 1251 }
1579#endif 1252#endif
1580 1253
@@ -1591,27 +1264,41 @@ EAPI Ecore_X_Randr_Crtc *
1591ecore_x_randr_crtcs_get(Ecore_X_Window root, int *num) 1264ecore_x_randr_crtcs_get(Ecore_X_Window root, int *num)
1592{ 1265{
1593 Ecore_X_Randr_Crtc *ret = NULL; 1266 Ecore_X_Randr_Crtc *ret = NULL;
1594#ifdef ECORE_XCB_RANDR
1595 xcb_randr_get_screen_resources_cookie_t cookie;
1596 xcb_randr_get_screen_resources_reply_t *reply;
1597#endif
1598 1267
1599 LOGFN(__FILE__, __LINE__, __FUNCTION__); 1268 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1600 CHECK_XCB_CONN;
1601
1602 if (!_randr_avail) return NULL;
1603 1269
1604#ifdef ECORE_XCB_RANDR 1270#ifdef ECORE_XCB_RANDR
1605 cookie = xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, root); 1271 RANDR_CHECK_1_2_RET(NULL);
1606 reply = xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL); 1272
1607 if (reply) 1273 if (_randr_version >= RANDR_1_3)
1608 { 1274 {
1609 if (num) *num = reply->num_crtcs; 1275 xcb_randr_get_screen_resources_current_reply_t *reply;
1610 ret = malloc(sizeof(Ecore_X_Randr_Crtc) * reply->num_crtcs); 1276
1611 if (ret) 1277 reply = _ecore_xcb_randr_13_get_resources(root);
1612 memcpy(ret, xcb_randr_get_screen_resources_crtcs(reply), 1278 if (reply)
1613 sizeof(Ecore_X_Randr_Crtc) * reply->num_crtcs); 1279 {
1614 free(reply); 1280 if (num) *num = reply->num_crtcs;
1281 ret = malloc(sizeof(Ecore_X_Randr_Crtc) * reply->num_crtcs);
1282 if (ret)
1283 memcpy(ret, xcb_randr_get_screen_resources_current_crtcs(reply),
1284 sizeof(Ecore_X_Randr_Crtc) * reply->num_crtcs);
1285 free(reply);
1286 }
1287 }
1288 else if (_randr_version == RANDR_1_2)
1289 {
1290 xcb_randr_get_screen_resources_reply_t *reply;
1291
1292 reply = _ecore_xcb_randr_12_get_resources(root);
1293 if (reply)
1294 {
1295 if (num) *num = reply->num_crtcs;
1296 ret = malloc(sizeof(Ecore_X_Randr_Crtc) * reply->num_crtcs);
1297 if (ret)
1298 memcpy(ret, xcb_randr_get_screen_resources_crtcs(reply),
1299 sizeof(Ecore_X_Randr_Crtc) * reply->num_crtcs);
1300 free(reply);
1301 }
1615 } 1302 }
1616#endif 1303#endif
1617 1304
@@ -1628,40 +1315,34 @@ ecore_x_randr_crtc_outputs_get(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc, int
1628{ 1315{
1629 Ecore_X_Randr_Output *ret = NULL; 1316 Ecore_X_Randr_Output *ret = NULL;
1630#ifdef ECORE_XCB_RANDR 1317#ifdef ECORE_XCB_RANDR
1631 xcb_randr_get_screen_resources_cookie_t cookie; 1318 xcb_timestamp_t stamp = 0;
1632 xcb_randr_get_screen_resources_reply_t *reply; 1319 xcb_randr_get_crtc_info_cookie_t ocookie;
1320 xcb_randr_get_crtc_info_reply_t *oreply;
1633#endif 1321#endif
1634 1322
1635 LOGFN(__FILE__, __LINE__, __FUNCTION__); 1323 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1636 CHECK_XCB_CONN;
1637
1638 if (!_randr_avail) return NULL;
1639 1324
1640#ifdef ECORE_XCB_RANDR 1325#ifdef ECORE_XCB_RANDR
1326 RANDR_CHECK_1_2_RET(NULL);
1327
1641 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret; 1328 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret;
1642 1329
1643 cookie = xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, root); 1330 if (_randr_version >= RANDR_1_3)
1644 reply = xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL); 1331 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
1645 if (reply) 1332 else if (_randr_version == RANDR_1_2)
1646 { 1333 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
1647 xcb_randr_get_crtc_info_cookie_t ocookie;
1648 xcb_randr_get_crtc_info_reply_t *oreply;
1649 1334
1650 ocookie = 1335 ocookie =
1651 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, 1336 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp);
1652 reply->config_timestamp); 1337 oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL);
1653 oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, 1338 if (oreply)
1654 ocookie, NULL); 1339 {
1655 if (oreply) 1340 if (num) *num = oreply->num_outputs;
1656 { 1341 ret = malloc(sizeof(Ecore_X_Randr_Output) * oreply->num_outputs);
1657 if (num) *num = oreply->num_outputs; 1342 if (ret)
1658 ret = malloc(sizeof(Ecore_X_Randr_Output) * oreply->num_outputs); 1343 memcpy(ret, xcb_randr_get_crtc_info_outputs(oreply),
1659 if (ret) 1344 sizeof(Ecore_X_Randr_Output) * oreply->num_outputs);
1660 memcpy(ret, xcb_randr_get_crtc_info_outputs(oreply), 1345 free(oreply);
1661 sizeof(Ecore_X_Randr_Output) * oreply->num_outputs);
1662 free(oreply);
1663 }
1664 free(reply);
1665 } 1346 }
1666#endif 1347#endif
1667 1348
@@ -1672,39 +1353,33 @@ EAPI void
1672ecore_x_randr_crtc_geometry_get(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc, int *x, int *y, int *w, int *h) 1353ecore_x_randr_crtc_geometry_get(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc, int *x, int *y, int *w, int *h)
1673{ 1354{
1674#ifdef ECORE_XCB_RANDR 1355#ifdef ECORE_XCB_RANDR
1675 xcb_randr_get_screen_resources_cookie_t cookie; 1356 xcb_timestamp_t stamp = 0;
1676 xcb_randr_get_screen_resources_reply_t *reply; 1357 xcb_randr_get_crtc_info_cookie_t ocookie;
1358 xcb_randr_get_crtc_info_reply_t *oreply;
1677#endif 1359#endif
1678 1360
1679 LOGFN(__FILE__, __LINE__, __FUNCTION__); 1361 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1680 CHECK_XCB_CONN;
1681
1682 if (!_randr_avail) return;
1683 1362
1684#ifdef ECORE_XCB_RANDR 1363#ifdef ECORE_XCB_RANDR
1364 RANDR_CHECK_1_2_RET();
1365
1685 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return; 1366 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return;
1686 1367
1687 cookie = xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, root); 1368 if (_randr_version >= RANDR_1_3)
1688 reply = xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL); 1369 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
1689 if (reply) 1370 else if (_randr_version == RANDR_1_2)
1690 { 1371 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
1691 xcb_randr_get_crtc_info_cookie_t ocookie;
1692 xcb_randr_get_crtc_info_reply_t *oreply;
1693 1372
1694 ocookie = 1373 ocookie =
1695 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, 1374 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp);
1696 reply->config_timestamp); 1375 oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL);
1697 oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, 1376 if (oreply)
1698 ocookie, NULL); 1377 {
1699 if (oreply) 1378 if (x) *x = oreply->x;
1700 { 1379 if (y) *y = oreply->y;
1701 if (x) *x = oreply->x; 1380 if (w) *w = oreply->width;
1702 if (y) *y = oreply->y; 1381 if (h) *h = oreply->height;
1703 if (w) *w = oreply->width; 1382 free(oreply);
1704 if (h) *h = oreply->height;
1705 free(oreply);
1706 }
1707 free(reply);
1708 } 1383 }
1709#endif 1384#endif
1710} 1385}
@@ -1728,11 +1403,10 @@ ecore_x_randr_crtc_pos_relative_set(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc
1728#endif 1403#endif
1729 1404
1730 LOGFN(__FILE__, __LINE__, __FUNCTION__); 1405 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1731 CHECK_XCB_CONN;
1732
1733 if (!_randr_avail) return EINA_FALSE;
1734 1406
1735#ifdef ECORE_XCB_RANDR 1407#ifdef ECORE_XCB_RANDR
1408 RANDR_CHECK_1_2_RET(EINA_FALSE);
1409
1736 if ((ecore_x_randr_crtc_mode_get(root, crtc1) == 0) || 1410 if ((ecore_x_randr_crtc_mode_get(root, crtc1) == 0) ||
1737 (ecore_x_randr_crtc_mode_get(root, crtc2) == 0)) 1411 (ecore_x_randr_crtc_mode_get(root, crtc2) == 0))
1738 return EINA_FALSE; 1412 return EINA_FALSE;
@@ -1811,9 +1485,6 @@ ecore_x_randr_move_all_crtcs_but(Ecore_X_Window root, const Ecore_X_Randr_Crtc *
1811#endif 1485#endif
1812 1486
1813 LOGFN(__FILE__, __LINE__, __FUNCTION__); 1487 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1814 CHECK_XCB_CONN;
1815
1816 if (!_randr_avail) return EINA_FALSE;
1817 1488
1818#ifdef ECORE_XCB_RANDR 1489#ifdef ECORE_XCB_RANDR
1819 if ((num <= 0) || (!not_moved) || (!_ecore_xcb_randr_root_validate(root))) 1490 if ((num <= 0) || (!not_moved) || (!_ecore_xcb_randr_root_validate(root)))
@@ -1844,11 +1515,10 @@ EAPI void
1844ecore_x_randr_crtc_pos_get(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc, int *x, int *y) 1515ecore_x_randr_crtc_pos_get(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc, int *x, int *y)
1845{ 1516{
1846 LOGFN(__FILE__, __LINE__, __FUNCTION__); 1517 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1847 CHECK_XCB_CONN;
1848
1849 if (!_randr_avail) return;
1850 1518
1851#ifdef ECORE_XCB_RANDR 1519#ifdef ECORE_XCB_RANDR
1520 RANDR_CHECK_1_2_RET();
1521
1852 ecore_x_randr_crtc_geometry_get(root, crtc, x, y, NULL, NULL); 1522 ecore_x_randr_crtc_geometry_get(root, crtc, x, y, NULL, NULL);
1853#endif 1523#endif
1854} 1524}
@@ -1871,11 +1541,10 @@ ecore_x_randr_crtc_pos_set(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc, int x,
1871#endif 1541#endif
1872 1542
1873 LOGFN(__FILE__, __LINE__, __FUNCTION__); 1543 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1874 CHECK_XCB_CONN;
1875
1876 if (!_randr_avail) return EINA_FALSE;
1877 1544
1878#ifdef ECORE_XCB_RANDR 1545#ifdef ECORE_XCB_RANDR
1546 RANDR_CHECK_1_2_RET(EINA_FALSE);
1547
1879 ecore_x_randr_crtc_geometry_get(root, crtc, 1548 ecore_x_randr_crtc_geometry_get(root, crtc,
1880 &rect.x, &rect.y, &rect.w, &rect.h); 1549 &rect.x, &rect.y, &rect.w, &rect.h);
1881 ecore_x_randr_screen_current_size_get(root, &w, &h, NULL, NULL); 1550 ecore_x_randr_screen_current_size_get(root, &w, &h, NULL, NULL);
@@ -1902,11 +1571,9 @@ EAPI void
1902ecore_x_randr_crtc_size_get(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc, int *w, int *h) 1571ecore_x_randr_crtc_size_get(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc, int *w, int *h)
1903{ 1572{
1904 LOGFN(__FILE__, __LINE__, __FUNCTION__); 1573 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1905 CHECK_XCB_CONN;
1906
1907 if (!_randr_avail) return;
1908 1574
1909#ifdef ECORE_XCB_RANDR 1575#ifdef ECORE_XCB_RANDR
1576 RANDR_CHECK_1_2_RET();
1910 ecore_x_randr_crtc_geometry_get(root, crtc, NULL, NULL, w, h); 1577 ecore_x_randr_crtc_geometry_get(root, crtc, NULL, NULL, w, h);
1911#endif 1578#endif
1912} 1579}
@@ -1915,42 +1582,74 @@ EAPI Ecore_X_Randr_Refresh_Rate
1915ecore_x_randr_crtc_refresh_rate_get(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc, Ecore_X_Randr_Mode mode) 1582ecore_x_randr_crtc_refresh_rate_get(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc, Ecore_X_Randr_Mode mode)
1916{ 1583{
1917 Ecore_X_Randr_Refresh_Rate ret = 0.0; 1584 Ecore_X_Randr_Refresh_Rate ret = 0.0;
1918#ifdef ECORE_XCB_RANDR
1919 xcb_randr_get_screen_resources_cookie_t cookie;
1920 xcb_randr_get_screen_resources_reply_t *reply;
1921#endif
1922 1585
1923 LOGFN(__FILE__, __LINE__, __FUNCTION__); 1586 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1924 CHECK_XCB_CONN;
1925
1926 if (!_randr_avail) return 0.0;
1927 1587
1928#ifdef ECORE_XCB_RANDR 1588#ifdef ECORE_XCB_RANDR
1589 RANDR_CHECK_1_2_RET(0.0);
1590
1929 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return 0.0; 1591 if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return 0.0;
1930 cookie = xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, root); 1592
1931 reply = xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL); 1593 if (_randr_version >= RANDR_1_3)
1932 if (reply)
1933 { 1594 {
1934 xcb_randr_mode_info_iterator_t miter; 1595 xcb_randr_get_screen_resources_current_reply_t *reply;
1935 1596
1936 miter = xcb_randr_get_screen_resources_modes_iterator(reply); 1597 reply = _ecore_xcb_randr_13_get_resources(root);
1937 while (miter.rem) 1598 if (reply)
1938 { 1599 {
1939 xcb_randr_mode_info_t *minfo; 1600 xcb_randr_mode_info_iterator_t miter;
1940 1601
1941 minfo = miter.data; 1602 miter =
1942 if (minfo->id == mode) 1603 xcb_randr_get_screen_resources_current_modes_iterator(reply);
1604 while (miter.rem)
1943 { 1605 {
1944 if ((minfo->htotal) && (minfo->vtotal)) 1606 xcb_randr_mode_info_t *minfo;
1607
1608 minfo = miter.data;
1609 if (minfo->id == mode)
1945 { 1610 {
1946 ret = ((double)minfo->dot_clock / 1611 if ((minfo->htotal) && (minfo->vtotal))
1947 ((double)minfo->htotal * (double)minfo->vtotal)); 1612 {
1613 ret = ((double)minfo->dot_clock /
1614 ((double)minfo->htotal *
1615 (double)minfo->vtotal));
1616 }
1617 break;
1948 } 1618 }
1949 break; 1619 xcb_randr_mode_info_next(&miter);
1950 } 1620 }
1951 xcb_randr_mode_info_next(&miter); 1621 free(reply);
1622 }
1623 }
1624 else if (_randr_version == RANDR_1_2)
1625 {
1626 xcb_randr_get_screen_resources_reply_t *reply;
1627
1628 reply = _ecore_xcb_randr_12_get_resources(root);
1629 if (reply)
1630 {
1631 xcb_randr_mode_info_iterator_t miter;
1632
1633 miter = xcb_randr_get_screen_resources_modes_iterator(reply);
1634 while (miter.rem)
1635 {
1636 xcb_randr_mode_info_t *minfo;
1637
1638 minfo = miter.data;
1639 if (minfo->id == mode)
1640 {
1641 if ((minfo->htotal) && (minfo->vtotal))
1642 {
1643 ret = ((double)minfo->dot_clock /
1644 ((double)minfo->htotal *
1645 (double)minfo->vtotal));
1646 }
1647 break;
1648 }
1649 xcb_randr_mode_info_next(&miter);
1650 }
1651 free(reply);
1952 } 1652 }
1953 free(reply);
1954 } 1653 }
1955#endif 1654#endif
1956 return ret; 1655 return ret;
@@ -1970,96 +1669,92 @@ ecore_x_randr_move_crtcs(Ecore_X_Window root, const Ecore_X_Randr_Crtc *crtcs, i
1970{ 1669{
1971 Eina_Bool ret = EINA_TRUE; 1670 Eina_Bool ret = EINA_TRUE;
1972#ifdef ECORE_XCB_RANDR 1671#ifdef ECORE_XCB_RANDR
1973 xcb_randr_get_screen_resources_cookie_t cookie; 1672 xcb_timestamp_t stamp = 0;
1974 xcb_randr_get_screen_resources_reply_t *reply; 1673 xcb_randr_get_crtc_info_reply_t *oreply[num];
1674 int i = 0, cw = 0, ch = 0;
1675 int mw = 0, mh = 0, nw = 0, nh = 0;
1975#endif 1676#endif
1976 1677
1977 LOGFN(__FILE__, __LINE__, __FUNCTION__); 1678 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1978 CHECK_XCB_CONN;
1979
1980 if (!_randr_avail) return EINA_FALSE;
1981 1679
1982#ifdef ECORE_XCB_RANDR 1680#ifdef ECORE_XCB_RANDR
1681 RANDR_CHECK_1_2_RET(EINA_FALSE);
1682
1983 if (!_ecore_xcb_randr_root_validate(root)) return EINA_FALSE; 1683 if (!_ecore_xcb_randr_root_validate(root)) return EINA_FALSE;
1984 1684
1985 cookie = xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, root); 1685 if (_randr_version >= RANDR_1_3)
1986 reply = xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL); 1686 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
1987 if (reply) 1687 else if (_randr_version == RANDR_1_2)
1988 { 1688 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
1989 xcb_randr_get_crtc_info_reply_t *oreply[num]; 1689
1990 int i = 0, cw = 0, ch = 0; 1690 ecore_x_randr_screen_size_range_get(root, NULL, NULL, &mw, &mh);
1991 int mw = 0, mh = 0, nw = 0, nh = 0; 1691 ecore_x_randr_screen_current_size_get(root, &cw, &ch, NULL, NULL);
1692 nw = cw;
1693 nh = ch;
1992 1694
1993 ecore_x_randr_screen_size_range_get(root, NULL, NULL, &mw, &mh); 1695 for (i = 0; i < num; i++)
1994 ecore_x_randr_screen_current_size_get(root, &cw, &ch, NULL, NULL); 1696 {
1995 nw = cw; 1697 xcb_randr_get_crtc_info_cookie_t ocookie;
1996 nh = ch;
1997 1698
1998 for (i = 0; i < num; i++) 1699 ocookie =
1700 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtcs[i],
1701 stamp);
1702 oreply[i] = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn,
1703 ocookie, NULL);
1704 if (oreply[i])
1999 { 1705 {
2000 xcb_randr_get_crtc_info_cookie_t ocookie; 1706 if (((oreply[i]->x + dx) < 0) ||
2001 1707 ((oreply[i]->y + dy) < 0) ||
2002 ocookie = 1708 ((oreply[i]->x + oreply[i]->width + dx) > mw) ||
2003 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtcs[i], 1709 ((oreply[i]->y + oreply[i]->height + dy) > mh))
2004 reply->config_timestamp);
2005 oreply[i] = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn,
2006 ocookie, NULL);
2007 if (oreply[i])
2008 { 1710 {
2009 if (((oreply[i]->x + dx) < 0) || 1711 continue;
2010 ((oreply[i]->y + dy) < 0) ||
2011 ((oreply[i]->x + oreply[i]->width + dx) > mw) ||
2012 ((oreply[i]->y + oreply[i]->height + dy) > mh))
2013 {
2014 continue;
2015 }
2016 nw = MAX((int)(oreply[i]->x + oreply[i]->width + dx), nw);
2017 nh = MAX((int)(oreply[i]->y + oreply[i]->height + dy), nh);
2018 } 1712 }
1713 nw = MAX((int)(oreply[i]->x + oreply[i]->width + dx), nw);
1714 nh = MAX((int)(oreply[i]->y + oreply[i]->height + dy), nh);
2019 } 1715 }
2020 free(reply); 1716 }
2021 1717
2022 if ((nw > cw) || (nh > ch)) 1718 if ((nw > cw) || (nh > ch))
1719 {
1720 if (!ecore_x_randr_screen_current_size_set(root, nw, nh, -1, -1))
2023 { 1721 {
2024 if (!ecore_x_randr_screen_current_size_set(root, nw, nh, -1, -1)) 1722 for (i = 0; i < num; i++)
2025 { 1723 if (oreply[i]) free(oreply[i]);
2026 for (i = 0; i < num; i++)
2027 if (oreply[i]) free(oreply[i]);
2028 1724
2029 return EINA_FALSE; 1725 return EINA_FALSE;
2030 }
2031 } 1726 }
1727 }
2032 1728
2033 for (i = 0; ((i < num) && (oreply[i])); i++) 1729 for (i = 0; ((i < num) && (oreply[i])); i++)
1730 {
1731 if (!oreply[i]) continue;
1732 if (!ecore_x_randr_crtc_settings_set(root, crtcs[i], NULL, -1,
1733 (oreply[i]->x + dx),
1734 (oreply[i]->y + dy),
1735 oreply[i]->mode,
1736 oreply[i]->rotation))
2034 { 1737 {
2035 if (!oreply[i]) continue; 1738 ret = EINA_FALSE;
2036 if (!ecore_x_randr_crtc_settings_set(root, crtcs[i], NULL, -1, 1739 break;
2037 (oreply[i]->x + dx),
2038 (oreply[i]->y + dy),
2039 oreply[i]->mode,
2040 oreply[i]->rotation))
2041 {
2042 ret = EINA_FALSE;
2043 break;
2044 }
2045 } 1740 }
1741 }
2046 1742
2047 if (i < num) 1743 if (i < num)
1744 {
1745 while (i-- >= 0)
2048 { 1746 {
2049 while (i-- >= 0) 1747 if (oreply[i])
2050 { 1748 ecore_x_randr_crtc_settings_set(root, crtcs[i], NULL, -1,
2051 if (oreply[i]) 1749 (oreply[i]->x - dx),
2052 ecore_x_randr_crtc_settings_set(root, crtcs[i], NULL, -1, 1750 (oreply[i]->y - dy),
2053 (oreply[i]->x - dx), 1751 oreply[i]->mode,
2054 (oreply[i]->y - dy), 1752 oreply[i]->rotation);
2055 oreply[i]->mode,
2056 oreply[i]->rotation);
2057 }
2058 } 1753 }
2059
2060 for (i = 0; i < num; i++)
2061 if (oreply[i]) free(oreply[i]);
2062 } 1754 }
1755
1756 for (i = 0; i < num; i++)
1757 if (oreply[i]) free(oreply[i]);
2063#endif 1758#endif
2064 1759
2065 return ret; 1760 return ret;
@@ -2079,9 +1774,6 @@ ecore_x_randr_events_select(Ecore_X_Window win, Eina_Bool on)
2079#endif 1774#endif
2080 1775
2081 LOGFN(__FILE__, __LINE__, __FUNCTION__); 1776 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2082 CHECK_XCB_CONN;
2083
2084 if (!_randr_avail) return;
2085 1777
2086#ifdef ECORE_XCB_RANDR 1778#ifdef ECORE_XCB_RANDR
2087 if (on) 1779 if (on)
@@ -2108,70 +1800,66 @@ EAPI void
2108ecore_x_randr_screen_reset(Ecore_X_Window root) 1800ecore_x_randr_screen_reset(Ecore_X_Window root)
2109{ 1801{
2110#ifdef ECORE_XCB_RANDR 1802#ifdef ECORE_XCB_RANDR
2111 xcb_randr_get_screen_resources_cookie_t cookie; 1803 xcb_timestamp_t stamp = 0;
2112 xcb_randr_get_screen_resources_reply_t *reply;
2113 Ecore_X_Randr_Crtc *crtcs = NULL; 1804 Ecore_X_Randr_Crtc *crtcs = NULL;
2114 int total = 0, i = 0, w = 0, h = 0; 1805 int total = 0, i = 0, w = 0, h = 0;
2115 int dx = 100000, dy = 100000, num = 0; 1806 int dx = 100000, dy = 100000, num = 0;
2116#endif 1807#endif
2117 1808
2118 LOGFN(__FILE__, __LINE__, __FUNCTION__); 1809 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2119 CHECK_XCB_CONN;
2120
2121 if (!_randr_avail) return;
2122 1810
2123#ifdef ECORE_XCB_RANDR 1811#ifdef ECORE_XCB_RANDR
2124 if (!_ecore_xcb_randr_root_validate(root)) return; 1812 if (!_ecore_xcb_randr_root_validate(root)) return;
2125 crtcs = ecore_x_randr_crtcs_get(root, &total); 1813 crtcs = ecore_x_randr_crtcs_get(root, &total);
2126 1814
2127 cookie = xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, root); 1815 if (_randr_version >= RANDR_1_3)
2128 reply = xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL); 1816 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
2129 if (reply) 1817 else if (_randr_version == RANDR_1_2)
1818 stamp = _ecore_xcb_randr_12_get_resource_timestamp(root);
1819
1820 /* I hate declaring variables inside code like this, but we need the
1821 * value of 'total' before we can */
1822 Ecore_X_Randr_Crtc enabled[total];
1823
1824 for (i = 0; i < total; i++)
2130 { 1825 {
2131 Ecore_X_Randr_Crtc enabled[total]; 1826 xcb_randr_get_crtc_info_cookie_t ocookie;
1827 xcb_randr_get_crtc_info_reply_t *oreply;
2132 1828
2133 for (i = 0; i < total; i++) 1829 ocookie =
1830 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtcs[i], stamp);
1831 oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn,
1832 ocookie, NULL);
1833 if (!oreply) continue;
1834 if ((oreply->mode <= 0) || (oreply->num_outputs == 0))
2134 { 1835 {
2135 xcb_randr_get_crtc_info_cookie_t ocookie; 1836 free(oreply);
2136 xcb_randr_get_crtc_info_reply_t *oreply; 1837 continue;
2137 1838 }
2138 ocookie =
2139 xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtcs[i],
2140 reply->config_timestamp);
2141 oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn,
2142 ocookie, NULL);
2143 if (!oreply) continue;
2144 if ((oreply->mode <= 0) || (oreply->num_outputs == 0))
2145 {
2146 free(oreply);
2147 continue;
2148 }
2149 1839
2150 enabled[num++] = crtcs[i]; 1840 enabled[num++] = crtcs[i];
2151 if ((int)(oreply->x + oreply->width) > w) 1841 if ((int)(oreply->x + oreply->width) > w)
2152 w = (oreply->x + oreply->width); 1842 w = (oreply->x + oreply->width);
2153 if ((int)(oreply->y + oreply->height) > h) 1843 if ((int)(oreply->y + oreply->height) > h)
2154 h = (oreply->y + oreply->height); 1844 h = (oreply->y + oreply->height);
2155 1845
2156 if (oreply->x < dx) dx = oreply->x; 1846 if (oreply->x < dx) dx = oreply->x;
2157 if (oreply->y < dy) dy = oreply->y; 1847 if (oreply->y < dy) dy = oreply->y;
2158 1848
2159 free(oreply); 1849 free(oreply);
2160 } 1850 }
2161 free(reply); 1851 free(crtcs);
2162 free(crtcs);
2163 1852
2164 if ((dx > 0) || (dy > 0)) 1853 if ((dx > 0) || (dy > 0))
1854 {
1855 if (ecore_x_randr_move_crtcs(root, enabled, num, -dx, -dy))
2165 { 1856 {
2166 if (ecore_x_randr_move_crtcs(root, enabled, num, -dx, -dy)) 1857 w -= dx;
2167 { 1858 h -= dy;
2168 w -= dx;
2169 h -= dy;
2170 }
2171 } 1859 }
2172
2173 ecore_x_randr_screen_current_size_set(root, w, h, -1, -1);
2174 } 1860 }
1861
1862 ecore_x_randr_screen_current_size_set(root, w, h, -1, -1);
2175#endif 1863#endif
2176} 1864}
2177 1865
@@ -2191,11 +1879,10 @@ ecore_x_randr_screen_size_range_get(Ecore_X_Window root, int *minw, int *minh, i
2191#endif 1879#endif
2192 1880
2193 LOGFN(__FILE__, __LINE__, __FUNCTION__); 1881 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2194 CHECK_XCB_CONN;
2195
2196 if (!_randr_avail) return;
2197 1882
2198#ifdef ECORE_XCB_RANDR 1883#ifdef ECORE_XCB_RANDR
1884 RANDR_CHECK_1_2_RET();
1885
2199 cookie = xcb_randr_get_screen_size_range_unchecked(_ecore_xcb_conn, root); 1886 cookie = xcb_randr_get_screen_size_range_unchecked(_ecore_xcb_conn, root);
2200 reply = xcb_randr_get_screen_size_range_reply(_ecore_xcb_conn, cookie, NULL); 1887 reply = xcb_randr_get_screen_size_range_reply(_ecore_xcb_conn, cookie, NULL);
2201 if (reply) 1888 if (reply)
@@ -2217,45 +1904,24 @@ EAPI void
2217ecore_x_randr_screen_current_size_get(Ecore_X_Window root, int *w, int *h, int *w_mm, int *h_mm) 1904ecore_x_randr_screen_current_size_get(Ecore_X_Window root, int *w, int *h, int *w_mm, int *h_mm)
2218{ 1905{
2219#ifdef ECORE_XCB_RANDR 1906#ifdef ECORE_XCB_RANDR
2220 xcb_randr_get_screen_info_cookie_t cookie; 1907 Ecore_X_Randr_Screen scr = 0;
2221 xcb_randr_get_screen_info_reply_t *reply; 1908 xcb_screen_t *s;
2222 Ecore_X_Randr_Screen scr;
2223# define RANDR_VALIDATE_ROOT(screen, root) \ 1909# define RANDR_VALIDATE_ROOT(screen, root) \
2224 ((screen == _ecore_xcb_randr_root_to_screen(root)) != -1) 1910 ((screen == _ecore_xcb_randr_root_to_screen(root)) != -1)
2225#endif 1911#endif
2226 1912
2227 LOGFN(__FILE__, __LINE__, __FUNCTION__); 1913 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2228 CHECK_XCB_CONN;
2229
2230 if (!_randr_avail) return;
2231 1914
2232#ifdef ECORE_XCB_RANDR 1915#ifdef ECORE_XCB_RANDR
2233 if (!RANDR_VALIDATE_ROOT(scr, root)) return; 1916 RANDR_CHECK_1_2_RET();
2234 1917
2235 cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root); 1918 if (!RANDR_VALIDATE_ROOT(scr, root)) return;
2236 reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL);
2237 if (reply)
2238 {
2239 int len = 0, idx = 0;
2240 xcb_randr_screen_size_t *sizes;
2241 1919
2242 len = xcb_randr_get_screen_info_sizes_length(reply); 1920 s = ecore_x_screen_get(scr);
2243 sizes = xcb_randr_get_screen_info_sizes(reply); 1921 if (w) *w = s->width_in_pixels;
2244 if ((!sizes) || (len <= 0)) 1922 if (h) *h = s->height_in_pixels;
2245 { 1923 if (w_mm) *w_mm = s->width_in_millimeters;
2246 free(reply); 1924 if (h_mm) *h_mm = s->height_in_millimeters;
2247 return;
2248 }
2249 idx = reply->sizeID;
2250 if ((idx < len) && (idx >= 0))
2251 {
2252 if (w) *w = sizes[idx].width;
2253 if (h) *h = sizes[idx].height;
2254 if (w_mm) *w_mm = sizes[idx].mwidth;
2255 if (h_mm) *h_mm = sizes[idx].mheight;
2256 }
2257 free(reply);
2258 }
2259#endif 1925#endif
2260} 1926}
2261 1927
@@ -2281,11 +1947,10 @@ ecore_x_randr_screen_current_size_set(Ecore_X_Window root, int w, int h, int w_m
2281#endif 1947#endif
2282 1948
2283 LOGFN(__FILE__, __LINE__, __FUNCTION__); 1949 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2284 CHECK_XCB_CONN;
2285
2286 if (!_randr_avail) return EINA_FALSE;
2287 1950
2288#ifdef ECORE_XCB_RANDR 1951#ifdef ECORE_XCB_RANDR
1952 RANDR_CHECK_1_2_RET(EINA_FALSE);
1953
2289 if (!RANDR_VALIDATE_ROOT(scr, root)) return EINA_FALSE; 1954 if (!RANDR_VALIDATE_ROOT(scr, root)) return EINA_FALSE;
2290 ecore_x_randr_screen_current_size_get(root, &wc, &hc, &w_mm_c, &h_mm_c); 1955 ecore_x_randr_screen_current_size_get(root, &wc, &hc, &w_mm_c, &h_mm_c);
2291 if ((w == wc) && (h == hc) && (w_mm == w_mm_c) && (h_mm == h_mm_c)) 1956 if ((w == wc) && (h == hc) && (w_mm == w_mm_c) && (h_mm == h_mm_c))
@@ -2293,10 +1958,13 @@ ecore_x_randr_screen_current_size_set(Ecore_X_Window root, int w, int h, int w_m
2293 ecore_x_randr_screen_size_range_get(root, &mw, &mh, &xw, &xh); 1958 ecore_x_randr_screen_size_range_get(root, &mw, &mh, &xw, &xh);
2294 if (((w != 1) && ((w < mw) || (w > xw))) || 1959 if (((w != 1) && ((w < mw) || (w > xw))) ||
2295 ((h != -1) && ((h < mh) || (h > xh)))) return EINA_FALSE; 1960 ((h != -1) && ((h < mh) || (h > xh)))) return EINA_FALSE;
1961
2296 if (w <= 0) 1962 if (w <= 0)
2297 w = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_pixels; 1963 w = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_pixels;
2298 if (h <= 0) 1964 if (h <= 0)
2299 h = ((xcb_screen_t *)_ecore_xcb_screen)->height_in_pixels; 1965 h = ((xcb_screen_t *)_ecore_xcb_screen)->height_in_pixels;
1966
1967 /* NB: Hmmmm, xlib version divides w_mm by width ... that seems wrong */
2300 if (w_mm <= 0) 1968 if (w_mm <= 0)
2301 w_mm = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_millimeters; 1969 w_mm = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_millimeters;
2302 if (h_mm <= 0) 1970 if (h_mm <= 0)
@@ -2325,17 +1993,16 @@ ecore_x_randr_window_outputs_get(Ecore_X_Window window, int *num)
2325 Ecore_X_Randr_Mode mode; 1993 Ecore_X_Randr_Mode mode;
2326 Ecore_X_Randr_Output *outputs, *ret = NULL, *tret; 1994 Ecore_X_Randr_Output *outputs, *ret = NULL, *tret;
2327 int ncrtcs, noutputs, i, nret = 0; 1995 int ncrtcs, noutputs, i, nret = 0;
1996 xcb_translate_coordinates_cookie_t cookie;
2328 xcb_translate_coordinates_reply_t *trans; 1997 xcb_translate_coordinates_reply_t *trans;
2329#endif 1998#endif
2330 1999
2331 LOGFN(__FILE__, __LINE__, __FUNCTION__); 2000 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2332 CHECK_XCB_CONN;
2333 2001
2334 if (num) *num = 0; 2002 if (num) *num = 0;
2335 if (!_randr_avail) return NULL;
2336 2003
2337#ifdef ECORE_XCB_RANDR 2004#ifdef ECORE_XCB_RANDR
2338 if (_randr_version < ((1 << 16) | 2)) return NULL; 2005 RANDR_CHECK_1_2_RET(NULL);
2339 2006
2340 ecore_x_window_geometry_get(window, &w_geo.x, &w_geo.y, &w_geo.w, &w_geo.h); 2007 ecore_x_window_geometry_get(window, &w_geo.x, &w_geo.y, &w_geo.w, &w_geo.h);
2341 2008
@@ -2344,11 +2011,8 @@ ecore_x_randr_window_outputs_get(Ecore_X_Window window, int *num)
2344 if (!crtcs) return NULL; 2011 if (!crtcs) return NULL;
2345 2012
2346 /* now get window RELATIVE to root window - thats what matters. */ 2013 /* now get window RELATIVE to root window - thats what matters. */
2347 trans = 2014 cookie = xcb_translate_coordinates(_ecore_xcb_conn, window, root, 0, 0);
2348 xcb_translate_coordinates_reply(_ecore_xcb_conn, 2015 trans = xcb_translate_coordinates_reply(_ecore_xcb_conn, cookie, NULL);
2349 xcb_translate_coordinates(_ecore_xcb_conn,
2350 window, root, 0, 0),
2351 NULL);
2352 w_geo.x = trans->dst_x; 2016 w_geo.x = trans->dst_x;
2353 w_geo.y = trans->dst_y; 2017 w_geo.y = trans->dst_y;
2354 free(trans); 2018 free(trans);
@@ -2374,7 +2038,8 @@ ecore_x_randr_window_outputs_get(Ecore_X_Window window, int *num)
2374 free(crtcs); 2038 free(crtcs);
2375 return NULL; 2039 return NULL;
2376 } 2040 }
2377 tret = realloc(ret, ((nret + noutputs) * sizeof(Ecore_X_Randr_Output))); 2041 tret = realloc(ret, ((nret + noutputs) *
2042 sizeof(Ecore_X_Randr_Output)));
2378 if (!tret) 2043 if (!tret)
2379 { 2044 {
2380 if (num) *num = 0; 2045 if (num) *num = 0;
@@ -2422,11 +2087,10 @@ ecore_x_randr_output_backlight_level_get(Ecore_X_Window root, Ecore_X_Randr_Outp
2422#endif 2087#endif
2423 2088
2424 LOGFN(__FILE__, __LINE__, __FUNCTION__); 2089 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2425 CHECK_XCB_CONN;
2426
2427 if (!_randr_avail) return -1;
2428 2090
2429#ifdef ECORE_XCB_RANDR 2091#ifdef ECORE_XCB_RANDR
2092 RANDR_CHECK_1_2_RET(-1);
2093
2430 acookie = 2094 acookie =
2431 xcb_intern_atom_unchecked(_ecore_xcb_conn, 1, 2095 xcb_intern_atom_unchecked(_ecore_xcb_conn, 1,
2432 strlen("Backlight"), "Backlight"); 2096 strlen("Backlight"), "Backlight");
@@ -2518,11 +2182,10 @@ ecore_x_randr_output_backlight_level_set(Ecore_X_Window root, Ecore_X_Randr_Outp
2518#endif 2182#endif
2519 2183
2520 LOGFN(__FILE__, __LINE__, __FUNCTION__); 2184 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2521 CHECK_XCB_CONN;
2522
2523 if (!_randr_avail) return EINA_FALSE;
2524 2185
2525#ifdef ECORE_XCB_RANDR 2186#ifdef ECORE_XCB_RANDR
2187 RANDR_CHECK_1_2_RET(EINA_FALSE);
2188
2526 if ((level < 0) || (level > 1)) 2189 if ((level < 0) || (level > 1))
2527 { 2190 {
2528 ERR("Backlight level should be between 0 and 1"); 2191 ERR("Backlight level should be between 0 and 1");
@@ -2574,7 +2237,7 @@ ecore_x_randr_output_backlight_level_set(Ecore_X_Window root, Ecore_X_Randr_Outp
2574 _backlight, XCB_ATOM_INTEGER, 2237 _backlight, XCB_ATOM_INTEGER,
2575 32, XCB_PROP_MODE_REPLACE, 2238 32, XCB_PROP_MODE_REPLACE,
2576 1, (unsigned char *)&n); 2239 1, (unsigned char *)&n);
2577// ecore_x_flush(); // needed 2240 ecore_x_flush(); // needed
2578 } 2241 }
2579 2242
2580 free(qreply); 2243 free(qreply);
@@ -2591,36 +2254,59 @@ _ecore_xcb_randr_output_validate(Ecore_X_Window root, Ecore_X_Randr_Output outpu
2591 Eina_Bool ret = EINA_FALSE; 2254 Eina_Bool ret = EINA_FALSE;
2592 2255
2593 LOGFN(__FILE__, __LINE__, __FUNCTION__); 2256 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2594 CHECK_XCB_CONN;
2595
2596 if (!_randr_avail) return EINA_FALSE;
2597 2257
2598#ifdef ECORE_XCB_RANDR 2258#ifdef ECORE_XCB_RANDR
2259 RANDR_CHECK_1_2_RET(EINA_FALSE);
2260
2599 if ((output) && (_ecore_xcb_randr_root_validate(root))) 2261 if ((output) && (_ecore_xcb_randr_root_validate(root)))
2600 { 2262 {
2601 xcb_randr_get_screen_resources_cookie_t cookie; 2263 if (_randr_version >= RANDR_1_3)
2602 xcb_randr_get_screen_resources_reply_t *reply; 2264 {
2265 xcb_randr_get_screen_resources_current_reply_t *reply;
2603 2266
2604 cookie = 2267 reply = _ecore_xcb_randr_13_get_resources(root);
2605 xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, root); 2268 if (reply)
2606 reply = 2269 {
2607 xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL); 2270 int len = 0, i = 0;
2608 if (reply) 2271 xcb_randr_output_t *outputs;
2272
2273 len =
2274 xcb_randr_get_screen_resources_current_outputs_length(reply);
2275 outputs =
2276 xcb_randr_get_screen_resources_current_outputs(reply);
2277 for (i = 0; i < len; i++)
2278 {
2279 if (outputs[i] == output)
2280 {
2281 ret = EINA_TRUE;
2282 break;
2283 }
2284 }
2285 free(reply);
2286 }
2287 }
2288 else if (_randr_version == RANDR_1_2)
2609 { 2289 {
2610 int len = 0, i = 0; 2290 xcb_randr_get_screen_resources_reply_t *reply;
2611 xcb_randr_output_t *outputs;
2612 2291
2613 len = xcb_randr_get_screen_resources_outputs_length(reply); 2292 reply = _ecore_xcb_randr_12_get_resources(root);
2614 outputs = xcb_randr_get_screen_resources_outputs(reply); 2293 if (reply)
2615 for (i = 0; i < len; i++)
2616 { 2294 {
2617 if (outputs[i] == output) 2295 int len = 0, i = 0;
2296 xcb_randr_output_t *outputs;
2297
2298 len = xcb_randr_get_screen_resources_outputs_length(reply);
2299 outputs = xcb_randr_get_screen_resources_outputs(reply);
2300 for (i = 0; i < len; i++)
2618 { 2301 {
2619 ret = EINA_TRUE; 2302 if (outputs[i] == output)
2620 break; 2303 {
2304 ret = EINA_TRUE;
2305 break;
2306 }
2621 } 2307 }
2308 free(reply);
2622 } 2309 }
2623 free(reply);
2624 } 2310 }
2625 } 2311 }
2626#endif 2312#endif
@@ -2639,41 +2325,851 @@ _ecore_xcb_randr_crtc_validate(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc)
2639 Eina_Bool ret = EINA_FALSE; 2325 Eina_Bool ret = EINA_FALSE;
2640 2326
2641 LOGFN(__FILE__, __LINE__, __FUNCTION__); 2327 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2642 CHECK_XCB_CONN;
2643
2644 if (!_randr_avail) return EINA_FALSE;
2645 2328
2646#ifdef ECORE_XCB_RANDR 2329#ifdef ECORE_XCB_RANDR
2330 RANDR_CHECK_1_2_RET(EINA_FALSE);
2331
2647 if (((int)crtc == Ecore_X_Randr_None) || ((int)crtc == Ecore_X_Randr_Unset)) 2332 if (((int)crtc == Ecore_X_Randr_None) || ((int)crtc == Ecore_X_Randr_Unset))
2648 return ret; 2333 return ret;
2649 2334
2650 if ((crtc) && (_ecore_xcb_randr_root_validate(root))) 2335 if ((crtc) && (_ecore_xcb_randr_root_validate(root)))
2651 { 2336 {
2652 xcb_randr_get_screen_resources_cookie_t cookie; 2337 if (_randr_version >= RANDR_1_3)
2653 xcb_randr_get_screen_resources_reply_t *reply; 2338 {
2339 xcb_randr_get_screen_resources_current_reply_t *reply;
2654 2340
2655 cookie = 2341 reply = _ecore_xcb_randr_13_get_resources(root);
2656 xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, root); 2342 if (reply)
2657 reply = 2343 {
2658 xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL); 2344 int i = 0;
2659 if (reply) 2345 xcb_randr_crtc_t *crtcs;
2346
2347 crtcs = xcb_randr_get_screen_resources_current_crtcs(reply);
2348 for (i = 0; i < reply->num_crtcs; i++)
2349 {
2350 if (crtcs[i] == crtc)
2351 {
2352 ret = EINA_TRUE;
2353 break;
2354 }
2355 }
2356 free(reply);
2357 }
2358 }
2359 else if (_randr_version == RANDR_1_2)
2360 {
2361 xcb_randr_get_screen_resources_reply_t *reply;
2362
2363 reply = _ecore_xcb_randr_12_get_resources(root);
2364 if (reply)
2365 {
2366 int i = 0;
2367 xcb_randr_crtc_t *crtcs;
2368
2369 crtcs = xcb_randr_get_screen_resources_crtcs(reply);
2370 for (i = 0; i < reply->num_crtcs; i++)
2371 {
2372 if (crtcs[i] == crtc)
2373 {
2374 ret = EINA_TRUE;
2375 break;
2376 }
2377 }
2378 free(reply);
2379 }
2380 }
2381 }
2382#endif
2383
2384 return ret;
2385}
2386
2387static Ecore_X_Randr_Mode *
2388_ecore_xcb_randr_12_output_modes_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *num, int *npreferred)
2389{
2390 Ecore_X_Randr_Mode *modes = NULL;
2391 xcb_randr_get_screen_resources_reply_t *reply;
2392
2393 reply = _ecore_xcb_randr_12_get_resources(root);
2394 if (reply)
2395 {
2396 xcb_randr_get_output_info_cookie_t ocookie;
2397 xcb_randr_get_output_info_reply_t *oreply;
2398
2399 ocookie =
2400 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
2401 reply->config_timestamp);
2402 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
2403 ocookie, NULL);
2404 if (oreply)
2660 { 2405 {
2406 if (num) *num = oreply->num_modes;
2407 if (npreferred) *npreferred = oreply->num_preferred;
2408
2409 modes = malloc(sizeof(Ecore_X_Randr_Mode) *
2410 oreply->num_modes);
2411 if (modes)
2412 {
2413 xcb_randr_mode_t *rmodes;
2414 int len = 0;
2415
2416 len = xcb_randr_get_output_info_modes_length(oreply);
2417 rmodes = xcb_randr_get_output_info_modes(oreply);
2418 memcpy(modes, rmodes, sizeof(Ecore_X_Randr_Mode) * len);
2419 }
2420 free(oreply);
2421 }
2422 free(reply);
2423 }
2424
2425 return modes;
2426}
2427
2428static Ecore_X_Randr_Mode *
2429_ecore_xcb_randr_13_output_modes_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *num, int *npreferred)
2430{
2431 Ecore_X_Randr_Mode *modes = NULL;
2432 xcb_timestamp_t stamp = 0;
2433 xcb_randr_get_output_info_cookie_t ocookie;
2434 xcb_randr_get_output_info_reply_t *oreply;
2435
2436 stamp = _ecore_xcb_randr_13_get_resource_timestamp(root);
2437
2438 ocookie =
2439 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output, stamp);
2440 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn, ocookie, NULL);
2441 if (oreply)
2442 {
2443 if (num) *num = oreply->num_modes;
2444 if (npreferred) *npreferred = oreply->num_preferred;
2445
2446 modes = malloc(sizeof(Ecore_X_Randr_Mode) * oreply->num_modes);
2447 if (modes)
2448 {
2449 xcb_randr_mode_t *rmodes;
2450 int len = 0;
2451
2452 len = xcb_randr_get_output_info_modes_length(oreply);
2453 rmodes = xcb_randr_get_output_info_modes(oreply);
2454 memcpy(modes, rmodes, sizeof(Ecore_X_Randr_Mode) * len);
2455 }
2456 free(oreply);
2457 }
2458
2459 return modes;
2460}
2461
2462static Ecore_X_Randr_Mode_Info *
2463_ecore_xcb_randr_12_mode_info_get(Ecore_X_Window root, Ecore_X_Randr_Mode mode)
2464{
2465 Ecore_X_Randr_Mode_Info *ret = NULL;
2466 xcb_randr_get_screen_resources_reply_t *reply;
2467
2468 reply = _ecore_xcb_randr_12_get_resources(root);
2469 if (reply)
2470 {
2471 if ((ret = malloc(sizeof(Ecore_X_Randr_Mode_Info))))
2472 {
2473 uint8_t *nbuf;
2474 xcb_randr_mode_info_iterator_t miter;
2475
2476 nbuf = xcb_randr_get_screen_resources_names(reply);
2477 miter = xcb_randr_get_screen_resources_modes_iterator(reply);
2478 while (miter.rem)
2479 {
2480 xcb_randr_mode_info_t *minfo;
2481
2482 minfo = miter.data;
2483 nbuf += minfo->name_len;
2484
2485 if (minfo->id == mode)
2486 {
2487 ret->xid = minfo->id;
2488 ret->width = minfo->width;
2489 ret->height = minfo->height;
2490 ret->dotClock = minfo->dot_clock;
2491 ret->hSyncStart = minfo->hsync_start;
2492 ret->hSyncEnd = minfo->hsync_end;
2493 ret->hTotal = minfo->htotal;
2494 ret->vSyncStart = minfo->vsync_start;
2495 ret->vSyncEnd = minfo->vsync_end;
2496 ret->vTotal = minfo->vtotal;
2497 ret->modeFlags = minfo->mode_flags;
2498
2499 ret->name = NULL;
2500 ret->nameLength = minfo->name_len;
2501 if (ret->nameLength > 0)
2502 {
2503 ret->name = malloc(ret->nameLength + 1);
2504 if (ret->name)
2505 memcpy(ret->name, nbuf, ret->nameLength + 1);
2506 }
2507
2508 break;
2509 }
2510 xcb_randr_mode_info_next(&miter);
2511 }
2512 }
2513
2514 free(reply);
2515 }
2516 return ret;
2517}
2518
2519static Ecore_X_Randr_Mode_Info *
2520_ecore_xcb_randr_13_mode_info_get(Ecore_X_Window root, Ecore_X_Randr_Mode mode)
2521{
2522 Ecore_X_Randr_Mode_Info *ret = NULL;
2523 xcb_randr_get_screen_resources_current_reply_t *reply;
2524
2525 reply = _ecore_xcb_randr_13_get_resources(root);
2526 if (reply)
2527 {
2528 if ((ret = malloc(sizeof(Ecore_X_Randr_Mode_Info))))
2529 {
2530 uint8_t *nbuf;
2531 xcb_randr_mode_info_iterator_t miter;
2532
2533 nbuf = xcb_randr_get_screen_resources_current_names(reply);
2534 miter =
2535 xcb_randr_get_screen_resources_current_modes_iterator(reply);
2536 while (miter.rem)
2537 {
2538 xcb_randr_mode_info_t *minfo;
2539
2540 minfo = miter.data;
2541 nbuf += minfo->name_len;
2542
2543 if (minfo->id == mode)
2544 {
2545 ret->xid = minfo->id;
2546 ret->width = minfo->width;
2547 ret->height = minfo->height;
2548 ret->dotClock = minfo->dot_clock;
2549 ret->hSyncStart = minfo->hsync_start;
2550 ret->hSyncEnd = minfo->hsync_end;
2551 ret->hTotal = minfo->htotal;
2552 ret->vSyncStart = minfo->vsync_start;
2553 ret->vSyncEnd = minfo->vsync_end;
2554 ret->vTotal = minfo->vtotal;
2555 ret->modeFlags = minfo->mode_flags;
2556
2557 ret->name = NULL;
2558 ret->nameLength = minfo->name_len;
2559 if (ret->nameLength > 0)
2560 {
2561 ret->name = malloc(ret->nameLength + 1);
2562 if (ret->name)
2563 memcpy(ret->name, nbuf, ret->nameLength + 1);
2564 }
2565
2566 break;
2567 }
2568 xcb_randr_mode_info_next(&miter);
2569 }
2570 }
2571
2572 free(reply);
2573 }
2574 return ret;
2575}
2576
2577static Ecore_X_Randr_Mode_Info **
2578_ecore_xcb_randr_12_modes_info_get(Ecore_X_Window root, int *num)
2579{
2580 Ecore_X_Randr_Mode_Info **ret = NULL;
2581 xcb_randr_get_screen_resources_reply_t *reply;
2582
2583 reply = _ecore_xcb_randr_12_get_resources(root);
2584 if (reply)
2585 {
2586 if (num) *num = reply->num_modes;
2587 ret = malloc(sizeof(Ecore_X_Randr_Mode_Info *) * reply->num_modes);
2588 if (ret)
2589 {
2590 xcb_randr_mode_info_iterator_t miter;
2661 int i = 0; 2591 int i = 0;
2662 xcb_randr_crtc_t *crtcs; 2592 uint8_t *nbuf;
2663 2593
2664 crtcs = xcb_randr_get_screen_resources_crtcs(reply); 2594 nbuf = xcb_randr_get_screen_resources_names(reply);
2665 for (i = 0; i < reply->num_crtcs; i++) 2595 miter = xcb_randr_get_screen_resources_modes_iterator(reply);
2596 while (miter.rem)
2666 { 2597 {
2667 if (crtcs[i] == crtc) 2598 xcb_randr_mode_info_t *minfo;
2599
2600 minfo = miter.data;
2601 nbuf += minfo->name_len;
2602 if ((ret[i] = malloc(sizeof(Ecore_X_Randr_Mode_Info))))
2668 { 2603 {
2669 ret = EINA_TRUE; 2604 ret[i]->xid = minfo->id;
2605 ret[i]->width = minfo->width;
2606 ret[i]->height = minfo->height;
2607 ret[i]->dotClock = minfo->dot_clock;
2608 ret[i]->hSyncStart = minfo->hsync_start;
2609 ret[i]->hSyncEnd = minfo->hsync_end;
2610 ret[i]->hTotal = minfo->htotal;
2611 ret[i]->vSyncStart = minfo->vsync_start;
2612 ret[i]->vSyncEnd = minfo->vsync_end;
2613 ret[i]->vTotal = minfo->vtotal;
2614 ret[i]->modeFlags = minfo->mode_flags;
2615
2616 ret[i]->name = NULL;
2617 ret[i]->nameLength = minfo->name_len;
2618 if (ret[i]->nameLength > 0)
2619 {
2620 ret[i]->name = malloc(ret[i]->nameLength + 1);
2621 if (ret[i]->name)
2622 memcpy(ret[i]->name, nbuf,
2623 ret[i]->nameLength + 1);
2624 }
2625 }
2626 else
2627 {
2628 while (i > 0)
2629 free(ret[--i]);
2630 free(ret);
2631 ret = NULL;
2670 break; 2632 break;
2671 } 2633 }
2634 i++;
2635 xcb_randr_mode_info_next(&miter);
2672 } 2636 }
2673 free(reply);
2674 } 2637 }
2638 free(reply);
2675 } 2639 }
2676#endif 2640 return ret;
2641}
2642
2643static Ecore_X_Randr_Mode_Info **
2644_ecore_xcb_randr_13_modes_info_get(Ecore_X_Window root, int *num)
2645{
2646 Ecore_X_Randr_Mode_Info **ret = NULL;
2647 xcb_randr_get_screen_resources_current_reply_t *reply;
2648
2649 reply = _ecore_xcb_randr_13_get_resources(root);
2650 if (reply)
2651 {
2652 if (num) *num = reply->num_modes;
2653 ret = malloc(sizeof(Ecore_X_Randr_Mode_Info *) * reply->num_modes);
2654 if (ret)
2655 {
2656 xcb_randr_mode_info_iterator_t miter;
2657 int i = 0;
2658 uint8_t *nbuf;
2659
2660 nbuf = xcb_randr_get_screen_resources_current_names(reply);
2661 miter =
2662 xcb_randr_get_screen_resources_current_modes_iterator(reply);
2663 while (miter.rem)
2664 {
2665 xcb_randr_mode_info_t *minfo;
2666
2667 minfo = miter.data;
2668 nbuf += minfo->name_len;
2669 if ((ret[i] = malloc(sizeof(Ecore_X_Randr_Mode_Info))))
2670 {
2671 ret[i]->xid = minfo->id;
2672 ret[i]->width = minfo->width;
2673 ret[i]->height = minfo->height;
2674 ret[i]->dotClock = minfo->dot_clock;
2675 ret[i]->hSyncStart = minfo->hsync_start;
2676 ret[i]->hSyncEnd = minfo->hsync_end;
2677 ret[i]->hTotal = minfo->htotal;
2678 ret[i]->vSyncStart = minfo->vsync_start;
2679 ret[i]->vSyncEnd = minfo->vsync_end;
2680 ret[i]->vTotal = minfo->vtotal;
2681 ret[i]->modeFlags = minfo->mode_flags;
2682
2683 ret[i]->name = NULL;
2684 ret[i]->nameLength = minfo->name_len;
2685 if (ret[i]->nameLength > 0)
2686 {
2687 ret[i]->name = malloc(ret[i]->nameLength + 1);
2688 if (ret[i]->name)
2689 memcpy(ret[i]->name, nbuf,
2690 ret[i]->nameLength + 1);
2691 }
2692 }
2693 else
2694 {
2695 while (i > 0)
2696 free(ret[--i]);
2697 free(ret);
2698 ret = NULL;
2699 break;
2700 }
2701 i++;
2702 xcb_randr_mode_info_next(&miter);
2703 }
2704 }
2705 free(reply);
2706 }
2707 return ret;
2708}
2709
2710static void
2711_ecore_xcb_randr_12_mode_size_get(Ecore_X_Window root, Ecore_X_Randr_Mode mode, int *w, int *h)
2712{
2713 xcb_randr_get_screen_resources_reply_t *reply;
2714
2715 reply = _ecore_xcb_randr_12_get_resources(root);
2716 if (reply)
2717 {
2718 xcb_randr_mode_info_iterator_t miter;
2719
2720 miter = xcb_randr_get_screen_resources_modes_iterator(reply);
2721 while (miter.rem)
2722 {
2723 xcb_randr_mode_info_t *minfo;
2724
2725 minfo = miter.data;
2726 if (minfo->id == mode)
2727 {
2728 if (w) *w = minfo->width;
2729 if (h) *h = minfo->height;
2730 break;
2731 }
2732 xcb_randr_mode_info_next(&miter);
2733 }
2734 free(reply);
2735 }
2736}
2737
2738static void
2739_ecore_xcb_randr_13_mode_size_get(Ecore_X_Window root, Ecore_X_Randr_Mode mode, int *w, int *h)
2740{
2741 xcb_randr_get_screen_resources_current_reply_t *reply;
2742
2743 reply = _ecore_xcb_randr_13_get_resources(root);
2744 if (reply)
2745 {
2746 xcb_randr_mode_info_iterator_t miter;
2747
2748 miter = xcb_randr_get_screen_resources_current_modes_iterator(reply);
2749 while (miter.rem)
2750 {
2751 xcb_randr_mode_info_t *minfo;
2752
2753 minfo = miter.data;
2754 if (minfo->id == mode)
2755 {
2756 if (w) *w = minfo->width;
2757 if (h) *h = minfo->height;
2758 break;
2759 }
2760 xcb_randr_mode_info_next(&miter);
2761 }
2762 free(reply);
2763 }
2764}
2765
2766static Ecore_X_Randr_Output *
2767_ecore_xcb_randr_12_output_clones_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *num)
2768{
2769 Ecore_X_Randr_Output *outputs = NULL;
2770 xcb_randr_get_screen_resources_reply_t *reply;
2771
2772 reply = _ecore_xcb_randr_12_get_resources(root);
2773 if (reply)
2774 {
2775 xcb_randr_get_output_info_cookie_t ocookie;
2776 xcb_randr_get_output_info_reply_t *oreply;
2777
2778 ocookie =
2779 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
2780 reply->config_timestamp);
2781 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
2782 ocookie, NULL);
2783 if (oreply)
2784 {
2785 if (num) *num = oreply->num_clones;
2786
2787 outputs =
2788 malloc(sizeof(Ecore_X_Randr_Output) * oreply->num_clones);
2789 if (outputs)
2790 {
2791 memcpy(outputs, xcb_randr_get_output_info_clones(oreply),
2792 sizeof(Ecore_X_Randr_Output) * oreply->num_clones);
2793 }
2794 free(oreply);
2795 }
2796 free(reply);
2797 }
2798 return outputs;
2799}
2677 2800
2801static Ecore_X_Randr_Output *
2802_ecore_xcb_randr_13_output_clones_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *num)
2803{
2804 Ecore_X_Randr_Output *outputs = NULL;
2805 xcb_randr_get_screen_resources_current_reply_t *reply;
2806
2807 reply = _ecore_xcb_randr_13_get_resources(root);
2808 if (reply)
2809 {
2810 xcb_randr_get_output_info_cookie_t ocookie;
2811 xcb_randr_get_output_info_reply_t *oreply;
2812
2813 ocookie =
2814 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
2815 reply->config_timestamp);
2816 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
2817 ocookie, NULL);
2818 if (oreply)
2819 {
2820 if (num) *num = oreply->num_clones;
2821
2822 outputs =
2823 malloc(sizeof(Ecore_X_Randr_Output) * oreply->num_clones);
2824 if (outputs)
2825 {
2826 memcpy(outputs, xcb_randr_get_output_info_clones(oreply),
2827 sizeof(Ecore_X_Randr_Output) * oreply->num_clones);
2828 }
2829 free(oreply);
2830 }
2831 free(reply);
2832 }
2833 return outputs;
2834}
2835
2836static Ecore_X_Randr_Crtc *
2837_ecore_xcb_randr_12_output_possible_crtcs_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *num)
2838{
2839 Ecore_X_Randr_Crtc *crtcs = NULL;
2840 xcb_randr_get_screen_resources_reply_t *reply;
2841
2842 reply = _ecore_xcb_randr_12_get_resources(root);
2843 if (reply)
2844 {
2845 xcb_randr_get_output_info_cookie_t ocookie;
2846 xcb_randr_get_output_info_reply_t *oreply;
2847
2848 ocookie =
2849 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
2850 reply->config_timestamp);
2851 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
2852 ocookie, NULL);
2853 if (oreply)
2854 {
2855 if (num) *num = oreply->num_crtcs;
2856
2857 crtcs = malloc(sizeof(Ecore_X_Randr_Crtc) * oreply->num_crtcs);
2858 if (crtcs)
2859 {
2860 memcpy(crtcs, xcb_randr_get_output_info_crtcs(oreply),
2861 sizeof(Ecore_X_Randr_Crtc) * oreply->num_crtcs);
2862 }
2863 free(oreply);
2864 }
2865 free(reply);
2866 }
2867 return crtcs;
2868}
2869
2870static Ecore_X_Randr_Crtc *
2871_ecore_xcb_randr_13_output_possible_crtcs_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *num)
2872{
2873 Ecore_X_Randr_Crtc *crtcs = NULL;
2874 xcb_randr_get_screen_resources_current_reply_t *reply;
2875
2876 reply = _ecore_xcb_randr_13_get_resources(root);
2877 if (reply)
2878 {
2879 xcb_randr_get_output_info_cookie_t ocookie;
2880 xcb_randr_get_output_info_reply_t *oreply;
2881
2882 ocookie =
2883 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
2884 reply->config_timestamp);
2885 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
2886 ocookie, NULL);
2887 if (oreply)
2888 {
2889 if (num) *num = oreply->num_crtcs;
2890
2891 crtcs = malloc(sizeof(Ecore_X_Randr_Crtc) * oreply->num_crtcs);
2892 if (crtcs)
2893 {
2894 memcpy(crtcs, xcb_randr_get_output_info_crtcs(oreply),
2895 sizeof(Ecore_X_Randr_Crtc) * oreply->num_crtcs);
2896 }
2897 free(oreply);
2898 }
2899 free(reply);
2900 }
2901 return crtcs;
2902}
2903
2904static char *
2905_ecore_xcb_randr_12_output_name_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *len)
2906{
2907 char *ret = NULL;
2908 xcb_randr_get_screen_resources_reply_t *reply;
2909
2910 reply = _ecore_xcb_randr_12_get_resources(root);
2911 if (reply)
2912 {
2913 xcb_randr_get_output_info_cookie_t ocookie;
2914 xcb_randr_get_output_info_reply_t *oreply;
2915
2916 ocookie =
2917 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
2918 reply->config_timestamp);
2919 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
2920 ocookie, NULL);
2921 if (oreply)
2922 {
2923 uint8_t *nbuf;
2924
2925 nbuf = xcb_randr_get_output_info_name(oreply);
2926 nbuf += oreply->name_len;
2927
2928 if (len) *len = oreply->name_len;
2929 if (oreply->name_len > 0)
2930 {
2931 ret = malloc(oreply->name_len + 1);
2932 if (ret)
2933 memcpy(ret, nbuf, oreply->name_len + 1);
2934 }
2935
2936 free(oreply);
2937 }
2938 free(reply);
2939 }
2678 return ret; 2940 return ret;
2679} 2941}
2942
2943static char *
2944_ecore_xcb_randr_13_output_name_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *len)
2945{
2946 char *ret = NULL;
2947 xcb_randr_get_screen_resources_current_reply_t *reply;
2948
2949 reply = _ecore_xcb_randr_13_get_resources(root);
2950 if (reply)
2951 {
2952 xcb_randr_get_output_info_cookie_t ocookie;
2953 xcb_randr_get_output_info_reply_t *oreply;
2954
2955 ocookie =
2956 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
2957 reply->config_timestamp);
2958 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
2959 ocookie, NULL);
2960 if (oreply)
2961 {
2962 uint8_t *nbuf;
2963
2964 nbuf = xcb_randr_get_output_info_name(oreply);
2965 nbuf += oreply->name_len;
2966
2967 if (len) *len = oreply->name_len;
2968 if (oreply->name_len > 0)
2969 {
2970 ret = malloc(oreply->name_len + 1);
2971 if (ret)
2972 memcpy(ret, nbuf, oreply->name_len + 1);
2973 }
2974
2975 free(oreply);
2976 }
2977 free(reply);
2978 }
2979 return ret;
2980}
2981
2982static Ecore_X_Randr_Connection_Status
2983_ecore_xcb_randr_12_output_connection_status_get(Ecore_X_Window root, Ecore_X_Randr_Output output)
2984{
2985 Ecore_X_Randr_Connection_Status ret = ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN;
2986 xcb_randr_get_screen_resources_reply_t *reply;
2987
2988 reply = _ecore_xcb_randr_12_get_resources(root);
2989 if (reply)
2990 {
2991 xcb_randr_get_output_info_cookie_t ocookie;
2992 xcb_randr_get_output_info_reply_t *oreply;
2993
2994 ocookie =
2995 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
2996 reply->config_timestamp);
2997 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
2998 ocookie, NULL);
2999 if (oreply)
3000 {
3001 ret = oreply->connection;
3002 free(oreply);
3003 }
3004 free(reply);
3005 }
3006 return ret;
3007}
3008
3009static Ecore_X_Randr_Connection_Status
3010_ecore_xcb_randr_13_output_connection_status_get(Ecore_X_Window root, Ecore_X_Randr_Output output)
3011{
3012 Ecore_X_Randr_Connection_Status ret = ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN;
3013 xcb_randr_get_screen_resources_current_reply_t *reply;
3014
3015 reply = _ecore_xcb_randr_13_get_resources(root);
3016 if (reply)
3017 {
3018 xcb_randr_get_output_info_cookie_t ocookie;
3019 xcb_randr_get_output_info_reply_t *oreply;
3020
3021 ocookie =
3022 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
3023 reply->config_timestamp);
3024 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
3025 ocookie, NULL);
3026 if (oreply)
3027 {
3028 ret = oreply->connection;
3029 free(oreply);
3030 }
3031 free(reply);
3032 }
3033 return ret;
3034}
3035
3036static Ecore_X_Randr_Output *
3037_ecore_xcb_randr_12_outputs_get(Ecore_X_Window root, int *num)
3038{
3039 Ecore_X_Randr_Output *ret = NULL;
3040 xcb_randr_get_screen_resources_reply_t *reply;
3041
3042 reply = _ecore_xcb_randr_12_get_resources(root);
3043 if (reply)
3044 {
3045 if (num) *num = reply->num_outputs;
3046 ret = malloc(sizeof(Ecore_X_Randr_Output) * reply->num_outputs);
3047 if (ret)
3048 memcpy(ret, xcb_randr_get_screen_resources_outputs(reply),
3049 sizeof(Ecore_X_Randr_Output) * reply->num_outputs);
3050 free(reply);
3051 }
3052 return ret;
3053}
3054
3055static Ecore_X_Randr_Output *
3056_ecore_xcb_randr_13_outputs_get(Ecore_X_Window root, int *num)
3057{
3058 Ecore_X_Randr_Output *ret = NULL;
3059 xcb_randr_get_screen_resources_current_reply_t *reply;
3060
3061 reply = _ecore_xcb_randr_13_get_resources(root);
3062 if (reply)
3063 {
3064 if (num) *num = reply->num_outputs;
3065 ret = malloc(sizeof(Ecore_X_Randr_Output) * reply->num_outputs);
3066 if (ret)
3067 memcpy(ret, xcb_randr_get_screen_resources_current_outputs(reply),
3068 sizeof(Ecore_X_Randr_Output) * reply->num_outputs);
3069 free(reply);
3070 }
3071 return ret;
3072}
3073
3074static Ecore_X_Randr_Crtc
3075_ecore_xcb_randr_12_output_crtc_get(Ecore_X_Window root, Ecore_X_Randr_Output output)
3076{
3077 Ecore_X_Randr_Crtc ret = Ecore_X_Randr_None;
3078 xcb_randr_get_screen_resources_reply_t *reply;
3079
3080 reply = _ecore_xcb_randr_12_get_resources(root);
3081 if (reply)
3082 {
3083 xcb_randr_get_output_info_cookie_t ocookie;
3084 xcb_randr_get_output_info_reply_t *oreply;
3085
3086 ocookie =
3087 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
3088 reply->config_timestamp);
3089 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
3090 ocookie, NULL);
3091 if (oreply)
3092 {
3093 ret = oreply->crtc;
3094 free(oreply);
3095 }
3096 free(reply);
3097 }
3098 return ret;
3099}
3100
3101static Ecore_X_Randr_Crtc
3102_ecore_xcb_randr_13_output_crtc_get(Ecore_X_Window root, Ecore_X_Randr_Output output)
3103{
3104 Ecore_X_Randr_Crtc ret = Ecore_X_Randr_None;
3105 xcb_randr_get_screen_resources_current_reply_t *reply;
3106
3107 reply = _ecore_xcb_randr_13_get_resources(root);
3108 if (reply)
3109 {
3110 xcb_randr_get_output_info_cookie_t ocookie;
3111 xcb_randr_get_output_info_reply_t *oreply;
3112
3113 ocookie =
3114 xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output,
3115 reply->config_timestamp);
3116 oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn,
3117 ocookie, NULL);
3118 if (oreply)
3119 {
3120 ret = oreply->crtc;
3121 free(oreply);
3122 }
3123 free(reply);
3124 }
3125 return ret;
3126}
3127
3128static xcb_randr_get_screen_resources_reply_t *
3129_ecore_xcb_randr_12_get_resources(Ecore_X_Window win)
3130{
3131 xcb_randr_get_screen_resources_cookie_t cookie;
3132 xcb_randr_get_screen_resources_reply_t *reply;
3133
3134 cookie = xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, win);
3135 reply = xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL);
3136 return reply;
3137}
3138
3139static xcb_randr_get_screen_resources_current_reply_t *
3140_ecore_xcb_randr_13_get_resources(Ecore_X_Window win)
3141{
3142 xcb_randr_get_screen_resources_current_cookie_t cookie;
3143 xcb_randr_get_screen_resources_current_reply_t *reply;
3144
3145 cookie =
3146 xcb_randr_get_screen_resources_current_unchecked(_ecore_xcb_conn, win);
3147 reply =
3148 xcb_randr_get_screen_resources_current_reply(_ecore_xcb_conn,
3149 cookie, NULL);
3150 return reply;
3151}
3152
3153static xcb_timestamp_t
3154_ecore_xcb_randr_12_get_resource_timestamp(Ecore_X_Window win)
3155{
3156 xcb_timestamp_t stamp = 0;
3157 xcb_randr_get_screen_resources_reply_t *reply;
3158
3159 reply = _ecore_xcb_randr_12_get_resources(win);
3160 stamp = reply->config_timestamp;
3161 free(reply);
3162 return stamp;
3163}
3164
3165static xcb_timestamp_t
3166_ecore_xcb_randr_13_get_resource_timestamp(Ecore_X_Window win)
3167{
3168 xcb_timestamp_t stamp = 0;
3169 xcb_randr_get_screen_resources_current_reply_t *reply;
3170
3171 reply = _ecore_xcb_randr_13_get_resources(win);
3172 stamp = reply->config_timestamp;
3173 free(reply);
3174 return stamp;
3175}