2008-12-19 21:47:53 +03:00
|
|
|
/*
|
|
|
|
* Copyright © 2008 Kristian Høgsberg
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _WAYLAND_SYSTEM_COMPOSITOR_H_
|
|
|
|
#define _WAYLAND_SYSTEM_COMPOSITOR_H_
|
|
|
|
|
2010-06-11 20:56:24 +04:00
|
|
|
#include <libudev.h>
|
2011-02-13 21:00:51 +03:00
|
|
|
#include <pixman.h>
|
2010-08-10 22:12:05 +04:00
|
|
|
#include "wayland-server.h"
|
2010-06-11 20:56:24 +04:00
|
|
|
#include "wayland-util.h"
|
|
|
|
|
2010-08-09 22:43:33 +04:00
|
|
|
#define GL_GLEXT_PROTOTYPES
|
|
|
|
#define EGL_EGLEXT_PROTOTYPES
|
|
|
|
#include <GLES2/gl2.h>
|
|
|
|
#include <GLES2/gl2ext.h>
|
2010-06-11 20:56:24 +04:00
|
|
|
#include <EGL/egl.h>
|
|
|
|
#include <EGL/eglext.h>
|
|
|
|
|
|
|
|
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
|
|
|
|
|
|
|
|
struct wlsc_matrix {
|
|
|
|
GLfloat d[16];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct wlsc_surface;
|
|
|
|
|
|
|
|
struct wlsc_output {
|
2010-12-02 01:07:41 +03:00
|
|
|
struct wl_object object;
|
2010-06-11 20:56:24 +04:00
|
|
|
struct wl_list link;
|
|
|
|
struct wlsc_compositor *compositor;
|
|
|
|
struct wlsc_surface *background;
|
|
|
|
struct wlsc_matrix matrix;
|
|
|
|
int32_t x, y, width, height;
|
2011-02-13 21:00:51 +03:00
|
|
|
pixman_region32_t previous_damage_region;
|
2011-03-15 17:08:41 +03:00
|
|
|
uint32_t flags;
|
2011-03-14 14:07:26 +03:00
|
|
|
int repaint_needed;
|
|
|
|
int finished;
|
2011-03-11 18:39:20 +03:00
|
|
|
|
|
|
|
int (*prepare_render)(struct wlsc_output *output);
|
2011-03-14 14:07:26 +03:00
|
|
|
int (*present)(struct wlsc_output *output);
|
2010-06-11 20:56:24 +04:00
|
|
|
};
|
|
|
|
|
2010-08-17 00:08:12 +04:00
|
|
|
enum wlsc_pointer_type {
|
|
|
|
WLSC_POINTER_BOTTOM_LEFT,
|
|
|
|
WLSC_POINTER_BOTTOM_RIGHT,
|
|
|
|
WLSC_POINTER_BOTTOM,
|
|
|
|
WLSC_POINTER_DRAGGING,
|
|
|
|
WLSC_POINTER_LEFT_PTR,
|
|
|
|
WLSC_POINTER_LEFT,
|
|
|
|
WLSC_POINTER_RIGHT,
|
|
|
|
WLSC_POINTER_TOP_LEFT,
|
|
|
|
WLSC_POINTER_TOP_RIGHT,
|
|
|
|
WLSC_POINTER_TOP,
|
|
|
|
WLSC_POINTER_IBEAM,
|
|
|
|
};
|
|
|
|
|
2010-06-11 20:56:24 +04:00
|
|
|
struct wlsc_input_device {
|
2010-12-02 01:07:41 +03:00
|
|
|
struct wl_input_device input_device;
|
2010-06-11 20:56:24 +04:00
|
|
|
struct wlsc_surface *sprite;
|
2010-08-16 18:38:29 +04:00
|
|
|
int32_t hotspot_x, hotspot_y;
|
2010-06-11 20:56:24 +04:00
|
|
|
struct wl_list link;
|
2010-08-05 07:21:41 +04:00
|
|
|
uint32_t modifier_state;
|
2011-01-18 17:08:53 +03:00
|
|
|
struct wl_selection *selection;
|
2010-06-11 20:56:24 +04:00
|
|
|
};
|
|
|
|
|
2010-10-07 05:17:40 +04:00
|
|
|
struct wlsc_shm {
|
2010-12-02 01:07:41 +03:00
|
|
|
struct wl_object object;
|
2010-10-07 05:17:40 +04:00
|
|
|
};
|
|
|
|
|
2010-06-11 20:56:24 +04:00
|
|
|
struct wlsc_compositor {
|
2010-12-02 01:07:41 +03:00
|
|
|
struct wl_compositor compositor;
|
2010-06-11 20:56:24 +04:00
|
|
|
|
2010-10-07 05:17:40 +04:00
|
|
|
struct wlsc_shm shm;
|
2010-06-11 20:56:24 +04:00
|
|
|
EGLDisplay display;
|
|
|
|
EGLContext context;
|
2011-02-18 19:04:24 +03:00
|
|
|
EGLConfig config;
|
2011-02-13 21:44:55 +03:00
|
|
|
GLuint fbo;
|
2010-06-11 20:56:24 +04:00
|
|
|
GLuint proj_uniform, tex_uniform;
|
2011-01-15 00:20:21 +03:00
|
|
|
struct wl_buffer **pointer_buffers;
|
2010-06-11 20:56:24 +04:00
|
|
|
struct wl_display *wl_display;
|
|
|
|
|
2010-08-05 06:44:55 +04:00
|
|
|
/* We implement the shell interface. */
|
2010-08-17 00:24:19 +04:00
|
|
|
struct wl_shell shell;
|
2010-08-05 06:44:55 +04:00
|
|
|
|
2010-06-11 20:56:24 +04:00
|
|
|
/* There can be more than one, but not right now... */
|
2010-12-08 17:48:52 +03:00
|
|
|
struct wl_input_device *input_device;
|
2010-06-11 20:56:24 +04:00
|
|
|
|
|
|
|
struct wl_list output_list;
|
|
|
|
struct wl_list input_device_list;
|
|
|
|
struct wl_list surface_list;
|
2011-04-11 21:58:13 +04:00
|
|
|
struct wl_list binding_list;
|
2010-06-11 20:56:24 +04:00
|
|
|
|
|
|
|
/* Repaint state. */
|
|
|
|
struct wl_event_source *timer_source;
|
|
|
|
int repaint_on_timeout;
|
|
|
|
struct timespec previous_swap;
|
2011-02-13 21:00:51 +03:00
|
|
|
pixman_region32_t damage_region;
|
2011-02-14 18:39:54 +03:00
|
|
|
struct wl_array vertices, indices;
|
2010-06-11 20:56:24 +04:00
|
|
|
|
2011-02-07 00:54:59 +03:00
|
|
|
struct wlsc_switcher *switcher;
|
2010-07-07 17:51:11 +04:00
|
|
|
uint32_t focus;
|
2010-06-14 19:54:00 +04:00
|
|
|
|
2010-12-02 00:52:15 +03:00
|
|
|
void (*destroy)(struct wlsc_compositor *ec);
|
2010-08-10 06:11:47 +04:00
|
|
|
int (*authenticate)(struct wlsc_compositor *c, uint32_t id);
|
2011-01-15 00:20:21 +03:00
|
|
|
struct wl_buffer *(*create_buffer)(struct wlsc_compositor *c,
|
|
|
|
int32_t width, int32_t height,
|
2011-03-02 13:56:04 +03:00
|
|
|
int32_t stride, struct wl_visual *visual,
|
|
|
|
void *data);
|
2010-06-11 20:56:24 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#define MODIFIER_CTRL (1 << 8)
|
|
|
|
#define MODIFIER_ALT (1 << 9)
|
2010-08-05 07:21:41 +04:00
|
|
|
#define MODIFIER_SUPER (1 << 10)
|
2010-06-11 20:56:24 +04:00
|
|
|
|
2011-02-18 18:51:37 +03:00
|
|
|
enum wlsc_output_flags {
|
|
|
|
WL_OUTPUT_FLIPPED = 0x01
|
|
|
|
};
|
|
|
|
|
2010-06-11 20:56:24 +04:00
|
|
|
struct wlsc_vector {
|
|
|
|
GLfloat f[4];
|
|
|
|
};
|
|
|
|
|
2011-01-28 23:18:33 +03:00
|
|
|
enum wlsc_surface_map_type {
|
|
|
|
WLSC_SURFACE_MAP_UNMAPPED,
|
|
|
|
WLSC_SURFACE_MAP_TOPLEVEL,
|
|
|
|
WLSC_SURFACE_MAP_TRANSIENT,
|
|
|
|
WLSC_SURFACE_MAP_FULLSCREEN
|
|
|
|
};
|
|
|
|
|
2010-06-11 20:56:24 +04:00
|
|
|
struct wlsc_surface {
|
2010-12-02 01:07:41 +03:00
|
|
|
struct wl_surface surface;
|
2010-06-11 20:56:24 +04:00
|
|
|
struct wlsc_compositor *compositor;
|
|
|
|
GLuint texture;
|
2010-08-05 06:44:55 +04:00
|
|
|
int32_t x, y, width, height;
|
2011-01-28 23:18:33 +03:00
|
|
|
int32_t saved_x, saved_y;
|
2010-06-11 20:56:24 +04:00
|
|
|
struct wl_list link;
|
|
|
|
struct wlsc_matrix matrix;
|
|
|
|
struct wlsc_matrix matrix_inv;
|
2010-08-09 22:43:33 +04:00
|
|
|
struct wl_visual *visual;
|
2010-10-07 05:17:40 +04:00
|
|
|
struct wl_buffer *buffer;
|
2011-03-14 14:07:26 +03:00
|
|
|
struct wlsc_output *output;
|
2011-01-28 23:18:33 +03:00
|
|
|
enum wlsc_surface_map_type map_type;
|
|
|
|
struct wlsc_output *fullscreen_output;
|
2010-06-11 20:56:24 +04:00
|
|
|
};
|
|
|
|
|
2011-01-18 15:53:49 +03:00
|
|
|
void
|
|
|
|
wlsc_surface_update_matrix(struct wlsc_surface *es);
|
|
|
|
|
2008-12-19 21:47:53 +03:00
|
|
|
void
|
2010-12-08 17:48:52 +03:00
|
|
|
notify_motion(struct wl_input_device *device,
|
2010-07-21 01:06:19 +04:00
|
|
|
uint32_t time, int x, int y);
|
2008-12-19 21:47:53 +03:00
|
|
|
void
|
2010-12-08 17:48:52 +03:00
|
|
|
notify_button(struct wl_input_device *device,
|
2010-07-21 01:06:19 +04:00
|
|
|
uint32_t time, int32_t button, int32_t state);
|
2008-12-19 21:47:53 +03:00
|
|
|
void
|
2010-12-08 17:48:52 +03:00
|
|
|
notify_key(struct wl_input_device *device,
|
2010-07-21 01:06:19 +04:00
|
|
|
uint32_t time, uint32_t key, uint32_t state);
|
2008-12-19 21:47:53 +03:00
|
|
|
|
2011-01-27 04:35:07 +03:00
|
|
|
void
|
|
|
|
notify_pointer_focus(struct wl_input_device *device,
|
|
|
|
uint32_t time,
|
|
|
|
struct wlsc_output *output,
|
|
|
|
int32_t x, int32_t y);
|
|
|
|
|
2011-01-27 19:57:19 +03:00
|
|
|
void
|
|
|
|
notify_keyboard_focus(struct wl_input_device *device,
|
|
|
|
uint32_t time, struct wlsc_output *output,
|
|
|
|
struct wl_array *keys);
|
|
|
|
|
2010-06-11 20:56:24 +04:00
|
|
|
void
|
2011-03-14 14:07:26 +03:00
|
|
|
wlsc_output_finish_frame(struct wlsc_output *output, int msecs);
|
2010-07-07 17:51:11 +04:00
|
|
|
void
|
|
|
|
wlsc_compositor_schedule_repaint(struct wlsc_compositor *compositor);
|
2010-06-11 20:56:24 +04:00
|
|
|
|
2011-04-11 21:58:13 +04:00
|
|
|
struct wlsc_binding;
|
|
|
|
typedef void (*wlsc_binding_handler_t)(struct wlsc_input_device *device,
|
|
|
|
uint32_t time, uint32_t key,
|
|
|
|
uint32_t state, void *data);
|
|
|
|
struct wlsc_binding *
|
|
|
|
wlsc_compositor_add_binding(struct wlsc_compositor *compositor,
|
|
|
|
uint32_t key, uint32_t modifier,
|
|
|
|
wlsc_binding_handler_t binding, void *data);
|
|
|
|
void
|
|
|
|
wlsc_binding_destroy(struct wlsc_binding *binding);
|
|
|
|
|
|
|
|
|
2011-03-14 14:07:26 +03:00
|
|
|
void
|
|
|
|
wlsc_surface_assign_output(struct wlsc_surface *surface);
|
|
|
|
|
2011-02-13 21:00:51 +03:00
|
|
|
void
|
|
|
|
wlsc_surface_damage(struct wlsc_surface *surface);
|
|
|
|
|
|
|
|
void
|
|
|
|
wlsc_surface_damage_rectangle(struct wlsc_surface *surface,
|
|
|
|
int32_t x, int32_t y,
|
|
|
|
int32_t width, int32_t height);
|
|
|
|
|
2011-01-18 15:53:49 +03:00
|
|
|
void
|
|
|
|
wlsc_input_device_set_pointer_image(struct wlsc_input_device *device,
|
|
|
|
enum wlsc_pointer_type type);
|
|
|
|
struct wlsc_surface *
|
|
|
|
pick_surface(struct wl_input_device *device, int32_t *sx, int32_t *sy);
|
|
|
|
|
2011-01-18 17:08:53 +03:00
|
|
|
void
|
|
|
|
wlsc_selection_set_focus(struct wl_selection *selection,
|
|
|
|
struct wl_surface *surface, uint32_t time);
|
|
|
|
|
2011-01-18 15:53:49 +03:00
|
|
|
uint32_t
|
|
|
|
get_time(void);
|
|
|
|
|
2011-01-15 00:20:21 +03:00
|
|
|
struct wl_buffer *
|
2011-03-02 13:56:04 +03:00
|
|
|
wlsc_shm_buffer_create(struct wlsc_compositor *ec,
|
|
|
|
int32_t width, int32_t height,
|
|
|
|
int32_t stride, struct wl_visual *visual,
|
|
|
|
void *data);
|
2010-10-07 05:17:40 +04:00
|
|
|
|
2010-06-14 19:54:00 +04:00
|
|
|
int
|
|
|
|
wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display);
|
|
|
|
void
|
2011-03-15 17:08:41 +03:00
|
|
|
wlsc_output_move(struct wlsc_output *output, int x, int y);
|
|
|
|
void
|
2010-06-14 19:54:00 +04:00
|
|
|
wlsc_output_init(struct wlsc_output *output, struct wlsc_compositor *c,
|
2011-02-18 18:51:37 +03:00
|
|
|
int x, int y, int width, int height, uint32_t flags);
|
2011-03-15 17:08:41 +03:00
|
|
|
void
|
|
|
|
wlsc_output_destroy(struct wlsc_output *output);
|
|
|
|
|
2010-06-14 19:54:00 +04:00
|
|
|
void
|
|
|
|
wlsc_input_device_init(struct wlsc_input_device *device,
|
|
|
|
struct wlsc_compositor *ec);
|
|
|
|
|
2010-10-07 05:17:40 +04:00
|
|
|
int
|
|
|
|
wlsc_shm_init(struct wlsc_compositor *ec);
|
|
|
|
|
2011-01-18 15:53:49 +03:00
|
|
|
int
|
|
|
|
wlsc_shell_init(struct wlsc_compositor *ec);
|
|
|
|
|
|
|
|
void
|
|
|
|
shell_move(struct wl_client *client, struct wl_shell *shell,
|
|
|
|
struct wl_surface *surface,
|
|
|
|
struct wl_input_device *device, uint32_t time);
|
|
|
|
|
|
|
|
void
|
|
|
|
shell_resize(struct wl_client *client, struct wl_shell *shell,
|
|
|
|
struct wl_surface *surface,
|
|
|
|
struct wl_input_device *device, uint32_t time, uint32_t edges);
|
|
|
|
|
2010-06-14 19:54:00 +04:00
|
|
|
struct wlsc_compositor *
|
2010-10-26 19:26:44 +04:00
|
|
|
x11_compositor_create(struct wl_display *display, int width, int height);
|
2010-06-14 19:54:00 +04:00
|
|
|
|
|
|
|
struct wlsc_compositor *
|
2010-10-26 19:26:44 +04:00
|
|
|
drm_compositor_create(struct wl_display *display, int connector);
|
2010-06-14 19:54:00 +04:00
|
|
|
|
2010-11-27 21:04:12 +03:00
|
|
|
struct wlsc_compositor *
|
|
|
|
wayland_compositor_create(struct wl_display *display, int width, int height);
|
|
|
|
|
2011-01-14 22:45:42 +03:00
|
|
|
void
|
|
|
|
evdev_input_add_devices(struct wlsc_compositor *c, struct udev *udev);
|
|
|
|
|
2011-01-14 22:59:13 +03:00
|
|
|
struct tty *
|
|
|
|
tty_create(struct wlsc_compositor *compositor);
|
|
|
|
|
|
|
|
void
|
|
|
|
tty_destroy(struct tty *tty);
|
|
|
|
|
2010-06-11 20:56:24 +04:00
|
|
|
void
|
|
|
|
screenshooter_create(struct wlsc_compositor *ec);
|
|
|
|
|
2011-01-26 22:37:07 +03:00
|
|
|
uint32_t *
|
|
|
|
wlsc_load_image(const char *filename, int width, int height);
|
|
|
|
|
2008-12-19 21:47:53 +03:00
|
|
|
#endif
|