blob: ba843cc1873dbf6131f0cb674eae9c4180248b76 [file] [log] [blame]
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -05001/*
2 * Copyright © 2008 Kristian Høgsberg
3 *
Bryce Harrington1f6b0d12015-06-10 22:48:59 -07004 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050010 *
Bryce Harrington1f6b0d12015-06-10 22:48:59 -070011 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050022 */
23
24#ifndef _WINDOW_H_
25#define _WINDOW_H_
26
Andrew Wedgbury9cd661e2014-04-07 12:40:35 +010027#include "config.h"
28
Daniel Stone9d4f0302012-02-15 16:33:21 +000029#include <xkbcommon/xkbcommon.h>
Fred Morcosc4b8c452010-11-28 19:31:55 +010030#include <wayland-client.h>
Benjamin Franzkecff904e2011-02-18 23:00:55 +010031#include <cairo.h>
Jon Cruz4678bab2015-06-15 15:37:07 -070032#include "shared/config-parser.h"
33#include "shared/zalloc.h"
34#include "shared/platform.h"
Fred Morcosc4b8c452010-11-28 19:31:55 +010035
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050036struct window;
Kristian Høgsbergc51f7992012-01-08 15:09:53 -050037struct widget;
Kristian Høgsberge28d05b2011-09-20 21:43:54 -040038struct display;
39struct input;
Kristian Høgsberg53ff2f62011-11-26 17:27:37 -050040struct output;
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050041
Kristian Høgsberg3a696272011-09-14 17:33:48 -040042struct task {
43 void (*run)(struct task *task, uint32_t events);
44 struct wl_list link;
45};
46
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050047struct rectangle {
48 int32_t x;
49 int32_t y;
50 int32_t width;
51 int32_t height;
52};
53
Kristian Høgsbergce278412013-07-25 15:20:20 -070054void *
55fail_on_null(void *p);
56void *
57xmalloc(size_t s);
Peter Huttererf3d62272013-08-08 11:57:05 +100058void *
59xzalloc(size_t s);
Kristian Høgsbergce278412013-07-25 15:20:20 -070060char *
61xstrdup(const char *s);
Kristian Høgsberg700d6ad2014-01-09 23:45:18 -080062void *
63xrealloc(char *p, size_t s);
Kristian Høgsbergce278412013-07-25 15:20:20 -070064
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -050065struct display *
Kristian Høgsberg4172f662013-02-20 15:27:49 -050066display_create(int *argc, char *argv[]);
Kristian Høgsberg7824d812010-06-08 14:59:44 -040067
Pekka Paalanen999c5b52011-11-30 10:52:38 +020068void
Pekka Paalanenfe6079a2011-12-15 15:20:04 +020069display_destroy(struct display *display);
70
71void
Pekka Paalanen999c5b52011-11-30 10:52:38 +020072display_set_user_data(struct display *display, void *data);
73
74void *
75display_get_user_data(struct display *display);
76
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -040077struct wl_display *
78display_get_display(struct display *display);
79
Kristian Høgsbergb20b0092013-08-15 11:54:03 -070080int
81display_has_subcompositor(struct display *display);
82
Kristian Høgsberg1cc5ac32013-04-11 21:47:41 -040083cairo_device_t *
84display_get_cairo_device(struct display *display);
85
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -050086struct wl_compositor *
87display_get_compositor(struct display *display);
88
Kristian Høgsberg53ff2f62011-11-26 17:27:37 -050089struct output *
90display_get_output(struct display *display);
91
Kristian Høgsbergeae5de72012-04-11 22:42:15 -040092uint32_t
93display_get_serial(struct display *display);
94
Kristian Høgsbergfa80e112012-10-10 21:34:26 -040095typedef void (*display_global_handler_t)(struct display *display,
96 uint32_t name,
97 const char *interface,
98 uint32_t version, void *data);
99
100void
101display_set_global_handler(struct display *display,
102 display_global_handler_t handler);
Xiong Zhang83d8ee72013-10-23 13:58:35 +0800103void
104display_set_global_handler_remove(struct display *display,
105 display_global_handler_t remove_handler);
Kristian Høgsbergfa80e112012-10-10 21:34:26 -0400106void *
107display_bind(struct display *display, uint32_t name,
108 const struct wl_interface *interface, uint32_t version);
109
Pekka Paalanen999c5b52011-11-30 10:52:38 +0200110typedef void (*display_output_handler_t)(struct output *output, void *data);
111
112/*
113 * The output configure handler is called, when a new output is connected
114 * and we know its current mode, or when the current mode changes.
115 * Test and set the output user data in your handler to know, if the
116 * output is new. Note: 'data' in the configure handler is the display
117 * user data.
118 */
119void
120display_set_output_configure_handler(struct display *display,
121 display_output_handler_t handler);
122
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400123struct wl_data_source *
124display_create_data_source(struct display *display);
125
Kristian Høgsberg7824d812010-06-08 14:59:44 -0400126#ifdef EGL_NO_DISPLAY
127EGLDisplay
128display_get_egl_display(struct display *d);
Kristian Høgsberg2b43bd72010-11-08 15:45:55 -0500129
Benjamin Franzkecff904e2011-02-18 23:00:55 +0100130EGLConfig
Benjamin Franzke0c991632011-09-27 21:57:31 +0200131display_get_argb_egl_config(struct display *d);
Benjamin Franzkecff904e2011-02-18 23:00:55 +0100132
Benjamin Franzke1a89f282011-10-07 09:33:06 +0200133int
Benjamin Franzkecff904e2011-02-18 23:00:55 +0100134display_acquire_window_surface(struct display *display,
135 struct window *window,
136 EGLContext ctx);
137void
Benjamin Franzke0c991632011-09-27 21:57:31 +0200138display_release_window_surface(struct display *display,
139 struct window *window);
nobled98354172011-01-05 17:48:15 +0000140#endif
Kristian Høgsberg7824d812010-06-08 14:59:44 -0400141
Kristian Høgsberg3be87d12011-05-13 13:45:17 -0400142#define SURFACE_OPAQUE 0x01
Ander Conselvan de Oliveira210eb9d2012-05-25 16:03:06 +0300143#define SURFACE_SHM 0x02
Kristian Høgsberg3be87d12011-05-13 13:45:17 -0400144
Pekka Paalanen02bba7c2013-02-13 16:17:15 +0200145#define SURFACE_HINT_RESIZE 0x10
146
Tomeu Vizosobee45a12013-08-06 20:05:54 +0200147#define SURFACE_HINT_RGB565 0x100
148
Kristian Høgsbergdcb71b62010-06-15 17:16:35 -0400149cairo_surface_t *
150display_create_surface(struct display *display,
Benjamin Franzke6693ac22011-02-10 12:04:30 +0100151 struct wl_surface *surface,
Kristian Høgsberg3be87d12011-05-13 13:45:17 -0400152 struct rectangle *rectangle,
153 uint32_t flags);
Kristian Høgsbergdcb71b62010-06-15 17:16:35 -0400154
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400155struct wl_buffer *
156display_get_buffer_for_surface(struct display *display,
157 cairo_surface_t *surface);
158
Ander Conselvan de Oliveira1042dc12012-05-22 15:39:42 +0300159struct wl_cursor_image *
160display_get_pointer_image(struct display *display, int pointer);
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400161
Kristian Høgsberg7824d812010-06-08 14:59:44 -0400162void
Kristian Høgsberg3a696272011-09-14 17:33:48 -0400163display_defer(struct display *display, struct task *task);
164
165void
166display_watch_fd(struct display *display,
167 int fd, uint32_t events, struct task *task);
168
169void
Dima Ryazanova85292e2012-11-29 00:27:09 -0800170display_unwatch_fd(struct display *display, int fd);
171
172void
Kristian Høgsberg7824d812010-06-08 14:59:44 -0400173display_run(struct display *d);
174
Pekka Paalanen826d7952011-12-15 10:14:07 +0200175void
176display_exit(struct display *d);
177
Ander Conselvan de Oliveiradc8c8fc2012-05-25 16:01:41 +0300178enum cursor_type {
179 CURSOR_BOTTOM_LEFT,
180 CURSOR_BOTTOM_RIGHT,
181 CURSOR_BOTTOM,
182 CURSOR_DRAGGING,
183 CURSOR_LEFT_PTR,
184 CURSOR_LEFT,
185 CURSOR_RIGHT,
186 CURSOR_TOP_LEFT,
187 CURSOR_TOP_RIGHT,
188 CURSOR_TOP,
189 CURSOR_IBEAM,
190 CURSOR_HAND1,
Kristian Høgsbergf3370522012-06-20 23:04:41 -0400191 CURSOR_WATCH,
192
193 CURSOR_BLANK
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400194};
195
Kristian Høgsberg67cac8a2011-01-19 14:20:33 -0500196typedef void (*window_key_handler_t)(struct window *window, struct input *input,
197 uint32_t time, uint32_t key, uint32_t unicode,
Daniel Stonec9785ea2012-05-30 16:31:52 +0100198 enum wl_keyboard_key_state state, void *data);
Tim Wiederhakedc3f8172011-01-17 17:25:34 +0100199
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500200typedef void (*window_keyboard_focus_handler_t)(struct window *window,
Kristian Høgsberg808fd412010-07-20 17:06:19 -0400201 struct input *device, void *data);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500202
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400203typedef void (*window_data_handler_t)(struct window *window,
Kristian Høgsbergeae5de72012-04-11 22:42:15 -0400204 struct input *input,
Kristian Høgsberg80680c72012-05-10 12:21:37 -0400205 float x, float y,
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400206 const char **types,
207 void *data);
208
209typedef void (*window_drop_handler_t)(struct window *window,
210 struct input *input,
211 int32_t x, int32_t y, void *data);
212
Jasper St. Pierrebf175902013-11-12 20:19:58 -0500213typedef void (*window_close_handler_t)(void *data);
Kristian Høgsberg67ace202012-07-23 21:56:31 -0400214typedef void (*window_fullscreen_handler_t)(struct window *window, void *data);
Kristian Høgsberg4f7dcd62012-01-06 21:59:05 -0500215
Ander Conselvan de Oliveira15256f62012-11-30 17:34:25 +0200216typedef void (*window_output_handler_t)(struct window *window, struct output *output,
217 int enter, void *data);
Jasper St. Pierrede680992014-04-10 17:23:49 -0700218typedef void (*window_state_changed_handler_t)(struct window *window,
219 void *data);
Ander Conselvan de Oliveira15256f62012-11-30 17:34:25 +0200220
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);
Murray Calavera883ac022015-06-06 13:02:22 +0000260typedef void (*widget_touch_frame_handler_t)(struct widget *widget,
Rusty Lynch1084da52013-08-15 09:10:08 -0700261 struct input *input, void *data);
Murray Calavera883ac022015-06-06 13:02:22 +0000262typedef void (*widget_touch_cancel_handler_t)(struct widget *widget,
Rusty Lynch1084da52013-08-15 09:10:08 -0700263 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
Peter Hutterer87743e92016-01-18 16:38:22 +1000270typedef void (*widget_pointer_frame_handler_t)(struct widget *widget,
271 struct input *input,
272 void *data);
273
274typedef void (*widget_axis_source_handler_t)(struct widget *widget,
275 struct input *input,
276 uint32_t source,
277 void *data);
278
279typedef void (*widget_axis_stop_handler_t)(struct widget *widget,
280 struct input *input,
281 uint32_t time,
282 uint32_t axis,
283 void *data);
284
285typedef void (*widget_axis_discrete_handler_t)(struct widget *widget,
286 struct input *input,
287 uint32_t axis,
288 int32_t discrete,
289 void *data);
290
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500291struct window *
Kristian Høgsberg009ac0a2012-01-31 15:24:48 -0500292window_create(struct display *display);
Kristian Høgsberg248c1b62011-01-21 18:03:15 -0500293struct window *
Kristian Høgsberg962342c2012-06-26 16:29:50 -0400294window_create_custom(struct display *display);
Kristian Høgsberg4f7dcd62012-01-06 21:59:05 -0500295
Jasper St. Pierre53686042013-12-09 15:26:25 -0500296void
Jasper St. Pierrec815d622014-04-10 18:37:54 -0700297window_set_parent(struct window *window, struct window *parent_window);
Jasper St. Pierre53686042013-12-09 15:26:25 -0500298struct window *
Jasper St. Pierrec815d622014-04-10 18:37:54 -0700299window_get_parent(struct window *window);
Jasper St. Pierre53686042013-12-09 15:26:25 -0500300
Kristian Høgsberg86adef92012-08-13 22:25:53 -0400301int
302window_has_focus(struct window *window);
303
Jasper St. Pierredda93132014-03-13 12:06:00 -0400304typedef void (*menu_func_t)(void *data, struct input *input, int index);
Kristian Høgsberg4f7dcd62012-01-06 21:59:05 -0500305
Jasper St. Pierrede8bd502014-03-13 11:57:31 -0400306struct window *
307window_create_menu(struct display *display,
308 struct input *input, uint32_t time,
309 menu_func_t func, const char **entries, int count,
310 void *user_data);
Pekka Paalanen6d174cf2012-01-19 15:17:59 +0200311void
312window_show_menu(struct display *display,
313 struct input *input, uint32_t time, struct window *parent,
314 int32_t x, int32_t y,
315 menu_func_t func, const char **entries, int count);
Kristian Høgsberg248c1b62011-01-21 18:03:15 -0500316
317void
Kristian Høgsbergd31fcab2012-01-31 09:53:44 -0500318window_show_frame_menu(struct window *window,
319 struct input *input, uint32_t time);
320
Ander Conselvan de Oliveira6d4cb4e2012-11-30 17:34:24 +0200321int
322window_get_buffer_transform(struct window *window);
323
324void
325window_set_buffer_transform(struct window *window,
326 enum wl_output_transform transform);
327
Alexander Larsson5e9b6522013-05-22 14:41:28 +0200328uint32_t
329window_get_buffer_scale(struct window *window);
330
331void
332window_set_buffer_scale(struct window *window,
Alexander Larssonedddbd12013-05-24 13:09:43 +0200333 int32_t scale);
Alexander Larsson5e9b6522013-05-22 14:41:28 +0200334
Alexander Larssond68f5232013-05-22 14:41:33 +0200335uint32_t
336window_get_output_scale(struct window *window);
337
Kristian Høgsbergd31fcab2012-01-31 09:53:44 -0500338void
Kristian Høgsberg248c1b62011-01-21 18:03:15 -0500339window_destroy(struct window *window);
340
Kristian Høgsbergc51f7992012-01-08 15:09:53 -0500341struct widget *
342window_add_widget(struct window *window, void *data);
Kristian Høgsberge28d05b2011-09-20 21:43:54 -0400343
Pekka Paalanen35e82632013-04-25 13:57:48 +0300344enum subsurface_mode {
345 SUBSURFACE_SYNCHRONIZED,
346 SUBSURFACE_DESYNCHRONIZED
347};
348
349struct widget *
350window_add_subsurface(struct window *window, void *data,
351 enum subsurface_mode default_mode);
352
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400353typedef void (*data_func_t)(void *data, size_t len,
354 int32_t x, int32_t y, void *user_data);
355
Kristian Høgsbergbcee9a42011-10-12 00:36:16 -0400356struct display *
357window_get_display(struct window *window);
Kristian Høgsberg248c1b62011-01-21 18:03:15 -0500358void
Kristian Høgsberg82da52b2010-12-17 09:53:12 -0500359window_move(struct window *window, struct input *input, uint32_t time);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500360void
Kristian Høgsbergbb977002012-01-10 19:11:42 -0500361window_get_allocation(struct window *window, struct rectangle *allocation);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500362void
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400363window_schedule_redraw(struct window *window);
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500364void
365window_schedule_resize(struct window *window, int width, int height);
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400366
Kristian Høgsberg0ac16f02009-01-15 11:37:43 -0500367cairo_surface_t *
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400368window_get_surface(struct window *window);
369
Benjamin Franzkeec4d3422011-03-14 12:07:26 +0100370struct wl_surface *
371window_get_wl_surface(struct window *window);
372
Neil Roberts5e10a042013-09-09 00:40:17 +0100373struct wl_subsurface *
374widget_get_wl_subsurface(struct widget *widget);
375
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400376enum window_buffer_type {
Benjamin Franzke6693ac22011-02-10 12:04:30 +0100377 WINDOW_BUFFER_TYPE_EGL_WINDOW,
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400378 WINDOW_BUFFER_TYPE_SHM,
379};
380
381void
Benjamin Franzkebde55ec2011-03-07 15:08:09 +0100382display_surface_damage(struct display *display, cairo_surface_t *cairo_surface,
383 int32_t x, int32_t y, int32_t width, int32_t height);
384
385void
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400386window_set_buffer_type(struct window *window, enum window_buffer_type type);
387
Manuel Bachmanncd186fb2014-04-04 10:04:18 +0200388enum window_buffer_type
389window_get_buffer_type(struct window *window);
390
Kristian Høgsberg1671e112012-10-10 11:36:24 -0400391int
392window_is_fullscreen(struct window *window);
393
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -0400394void
Kristian Høgsberg0395f302008-12-22 12:14:50 -0500395window_set_fullscreen(struct window *window, int fullscreen);
396
Kristian Høgsberg1671e112012-10-10 11:36:24 -0400397int
398window_is_maximized(struct window *window);
399
Kristian Høgsberg0395f302008-12-22 12:14:50 -0500400void
Kristian Høgsbergd6bcd7d2012-02-16 15:53:46 -0500401window_set_maximized(struct window *window, int maximized);
402
Jasper St. Pierrede680992014-04-10 17:23:49 -0700403int
404window_is_resizing(struct window *window);
405
Kristian Høgsbergd6bcd7d2012-02-16 15:53:46 -0500406void
Jasper St. Pierre5a183322014-02-18 19:18:42 -0500407window_set_minimized(struct window *window);
408
409void
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400410window_set_user_data(struct window *window, void *data);
411
Kristian Høgsberge9d37bd2010-09-02 20:22:42 -0400412void *
413window_get_user_data(struct window *window);
414
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400415void
Kristian Høgsberg6e83d582008-12-08 00:01:36 -0500416window_set_key_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400417 window_key_handler_t handler);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500418
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500419void
420window_set_keyboard_focus_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400421 window_keyboard_focus_handler_t handler);
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400422
423void
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400424window_set_data_handler(struct window *window,
425 window_data_handler_t handler);
426
427void
428window_set_drop_handler(struct window *window,
429 window_drop_handler_t handler);
430
431void
Kristian Høgsberg4f7dcd62012-01-06 21:59:05 -0500432window_set_close_handler(struct window *window,
433 window_close_handler_t handler);
Kristian Høgsberg67ace202012-07-23 21:56:31 -0400434void
435window_set_fullscreen_handler(struct window *window,
436 window_fullscreen_handler_t handler);
Ander Conselvan de Oliveira15256f62012-11-30 17:34:25 +0200437void
438window_set_output_handler(struct window *window,
439 window_output_handler_t handler);
Jasper St. Pierrede680992014-04-10 17:23:49 -0700440void
441window_set_state_changed_handler(struct window *window,
442 window_state_changed_handler_t handler);
Kristian Høgsberg4f7dcd62012-01-06 21:59:05 -0500443
444void
Callum Lowcayef57a9b2011-01-14 20:46:23 +1300445window_set_title(struct window *window, const char *title);
446
447const char *
448window_get_title(struct window *window);
449
Scott Moreau7a1b32a2012-05-27 14:25:02 -0600450void
451window_set_text_cursor_position(struct window *window, int32_t x, int32_t y);
452
Tomeu Vizosobee45a12013-08-06 20:05:54 +0200453enum preferred_format {
454 WINDOW_PREFERRED_FORMAT_NONE,
455 WINDOW_PREFERRED_FORMAT_RGB565
456};
457
458void
459window_set_preferred_format(struct window *window,
460 enum preferred_format format);
461
Tiago Vignatti82db9d82012-05-23 22:06:27 +0300462int
463widget_set_tooltip(struct widget *parent, char *entry, float x, float y);
464
465void
466widget_destroy_tooltip(struct widget *parent);
467
Kristian Høgsberg441338c2012-01-10 13:52:34 -0500468struct widget *
469widget_add_widget(struct widget *parent, void *data);
Tiago Vignatti82db9d82012-05-23 22:06:27 +0300470
Kristian Høgsberg441338c2012-01-10 13:52:34 -0500471void
472widget_destroy(struct widget *widget);
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400473void
Kristian Høgsbergbf74d522012-11-30 14:54:35 -0500474widget_set_default_cursor(struct widget *widget, int cursor);
475void
Kristian Høgsbergc51f7992012-01-08 15:09:53 -0500476widget_get_allocation(struct widget *widget, struct rectangle *allocation);
Kristian Høgsberge28d05b2011-09-20 21:43:54 -0400477
478void
Kristian Høgsbergc51f7992012-01-08 15:09:53 -0500479widget_set_allocation(struct widget *widget,
480 int32_t x, int32_t y, int32_t width, int32_t height);
Kristian Høgsbergbb977002012-01-10 19:11:42 -0500481void
482widget_set_size(struct widget *widget, int32_t width, int32_t height);
483void
Kristian Høgsberg010f98b2012-02-23 17:30:45 -0500484widget_set_transparent(struct widget *widget, int transparent);
485void
Kristian Høgsbergbb977002012-01-10 19:11:42 -0500486widget_schedule_resize(struct widget *widget, int32_t width, int32_t height);
Kristian Høgsberge28d05b2011-09-20 21:43:54 -0400487
488void *
Kristian Høgsbergc51f7992012-01-08 15:09:53 -0500489widget_get_user_data(struct widget *widget);
Kristian Høgsberge28d05b2011-09-20 21:43:54 -0400490
Pekka Paalanen0c4445b2013-02-13 16:17:23 +0200491cairo_t *
492widget_cairo_create(struct widget *widget);
493
Pekka Paalanen7ff7a802013-04-25 13:57:50 +0300494struct wl_surface *
495widget_get_wl_surface(struct widget *widget);
496
497uint32_t
498widget_get_last_time(struct widget *widget);
499
500void
501widget_input_region_add(struct widget *widget, const struct rectangle *rect);
502
Kristian Høgsberge28d05b2011-09-20 21:43:54 -0400503void
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500504widget_set_redraw_handler(struct widget *widget,
505 widget_redraw_handler_t handler);
506void
507widget_set_resize_handler(struct widget *widget,
508 widget_resize_handler_t handler);
509void
Kristian Høgsbergee143232012-01-09 08:42:24 -0500510widget_set_enter_handler(struct widget *widget,
511 widget_enter_handler_t handler);
512void
513widget_set_leave_handler(struct widget *widget,
514 widget_leave_handler_t handler);
Kristian Høgsberg04e98342012-01-09 09:36:16 -0500515void
516widget_set_motion_handler(struct widget *widget,
517 widget_motion_handler_t handler);
Kristian Høgsberg9a13dab2012-01-08 15:18:19 -0500518void
Kristian Høgsberga8a0db32012-01-09 11:12:05 -0500519widget_set_button_handler(struct widget *widget,
520 widget_button_handler_t handler);
Philipp Brüschweiler7e0cc542012-08-14 11:02:41 +0200521void
Rusty Lynch041815a2013-08-08 21:20:38 -0700522widget_set_touch_down_handler(struct widget *widget,
523 widget_touch_down_handler_t handler);
524void
525widget_set_touch_up_handler(struct widget *widget,
526 widget_touch_up_handler_t handler);
527void
528widget_set_touch_motion_handler(struct widget *widget,
529 widget_touch_motion_handler_t handler);
530void
531widget_set_touch_frame_handler(struct widget *widget,
532 widget_touch_frame_handler_t handler);
533void
534widget_set_touch_cancel_handler(struct widget *widget,
535 widget_touch_cancel_handler_t handler);
536void
Philipp Brüschweiler7e0cc542012-08-14 11:02:41 +0200537widget_set_axis_handler(struct widget *widget,
538 widget_axis_handler_t handler);
Kristian Høgsberga8a0db32012-01-09 11:12:05 -0500539void
Peter Hutterer87743e92016-01-18 16:38:22 +1000540widget_set_pointer_frame_handler(struct widget *widget,
541 widget_pointer_frame_handler_t handler);
542void
543widget_set_axis_handlers(struct widget *widget,
544 widget_axis_handler_t axis_handler,
545 widget_axis_source_handler_t axis_source_handler,
546 widget_axis_stop_handler_t axis_stop_handler,
547 widget_axis_discrete_handler_t axis_discrete_handler);
548
549void
Kristian Høgsberg9a13dab2012-01-08 15:18:19 -0500550widget_schedule_redraw(struct widget *widget);
Neil Roberts97b747c2013-12-19 16:17:12 +0000551void
552widget_set_use_cairo(struct widget *widget, int use_cairo);
Kristian Høgsberg9a13dab2012-01-08 15:18:19 -0500553
Kristian Høgsberg29af3eb2012-01-10 22:41:05 -0500554struct widget *
Jason Ekstrandee7fefc2013-10-13 19:08:38 -0500555window_frame_create(struct window *window, void *data);
Pekka Paalanen0c4445b2013-02-13 16:17:23 +0200556
Kristian Høgsberga1627922012-06-20 17:30:03 -0400557void
Jason Ekstrandee7fefc2013-10-13 19:08:38 -0500558window_frame_set_child_size(struct widget *widget, int child_width,
559 int child_height);
Kristian Høgsberg29af3eb2012-01-10 22:41:05 -0500560
Kristian Høgsberg9a13dab2012-01-08 15:18:19 -0500561void
Kristian Høgsberg5a4e9ff2012-06-04 16:04:07 -0400562input_set_pointer_image(struct input *input, int pointer);
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400563
564void
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400565input_get_position(struct input *input, int32_t *x, int32_t *y);
566
Kristian Høgsbergef9c8eb2014-01-07 12:57:59 -0800567int
568input_get_touch(struct input *input, int32_t id, float *x, float *y);
569
Kristian Høgsberg70163132012-05-08 15:55:39 -0400570#define MOD_SHIFT_MASK 0x01
571#define MOD_ALT_MASK 0x02
572#define MOD_CONTROL_MASK 0x04
573
Kristian Høgsberg67cac8a2011-01-19 14:20:33 -0500574uint32_t
575input_get_modifiers(struct input *input);
576
Kristian Høgsberg831dd522012-01-10 23:46:33 -0500577void
Xiong Zhangbf3c1c62013-11-25 18:42:51 +0800578touch_grab(struct input *input, int32_t touch_id);
579
580void
581touch_ungrab(struct input *input);
582
583void
Kristian Høgsberg831dd522012-01-10 23:46:33 -0500584input_grab(struct input *input, struct widget *widget, uint32_t button);
585
586void
Kristian Høgsbergeae5de72012-04-11 22:42:15 -0400587input_ungrab(struct input *input);
Kristian Høgsberg831dd522012-01-10 23:46:33 -0500588
Kristian Høgsbergb6323512012-01-11 00:04:42 -0500589struct widget *
590input_get_focus_widget(struct input *input);
591
Kristian Høgsbergd56bd902012-06-05 09:58:51 -0400592struct display *
593input_get_display(struct input *input);
594
Daniel Stone37816df2012-05-16 18:45:18 +0100595struct wl_seat *
596input_get_seat(struct input *input);
Kristian Høgsberg1d7ffd32010-08-25 16:34:05 -0400597
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400598struct wl_data_device *
599input_get_data_device(struct input *input);
600
Kristian Høgsberg6bccebe2011-01-21 16:23:09 -0500601void
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400602input_set_selection(struct input *input,
603 struct wl_data_source *source, uint32_t time);
604
605void
Kristian Høgsbergeae5de72012-04-11 22:42:15 -0400606input_accept(struct input *input, const char *type);
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400607
608
609void
610input_receive_drag_data(struct input *input, const char *mime_type,
611 data_func_t func, void *user_data);
Kristian Høgsberg0749e3f2013-09-04 20:41:06 -0700612int
613input_receive_drag_data_to_fd(struct input *input,
614 const char *mime_type, int fd);
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400615
616int
617input_receive_selection_data(struct input *input, const char *mime_type,
618 data_func_t func, void *data);
Kristian Høgsberge7aaec32011-12-27 13:50:04 -0500619int
620input_receive_selection_data_to_fd(struct input *input,
621 const char *mime_type, int fd);
Kristian Høgsberg58eec362011-01-19 14:27:42 -0500622
Kristian Høgsberg53ff2f62011-11-26 17:27:37 -0500623void
Pekka Paalanen999c5b52011-11-30 10:52:38 +0200624output_set_user_data(struct output *output, void *data);
625
626void *
627output_get_user_data(struct output *output);
628
629void
630output_set_destroy_handler(struct output *output,
631 display_output_handler_t handler);
632
633void
Kristian Høgsberg53ff2f62011-11-26 17:27:37 -0500634output_get_allocation(struct output *output, struct rectangle *allocation);
635
Pekka Paalanen999c5b52011-11-30 10:52:38 +0200636struct wl_output *
637output_get_wl_output(struct output *output);
Kristian Høgsberg53ff2f62011-11-26 17:27:37 -0500638
Ander Conselvan de Oliveira15256f62012-11-30 17:34:25 +0200639enum wl_output_transform
640output_get_transform(struct output *output);
641
Alexander Larssonafd319a2013-05-22 14:41:27 +0200642uint32_t
643output_get_scale(struct output *output);
644
Jason Ekstrand738715d2014-04-02 19:53:50 -0500645const char *
646output_get_make(struct output *output);
647
648const char *
649output_get_model(struct output *output);
650
Jan Arne Petersencd997062012-11-18 19:06:44 +0100651void
652keysym_modifiers_add(struct wl_array *modifiers_map,
653 const char *name);
654
655xkb_mod_mask_t
656keysym_modifiers_get_mask(struct wl_array *modifiers_map,
657 const char *name);
658
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500659#endif