883f9821ea574505f36ccfad2f23526e82340a59
[profile/ivi/ecore.git] / src / lib / ecore_x / xcb / ecore_xcb_composite.c
1 #include "ecore_xcb_private.h"
2
3 /**
4  * @defgroup Ecore_X_Composite_Group X Composite Extension Functions
5  *
6  * Functions related to the X Composite extension.
7  */
8
9 #ifdef ECORE_XCB_COMPOSITE
10 static uint8_t _composite_available = 0;
11 static xcb_composite_query_version_cookie_t _ecore_xcb_composite_init_cookie;
12 #endif /* ECORE_XCB_COMPOSITE */
13
14 /* To avoid round trips, the initialization is separated in 2
15    functions: _ecore_xcb_composite_init and
16    _ecore_xcb_composite_init_finalize. The first one gets the cookies and
17    the second one gets the replies. */
18
19 void
20 _ecore_x_composite_init(const xcb_query_extension_reply_t *reply)
21 {
22 #ifdef ECORE_XCB_COMPOSITE
23    if (reply && reply->present)
24       _ecore_xcb_composite_init_cookie = xcb_composite_query_version_unchecked(_ecore_xcb_conn, XCB_COMPOSITE_MAJOR_VERSION, XCB_COMPOSITE_MINOR_VERSION);
25
26 #endif /* ECORE_XCB_COMPOSITE */
27 } /* _ecore_x_composite_init */
28
29 void
30 _ecore_x_composite_init_finalize(void)
31 {
32 #ifdef ECORE_XCB_COMPOSITE
33    xcb_composite_query_version_reply_t *reply;
34
35    reply = xcb_composite_query_version_reply(_ecore_xcb_conn,
36                                              _ecore_xcb_composite_init_cookie,
37                                              NULL);
38    if (reply)
39      {
40         if ((reply->major_version == XCB_COMPOSITE_MAJOR_VERSION) &&
41             (reply->minor_version >= XCB_COMPOSITE_MINOR_VERSION))
42            _composite_available = 1;
43
44         free(reply);
45      }
46
47 #endif /* ECORE_XCB_COMPOSITE */
48 } /* _ecore_x_composite_init_finalize */
49
50 /**
51  * Return whether the Composite Extension is available.
52  * @return 1 if the Composite Extension is available, 0 if not.
53  *
54  * Return 1 if the X server supports the Composite Extension version 0.4
55  * or greater, 0 otherwise.
56  * @ingroup Ecore_X_Composite_Group
57  */
58 EAPI int
59 ecore_x_composite_query(void)
60 {
61 #ifdef ECORE_XCB_COMPOSITE
62    return _composite_available;
63 #else /* ifdef ECORE_XCB_COMPOSITE */
64    return 0;
65 #endif /* ECORE_XCB_COMPOSITE */
66 } /* ecore_x_composite_query */
67