diff options
Diffstat (limited to 'libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_xinerama.c')
-rw-r--r-- | libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_xinerama.c | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_xinerama.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_xinerama.c new file mode 100644 index 0000000..37a2339 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_xinerama.c | |||
@@ -0,0 +1,139 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | #ifdef ECORE_XCB_XINERAMA | ||
3 | # include <xcb/xinerama.h> | ||
4 | #endif | ||
5 | |||
6 | /* local variables */ | ||
7 | static Eina_Bool _xinerama_avail = EINA_FALSE; | ||
8 | static Eina_Bool _xinerama_active = EINA_FALSE; | ||
9 | |||
10 | void | ||
11 | _ecore_xcb_xinerama_init(void) | ||
12 | { | ||
13 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
14 | |||
15 | #ifdef ECORE_XCB_XINERAMA | ||
16 | xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_xinerama_id); | ||
17 | #endif | ||
18 | } | ||
19 | |||
20 | void | ||
21 | _ecore_xcb_xinerama_finalize(void) | ||
22 | { | ||
23 | #ifdef ECORE_XCB_XINERAMA | ||
24 | const xcb_query_extension_reply_t *ext_reply; | ||
25 | #endif | ||
26 | |||
27 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
28 | |||
29 | #ifdef ECORE_XCB_XINERAMA | ||
30 | ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_xinerama_id); | ||
31 | if ((ext_reply) && (ext_reply->present)) | ||
32 | { | ||
33 | xcb_xinerama_query_version_cookie_t cookie; | ||
34 | xcb_xinerama_query_version_reply_t *reply; | ||
35 | |||
36 | cookie = | ||
37 | xcb_xinerama_query_version_unchecked(_ecore_xcb_conn, | ||
38 | XCB_XINERAMA_MAJOR_VERSION, | ||
39 | XCB_XINERAMA_MINOR_VERSION); | ||
40 | reply = | ||
41 | xcb_xinerama_query_version_reply(_ecore_xcb_conn, cookie, NULL); | ||
42 | if (reply) | ||
43 | { | ||
44 | _xinerama_avail = EINA_TRUE; | ||
45 | // NB: Do we need to compare version numbers here ? | ||
46 | free(reply); | ||
47 | } | ||
48 | |||
49 | if (_xinerama_avail) | ||
50 | { | ||
51 | xcb_xinerama_is_active_cookie_t acookie; | ||
52 | xcb_xinerama_is_active_reply_t *areply; | ||
53 | |||
54 | acookie = xcb_xinerama_is_active_unchecked(_ecore_xcb_conn); | ||
55 | areply = | ||
56 | xcb_xinerama_is_active_reply(_ecore_xcb_conn, acookie, NULL); | ||
57 | if (areply) | ||
58 | { | ||
59 | _xinerama_active = areply->state; | ||
60 | free(areply); | ||
61 | } | ||
62 | } | ||
63 | } | ||
64 | #endif | ||
65 | } | ||
66 | |||
67 | EAPI int | ||
68 | ecore_x_xinerama_screen_count_get(void) | ||
69 | { | ||
70 | int count = 0; | ||
71 | #ifdef ECORE_XCB_XINERAMA | ||
72 | xcb_xinerama_query_screens_cookie_t cookie; | ||
73 | xcb_xinerama_query_screens_reply_t *reply; | ||
74 | #endif | ||
75 | |||
76 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
77 | CHECK_XCB_CONN; | ||
78 | |||
79 | if (!_xinerama_avail) return 0; | ||
80 | |||
81 | #ifdef ECORE_XCB_XINERAMA | ||
82 | cookie = xcb_xinerama_query_screens_unchecked(_ecore_xcb_conn); | ||
83 | reply = | ||
84 | xcb_xinerama_query_screens_reply(_ecore_xcb_conn, cookie, NULL); | ||
85 | if (!reply) return 0; | ||
86 | count = reply->number; | ||
87 | #endif | ||
88 | |||
89 | return count; | ||
90 | } | ||
91 | |||
92 | EAPI Eina_Bool | ||
93 | ecore_x_xinerama_screen_geometry_get(int screen, | ||
94 | int *x, | ||
95 | int *y, | ||
96 | int *w, | ||
97 | int *h) | ||
98 | { | ||
99 | #ifdef ECORE_XCB_XINERAMA | ||
100 | xcb_xinerama_query_screens_cookie_t cookie; | ||
101 | xcb_xinerama_query_screens_reply_t *reply; | ||
102 | xcb_xinerama_screen_info_t *info; | ||
103 | #endif | ||
104 | |||
105 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
106 | CHECK_XCB_CONN; | ||
107 | |||
108 | if (x) *x = 0; | ||
109 | if (y) *y = 0; | ||
110 | if (w) *w = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_pixels; | ||
111 | if (h) *h = ((xcb_screen_t *)_ecore_xcb_screen)->height_in_pixels; | ||
112 | |||
113 | if (!_xinerama_avail) return EINA_FALSE; | ||
114 | |||
115 | #ifdef ECORE_XCB_XINERAMA | ||
116 | cookie = xcb_xinerama_query_screens_unchecked(_ecore_xcb_conn); | ||
117 | reply = | ||
118 | xcb_xinerama_query_screens_reply(_ecore_xcb_conn, cookie, NULL); | ||
119 | if (!reply) return EINA_FALSE; | ||
120 | |||
121 | info = xcb_xinerama_query_screens_screen_info(reply); | ||
122 | if (!info) | ||
123 | { | ||
124 | free(reply); | ||
125 | return EINA_FALSE; | ||
126 | } | ||
127 | |||
128 | if (x) *x = info[screen].x_org; | ||
129 | if (y) *y = info[screen].y_org; | ||
130 | if (w) *w = info[screen].width; | ||
131 | if (h) *h = info[screen].height; | ||
132 | |||
133 | free(reply); | ||
134 | return EINA_TRUE; | ||
135 | #endif | ||
136 | |||
137 | return EINA_FALSE; | ||
138 | } | ||
139 | |||