blob: d67aeda9949460109f90ec3f02c3e052a81261b5 [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
Fred Morcosc4b8c452010-11-28 19:31:55 +010026#include <glib.h>
27#include <wayland-client.h>
28
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050029struct window;
30
31struct rectangle {
32 int32_t x;
33 int32_t y;
34 int32_t width;
35 int32_t height;
36};
37
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -050038struct display;
Kristian Høgsberg808fd412010-07-20 17:06:19 -040039struct input;
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -050040
41struct display *
Kristian Høgsberg7824d812010-06-08 14:59:44 -040042display_create(int *argc, char **argv[], const GOptionEntry *option_entries);
43
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -040044struct wl_display *
45display_get_display(struct display *display);
46
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -050047struct wl_compositor *
48display_get_compositor(struct display *display);
49
Kristian Høgsberg58eec362011-01-19 14:27:42 -050050struct wl_shell *
51display_get_shell(struct display *display);
52
Kristian Høgsberg7824d812010-06-08 14:59:44 -040053#ifdef EGL_NO_DISPLAY
54EGLDisplay
55display_get_egl_display(struct display *d);
Kristian Høgsberg2b43bd72010-11-08 15:45:55 -050056
Kristian Høgsberg8def2642011-01-14 17:41:33 -050057#ifdef HAVE_CAIRO_EGL
Kristian Høgsberg2b43bd72010-11-08 15:45:55 -050058EGLImageKHR
59display_get_image_for_drm_surface(struct display *display,
60 cairo_surface_t *surface);
Kristian Høgsberg7824d812010-06-08 14:59:44 -040061#endif
nobled98354172011-01-05 17:48:15 +000062#endif
Kristian Høgsberg7824d812010-06-08 14:59:44 -040063
Kristian Høgsbergdcb71b62010-06-15 17:16:35 -040064cairo_surface_t *
65display_create_surface(struct display *display,
66 struct rectangle *rectangle);
67
Kristian Høgsberg9a686242010-08-18 15:28:04 -040068struct wl_buffer *
69display_get_buffer_for_surface(struct display *display,
70 cairo_surface_t *surface);
71
72cairo_surface_t *
73display_get_pointer_surface(struct display *display, int pointer,
74 int *width, int *height,
75 int *hotspot_x, int *hotspot_y);
76
Kristian Høgsberg7824d812010-06-08 14:59:44 -040077void
Kristian Høgsberg506e20e2010-08-19 17:26:02 -040078display_add_drag_listener(struct display *display,
79 const struct wl_drag_listener *drag_listener,
80 void *data);
81
82void
Kristian Høgsberge968f9c2010-08-27 22:18:00 -040083display_flush_cairo_device(struct display *display);
84
85void
Kristian Høgsberg7824d812010-06-08 14:59:44 -040086display_run(struct display *d);
87
Kristian Høgsberg55444912009-02-21 14:31:09 -050088enum {
89 WINDOW_MODIFIER_SHIFT = 0x01,
Kristian Høgsberg94adf6c2010-06-25 16:50:05 -040090 WINDOW_MODIFIER_LOCK = 0x02,
Kristian Høgsberg55444912009-02-21 14:31:09 -050091 WINDOW_MODIFIER_CONTROL = 0x04,
Kristian Høgsberg94adf6c2010-06-25 16:50:05 -040092 WINDOW_MODIFIER_ALT = 0x08,
93 WINDOW_MODIFIER_MOD2 = 0x10,
Kristian Høgsberg55444912009-02-21 14:31:09 -050094};
95
Kristian Høgsberg9a686242010-08-18 15:28:04 -040096enum pointer_type {
97 POINTER_BOTTOM_LEFT,
98 POINTER_BOTTOM_RIGHT,
99 POINTER_BOTTOM,
100 POINTER_DRAGGING,
101 POINTER_LEFT_PTR,
102 POINTER_LEFT,
103 POINTER_RIGHT,
104 POINTER_TOP_LEFT,
105 POINTER_TOP_RIGHT,
106 POINTER_TOP,
107 POINTER_IBEAM,
108 POINTER_HAND1,
109};
110
Kristian Høgsbergda846ca2011-01-11 10:00:52 -0500111typedef void (*window_resize_handler_t)(struct window *window,
112 int32_t width, int32_t height,
113 void *data);
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400114typedef void (*window_redraw_handler_t)(struct window *window, void *data);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500115typedef void (*window_frame_handler_t)(struct window *window, uint32_t frame, uint32_t timestamp, void *data);
Kristian Høgsberg67cac8a2011-01-19 14:20:33 -0500116typedef void (*window_key_handler_t)(struct window *window, struct input *input,
117 uint32_t time, uint32_t key, uint32_t unicode,
118 uint32_t state, void *data);
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500119typedef void (*window_keyboard_focus_handler_t)(struct window *window,
Kristian Høgsberg808fd412010-07-20 17:06:19 -0400120 struct input *device, void *data);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500121
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400122typedef void (*window_button_handler_t)(struct window *window,
123 struct input *input, uint32_t time,
124 int button, int state, void *data);
125
126typedef int (*window_motion_handler_t)(struct window *window,
127 struct input *input, uint32_t time,
128 int32_t x, int32_t y,
129 int32_t sx, int32_t sy, void *data);
130
Kristian Høgsbergb46df052011-01-18 09:17:57 -0500131typedef void (*display_global_handler_t)(struct display *display,
132 const char *interface,
Kristian Høgsberg943741c2011-01-18 09:23:13 -0500133 uint32_t id,
Kristian Høgsbergb46df052011-01-18 09:17:57 -0500134 uint32_t version);
135
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500136struct window *
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -0500137window_create(struct display *display, const char *title,
Kristian Høgsberg82da52b2010-12-17 09:53:12 -0500138 int32_t width, int32_t height);
139
140void
141window_move(struct window *window, struct input *input, uint32_t time);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500142
143void
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500144window_draw(struct window *window);
145void
Kristian Høgsbergda846ca2011-01-11 10:00:52 -0500146window_get_child_allocation(struct window *window,
147 struct rectangle *allocation);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500148void
Kristian Høgsbergda846ca2011-01-11 10:00:52 -0500149window_set_child_size(struct window *window, int32_t width, int32_t height);
Kristian Høgsberg22106762008-12-08 13:50:07 -0500150void
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400151window_copy_image(struct window *window,
152 struct rectangle *rectangle,
153 void *image);
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400154void
155window_schedule_redraw(struct window *window);
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400156
157void
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400158window_damage(struct window *window, int32_t x, int32_t y,
159 int32_t width, int32_t height);
160
Kristian Høgsberg0ac16f02009-01-15 11:37:43 -0500161cairo_surface_t *
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400162window_get_surface(struct window *window);
163
Kristian Høgsberg0ac16f02009-01-15 11:37:43 -0500164void
165window_copy_surface(struct window *window,
166 struct rectangle *rectangle,
167 cairo_surface_t *surface);
168
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500169void
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -0400170window_flush(struct window *window);
171
Kristian Høgsberg012a0072010-10-26 00:02:20 -0400172void
Bryce Harringtonf57303f2010-11-19 12:15:15 -0800173window_set_surface(struct window *window, cairo_surface_t *surface);
174
175void
Kristian Høgsberg012a0072010-10-26 00:02:20 -0400176window_create_surface(struct window *window);
177
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400178enum window_buffer_type {
179 WINDOW_BUFFER_TYPE_DRM,
180 WINDOW_BUFFER_TYPE_SHM,
181};
182
183void
184window_set_buffer_type(struct window *window, enum window_buffer_type type);
185
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -0400186void
Kristian Høgsberg0395f302008-12-22 12:14:50 -0500187window_set_fullscreen(struct window *window, int fullscreen);
188
189void
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400190window_set_user_data(struct window *window, void *data);
191
Kristian Høgsberge9d37bd2010-09-02 20:22:42 -0400192void *
193window_get_user_data(struct window *window);
194
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400195void
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400196window_set_redraw_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400197 window_redraw_handler_t handler);
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400198
199void
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400200window_set_decoration(struct window *window, int decoration);
201
202void
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500203window_set_resize_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400204 window_resize_handler_t handler);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500205void
206window_set_frame_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400207 window_frame_handler_t handler);
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400208
Kristian Høgsberg6e83d582008-12-08 00:01:36 -0500209void
210window_set_key_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400211 window_key_handler_t handler);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500212
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500213void
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400214window_set_button_handler(struct window *window,
215 window_button_handler_t handler);
216
217void
218window_set_motion_handler(struct window *window,
219 window_motion_handler_t handler);
220
221void
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500222window_set_keyboard_focus_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400223 window_keyboard_focus_handler_t handler);
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400224
225void
226window_set_frame_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400227 window_frame_handler_t handler);
Kristian Høgsberg7824d812010-06-08 14:59:44 -0400228
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400229void
Kristian Høgsbergb46df052011-01-18 09:17:57 -0500230display_set_global_handler(struct display *display,
231 display_global_handler_t handler);
232
Kristian Høgsberge9d37bd2010-09-02 20:22:42 -0400233struct wl_drag *
Kristian Høgsberg41da9082010-11-30 14:01:07 -0500234window_create_drag(struct window *window);
Kristian Høgsberge9d37bd2010-09-02 20:22:42 -0400235
Kristian Høgsberg41da9082010-11-30 14:01:07 -0500236void
237window_activate_drag(struct wl_drag *drag, struct window *window,
238 struct input *input, uint32_t time);
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400239
240void
241input_get_position(struct input *input, int32_t *x, int32_t *y);
242
Kristian Høgsberg67cac8a2011-01-19 14:20:33 -0500243uint32_t
244input_get_modifiers(struct input *input);
245
Kristian Høgsberg1d7ffd32010-08-25 16:34:05 -0400246struct wl_input_device *
247input_get_input_device(struct input *input);
248
Kristian Høgsberg58eec362011-01-19 14:27:42 -0500249int
250input_offers_mime_type(struct input *input, const char *type);
251int
252input_receive_mime_type(struct input *input, const char *type);
253
254
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500255#endif