Kristian Høgsberg | 82f6e8a | 2008-12-19 13:47:53 -0500 | [diff] [blame] | 1 | /* |
| 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øgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 22 | #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 | |
| 34 | struct wlsc_matrix { |
| 35 | GLfloat d[16]; |
| 36 | }; |
| 37 | |
| 38 | struct wl_visual { |
| 39 | struct wl_object base; |
| 40 | }; |
| 41 | |
| 42 | struct wlsc_surface; |
| 43 | |
| 44 | struct wlsc_listener { |
| 45 | struct wl_list link; |
| 46 | void (*func)(struct wlsc_listener *listener, |
| 47 | struct wlsc_surface *surface); |
| 48 | }; |
| 49 | |
| 50 | struct 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øgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | struct 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 | |
| 75 | struct 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øgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 81 | 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øgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 94 | /* 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øgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 100 | |
| 101 | uint32_t modifier_state; |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame^] | 102 | |
| 103 | void (*present)(struct wlsc_compositor *c); |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 104 | }; |
| 105 | |
| 106 | #define MODIFIER_CTRL (1 << 8) |
| 107 | #define MODIFIER_ALT (1 << 9) |
| 108 | |
| 109 | struct wlsc_vector { |
| 110 | GLfloat f[4]; |
| 111 | }; |
| 112 | |
| 113 | struct 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øgsberg | 82f6e8a | 2008-12-19 13:47:53 -0500 | [diff] [blame] | 125 | void |
| 126 | notify_motion(struct wlsc_input_device *device, int x, int y); |
| 127 | void |
| 128 | notify_button(struct wlsc_input_device *device, int32_t button, int32_t state); |
| 129 | void |
| 130 | notify_key(struct wlsc_input_device *device, uint32_t key, uint32_t state); |
| 131 | |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 132 | void |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 133 | wlsc_compositor_finish_frame(struct wlsc_compositor *compositor, int msecs); |
| 134 | struct wlsc_input_device * |
| 135 | wlsc_input_device_create(struct wlsc_compositor *ec); |
| 136 | |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame^] | 137 | int |
| 138 | wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display); |
| 139 | void |
| 140 | wlsc_output_init(struct wlsc_output *output, struct wlsc_compositor *c, |
| 141 | int x, int y, int width, int height); |
| 142 | void |
| 143 | wlsc_input_device_init(struct wlsc_input_device *device, |
| 144 | struct wlsc_compositor *ec); |
| 145 | |
| 146 | struct wlsc_compositor * |
| 147 | x11_compositor_create(struct wl_display *display); |
| 148 | |
| 149 | struct wlsc_compositor * |
| 150 | drm_compositor_create(struct wl_display *display); |
| 151 | |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 152 | void |
| 153 | screenshooter_create(struct wlsc_compositor *ec); |
| 154 | |
| 155 | extern const char *option_background; |
| 156 | extern int option_connector; |
Kristian Høgsberg | 82f6e8a | 2008-12-19 13:47:53 -0500 | [diff] [blame] | 157 | |
| 158 | #endif |