2 * Copyright © 2008 Kristian Høgsberg
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 #ifndef _WAYLAND_SYSTEM_COMPOSITOR_H_
20 #define _WAYLAND_SYSTEM_COMPOSITOR_H_
23 #include <xf86drmMode.h>
26 #include "wayland-server.h"
27 #include "wayland-util.h"
29 #define GL_GLEXT_PROTOTYPES
30 #define EGL_EGLEXT_PROTOTYPES
31 #include <GLES2/gl2.h>
32 #include <GLES2/gl2ext.h>
34 #include <EGL/eglext.h>
36 #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
45 struct wl_object object;
47 struct wlsc_compositor *compositor;
48 struct wlsc_surface *background;
49 struct wlsc_matrix matrix;
50 int32_t x, y, width, height;
51 pixman_region32_t previous_damage_region;
54 enum wlsc_pointer_type {
55 WLSC_POINTER_BOTTOM_LEFT,
56 WLSC_POINTER_BOTTOM_RIGHT,
58 WLSC_POINTER_DRAGGING,
59 WLSC_POINTER_LEFT_PTR,
62 WLSC_POINTER_TOP_LEFT,
63 WLSC_POINTER_TOP_RIGHT,
68 struct wlsc_input_device {
69 struct wl_input_device input_device;
70 struct wlsc_surface *sprite;
71 int32_t hotspot_x, hotspot_y;
73 uint32_t modifier_state;
74 struct wl_selection *selection;
78 struct wl_object object;
84 struct wl_object object;
87 struct wlsc_compositor {
88 struct wl_compositor compositor;
96 GLuint proj_uniform, tex_uniform;
97 struct wl_buffer **pointer_buffers;
98 struct wl_display *wl_display;
100 /* We implement the shell interface. */
101 struct wl_shell shell;
103 /* There can be more than one, but not right now... */
104 struct wl_input_device *input_device;
106 struct wl_list output_list;
107 struct wl_list input_device_list;
108 struct wl_list surface_list;
111 struct wl_event_source *timer_source;
113 int repaint_on_timeout;
114 struct timespec previous_swap;
115 pixman_region32_t damage_region;
116 struct wl_array vertices, indices;
118 struct wlsc_switcher *switcher;
121 void (*destroy)(struct wlsc_compositor *ec);
122 int (*authenticate)(struct wlsc_compositor *c, uint32_t id);
123 void (*present)(struct wlsc_compositor *c);
124 struct wl_buffer *(*create_buffer)(struct wlsc_compositor *c,
125 int32_t width, int32_t height,
126 struct wl_visual *visual,
130 #define MODIFIER_CTRL (1 << 8)
131 #define MODIFIER_ALT (1 << 9)
132 #define MODIFIER_SUPER (1 << 10)
134 enum wlsc_output_flags {
135 WL_OUTPUT_FLIPPED = 0x01
142 enum wlsc_surface_map_type {
143 WLSC_SURFACE_MAP_UNMAPPED,
144 WLSC_SURFACE_MAP_TOPLEVEL,
145 WLSC_SURFACE_MAP_TRANSIENT,
146 WLSC_SURFACE_MAP_FULLSCREEN
149 struct wlsc_surface {
150 struct wl_surface surface;
151 struct wlsc_compositor *compositor;
153 int32_t x, y, width, height;
154 int32_t saved_x, saved_y;
156 struct wlsc_matrix matrix;
157 struct wlsc_matrix matrix_inv;
158 struct wl_visual *visual;
159 struct wl_buffer *buffer;
160 enum wlsc_surface_map_type map_type;
161 struct wlsc_output *fullscreen_output;
165 wlsc_surface_update_matrix(struct wlsc_surface *es);
168 notify_motion(struct wl_input_device *device,
169 uint32_t time, int x, int y);
171 notify_button(struct wl_input_device *device,
172 uint32_t time, int32_t button, int32_t state);
174 notify_key(struct wl_input_device *device,
175 uint32_t time, uint32_t key, uint32_t state);
178 notify_pointer_focus(struct wl_input_device *device,
180 struct wlsc_output *output,
181 int32_t x, int32_t y);
184 notify_keyboard_focus(struct wl_input_device *device,
185 uint32_t time, struct wlsc_output *output,
186 struct wl_array *keys);
189 wlsc_compositor_finish_frame(struct wlsc_compositor *compositor, int msecs);
191 wlsc_compositor_schedule_repaint(struct wlsc_compositor *compositor);
194 wlsc_surface_damage(struct wlsc_surface *surface);
197 wlsc_surface_damage_rectangle(struct wlsc_surface *surface,
198 int32_t x, int32_t y,
199 int32_t width, int32_t height);
202 wlsc_input_device_set_pointer_image(struct wlsc_input_device *device,
203 enum wlsc_pointer_type type);
204 struct wlsc_surface *
205 pick_surface(struct wl_input_device *device, int32_t *sx, int32_t *sy);
208 wlsc_selection_set_focus(struct wl_selection *selection,
209 struct wl_surface *surface, uint32_t time);
215 wlsc_drm_buffer_create(struct wlsc_compositor *ec,
216 int width, int height,
217 struct wl_visual *visual, const void *data);
220 wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display);
222 wlsc_output_init(struct wlsc_output *output, struct wlsc_compositor *c,
223 int x, int y, int width, int height, uint32_t flags);
225 wlsc_input_device_init(struct wlsc_input_device *device,
226 struct wlsc_compositor *ec);
228 wlsc_drm_init(struct wlsc_compositor *ec, int fd, const char *filename);
231 wlsc_shm_init(struct wlsc_compositor *ec);
234 wlsc_shell_init(struct wlsc_compositor *ec);
237 shell_move(struct wl_client *client, struct wl_shell *shell,
238 struct wl_surface *surface,
239 struct wl_input_device *device, uint32_t time);
242 shell_resize(struct wl_client *client, struct wl_shell *shell,
243 struct wl_surface *surface,
244 struct wl_input_device *device, uint32_t time, uint32_t edges);
247 wl_buffer_create_drm(struct wlsc_compositor *compositor,
248 struct wl_visual *visual);
250 struct wlsc_compositor *
251 x11_compositor_create(struct wl_display *display, int width, int height);
253 struct wlsc_compositor *
254 drm_compositor_create(struct wl_display *display, int connector);
256 struct wlsc_compositor *
257 wayland_compositor_create(struct wl_display *display, int width, int height);
260 evdev_input_add_devices(struct wlsc_compositor *c, struct udev *udev);
263 tty_create(struct wlsc_compositor *compositor);
266 tty_destroy(struct tty *tty);
269 screenshooter_create(struct wlsc_compositor *ec);
272 wlsc_load_image(const char *filename, int width, int height);