efc1c9c02e105a86766426fa9a0179b31d19cf50
[framework/uifw/ecore.git] / src / lib / ecore_x / xlib / ecore_x_drawable.c
1 /*
2  * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3  */
4
5 #include "ecore_x_private.h"
6
7
8 /**
9  * @defgroup Ecore_X_Drawable_Group X Drawable Functions
10  *
11  * Functions that operate on drawables.
12  */
13
14
15 /**
16  * Retrieves the geometry of the given drawable.
17  * @param d The given drawable.
18  * @param x Pointer to an integer into which the X position is to be stored.
19  * @param y Pointer to an integer into which the Y position is to be stored.
20  * @param w Pointer to an integer into which the width is to be stored.
21  * @param h Pointer to an integer into which the height is to be stored.
22  * @ingroup Ecore_X_Drawable_Group
23  */
24 EAPI void
25 ecore_x_drawable_geometry_get(Ecore_X_Drawable d, int *x, int *y, int *w, int *h)
26 {
27    Window         dummy_win;
28    int            ret_x, ret_y;
29    unsigned int   ret_w, ret_h, dummy_border, dummy_depth;
30
31    if (!XGetGeometry(_ecore_x_disp, d, &dummy_win, &ret_x, &ret_y,
32                      &ret_w, &ret_h, &dummy_border, &dummy_depth))
33    {
34       ret_x = 0;
35       ret_y = 0;
36       ret_w = 0;
37       ret_h = 0;
38    }
39
40    if (x) *x = ret_x;
41    if (y) *y = ret_y;
42    if (w) *w = (int) ret_w;
43    if (h) *h = (int) ret_h;
44 }
45
46 /**
47  * Retrieves the width of the border of the given drawable.
48  * @param  d The given drawable.
49  * @return The border width of the given drawable.
50  * @ingroup Ecore_X_Drawable_Group
51  */
52 EAPI int
53 ecore_x_drawable_border_width_get(Ecore_X_Drawable d)
54 {
55    Window         dummy_win;
56    int            dummy_x, dummy_y;
57    unsigned int   dummy_w, dummy_h, border_ret, dummy_depth;
58
59    if (!XGetGeometry(_ecore_x_disp, d, &dummy_win, &dummy_x, &dummy_y,
60                      &dummy_w, &dummy_h, &border_ret, &dummy_depth))
61       border_ret = 0;
62
63    return (int) border_ret;
64 }
65
66 /**
67  * Retrieves the depth of the given drawable.
68  * @param  d The given drawable.
69  * @return The depth of the given drawable.
70  * @ingroup Ecore_X_Drawable_Group
71  */
72 EAPI int
73 ecore_x_drawable_depth_get(Ecore_X_Drawable d)
74 {
75    Window         dummy_win;
76    int            dummy_x, dummy_y;
77    unsigned int   dummy_w, dummy_h, dummy_border, depth_ret;
78
79    if (!XGetGeometry(_ecore_x_disp, d, &dummy_win, &dummy_x, &dummy_y,
80                      &dummy_w, &dummy_h, &dummy_border, &depth_ret))
81       depth_ret = 0;
82
83    return (int) depth_ret;
84 }