tag: Improve tag property::index support (FS#1229)
[awesome.git] / draw.h
blob1bbf1cc7acba5d6ac51a7569f8026ba55e4207cf
1 /*
2 * draw.h - draw functions header
4 * Copyright © 2007-2009 Julien Danjou <julien@danjou.info>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef AWESOME_COMMON_DRAW_H
23 #define AWESOME_COMMON_DRAW_H
25 #include <xcb/xcb.h>
26 #include <cairo.h>
27 #include <lua.h>
29 #include "common/util.h"
31 typedef struct area_t area_t;
32 struct area_t
34 /** Co-ords of upper left corner */
35 int16_t x;
36 int16_t y;
37 uint16_t width;
38 uint16_t height;
41 #define AREA_LEFT(a) ((a).x)
42 #define AREA_TOP(a) ((a).y)
43 #define AREA_RIGHT(a) ((a).x + (a).width)
44 #define AREA_BOTTOM(a) ((a).y + (a).height)
46 bool draw_iso2utf8(const char *, size_t, char **, ssize_t *);
48 /** Convert a string to UTF-8.
49 * \param str The string to convert.
50 * \param len The string length.
51 * \param dest The destination string that will be allocated.
52 * \param dlen The destination string length allocated, can be NULL.
53 * \return True if the conversion happened, false otherwise. In both case, dest
54 * and dlen will have value and dest have to be free().
56 static inline bool
57 a_iso2utf8(const char *str, ssize_t len, char **dest, ssize_t *dlen)
59 if(draw_iso2utf8(str, len, dest, dlen))
60 return true;
62 *dest = a_strdup(str);
63 if(dlen)
64 *dlen = len;
66 return false;
69 cairo_surface_t *draw_surface_from_data(int width, int height, uint32_t *data);
70 cairo_surface_t *draw_dup_image_surface(cairo_surface_t *surface);
71 cairo_surface_t *draw_load_image(lua_State *L, const char *path);
73 xcb_visualtype_t *draw_find_visual(const xcb_screen_t *s, xcb_visualid_t visual);
74 xcb_visualtype_t *draw_default_visual(const xcb_screen_t *s);
75 xcb_visualtype_t *draw_argb_visual(const xcb_screen_t *s);
76 uint8_t draw_visual_depth(const xcb_screen_t *s, xcb_visualid_t vis);
78 #endif
79 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80