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 | |
| 26 | struct window; |
| 27 | |
| 28 | struct rectangle { |
| 29 | int32_t x; |
| 30 | int32_t y; |
| 31 | int32_t width; |
| 32 | int32_t height; |
| 33 | }; |
| 34 | |
Kristian Høgsberg | 43c28ee | 2009-01-26 23:42:46 -0500 | [diff] [blame] | 35 | struct display; |
| 36 | |
| 37 | struct display * |
| 38 | display_create(struct wl_display *display, int fd); |
| 39 | struct wl_compositor * |
| 40 | display_get_compositor(struct display *display); |
| 41 | |
Kristian Høgsberg | 5544491 | 2009-02-21 14:31:09 -0500 | [diff] [blame] | 42 | enum { |
| 43 | WINDOW_MODIFIER_SHIFT = 0x01, |
| 44 | WINDOW_MODIFIER_ALT = 0x02, |
| 45 | WINDOW_MODIFIER_CONTROL = 0x04, |
| 46 | }; |
| 47 | |
Kristian Høgsberg | 2210676 | 2008-12-08 13:50:07 -0500 | [diff] [blame] | 48 | typedef void (*window_resize_handler_t)(struct window *window, void *data); |
Kristian Høgsberg | 0c4457f | 2008-12-07 19:59:11 -0500 | [diff] [blame] | 49 | typedef void (*window_frame_handler_t)(struct window *window, uint32_t frame, uint32_t timestamp, void *data); |
| 50 | typedef void (*window_acknowledge_handler_t)(struct window *window, uint32_t key, void *data); |
Kristian Høgsberg | 5544491 | 2009-02-21 14:31:09 -0500 | [diff] [blame] | 51 | typedef void (*window_key_handler_t)(struct window *window, uint32_t key, uint32_t unicode, |
| 52 | uint32_t state, uint32_t modifiers, void *data); |
Kristian Høgsberg | 3c248cc | 2009-02-22 23:01:35 -0500 | [diff] [blame^] | 53 | typedef void (*window_keyboard_focus_handler_t)(struct window *window, |
| 54 | struct wl_input_device *device, void *data); |
Kristian Høgsberg | 0c4457f | 2008-12-07 19:59:11 -0500 | [diff] [blame] | 55 | |
| 56 | struct window * |
Kristian Høgsberg | 43c28ee | 2009-01-26 23:42:46 -0500 | [diff] [blame] | 57 | window_create(struct display *display, const char *title, |
Kristian Høgsberg | 0c4457f | 2008-12-07 19:59:11 -0500 | [diff] [blame] | 58 | int32_t x, int32_t y, int32_t width, int32_t height); |
| 59 | |
| 60 | void |
Kristian Høgsberg | 0c4457f | 2008-12-07 19:59:11 -0500 | [diff] [blame] | 61 | window_draw(struct window *window); |
| 62 | void |
| 63 | window_get_child_rectangle(struct window *window, |
| 64 | struct rectangle *rectangle); |
| 65 | void |
Kristian Høgsberg | 2210676 | 2008-12-08 13:50:07 -0500 | [diff] [blame] | 66 | window_set_child_size(struct window *window, |
| 67 | struct rectangle *rectangle); |
| 68 | void |
Kristian Høgsberg | 0c4457f | 2008-12-07 19:59:11 -0500 | [diff] [blame] | 69 | window_copy(struct window *window, |
| 70 | struct rectangle *rectangle, |
| 71 | uint32_t name, uint32_t stride); |
| 72 | |
Kristian Høgsberg | 0ac16f0 | 2009-01-15 11:37:43 -0500 | [diff] [blame] | 73 | cairo_surface_t * |
| 74 | window_create_surface(struct window *window, |
| 75 | struct rectangle *rectangle); |
| 76 | |
| 77 | void |
| 78 | window_copy_surface(struct window *window, |
| 79 | struct rectangle *rectangle, |
| 80 | cairo_surface_t *surface); |
| 81 | |
Kristian Høgsberg | 0c4457f | 2008-12-07 19:59:11 -0500 | [diff] [blame] | 82 | void |
Kristian Høgsberg | 0395f30 | 2008-12-22 12:14:50 -0500 | [diff] [blame] | 83 | window_set_fullscreen(struct window *window, int fullscreen); |
| 84 | |
| 85 | void |
Kristian Høgsberg | 0c4457f | 2008-12-07 19:59:11 -0500 | [diff] [blame] | 86 | window_set_resize_handler(struct window *window, |
| 87 | window_resize_handler_t handler, void *data); |
| 88 | void |
| 89 | window_set_frame_handler(struct window *window, |
| 90 | window_frame_handler_t handler, void *data); |
| 91 | void |
| 92 | window_set_acknowledge_handler(struct window *window, |
| 93 | window_acknowledge_handler_t handler, void *data); |
Kristian Høgsberg | 6e83d58 | 2008-12-08 00:01:36 -0500 | [diff] [blame] | 94 | void |
| 95 | window_set_key_handler(struct window *window, |
| 96 | window_key_handler_t handler, void *data); |
Kristian Høgsberg | 0c4457f | 2008-12-07 19:59:11 -0500 | [diff] [blame] | 97 | |
Kristian Høgsberg | 3c248cc | 2009-02-22 23:01:35 -0500 | [diff] [blame^] | 98 | void |
| 99 | window_set_keyboard_focus_handler(struct window *window, |
| 100 | window_keyboard_focus_handler_t handler, |
| 101 | void *data); |
Kristian Høgsberg | 0c4457f | 2008-12-07 19:59:11 -0500 | [diff] [blame] | 102 | #endif |