aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c')
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c339
1 files changed, 182 insertions, 157 deletions
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c
index fb607d1..38218a5 100644
--- a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c
@@ -8,6 +8,10 @@
8 8
9#include "ecore_x_private.h" 9#include "ecore_x_private.h"
10#include "ecore_x_randr.h" 10#include "ecore_x_randr.h"
11#include <stdio.h>
12#include <stdlib.h>
13#include <unistd.h>
14#include <string.h>
11 15
12#define Ecore_X_Randr_None (Ecore_X_Randr_Crtc)0 16#define Ecore_X_Randr_None (Ecore_X_Randr_Crtc)0
13#define Ecore_X_Randr_Unset (Ecore_X_Randr_Crtc) - 1 17#define Ecore_X_Randr_Unset (Ecore_X_Randr_Crtc) - 1
@@ -19,7 +23,8 @@
19#define RANDR_VALIDATE_ROOT(screen, root) \ 23#define RANDR_VALIDATE_ROOT(screen, root) \
20 ((screen = XRRRootToScreen(_ecore_x_disp, root)) != -1) 24 ((screen = XRRRootToScreen(_ecore_x_disp, root)) != -1)
21 25
22#define RANDR_CHECK_1_2_RET(ret) if(_randr_version < RANDR_1_2) return ret 26#define RANDR_CHECK_1_2_RET(ret) if (_randr_version < RANDR_1_2) \
27 return ret
23 28
24#define RANDR_PROPERTY_EDID "EDID" 29#define RANDR_PROPERTY_EDID "EDID"
25#define RANDR_PROPERTY_BACKLIGHT "Backlight" 30#define RANDR_PROPERTY_BACKLIGHT "Backlight"
@@ -45,7 +50,7 @@ extern int _randr_version;
45 */ 50 */
46EAPI void 51EAPI void
47ecore_x_randr_events_select(Ecore_X_Window win, 52ecore_x_randr_events_select(Ecore_X_Window win,
48 Eina_Bool on) 53 Eina_Bool on)
49{ 54{
50#ifdef ECORE_XRANDR 55#ifdef ECORE_XRANDR
51 int mask; 56 int mask;
@@ -73,7 +78,7 @@ ecore_x_randr_events_select(Ecore_X_Window win,
73 * @return in case it is found EINA_TRUE will be returned. Else EINA_FALSE is returned. 78 * @return in case it is found EINA_TRUE will be returned. Else EINA_FALSE is returned.
74 */ 79 */
75static inline Eina_Bool 80static inline Eina_Bool
76_ecore_x_randr_crtc_validate(Ecore_X_Window root, 81_ecore_x_randr_crtc_validate(Ecore_X_Window root,
77 Ecore_X_Randr_Crtc crtc) 82 Ecore_X_Randr_Crtc crtc)
78{ 83{
79#ifdef ECORE_XRANDR 84#ifdef ECORE_XRANDR
@@ -108,7 +113,7 @@ _ecore_x_randr_crtc_validate(Ecore_X_Window root,
108} 113}
109 114
110Eina_Bool 115Eina_Bool
111_ecore_x_randr_output_validate(Ecore_X_Window root, 116_ecore_x_randr_output_validate(Ecore_X_Window root,
112 Ecore_X_Randr_Output output) 117 Ecore_X_Randr_Output output)
113{ 118{
114#ifdef ECORE_XRANDR 119#ifdef ECORE_XRANDR
@@ -139,7 +144,7 @@ _ecore_x_randr_output_validate(Ecore_X_Window root,
139} 144}
140 145
141static inline Eina_Bool 146static inline Eina_Bool
142_ecore_x_randr_mode_validate(Ecore_X_Window root, 147_ecore_x_randr_mode_validate(Ecore_X_Window root,
143 Ecore_X_Randr_Mode mode) 148 Ecore_X_Randr_Mode mode)
144{ 149{
145#ifdef ECORE_XRANDR 150#ifdef ECORE_XRANDR
@@ -175,10 +180,10 @@ _ecore_x_randr_mode_validate(Ecore_X_Window root,
175 */ 180 */
176EAPI void 181EAPI void
177ecore_x_randr_screen_current_size_get(Ecore_X_Window root, 182ecore_x_randr_screen_current_size_get(Ecore_X_Window root,
178 int *w, 183 int *w,
179 int *h, 184 int *h,
180 int *w_mm, 185 int *w_mm,
181 int *h_mm) 186 int *h_mm)
182{ 187{
183#ifdef ECORE_XRANDR 188#ifdef ECORE_XRANDR
184 RANDR_CHECK_1_2_RET(); 189 RANDR_CHECK_1_2_RET();
@@ -211,10 +216,10 @@ ecore_x_randr_screen_current_size_get(Ecore_X_Window root,
211 */ 216 */
212EAPI void 217EAPI void
213ecore_x_randr_screen_size_range_get(Ecore_X_Window root, 218ecore_x_randr_screen_size_range_get(Ecore_X_Window root,
214 int *wmin, 219 int *wmin,
215 int *hmin, 220 int *hmin,
216 int *wmax, 221 int *wmax,
217 int *hmax) 222 int *hmax)
218{ 223{
219#ifdef ECORE_XRANDR 224#ifdef ECORE_XRANDR
220 RANDR_CHECK_1_2_RET(); 225 RANDR_CHECK_1_2_RET();
@@ -249,10 +254,10 @@ ecore_x_randr_screen_size_range_get(Ecore_X_Window root,
249 */ 254 */
250EAPI Eina_Bool 255EAPI Eina_Bool
251ecore_x_randr_screen_current_size_set(Ecore_X_Window root, 256ecore_x_randr_screen_current_size_set(Ecore_X_Window root,
252 int w, 257 int w,
253 int h, 258 int h,
254 int w_mm, 259 int w_mm,
255 int h_mm) 260 int h_mm)
256{ 261{
257#ifdef ECORE_XRANDR 262#ifdef ECORE_XRANDR
258 RANDR_CHECK_1_2_RET(EINA_FALSE); 263 RANDR_CHECK_1_2_RET(EINA_FALSE);
@@ -281,14 +286,14 @@ ecore_x_randr_screen_current_size_set(Ecore_X_Window root,
281 if (h <= 0) 286 if (h <= 0)
282 h = DisplayHeight(_ecore_x_disp, scr); 287 h = DisplayHeight(_ecore_x_disp, scr);
283 288
284 if(w_mm <= 0) 289 if (w_mm <= 0)
285 w_mm = 290 w_mm =
286 (int)(((double)(DisplayWidthMM(_ecore_x_disp, 291 (int)(((double)(DisplayWidthMM(_ecore_x_disp,
287 scr) / 292 scr) /
288 (double)DisplayWidth(_ecore_x_disp, 293 (double)DisplayWidth(_ecore_x_disp,
289 scr))) * (double)w); 294 scr))) * (double)w);
290 295
291 if(h_mm <= 0) 296 if (h_mm <= 0)
292 h_mm = 297 h_mm =
293 (int)(((double)(DisplayHeightMM(_ecore_x_disp, 298 (int)(((double)(DisplayHeightMM(_ecore_x_disp,
294 scr) / 299 scr) /
@@ -310,7 +315,7 @@ ecore_x_randr_screen_current_size_set(Ecore_X_Window root,
310 */ 315 */
311EAPI Ecore_X_Randr_Mode_Info ** 316EAPI Ecore_X_Randr_Mode_Info **
312ecore_x_randr_modes_info_get(Ecore_X_Window root, 317ecore_x_randr_modes_info_get(Ecore_X_Window root,
313 int *num) 318 int *num)
314{ 319{
315#ifdef ECORE_XRANDR 320#ifdef ECORE_XRANDR
316 RANDR_CHECK_1_2_RET(NULL); 321 RANDR_CHECK_1_2_RET(NULL);
@@ -353,7 +358,7 @@ ecore_x_randr_modes_info_get(Ecore_X_Window root,
353 } 358 }
354 else 359 else
355 { 360 {
356 while(i > 0) 361 while (i > 0)
357 free(ret[--i]); 362 free(ret[--i]);
358 free(ret); 363 free(ret);
359 ret = NULL; 364 ret = NULL;
@@ -381,7 +386,7 @@ ecore_x_randr_modes_info_get(Ecore_X_Window root,
381 * @return mode's detailed information 386 * @return mode's detailed information
382 */ 387 */
383EAPI Ecore_X_Randr_Mode_Info * 388EAPI Ecore_X_Randr_Mode_Info *
384ecore_x_randr_mode_info_get(Ecore_X_Window root, 389ecore_x_randr_mode_info_get(Ecore_X_Window root,
385 Ecore_X_Randr_Mode mode) 390 Ecore_X_Randr_Mode mode)
386{ 391{
387#ifdef ECORE_XRANDR 392#ifdef ECORE_XRANDR
@@ -461,7 +466,7 @@ ecore_x_randr_mode_info_free(Ecore_X_Randr_Mode_Info *mode_info)
461 */ 466 */
462EAPI Ecore_X_Randr_Crtc * 467EAPI Ecore_X_Randr_Crtc *
463ecore_x_randr_crtcs_get(Ecore_X_Window root, 468ecore_x_randr_crtcs_get(Ecore_X_Window root,
464 int *num) 469 int *num)
465{ 470{
466#ifdef ECORE_XRANDR 471#ifdef ECORE_XRANDR
467 RANDR_CHECK_1_2_RET(NULL); 472 RANDR_CHECK_1_2_RET(NULL);
@@ -488,7 +493,7 @@ ecore_x_randr_crtcs_get(Ecore_X_Window root,
488 493
489EAPI Ecore_X_Randr_Output * 494EAPI Ecore_X_Randr_Output *
490ecore_x_randr_outputs_get(Ecore_X_Window root, 495ecore_x_randr_outputs_get(Ecore_X_Window root,
491 int *num) 496 int *num)
492{ 497{
493#ifdef ECORE_XRANDR 498#ifdef ECORE_XRANDR
494 RANDR_CHECK_1_2_RET(NULL); 499 RANDR_CHECK_1_2_RET(NULL);
@@ -523,9 +528,9 @@ ecore_x_randr_outputs_get(Ecore_X_Window root,
523 * @param num number of outputs referenced by given CRTC 528 * @param num number of outputs referenced by given CRTC
524 */ 529 */
525EAPI Ecore_X_Randr_Output * 530EAPI Ecore_X_Randr_Output *
526ecore_x_randr_crtc_outputs_get(Ecore_X_Window root, 531ecore_x_randr_crtc_outputs_get(Ecore_X_Window root,
527 Ecore_X_Randr_Crtc crtc, 532 Ecore_X_Randr_Crtc crtc,
528 int *num) 533 int *num)
529{ 534{
530#ifdef ECORE_XRANDR 535#ifdef ECORE_XRANDR
531 RANDR_CHECK_1_2_RET(NULL); 536 RANDR_CHECK_1_2_RET(NULL);
@@ -567,9 +572,9 @@ ecore_x_randr_crtc_outputs_get(Ecore_X_Window root,
567 * @param num number of possible outputs referenced by given CRTC 572 * @param num number of possible outputs referenced by given CRTC
568 */ 573 */
569EAPI Ecore_X_Randr_Output * 574EAPI Ecore_X_Randr_Output *
570ecore_x_randr_crtc_possible_outputs_get(Ecore_X_Window root, 575ecore_x_randr_crtc_possible_outputs_get(Ecore_X_Window root,
571 Ecore_X_Randr_Crtc crtc, 576 Ecore_X_Randr_Crtc crtc,
572 int *num) 577 int *num)
573{ 578{
574#ifdef ECORE_XRANDR 579#ifdef ECORE_XRANDR
575 RANDR_CHECK_1_2_RET(NULL); 580 RANDR_CHECK_1_2_RET(NULL);
@@ -581,7 +586,7 @@ ecore_x_randr_crtc_possible_outputs_get(Ecore_X_Window root,
581 crtc) && 586 crtc) &&
582 (res = _ecore_x_randr_get_screen_resources (_ecore_x_disp, root))) 587 (res = _ecore_x_randr_get_screen_resources (_ecore_x_disp, root)))
583 { 588 {
584 if((crtc_info = XRRGetCrtcInfo(_ecore_x_disp, res, crtc))) 589 if ((crtc_info = XRRGetCrtcInfo(_ecore_x_disp, res, crtc)))
585 { 590 {
586 if ((ret = 591 if ((ret =
587 malloc(sizeof(Ecore_X_Randr_Output) * crtc_info->npossible))) 592 malloc(sizeof(Ecore_X_Randr_Output) * crtc_info->npossible)))
@@ -605,12 +610,12 @@ ecore_x_randr_crtc_possible_outputs_get(Ecore_X_Window root,
605} 610}
606 611
607EAPI void 612EAPI void
608ecore_x_randr_crtc_geometry_get(Ecore_X_Window root, 613ecore_x_randr_crtc_geometry_get(Ecore_X_Window root,
609 Ecore_X_Randr_Crtc crtc, 614 Ecore_X_Randr_Crtc crtc,
610 int *x, 615 int *x,
611 int *y, 616 int *y,
612 int *w, 617 int *w,
613 int *h) 618 int *h)
614{ 619{
615#ifdef ECORE_XRANDR 620#ifdef ECORE_XRANDR
616 RANDR_CHECK_1_2_RET(); 621 RANDR_CHECK_1_2_RET();
@@ -652,10 +657,10 @@ ecore_x_randr_crtc_geometry_get(Ecore_X_Window root,
652 * @return EINA_TRUE if position could be successfully be altered. 657 * @return EINA_TRUE if position could be successfully be altered.
653 */ 658 */
654EAPI Eina_Bool 659EAPI Eina_Bool
655ecore_x_randr_crtc_pos_set(Ecore_X_Window root, 660ecore_x_randr_crtc_pos_set(Ecore_X_Window root,
656 Ecore_X_Randr_Crtc crtc, 661 Ecore_X_Randr_Crtc crtc,
657 int x, 662 int x,
658 int y) 663 int y)
659{ 664{
660#ifdef ECORE_XRANDR 665#ifdef ECORE_XRANDR
661 RANDR_CHECK_1_2_RET(EINA_FALSE); 666 RANDR_CHECK_1_2_RET(EINA_FALSE);
@@ -706,7 +711,7 @@ ecore_x_randr_crtc_pos_set(Ecore_X_Window root,
706 * Ecore_X_Randr_Unset 711 * Ecore_X_Randr_Unset
707 */ 712 */
708EAPI Ecore_X_Randr_Mode 713EAPI Ecore_X_Randr_Mode
709ecore_x_randr_crtc_mode_get(Ecore_X_Window root, 714ecore_x_randr_crtc_mode_get(Ecore_X_Window root,
710 Ecore_X_Randr_Crtc crtc) 715 Ecore_X_Randr_Crtc crtc)
711{ 716{
712#ifdef ECORE_XRANDR 717#ifdef ECORE_XRANDR
@@ -746,11 +751,11 @@ ecore_x_randr_crtc_mode_get(Ecore_X_Window root,
746 * @return EINA_TRUE if mode setting was successful. Else EINA_FALSE 751 * @return EINA_TRUE if mode setting was successful. Else EINA_FALSE
747 */ 752 */
748EAPI Eina_Bool 753EAPI Eina_Bool
749ecore_x_randr_crtc_mode_set(Ecore_X_Window root, 754ecore_x_randr_crtc_mode_set(Ecore_X_Window root,
750 Ecore_X_Randr_Crtc crtc, 755 Ecore_X_Randr_Crtc crtc,
751 Ecore_X_Randr_Output *outputs, 756 Ecore_X_Randr_Output *outputs,
752 int noutputs, 757 int noutputs,
753 Ecore_X_Randr_Mode mode) 758 Ecore_X_Randr_Mode mode)
754{ 759{
755#ifdef ECORE_XRANDR 760#ifdef ECORE_XRANDR
756 RANDR_CHECK_1_2_RET(EINA_FALSE); 761 RANDR_CHECK_1_2_RET(EINA_FALSE);
@@ -772,10 +777,10 @@ ecore_x_randr_crtc_mode_set(Ecore_X_Window root,
772} 777}
773 778
774EAPI void 779EAPI void
775ecore_x_randr_crtc_size_get(Ecore_X_Window root, 780ecore_x_randr_crtc_size_get(Ecore_X_Window root,
776 Ecore_X_Randr_Crtc crtc, 781 Ecore_X_Randr_Crtc crtc,
777 int *w, 782 int *w,
778 int *h) 783 int *h)
779{ 784{
780#ifdef ECORE_XRANDR 785#ifdef ECORE_XRANDR
781 RANDR_CHECK_1_2_RET(); 786 RANDR_CHECK_1_2_RET();
@@ -784,7 +789,7 @@ ecore_x_randr_crtc_size_get(Ecore_X_Window root,
784} 789}
785 790
786EAPI Ecore_X_Randr_Refresh_Rate 791EAPI Ecore_X_Randr_Refresh_Rate
787ecore_x_randr_crtc_refresh_rate_get(Ecore_X_Window root, 792ecore_x_randr_crtc_refresh_rate_get(Ecore_X_Window root,
788 Ecore_X_Randr_Crtc crtc, 793 Ecore_X_Randr_Crtc crtc,
789 Ecore_X_Randr_Mode mode) 794 Ecore_X_Randr_Mode mode)
790{ 795{
@@ -824,7 +829,7 @@ ecore_x_randr_crtc_refresh_rate_get(Ecore_X_Window root,
824} 829}
825 830
826EAPI Ecore_X_Randr_Orientation 831EAPI Ecore_X_Randr_Orientation
827ecore_x_randr_crtc_orientations_get(Ecore_X_Window root, 832ecore_x_randr_crtc_orientations_get(Ecore_X_Window root,
828 Ecore_X_Randr_Crtc crtc) 833 Ecore_X_Randr_Crtc crtc)
829{ 834{
830#ifdef ECORE_XRANDR 835#ifdef ECORE_XRANDR
@@ -855,7 +860,7 @@ ecore_x_randr_crtc_orientations_get(Ecore_X_Window root,
855} 860}
856 861
857EAPI Ecore_X_Randr_Orientation 862EAPI Ecore_X_Randr_Orientation
858ecore_x_randr_crtc_orientation_get(Ecore_X_Window root, 863ecore_x_randr_crtc_orientation_get(Ecore_X_Window root,
859 Ecore_X_Randr_Crtc crtc) 864 Ecore_X_Randr_Crtc crtc)
860{ 865{
861#ifdef ECORE_XRANDR 866#ifdef ECORE_XRANDR
@@ -886,8 +891,8 @@ ecore_x_randr_crtc_orientation_get(Ecore_X_Window root,
886} 891}
887 892
888EAPI Eina_Bool 893EAPI Eina_Bool
889ecore_x_randr_crtc_orientation_set(Ecore_X_Window root, 894ecore_x_randr_crtc_orientation_set(Ecore_X_Window root,
890 Ecore_X_Randr_Crtc crtc, 895 Ecore_X_Randr_Crtc crtc,
891 Ecore_X_Randr_Orientation orientation) 896 Ecore_X_Randr_Orientation orientation)
892{ 897{
893#ifdef ECORE_XRANDR 898#ifdef ECORE_XRANDR
@@ -913,10 +918,10 @@ ecore_x_randr_crtc_orientation_set(Ecore_X_Window root,
913} 918}
914 919
915EAPI void 920EAPI void
916ecore_x_randr_crtc_pos_get(Ecore_X_Window root, 921ecore_x_randr_crtc_pos_get(Ecore_X_Window root,
917 Ecore_X_Randr_Crtc crtc, 922 Ecore_X_Randr_Crtc crtc,
918 int *x, 923 int *x,
919 int *y) 924 int *y)
920{ 925{
921#ifdef ECORE_XRANDR 926#ifdef ECORE_XRANDR
922 RANDR_CHECK_1_2_RET(); 927 RANDR_CHECK_1_2_RET();
@@ -926,7 +931,7 @@ ecore_x_randr_crtc_pos_get(Ecore_X_Window root,
926} 931}
927 932
928EAPI Eina_Bool 933EAPI Eina_Bool
929ecore_x_randr_crtc_clone_set(Ecore_X_Window root, 934ecore_x_randr_crtc_clone_set(Ecore_X_Window root,
930 Ecore_X_Randr_Crtc original, 935 Ecore_X_Randr_Crtc original,
931 Ecore_X_Randr_Crtc clon) 936 Ecore_X_Randr_Crtc clon)
932{ 937{
@@ -993,13 +998,13 @@ ecore_x_randr_crtc_clone_set(Ecore_X_Window root,
993 * EINA_FALSE 998 * EINA_FALSE
994 */ 999 */
995EAPI Eina_Bool 1000EAPI Eina_Bool
996ecore_x_randr_crtc_settings_set(Ecore_X_Window root, 1001ecore_x_randr_crtc_settings_set(Ecore_X_Window root,
997 Ecore_X_Randr_Crtc crtc, 1002 Ecore_X_Randr_Crtc crtc,
998 Ecore_X_Randr_Output *outputs, 1003 Ecore_X_Randr_Output *outputs,
999 int noutputs, 1004 int noutputs,
1000 int x, 1005 int x,
1001 int y, 1006 int y,
1002 Ecore_X_Randr_Mode mode, 1007 Ecore_X_Randr_Mode mode,
1003 Ecore_X_Randr_Orientation orientation) 1008 Ecore_X_Randr_Orientation orientation)
1004{ 1009{
1005#ifdef ECORE_XRANDR 1010#ifdef ECORE_XRANDR
@@ -1059,17 +1064,17 @@ ecore_x_randr_crtc_settings_set(Ecore_X_Window root,
1059 * @brief sets a CRTC relative to another one. 1064 * @brief sets a CRTC relative to another one.
1060 * @param crtc_r1 the CRTC to be positioned. 1065 * @param crtc_r1 the CRTC to be positioned.
1061 * @param crtc_r2 the CRTC the position should be relative to 1066 * @param crtc_r2 the CRTC the position should be relative to
1062 * @param position the relation between the crtcs 1067 * @param policy the relation between the crtcs
1063 * @param alignment in case CRTCs size differ, aligns CRTC1 accordingly at CRTC2's 1068 * @param alignment in case CRTCs size differ, aligns CRTC1 accordingly at CRTC2's
1064 * borders 1069 * borders
1065 * @return EINA_TRUE if crtc could be successfully positioned. EINA_FALSE if 1070 * @return EINA_TRUE if crtc could be successfully positioned. EINA_FALSE if
1066 * repositioning failed or if position of new crtc would be out of given screen's min/max bounds. 1071 * repositioning failed or if position of new crtc would be out of given screen's min/max bounds.
1067 */ 1072 */
1068EAPI Eina_Bool 1073EAPI Eina_Bool
1069ecore_x_randr_crtc_pos_relative_set(Ecore_X_Window root, 1074ecore_x_randr_crtc_pos_relative_set(Ecore_X_Window root,
1070 Ecore_X_Randr_Crtc crtc_r1, 1075 Ecore_X_Randr_Crtc crtc_r1,
1071 Ecore_X_Randr_Crtc crtc_r2, 1076 Ecore_X_Randr_Crtc crtc_r2,
1072 Ecore_X_Randr_Output_Policy policy, 1077 Ecore_X_Randr_Output_Policy policy,
1073 Ecore_X_Randr_Relative_Alignment alignment) 1078 Ecore_X_Randr_Relative_Alignment alignment)
1074{ 1079{
1075#ifdef ECORE_XRANDR 1080#ifdef ECORE_XRANDR
@@ -1360,10 +1365,10 @@ ecore_x_randr_crtc_pos_relative_set(Ecore_X_Window root,
1360} 1365}
1361 1366
1362EAPI Ecore_X_Randr_Mode * 1367EAPI Ecore_X_Randr_Mode *
1363ecore_x_randr_output_modes_get(Ecore_X_Window root, 1368ecore_x_randr_output_modes_get(Ecore_X_Window root,
1364 Ecore_X_Randr_Output output, 1369 Ecore_X_Randr_Output output,
1365 int *num, 1370 int *num,
1366 int *npreferred) 1371 int *npreferred)
1367{ 1372{
1368#ifdef ECORE_XRANDR 1373#ifdef ECORE_XRANDR
1369 RANDR_CHECK_1_2_RET(NULL); 1374 RANDR_CHECK_1_2_RET(NULL);
@@ -1401,9 +1406,9 @@ ecore_x_randr_output_modes_get(Ecore_X_Window root,
1401} 1406}
1402 1407
1403EAPI Ecore_X_Randr_Crtc * 1408EAPI Ecore_X_Randr_Crtc *
1404ecore_x_randr_output_possible_crtcs_get(Ecore_X_Window root, 1409ecore_x_randr_output_possible_crtcs_get(Ecore_X_Window root,
1405 Ecore_X_Randr_Output output, 1410 Ecore_X_Randr_Output output,
1406 int *num) 1411 int *num)
1407{ 1412{
1408#ifdef ECORE_XRANDR 1413#ifdef ECORE_XRANDR
1409 RANDR_CHECK_1_2_RET(NULL); 1414 RANDR_CHECK_1_2_RET(NULL);
@@ -1441,9 +1446,9 @@ ecore_x_randr_output_possible_crtcs_get(Ecore_X_Window root,
1441 * @param num number of possible clones 1446 * @param num number of possible clones
1442 */ 1447 */
1443EAPI Ecore_X_Randr_Output * 1448EAPI Ecore_X_Randr_Output *
1444ecore_x_randr_output_clones_get(Ecore_X_Window root, 1449ecore_x_randr_output_clones_get(Ecore_X_Window root,
1445 Ecore_X_Randr_Output output, 1450 Ecore_X_Randr_Output output,
1446 int *num) 1451 int *num)
1447{ 1452{
1448#ifdef ECORE_XRANDR 1453#ifdef ECORE_XRANDR
1449 RANDR_CHECK_1_2_RET(NULL); 1454 RANDR_CHECK_1_2_RET(NULL);
@@ -1474,7 +1479,7 @@ ecore_x_randr_output_clones_get(Ecore_X_Window root,
1474} 1479}
1475 1480
1476EAPI Ecore_X_Randr_Crtc 1481EAPI Ecore_X_Randr_Crtc
1477ecore_x_randr_output_crtc_get(Ecore_X_Window root, 1482ecore_x_randr_output_crtc_get(Ecore_X_Window root,
1478 Ecore_X_Randr_Output output) 1483 Ecore_X_Randr_Output output)
1479{ 1484{
1480#ifdef ECORE_XRANDR 1485#ifdef ECORE_XRANDR
@@ -1509,9 +1514,9 @@ ecore_x_randr_output_crtc_get(Ecore_X_Window root,
1509 * @return name of the output as reported by X 1514 * @return name of the output as reported by X
1510 */ 1515 */
1511EAPI char * 1516EAPI char *
1512ecore_x_randr_output_name_get(Ecore_X_Window root, 1517ecore_x_randr_output_name_get(Ecore_X_Window root,
1513 Ecore_X_Randr_Output output, 1518 Ecore_X_Randr_Output output,
1514 int *len) 1519 int *len)
1515{ 1520{
1516#ifdef ECORE_XRANDR 1521#ifdef ECORE_XRANDR
1517 RANDR_CHECK_1_2_RET(NULL); 1522 RANDR_CHECK_1_2_RET(NULL);
@@ -1532,10 +1537,10 @@ ecore_x_randr_output_name_get(Ecore_X_Window root,
1532 * *len = output_info->nameLen; 1537 * *len = output_info->nameLen;
1533 * 1538 *
1534 */ 1539 */
1535 if ((ret = strdup(output_info->name)) && len) 1540 if ((ret = strdup(output_info->name)) && len)
1536 *len = strlen(ret); 1541 *len = strlen(ret);
1537 1542
1538 XRRFreeOutputInfo(output_info); 1543 XRRFreeOutputInfo(output_info);
1539 } 1544 }
1540 1545
1541 if (res) 1546 if (res)
@@ -1554,10 +1559,10 @@ ecore_x_randr_output_name_get(Ecore_X_Window root,
1554 * @param h height of given mode in px 1559 * @param h height of given mode in px
1555 */ 1560 */
1556EAPI void 1561EAPI void
1557ecore_x_randr_mode_size_get(Ecore_X_Window root, 1562ecore_x_randr_mode_size_get(Ecore_X_Window root,
1558 Ecore_X_Randr_Mode mode, 1563 Ecore_X_Randr_Mode mode,
1559 int *w, 1564 int *w,
1560 int *h) 1565 int *h)
1561{ 1566{
1562#ifdef ECORE_XRANDR 1567#ifdef ECORE_XRANDR
1563 RANDR_CHECK_1_2_RET(); 1568 RANDR_CHECK_1_2_RET();
@@ -1598,9 +1603,9 @@ ecore_x_randr_mode_size_get(Ecore_X_Window root,
1598 * @param length length of the byte-array. If NULL, request will fail. 1603 * @param length length of the byte-array. If NULL, request will fail.
1599 */ 1604 */
1600EAPI unsigned char * 1605EAPI unsigned char *
1601ecore_x_randr_output_edid_get(Ecore_X_Window root, 1606ecore_x_randr_output_edid_get(Ecore_X_Window root,
1602 Ecore_X_Randr_Output output, 1607 Ecore_X_Randr_Output output,
1603 unsigned long *length) 1608 unsigned long *length)
1604{ 1609{
1605#ifdef ECORE_XRANDR 1610#ifdef ECORE_XRANDR
1606 RANDR_CHECK_1_2_RET(NULL); 1611 RANDR_CHECK_1_2_RET(NULL);
@@ -1613,18 +1618,18 @@ ecore_x_randr_output_edid_get(Ecore_X_Window root,
1613 if (!length || !_ecore_x_randr_output_validate(root, output)) 1618 if (!length || !_ecore_x_randr_output_validate(root, output))
1614 return NULL; 1619 return NULL;
1615 1620
1616 if(XRRGetOutputProperty (_ecore_x_disp, output, name, 1621 if (XRRGetOutputProperty (_ecore_x_disp, output, name,
1617 0, 100, False, False, 1622 0, 100, False, False,
1618 AnyPropertyType, 1623 AnyPropertyType,
1619 &actual_type, &actual_format, 1624 &actual_type, &actual_format,
1620 &nitems, &bytes_after, &prop_data) == Success) 1625 &nitems, &bytes_after, &prop_data) == Success)
1621 { 1626 {
1622 if (actual_type == XA_INTEGER && actual_format == 8) 1627 if (actual_type == XA_INTEGER && actual_format == 8)
1623 { 1628 {
1624 if ((ret = malloc(nitems * sizeof(unsigned char)))) 1629 if ((ret = malloc(nitems * sizeof(unsigned char))))
1625 { 1630 {
1626 if(length && 1631 if (length &&
1627 (memcpy(ret, prop_data, (nitems * sizeof(unsigned char))))) 1632 (memcpy(ret, prop_data, (nitems * sizeof(unsigned char)))))
1628 *length = nitems; 1633 *length = nitems;
1629 1634
1630 return ret; 1635 return ret;
@@ -1639,7 +1644,7 @@ ecore_x_randr_output_edid_get(Ecore_X_Window root,
1639} 1644}
1640 1645
1641EAPI Ecore_X_Randr_Connection_Status 1646EAPI Ecore_X_Randr_Connection_Status
1642ecore_x_randr_output_connection_status_get(Ecore_X_Window root, 1647ecore_x_randr_output_connection_status_get(Ecore_X_Window root,
1643 Ecore_X_Randr_Output output) 1648 Ecore_X_Randr_Output output)
1644{ 1649{
1645#ifdef ECORE_XRANDR 1650#ifdef ECORE_XRANDR
@@ -1669,10 +1674,10 @@ ecore_x_randr_output_connection_status_get(Ecore_X_Window root,
1669} 1674}
1670 1675
1671EAPI void 1676EAPI void
1672ecore_x_randr_output_size_mm_get(Ecore_X_Window root, 1677ecore_x_randr_output_size_mm_get(Ecore_X_Window root,
1673 Ecore_X_Randr_Output output, 1678 Ecore_X_Randr_Output output,
1674 int *w_mm, 1679 int *w_mm,
1675 int *h_mm) 1680 int *h_mm)
1676{ 1681{
1677#ifdef ECORE_XRANDR 1682#ifdef ECORE_XRANDR
1678 RANDR_CHECK_1_2_RET(); 1683 RANDR_CHECK_1_2_RET();
@@ -1701,11 +1706,11 @@ ecore_x_randr_output_size_mm_get(Ecore_X_Window root,
1701} 1706}
1702 1707
1703EAPI Eina_Bool 1708EAPI Eina_Bool
1704ecore_x_randr_move_all_crtcs_but(Ecore_X_Window root, 1709ecore_x_randr_move_all_crtcs_but(Ecore_X_Window root,
1705 const Ecore_X_Randr_Crtc *not_moved, 1710 const Ecore_X_Randr_Crtc *not_moved,
1706 int nnot_moved, 1711 int nnot_moved,
1707 int dx, 1712 int dx,
1708 int dy) 1713 int dy)
1709{ 1714{
1710#ifdef ECORE_XRANDR 1715#ifdef ECORE_XRANDR
1711 Ecore_X_Randr_Crtc *crtcs_to_be_moved = NULL; 1716 Ecore_X_Randr_Crtc *crtcs_to_be_moved = NULL;
@@ -1754,11 +1759,11 @@ ecore_x_randr_move_all_crtcs_but(Ecore_X_Window root,
1754 * @return EINA_TRUE if all crtcs could be moved successfully. 1759 * @return EINA_TRUE if all crtcs could be moved successfully.
1755 */ 1760 */
1756EAPI Eina_Bool 1761EAPI Eina_Bool
1757ecore_x_randr_move_crtcs(Ecore_X_Window root, 1762ecore_x_randr_move_crtcs(Ecore_X_Window root,
1758 const Ecore_X_Randr_Crtc *crtcs, 1763 const Ecore_X_Randr_Crtc *crtcs,
1759 int ncrtc, 1764 int ncrtc,
1760 int dx, 1765 int dx,
1761 int dy) 1766 int dy)
1762{ 1767{
1763#ifdef ECORE_XRANDR 1768#ifdef ECORE_XRANDR
1764 RANDR_CHECK_1_2_RET(EINA_FALSE); 1769 RANDR_CHECK_1_2_RET(EINA_FALSE);
@@ -1821,18 +1826,18 @@ ecore_x_randr_move_crtcs(Ecore_X_Window root,
1821 { 1826 {
1822 //something went wrong, let's try to move the already moved crtcs 1827 //something went wrong, let's try to move the already moved crtcs
1823 //back. 1828 //back.
1824 while ((i--) >= 0) 1829 while ((i--) >= 0)
1825 { 1830 {
1826 if (crtc_info[i]) 1831 if (crtc_info[i])
1827 ecore_x_randr_crtc_settings_set(root, 1832 ecore_x_randr_crtc_settings_set(root,
1828 crtcs[i], 1833 crtcs[i],
1829 NULL, 1834 NULL,
1830 Ecore_X_Randr_Unset, 1835 Ecore_X_Randr_Unset,
1831 (crtc_info[i]->x - dx), 1836 (crtc_info[i]->x - dx),
1832 (crtc_info[i]->y - dy), 1837 (crtc_info[i]->y - dy),
1833 crtc_info[i]->mode, 1838 crtc_info[i]->mode,
1834 crtc_info[i]->rotation); 1839 crtc_info[i]->rotation);
1835 } 1840 }
1836 } 1841 }
1837 1842
1838 for (i = 0; i < ncrtc; i++) 1843 for (i = 0; i < ncrtc; i++)
@@ -1923,7 +1928,7 @@ ecore_x_randr_screen_reset(Ecore_X_Window root)
1923 1928
1924EAPI void 1929EAPI void
1925ecore_x_randr_screen_backlight_level_set(Ecore_X_Window root, 1930ecore_x_randr_screen_backlight_level_set(Ecore_X_Window root,
1926 double level) 1931 double level)
1927{ 1932{
1928#ifdef ECORE_XRANDR 1933#ifdef ECORE_XRANDR
1929 RANDR_CHECK_1_2_RET(); 1934 RANDR_CHECK_1_2_RET();
@@ -1965,6 +1970,26 @@ ecore_x_randr_screen_backlight_level_set(Ecore_X_Window root,
1965} 1970}
1966 1971
1967/* 1972/*
1973 * @brief check if a backlight is available
1974 * @return whether a blacklight is available
1975 */
1976
1977EAPI Eina_Bool
1978ecore_x_randr_output_backlight_available(void)
1979{
1980#ifdef ECORE_XRANDR
1981 RANDR_CHECK_1_2_RET(-1);
1982 Atom _backlight;
1983
1984 _backlight = XInternAtom(_ecore_x_disp, RANDR_PROPERTY_BACKLIGHT, True);
1985
1986 return (_backlight == None) ? EINA_FALSE : EINA_TRUE;
1987
1988#endif
1989 return EINA_FALSE;
1990}
1991
1992/*
1968 * @brief get the backlight level of the given output 1993 * @brief get the backlight level of the given output
1969 * @param root window which's screen should be queried 1994 * @param root window which's screen should be queried
1970 * @param output from which the backlight level should be retrieved 1995 * @param output from which the backlight level should be retrieved
@@ -1972,7 +1997,7 @@ ecore_x_randr_screen_backlight_level_set(Ecore_X_Window root,
1972 */ 1997 */
1973 1998
1974EAPI double 1999EAPI double
1975ecore_x_randr_output_backlight_level_get(Ecore_X_Window root, 2000ecore_x_randr_output_backlight_level_get(Ecore_X_Window root,
1976 Ecore_X_Randr_Output output) 2001 Ecore_X_Randr_Output output)
1977{ 2002{
1978#ifdef ECORE_XRANDR 2003#ifdef ECORE_XRANDR
@@ -2025,9 +2050,9 @@ ecore_x_randr_output_backlight_level_get(Ecore_X_Window root,
2025 if ((info->range) && (info->num_values == 2)) 2050 if ((info->range) && (info->num_values == 2))
2026 { 2051 {
2027 /* finally convert the current value in the interval [0..1] */ 2052 /* finally convert the current value in the interval [0..1] */
2028 min = info->values[0]; 2053 min = info->values[0];
2029 max = info->values[1]; 2054 max = info->values[1];
2030 dvalue = ((double)(value - min)) / ((double)(max - min)); 2055 dvalue = ((double)(value - min)) / ((double)(max - min));
2031 } 2056 }
2032 free(info); 2057 free(info);
2033 return dvalue; 2058 return dvalue;
@@ -2045,9 +2070,9 @@ ecore_x_randr_output_backlight_level_get(Ecore_X_Window root,
2045 */ 2070 */
2046 2071
2047EAPI Eina_Bool 2072EAPI Eina_Bool
2048ecore_x_randr_output_backlight_level_set(Ecore_X_Window root, 2073ecore_x_randr_output_backlight_level_set(Ecore_X_Window root,
2049 Ecore_X_Randr_Output output, 2074 Ecore_X_Randr_Output output,
2050 double level) 2075 double level)
2051{ 2076{
2052#ifdef ECORE_XRANDR 2077#ifdef ECORE_XRANDR
2053 RANDR_CHECK_1_2_RET(EINA_FALSE); 2078 RANDR_CHECK_1_2_RET(EINA_FALSE);
@@ -2107,7 +2132,7 @@ ecore_x_randr_output_backlight_level_set(Ecore_X_Window root,
2107 2132
2108EAPI Ecore_X_Randr_Output * 2133EAPI Ecore_X_Randr_Output *
2109ecore_x_randr_window_outputs_get(Ecore_X_Window window, 2134ecore_x_randr_window_outputs_get(Ecore_X_Window window,
2110 int *num) 2135 int *num)
2111{ 2136{
2112#ifdef ECORE_XRANDR 2137#ifdef ECORE_XRANDR
2113 Ecore_X_Window root; 2138 Ecore_X_Window root;
@@ -2136,39 +2161,39 @@ ecore_x_randr_window_outputs_get(Ecore_X_Window window,
2136 for (i = 0; i < ncrtcs; i++) 2161 for (i = 0; i < ncrtcs; i++)
2137 { 2162 {
2138 /* if crtc is not enabled, don't bother about it any further */ 2163 /* if crtc is not enabled, don't bother about it any further */
2139 mode = ecore_x_randr_crtc_mode_get(root, crtcs[i]); 2164 mode = ecore_x_randr_crtc_mode_get(root, crtcs[i]);
2140 if (mode == Ecore_X_Randr_None) continue; 2165 if (mode == Ecore_X_Randr_None) continue;
2141 2166
2142 ecore_x_randr_crtc_geometry_get(root, crtcs[i], 2167 ecore_x_randr_crtc_geometry_get(root, crtcs[i],
2143 &c_geo.x, &c_geo.y, 2168 &c_geo.x, &c_geo.y,
2144 &c_geo.w, &c_geo.h); 2169 &c_geo.w, &c_geo.h);
2145 if (eina_rectangles_intersect(&w_geo, &c_geo)) 2170 if (eina_rectangles_intersect(&w_geo, &c_geo))
2146 { 2171 {
2147 outputs = ecore_x_randr_crtc_outputs_get(root, crtcs[i], 2172 outputs = ecore_x_randr_crtc_outputs_get(root, crtcs[i],
2148 &noutputs); 2173 &noutputs);
2149 /* The case below should be impossible, but for safety reasons 2174 /* The case below should be impossible, but for safety reasons
2150 * remains */ 2175 * remains */
2151 if (!outputs) 2176 if (!outputs)
2152 { 2177 {
2153 if (num) *num = 0; 2178 if (num) *num = 0;
2154 free(ret); 2179 free(ret);
2155 free(crtcs); 2180 free(crtcs);
2156 return NULL; 2181 return NULL;
2157 } 2182 }
2158 tret = realloc(ret, ((nret + noutputs) * sizeof(Ecore_X_Randr_Output))); 2183 tret = realloc(ret, ((nret + noutputs) * sizeof(Ecore_X_Randr_Output)));
2159 if (!tret) 2184 if (!tret)
2160 { 2185 {
2161 if (num) *num = 0; 2186 if (num) *num = 0;
2162 free(outputs); 2187 free(outputs);
2163 free(ret); 2188 free(ret);
2164 free(crtcs); 2189 free(crtcs);
2165 return NULL; 2190 return NULL;
2166 } 2191 }
2167 ret = tret; 2192 ret = tret;
2168 memcpy(&ret[nret], outputs, (noutputs * sizeof(Ecore_X_Randr_Output))); 2193 memcpy(&ret[nret], outputs, (noutputs * sizeof(Ecore_X_Randr_Output)));
2169 nret += noutputs; 2194 nret += noutputs;
2170 free(outputs); 2195 free(outputs);
2171 } 2196 }
2172 } 2197 }
2173 free(crtcs); 2198 free(crtcs);
2174 2199
@@ -2192,7 +2217,7 @@ _ecore_x_randr_current_output_get_fail:
2192 2217
2193EINA_DEPRECATED EAPI Ecore_X_Randr_Output * 2218EINA_DEPRECATED EAPI Ecore_X_Randr_Output *
2194ecore_x_randr_current_output_get(Ecore_X_Window window, 2219ecore_x_randr_current_output_get(Ecore_X_Window window,
2195 int *num) 2220 int *num)
2196{ 2221{
2197 return ecore_x_randr_window_outputs_get(window, num); 2222 return ecore_x_randr_window_outputs_get(window, num);
2198} 2223}