30bb8804495146b776315e5e2796888978241f4f
[platform/upstream/efl.git] / src / lib / ecore_x / xcb / ecore_xcb_drawable.c
1 #include "ecore_xcb_private.h"
2
3 /**
4  * @defgroup Ecore_X_Drawable_Group X Drawable Functions
5  * @ingroup Ecore_X_Group
6  *
7  * Functions that operate on drawables.
8  */
9
10 /**
11  * Fill the specified rectangle on a drawable.
12  * @param d The given drawable.
13  * @param gc The graphic context that controls the fill rules.
14  * @param x The X coordinate of the top-left corner of the rectangle.
15  * @param y The Y coordinate of the top-left corner of the rectangle.
16  * @param width The width of the rectangle.
17  * @param height The height of the rectangle.
18  */
19 EAPI void
20 ecore_x_drawable_rectangle_fill(Ecore_X_Drawable draw,
21                                 Ecore_X_GC       gc,
22                                 int              x,
23                                 int              y,
24                                 int              w,
25                                 int              h)
26 {
27    xcb_rectangle_t rect;
28
29    LOGFN(__FILE__, __LINE__, __FUNCTION__);
30    CHECK_XCB_CONN;
31
32    rect.x = x;
33    rect.y = y;
34    rect.width = w;
35    rect.height = h;
36    xcb_poly_fill_rectangle(_ecore_xcb_conn, draw, gc, 1,
37                            (const xcb_rectangle_t *)&rect);
38 //   ecore_x_flush();
39 }
40
41 /**
42  * Retrieves the geometry of the given drawable.
43  * @param d The given drawable.
44  * @param x Pointer to an integer into which the X position is to be stored.
45  * @param y Pointer to an integer into which the Y position is to be stored.
46  * @param w Pointer to an integer into which the width is to be stored.
47  * @param h Pointer to an integer into which the height is to be stored.
48  * @ingroup Ecore_X_Drawable_Group
49  */
50 EAPI void
51 ecore_x_drawable_geometry_get(Ecore_X_Drawable draw,
52                               int             *x,
53                               int             *y,
54                               int             *w,
55                               int             *h)
56 {
57    xcb_get_geometry_cookie_t cookie;
58    xcb_get_geometry_reply_t *reply;
59
60    LOGFN(__FILE__, __LINE__, __FUNCTION__);
61    CHECK_XCB_CONN;
62
63    if (x) *x = 0;
64    if (y) *y = 0;
65    if (w) *w = 0;
66    if (h) *h = 0;
67    cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, draw);
68    reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL);
69    if (!reply) return;
70    if (x) *x = reply->x;
71    if (y) *y = reply->y;
72    if (w) *w = (int)reply->width;
73    if (h) *h = (int)reply->height;
74    free(reply);
75 }
76
77 /**
78  * Retrieves the width of the border of the given drawable.
79  * @param  d The given drawable.
80  * @return The border width of the given drawable.
81  * @ingroup Ecore_X_Drawable_Group
82  */
83 EAPI int
84 ecore_x_drawable_border_width_get(Ecore_X_Drawable d)
85 {
86    xcb_get_geometry_cookie_t cookie;
87    xcb_get_geometry_reply_t *reply;
88    int ret = 0;
89
90    LOGFN(__FILE__, __LINE__, __FUNCTION__);
91    CHECK_XCB_CONN;
92
93    cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, d);
94    reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL);
95    if (!reply) return 0;
96    ret = (int)reply->border_width;
97    free(reply);
98    return ret;
99 }
100
101 /**
102  * Retrieves the depth of the given drawable.
103  * @param  d The given drawable.
104  * @return The depth of the given drawable.
105  * @ingroup Ecore_X_Drawable_Group
106  */
107 EAPI int
108 ecore_x_drawable_depth_get(Ecore_X_Drawable d)
109 {
110    xcb_get_geometry_cookie_t cookie;
111    xcb_get_geometry_reply_t *reply;
112    int ret = 0;
113
114    LOGFN(__FILE__, __LINE__, __FUNCTION__);
115    CHECK_XCB_CONN;
116
117    cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, d);
118    reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL);
119    if (!reply) return 0;
120    ret = (int)reply->depth;
121    free(reply);
122    return ret;
123 }
124