blob: d7a632ee95a789f2ffbfe2d16890af199cacaa43 [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
26struct window;
27
28struct rectangle {
29 int32_t x;
30 int32_t y;
31 int32_t width;
32 int32_t height;
33};
34
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -050035struct display;
Kristian Høgsberg808fd412010-07-20 17:06:19 -040036struct input;
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -050037
38struct display *
Kristian Høgsberg7824d812010-06-08 14:59:44 -040039display_create(int *argc, char **argv[], const GOptionEntry *option_entries);
40
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -040041struct wl_display *
42display_get_display(struct display *display);
43
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -050044struct wl_compositor *
45display_get_compositor(struct display *display);
46
Kristian Høgsberg7824d812010-06-08 14:59:44 -040047#ifdef EGL_NO_DISPLAY
48EGLDisplay
49display_get_egl_display(struct display *d);
50#endif
51
Kristian Høgsbergdcb71b62010-06-15 17:16:35 -040052cairo_surface_t *
53display_create_surface(struct display *display,
54 struct rectangle *rectangle);
55
Kristian Høgsberg9a686242010-08-18 15:28:04 -040056struct wl_buffer *
57display_get_buffer_for_surface(struct display *display,
58 cairo_surface_t *surface);
59
60cairo_surface_t *
61display_get_pointer_surface(struct display *display, int pointer,
62 int *width, int *height,
63 int *hotspot_x, int *hotspot_y);
64
Kristian Høgsberg7824d812010-06-08 14:59:44 -040065void
Kristian Høgsberg506e20e2010-08-19 17:26:02 -040066display_add_drag_listener(struct display *display,
67 const struct wl_drag_listener *drag_listener,
68 void *data);
69
70void
Kristian Høgsberge968f9c2010-08-27 22:18:00 -040071display_flush_cairo_device(struct display *display);
72
73void
Kristian Høgsberg7824d812010-06-08 14:59:44 -040074display_run(struct display *d);
75
Kristian Høgsberg55444912009-02-21 14:31:09 -050076enum {
77 WINDOW_MODIFIER_SHIFT = 0x01,
Kristian Høgsberg94adf6c2010-06-25 16:50:05 -040078 WINDOW_MODIFIER_LOCK = 0x02,
Kristian Høgsberg55444912009-02-21 14:31:09 -050079 WINDOW_MODIFIER_CONTROL = 0x04,
Kristian Høgsberg94adf6c2010-06-25 16:50:05 -040080 WINDOW_MODIFIER_ALT = 0x08,
81 WINDOW_MODIFIER_MOD2 = 0x10,
Kristian Høgsberg55444912009-02-21 14:31:09 -050082};
83
Kristian Høgsberg9a686242010-08-18 15:28:04 -040084enum pointer_type {
85 POINTER_BOTTOM_LEFT,
86 POINTER_BOTTOM_RIGHT,
87 POINTER_BOTTOM,
88 POINTER_DRAGGING,
89 POINTER_LEFT_PTR,
90 POINTER_LEFT,
91 POINTER_RIGHT,
92 POINTER_TOP_LEFT,
93 POINTER_TOP_RIGHT,
94 POINTER_TOP,
95 POINTER_IBEAM,
96 POINTER_HAND1,
97};
98
Kristian Høgsberg22106762008-12-08 13:50:07 -050099typedef void (*window_resize_handler_t)(struct window *window, void *data);
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400100typedef void (*window_redraw_handler_t)(struct window *window, void *data);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500101typedef void (*window_frame_handler_t)(struct window *window, uint32_t frame, uint32_t timestamp, void *data);
Kristian Høgsberg55444912009-02-21 14:31:09 -0500102typedef void (*window_key_handler_t)(struct window *window, uint32_t key, uint32_t unicode,
103 uint32_t state, uint32_t modifiers, void *data);
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500104typedef void (*window_keyboard_focus_handler_t)(struct window *window,
Kristian Høgsberg808fd412010-07-20 17:06:19 -0400105 struct input *device, void *data);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500106
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400107typedef void (*window_button_handler_t)(struct window *window,
108 struct input *input, uint32_t time,
109 int button, int state, void *data);
110
111typedef int (*window_motion_handler_t)(struct window *window,
112 struct input *input, uint32_t time,
113 int32_t x, int32_t y,
114 int32_t sx, int32_t sy, void *data);
115
Kristian Høgsberge9d37bd2010-09-02 20:22:42 -0400116typedef void (*display_drag_offer_handler_t)(struct wl_drag_offer *offer,
117 struct display *display);
118
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500119struct window *
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -0500120window_create(struct display *display, const char *title,
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500121 int32_t x, int32_t y, int32_t width, int32_t height);
122
123void
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500124window_draw(struct window *window);
125void
126window_get_child_rectangle(struct window *window,
127 struct rectangle *rectangle);
128void
Kristian Høgsberg22106762008-12-08 13:50:07 -0500129window_set_child_size(struct window *window,
130 struct rectangle *rectangle);
131void
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400132window_copy_image(struct window *window,
133 struct rectangle *rectangle,
134 void *image);
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400135void
136window_schedule_redraw(struct window *window);
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400137
138void
139window_move(struct window *window, int32_t x, int32_t y);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500140
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400141void
142window_damage(struct window *window, int32_t x, int32_t y,
143 int32_t width, int32_t height);
144
Kristian Høgsberg0ac16f02009-01-15 11:37:43 -0500145cairo_surface_t *
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400146window_get_surface(struct window *window);
147
Kristian Høgsberg0ac16f02009-01-15 11:37:43 -0500148void
149window_copy_surface(struct window *window,
150 struct rectangle *rectangle,
151 cairo_surface_t *surface);
152
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500153void
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -0400154window_flush(struct window *window);
155
Kristian Høgsberg012a0072010-10-26 00:02:20 -0400156void
157window_create_surface(struct window *window);
158
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400159enum window_buffer_type {
160 WINDOW_BUFFER_TYPE_DRM,
161 WINDOW_BUFFER_TYPE_SHM,
162};
163
164void
165window_set_buffer_type(struct window *window, enum window_buffer_type type);
166
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -0400167void
Kristian Høgsberg0395f302008-12-22 12:14:50 -0500168window_set_fullscreen(struct window *window, int fullscreen);
169
170void
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400171window_set_user_data(struct window *window, void *data);
172
Kristian Høgsberge9d37bd2010-09-02 20:22:42 -0400173void *
174window_get_user_data(struct window *window);
175
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400176void
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400177window_set_redraw_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400178 window_redraw_handler_t handler);
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400179
180void
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400181window_set_decoration(struct window *window, int decoration);
182
183void
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500184window_set_resize_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400185 window_resize_handler_t handler);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500186void
187window_set_frame_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400188 window_frame_handler_t handler);
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400189
Kristian Høgsberg6e83d582008-12-08 00:01:36 -0500190void
191window_set_key_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400192 window_key_handler_t handler);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500193
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500194void
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400195window_set_button_handler(struct window *window,
196 window_button_handler_t handler);
197
198void
199window_set_motion_handler(struct window *window,
200 window_motion_handler_t handler);
201
202void
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500203window_set_keyboard_focus_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400204 window_keyboard_focus_handler_t handler);
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400205
206void
207window_set_frame_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400208 window_frame_handler_t handler);
Kristian Høgsberg7824d812010-06-08 14:59:44 -0400209
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400210void
Kristian Høgsberge9d37bd2010-09-02 20:22:42 -0400211display_set_drag_offer_handler(struct display *display,
212 display_drag_offer_handler_t handler);
213
214struct wl_drag *
215window_start_drag(struct window *window, struct input *input, uint32_t time,
216 const struct wl_drag_listener *listener, void *data);
217
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400218
219void
220input_get_position(struct input *input, int32_t *x, int32_t *y);
221
Kristian Høgsberg1d7ffd32010-08-25 16:34:05 -0400222struct wl_input_device *
223input_get_input_device(struct input *input);
224
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500225#endif