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 <waiter/waiter.h>
23 #include <libtwin/twin.h>
24 #include <libtwin/twin_jpeg.h>
25 #include <libtwin/twin_linux_mouse.h>
26 #include <libtwin/twin_linux_js.h>
27 #include <libtwin/twin_png.h>
29 #if defined(HAVE_LIBTWIN_TWIN_X11_H)
30 # include <libtwin/twin_x11.h>
32 #if defined(HAVE_LIBTWIN_TWIN_FBDEV_H)
33 # include <libtwin/twin_fbdev.h>
36 #define DBG(fmt, args...) pb_debug("DBG: " fmt, ## args)
37 #define DBGS(fmt, args...) \
38 pb_debug("DBG:%s:%d: " fmt, __func__, __LINE__, ## args)
48 * struct pbt_border - A window border.
49 * @left: Pixel count for left side.
50 * @fill_color: Border fill color.
58 twin_argb32_t fill_color;
62 pbt_debug_red = 0x00800000,
63 pbt_debug_green = 0x00008000,
64 pbt_debug_blue = 0x00000080,
67 static const struct pbt_border pbt_thin_border = {
74 static const struct pbt_border pbt_right_border = {
78 static const struct pbt_border pbt_red_debug_border = {
83 .fill_color = pbt_debug_red,
86 static const struct pbt_border pbt_green_debug_border = {
91 .fill_color = pbt_debug_green,
94 static const struct pbt_border pbt_blue_debug_border = {
99 .fill_color = pbt_debug_blue,
102 static const struct pbt_border pbt_yellow_debug_border = {
107 .fill_color = pbt_debug_green + pbt_debug_red,
110 void pbt_border_draw(twin_pixmap_t *pixmap, const struct pbt_border *border);
113 twin_pixmap_t *pixmap;
118 enum pbt_twin_backend {
123 struct pbt_twin_ctx {
126 #if defined(HAVE_LIBTWIN_TWIN_X11_H)
129 #if defined(HAVE_LIBTWIN_TWIN_FBDEV_H)
133 enum pbt_twin_backend backend;
137 struct pbt_twin_ctx twin_ctx;
138 twin_screen_t *tscreen;
139 twin_pixmap_t *cursor;
142 struct pbt_scr *pbt_scr_init(void *talloc_ctx, struct waitset *waitset,
143 enum pbt_twin_backend backend,
144 unsigned int width, unsigned int height,
145 const char *filename_background,
146 twin_bool_t (*scr_event_cb)(twin_screen_t *tscreen,
147 twin_event_t *event));
149 static inline struct pbt_scr *pbt_scr_from_tscreen(twin_screen_t *tscreen)
151 size_t offset = (size_t)&((struct pbt_scr *)0)->tscreen;
152 return (struct pbt_scr *)((char *)tscreen - offset);
155 void pbt_image_draw(twin_pixmap_t *dest, twin_pixmap_t *image);
157 #define pbt_dump_event(_s, _w, _e) _pbt_dump_event(_s, _w, _e, __func__, __LINE__)
158 void _pbt_dump_event(const char *text, twin_window_t *twindow,
159 const twin_event_t *tevent, const char *func, int line);
161 twin_pixmap_t *pbt_background_load(twin_screen_t *tscreen,
162 const char *filename);
163 twin_pixmap_t *pbt_icon_load(const char *filename);
164 const char *pbt_icon_chooser(const char *hint);
165 int pbt_window_contains(const twin_window_t *window, const twin_event_t *event);
166 void pbt_window_redraw(twin_window_t *twindow);
168 #define pbt_dump_pixmap(_p) \
169 DBGS("pixmap(%p): {x,y,w,h} = {%d,%d,%d,%d}\n", \