blob: 36ca196fa84ba686750805cf21e6f9f7f78b3f1f [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øgsberg7824d812010-06-08 14:59:44 -040050#ifdef EGL_NO_DISPLAY
51EGLDisplay
52display_get_egl_display(struct display *d);
Kristian Høgsberg2b43bd72010-11-08 15:45:55 -050053
nobled98354172011-01-05 17:48:15 +000054#ifdef HAVE_CAIRO_GL
Kristian Høgsberg2b43bd72010-11-08 15:45:55 -050055EGLImageKHR
56display_get_image_for_drm_surface(struct display *display,
57 cairo_surface_t *surface);
Kristian Høgsberg7824d812010-06-08 14:59:44 -040058#endif
nobled98354172011-01-05 17:48:15 +000059#endif
Kristian Høgsberg7824d812010-06-08 14:59:44 -040060
Kristian Høgsbergdcb71b62010-06-15 17:16:35 -040061cairo_surface_t *
62display_create_surface(struct display *display,
63 struct rectangle *rectangle);
64
Kristian Høgsberg9a686242010-08-18 15:28:04 -040065struct wl_buffer *
66display_get_buffer_for_surface(struct display *display,
67 cairo_surface_t *surface);
68
69cairo_surface_t *
70display_get_pointer_surface(struct display *display, int pointer,
71 int *width, int *height,
72 int *hotspot_x, int *hotspot_y);
73
Kristian Høgsberg7824d812010-06-08 14:59:44 -040074void
Kristian Høgsberg506e20e2010-08-19 17:26:02 -040075display_add_drag_listener(struct display *display,
76 const struct wl_drag_listener *drag_listener,
77 void *data);
78
79void
Kristian Høgsberge968f9c2010-08-27 22:18:00 -040080display_flush_cairo_device(struct display *display);
81
82void
Kristian Høgsberg7824d812010-06-08 14:59:44 -040083display_run(struct display *d);
84
Kristian Høgsberg55444912009-02-21 14:31:09 -050085enum {
86 WINDOW_MODIFIER_SHIFT = 0x01,
Kristian Høgsberg94adf6c2010-06-25 16:50:05 -040087 WINDOW_MODIFIER_LOCK = 0x02,
Kristian Høgsberg55444912009-02-21 14:31:09 -050088 WINDOW_MODIFIER_CONTROL = 0x04,
Kristian Høgsberg94adf6c2010-06-25 16:50:05 -040089 WINDOW_MODIFIER_ALT = 0x08,
90 WINDOW_MODIFIER_MOD2 = 0x10,
Kristian Høgsberg55444912009-02-21 14:31:09 -050091};
92
Kristian Høgsberg9a686242010-08-18 15:28:04 -040093enum pointer_type {
94 POINTER_BOTTOM_LEFT,
95 POINTER_BOTTOM_RIGHT,
96 POINTER_BOTTOM,
97 POINTER_DRAGGING,
98 POINTER_LEFT_PTR,
99 POINTER_LEFT,
100 POINTER_RIGHT,
101 POINTER_TOP_LEFT,
102 POINTER_TOP_RIGHT,
103 POINTER_TOP,
104 POINTER_IBEAM,
105 POINTER_HAND1,
106};
107
Kristian Høgsbergda846ca2011-01-11 10:00:52 -0500108typedef void (*window_resize_handler_t)(struct window *window,
109 int32_t width, int32_t height,
110 void *data);
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400111typedef void (*window_redraw_handler_t)(struct window *window, void *data);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500112typedef void (*window_frame_handler_t)(struct window *window, uint32_t frame, uint32_t timestamp, void *data);
Kristian Høgsberg55444912009-02-21 14:31:09 -0500113typedef void (*window_key_handler_t)(struct window *window, uint32_t key, uint32_t unicode,
114 uint32_t state, uint32_t modifiers, void *data);
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500115typedef void (*window_keyboard_focus_handler_t)(struct window *window,
Kristian Høgsberg808fd412010-07-20 17:06:19 -0400116 struct input *device, void *data);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500117
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400118typedef void (*window_button_handler_t)(struct window *window,
119 struct input *input, uint32_t time,
120 int button, int state, void *data);
121
122typedef int (*window_motion_handler_t)(struct window *window,
123 struct input *input, uint32_t time,
124 int32_t x, int32_t y,
125 int32_t sx, int32_t sy, void *data);
126
Kristian Høgsberge9d37bd2010-09-02 20:22:42 -0400127typedef void (*display_drag_offer_handler_t)(struct wl_drag_offer *offer,
128 struct display *display);
129
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500130struct window *
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -0500131window_create(struct display *display, const char *title,
Kristian Høgsberg82da52b2010-12-17 09:53:12 -0500132 int32_t width, int32_t height);
133
134void
135window_move(struct window *window, struct input *input, uint32_t time);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500136
137void
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500138window_draw(struct window *window);
139void
Kristian Høgsbergda846ca2011-01-11 10:00:52 -0500140window_get_child_allocation(struct window *window,
141 struct rectangle *allocation);
Callum Lowcayef57a9b2011-01-14 20:46:23 +1300142
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500143void
Kristian Høgsbergda846ca2011-01-11 10:00:52 -0500144window_set_child_size(struct window *window, int32_t width, int32_t height);
Kristian Høgsberg22106762008-12-08 13:50:07 -0500145void
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400146window_copy_image(struct window *window,
147 struct rectangle *rectangle,
148 void *image);
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400149void
150window_schedule_redraw(struct window *window);
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400151
152void
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400153window_damage(struct window *window, int32_t x, int32_t y,
154 int32_t width, int32_t height);
155
Kristian Høgsberg0ac16f02009-01-15 11:37:43 -0500156cairo_surface_t *
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400157window_get_surface(struct window *window);
158
Kristian Høgsberg0ac16f02009-01-15 11:37:43 -0500159void
160window_copy_surface(struct window *window,
161 struct rectangle *rectangle,
162 cairo_surface_t *surface);
163
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500164void
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -0400165window_flush(struct window *window);
166
Kristian Høgsberg012a0072010-10-26 00:02:20 -0400167void
Bryce Harringtonf57303f2010-11-19 12:15:15 -0800168window_set_surface(struct window *window, cairo_surface_t *surface);
169
170void
Kristian Høgsberg012a0072010-10-26 00:02:20 -0400171window_create_surface(struct window *window);
172
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400173enum window_buffer_type {
174 WINDOW_BUFFER_TYPE_DRM,
175 WINDOW_BUFFER_TYPE_SHM,
176};
177
178void
179window_set_buffer_type(struct window *window, enum window_buffer_type type);
180
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -0400181void
Kristian Høgsberg0395f302008-12-22 12:14:50 -0500182window_set_fullscreen(struct window *window, int fullscreen);
183
184void
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400185window_set_user_data(struct window *window, void *data);
186
Kristian Høgsberge9d37bd2010-09-02 20:22:42 -0400187void *
188window_get_user_data(struct window *window);
189
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400190void
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400191window_set_redraw_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400192 window_redraw_handler_t handler);
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400193
194void
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400195window_set_decoration(struct window *window, int decoration);
196
197void
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500198window_set_resize_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400199 window_resize_handler_t handler);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500200void
201window_set_frame_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400202 window_frame_handler_t handler);
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400203
Kristian Høgsberg6e83d582008-12-08 00:01:36 -0500204void
205window_set_key_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400206 window_key_handler_t handler);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500207
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500208void
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400209window_set_button_handler(struct window *window,
210 window_button_handler_t handler);
211
212void
213window_set_motion_handler(struct window *window,
214 window_motion_handler_t handler);
215
216void
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500217window_set_keyboard_focus_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400218 window_keyboard_focus_handler_t handler);
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400219
220void
221window_set_frame_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400222 window_frame_handler_t handler);
Kristian Høgsberg7824d812010-06-08 14:59:44 -0400223
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400224void
Callum Lowcayef57a9b2011-01-14 20:46:23 +1300225window_set_title(struct window *window, const char *title);
226
227const char *
228window_get_title(struct window *window);
229
230void
Kristian Høgsberge9d37bd2010-09-02 20:22:42 -0400231display_set_drag_offer_handler(struct display *display,
232 display_drag_offer_handler_t handler);
233
234struct wl_drag *
Kristian Høgsberg41da9082010-11-30 14:01:07 -0500235window_create_drag(struct window *window);
Kristian Høgsberge9d37bd2010-09-02 20:22:42 -0400236
Kristian Høgsberg41da9082010-11-30 14:01:07 -0500237void
238window_activate_drag(struct wl_drag *drag, struct window *window,
239 struct input *input, uint32_t time);
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400240
241void
242input_get_position(struct input *input, int32_t *x, int32_t *y);
243
Kristian Høgsberg1d7ffd32010-08-25 16:34:05 -0400244struct wl_input_device *
245input_get_input_device(struct input *input);
246
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500247#endif