Provide visual feedback as to whether drop is supported
[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 struct input;
37
38 struct display *
39 display_create(int *argc, char **argv[], const GOptionEntry *option_entries);
40
41 struct wl_compositor *
42 display_get_compositor(struct display *display);
43
44 #ifdef EGL_NO_DISPLAY
45 EGLDisplay
46 display_get_egl_display(struct display *d);
47 #endif
48
49 cairo_surface_t *
50 display_create_surface(struct display *display,
51                        struct rectangle *rectangle);
52
53 struct wl_buffer *
54 display_get_buffer_for_surface(struct display *display,
55                                cairo_surface_t *surface);
56
57 cairo_surface_t *
58 display_get_pointer_surface(struct display *display, int pointer,
59                             int *width, int *height,
60                             int *hotspot_x, int *hotspot_y);
61
62 void
63 display_add_drag_listener(struct display *display,
64                           const struct wl_drag_listener *drag_listener,
65                           void *data);
66
67 void
68 display_flush_cairo_device(struct display *display);
69
70 void
71 display_run(struct display *d);
72
73 enum {
74         WINDOW_MODIFIER_SHIFT = 0x01,
75         WINDOW_MODIFIER_LOCK = 0x02,
76         WINDOW_MODIFIER_CONTROL = 0x04,
77         WINDOW_MODIFIER_ALT = 0x08,
78         WINDOW_MODIFIER_MOD2 = 0x10,
79 };
80
81 enum pointer_type {
82         POINTER_BOTTOM_LEFT,
83         POINTER_BOTTOM_RIGHT,
84         POINTER_BOTTOM,
85         POINTER_DRAGGING,
86         POINTER_LEFT_PTR,
87         POINTER_LEFT,
88         POINTER_RIGHT,
89         POINTER_TOP_LEFT,
90         POINTER_TOP_RIGHT,
91         POINTER_TOP,
92         POINTER_IBEAM,
93         POINTER_HAND1,
94 };
95
96 typedef void (*window_resize_handler_t)(struct window *window, void *data);
97 typedef void (*window_redraw_handler_t)(struct window *window, void *data);
98 typedef void (*window_frame_handler_t)(struct window *window, uint32_t frame, uint32_t timestamp, void *data);
99 typedef void (*window_acknowledge_handler_t)(struct window *window, uint32_t key, uint32_t frame, void *data);
100 typedef void (*window_key_handler_t)(struct window *window, uint32_t key, uint32_t unicode,
101                                      uint32_t state, uint32_t modifiers, void *data);
102 typedef void (*window_keyboard_focus_handler_t)(struct window *window,
103                                                 struct input *device, void *data);
104
105 typedef void (*window_button_handler_t)(struct window *window,
106                                         struct input *input, uint32_t time,
107                                         int button, int state, void *data);
108
109 typedef int (*window_motion_handler_t)(struct window *window,
110                                        struct input *input, uint32_t time,
111                                        int32_t x, int32_t y,
112                                        int32_t sx, int32_t sy, void *data);
113
114 struct window *
115 window_create(struct display *display, const char *title,
116               int32_t x, int32_t y, int32_t width, int32_t height);
117
118 void
119 window_draw(struct window *window);
120 void
121 window_commit(struct window *window, uint32_t key);
122 void
123 window_get_child_rectangle(struct window *window,
124                            struct rectangle *rectangle);
125 void
126 window_set_child_size(struct window *window,
127                       struct rectangle *rectangle);
128 void
129 window_copy_image(struct window *window,
130                   struct rectangle *rectangle,
131                   void *image);
132 void
133 window_schedule_redraw(struct window *window);
134
135 void
136 window_move(struct window *window, int32_t x, int32_t y);
137
138 cairo_surface_t *
139 window_get_surface(struct window *window);
140
141 void
142 window_copy_surface(struct window *window,
143                     struct rectangle *rectangle,
144                     cairo_surface_t *surface);
145
146 void
147 window_set_fullscreen(struct window *window, int fullscreen);
148
149 void
150 window_set_user_data(struct window *window, void *data);
151
152 void
153 window_set_redraw_handler(struct window *window,
154                           window_redraw_handler_t handler);
155
156 void
157 window_set_decoration(struct window *window, int decoration);
158
159 void
160 window_set_resize_handler(struct window *window,
161                           window_resize_handler_t handler);
162 void
163 window_set_frame_handler(struct window *window,
164                          window_frame_handler_t handler);
165 void
166 window_set_acknowledge_handler(struct window *window,
167                                window_acknowledge_handler_t handler);
168
169 void
170 window_set_key_handler(struct window *window,
171                        window_key_handler_t handler);
172
173 void
174 window_set_button_handler(struct window *window,
175                           window_button_handler_t handler);
176
177 void
178 window_set_motion_handler(struct window *window,
179                           window_motion_handler_t handler);
180
181 void
182 window_set_keyboard_focus_handler(struct window *window,
183                                   window_keyboard_focus_handler_t handler);
184
185 void
186 window_set_acknowledge_handler(struct window *window,
187                                window_acknowledge_handler_t handler);
188
189 void
190 window_set_frame_handler(struct window *window,
191                          window_frame_handler_t handler);
192
193 void
194 window_start_drag(struct window *window, struct input *input, uint32_t time);
195
196 void
197 input_get_position(struct input *input, int32_t *x, int32_t *y);
198
199 struct wl_input_device *
200 input_get_input_device(struct input *input);
201
202 #endif