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