blob: 041d35d4e13ab541ba21c16e129f0efaaa5ac245 [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;
36
37struct display *
Kristian Høgsberg7824d812010-06-08 14:59:44 -040038display_create(int *argc, char **argv[], const GOptionEntry *option_entries);
39
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -050040struct wl_compositor *
41display_get_compositor(struct display *display);
42
Kristian Høgsberg7824d812010-06-08 14:59:44 -040043#ifdef EGL_NO_DISPLAY
44EGLDisplay
45display_get_egl_display(struct display *d);
46#endif
47
Kristian Høgsbergdcb71b62010-06-15 17:16:35 -040048cairo_surface_t *
49display_create_surface(struct display *display,
50 struct rectangle *rectangle);
51
Kristian Høgsberg7824d812010-06-08 14:59:44 -040052void
53display_run(struct display *d);
54
Kristian Høgsberg55444912009-02-21 14:31:09 -050055enum {
56 WINDOW_MODIFIER_SHIFT = 0x01,
57 WINDOW_MODIFIER_ALT = 0x02,
58 WINDOW_MODIFIER_CONTROL = 0x04,
59};
60
Kristian Høgsberg22106762008-12-08 13:50:07 -050061typedef void (*window_resize_handler_t)(struct window *window, void *data);
Kristian Høgsberg80d746f2010-06-14 23:52:50 -040062typedef void (*window_redraw_handler_t)(struct window *window, void *data);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050063typedef void (*window_frame_handler_t)(struct window *window, uint32_t frame, uint32_t timestamp, void *data);
Kristian Høgsberg478d9262010-06-08 20:34:11 -040064typedef void (*window_acknowledge_handler_t)(struct window *window, uint32_t key, uint32_t frame, void *data);
Kristian Høgsberg55444912009-02-21 14:31:09 -050065typedef void (*window_key_handler_t)(struct window *window, uint32_t key, uint32_t unicode,
66 uint32_t state, uint32_t modifiers, void *data);
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -050067typedef void (*window_keyboard_focus_handler_t)(struct window *window,
68 struct wl_input_device *device, void *data);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050069
70struct window *
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -050071window_create(struct display *display, const char *title,
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050072 int32_t x, int32_t y, int32_t width, int32_t height);
73
74void
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050075window_draw(struct window *window);
76void
Kristian Høgsberga341fa02010-01-24 18:10:15 -050077window_commit(struct window *window, uint32_t key);
78void
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050079window_get_child_rectangle(struct window *window,
80 struct rectangle *rectangle);
81void
Kristian Høgsberg22106762008-12-08 13:50:07 -050082window_set_child_size(struct window *window,
83 struct rectangle *rectangle);
84void
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -040085window_copy_image(struct window *window,
86 struct rectangle *rectangle,
87 void *image);
Kristian Høgsberg80d746f2010-06-14 23:52:50 -040088void
89window_schedule_redraw(struct window *window);
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -040090
91void
92window_move(struct window *window, int32_t x, int32_t y);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050093
Kristian Høgsberg0ac16f02009-01-15 11:37:43 -050094cairo_surface_t *
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -040095window_get_surface(struct window *window);
96
Kristian Høgsberg0ac16f02009-01-15 11:37:43 -050097void
98window_copy_surface(struct window *window,
99 struct rectangle *rectangle,
100 cairo_surface_t *surface);
101
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500102void
Kristian Høgsberg0395f302008-12-22 12:14:50 -0500103window_set_fullscreen(struct window *window, int fullscreen);
104
105void
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400106window_set_redraw_handler(struct window *window,
107 window_redraw_handler_t handler, void *data);
108
109void
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400110window_set_decoration(struct window *window, int decoration);
111
112void
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500113window_set_resize_handler(struct window *window,
114 window_resize_handler_t handler, void *data);
115void
116window_set_frame_handler(struct window *window,
117 window_frame_handler_t handler, void *data);
118void
119window_set_acknowledge_handler(struct window *window,
120 window_acknowledge_handler_t handler, void *data);
Kristian Høgsberg6e83d582008-12-08 00:01:36 -0500121void
122window_set_key_handler(struct window *window,
123 window_key_handler_t handler, void *data);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500124
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500125void
126window_set_keyboard_focus_handler(struct window *window,
127 window_keyboard_focus_handler_t handler,
128 void *data);
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400129
130void
Kristian Høgsberg478d9262010-06-08 20:34:11 -0400131window_set_acknowledge_handler(struct window *window,
132 window_acknowledge_handler_t handler, void *data);
133
134void
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400135window_set_frame_handler(struct window *window,
136 window_frame_handler_t handler, void *data);
Kristian Høgsberg7824d812010-06-08 14:59:44 -0400137
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500138#endif