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_
24 #include <xf86drmMode.h>
27 #include "wayland-util.h"
30 #include <EGL/eglext.h>
32 #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
39 struct wl_object base;
44 struct wlsc_listener {
46 void (*func)(struct wlsc_listener *listener,
47 struct wlsc_surface *surface);
51 struct wl_object base;
53 struct wlsc_compositor *compositor;
54 struct wlsc_surface *background;
55 struct wlsc_matrix matrix;
56 int32_t x, y, width, height;
60 uint32_t connector_id;
68 struct wlsc_input_device {
69 struct wl_object base;
71 struct wlsc_compositor *ec;
72 struct wlsc_surface *sprite;
76 struct wlsc_surface *grab_surface;
77 struct wlsc_surface *pointer_focus;
78 struct wlsc_surface *keyboard_focus;
81 struct wlsc_listener listener;
84 struct wlsc_compositor {
85 struct wl_compositor base;
86 struct wl_visual argb_visual, premultiplied_argb_visual, rgb_visual;
92 GLuint proj_uniform, tex_uniform;
93 struct wl_display *wl_display;
95 /* There can be more than one, but not right now... */
96 struct wlsc_input_device *input_device;
98 struct wl_list output_list;
99 struct wl_list input_device_list;
100 struct wl_list surface_list;
102 struct wl_list surface_destroy_listener_list;
104 struct wl_event_source *term_signal_source;
106 /* tty handling state */
108 uint32_t vt_active : 1;
110 struct termios terminal_attributes;
111 struct wl_event_source *tty_input_source;
112 struct wl_event_source *enter_vt_source;
113 struct wl_event_source *leave_vt_source;
118 struct wl_event_source *timer_source;
120 int repaint_on_timeout;
121 struct timespec previous_swap;
122 uint32_t current_frame;
123 struct wl_event_source *drm_source;
125 uint32_t modifier_state;
128 #define MODIFIER_CTRL (1 << 8)
129 #define MODIFIER_ALT (1 << 9)
135 struct wlsc_surface {
136 struct wl_surface base;
137 struct wlsc_compositor *compositor;
138 struct wl_visual *visual;
143 struct wlsc_matrix matrix;
144 struct wlsc_matrix matrix_inv;
148 notify_motion(struct wlsc_input_device *device, int x, int y);
150 notify_button(struct wlsc_input_device *device, int32_t button, int32_t state);
152 notify_key(struct wlsc_input_device *device, uint32_t key, uint32_t state);
155 wlsc_compositor_present_drm(struct wlsc_compositor *wlsc);
157 wlsc_compositor_init_drm(struct wlsc_compositor *ec);
159 wlsc_compositor_finish_frame(struct wlsc_compositor *compositor, int msecs);
160 struct wlsc_input_device *
161 wlsc_input_device_create(struct wlsc_compositor *ec);
164 screenshooter_create(struct wlsc_compositor *ec);
166 extern const char *option_background;
167 extern int option_connector;