4 * Copyright (c) 2012 David Herrmann <dh.herrmann@googlemail.com>
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files
8 * (the "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * Wayland Terminal toolkit helpers
41 enum wlt_display_event {
53 struct wlt_shm_buffer {
68 WLT_CURSOR_BOTTOM_LEFT,
69 WLT_CURSOR_BOTTOM_RIGHT,
76 #define WLT_WINDOW_MAXIMIZED 0x01
77 #define WLT_WINDOW_FULLSCREEN 0x02
79 typedef void (*wlt_display_cb) (struct wlt_display *disp,
82 typedef void (*wlt_window_close_cb) (struct wlt_window *wnd, void *data);
83 typedef void (*wlt_widget_redraw_cb) (struct wlt_widget *widget,
86 typedef void (*wlt_widget_destroy_cb) (struct wlt_widget *widget,
88 typedef void (*wlt_widget_prepare_resize_cb) (struct wlt_widget *widget,
92 unsigned int *min_width,
93 unsigned int *min_height,
94 unsigned int *new_width,
95 unsigned int *new_height,
97 typedef void (*wlt_widget_resize_cb) (struct wlt_widget *widget,
99 struct wlt_rect *allocation,
101 typedef void (*wlt_widget_pointer_enter_cb) (struct wlt_widget *widget,
105 typedef void (*wlt_widget_pointer_leave_cb) (struct wlt_widget *widget,
107 typedef void (*wlt_widget_pointer_motion_cb) (struct wlt_widget *widget,
111 typedef void (*wlt_widget_pointer_button_cb) (struct wlt_widget *widget,
115 typedef bool (*wlt_widget_keyboard_cb) (struct wlt_widget *widget,
123 int wlt_display_new(struct wlt_display **out,
124 struct ev_eloop *eloop);
125 void wlt_display_ref(struct wlt_display *disp);
126 void wlt_display_unref(struct wlt_display *disp);
128 int wlt_display_create_window(struct wlt_display *disp,
129 struct wlt_window **out,
133 int wlt_display_register_cb(struct wlt_display *disp,
134 wlt_display_cb cb, void *data);
135 void wlt_display_unregister_cb(struct wlt_display *disp,
136 wlt_display_cb cb, void *data);
138 int wlt_display_get_selection_fd(struct wlt_display *disp, const char *mime);
139 int wlt_display_get_selection_to_fd(struct wlt_display *disp, const char *mime,
141 int wlt_display_new_data_source(struct wlt_display *disp,
142 struct wl_data_source **out);
143 void wlt_display_set_selection(struct wlt_display *disp,
144 struct wl_data_source *selection);
146 void wlt_window_ref(struct wlt_window *wnd);
147 void wlt_window_unref(struct wlt_window *wnd);
149 int wlt_window_create_widget(struct wlt_window *wnd,
150 struct wlt_widget **out,
152 void wlt_window_schedule_redraw(struct wlt_window *wnd);
153 void wlt_window_damage(struct wlt_window *wnd,
154 struct wlt_rect *damage);
155 void wlt_window_get_buffer(struct wlt_window *wnd,
156 const struct wlt_rect *alloc,
157 struct wlt_shm_buffer *buf);
158 void wlt_window_move(struct wlt_window *wnd);
159 void wlt_window_resize(struct wlt_window *wnd, uint32_t edges);
160 int wlt_window_set_size(struct wlt_window *wnd,
161 unsigned int width, unsigned int height);
162 void wlt_window_set_cursor(struct wlt_window *wnd, unsigned int cursor);
163 void wlt_window_set_close_cb(struct wlt_window *wnd,
164 wlt_window_close_cb cb);
165 void wlt_window_close(struct wlt_window *wnd);
166 void wlt_window_toggle_maximize(struct wlt_window *wnd);
167 void wlt_window_toggle_fullscreen(struct wlt_window *wnd);
168 struct ev_eloop *wlt_window_get_eloop(struct wlt_window *wnd);
169 struct wlt_display *wlt_window_get_display(struct wlt_window *wnd);
171 void wlt_widget_destroy(struct wlt_widget *widget);
172 struct wlt_window *wlt_widget_get_window(struct wlt_widget *widget);
173 void wlt_widget_set_redraw_cb(struct wlt_widget *widget,
174 wlt_widget_redraw_cb cb);
175 void wlt_widget_set_destroy_cb(struct wlt_widget *widget,
176 wlt_widget_destroy_cb cb);
177 void wlt_widget_set_resize_cb(struct wlt_widget *widget,
178 wlt_widget_prepare_resize_cb prepare_cb,
179 wlt_widget_resize_cb cb);
180 void wlt_widget_set_pointer_cb(struct wlt_widget *widget,
181 wlt_widget_pointer_enter_cb enter_cb,
182 wlt_widget_pointer_leave_cb leave_cb,
183 wlt_widget_pointer_motion_cb motion_cb,
184 wlt_widget_pointer_button_cb button_cb);
185 void wlt_widget_set_keyboard_cb(struct wlt_widget *widget,
186 wlt_widget_keyboard_cb cb);
188 static inline bool wlt_rect_contains(struct wlt_rect *rect,
192 if (x < rect->x || y < rect->y)
194 if (x >= rect->x + rect->width)
196 if (y >= rect->y + rect->height)
201 #endif /* WLT_TOOLKIT_H */