blob: 27811f3fa17e111368f452d4201575d4c88d4893 [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
Kristian Høgsberg23c03ad2011-01-19 14:41:20 -050026#include <X11/extensions/XKBcommon.h>
Fred Morcosc4b8c452010-11-28 19:31:55 +010027#include <glib.h>
28#include <wayland-client.h>
29
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050030struct window;
31
32struct rectangle {
33 int32_t x;
34 int32_t y;
35 int32_t width;
36 int32_t height;
37};
38
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -050039struct display;
Kristian Høgsberg808fd412010-07-20 17:06:19 -040040struct input;
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -050041
42struct display *
Kristian Høgsberg7824d812010-06-08 14:59:44 -040043display_create(int *argc, char **argv[], const GOptionEntry *option_entries);
44
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -040045struct wl_display *
46display_get_display(struct display *display);
47
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -050048struct wl_compositor *
49display_get_compositor(struct display *display);
50
Kristian Høgsberg58eec362011-01-19 14:27:42 -050051struct wl_shell *
52display_get_shell(struct display *display);
53
Kristian Høgsberg7824d812010-06-08 14:59:44 -040054#ifdef EGL_NO_DISPLAY
55EGLDisplay
56display_get_egl_display(struct display *d);
Kristian Høgsberg2b43bd72010-11-08 15:45:55 -050057
Kristian Høgsberg8def2642011-01-14 17:41:33 -050058#ifdef HAVE_CAIRO_EGL
Kristian Høgsberg2b43bd72010-11-08 15:45:55 -050059EGLImageKHR
60display_get_image_for_drm_surface(struct display *display,
61 cairo_surface_t *surface);
Kristian Høgsberg7824d812010-06-08 14:59:44 -040062#endif
nobled98354172011-01-05 17:48:15 +000063#endif
Kristian Høgsberg7824d812010-06-08 14:59:44 -040064
Kristian Høgsbergdcb71b62010-06-15 17:16:35 -040065cairo_surface_t *
66display_create_surface(struct display *display,
67 struct rectangle *rectangle);
68
Kristian Høgsberg9a686242010-08-18 15:28:04 -040069struct wl_buffer *
70display_get_buffer_for_surface(struct display *display,
71 cairo_surface_t *surface);
72
73cairo_surface_t *
74display_get_pointer_surface(struct display *display, int pointer,
75 int *width, int *height,
76 int *hotspot_x, int *hotspot_y);
77
Kristian Høgsberg7824d812010-06-08 14:59:44 -040078void
Kristian Høgsberg506e20e2010-08-19 17:26:02 -040079display_add_drag_listener(struct display *display,
80 const struct wl_drag_listener *drag_listener,
81 void *data);
82
83void
Kristian Høgsberge968f9c2010-08-27 22:18:00 -040084display_flush_cairo_device(struct display *display);
85
86void
Kristian Høgsberg7824d812010-06-08 14:59:44 -040087display_run(struct display *d);
88
Kristian Høgsberg9a686242010-08-18 15:28:04 -040089enum pointer_type {
90 POINTER_BOTTOM_LEFT,
91 POINTER_BOTTOM_RIGHT,
92 POINTER_BOTTOM,
93 POINTER_DRAGGING,
94 POINTER_LEFT_PTR,
95 POINTER_LEFT,
96 POINTER_RIGHT,
97 POINTER_TOP_LEFT,
98 POINTER_TOP_RIGHT,
99 POINTER_TOP,
100 POINTER_IBEAM,
101 POINTER_HAND1,
102};
103
Kristian Høgsbergda846ca2011-01-11 10:00:52 -0500104typedef void (*window_resize_handler_t)(struct window *window,
105 int32_t width, int32_t height,
106 void *data);
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400107typedef void (*window_redraw_handler_t)(struct window *window, void *data);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500108typedef void (*window_frame_handler_t)(struct window *window, uint32_t frame, uint32_t timestamp, void *data);
Kristian Høgsberg67cac8a2011-01-19 14:20:33 -0500109typedef void (*window_key_handler_t)(struct window *window, struct input *input,
110 uint32_t time, uint32_t key, uint32_t unicode,
111 uint32_t state, void *data);
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500112typedef void (*window_keyboard_focus_handler_t)(struct window *window,
Kristian Høgsberg808fd412010-07-20 17:06:19 -0400113 struct input *device, void *data);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500114
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400115typedef void (*window_button_handler_t)(struct window *window,
116 struct input *input, uint32_t time,
117 int button, int state, void *data);
118
119typedef int (*window_motion_handler_t)(struct window *window,
120 struct input *input, uint32_t time,
121 int32_t x, int32_t y,
122 int32_t sx, int32_t sy, void *data);
123
Kristian Høgsbergb46df052011-01-18 09:17:57 -0500124typedef void (*display_global_handler_t)(struct display *display,
125 const char *interface,
Kristian Høgsberg943741c2011-01-18 09:23:13 -0500126 uint32_t id,
Kristian Høgsbergb46df052011-01-18 09:17:57 -0500127 uint32_t version);
128
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500129struct window *
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -0500130window_create(struct display *display, const char *title,
Kristian Høgsberg82da52b2010-12-17 09:53:12 -0500131 int32_t width, int32_t height);
132
133void
134window_move(struct window *window, struct input *input, uint32_t time);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500135
136void
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500137window_draw(struct window *window);
138void
Kristian Høgsbergda846ca2011-01-11 10:00:52 -0500139window_get_child_allocation(struct window *window,
140 struct rectangle *allocation);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500141void
Kristian Høgsbergda846ca2011-01-11 10:00:52 -0500142window_set_child_size(struct window *window, int32_t width, int32_t height);
Kristian Høgsberg22106762008-12-08 13:50:07 -0500143void
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400144window_schedule_redraw(struct window *window);
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400145
146void
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400147window_damage(struct window *window, int32_t x, int32_t y,
148 int32_t width, int32_t height);
149
Kristian Høgsberg0ac16f02009-01-15 11:37:43 -0500150cairo_surface_t *
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400151window_get_surface(struct window *window);
152
Kristian Høgsberg0ac16f02009-01-15 11:37:43 -0500153void
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -0400154window_flush(struct window *window);
155
Kristian Høgsberg012a0072010-10-26 00:02:20 -0400156void
Bryce Harringtonf57303f2010-11-19 12:15:15 -0800157window_set_surface(struct window *window, cairo_surface_t *surface);
158
159void
Kristian Høgsberg012a0072010-10-26 00:02:20 -0400160window_create_surface(struct window *window);
161
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400162enum window_buffer_type {
163 WINDOW_BUFFER_TYPE_DRM,
164 WINDOW_BUFFER_TYPE_SHM,
165};
166
167void
168window_set_buffer_type(struct window *window, enum window_buffer_type type);
169
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -0400170void
Kristian Høgsberg0395f302008-12-22 12:14:50 -0500171window_set_fullscreen(struct window *window, int fullscreen);
172
173void
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400174window_set_user_data(struct window *window, void *data);
175
Kristian Høgsberge9d37bd2010-09-02 20:22:42 -0400176void *
177window_get_user_data(struct window *window);
178
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400179void
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400180window_set_redraw_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400181 window_redraw_handler_t handler);
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400182
183void
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400184window_set_decoration(struct window *window, int decoration);
185
186void
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500187window_set_resize_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400188 window_resize_handler_t handler);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500189void
190window_set_frame_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400191 window_frame_handler_t handler);
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400192
Kristian Høgsberg6e83d582008-12-08 00:01:36 -0500193void
194window_set_key_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400195 window_key_handler_t handler);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500196
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500197void
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400198window_set_button_handler(struct window *window,
199 window_button_handler_t handler);
200
201void
202window_set_motion_handler(struct window *window,
203 window_motion_handler_t handler);
204
205void
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500206window_set_keyboard_focus_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400207 window_keyboard_focus_handler_t handler);
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400208
209void
210window_set_frame_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400211 window_frame_handler_t handler);
Kristian Høgsberg7824d812010-06-08 14:59:44 -0400212
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400213void
Kristian Høgsbergb46df052011-01-18 09:17:57 -0500214display_set_global_handler(struct display *display,
215 display_global_handler_t handler);
216
Kristian Høgsberge9d37bd2010-09-02 20:22:42 -0400217struct wl_drag *
Kristian Høgsberg41da9082010-11-30 14:01:07 -0500218window_create_drag(struct window *window);
Kristian Høgsberge9d37bd2010-09-02 20:22:42 -0400219
Kristian Høgsberg41da9082010-11-30 14:01:07 -0500220void
221window_activate_drag(struct wl_drag *drag, struct window *window,
222 struct input *input, uint32_t time);
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400223
224void
225input_get_position(struct input *input, int32_t *x, int32_t *y);
226
Kristian Høgsberg67cac8a2011-01-19 14:20:33 -0500227uint32_t
228input_get_modifiers(struct input *input);
229
Kristian Høgsberg1d7ffd32010-08-25 16:34:05 -0400230struct wl_input_device *
231input_get_input_device(struct input *input);
232
Kristian Høgsberg58eec362011-01-19 14:27:42 -0500233int
234input_offers_mime_type(struct input *input, const char *type);
Kristian Høgsberg6bccebe2011-01-21 16:23:09 -0500235void
236input_receive_mime_type(struct input *input, const char *type, int fd);
Kristian Høgsberg58eec362011-01-19 14:27:42 -0500237
238
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500239#endif