Kristian Høgsberg | 0c4457f | 2008-12-07 19:59:11 -0500 | [diff] [blame] | 1 | /* |
| 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øgsberg | 23c03ad | 2011-01-19 14:41:20 -0500 | [diff] [blame] | 26 | #include <X11/extensions/XKBcommon.h> |
Fred Morcos | c4b8c45 | 2010-11-28 19:31:55 +0100 | [diff] [blame] | 27 | #include <glib.h> |
| 28 | #include <wayland-client.h> |
| 29 | |
Kristian Høgsberg | 0c4457f | 2008-12-07 19:59:11 -0500 | [diff] [blame] | 30 | struct window; |
| 31 | |
| 32 | struct rectangle { |
| 33 | int32_t x; |
| 34 | int32_t y; |
| 35 | int32_t width; |
| 36 | int32_t height; |
| 37 | }; |
| 38 | |
Kristian Høgsberg | 43c28ee | 2009-01-26 23:42:46 -0500 | [diff] [blame] | 39 | struct display; |
Kristian Høgsberg | 808fd41 | 2010-07-20 17:06:19 -0400 | [diff] [blame] | 40 | struct input; |
Kristian Høgsberg | 43c28ee | 2009-01-26 23:42:46 -0500 | [diff] [blame] | 41 | |
| 42 | struct display * |
Kristian Høgsberg | 7824d81 | 2010-06-08 14:59:44 -0400 | [diff] [blame] | 43 | display_create(int *argc, char **argv[], const GOptionEntry *option_entries); |
| 44 | |
Kristian Høgsberg | 9d69f8e | 2010-09-03 14:46:38 -0400 | [diff] [blame] | 45 | struct wl_display * |
| 46 | display_get_display(struct display *display); |
| 47 | |
Kristian Høgsberg | 43c28ee | 2009-01-26 23:42:46 -0500 | [diff] [blame] | 48 | struct wl_compositor * |
| 49 | display_get_compositor(struct display *display); |
| 50 | |
Kristian Høgsberg | 58eec36 | 2011-01-19 14:27:42 -0500 | [diff] [blame] | 51 | struct wl_shell * |
| 52 | display_get_shell(struct display *display); |
| 53 | |
Kristian Høgsberg | 7824d81 | 2010-06-08 14:59:44 -0400 | [diff] [blame] | 54 | #ifdef EGL_NO_DISPLAY |
| 55 | EGLDisplay |
| 56 | display_get_egl_display(struct display *d); |
Kristian Høgsberg | 2b43bd7 | 2010-11-08 15:45:55 -0500 | [diff] [blame] | 57 | |
Kristian Høgsberg | 8def264 | 2011-01-14 17:41:33 -0500 | [diff] [blame] | 58 | #ifdef HAVE_CAIRO_EGL |
Kristian Høgsberg | 2b43bd7 | 2010-11-08 15:45:55 -0500 | [diff] [blame] | 59 | EGLImageKHR |
Kristian Høgsberg | 297c631 | 2011-02-04 14:11:33 -0500 | [diff] [blame] | 60 | display_get_image_for_egl_image_surface(struct display *display, |
| 61 | cairo_surface_t *surface); |
Kristian Høgsberg | 7824d81 | 2010-06-08 14:59:44 -0400 | [diff] [blame] | 62 | #endif |
nobled | 9835417 | 2011-01-05 17:48:15 +0000 | [diff] [blame] | 63 | #endif |
Kristian Høgsberg | 7824d81 | 2010-06-08 14:59:44 -0400 | [diff] [blame] | 64 | |
Kristian Høgsberg | dcb71b6 | 2010-06-15 17:16:35 -0400 | [diff] [blame] | 65 | cairo_surface_t * |
| 66 | display_create_surface(struct display *display, |
Benjamin Franzke | 6693ac2 | 2011-02-10 12:04:30 +0100 | [diff] [blame^] | 67 | struct wl_surface *surface, |
Kristian Høgsberg | dcb71b6 | 2010-06-15 17:16:35 -0400 | [diff] [blame] | 68 | struct rectangle *rectangle); |
| 69 | |
Kristian Høgsberg | 9a68624 | 2010-08-18 15:28:04 -0400 | [diff] [blame] | 70 | struct wl_buffer * |
| 71 | display_get_buffer_for_surface(struct display *display, |
| 72 | cairo_surface_t *surface); |
| 73 | |
| 74 | cairo_surface_t * |
| 75 | display_get_pointer_surface(struct display *display, int pointer, |
| 76 | int *width, int *height, |
| 77 | int *hotspot_x, int *hotspot_y); |
| 78 | |
Kristian Høgsberg | 7824d81 | 2010-06-08 14:59:44 -0400 | [diff] [blame] | 79 | void |
Kristian Høgsberg | 506e20e | 2010-08-19 17:26:02 -0400 | [diff] [blame] | 80 | display_add_drag_listener(struct display *display, |
| 81 | const struct wl_drag_listener *drag_listener, |
| 82 | void *data); |
| 83 | |
| 84 | void |
Kristian Høgsberg | e968f9c | 2010-08-27 22:18:00 -0400 | [diff] [blame] | 85 | display_flush_cairo_device(struct display *display); |
| 86 | |
| 87 | void |
Kristian Høgsberg | 7824d81 | 2010-06-08 14:59:44 -0400 | [diff] [blame] | 88 | display_run(struct display *d); |
| 89 | |
Kristian Høgsberg | 9a68624 | 2010-08-18 15:28:04 -0400 | [diff] [blame] | 90 | enum pointer_type { |
| 91 | POINTER_BOTTOM_LEFT, |
| 92 | POINTER_BOTTOM_RIGHT, |
| 93 | POINTER_BOTTOM, |
| 94 | POINTER_DRAGGING, |
| 95 | POINTER_LEFT_PTR, |
| 96 | POINTER_LEFT, |
| 97 | POINTER_RIGHT, |
| 98 | POINTER_TOP_LEFT, |
| 99 | POINTER_TOP_RIGHT, |
| 100 | POINTER_TOP, |
| 101 | POINTER_IBEAM, |
| 102 | POINTER_HAND1, |
| 103 | }; |
| 104 | |
Kristian Høgsberg | da846ca | 2011-01-11 10:00:52 -0500 | [diff] [blame] | 105 | typedef void (*window_resize_handler_t)(struct window *window, |
| 106 | int32_t width, int32_t height, |
| 107 | void *data); |
Kristian Høgsberg | 80d746f | 2010-06-14 23:52:50 -0400 | [diff] [blame] | 108 | typedef void (*window_redraw_handler_t)(struct window *window, void *data); |
Tim Wiederhake | dc3f817 | 2011-01-17 17:25:34 +0100 | [diff] [blame] | 109 | |
Kristian Høgsberg | 67cac8a | 2011-01-19 14:20:33 -0500 | [diff] [blame] | 110 | typedef void (*window_key_handler_t)(struct window *window, struct input *input, |
| 111 | uint32_t time, uint32_t key, uint32_t unicode, |
| 112 | uint32_t state, void *data); |
Tim Wiederhake | dc3f817 | 2011-01-17 17:25:34 +0100 | [diff] [blame] | 113 | |
Kristian Høgsberg | 3c248cc | 2009-02-22 23:01:35 -0500 | [diff] [blame] | 114 | typedef void (*window_keyboard_focus_handler_t)(struct window *window, |
Kristian Høgsberg | 808fd41 | 2010-07-20 17:06:19 -0400 | [diff] [blame] | 115 | struct input *device, void *data); |
Kristian Høgsberg | 0c4457f | 2008-12-07 19:59:11 -0500 | [diff] [blame] | 116 | |
Kristian Høgsberg | 9a68624 | 2010-08-18 15:28:04 -0400 | [diff] [blame] | 117 | typedef void (*window_button_handler_t)(struct window *window, |
| 118 | struct input *input, uint32_t time, |
| 119 | int button, int state, void *data); |
| 120 | |
| 121 | typedef int (*window_motion_handler_t)(struct window *window, |
| 122 | struct input *input, uint32_t time, |
| 123 | int32_t x, int32_t y, |
| 124 | int32_t sx, int32_t sy, void *data); |
| 125 | |
Kristian Høgsberg | b46df05 | 2011-01-18 09:17:57 -0500 | [diff] [blame] | 126 | typedef void (*display_global_handler_t)(struct display *display, |
| 127 | const char *interface, |
Kristian Høgsberg | 943741c | 2011-01-18 09:23:13 -0500 | [diff] [blame] | 128 | uint32_t id, |
Kristian Høgsberg | b46df05 | 2011-01-18 09:17:57 -0500 | [diff] [blame] | 129 | uint32_t version); |
| 130 | |
Kristian Høgsberg | 0c4457f | 2008-12-07 19:59:11 -0500 | [diff] [blame] | 131 | struct window * |
Kristian Høgsberg | 248c1b6 | 2011-01-21 18:03:15 -0500 | [diff] [blame] | 132 | window_create(struct display *display, int32_t width, int32_t height); |
| 133 | struct window * |
| 134 | window_create_transient(struct display *display, struct window *parent, |
| 135 | int32_t x, int32_t y, int32_t width, int32_t height); |
| 136 | |
| 137 | void |
| 138 | window_destroy(struct window *window); |
| 139 | |
| 140 | void |
Kristian Høgsberg | 82da52b | 2010-12-17 09:53:12 -0500 | [diff] [blame] | 141 | window_move(struct window *window, struct input *input, uint32_t time); |
Kristian Høgsberg | 0c4457f | 2008-12-07 19:59:11 -0500 | [diff] [blame] | 142 | |
| 143 | void |
Kristian Høgsberg | 0c4457f | 2008-12-07 19:59:11 -0500 | [diff] [blame] | 144 | window_draw(struct window *window); |
| 145 | void |
Kristian Høgsberg | da846ca | 2011-01-11 10:00:52 -0500 | [diff] [blame] | 146 | window_get_child_allocation(struct window *window, |
| 147 | struct rectangle *allocation); |
Callum Lowcay | ef57a9b | 2011-01-14 20:46:23 +1300 | [diff] [blame] | 148 | |
Kristian Høgsberg | 0c4457f | 2008-12-07 19:59:11 -0500 | [diff] [blame] | 149 | void |
Kristian Høgsberg | da846ca | 2011-01-11 10:00:52 -0500 | [diff] [blame] | 150 | window_set_child_size(struct window *window, int32_t width, int32_t height); |
Kristian Høgsberg | 2210676 | 2008-12-08 13:50:07 -0500 | [diff] [blame] | 151 | void |
Kristian Høgsberg | 80d746f | 2010-06-14 23:52:50 -0400 | [diff] [blame] | 152 | window_schedule_redraw(struct window *window); |
Kristian Høgsberg | a85fe3c | 2010-06-08 14:08:30 -0400 | [diff] [blame] | 153 | |
| 154 | void |
Kristian Høgsberg | d0c3b9d | 2010-10-25 11:40:03 -0400 | [diff] [blame] | 155 | window_damage(struct window *window, int32_t x, int32_t y, |
| 156 | int32_t width, int32_t height); |
| 157 | |
Kristian Høgsberg | 0ac16f0 | 2009-01-15 11:37:43 -0500 | [diff] [blame] | 158 | cairo_surface_t * |
Kristian Høgsberg | a85fe3c | 2010-06-08 14:08:30 -0400 | [diff] [blame] | 159 | window_get_surface(struct window *window); |
| 160 | |
Kristian Høgsberg | 0ac16f0 | 2009-01-15 11:37:43 -0500 | [diff] [blame] | 161 | void |
Kristian Høgsberg | 9d69f8e | 2010-09-03 14:46:38 -0400 | [diff] [blame] | 162 | window_flush(struct window *window); |
| 163 | |
Kristian Høgsberg | 012a007 | 2010-10-26 00:02:20 -0400 | [diff] [blame] | 164 | void |
Bryce Harrington | f57303f | 2010-11-19 12:15:15 -0800 | [diff] [blame] | 165 | window_set_surface(struct window *window, cairo_surface_t *surface); |
| 166 | |
| 167 | void |
Kristian Høgsberg | 012a007 | 2010-10-26 00:02:20 -0400 | [diff] [blame] | 168 | window_create_surface(struct window *window); |
| 169 | |
Kristian Høgsberg | d0c3b9d | 2010-10-25 11:40:03 -0400 | [diff] [blame] | 170 | enum window_buffer_type { |
Benjamin Franzke | 6693ac2 | 2011-02-10 12:04:30 +0100 | [diff] [blame^] | 171 | WINDOW_BUFFER_TYPE_EGL_WINDOW, |
Kristian Høgsberg | 297c631 | 2011-02-04 14:11:33 -0500 | [diff] [blame] | 172 | WINDOW_BUFFER_TYPE_EGL_IMAGE, |
Kristian Høgsberg | d0c3b9d | 2010-10-25 11:40:03 -0400 | [diff] [blame] | 173 | WINDOW_BUFFER_TYPE_SHM, |
| 174 | }; |
| 175 | |
| 176 | void |
| 177 | window_set_buffer_type(struct window *window, enum window_buffer_type type); |
| 178 | |
Kristian Høgsberg | 9d69f8e | 2010-09-03 14:46:38 -0400 | [diff] [blame] | 179 | void |
Kristian Høgsberg | 0395f30 | 2008-12-22 12:14:50 -0500 | [diff] [blame] | 180 | window_set_fullscreen(struct window *window, int fullscreen); |
| 181 | |
| 182 | void |
Kristian Høgsberg | c8c3734 | 2010-06-25 11:19:22 -0400 | [diff] [blame] | 183 | window_set_user_data(struct window *window, void *data); |
| 184 | |
Kristian Høgsberg | e9d37bd | 2010-09-02 20:22:42 -0400 | [diff] [blame] | 185 | void * |
| 186 | window_get_user_data(struct window *window); |
| 187 | |
Kristian Høgsberg | c8c3734 | 2010-06-25 11:19:22 -0400 | [diff] [blame] | 188 | void |
Kristian Høgsberg | 80d746f | 2010-06-14 23:52:50 -0400 | [diff] [blame] | 189 | window_set_redraw_handler(struct window *window, |
Kristian Høgsberg | c8c3734 | 2010-06-25 11:19:22 -0400 | [diff] [blame] | 190 | window_redraw_handler_t handler); |
Kristian Høgsberg | 80d746f | 2010-06-14 23:52:50 -0400 | [diff] [blame] | 191 | |
| 192 | void |
Kristian Høgsberg | a85fe3c | 2010-06-08 14:08:30 -0400 | [diff] [blame] | 193 | window_set_decoration(struct window *window, int decoration); |
| 194 | |
| 195 | void |
Kristian Høgsberg | 0c4457f | 2008-12-07 19:59:11 -0500 | [diff] [blame] | 196 | window_set_resize_handler(struct window *window, |
Kristian Høgsberg | c8c3734 | 2010-06-25 11:19:22 -0400 | [diff] [blame] | 197 | window_resize_handler_t handler); |
Kristian Høgsberg | c8c3734 | 2010-06-25 11:19:22 -0400 | [diff] [blame] | 198 | |
Kristian Høgsberg | 6e83d58 | 2008-12-08 00:01:36 -0500 | [diff] [blame] | 199 | void |
| 200 | window_set_key_handler(struct window *window, |
Kristian Høgsberg | c8c3734 | 2010-06-25 11:19:22 -0400 | [diff] [blame] | 201 | window_key_handler_t handler); |
Kristian Høgsberg | 0c4457f | 2008-12-07 19:59:11 -0500 | [diff] [blame] | 202 | |
Kristian Høgsberg | 3c248cc | 2009-02-22 23:01:35 -0500 | [diff] [blame] | 203 | void |
Kristian Høgsberg | 9a68624 | 2010-08-18 15:28:04 -0400 | [diff] [blame] | 204 | window_set_button_handler(struct window *window, |
| 205 | window_button_handler_t handler); |
| 206 | |
| 207 | void |
| 208 | window_set_motion_handler(struct window *window, |
| 209 | window_motion_handler_t handler); |
| 210 | |
| 211 | void |
Kristian Høgsberg | 3c248cc | 2009-02-22 23:01:35 -0500 | [diff] [blame] | 212 | window_set_keyboard_focus_handler(struct window *window, |
Kristian Høgsberg | c8c3734 | 2010-06-25 11:19:22 -0400 | [diff] [blame] | 213 | window_keyboard_focus_handler_t handler); |
Kristian Høgsberg | a85fe3c | 2010-06-08 14:08:30 -0400 | [diff] [blame] | 214 | |
| 215 | void |
Callum Lowcay | ef57a9b | 2011-01-14 20:46:23 +1300 | [diff] [blame] | 216 | window_set_title(struct window *window, const char *title); |
| 217 | |
| 218 | const char * |
| 219 | window_get_title(struct window *window); |
| 220 | |
| 221 | void |
Kristian Høgsberg | b46df05 | 2011-01-18 09:17:57 -0500 | [diff] [blame] | 222 | display_set_global_handler(struct display *display, |
| 223 | display_global_handler_t handler); |
| 224 | |
Kristian Høgsberg | e9d37bd | 2010-09-02 20:22:42 -0400 | [diff] [blame] | 225 | struct wl_drag * |
Kristian Høgsberg | 41da908 | 2010-11-30 14:01:07 -0500 | [diff] [blame] | 226 | window_create_drag(struct window *window); |
Kristian Høgsberg | e9d37bd | 2010-09-02 20:22:42 -0400 | [diff] [blame] | 227 | |
Kristian Høgsberg | 41da908 | 2010-11-30 14:01:07 -0500 | [diff] [blame] | 228 | void |
| 229 | window_activate_drag(struct wl_drag *drag, struct window *window, |
| 230 | struct input *input, uint32_t time); |
Kristian Høgsberg | 9a68624 | 2010-08-18 15:28:04 -0400 | [diff] [blame] | 231 | |
| 232 | void |
| 233 | input_get_position(struct input *input, int32_t *x, int32_t *y); |
| 234 | |
Kristian Høgsberg | 67cac8a | 2011-01-19 14:20:33 -0500 | [diff] [blame] | 235 | uint32_t |
| 236 | input_get_modifiers(struct input *input); |
| 237 | |
Kristian Høgsberg | 1d7ffd3 | 2010-08-25 16:34:05 -0400 | [diff] [blame] | 238 | struct wl_input_device * |
| 239 | input_get_input_device(struct input *input); |
| 240 | |
Kristian Høgsberg | 58eec36 | 2011-01-19 14:27:42 -0500 | [diff] [blame] | 241 | int |
| 242 | input_offers_mime_type(struct input *input, const char *type); |
Kristian Høgsberg | 6bccebe | 2011-01-21 16:23:09 -0500 | [diff] [blame] | 243 | void |
| 244 | input_receive_mime_type(struct input *input, const char *type, int fd); |
Kristian Høgsberg | 58eec36 | 2011-01-19 14:27:42 -0500 | [diff] [blame] | 245 | |
| 246 | |
Kristian Høgsberg | 0c4457f | 2008-12-07 19:59:11 -0500 | [diff] [blame] | 247 | #endif |