blob: 7ec3537576264fefad14b9d111ac9f084a5fcf81 [file] [log] [blame]
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -05001/*
2 * Copyright © 2008 Kristian Høgsberg
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
13 *
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20 * OF THIS SOFTWARE.
21 */
22
23#ifndef _WINDOW_H_
24#define _WINDOW_H_
25
Daniel Stone9d4f0302012-02-15 16:33:21 +000026#include <xkbcommon/xkbcommon.h>
Fred Morcosc4b8c452010-11-28 19:31:55 +010027#include <wayland-client.h>
Benjamin Franzkecff904e2011-02-18 23:00:55 +010028#include <cairo.h>
Kristian Høgsbergbcacef12012-03-11 21:05:57 -040029#include "../shared/config-parser.h"
Peter Huttererf3d62272013-08-08 11:57:05 +100030#include "../shared/zalloc.h"
Fred Morcosc4b8c452010-11-28 19:31:55 +010031
Kristian Høgsberg5717b6d2012-10-19 17:12:38 -040032#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
33
Kristian Høgsberg8c31a4c2012-10-19 23:05:37 -040034#define container_of(ptr, type, member) ({ \
35 const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
36 (type *)( (char *)__mptr - offsetof(type,member) );})
37
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050038struct window;
Kristian Høgsbergc51f7992012-01-08 15:09:53 -050039struct widget;
Kristian Høgsberge28d05b2011-09-20 21:43:54 -040040struct display;
41struct input;
Kristian Høgsberg53ff2f62011-11-26 17:27:37 -050042struct output;
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050043
Kristian Høgsberg3a696272011-09-14 17:33:48 -040044struct task {
45 void (*run)(struct task *task, uint32_t events);
46 struct wl_list link;
47};
48
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050049struct rectangle {
50 int32_t x;
51 int32_t y;
52 int32_t width;
53 int32_t height;
54};
55
Kristian Høgsbergce278412013-07-25 15:20:20 -070056void *
57fail_on_null(void *p);
58void *
59xmalloc(size_t s);
Peter Huttererf3d62272013-08-08 11:57:05 +100060void *
61xzalloc(size_t s);
Kristian Høgsbergce278412013-07-25 15:20:20 -070062char *
63xstrdup(const char *s);
Kristian Høgsberg700d6ad2014-01-09 23:45:18 -080064void *
65xrealloc(char *p, size_t s);
Kristian Høgsbergce278412013-07-25 15:20:20 -070066
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -050067struct display *
Kristian Høgsberg4172f662013-02-20 15:27:49 -050068display_create(int *argc, char *argv[]);
Kristian Høgsberg7824d812010-06-08 14:59:44 -040069
Pekka Paalanen999c5b52011-11-30 10:52:38 +020070void
Pekka Paalanenfe6079a2011-12-15 15:20:04 +020071display_destroy(struct display *display);
72
73void
Pekka Paalanen999c5b52011-11-30 10:52:38 +020074display_set_user_data(struct display *display, void *data);
75
76void *
77display_get_user_data(struct display *display);
78
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -040079struct wl_display *
80display_get_display(struct display *display);
81
Kristian Høgsbergb20b0092013-08-15 11:54:03 -070082int
83display_has_subcompositor(struct display *display);
84
Kristian Høgsberg1cc5ac32013-04-11 21:47:41 -040085cairo_device_t *
86display_get_cairo_device(struct display *display);
87
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -050088struct wl_compositor *
89display_get_compositor(struct display *display);
90
Kristian Høgsberg53ff2f62011-11-26 17:27:37 -050091struct output *
92display_get_output(struct display *display);
93
Kristian Høgsbergeae5de72012-04-11 22:42:15 -040094uint32_t
95display_get_serial(struct display *display);
96
Kristian Høgsbergfa80e112012-10-10 21:34:26 -040097typedef void (*display_global_handler_t)(struct display *display,
98 uint32_t name,
99 const char *interface,
100 uint32_t version, void *data);
101
102void
103display_set_global_handler(struct display *display,
104 display_global_handler_t handler);
Xiong Zhang83d8ee72013-10-23 13:58:35 +0800105void
106display_set_global_handler_remove(struct display *display,
107 display_global_handler_t remove_handler);
Kristian Høgsbergfa80e112012-10-10 21:34:26 -0400108void *
109display_bind(struct display *display, uint32_t name,
110 const struct wl_interface *interface, uint32_t version);
111
Pekka Paalanen999c5b52011-11-30 10:52:38 +0200112typedef void (*display_output_handler_t)(struct output *output, void *data);
113
114/*
115 * The output configure handler is called, when a new output is connected
116 * and we know its current mode, or when the current mode changes.
117 * Test and set the output user data in your handler to know, if the
118 * output is new. Note: 'data' in the configure handler is the display
119 * user data.
120 */
121void
122display_set_output_configure_handler(struct display *display,
123 display_output_handler_t handler);
124
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400125struct wl_data_source *
126display_create_data_source(struct display *display);
127
Kristian Høgsberg7824d812010-06-08 14:59:44 -0400128#ifdef EGL_NO_DISPLAY
129EGLDisplay
130display_get_egl_display(struct display *d);
Kristian Høgsberg2b43bd72010-11-08 15:45:55 -0500131
Benjamin Franzkecff904e2011-02-18 23:00:55 +0100132EGLConfig
Benjamin Franzke0c991632011-09-27 21:57:31 +0200133display_get_argb_egl_config(struct display *d);
Benjamin Franzkecff904e2011-02-18 23:00:55 +0100134
Benjamin Franzke1a89f282011-10-07 09:33:06 +0200135int
Benjamin Franzkecff904e2011-02-18 23:00:55 +0100136display_acquire_window_surface(struct display *display,
137 struct window *window,
138 EGLContext ctx);
139void
Benjamin Franzke0c991632011-09-27 21:57:31 +0200140display_release_window_surface(struct display *display,
141 struct window *window);
nobled98354172011-01-05 17:48:15 +0000142#endif
Kristian Høgsberg7824d812010-06-08 14:59:44 -0400143
Kristian Høgsberg3be87d12011-05-13 13:45:17 -0400144#define SURFACE_OPAQUE 0x01
Ander Conselvan de Oliveira210eb9d2012-05-25 16:03:06 +0300145#define SURFACE_SHM 0x02
Kristian Høgsberg3be87d12011-05-13 13:45:17 -0400146
Pekka Paalanen02bba7c2013-02-13 16:17:15 +0200147#define SURFACE_HINT_RESIZE 0x10
148
Tomeu Vizosobee45a12013-08-06 20:05:54 +0200149#define SURFACE_HINT_RGB565 0x100
150
Kristian Høgsbergdcb71b62010-06-15 17:16:35 -0400151cairo_surface_t *
152display_create_surface(struct display *display,
Benjamin Franzke6693ac22011-02-10 12:04:30 +0100153 struct wl_surface *surface,
Kristian Høgsberg3be87d12011-05-13 13:45:17 -0400154 struct rectangle *rectangle,
155 uint32_t flags);
Kristian Høgsbergdcb71b62010-06-15 17:16:35 -0400156
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400157struct wl_buffer *
158display_get_buffer_for_surface(struct display *display,
159 cairo_surface_t *surface);
160
Ander Conselvan de Oliveira1042dc12012-05-22 15:39:42 +0300161struct wl_cursor_image *
162display_get_pointer_image(struct display *display, int pointer);
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400163
Kristian Høgsberg7824d812010-06-08 14:59:44 -0400164void
Kristian Høgsberg3a696272011-09-14 17:33:48 -0400165display_defer(struct display *display, struct task *task);
166
167void
168display_watch_fd(struct display *display,
169 int fd, uint32_t events, struct task *task);
170
171void
Dima Ryazanova85292e2012-11-29 00:27:09 -0800172display_unwatch_fd(struct display *display, int fd);
173
174void
Kristian Høgsberg7824d812010-06-08 14:59:44 -0400175display_run(struct display *d);
176
Pekka Paalanen826d7952011-12-15 10:14:07 +0200177void
178display_exit(struct display *d);
179
Ander Conselvan de Oliveiradc8c8fc2012-05-25 16:01:41 +0300180enum cursor_type {
181 CURSOR_BOTTOM_LEFT,
182 CURSOR_BOTTOM_RIGHT,
183 CURSOR_BOTTOM,
184 CURSOR_DRAGGING,
185 CURSOR_LEFT_PTR,
186 CURSOR_LEFT,
187 CURSOR_RIGHT,
188 CURSOR_TOP_LEFT,
189 CURSOR_TOP_RIGHT,
190 CURSOR_TOP,
191 CURSOR_IBEAM,
192 CURSOR_HAND1,
Kristian Høgsbergf3370522012-06-20 23:04:41 -0400193 CURSOR_WATCH,
194
195 CURSOR_BLANK
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400196};
197
Kristian Høgsberg67cac8a2011-01-19 14:20:33 -0500198typedef void (*window_key_handler_t)(struct window *window, struct input *input,
199 uint32_t time, uint32_t key, uint32_t unicode,
Daniel Stonec9785ea2012-05-30 16:31:52 +0100200 enum wl_keyboard_key_state state, void *data);
Tim Wiederhakedc3f8172011-01-17 17:25:34 +0100201
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500202typedef void (*window_keyboard_focus_handler_t)(struct window *window,
Kristian Høgsberg808fd412010-07-20 17:06:19 -0400203 struct input *device, void *data);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500204
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400205typedef void (*window_data_handler_t)(struct window *window,
Kristian Høgsbergeae5de72012-04-11 22:42:15 -0400206 struct input *input,
Kristian Høgsberg80680c72012-05-10 12:21:37 -0400207 float x, float y,
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400208 const char **types,
209 void *data);
210
211typedef void (*window_drop_handler_t)(struct window *window,
212 struct input *input,
213 int32_t x, int32_t y, void *data);
214
Jasper St. Pierrebf175902013-11-12 20:19:58 -0500215typedef void (*window_close_handler_t)(void *data);
Kristian Høgsberg67ace202012-07-23 21:56:31 -0400216typedef void (*window_fullscreen_handler_t)(struct window *window, void *data);
Kristian Høgsberg4f7dcd62012-01-06 21:59:05 -0500217
Ander Conselvan de Oliveira15256f62012-11-30 17:34:25 +0200218typedef void (*window_output_handler_t)(struct window *window, struct output *output,
219 int enter, void *data);
220
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500221typedef void (*widget_resize_handler_t)(struct widget *widget,
222 int32_t width, int32_t height,
223 void *data);
224typedef void (*widget_redraw_handler_t)(struct widget *widget, void *data);
225
Kristian Høgsbergbb901fa2012-01-09 11:22:32 -0500226typedef int (*widget_enter_handler_t)(struct widget *widget,
Kristian Høgsbergeae5de72012-04-11 22:42:15 -0400227 struct input *input,
Kristian Høgsberg80680c72012-05-10 12:21:37 -0400228 float x, float y, void *data);
Kristian Høgsbergee143232012-01-09 08:42:24 -0500229typedef void (*widget_leave_handler_t)(struct widget *widget,
230 struct input *input, void *data);
Kristian Høgsberg04e98342012-01-09 09:36:16 -0500231typedef int (*widget_motion_handler_t)(struct widget *widget,
232 struct input *input, uint32_t time,
Kristian Høgsberg80680c72012-05-10 12:21:37 -0400233 float x, float y, void *data);
Kristian Høgsberga8a0db32012-01-09 11:12:05 -0500234typedef void (*widget_button_handler_t)(struct widget *widget,
235 struct input *input, uint32_t time,
Daniel Stone4dbadb12012-05-30 16:31:51 +0100236 uint32_t button,
237 enum wl_pointer_button_state state,
Daniel Stoneda5b93c2012-05-04 11:21:54 +0100238 void *data);
Rusty Lynch041815a2013-08-08 21:20:38 -0700239typedef void (*widget_touch_down_handler_t)(struct widget *widget,
Rusty Lynch1084da52013-08-15 09:10:08 -0700240 struct input *input,
Rusty Lynch041815a2013-08-08 21:20:38 -0700241 uint32_t serial,
242 uint32_t time,
243 int32_t id,
244 float x,
245 float y,
246 void *data);
247typedef void (*widget_touch_up_handler_t)(struct widget *widget,
Rusty Lynch1084da52013-08-15 09:10:08 -0700248 struct input *input,
Rusty Lynch041815a2013-08-08 21:20:38 -0700249 uint32_t serial,
250 uint32_t time,
251 int32_t id,
252 void *data);
253typedef void (*widget_touch_motion_handler_t)(struct widget *widget,
Rusty Lynch1084da52013-08-15 09:10:08 -0700254 struct input *input,
Rusty Lynch041815a2013-08-08 21:20:38 -0700255 uint32_t time,
256 int32_t id,
257 float x,
258 float y,
259 void *data);
Rusty Lynch1084da52013-08-15 09:10:08 -0700260typedef void (*widget_touch_frame_handler_t)(struct widget *widget,
261 struct input *input, void *data);
262typedef void (*widget_touch_cancel_handler_t)(struct widget *widget,
263 struct input *input, void *data);
Philipp Brüschweiler7e0cc542012-08-14 11:02:41 +0200264typedef void (*widget_axis_handler_t)(struct widget *widget,
265 struct input *input, uint32_t time,
266 uint32_t axis,
267 wl_fixed_t value,
268 void *data);
Kristian Høgsbergee143232012-01-09 08:42:24 -0500269
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500270struct window *
Kristian Høgsberg009ac0a2012-01-31 15:24:48 -0500271window_create(struct display *display);
Kristian Høgsberg248c1b62011-01-21 18:03:15 -0500272struct window *
Kristian Høgsberg962342c2012-06-26 16:29:50 -0400273window_create_custom(struct display *display);
Kristian Høgsberg4f7dcd62012-01-06 21:59:05 -0500274
Jasper St. Pierre53686042013-12-09 15:26:25 -0500275void
276window_set_transient_for(struct window *window, struct window *parent_window);
277struct window *
278window_get_transient_for(struct window *window);
279
Kristian Høgsberg86adef92012-08-13 22:25:53 -0400280int
281window_has_focus(struct window *window);
282
Kristian Høgsberg67b82152013-10-23 16:52:05 -0700283typedef void (*menu_func_t)(struct window *window,
284 struct input *input, int index, void *data);
Kristian Høgsberg4f7dcd62012-01-06 21:59:05 -0500285
Pekka Paalanen6d174cf2012-01-19 15:17:59 +0200286void
287window_show_menu(struct display *display,
288 struct input *input, uint32_t time, struct window *parent,
289 int32_t x, int32_t y,
290 menu_func_t func, const char **entries, int count);
Kristian Høgsberg248c1b62011-01-21 18:03:15 -0500291
292void
Kristian Høgsbergd31fcab2012-01-31 09:53:44 -0500293window_show_frame_menu(struct window *window,
294 struct input *input, uint32_t time);
295
Ander Conselvan de Oliveira6d4cb4e2012-11-30 17:34:24 +0200296int
297window_get_buffer_transform(struct window *window);
298
299void
300window_set_buffer_transform(struct window *window,
301 enum wl_output_transform transform);
302
Alexander Larsson5e9b6522013-05-22 14:41:28 +0200303uint32_t
304window_get_buffer_scale(struct window *window);
305
306void
307window_set_buffer_scale(struct window *window,
Alexander Larssonedddbd12013-05-24 13:09:43 +0200308 int32_t scale);
Alexander Larsson5e9b6522013-05-22 14:41:28 +0200309
Alexander Larssond68f5232013-05-22 14:41:33 +0200310uint32_t
311window_get_output_scale(struct window *window);
312
Kristian Høgsbergd31fcab2012-01-31 09:53:44 -0500313void
Kristian Høgsberg248c1b62011-01-21 18:03:15 -0500314window_destroy(struct window *window);
315
Kristian Høgsbergc51f7992012-01-08 15:09:53 -0500316struct widget *
317window_add_widget(struct window *window, void *data);
Kristian Høgsberge28d05b2011-09-20 21:43:54 -0400318
Pekka Paalanen35e82632013-04-25 13:57:48 +0300319enum subsurface_mode {
320 SUBSURFACE_SYNCHRONIZED,
321 SUBSURFACE_DESYNCHRONIZED
322};
323
324struct widget *
325window_add_subsurface(struct window *window, void *data,
326 enum subsurface_mode default_mode);
327
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400328typedef void (*data_func_t)(void *data, size_t len,
329 int32_t x, int32_t y, void *user_data);
330
Kristian Høgsbergbcee9a42011-10-12 00:36:16 -0400331struct display *
332window_get_display(struct window *window);
Kristian Høgsberg248c1b62011-01-21 18:03:15 -0500333void
Kristian Høgsberg82da52b2010-12-17 09:53:12 -0500334window_move(struct window *window, struct input *input, uint32_t time);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500335void
Kristian Høgsbergbb977002012-01-10 19:11:42 -0500336window_get_allocation(struct window *window, struct rectangle *allocation);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500337void
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400338window_schedule_redraw(struct window *window);
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500339void
340window_schedule_resize(struct window *window, int width, int height);
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400341
342void
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400343window_damage(struct window *window, int32_t x, int32_t y,
344 int32_t width, int32_t height);
345
Kristian Høgsberg0ac16f02009-01-15 11:37:43 -0500346cairo_surface_t *
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400347window_get_surface(struct window *window);
348
Benjamin Franzkeec4d3422011-03-14 12:07:26 +0100349struct wl_surface *
350window_get_wl_surface(struct window *window);
351
Neil Roberts5e10a042013-09-09 00:40:17 +0100352struct wl_subsurface *
353widget_get_wl_subsurface(struct widget *widget);
354
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400355enum window_buffer_type {
Benjamin Franzke6693ac22011-02-10 12:04:30 +0100356 WINDOW_BUFFER_TYPE_EGL_WINDOW,
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400357 WINDOW_BUFFER_TYPE_SHM,
358};
359
360void
Benjamin Franzkebde55ec2011-03-07 15:08:09 +0100361display_surface_damage(struct display *display, cairo_surface_t *cairo_surface,
362 int32_t x, int32_t y, int32_t width, int32_t height);
363
364void
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400365window_set_buffer_type(struct window *window, enum window_buffer_type type);
366
Kristian Høgsberg1671e112012-10-10 11:36:24 -0400367int
368window_is_fullscreen(struct window *window);
369
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -0400370void
Kristian Høgsberg0395f302008-12-22 12:14:50 -0500371window_set_fullscreen(struct window *window, int fullscreen);
372
Kristian Høgsberg1671e112012-10-10 11:36:24 -0400373int
374window_is_maximized(struct window *window);
375
Kristian Høgsberg0395f302008-12-22 12:14:50 -0500376void
Kristian Høgsbergd6bcd7d2012-02-16 15:53:46 -0500377window_set_maximized(struct window *window, int maximized);
378
379void
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400380window_set_user_data(struct window *window, void *data);
381
Kristian Høgsberge9d37bd2010-09-02 20:22:42 -0400382void *
383window_get_user_data(struct window *window);
384
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400385void
Kristian Høgsberg6e83d582008-12-08 00:01:36 -0500386window_set_key_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400387 window_key_handler_t handler);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500388
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500389void
390window_set_keyboard_focus_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400391 window_keyboard_focus_handler_t handler);
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400392
393void
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400394window_set_data_handler(struct window *window,
395 window_data_handler_t handler);
396
397void
398window_set_drop_handler(struct window *window,
399 window_drop_handler_t handler);
400
401void
Kristian Høgsberg4f7dcd62012-01-06 21:59:05 -0500402window_set_close_handler(struct window *window,
403 window_close_handler_t handler);
Kristian Høgsberg67ace202012-07-23 21:56:31 -0400404void
405window_set_fullscreen_handler(struct window *window,
406 window_fullscreen_handler_t handler);
Ander Conselvan de Oliveira15256f62012-11-30 17:34:25 +0200407void
408window_set_output_handler(struct window *window,
409 window_output_handler_t handler);
Kristian Høgsberg4f7dcd62012-01-06 21:59:05 -0500410
411void
Callum Lowcayef57a9b2011-01-14 20:46:23 +1300412window_set_title(struct window *window, const char *title);
413
414const char *
415window_get_title(struct window *window);
416
Scott Moreau7a1b32a2012-05-27 14:25:02 -0600417void
418window_set_text_cursor_position(struct window *window, int32_t x, int32_t y);
419
Tomeu Vizosobee45a12013-08-06 20:05:54 +0200420enum preferred_format {
421 WINDOW_PREFERRED_FORMAT_NONE,
422 WINDOW_PREFERRED_FORMAT_RGB565
423};
424
425void
426window_set_preferred_format(struct window *window,
427 enum preferred_format format);
428
Tiago Vignatti82db9d82012-05-23 22:06:27 +0300429int
430widget_set_tooltip(struct widget *parent, char *entry, float x, float y);
431
432void
433widget_destroy_tooltip(struct widget *parent);
434
Kristian Høgsberg441338c2012-01-10 13:52:34 -0500435struct widget *
436widget_add_widget(struct widget *parent, void *data);
Tiago Vignatti82db9d82012-05-23 22:06:27 +0300437
Kristian Høgsberg441338c2012-01-10 13:52:34 -0500438void
439widget_destroy(struct widget *widget);
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400440void
Kristian Høgsbergbf74d522012-11-30 14:54:35 -0500441widget_set_default_cursor(struct widget *widget, int cursor);
442void
Kristian Høgsbergc51f7992012-01-08 15:09:53 -0500443widget_get_allocation(struct widget *widget, struct rectangle *allocation);
Kristian Høgsberge28d05b2011-09-20 21:43:54 -0400444
445void
Kristian Høgsbergc51f7992012-01-08 15:09:53 -0500446widget_set_allocation(struct widget *widget,
447 int32_t x, int32_t y, int32_t width, int32_t height);
Kristian Høgsbergbb977002012-01-10 19:11:42 -0500448void
449widget_set_size(struct widget *widget, int32_t width, int32_t height);
450void
Kristian Høgsberg010f98b2012-02-23 17:30:45 -0500451widget_set_transparent(struct widget *widget, int transparent);
452void
Kristian Høgsbergbb977002012-01-10 19:11:42 -0500453widget_schedule_resize(struct widget *widget, int32_t width, int32_t height);
Kristian Høgsberge28d05b2011-09-20 21:43:54 -0400454
455void *
Kristian Høgsbergc51f7992012-01-08 15:09:53 -0500456widget_get_user_data(struct widget *widget);
Kristian Høgsberge28d05b2011-09-20 21:43:54 -0400457
Pekka Paalanen0c4445b2013-02-13 16:17:23 +0200458cairo_t *
459widget_cairo_create(struct widget *widget);
460
Pekka Paalanen7ff7a802013-04-25 13:57:50 +0300461struct wl_surface *
462widget_get_wl_surface(struct widget *widget);
463
464uint32_t
465widget_get_last_time(struct widget *widget);
466
467void
468widget_input_region_add(struct widget *widget, const struct rectangle *rect);
469
Kristian Høgsberge28d05b2011-09-20 21:43:54 -0400470void
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500471widget_set_redraw_handler(struct widget *widget,
472 widget_redraw_handler_t handler);
473void
474widget_set_resize_handler(struct widget *widget,
475 widget_resize_handler_t handler);
476void
Kristian Høgsbergee143232012-01-09 08:42:24 -0500477widget_set_enter_handler(struct widget *widget,
478 widget_enter_handler_t handler);
479void
480widget_set_leave_handler(struct widget *widget,
481 widget_leave_handler_t handler);
Kristian Høgsberg04e98342012-01-09 09:36:16 -0500482void
483widget_set_motion_handler(struct widget *widget,
484 widget_motion_handler_t handler);
Kristian Høgsberg9a13dab2012-01-08 15:18:19 -0500485void
Kristian Høgsberga8a0db32012-01-09 11:12:05 -0500486widget_set_button_handler(struct widget *widget,
487 widget_button_handler_t handler);
Philipp Brüschweiler7e0cc542012-08-14 11:02:41 +0200488void
Rusty Lynch041815a2013-08-08 21:20:38 -0700489widget_set_touch_down_handler(struct widget *widget,
490 widget_touch_down_handler_t handler);
491void
492widget_set_touch_up_handler(struct widget *widget,
493 widget_touch_up_handler_t handler);
494void
495widget_set_touch_motion_handler(struct widget *widget,
496 widget_touch_motion_handler_t handler);
497void
498widget_set_touch_frame_handler(struct widget *widget,
499 widget_touch_frame_handler_t handler);
500void
501widget_set_touch_cancel_handler(struct widget *widget,
502 widget_touch_cancel_handler_t handler);
503void
Philipp Brüschweiler7e0cc542012-08-14 11:02:41 +0200504widget_set_axis_handler(struct widget *widget,
505 widget_axis_handler_t handler);
Kristian Høgsberga8a0db32012-01-09 11:12:05 -0500506void
Kristian Høgsberg9a13dab2012-01-08 15:18:19 -0500507widget_schedule_redraw(struct widget *widget);
Neil Roberts97b747c2013-12-19 16:17:12 +0000508void
509widget_set_use_cairo(struct widget *widget, int use_cairo);
Kristian Høgsberg9a13dab2012-01-08 15:18:19 -0500510
Kristian Høgsberg29af3eb2012-01-10 22:41:05 -0500511struct widget *
Jason Ekstrandee7fefc2013-10-13 19:08:38 -0500512window_frame_create(struct window *window, void *data);
Pekka Paalanen0c4445b2013-02-13 16:17:23 +0200513
Kristian Høgsberga1627922012-06-20 17:30:03 -0400514void
Jason Ekstrandee7fefc2013-10-13 19:08:38 -0500515window_frame_set_child_size(struct widget *widget, int child_width,
516 int child_height);
Kristian Høgsberg29af3eb2012-01-10 22:41:05 -0500517
Kristian Høgsberg9a13dab2012-01-08 15:18:19 -0500518void
Kristian Høgsberg5a4e9ff2012-06-04 16:04:07 -0400519input_set_pointer_image(struct input *input, int pointer);
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400520
521void
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400522input_get_position(struct input *input, int32_t *x, int32_t *y);
523
Kristian Høgsbergef9c8eb2014-01-07 12:57:59 -0800524int
525input_get_touch(struct input *input, int32_t id, float *x, float *y);
526
Kristian Høgsberg70163132012-05-08 15:55:39 -0400527#define MOD_SHIFT_MASK 0x01
528#define MOD_ALT_MASK 0x02
529#define MOD_CONTROL_MASK 0x04
530
Kristian Høgsberg67cac8a2011-01-19 14:20:33 -0500531uint32_t
532input_get_modifiers(struct input *input);
533
Kristian Høgsberg831dd522012-01-10 23:46:33 -0500534void
Xiong Zhangbf3c1c62013-11-25 18:42:51 +0800535touch_grab(struct input *input, int32_t touch_id);
536
537void
538touch_ungrab(struct input *input);
539
540void
Kristian Høgsberg831dd522012-01-10 23:46:33 -0500541input_grab(struct input *input, struct widget *widget, uint32_t button);
542
543void
Kristian Høgsbergeae5de72012-04-11 22:42:15 -0400544input_ungrab(struct input *input);
Kristian Høgsberg831dd522012-01-10 23:46:33 -0500545
Kristian Høgsbergb6323512012-01-11 00:04:42 -0500546struct widget *
547input_get_focus_widget(struct input *input);
548
Kristian Høgsbergd56bd902012-06-05 09:58:51 -0400549struct display *
550input_get_display(struct input *input);
551
Daniel Stone37816df2012-05-16 18:45:18 +0100552struct wl_seat *
553input_get_seat(struct input *input);
Kristian Høgsberg1d7ffd32010-08-25 16:34:05 -0400554
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400555struct wl_data_device *
556input_get_data_device(struct input *input);
557
Kristian Høgsberg6bccebe2011-01-21 16:23:09 -0500558void
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400559input_set_selection(struct input *input,
560 struct wl_data_source *source, uint32_t time);
561
562void
Kristian Høgsbergeae5de72012-04-11 22:42:15 -0400563input_accept(struct input *input, const char *type);
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400564
565
566void
567input_receive_drag_data(struct input *input, const char *mime_type,
568 data_func_t func, void *user_data);
Kristian Høgsberg0749e3f2013-09-04 20:41:06 -0700569int
570input_receive_drag_data_to_fd(struct input *input,
571 const char *mime_type, int fd);
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400572
573int
574input_receive_selection_data(struct input *input, const char *mime_type,
575 data_func_t func, void *data);
Kristian Høgsberge7aaec32011-12-27 13:50:04 -0500576int
577input_receive_selection_data_to_fd(struct input *input,
578 const char *mime_type, int fd);
Kristian Høgsberg58eec362011-01-19 14:27:42 -0500579
Kristian Høgsberg53ff2f62011-11-26 17:27:37 -0500580void
Pekka Paalanen999c5b52011-11-30 10:52:38 +0200581output_set_user_data(struct output *output, void *data);
582
583void *
584output_get_user_data(struct output *output);
585
586void
587output_set_destroy_handler(struct output *output,
588 display_output_handler_t handler);
589
590void
Kristian Høgsberg53ff2f62011-11-26 17:27:37 -0500591output_get_allocation(struct output *output, struct rectangle *allocation);
592
Pekka Paalanen999c5b52011-11-30 10:52:38 +0200593struct wl_output *
594output_get_wl_output(struct output *output);
Kristian Høgsberg53ff2f62011-11-26 17:27:37 -0500595
Ander Conselvan de Oliveira15256f62012-11-30 17:34:25 +0200596enum wl_output_transform
597output_get_transform(struct output *output);
598
Alexander Larssonafd319a2013-05-22 14:41:27 +0200599uint32_t
600output_get_scale(struct output *output);
601
Jan Arne Petersencd997062012-11-18 19:06:44 +0100602void
603keysym_modifiers_add(struct wl_array *modifiers_map,
604 const char *name);
605
606xkb_mod_mask_t
607keysym_modifiers_get_mask(struct wl_array *modifiers_map,
608 const char *name);
609
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500610#endif