Consolidate more code in clients/window.c
[profile/ivi/weston.git] / clients / window.h
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
35 struct display;
36
37 struct display *
38 display_create(int *argc, char **argv[], const GOptionEntry *option_entries);
39
40 struct wl_compositor *
41 display_get_compositor(struct display *display);
42
43 #ifdef EGL_NO_DISPLAY
44 EGLDisplay
45 display_get_egl_display(struct display *d);
46 #endif
47
48 void
49 display_run(struct display *d);
50
51 enum {
52         WINDOW_MODIFIER_SHIFT = 0x01,
53         WINDOW_MODIFIER_ALT = 0x02,
54         WINDOW_MODIFIER_CONTROL = 0x04,
55 };
56
57 typedef void (*window_resize_handler_t)(struct window *window, void *data);
58 typedef void (*window_frame_handler_t)(struct window *window, uint32_t frame, uint32_t timestamp, void *data);
59 typedef void (*window_acknowledge_handler_t)(struct window *window, uint32_t key, void *data);
60 typedef void (*window_key_handler_t)(struct window *window, uint32_t key, uint32_t unicode,
61                                      uint32_t state, uint32_t modifiers, void *data);
62 typedef void (*window_keyboard_focus_handler_t)(struct window *window,
63                                                 struct wl_input_device *device, void *data);
64
65 struct window *
66 window_create(struct display *display, const char *title,
67               int32_t x, int32_t y, int32_t width, int32_t height);
68
69 void
70 window_draw(struct window *window);
71 void
72 window_commit(struct window *window, uint32_t key);
73 void
74 window_get_child_rectangle(struct window *window,
75                            struct rectangle *rectangle);
76 void
77 window_set_child_size(struct window *window,
78                       struct rectangle *rectangle);
79 void
80 window_copy_image(struct window *window,
81                   struct rectangle *rectangle,
82                   void *image);
83
84 void
85 window_move(struct window *window, int32_t x, int32_t y);
86
87 cairo_surface_t *
88 window_create_surface(struct window *window,
89                       struct rectangle *rectangle);
90
91 cairo_surface_t *
92 window_get_surface(struct window *window);
93
94 void
95 window_copy_surface(struct window *window,
96                     struct rectangle *rectangle,
97                     cairo_surface_t *surface);
98
99 void
100 window_set_fullscreen(struct window *window, int fullscreen);
101
102 void
103 window_set_decoration(struct window *window, int decoration);
104
105 void
106 window_set_resize_handler(struct window *window,
107                           window_resize_handler_t handler, void *data);
108 void
109 window_set_frame_handler(struct window *window,
110                          window_frame_handler_t handler, void *data);
111 void
112 window_set_acknowledge_handler(struct window *window,
113                                window_acknowledge_handler_t handler, void *data);
114 void
115 window_set_key_handler(struct window *window,
116                        window_key_handler_t handler, void *data);
117
118 void
119 window_set_keyboard_focus_handler(struct window *window,
120                                   window_keyboard_focus_handler_t handler,
121                                   void *data);
122
123 void
124 window_set_frame_handler(struct window *window,
125                          window_frame_handler_t handler, void *data);
126
127 #endif