blob: 34a5ef3276cf19fbb75ceda3e15ba49104ea73a6 [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
Andrew Wedgbury9cd661e2014-04-07 12:40:35 +010026#include "config.h"
27
Daniel Stone9d4f0302012-02-15 16:33:21 +000028#include <xkbcommon/xkbcommon.h>
Fred Morcosc4b8c452010-11-28 19:31:55 +010029#include <wayland-client.h>
Benjamin Franzkecff904e2011-02-18 23:00:55 +010030#include <cairo.h>
Kristian Høgsbergbcacef12012-03-11 21:05:57 -040031#include "../shared/config-parser.h"
Peter Huttererf3d62272013-08-08 11:57:05 +100032#include "../shared/zalloc.h"
Jonny Lamb51a7ae52015-03-20 15:26:51 +010033#include "../shared/platform.h"
Fred Morcosc4b8c452010-11-28 19:31:55 +010034
Kristian Høgsberg5717b6d2012-10-19 17:12:38 -040035#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
36
Kristian Høgsberg8c31a4c2012-10-19 23:05:37 -040037#define container_of(ptr, type, member) ({ \
38 const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
39 (type *)( (char *)__mptr - offsetof(type,member) );})
40
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050041struct window;
Kristian Høgsbergc51f7992012-01-08 15:09:53 -050042struct widget;
Kristian Høgsberge28d05b2011-09-20 21:43:54 -040043struct display;
44struct input;
Kristian Høgsberg53ff2f62011-11-26 17:27:37 -050045struct output;
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050046
Kristian Høgsberg3a696272011-09-14 17:33:48 -040047struct task {
48 void (*run)(struct task *task, uint32_t events);
49 struct wl_list link;
50};
51
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050052struct rectangle {
53 int32_t x;
54 int32_t y;
55 int32_t width;
56 int32_t height;
57};
58
Kristian Høgsbergce278412013-07-25 15:20:20 -070059void *
60fail_on_null(void *p);
61void *
62xmalloc(size_t s);
Peter Huttererf3d62272013-08-08 11:57:05 +100063void *
64xzalloc(size_t s);
Kristian Høgsbergce278412013-07-25 15:20:20 -070065char *
66xstrdup(const char *s);
Kristian Høgsberg700d6ad2014-01-09 23:45:18 -080067void *
68xrealloc(char *p, size_t s);
Kristian Høgsbergce278412013-07-25 15:20:20 -070069
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -050070struct display *
Kristian Høgsberg4172f662013-02-20 15:27:49 -050071display_create(int *argc, char *argv[]);
Kristian Høgsberg7824d812010-06-08 14:59:44 -040072
Pekka Paalanen999c5b52011-11-30 10:52:38 +020073void
Pekka Paalanenfe6079a2011-12-15 15:20:04 +020074display_destroy(struct display *display);
75
76void
Pekka Paalanen999c5b52011-11-30 10:52:38 +020077display_set_user_data(struct display *display, void *data);
78
79void *
80display_get_user_data(struct display *display);
81
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -040082struct wl_display *
83display_get_display(struct display *display);
84
Kristian Høgsbergb20b0092013-08-15 11:54:03 -070085int
86display_has_subcompositor(struct display *display);
87
Kristian Høgsberg1cc5ac32013-04-11 21:47:41 -040088cairo_device_t *
89display_get_cairo_device(struct display *display);
90
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -050091struct wl_compositor *
92display_get_compositor(struct display *display);
93
Kristian Høgsberg53ff2f62011-11-26 17:27:37 -050094struct output *
95display_get_output(struct display *display);
96
Kristian Høgsbergeae5de72012-04-11 22:42:15 -040097uint32_t
98display_get_serial(struct display *display);
99
Kristian Høgsbergfa80e112012-10-10 21:34:26 -0400100typedef void (*display_global_handler_t)(struct display *display,
101 uint32_t name,
102 const char *interface,
103 uint32_t version, void *data);
104
105void
106display_set_global_handler(struct display *display,
107 display_global_handler_t handler);
Xiong Zhang83d8ee72013-10-23 13:58:35 +0800108void
109display_set_global_handler_remove(struct display *display,
110 display_global_handler_t remove_handler);
Kristian Høgsbergfa80e112012-10-10 21:34:26 -0400111void *
112display_bind(struct display *display, uint32_t name,
113 const struct wl_interface *interface, uint32_t version);
114
Pekka Paalanen999c5b52011-11-30 10:52:38 +0200115typedef void (*display_output_handler_t)(struct output *output, void *data);
116
117/*
118 * The output configure handler is called, when a new output is connected
119 * and we know its current mode, or when the current mode changes.
120 * Test and set the output user data in your handler to know, if the
121 * output is new. Note: 'data' in the configure handler is the display
122 * user data.
123 */
124void
125display_set_output_configure_handler(struct display *display,
126 display_output_handler_t handler);
127
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400128struct wl_data_source *
129display_create_data_source(struct display *display);
130
Kristian Høgsberg7824d812010-06-08 14:59:44 -0400131#ifdef EGL_NO_DISPLAY
132EGLDisplay
133display_get_egl_display(struct display *d);
Kristian Høgsberg2b43bd72010-11-08 15:45:55 -0500134
Benjamin Franzkecff904e2011-02-18 23:00:55 +0100135EGLConfig
Benjamin Franzke0c991632011-09-27 21:57:31 +0200136display_get_argb_egl_config(struct display *d);
Benjamin Franzkecff904e2011-02-18 23:00:55 +0100137
Benjamin Franzke1a89f282011-10-07 09:33:06 +0200138int
Benjamin Franzkecff904e2011-02-18 23:00:55 +0100139display_acquire_window_surface(struct display *display,
140 struct window *window,
141 EGLContext ctx);
142void
Benjamin Franzke0c991632011-09-27 21:57:31 +0200143display_release_window_surface(struct display *display,
144 struct window *window);
nobled98354172011-01-05 17:48:15 +0000145#endif
Kristian Høgsberg7824d812010-06-08 14:59:44 -0400146
Kristian Høgsberg3be87d12011-05-13 13:45:17 -0400147#define SURFACE_OPAQUE 0x01
Ander Conselvan de Oliveira210eb9d2012-05-25 16:03:06 +0300148#define SURFACE_SHM 0x02
Kristian Høgsberg3be87d12011-05-13 13:45:17 -0400149
Pekka Paalanen02bba7c2013-02-13 16:17:15 +0200150#define SURFACE_HINT_RESIZE 0x10
151
Tomeu Vizosobee45a12013-08-06 20:05:54 +0200152#define SURFACE_HINT_RGB565 0x100
153
Kristian Høgsbergdcb71b62010-06-15 17:16:35 -0400154cairo_surface_t *
155display_create_surface(struct display *display,
Benjamin Franzke6693ac22011-02-10 12:04:30 +0100156 struct wl_surface *surface,
Kristian Høgsberg3be87d12011-05-13 13:45:17 -0400157 struct rectangle *rectangle,
158 uint32_t flags);
Kristian Høgsbergdcb71b62010-06-15 17:16:35 -0400159
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400160struct wl_buffer *
161display_get_buffer_for_surface(struct display *display,
162 cairo_surface_t *surface);
163
Ander Conselvan de Oliveira1042dc12012-05-22 15:39:42 +0300164struct wl_cursor_image *
165display_get_pointer_image(struct display *display, int pointer);
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400166
Kristian Høgsberg7824d812010-06-08 14:59:44 -0400167void
Kristian Høgsberg3a696272011-09-14 17:33:48 -0400168display_defer(struct display *display, struct task *task);
169
170void
171display_watch_fd(struct display *display,
172 int fd, uint32_t events, struct task *task);
173
174void
Dima Ryazanova85292e2012-11-29 00:27:09 -0800175display_unwatch_fd(struct display *display, int fd);
176
177void
Kristian Høgsberg7824d812010-06-08 14:59:44 -0400178display_run(struct display *d);
179
Pekka Paalanen826d7952011-12-15 10:14:07 +0200180void
181display_exit(struct display *d);
182
Ander Conselvan de Oliveiradc8c8fc2012-05-25 16:01:41 +0300183enum cursor_type {
184 CURSOR_BOTTOM_LEFT,
185 CURSOR_BOTTOM_RIGHT,
186 CURSOR_BOTTOM,
187 CURSOR_DRAGGING,
188 CURSOR_LEFT_PTR,
189 CURSOR_LEFT,
190 CURSOR_RIGHT,
191 CURSOR_TOP_LEFT,
192 CURSOR_TOP_RIGHT,
193 CURSOR_TOP,
194 CURSOR_IBEAM,
195 CURSOR_HAND1,
Kristian Høgsbergf3370522012-06-20 23:04:41 -0400196 CURSOR_WATCH,
197
198 CURSOR_BLANK
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400199};
200
Kristian Høgsberg67cac8a2011-01-19 14:20:33 -0500201typedef void (*window_key_handler_t)(struct window *window, struct input *input,
202 uint32_t time, uint32_t key, uint32_t unicode,
Daniel Stonec9785ea2012-05-30 16:31:52 +0100203 enum wl_keyboard_key_state state, void *data);
Tim Wiederhakedc3f8172011-01-17 17:25:34 +0100204
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500205typedef void (*window_keyboard_focus_handler_t)(struct window *window,
Kristian Høgsberg808fd412010-07-20 17:06:19 -0400206 struct input *device, void *data);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500207
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400208typedef void (*window_data_handler_t)(struct window *window,
Kristian Høgsbergeae5de72012-04-11 22:42:15 -0400209 struct input *input,
Kristian Høgsberg80680c72012-05-10 12:21:37 -0400210 float x, float y,
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400211 const char **types,
212 void *data);
213
214typedef void (*window_drop_handler_t)(struct window *window,
215 struct input *input,
216 int32_t x, int32_t y, void *data);
217
Jasper St. Pierrebf175902013-11-12 20:19:58 -0500218typedef void (*window_close_handler_t)(void *data);
Kristian Høgsberg67ace202012-07-23 21:56:31 -0400219typedef void (*window_fullscreen_handler_t)(struct window *window, void *data);
Kristian Høgsberg4f7dcd62012-01-06 21:59:05 -0500220
Ander Conselvan de Oliveira15256f62012-11-30 17:34:25 +0200221typedef void (*window_output_handler_t)(struct window *window, struct output *output,
222 int enter, void *data);
Jasper St. Pierrede680992014-04-10 17:23:49 -0700223typedef void (*window_state_changed_handler_t)(struct window *window,
224 void *data);
Ander Conselvan de Oliveira15256f62012-11-30 17:34:25 +0200225
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500226typedef void (*widget_resize_handler_t)(struct widget *widget,
227 int32_t width, int32_t height,
228 void *data);
229typedef void (*widget_redraw_handler_t)(struct widget *widget, void *data);
230
Kristian Høgsbergbb901fa2012-01-09 11:22:32 -0500231typedef int (*widget_enter_handler_t)(struct widget *widget,
Kristian Høgsbergeae5de72012-04-11 22:42:15 -0400232 struct input *input,
Kristian Høgsberg80680c72012-05-10 12:21:37 -0400233 float x, float y, void *data);
Kristian Høgsbergee143232012-01-09 08:42:24 -0500234typedef void (*widget_leave_handler_t)(struct widget *widget,
235 struct input *input, void *data);
Kristian Høgsberg04e98342012-01-09 09:36:16 -0500236typedef int (*widget_motion_handler_t)(struct widget *widget,
237 struct input *input, uint32_t time,
Kristian Høgsberg80680c72012-05-10 12:21:37 -0400238 float x, float y, void *data);
Kristian Høgsberga8a0db32012-01-09 11:12:05 -0500239typedef void (*widget_button_handler_t)(struct widget *widget,
240 struct input *input, uint32_t time,
Daniel Stone4dbadb12012-05-30 16:31:51 +0100241 uint32_t button,
242 enum wl_pointer_button_state state,
Daniel Stoneda5b93c2012-05-04 11:21:54 +0100243 void *data);
Rusty Lynch041815a2013-08-08 21:20:38 -0700244typedef void (*widget_touch_down_handler_t)(struct widget *widget,
Rusty Lynch1084da52013-08-15 09:10:08 -0700245 struct input *input,
Rusty Lynch041815a2013-08-08 21:20:38 -0700246 uint32_t serial,
247 uint32_t time,
248 int32_t id,
249 float x,
250 float y,
251 void *data);
252typedef void (*widget_touch_up_handler_t)(struct widget *widget,
Rusty Lynch1084da52013-08-15 09:10:08 -0700253 struct input *input,
Rusty Lynch041815a2013-08-08 21:20:38 -0700254 uint32_t serial,
255 uint32_t time,
256 int32_t id,
257 void *data);
258typedef void (*widget_touch_motion_handler_t)(struct widget *widget,
Rusty Lynch1084da52013-08-15 09:10:08 -0700259 struct input *input,
Rusty Lynch041815a2013-08-08 21:20:38 -0700260 uint32_t time,
261 int32_t id,
262 float x,
263 float y,
264 void *data);
Murray Calavera883ac022015-06-06 13:02:22 +0000265typedef void (*widget_touch_frame_handler_t)(struct widget *widget,
Rusty Lynch1084da52013-08-15 09:10:08 -0700266 struct input *input, void *data);
Murray Calavera883ac022015-06-06 13:02:22 +0000267typedef void (*widget_touch_cancel_handler_t)(struct widget *widget,
Rusty Lynch1084da52013-08-15 09:10:08 -0700268 struct input *input, void *data);
Philipp Brüschweiler7e0cc542012-08-14 11:02:41 +0200269typedef void (*widget_axis_handler_t)(struct widget *widget,
270 struct input *input, uint32_t time,
271 uint32_t axis,
272 wl_fixed_t value,
273 void *data);
Kristian Høgsbergee143232012-01-09 08:42:24 -0500274
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500275struct window *
Kristian Høgsberg009ac0a2012-01-31 15:24:48 -0500276window_create(struct display *display);
Kristian Høgsberg248c1b62011-01-21 18:03:15 -0500277struct window *
Kristian Høgsberg962342c2012-06-26 16:29:50 -0400278window_create_custom(struct display *display);
Kristian Høgsberg4f7dcd62012-01-06 21:59:05 -0500279
Jasper St. Pierre53686042013-12-09 15:26:25 -0500280void
Jasper St. Pierrec815d622014-04-10 18:37:54 -0700281window_set_parent(struct window *window, struct window *parent_window);
Jasper St. Pierre53686042013-12-09 15:26:25 -0500282struct window *
Jasper St. Pierrec815d622014-04-10 18:37:54 -0700283window_get_parent(struct window *window);
Jasper St. Pierre53686042013-12-09 15:26:25 -0500284
Kristian Høgsberg86adef92012-08-13 22:25:53 -0400285int
286window_has_focus(struct window *window);
287
Jasper St. Pierredda93132014-03-13 12:06:00 -0400288typedef void (*menu_func_t)(void *data, struct input *input, int index);
Kristian Høgsberg4f7dcd62012-01-06 21:59:05 -0500289
Jasper St. Pierrede8bd502014-03-13 11:57:31 -0400290struct window *
291window_create_menu(struct display *display,
292 struct input *input, uint32_t time,
293 menu_func_t func, const char **entries, int count,
294 void *user_data);
Pekka Paalanen6d174cf2012-01-19 15:17:59 +0200295void
296window_show_menu(struct display *display,
297 struct input *input, uint32_t time, struct window *parent,
298 int32_t x, int32_t y,
299 menu_func_t func, const char **entries, int count);
Kristian Høgsberg248c1b62011-01-21 18:03:15 -0500300
301void
Kristian Høgsbergd31fcab2012-01-31 09:53:44 -0500302window_show_frame_menu(struct window *window,
303 struct input *input, uint32_t time);
304
Ander Conselvan de Oliveira6d4cb4e2012-11-30 17:34:24 +0200305int
306window_get_buffer_transform(struct window *window);
307
308void
309window_set_buffer_transform(struct window *window,
310 enum wl_output_transform transform);
311
Alexander Larsson5e9b6522013-05-22 14:41:28 +0200312uint32_t
313window_get_buffer_scale(struct window *window);
314
315void
316window_set_buffer_scale(struct window *window,
Alexander Larssonedddbd12013-05-24 13:09:43 +0200317 int32_t scale);
Alexander Larsson5e9b6522013-05-22 14:41:28 +0200318
Alexander Larssond68f5232013-05-22 14:41:33 +0200319uint32_t
320window_get_output_scale(struct window *window);
321
Kristian Høgsbergd31fcab2012-01-31 09:53:44 -0500322void
Kristian Høgsberg248c1b62011-01-21 18:03:15 -0500323window_destroy(struct window *window);
324
Kristian Høgsbergc51f7992012-01-08 15:09:53 -0500325struct widget *
326window_add_widget(struct window *window, void *data);
Kristian Høgsberge28d05b2011-09-20 21:43:54 -0400327
Pekka Paalanen35e82632013-04-25 13:57:48 +0300328enum subsurface_mode {
329 SUBSURFACE_SYNCHRONIZED,
330 SUBSURFACE_DESYNCHRONIZED
331};
332
333struct widget *
334window_add_subsurface(struct window *window, void *data,
335 enum subsurface_mode default_mode);
336
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400337typedef void (*data_func_t)(void *data, size_t len,
338 int32_t x, int32_t y, void *user_data);
339
Kristian Høgsbergbcee9a42011-10-12 00:36:16 -0400340struct display *
341window_get_display(struct window *window);
Kristian Høgsberg248c1b62011-01-21 18:03:15 -0500342void
Kristian Høgsberg82da52b2010-12-17 09:53:12 -0500343window_move(struct window *window, struct input *input, uint32_t time);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500344void
Kristian Høgsbergbb977002012-01-10 19:11:42 -0500345window_get_allocation(struct window *window, struct rectangle *allocation);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500346void
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400347window_schedule_redraw(struct window *window);
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500348void
349window_schedule_resize(struct window *window, int width, int height);
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400350
351void
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400352window_damage(struct window *window, int32_t x, int32_t y,
353 int32_t width, int32_t height);
354
Kristian Høgsberg0ac16f02009-01-15 11:37:43 -0500355cairo_surface_t *
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400356window_get_surface(struct window *window);
357
Benjamin Franzkeec4d3422011-03-14 12:07:26 +0100358struct wl_surface *
359window_get_wl_surface(struct window *window);
360
Neil Roberts5e10a042013-09-09 00:40:17 +0100361struct wl_subsurface *
362widget_get_wl_subsurface(struct widget *widget);
363
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400364enum window_buffer_type {
Benjamin Franzke6693ac22011-02-10 12:04:30 +0100365 WINDOW_BUFFER_TYPE_EGL_WINDOW,
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400366 WINDOW_BUFFER_TYPE_SHM,
367};
368
369void
Benjamin Franzkebde55ec2011-03-07 15:08:09 +0100370display_surface_damage(struct display *display, cairo_surface_t *cairo_surface,
371 int32_t x, int32_t y, int32_t width, int32_t height);
372
373void
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400374window_set_buffer_type(struct window *window, enum window_buffer_type type);
375
Manuel Bachmanncd186fb2014-04-04 10:04:18 +0200376enum window_buffer_type
377window_get_buffer_type(struct window *window);
378
Kristian Høgsberg1671e112012-10-10 11:36:24 -0400379int
380window_is_fullscreen(struct window *window);
381
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -0400382void
Kristian Høgsberg0395f302008-12-22 12:14:50 -0500383window_set_fullscreen(struct window *window, int fullscreen);
384
Kristian Høgsberg1671e112012-10-10 11:36:24 -0400385int
386window_is_maximized(struct window *window);
387
Kristian Høgsberg0395f302008-12-22 12:14:50 -0500388void
Kristian Høgsbergd6bcd7d2012-02-16 15:53:46 -0500389window_set_maximized(struct window *window, int maximized);
390
Jasper St. Pierrede680992014-04-10 17:23:49 -0700391int
392window_is_resizing(struct window *window);
393
Kristian Høgsbergd6bcd7d2012-02-16 15:53:46 -0500394void
Jasper St. Pierre5a183322014-02-18 19:18:42 -0500395window_set_minimized(struct window *window);
396
397void
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400398window_set_user_data(struct window *window, void *data);
399
Kristian Høgsberge9d37bd2010-09-02 20:22:42 -0400400void *
401window_get_user_data(struct window *window);
402
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400403void
Kristian Høgsberg6e83d582008-12-08 00:01:36 -0500404window_set_key_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400405 window_key_handler_t handler);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500406
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500407void
408window_set_keyboard_focus_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400409 window_keyboard_focus_handler_t handler);
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400410
411void
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400412window_set_data_handler(struct window *window,
413 window_data_handler_t handler);
414
415void
416window_set_drop_handler(struct window *window,
417 window_drop_handler_t handler);
418
419void
Kristian Høgsberg4f7dcd62012-01-06 21:59:05 -0500420window_set_close_handler(struct window *window,
421 window_close_handler_t handler);
Kristian Høgsberg67ace202012-07-23 21:56:31 -0400422void
423window_set_fullscreen_handler(struct window *window,
424 window_fullscreen_handler_t handler);
Ander Conselvan de Oliveira15256f62012-11-30 17:34:25 +0200425void
426window_set_output_handler(struct window *window,
427 window_output_handler_t handler);
Jasper St. Pierrede680992014-04-10 17:23:49 -0700428void
429window_set_state_changed_handler(struct window *window,
430 window_state_changed_handler_t handler);
Kristian Høgsberg4f7dcd62012-01-06 21:59:05 -0500431
432void
Callum Lowcayef57a9b2011-01-14 20:46:23 +1300433window_set_title(struct window *window, const char *title);
434
435const char *
436window_get_title(struct window *window);
437
Scott Moreau7a1b32a2012-05-27 14:25:02 -0600438void
439window_set_text_cursor_position(struct window *window, int32_t x, int32_t y);
440
Tomeu Vizosobee45a12013-08-06 20:05:54 +0200441enum preferred_format {
442 WINDOW_PREFERRED_FORMAT_NONE,
443 WINDOW_PREFERRED_FORMAT_RGB565
444};
445
446void
447window_set_preferred_format(struct window *window,
448 enum preferred_format format);
449
Tiago Vignatti82db9d82012-05-23 22:06:27 +0300450int
451widget_set_tooltip(struct widget *parent, char *entry, float x, float y);
452
453void
454widget_destroy_tooltip(struct widget *parent);
455
Kristian Høgsberg441338c2012-01-10 13:52:34 -0500456struct widget *
457widget_add_widget(struct widget *parent, void *data);
Tiago Vignatti82db9d82012-05-23 22:06:27 +0300458
Kristian Høgsberg441338c2012-01-10 13:52:34 -0500459void
460widget_destroy(struct widget *widget);
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400461void
Kristian Høgsbergbf74d522012-11-30 14:54:35 -0500462widget_set_default_cursor(struct widget *widget, int cursor);
463void
Kristian Høgsbergc51f7992012-01-08 15:09:53 -0500464widget_get_allocation(struct widget *widget, struct rectangle *allocation);
Kristian Høgsberge28d05b2011-09-20 21:43:54 -0400465
466void
Kristian Høgsbergc51f7992012-01-08 15:09:53 -0500467widget_set_allocation(struct widget *widget,
468 int32_t x, int32_t y, int32_t width, int32_t height);
Kristian Høgsbergbb977002012-01-10 19:11:42 -0500469void
470widget_set_size(struct widget *widget, int32_t width, int32_t height);
471void
Kristian Høgsberg010f98b2012-02-23 17:30:45 -0500472widget_set_transparent(struct widget *widget, int transparent);
473void
Kristian Høgsbergbb977002012-01-10 19:11:42 -0500474widget_schedule_resize(struct widget *widget, int32_t width, int32_t height);
Kristian Høgsberge28d05b2011-09-20 21:43:54 -0400475
476void *
Kristian Høgsbergc51f7992012-01-08 15:09:53 -0500477widget_get_user_data(struct widget *widget);
Kristian Høgsberge28d05b2011-09-20 21:43:54 -0400478
Pekka Paalanen0c4445b2013-02-13 16:17:23 +0200479cairo_t *
480widget_cairo_create(struct widget *widget);
481
Pekka Paalanen7ff7a802013-04-25 13:57:50 +0300482struct wl_surface *
483widget_get_wl_surface(struct widget *widget);
484
485uint32_t
486widget_get_last_time(struct widget *widget);
487
488void
489widget_input_region_add(struct widget *widget, const struct rectangle *rect);
490
Kristian Høgsberge28d05b2011-09-20 21:43:54 -0400491void
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500492widget_set_redraw_handler(struct widget *widget,
493 widget_redraw_handler_t handler);
494void
495widget_set_resize_handler(struct widget *widget,
496 widget_resize_handler_t handler);
497void
Kristian Høgsbergee143232012-01-09 08:42:24 -0500498widget_set_enter_handler(struct widget *widget,
499 widget_enter_handler_t handler);
500void
501widget_set_leave_handler(struct widget *widget,
502 widget_leave_handler_t handler);
Kristian Høgsberg04e98342012-01-09 09:36:16 -0500503void
504widget_set_motion_handler(struct widget *widget,
505 widget_motion_handler_t handler);
Kristian Høgsberg9a13dab2012-01-08 15:18:19 -0500506void
Kristian Høgsberga8a0db32012-01-09 11:12:05 -0500507widget_set_button_handler(struct widget *widget,
508 widget_button_handler_t handler);
Philipp Brüschweiler7e0cc542012-08-14 11:02:41 +0200509void
Rusty Lynch041815a2013-08-08 21:20:38 -0700510widget_set_touch_down_handler(struct widget *widget,
511 widget_touch_down_handler_t handler);
512void
513widget_set_touch_up_handler(struct widget *widget,
514 widget_touch_up_handler_t handler);
515void
516widget_set_touch_motion_handler(struct widget *widget,
517 widget_touch_motion_handler_t handler);
518void
519widget_set_touch_frame_handler(struct widget *widget,
520 widget_touch_frame_handler_t handler);
521void
522widget_set_touch_cancel_handler(struct widget *widget,
523 widget_touch_cancel_handler_t handler);
524void
Philipp Brüschweiler7e0cc542012-08-14 11:02:41 +0200525widget_set_axis_handler(struct widget *widget,
526 widget_axis_handler_t handler);
Kristian Høgsberga8a0db32012-01-09 11:12:05 -0500527void
Kristian Høgsberg9a13dab2012-01-08 15:18:19 -0500528widget_schedule_redraw(struct widget *widget);
Neil Roberts97b747c2013-12-19 16:17:12 +0000529void
530widget_set_use_cairo(struct widget *widget, int use_cairo);
Kristian Høgsberg9a13dab2012-01-08 15:18:19 -0500531
Kristian Høgsberg29af3eb2012-01-10 22:41:05 -0500532struct widget *
Jason Ekstrandee7fefc2013-10-13 19:08:38 -0500533window_frame_create(struct window *window, void *data);
Pekka Paalanen0c4445b2013-02-13 16:17:23 +0200534
Kristian Høgsberga1627922012-06-20 17:30:03 -0400535void
Jason Ekstrandee7fefc2013-10-13 19:08:38 -0500536window_frame_set_child_size(struct widget *widget, int child_width,
537 int child_height);
Kristian Høgsberg29af3eb2012-01-10 22:41:05 -0500538
Kristian Høgsberg9a13dab2012-01-08 15:18:19 -0500539void
Kristian Høgsberg5a4e9ff2012-06-04 16:04:07 -0400540input_set_pointer_image(struct input *input, int pointer);
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400541
542void
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400543input_get_position(struct input *input, int32_t *x, int32_t *y);
544
Kristian Høgsbergef9c8eb2014-01-07 12:57:59 -0800545int
546input_get_touch(struct input *input, int32_t id, float *x, float *y);
547
Kristian Høgsberg70163132012-05-08 15:55:39 -0400548#define MOD_SHIFT_MASK 0x01
549#define MOD_ALT_MASK 0x02
550#define MOD_CONTROL_MASK 0x04
551
Kristian Høgsberg67cac8a2011-01-19 14:20:33 -0500552uint32_t
553input_get_modifiers(struct input *input);
554
Kristian Høgsberg831dd522012-01-10 23:46:33 -0500555void
Xiong Zhangbf3c1c62013-11-25 18:42:51 +0800556touch_grab(struct input *input, int32_t touch_id);
557
558void
559touch_ungrab(struct input *input);
560
561void
Kristian Høgsberg831dd522012-01-10 23:46:33 -0500562input_grab(struct input *input, struct widget *widget, uint32_t button);
563
564void
Kristian Høgsbergeae5de72012-04-11 22:42:15 -0400565input_ungrab(struct input *input);
Kristian Høgsberg831dd522012-01-10 23:46:33 -0500566
Kristian Høgsbergb6323512012-01-11 00:04:42 -0500567struct widget *
568input_get_focus_widget(struct input *input);
569
Kristian Høgsbergd56bd902012-06-05 09:58:51 -0400570struct display *
571input_get_display(struct input *input);
572
Daniel Stone37816df2012-05-16 18:45:18 +0100573struct wl_seat *
574input_get_seat(struct input *input);
Kristian Høgsberg1d7ffd32010-08-25 16:34:05 -0400575
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400576struct wl_data_device *
577input_get_data_device(struct input *input);
578
Kristian Høgsberg6bccebe2011-01-21 16:23:09 -0500579void
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400580input_set_selection(struct input *input,
581 struct wl_data_source *source, uint32_t time);
582
583void
Kristian Høgsbergeae5de72012-04-11 22:42:15 -0400584input_accept(struct input *input, const char *type);
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400585
586
587void
588input_receive_drag_data(struct input *input, const char *mime_type,
589 data_func_t func, void *user_data);
Kristian Høgsberg0749e3f2013-09-04 20:41:06 -0700590int
591input_receive_drag_data_to_fd(struct input *input,
592 const char *mime_type, int fd);
Kristian Høgsberg47fe08a2011-10-28 12:26:06 -0400593
594int
595input_receive_selection_data(struct input *input, const char *mime_type,
596 data_func_t func, void *data);
Kristian Høgsberge7aaec32011-12-27 13:50:04 -0500597int
598input_receive_selection_data_to_fd(struct input *input,
599 const char *mime_type, int fd);
Kristian Høgsberg58eec362011-01-19 14:27:42 -0500600
Kristian Høgsberg53ff2f62011-11-26 17:27:37 -0500601void
Pekka Paalanen999c5b52011-11-30 10:52:38 +0200602output_set_user_data(struct output *output, void *data);
603
604void *
605output_get_user_data(struct output *output);
606
607void
608output_set_destroy_handler(struct output *output,
609 display_output_handler_t handler);
610
611void
Kristian Høgsberg53ff2f62011-11-26 17:27:37 -0500612output_get_allocation(struct output *output, struct rectangle *allocation);
613
Pekka Paalanen999c5b52011-11-30 10:52:38 +0200614struct wl_output *
615output_get_wl_output(struct output *output);
Kristian Høgsberg53ff2f62011-11-26 17:27:37 -0500616
Ander Conselvan de Oliveira15256f62012-11-30 17:34:25 +0200617enum wl_output_transform
618output_get_transform(struct output *output);
619
Alexander Larssonafd319a2013-05-22 14:41:27 +0200620uint32_t
621output_get_scale(struct output *output);
622
Jason Ekstrand738715d2014-04-02 19:53:50 -0500623const char *
624output_get_make(struct output *output);
625
626const char *
627output_get_model(struct output *output);
628
Jan Arne Petersencd997062012-11-18 19:06:44 +0100629void
630keysym_modifiers_add(struct wl_array *modifiers_map,
631 const char *name);
632
633xkb_mod_mask_t
634keysym_modifiers_get_mask(struct wl_array *modifiers_map,
635 const char *name);
636
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500637#endif