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>
25 #include "wayland-server.h"
26 #include "wayland-util.h"
28 #define GL_GLEXT_PROTOTYPES
29 #define EGL_EGLEXT_PROTOTYPES
30 #include <GLES2/gl2.h>
31 #include <GLES2/gl2ext.h>
33 #include <EGL/eglext.h>
35 #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
44 struct wl_object object;
46 struct wlsc_compositor *compositor;
47 struct wlsc_surface *background;
48 struct wlsc_matrix matrix;
49 int32_t x, y, width, height;
52 enum wlsc_pointer_type {
53 WLSC_POINTER_BOTTOM_LEFT,
54 WLSC_POINTER_BOTTOM_RIGHT,
56 WLSC_POINTER_DRAGGING,
57 WLSC_POINTER_LEFT_PTR,
60 WLSC_POINTER_TOP_LEFT,
61 WLSC_POINTER_TOP_RIGHT,
66 struct wlsc_input_device {
67 struct wl_input_device input_device;
68 struct wlsc_surface *sprite;
69 int32_t hotspot_x, hotspot_y;
71 uint32_t modifier_state;
72 struct wl_selection *selection;
76 struct wl_object object;
82 struct wl_object object;
85 struct wlsc_compositor {
86 struct wl_compositor compositor;
93 GLuint proj_uniform, tex_uniform;
94 struct wl_buffer **pointer_buffers;
95 struct wl_display *wl_display;
97 /* We implement the shell interface. */
98 struct wl_shell shell;
100 /* There can be more than one, but not right now... */
101 struct wl_input_device *input_device;
103 struct wl_list output_list;
104 struct wl_list input_device_list;
105 struct wl_list surface_list;
108 struct wl_event_source *timer_source;
110 int repaint_on_timeout;
111 struct timespec previous_swap;
113 struct wlsc_switcher *switcher;
116 void (*destroy)(struct wlsc_compositor *ec);
117 int (*authenticate)(struct wlsc_compositor *c, uint32_t id);
118 void (*present)(struct wlsc_compositor *c);
119 struct wl_buffer *(*create_buffer)(struct wlsc_compositor *c,
120 int32_t width, int32_t height,
121 struct wl_visual *visual,
125 #define MODIFIER_CTRL (1 << 8)
126 #define MODIFIER_ALT (1 << 9)
127 #define MODIFIER_SUPER (1 << 10)
133 enum wlsc_surface_map_type {
134 WLSC_SURFACE_MAP_UNMAPPED,
135 WLSC_SURFACE_MAP_TOPLEVEL,
136 WLSC_SURFACE_MAP_TRANSIENT,
137 WLSC_SURFACE_MAP_FULLSCREEN
140 struct wlsc_surface {
141 struct wl_surface surface;
142 struct wlsc_compositor *compositor;
144 int32_t x, y, width, height;
145 int32_t saved_x, saved_y;
147 struct wlsc_matrix matrix;
148 struct wlsc_matrix matrix_inv;
149 struct wl_visual *visual;
150 struct wl_buffer *buffer;
151 enum wlsc_surface_map_type map_type;
152 struct wlsc_output *fullscreen_output;
156 wlsc_surface_update_matrix(struct wlsc_surface *es);
159 notify_motion(struct wl_input_device *device,
160 uint32_t time, int x, int y);
162 notify_button(struct wl_input_device *device,
163 uint32_t time, int32_t button, int32_t state);
165 notify_key(struct wl_input_device *device,
166 uint32_t time, uint32_t key, uint32_t state);
169 notify_pointer_focus(struct wl_input_device *device,
171 struct wlsc_output *output,
172 int32_t x, int32_t y);
175 notify_keyboard_focus(struct wl_input_device *device,
176 uint32_t time, struct wlsc_output *output,
177 struct wl_array *keys);
180 wlsc_compositor_finish_frame(struct wlsc_compositor *compositor, int msecs);
182 wlsc_compositor_schedule_repaint(struct wlsc_compositor *compositor);
185 wlsc_input_device_set_pointer_image(struct wlsc_input_device *device,
186 enum wlsc_pointer_type type);
187 struct wlsc_surface *
188 pick_surface(struct wl_input_device *device, int32_t *sx, int32_t *sy);
191 wlsc_selection_set_focus(struct wl_selection *selection,
192 struct wl_surface *surface, uint32_t time);
198 wlsc_drm_buffer_create(struct wlsc_compositor *ec,
199 int width, int height,
200 struct wl_visual *visual, const void *data);
203 wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display);
205 wlsc_output_init(struct wlsc_output *output, struct wlsc_compositor *c,
206 int x, int y, int width, int height);
208 wlsc_input_device_init(struct wlsc_input_device *device,
209 struct wlsc_compositor *ec);
211 wlsc_drm_init(struct wlsc_compositor *ec, int fd, const char *filename);
214 wlsc_shm_init(struct wlsc_compositor *ec);
217 wlsc_shell_init(struct wlsc_compositor *ec);
220 shell_move(struct wl_client *client, struct wl_shell *shell,
221 struct wl_surface *surface,
222 struct wl_input_device *device, uint32_t time);
225 shell_resize(struct wl_client *client, struct wl_shell *shell,
226 struct wl_surface *surface,
227 struct wl_input_device *device, uint32_t time, uint32_t edges);
230 wl_buffer_create_drm(struct wlsc_compositor *compositor,
231 struct wl_visual *visual);
233 struct wlsc_compositor *
234 x11_compositor_create(struct wl_display *display, int width, int height);
236 struct wlsc_compositor *
237 drm_compositor_create(struct wl_display *display, int connector);
239 struct wlsc_compositor *
240 wayland_compositor_create(struct wl_display *display, int width, int height);
243 evdev_input_add_devices(struct wlsc_compositor *c, struct udev *udev);
246 tty_create(struct wlsc_compositor *compositor);
249 tty_destroy(struct tty *tty);
252 screenshooter_create(struct wlsc_compositor *ec);
255 wlsc_load_image(const char *filename, int width, int height);