1 #include "ecore_xcb_private.h"
4 * @defgroup Ecore_X_Xinerama_Group X Xinerama Extension Functions
6 * Functions related to the X Xinerama extension.
9 #ifdef ECORE_XCB_XINERAMA
10 static int _xinerama_available = 0;
11 static xcb_xinerama_query_version_cookie_t _ecore_xcb_xinerama_init_cookie;
12 #endif /* ECORE_XCB_XINERAMA */
14 /* To avoid round trips, the initialization is separated in 2
15 functions: _ecore_xcb_xinerama_init and
16 _ecore_xcb_xinerama_init_finalize. The first one gets the cookies and
17 the second one gets the replies. */
20 _ecore_x_xinerama_init(const xcb_query_extension_reply_t *reply)
22 #ifdef ECORE_XCB_XINERAMA
23 if (reply && (reply->present))
24 _ecore_xcb_xinerama_init_cookie = xcb_xinerama_query_version_unchecked(_ecore_xcb_conn, 1, 2);
26 #endif /* ECORE_XCB_XINERAMA */
27 } /* _ecore_x_xinerama_init */
30 _ecore_x_xinerama_init_finalize(void)
32 #ifdef ECORE_XCB_XINERAMA
33 xcb_xinerama_query_version_reply_t *reply;
35 reply = xcb_xinerama_query_version_reply(_ecore_xcb_conn,
36 _ecore_xcb_xinerama_init_cookie, NULL);
40 if ((reply->major >= 1) &&
42 _xinerama_available = 1;
47 #endif /* ECORE_XCB_XINERAMA */
48 } /* _ecore_x_xinerama_init_finalize */
51 * Return whether the X server supports the Xinerama Extension.
52 * @return 1 if the X Xinerama Extension is available, 0 otherwise.
54 * Return 1 if the X server supports the Fixes Xinerama version 1.1,
56 * @ingroup Ecore_X_Xinerama_Group
59 ecore_x_xinerama_query(void)
61 #ifdef ECORE_XCB_XINERAMA
62 return _xinerama_available;
63 #else /* ifdef ECORE_XCB_XINERAMA */
65 #endif /* ECORE_XCB_XINERAMA */
66 } /* ecore_x_xinerama_query */
69 * Sends the XineramaQueryScreens request.
70 * @ingroup Ecore_X_Xinerama_Group
73 ecore_x_xinerama_query_screens_prefetch(void)
75 #ifdef ECORE_XCB_XINERAMA
76 xcb_xinerama_query_screens_cookie_t cookie;
78 cookie = xcb_xinerama_query_screens_unchecked(_ecore_xcb_conn);
79 _ecore_xcb_cookie_cache(cookie.sequence);
80 #endif /* ECORE_XCB_XINERAMA */
81 } /* ecore_x_xinerama_query_screens_prefetch */
84 * Gets the reply of the XineramaQueryScreens request sent by ecore_x_xinerama_query_screens_prefetch().
85 * @ingroup Ecore_X_Xinerama_Group
88 ecore_x_xinerama_query_screens_fetch(void)
90 #ifdef ECORE_XCB_XINERAMA
91 xcb_xinerama_query_screens_cookie_t cookie;
92 xcb_xinerama_query_screens_reply_t *reply;
94 cookie.sequence = _ecore_xcb_cookie_get();
95 reply = xcb_xinerama_query_screens_reply(_ecore_xcb_conn, cookie, NULL);
96 _ecore_xcb_reply_cache(reply);
97 #endif /* ECORE_XCB_XINERAMA */
98 } /* ecore_x_xinerama_query_screens_fetch */
101 * Return the number of screens.
102 * @return The screen count.
104 * Return the number of screens.
106 * To use this function, you must call before, and in order,
107 * ecore_x_xinerama_query_screens_prefetch(), which sends the XineramaQueryScreens request,
108 * then ecore_x_xinerama_query_screens_fetch(), which gets the reply.
109 * @ingroup Ecore_X_Xinerama_Group
112 ecore_x_xinerama_screen_count_get(void)
114 int screen_count = 0;
115 #ifdef ECORE_XCB_XINERAMA
116 xcb_xinerama_screen_info_iterator_t iter;
117 xcb_xinerama_query_screens_reply_t *reply;
119 reply = _ecore_xcb_reply_get();
123 iter = xcb_xinerama_query_screens_screen_info_iterator(reply);
124 screen_count = iter.rem;
125 #endif /* ECORE_XCB_XINERAMA */
128 } /* ecore_x_xinerama_screen_count_get */
131 * Get the geometry of the screen.
132 * @param screen The screen (Unused).
133 * @param x The X coordinate of the screen.
134 * @param y The Y coordinate of the screen
135 * @param width The width of the screen
136 * @param height The height of the screen
137 * @return 1 on success, 0 otherwise.
139 * Get the geometry of the screen whose number is @p screen. The
140 * returned values are stored in @p x, @p y, @p width and @p height.
142 * To use this function, you must call before, and in order,
143 * ecore_x_xinerama_query_screens_prefetch(), which sends the XineramaQueryScreens request,
144 * then ecore_x_xinerama_query_screens_fetch(), which gets the reply.
145 * @ingroup Ecore_X_Xinerama_Group
148 ecore_x_xinerama_screen_geometry_get(int screen,
154 #ifdef ECORE_XCB_XINERAMA
155 xcb_xinerama_screen_info_iterator_t iter;
156 xcb_xinerama_query_screens_reply_t *reply;
158 reply = _ecore_xcb_reply_get();
168 *width = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_pixels;
171 *height = ((xcb_screen_t *)_ecore_xcb_screen)->height_in_pixels;
176 iter = xcb_xinerama_query_screens_screen_info_iterator(reply);
177 for (; iter.rem; screen--, xcb_xinerama_screen_info_next(&iter))
182 *x = iter.data->x_org;
185 *y = iter.data->y_org;
188 *width = iter.data->width;
191 *height = iter.data->height;
196 #endif /* ECORE_XCB_XINERAMA */
205 *width = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_pixels;
208 *height = ((xcb_screen_t *)_ecore_xcb_screen)->height_in_pixels;
211 } /* ecore_x_xinerama_screen_geometry_get */