2 * Copyright Geoff Levand <geoff@infradead.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 #if !defined(_PBT_SCR_H)
21 #include <libtwin/twin.h>
22 #include <libtwin/twin_jpeg.h>
23 #include <libtwin/twin_linux_mouse.h>
24 #include <libtwin/twin_linux_js.h>
25 #include <libtwin/twin_png.h>
27 #if defined(HAVE_LIBTWIN_TWIN_X11_H)
28 # include <libtwin/twin_x11.h>
30 #if defined(HAVE_LIBTWIN_TWIN_FBDEV_H)
31 # include <libtwin/twin_fbdev.h>
34 #define DBG(fmt, args...) pb_log("DBG: " fmt, ## args)
35 #define DBGS(fmt, args...) \
36 pb_log("DBG:%s:%d: " fmt, __func__, __LINE__, ## args)
46 * struct pbt_border - A window border.
47 * @left: Pixel count for left side.
48 * @fill_color: Border fill color.
56 twin_argb32_t fill_color;
60 pbt_debug_red = 0x00800000,
61 pbt_debug_green = 0x00008000,
62 pbt_debug_blue = 0x00000080,
65 static const struct pbt_border pbt_thin_border = {
72 static const struct pbt_border pbt_right_border = {
76 static const struct pbt_border pbt_red_debug_border = {
81 .fill_color = pbt_debug_red,
84 static const struct pbt_border pbt_green_debug_border = {
89 .fill_color = pbt_debug_green,
92 static const struct pbt_border pbt_blue_debug_border = {
97 .fill_color = pbt_debug_blue,
100 static const struct pbt_border pbt_yellow_debug_border = {
105 .fill_color = pbt_debug_green + pbt_debug_red,
108 void pbt_border_draw(twin_pixmap_t *pixmap, const struct pbt_border *border);
111 twin_pixmap_t *pixmap;
116 enum pbt_twin_backend {
121 struct pbt_twin_ctx {
124 #if defined(HAVE_LIBTWIN_TWIN_X11_H)
127 #if defined(HAVE_LIBTWIN_TWIN_FBDEV_H)
131 enum pbt_twin_backend backend;
135 struct pbt_twin_ctx twin_ctx;
136 twin_screen_t *tscreen;
137 twin_pixmap_t *cursor;
140 struct pbt_scr *pbt_scr_init(void *talloc_ctx, enum pbt_twin_backend backend,
141 unsigned int width, unsigned int height,
142 const char *filename_background,
143 twin_bool_t (*scr_event_cb)(twin_screen_t *tscreen,
144 twin_event_t *event));
146 static inline struct pbt_scr *pbt_scr_from_tscreen(twin_screen_t *tscreen)
148 size_t offset = (size_t)&((struct pbt_scr *)0)->tscreen;
149 return (struct pbt_scr *)((char *)tscreen - offset);
152 void pbt_image_draw(twin_pixmap_t *dest, twin_pixmap_t *image);
154 #define pbt_dump_event(_s, _w, _e) _pbt_dump_event(_s, _w, _e, __func__, __LINE__)
155 void _pbt_dump_event(const char *text, twin_window_t *twindow,
156 const twin_event_t *tevent, const char *func, int line);
158 twin_pixmap_t *pbt_background_load(twin_screen_t *tscreen,
159 const char *filename);
160 twin_pixmap_t *pbt_icon_load(const char *filename);
161 const char *pbt_icon_chooser(const char *hint);
162 int pbt_window_contains(const twin_window_t *window, const twin_event_t *event);
163 void pbt_window_redraw(twin_window_t *twindow);
165 #define pbt_dump_pixmap(_p) \
166 DBGS("pixmap(%p): {x,y,w,h} = {%d,%d,%d,%d}\n", \