blob: 538ff07e01f6a07c67439ff070586e1811a200c9 [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
Kristian Høgsberg23c03ad2011-01-19 14:41:20 -050026#include <X11/extensions/XKBcommon.h>
Fred Morcosc4b8c452010-11-28 19:31:55 +010027#include <glib.h>
28#include <wayland-client.h>
Benjamin Franzkecff904e2011-02-18 23:00:55 +010029#include <cairo.h>
Fred Morcosc4b8c452010-11-28 19:31:55 +010030
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050031struct window;
32
33struct rectangle {
34 int32_t x;
35 int32_t y;
36 int32_t width;
37 int32_t height;
38};
39
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -050040struct display;
Kristian Høgsberg808fd412010-07-20 17:06:19 -040041struct input;
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -050042
43struct display *
Kristian Høgsberg7824d812010-06-08 14:59:44 -040044display_create(int *argc, char **argv[], const GOptionEntry *option_entries);
45
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -040046struct wl_display *
47display_get_display(struct display *display);
48
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -050049struct wl_compositor *
50display_get_compositor(struct display *display);
51
Kristian Høgsberg58eec362011-01-19 14:27:42 -050052struct wl_shell *
53display_get_shell(struct display *display);
54
Kristian Høgsberg7824d812010-06-08 14:59:44 -040055#ifdef EGL_NO_DISPLAY
56EGLDisplay
57display_get_egl_display(struct display *d);
Kristian Høgsberg2b43bd72010-11-08 15:45:55 -050058
Benjamin Franzkecff904e2011-02-18 23:00:55 +010059EGLConfig
60display_get_egl_config(struct display *d);
61
62void
63display_acquire_window_surface(struct display *display,
64 struct window *window,
65 EGLContext ctx);
66void
67display_release(struct display *display);
68
Kristian Høgsberg8def2642011-01-14 17:41:33 -050069#ifdef HAVE_CAIRO_EGL
Kristian Høgsberg2b43bd72010-11-08 15:45:55 -050070EGLImageKHR
Kristian Høgsberg297c6312011-02-04 14:11:33 -050071display_get_image_for_egl_image_surface(struct display *display,
72 cairo_surface_t *surface);
Kristian Høgsberg7824d812010-06-08 14:59:44 -040073#endif
nobled98354172011-01-05 17:48:15 +000074#endif
Kristian Høgsberg7824d812010-06-08 14:59:44 -040075
Kristian Høgsbergdcb71b62010-06-15 17:16:35 -040076cairo_surface_t *
77display_create_surface(struct display *display,
Benjamin Franzke6693ac22011-02-10 12:04:30 +010078 struct wl_surface *surface,
Kristian Høgsbergdcb71b62010-06-15 17:16:35 -040079 struct rectangle *rectangle);
80
Kristian Høgsberg9a686242010-08-18 15:28:04 -040081struct wl_buffer *
82display_get_buffer_for_surface(struct display *display,
83 cairo_surface_t *surface);
84
85cairo_surface_t *
86display_get_pointer_surface(struct display *display, int pointer,
87 int *width, int *height,
88 int *hotspot_x, int *hotspot_y);
89
Kristian Høgsberg7824d812010-06-08 14:59:44 -040090void
Kristian Høgsberg506e20e2010-08-19 17:26:02 -040091display_add_drag_listener(struct display *display,
92 const struct wl_drag_listener *drag_listener,
93 void *data);
94
95void
Kristian Høgsberge968f9c2010-08-27 22:18:00 -040096display_flush_cairo_device(struct display *display);
97
98void
Kristian Høgsberg7824d812010-06-08 14:59:44 -040099display_run(struct display *d);
100
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400101enum pointer_type {
102 POINTER_BOTTOM_LEFT,
103 POINTER_BOTTOM_RIGHT,
104 POINTER_BOTTOM,
105 POINTER_DRAGGING,
106 POINTER_LEFT_PTR,
107 POINTER_LEFT,
108 POINTER_RIGHT,
109 POINTER_TOP_LEFT,
110 POINTER_TOP_RIGHT,
111 POINTER_TOP,
112 POINTER_IBEAM,
113 POINTER_HAND1,
114};
115
Kristian Høgsbergda846ca2011-01-11 10:00:52 -0500116typedef void (*window_resize_handler_t)(struct window *window,
117 int32_t width, int32_t height,
118 void *data);
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400119typedef void (*window_redraw_handler_t)(struct window *window, void *data);
Tim Wiederhakedc3f8172011-01-17 17:25:34 +0100120
Kristian Høgsberg67cac8a2011-01-19 14:20:33 -0500121typedef void (*window_key_handler_t)(struct window *window, struct input *input,
122 uint32_t time, uint32_t key, uint32_t unicode,
123 uint32_t state, void *data);
Tim Wiederhakedc3f8172011-01-17 17:25:34 +0100124
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500125typedef void (*window_keyboard_focus_handler_t)(struct window *window,
Kristian Høgsberg808fd412010-07-20 17:06:19 -0400126 struct input *device, void *data);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500127
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400128typedef void (*window_button_handler_t)(struct window *window,
129 struct input *input, uint32_t time,
130 int button, int state, void *data);
131
132typedef int (*window_motion_handler_t)(struct window *window,
133 struct input *input, uint32_t time,
134 int32_t x, int32_t y,
135 int32_t sx, int32_t sy, void *data);
136
Kristian Høgsbergb46df052011-01-18 09:17:57 -0500137typedef void (*display_global_handler_t)(struct display *display,
138 const char *interface,
Kristian Høgsberg943741c2011-01-18 09:23:13 -0500139 uint32_t id,
Kristian Høgsbergb46df052011-01-18 09:17:57 -0500140 uint32_t version);
141
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500142struct window *
Kristian Høgsberg248c1b62011-01-21 18:03:15 -0500143window_create(struct display *display, int32_t width, int32_t height);
144struct window *
145window_create_transient(struct display *display, struct window *parent,
146 int32_t x, int32_t y, int32_t width, int32_t height);
147
148void
149window_destroy(struct window *window);
150
151void
Kristian Høgsberg82da52b2010-12-17 09:53:12 -0500152window_move(struct window *window, struct input *input, uint32_t time);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500153
154void
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500155window_draw(struct window *window);
Benjamin Franzkecff904e2011-02-18 23:00:55 +0100156
157void
158window_get_allocation(struct window *window,
159 struct rectangle *allocation);
160
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500161void
Kristian Høgsbergda846ca2011-01-11 10:00:52 -0500162window_get_child_allocation(struct window *window,
163 struct rectangle *allocation);
Callum Lowcayef57a9b2011-01-14 20:46:23 +1300164
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500165void
Kristian Høgsbergda846ca2011-01-11 10:00:52 -0500166window_set_child_size(struct window *window, int32_t width, int32_t height);
Kristian Høgsberg22106762008-12-08 13:50:07 -0500167void
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400168window_schedule_redraw(struct window *window);
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400169
170void
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400171window_damage(struct window *window, int32_t x, int32_t y,
172 int32_t width, int32_t height);
173
Kristian Høgsberg0ac16f02009-01-15 11:37:43 -0500174cairo_surface_t *
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400175window_get_surface(struct window *window);
176
Kristian Høgsberg0ac16f02009-01-15 11:37:43 -0500177void
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -0400178window_flush(struct window *window);
179
Kristian Høgsberg012a0072010-10-26 00:02:20 -0400180void
Bryce Harringtonf57303f2010-11-19 12:15:15 -0800181window_set_surface(struct window *window, cairo_surface_t *surface);
182
183void
Kristian Høgsberg012a0072010-10-26 00:02:20 -0400184window_create_surface(struct window *window);
185
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400186enum window_buffer_type {
Benjamin Franzke6693ac22011-02-10 12:04:30 +0100187 WINDOW_BUFFER_TYPE_EGL_WINDOW,
Kristian Høgsberg297c6312011-02-04 14:11:33 -0500188 WINDOW_BUFFER_TYPE_EGL_IMAGE,
Kristian Høgsbergd0c3b9d2010-10-25 11:40:03 -0400189 WINDOW_BUFFER_TYPE_SHM,
190};
191
192void
193window_set_buffer_type(struct window *window, enum window_buffer_type type);
194
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -0400195void
Kristian Høgsberg0395f302008-12-22 12:14:50 -0500196window_set_fullscreen(struct window *window, int fullscreen);
197
198void
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400199window_set_user_data(struct window *window, void *data);
200
Kristian Høgsberge9d37bd2010-09-02 20:22:42 -0400201void *
202window_get_user_data(struct window *window);
203
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400204void
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400205window_set_redraw_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400206 window_redraw_handler_t handler);
Kristian Høgsberg80d746f2010-06-14 23:52:50 -0400207
208void
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400209window_set_decoration(struct window *window, int decoration);
210
211void
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500212window_set_resize_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400213 window_resize_handler_t handler);
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400214
Kristian Høgsberg6e83d582008-12-08 00:01:36 -0500215void
216window_set_key_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400217 window_key_handler_t handler);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500218
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500219void
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400220window_set_button_handler(struct window *window,
221 window_button_handler_t handler);
222
223void
224window_set_motion_handler(struct window *window,
225 window_motion_handler_t handler);
226
227void
Kristian Høgsberg3c248cc2009-02-22 23:01:35 -0500228window_set_keyboard_focus_handler(struct window *window,
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400229 window_keyboard_focus_handler_t handler);
Kristian Høgsberga85fe3c2010-06-08 14:08:30 -0400230
231void
Callum Lowcayef57a9b2011-01-14 20:46:23 +1300232window_set_title(struct window *window, const char *title);
233
234const char *
235window_get_title(struct window *window);
236
237void
Kristian Høgsbergb46df052011-01-18 09:17:57 -0500238display_set_global_handler(struct display *display,
239 display_global_handler_t handler);
240
Kristian Høgsberge9d37bd2010-09-02 20:22:42 -0400241struct wl_drag *
Kristian Høgsberg41da9082010-11-30 14:01:07 -0500242window_create_drag(struct window *window);
Kristian Høgsberge9d37bd2010-09-02 20:22:42 -0400243
Kristian Høgsberg41da9082010-11-30 14:01:07 -0500244void
245window_activate_drag(struct wl_drag *drag, struct window *window,
246 struct input *input, uint32_t time);
Kristian Høgsberg9a686242010-08-18 15:28:04 -0400247
248void
249input_get_position(struct input *input, int32_t *x, int32_t *y);
250
Kristian Høgsberg67cac8a2011-01-19 14:20:33 -0500251uint32_t
252input_get_modifiers(struct input *input);
253
Kristian Høgsberg1d7ffd32010-08-25 16:34:05 -0400254struct wl_input_device *
255input_get_input_device(struct input *input);
256
Kristian Høgsberg58eec362011-01-19 14:27:42 -0500257int
258input_offers_mime_type(struct input *input, const char *type);
Kristian Høgsberg6bccebe2011-01-21 16:23:09 -0500259void
260input_receive_mime_type(struct input *input, const char *type, int fd);
Kristian Høgsberg58eec362011-01-19 14:27:42 -0500261
262
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500263#endif