blob: 99cce30334c152ba540d612282835da5cf592c74 [file] [log] [blame]
Kristian Høgsberg82f6e8a2008-12-19 13:47:53 -05001/*
2 * Copyright © 2008 Kristian Høgsberg
3 *
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.
8 *
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.
13 *
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.
17 */
18
19#ifndef _WAYLAND_SYSTEM_COMPOSITOR_H_
20#define _WAYLAND_SYSTEM_COMPOSITOR_H_
21
Kristian Høgsbergfc783d42010-06-11 12:56:24 -040022#include <termios.h>
23#include <xf86drm.h>
24#include <xf86drmMode.h>
25#include <libudev.h>
26#include "wayland.h"
27#include "wayland-util.h"
28
29#include <EGL/egl.h>
30#include <EGL/eglext.h>
31
32#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
33
34struct wlsc_matrix {
35 GLfloat d[16];
36};
37
38struct wl_visual {
39 struct wl_object base;
40};
41
42struct wlsc_surface;
43
44struct wlsc_listener {
45 struct wl_list link;
46 void (*func)(struct wlsc_listener *listener,
47 struct wlsc_surface *surface);
48};
49
50struct wlsc_output {
51 struct wl_object base;
52 struct wl_list link;
53 struct wlsc_compositor *compositor;
54 struct wlsc_surface *background;
55 struct wlsc_matrix matrix;
56 int32_t x, y, width, height;
Kristian Høgsbergfc783d42010-06-11 12:56:24 -040057};
58
59struct wlsc_input_device {
60 struct wl_object base;
61 int32_t x, y;
62 struct wlsc_compositor *ec;
63 struct wlsc_surface *sprite;
64 struct wl_list link;
65
66 int grab;
67 struct wlsc_surface *grab_surface;
68 struct wlsc_surface *pointer_focus;
69 struct wlsc_surface *keyboard_focus;
70 struct wl_array keys;
71
72 struct wlsc_listener listener;
73};
74
75struct wlsc_compositor {
76 struct wl_compositor base;
77 struct wl_visual argb_visual, premultiplied_argb_visual, rgb_visual;
78
79 EGLDisplay display;
80 EGLContext context;
Kristian Høgsbergfc783d42010-06-11 12:56:24 -040081 GLuint fbo, vbo;
82 GLuint proj_uniform, tex_uniform;
83 struct wl_display *wl_display;
84
85 /* There can be more than one, but not right now... */
86 struct wlsc_input_device *input_device;
87
88 struct wl_list output_list;
89 struct wl_list input_device_list;
90 struct wl_list surface_list;
91
92 struct wl_list surface_destroy_listener_list;
93
Kristian Høgsbergfc783d42010-06-11 12:56:24 -040094 /* Repaint state. */
95 struct wl_event_source *timer_source;
96 int repaint_needed;
97 int repaint_on_timeout;
98 struct timespec previous_swap;
99 uint32_t current_frame;
Kristian Høgsbergfc783d42010-06-11 12:56:24 -0400100
101 uint32_t modifier_state;
Kristian Høgsbergce5325d2010-06-14 11:54:00 -0400102
103 void (*present)(struct wlsc_compositor *c);
Kristian Høgsbergfc783d42010-06-11 12:56:24 -0400104};
105
106#define MODIFIER_CTRL (1 << 8)
107#define MODIFIER_ALT (1 << 9)
108
109struct wlsc_vector {
110 GLfloat f[4];
111};
112
113struct wlsc_surface {
114 struct wl_surface base;
115 struct wlsc_compositor *compositor;
116 struct wl_visual *visual;
117 GLuint texture;
118 EGLImageKHR image;
119 int width, height;
120 struct wl_list link;
121 struct wlsc_matrix matrix;
122 struct wlsc_matrix matrix_inv;
123};
124
Kristian Høgsberg82f6e8a2008-12-19 13:47:53 -0500125void
126notify_motion(struct wlsc_input_device *device, int x, int y);
127void
128notify_button(struct wlsc_input_device *device, int32_t button, int32_t state);
129void
130notify_key(struct wlsc_input_device *device, uint32_t key, uint32_t state);
131
Kristian Høgsbergfc783d42010-06-11 12:56:24 -0400132void
Kristian Høgsbergfc783d42010-06-11 12:56:24 -0400133wlsc_compositor_finish_frame(struct wlsc_compositor *compositor, int msecs);
134struct wlsc_input_device *
135wlsc_input_device_create(struct wlsc_compositor *ec);
136
Kristian Høgsbergce5325d2010-06-14 11:54:00 -0400137int
138wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display);
139void
140wlsc_output_init(struct wlsc_output *output, struct wlsc_compositor *c,
141 int x, int y, int width, int height);
142void
143wlsc_input_device_init(struct wlsc_input_device *device,
144 struct wlsc_compositor *ec);
145
146struct wlsc_compositor *
147x11_compositor_create(struct wl_display *display);
148
149struct wlsc_compositor *
150drm_compositor_create(struct wl_display *display);
151
Kristian Høgsbergfc783d42010-06-11 12:56:24 -0400152void
153screenshooter_create(struct wlsc_compositor *ec);
154
155extern const char *option_background;
156extern int option_connector;
Kristian Høgsberg82f6e8a2008-12-19 13:47:53 -0500157
158#endif