2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
5 #include "ecore_xcb_private.h"
9 * @defgroup Ecore_X_Xinerama_Group X Xinerama Extension Functions
11 * Functions related to the X Xinerama extension.
15 #ifdef ECORE_XCB_XINERAMA
16 static int _xinerama_available = 0;
17 static xcb_xinerama_query_version_cookie_t _ecore_xcb_xinerama_init_cookie;
18 #endif /* ECORE_XCB_XINERAMA */
21 /* To avoid round trips, the initialization is separated in 2
22 functions: _ecore_xcb_xinerama_init and
23 _ecore_xcb_xinerama_init_finalize. The first one gets the cookies and
24 the second one gets the replies. */
27 _ecore_x_xinerama_init(const xcb_query_extension_reply_t *reply)
29 #ifdef ECORE_XCB_XINERAMA
30 if (reply && (reply->present))
31 _ecore_xcb_xinerama_init_cookie = xcb_xinerama_query_version_unchecked(_ecore_xcb_conn, 1, 2);
32 #endif /* ECORE_XCB_XINERAMA */
36 _ecore_x_xinerama_init_finalize(void)
38 #ifdef ECORE_XCB_XINERAMA
39 xcb_xinerama_query_version_reply_t *reply;
41 reply = xcb_xinerama_query_version_reply(_ecore_xcb_conn,
42 _ecore_xcb_xinerama_init_cookie, NULL);
46 if ((reply->major >= 1) &&
48 _xinerama_available = 1;
51 #endif /* ECORE_XCB_XINERAMA */
56 * Return whether the X server supports the Xinerama Extension.
57 * @return 1 if the X Xinerama Extension is available, 0 otherwise.
59 * Return 1 if the X server supports the Fixes Xinerama version 1.1,
61 * @ingroup Ecore_X_Xinerama_Group
64 ecore_x_xinerama_query(void)
66 #ifdef ECORE_XCB_XINERAMA
67 return _xinerama_available;
70 #endif /* ECORE_XCB_XINERAMA */
75 * Sends the XineramaQueryScreens request.
76 * @ingroup Ecore_X_Xinerama_Group
79 ecore_x_xinerama_query_screens_prefetch(void)
81 #ifdef ECORE_XCB_XINERAMA
82 xcb_xinerama_query_screens_cookie_t cookie;
84 cookie = xcb_xinerama_query_screens_unchecked(_ecore_xcb_conn);
85 _ecore_xcb_cookie_cache(cookie.sequence);
86 #endif /* ECORE_XCB_XINERAMA */
91 * Gets the reply of the XineramaQueryScreens request sent by ecore_x_xinerama_query_screens_prefetch().
92 * @ingroup Ecore_X_Xinerama_Group
95 ecore_x_xinerama_query_screens_fetch(void)
97 #ifdef ECORE_XCB_XINERAMA
98 xcb_xinerama_query_screens_cookie_t cookie;
99 xcb_xinerama_query_screens_reply_t *reply;
101 cookie.sequence = _ecore_xcb_cookie_get();
102 reply = xcb_xinerama_query_screens_reply(_ecore_xcb_conn, cookie, NULL);
103 _ecore_xcb_reply_cache(reply);
104 #endif /* ECORE_XCB_XINERAMA */
109 * Return the number of screens.
110 * @return The screen count.
112 * Return the number of screens.
114 * To use this function, you must call before, and in order,
115 * ecore_x_xinerama_query_screens_prefetch(), which sends the XineramaQueryScreens request,
116 * then ecore_x_xinerama_query_screens_fetch(), which gets the reply.
117 * @ingroup Ecore_X_Xinerama_Group
120 ecore_x_xinerama_screen_count_get(void)
122 int screen_count = 0;
123 #ifdef ECORE_XCB_XINERAMA
124 xcb_xinerama_screen_info_iterator_t iter;
125 xcb_xinerama_query_screens_reply_t *reply;
127 reply = _ecore_xcb_reply_get();
128 if (!reply) return 0;
130 iter = xcb_xinerama_query_screens_screen_info_iterator(reply);
131 screen_count = iter.rem;
132 #endif /* ECORE_XCB_XINERAMA */
139 * Get the geometry of the screen.
140 * @param screen The screen (Unused).
141 * @param x The X coordinate of the screen.
142 * @param y The Y coordinate of the screen
143 * @param width The width of the screen
144 * @param height The height of the screen
145 * @return 1 on success, 0 otherwise.
147 * Get the geometry of the screen whose number is @p screen. The
148 * returned values are stored in @p x, @p y, @p width and @p height.
150 * To use this function, you must call before, and in order,
151 * ecore_x_xinerama_query_screens_prefetch(), which sends the XineramaQueryScreens request,
152 * then ecore_x_xinerama_query_screens_fetch(), which gets the reply.
153 * @ingroup Ecore_X_Xinerama_Group
156 ecore_x_xinerama_screen_geometry_get(int screen,
162 #ifdef ECORE_XCB_XINERAMA
163 xcb_xinerama_screen_info_iterator_t iter;
164 xcb_xinerama_query_screens_reply_t *reply;
166 reply = _ecore_xcb_reply_get();
171 if (width) *width = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_pixels;
172 if (height) *height = ((xcb_screen_t *)_ecore_xcb_screen)->height_in_pixels;
177 iter = xcb_xinerama_query_screens_screen_info_iterator(reply);
178 for (; iter.rem; screen--, xcb_xinerama_screen_info_next(&iter))
182 if (x) *x = iter.data->x_org;
183 if (y) *y = iter.data->y_org;
184 if (width) *width = iter.data->width;
185 if (height) *height = iter.data->height;
189 #endif /* ECORE_XCB_XINERAMA */
193 if (width) *width = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_pixels;
194 if (height) *height = ((xcb_screen_t *)_ecore_xcb_screen)->height_in_pixels;