blob: dc801237468935fdf21cf163c9a4f2d75c91c4c7 [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>
Benjamin Franzkecff904e2011-02-18 23:00:55 +010029#include <cairo.h>
Fred Morcosc4b8c452010-11-28 19:31:55 +010030
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050031struct window;
32
33struct rectangle {
34 int32_t x;
35 int32_t y;
36 int32_t width;
37 int32_t height;
38};
39
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -050040struct display;
Kristian Høgsberg808fd412010-07-20 17:06:19 -040041struct input;
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -050042
43struct display *
Kristian Høgsberg9de79a92011-08-24 11:09:53 -040044display_create(int *argc, char **argv[], const GOptionEntry *option_entries);
Kristian Høgsberg7824d812010-06-08 14:59:44 -040045
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -040046struct wl_display *
47display_get_display(struct display *display);
48
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -050049struct wl_compositor *
50display_get_compositor(struct display *display);
51
Kristian Høgsberg58eec362011-01-19 14:27:42 -050052struct wl_shell *
53display_get_shell(struct display *display);
54
Kristian Høgsberg7824d812010-06-08 14:59:44 -040055#ifdef EGL_NO_DISPLAY
56EGLDisplay
57display_get_egl_display(struct display *d);
Kristian Høgsberg2b43bd72010-11-08 15:45:55 -050058
Benjamin Franzkecff904e2011-02-18 23:00:55 +010059EGLConfig
60display_get_egl_config(struct display *d);
61
62void
63display_acquire_window_surface(struct display *display,
64 struct window *window,
65 EGLContext ctx);
66void
67display_release(struct display *display);
68
Kristian Høgsberg8def2642011-01-14 17:41:33 -050069#ifdef HAVE_CAIRO_EGL
Kristian Høgsberg2b43bd72010-11-08 15:45:55 -050070EGLImageKHR
Kristian Høgsberg297c6312011-02-04 14:11:33 -050071display_get_image_for_egl_image_surface(struct display *display,
72 cairo_surface_t *surface);
Kristian Høgsberg7824d812010-06-08 14:59:44 -040073#endif
nobled98354172011-01-05 17:48:15 +000074#endif
Kristian Høgsberg7824d812010-06-08 14:59:44 -040075
Kristian Høgsberg3be87d12011-05-13 13:45:17 -040076#define SURFACE_OPAQUE 0x01
77
Kristian Høgsbergdcb71b62010-06-15 17:16:35 -040078cairo_surface_t *
79display_create_surface(struct display *display,
Benjamin Franzke6693ac22011-02-10 12:04:30 +010080 struct wl_surface *surface,
Kristian Høgsberg3be87d12011-05-13 13:45:17 -040081 struct rectangle *rectangle,
82 uint32_t flags);
Kristian Høgsbergdcb71b62010-06-15 17:16:35 -040083
Kristian Høgsberg9a686242010-08-18 15:28:04 -040084struct wl_buffer *
85display_get_buffer_for_surface(struct display *display,
86 cairo_surface_t *surface);
87
88cairo_surface_t *
89display_get_pointer_surface(struct display *display, int pointer,
90 int *width, int *height,
91 int *hotspot_x, int *hotspot_y);
92
Kristian Høgsberg7824d812010-06-08 14:59:44 -040093void
Kristian Høgsberg506e20e2010-08-19 17:26:02 -040094display_add_drag_listener(struct display *display,
95 const struct wl_drag_listener *drag_listener,
96 void *data);
97
98void
Kristian Høgsberge968f9c2010-08-27 22:18:00 -040099display_flush_cairo_device(struct display *display);
100
101void
Kristian Høgsberg7824d812010-06-08 14:59:44 -0400102display_run(struct display *d);
103
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400104enum pointer_type {
105 POINTER_BOTTOM_LEFT,
106 POINTER_BOTTOM_RIGHT,
107 POINTER_BOTTOM,
108 POINTER_DRAGGING,
109 POINTER_LEFT_PTR,
110 POINTER_LEFT,
111 POINTER_RIGHT,
112 POINTER_TOP_LEFT,
113 POINTER_TOP_RIGHT,
114 POINTER_TOP,
115 POINTER_IBEAM,
116 POINTER_HAND1,
117};
118
Kristian Høgsbergda846ca2011-01-11 10:00:52 -0500119typedef void (*window_resize_handler_t)(struct window *window,
120 int32_t width, int32_t height,
121 void *data);
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400122typedef void (*window_redraw_handler_t)(struct window *window, void *data);
Tim Wiederhakedc3f8172011-01-17 17:25:34 +0100123
Kristian Høgsberg67cac8a2011-01-19 14:20:33 -0500124typedef void (*window_key_handler_t)(struct window *window, struct input *input,
125 uint32_t time, uint32_t key, uint32_t unicode,
126 uint32_t state, void *data);
Tim Wiederhakedc3f8172011-01-17 17:25:34 +0100127
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500128typedef void (*window_keyboard_focus_handler_t)(struct window *window,
Kristian Høgsberg808fd412010-07-20 17:06:19 -0400129 struct input *device, void *data);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500130
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400131typedef void (*window_button_handler_t)(struct window *window,
132 struct input *input, uint32_t time,
133 int button, int state, void *data);
134
Kristian Høgsberg900b2262011-09-06 14:33:52 -0400135typedef int (*window_enter_handler_t)(struct window *window,
136 struct input *input, uint32_t time,
137 int32_t x, int32_t y, void *data);
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400138typedef void (*window_leave_handler_t)(struct window *window,
139 struct input *input, uint32_t time,
140 void *data);
Kristian Høgsberg900b2262011-09-06 14:33:52 -0400141
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400142typedef int (*window_motion_handler_t)(struct window *window,
143 struct input *input, uint32_t time,
144 int32_t x, int32_t y,
145 int32_t sx, int32_t sy, void *data);
146
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500147struct window *
Kristian Høgsberg248c1b62011-01-21 18:03:15 -0500148window_create(struct display *display, int32_t width, int32_t height);
149struct window *
150window_create_transient(struct display *display, struct window *parent,
151 int32_t x, int32_t y, int32_t width, int32_t height);
152
153void
154window_destroy(struct window *window);
155
156void
Kristian Høgsberg82da52b2010-12-17 09:53:12 -0500157window_move(struct window *window, struct input *input, uint32_t time);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500158
159void
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500160window_draw(struct window *window);
Benjamin Franzkecff904e2011-02-18 23:00:55 +0100161
162void
163window_get_allocation(struct window *window,
164 struct rectangle *allocation);
165
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500166void
Kristian Høgsbergda846ca2011-01-11 10:00:52 -0500167window_get_child_allocation(struct window *window,
168 struct rectangle *allocation);
Callum Lowcayef57a9b2011-01-14 20:46:23 +1300169
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500170void
Kristian Høgsberg3be87d12011-05-13 13:45:17 -0400171window_set_transparent(struct window *window, int transparent);
172void
Kristian Høgsbergda846ca2011-01-11 10:00:52 -0500173window_set_child_size(struct window *window, int32_t width, int32_t height);
Kristian Høgsberg22106762008-12-08 13:50:07 -0500174void
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400175window_schedule_redraw(struct window *window);
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400176
177void
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400178window_damage(struct window *window, int32_t x, int32_t y,
179 int32_t width, int32_t height);
180
Kristian Høgsberg0ac16f02009-01-15 11:37:43 -0500181cairo_surface_t *
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400182window_get_surface(struct window *window);
183
Benjamin Franzkeec4d3422011-03-14 12:07:26 +0100184struct wl_surface *
185window_get_wl_surface(struct window *window);
186
Kristian Høgsberg0ac16f02009-01-15 11:37:43 -0500187void
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -0400188window_flush(struct window *window);
189
Kristian Høgsberg012a0072010-10-26 00:02:20 -0400190void
Bryce Harringtonf57303f2010-11-19 12:15:15 -0800191window_set_surface(struct window *window, cairo_surface_t *surface);
192
193void
Kristian Høgsberg012a0072010-10-26 00:02:20 -0400194window_create_surface(struct window *window);
195
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400196enum window_buffer_type {
Benjamin Franzke6693ac22011-02-10 12:04:30 +0100197 WINDOW_BUFFER_TYPE_EGL_WINDOW,
Kristian Høgsberg297c6312011-02-04 14:11:33 -0500198 WINDOW_BUFFER_TYPE_EGL_IMAGE,
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400199 WINDOW_BUFFER_TYPE_SHM,
200};
201
202void
Benjamin Franzkebde55ec2011-03-07 15:08:09 +0100203display_surface_damage(struct display *display, cairo_surface_t *cairo_surface,
204 int32_t x, int32_t y, int32_t width, int32_t height);
205
206void
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400207window_set_buffer_type(struct window *window, enum window_buffer_type type);
208
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -0400209void
Kristian Høgsberg0395f302008-12-22 12:14:50 -0500210window_set_fullscreen(struct window *window, int fullscreen);
211
212void
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400213window_set_custom(struct window *window);
214
215void
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400216window_set_user_data(struct window *window, void *data);
217
Kristian Høgsberge9d37bd2010-09-02 20:22:42 -0400218void *
219window_get_user_data(struct window *window);
220
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400221void
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400222window_set_redraw_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400223 window_redraw_handler_t handler);
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400224
225void
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400226window_set_decoration(struct window *window, int decoration);
227
228void
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500229window_set_resize_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400230 window_resize_handler_t handler);
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400231
Kristian Høgsberg6e83d582008-12-08 00:01:36 -0500232void
233window_set_key_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400234 window_key_handler_t handler);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500235
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500236void
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400237window_set_button_handler(struct window *window,
238 window_button_handler_t handler);
239
240void
241window_set_motion_handler(struct window *window,
242 window_motion_handler_t handler);
243
244void
Kristian Høgsberg900b2262011-09-06 14:33:52 -0400245window_set_enter_handler(struct window *window,
246 window_enter_handler_t handler);
247void
248window_set_leave_handler(struct window *window,
249 window_leave_handler_t handler);
250
251void
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500252window_set_keyboard_focus_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400253 window_keyboard_focus_handler_t handler);
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400254
255void
Callum Lowcayef57a9b2011-01-14 20:46:23 +1300256window_set_title(struct window *window, const char *title);
257
258const char *
259window_get_title(struct window *window);
260
Kristian Høgsberge9d37bd2010-09-02 20:22:42 -0400261struct wl_drag *
Kristian Høgsberg41da9082010-11-30 14:01:07 -0500262window_create_drag(struct window *window);
Kristian Høgsberge9d37bd2010-09-02 20:22:42 -0400263
Kristian Høgsberg41da9082010-11-30 14:01:07 -0500264void
265window_activate_drag(struct wl_drag *drag, struct window *window,
266 struct input *input, uint32_t time);
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400267
268void
269input_get_position(struct input *input, int32_t *x, int32_t *y);
270
Kristian Høgsberg67cac8a2011-01-19 14:20:33 -0500271uint32_t
272input_get_modifiers(struct input *input);
273
Kristian Høgsberg1d7ffd32010-08-25 16:34:05 -0400274struct wl_input_device *
275input_get_input_device(struct input *input);
276
Kristian Høgsberg58eec362011-01-19 14:27:42 -0500277int
278input_offers_mime_type(struct input *input, const char *type);
Kristian Høgsberg6bccebe2011-01-21 16:23:09 -0500279void
280input_receive_mime_type(struct input *input, const char *type, int fd);
Kristian Høgsberg58eec362011-01-19 14:27:42 -0500281
282
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500283#endif