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