blob: a1f58e92c87c3e8a1c6636e546b375b7b40d8225 [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øgsberg43c28ee2009-01-26 23:42:46 -050041struct wl_compositor *
42display_get_compositor(struct display *display);
43
Kristian Høgsberg7824d812010-06-08 14:59:44 -040044#ifdef EGL_NO_DISPLAY
45EGLDisplay
46display_get_egl_display(struct display *d);
47#endif
48
Kristian Høgsbergdcb71b62010-06-15 17:16:35 -040049cairo_surface_t *
50display_create_surface(struct display *display,
51 struct rectangle *rectangle);
52
Kristian Høgsberg9a686242010-08-18 15:28:04 -040053struct wl_buffer *
54display_get_buffer_for_surface(struct display *display,
55 cairo_surface_t *surface);
56
57cairo_surface_t *
58display_get_pointer_surface(struct display *display, int pointer,
59 int *width, int *height,
60 int *hotspot_x, int *hotspot_y);
61
Kristian Høgsberg7824d812010-06-08 14:59:44 -040062void
Kristian Høgsberg506e20e2010-08-19 17:26:02 -040063display_add_drag_listener(struct display *display,
64 const struct wl_drag_listener *drag_listener,
65 void *data);
66
67void
Kristian Høgsberg7824d812010-06-08 14:59:44 -040068display_run(struct display *d);
69
Kristian Høgsberg55444912009-02-21 14:31:09 -050070enum {
71 WINDOW_MODIFIER_SHIFT = 0x01,
Kristian Høgsberg94adf6c2010-06-25 16:50:05 -040072 WINDOW_MODIFIER_LOCK = 0x02,
Kristian Høgsberg55444912009-02-21 14:31:09 -050073 WINDOW_MODIFIER_CONTROL = 0x04,
Kristian Høgsberg94adf6c2010-06-25 16:50:05 -040074 WINDOW_MODIFIER_ALT = 0x08,
75 WINDOW_MODIFIER_MOD2 = 0x10,
Kristian Høgsberg55444912009-02-21 14:31:09 -050076};
77
Kristian Høgsberg9a686242010-08-18 15:28:04 -040078enum pointer_type {
79 POINTER_BOTTOM_LEFT,
80 POINTER_BOTTOM_RIGHT,
81 POINTER_BOTTOM,
82 POINTER_DRAGGING,
83 POINTER_LEFT_PTR,
84 POINTER_LEFT,
85 POINTER_RIGHT,
86 POINTER_TOP_LEFT,
87 POINTER_TOP_RIGHT,
88 POINTER_TOP,
89 POINTER_IBEAM,
90 POINTER_HAND1,
91};
92
Kristian Høgsberg22106762008-12-08 13:50:07 -050093typedef void (*window_resize_handler_t)(struct window *window, void *data);
Kristian Høgsberg80d746f2010-06-14 23:52:50 -040094typedef void (*window_redraw_handler_t)(struct window *window, void *data);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050095typedef void (*window_frame_handler_t)(struct window *window, uint32_t frame, uint32_t timestamp, void *data);
Kristian Høgsberg478d9262010-06-08 20:34:11 -040096typedef void (*window_acknowledge_handler_t)(struct window *window, uint32_t key, uint32_t frame, void *data);
Kristian Høgsberg55444912009-02-21 14:31:09 -050097typedef void (*window_key_handler_t)(struct window *window, uint32_t key, uint32_t unicode,
98 uint32_t state, uint32_t modifiers, void *data);
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -050099typedef void (*window_keyboard_focus_handler_t)(struct window *window,
Kristian Høgsberg808fd412010-07-20 17:06:19 -0400100 struct input *device, void *data);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500101
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400102typedef void (*window_button_handler_t)(struct window *window,
103 struct input *input, uint32_t time,
104 int button, int state, void *data);
105
106typedef int (*window_motion_handler_t)(struct window *window,
107 struct input *input, uint32_t time,
108 int32_t x, int32_t y,
109 int32_t sx, int32_t sy, void *data);
110
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500111struct window *
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -0500112window_create(struct display *display, const char *title,
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500113 int32_t x, int32_t y, int32_t width, int32_t height);
114
115void
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500116window_draw(struct window *window);
117void
Kristian Høgsberga341fa02010-01-24 18:10:15 -0500118window_commit(struct window *window, uint32_t key);
119void
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500120window_get_child_rectangle(struct window *window,
121 struct rectangle *rectangle);
122void
Kristian Høgsberg22106762008-12-08 13:50:07 -0500123window_set_child_size(struct window *window,
124 struct rectangle *rectangle);
125void
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400126window_copy_image(struct window *window,
127 struct rectangle *rectangle,
128 void *image);
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400129void
130window_schedule_redraw(struct window *window);
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400131
132void
133window_move(struct window *window, int32_t x, int32_t y);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500134
Kristian Høgsberg0ac16f02009-01-15 11:37:43 -0500135cairo_surface_t *
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400136window_get_surface(struct window *window);
137
Kristian Høgsberg0ac16f02009-01-15 11:37:43 -0500138void
139window_copy_surface(struct window *window,
140 struct rectangle *rectangle,
141 cairo_surface_t *surface);
142
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500143void
Kristian Høgsberg0395f302008-12-22 12:14:50 -0500144window_set_fullscreen(struct window *window, int fullscreen);
145
146void
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400147window_set_user_data(struct window *window, void *data);
148
149void
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400150window_set_redraw_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400151 window_redraw_handler_t handler);
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400152
153void
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400154window_set_decoration(struct window *window, int decoration);
155
156void
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500157window_set_resize_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400158 window_resize_handler_t handler);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500159void
160window_set_frame_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400161 window_frame_handler_t handler);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500162void
163window_set_acknowledge_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400164 window_acknowledge_handler_t handler);
165
Kristian Høgsberg6e83d582008-12-08 00:01:36 -0500166void
167window_set_key_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400168 window_key_handler_t handler);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500169
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500170void
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400171window_set_button_handler(struct window *window,
172 window_button_handler_t handler);
173
174void
175window_set_motion_handler(struct window *window,
176 window_motion_handler_t handler);
177
178void
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500179window_set_keyboard_focus_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400180 window_keyboard_focus_handler_t handler);
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400181
182void
Kristian Høgsberg478d9262010-06-08 20:34:11 -0400183window_set_acknowledge_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400184 window_acknowledge_handler_t handler);
Kristian Høgsberg478d9262010-06-08 20:34:11 -0400185
186void
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400187window_set_frame_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400188 window_frame_handler_t handler);
Kristian Høgsberg7824d812010-06-08 14:59:44 -0400189
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400190void
Kristian Høgsberg1d7ffd32010-08-25 16:34:05 -0400191window_start_drag(struct window *window, struct input *input, uint32_t time);
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400192
193void
194input_get_position(struct input *input, int32_t *x, int32_t *y);
195
Kristian Høgsberg1d7ffd32010-08-25 16:34:05 -0400196struct wl_input_device *
197input_get_input_device(struct input *input);
198
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500199#endif