Tizen 2.1 base
[framework/uifw/ecore.git] / src / lib / ecore_x / xlib / ecore_x_randr_13.c
1 /*
2  * vim:ts=8:sw=3:sts=8:expandtab:cino=>5n-3f0^-2{2
3  */
4
5 #ifdef HAVE_CONFIG_H
6 # include <config.h>
7 #endif
8
9 #include "ecore_x_private.h"
10 #include "ecore_x_randr.h"
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <unistd.h>
14 #include <string.h>
15
16 #define Ecore_X_Randr_None  0
17 #define Ecore_X_Randr_Unset -1
18
19 #ifdef ECORE_XRANDR
20
21 #define RANDR_1_3           ((1 << 16) | 3)
22 #define RANDR_CHECK_1_3_RET(ret) if (_randr_version < RANDR_1_3) \
23     return ret
24
25 extern XRRScreenResources *(*_ecore_x_randr_get_screen_resources)(Display *
26                                                                   dpy,
27                                                                   Window
28                                                                   window);
29 extern int _randr_version;
30 #endif
31
32 /*
33  * @param root window which's screen should be queried
34  * @return Ecore_X_Randr_Ouptut_Id or - if query failed or none is set - Ecore_X_Randr_None
35  */
36 EAPI Ecore_X_Randr_Output
37 ecore_x_randr_primary_output_get(Ecore_X_Window root)
38 {
39 #ifdef ECORE_XRANDR
40    RANDR_CHECK_1_3_RET(Ecore_X_Randr_None);
41    if (!_ecore_x_randr_root_validate(root))
42      return Ecore_X_Randr_None;
43
44    return XRRGetOutputPrimary(_ecore_x_disp, root);
45 #else
46    return Ecore_X_Randr_None;
47 #endif
48 }
49
50 /*
51  * @param root window which's screen should be queried
52  * @param output that should be set as given root window's screen primary output
53  */
54 EAPI void
55 ecore_x_randr_primary_output_set(Ecore_X_Window root,
56                                  Ecore_X_Randr_Output output)
57 {
58 #ifdef ECORE_XRANDR
59    RANDR_CHECK_1_3_RET();
60
61    if (_ecore_x_randr_output_validate(root, output))
62      {
63         XRRSetOutputPrimary(_ecore_x_disp, root, output);
64      }
65
66 #endif
67 }
68