Rename wayland-compositor to weston

This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.

1) Initially, we had one big repository with protocol code, sample
compositor and sample clients.  We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code.  At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message.  The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.

2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor.  Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example.  Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.

We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
dev
Kristian Høgsberg 13 years ago
parent 4c61747a1f
commit 8334bc1ef9
  1. 2
      Makefile.am
  2. 12
      clients/Makefile.am
  3. 470
      compositor/compositor.h
  4. 2
      configure.ac
  5. 4
      data/Makefile.am
  6. 0
      src/.gitignore
  7. 12
      src/Makefile.am
  8. 62
      src/compositor-drm.c
  9. 0
      src/compositor-openwfd.c
  10. 48
      src/compositor-wayland.c
  11. 66
      src/compositor-x11.c
  12. 503
      src/compositor.c
  13. 471
      src/compositor.h
  14. 82
      src/data-device.c
  15. 24
      src/evdev.c
  16. 8
      src/evdev.h
  17. 0
      src/hash.c
  18. 0
      src/hash.h
  19. 0
      src/image-loader.c
  20. 6
      src/screenshooter.c
  21. 198
      src/shell.c
  22. 52
      src/switcher.c
  23. 106
      src/tablet-shell.c
  24. 4
      src/tty.c
  25. 116
      src/util.c
  26. 278
      src/xserver-launcher.c

@ -1 +1 @@
SUBDIRS = shared compositor clients data SUBDIRS = shared src clients data

@ -29,8 +29,8 @@ clients_programs = \
wscreensaver \ wscreensaver \
eventdemo eventdemo
desktop_shell = wayland-desktop-shell desktop_shell = weston-desktop-shell
tablet_shell = wayland-tablet-shell tablet_shell = weston-tablet-shell
noinst_LIBRARIES = libtoytoolkit.a noinst_LIBRARIES = libtoytoolkit.a
@ -84,18 +84,18 @@ wscreensaver_LDADD = $(toolkit_libs) -lGLU
eventdemo_SOURCES = eventdemo.c eventdemo_SOURCES = eventdemo.c
eventdemo_LDADD = $(toolkit_libs) eventdemo_LDADD = $(toolkit_libs)
wayland_desktop_shell_SOURCES = \ weston_desktop_shell_SOURCES = \
desktop-shell.c \ desktop-shell.c \
desktop-shell-client-protocol.h \ desktop-shell-client-protocol.h \
desktop-shell-protocol.c desktop-shell-protocol.c
wayland_desktop_shell_LDADD = $(toolkit_libs) \ weston_desktop_shell_LDADD = $(toolkit_libs) \
../shared/libconfig-parser.la ../shared/libconfig-parser.la
wayland_tablet_shell_SOURCES = \ weston_tablet_shell_SOURCES = \
tablet-shell.c \ tablet-shell.c \
tablet-shell-client-protocol.h \ tablet-shell-client-protocol.h \
tablet-shell-protocol.c tablet-shell-protocol.c
wayland_tablet_shell_LDADD = $(toolkit_libs) \ weston_tablet_shell_LDADD = $(toolkit_libs) \
../shared/libconfig-parser.la ../shared/libconfig-parser.la
BUILT_SOURCES = \ BUILT_SOURCES = \

@ -1,470 +0,0 @@
/*
* Copyright © 2008-2011 Kristian Høgsberg
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of the copyright holders not be used in
* advertising or publicity pertaining to distribution of the software
* without specific, written prior permission. The copyright holders make
* no representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _WAYLAND_SYSTEM_COMPOSITOR_H_
#define _WAYLAND_SYSTEM_COMPOSITOR_H_
#include <libudev.h>
#include <pixman.h>
#include <wayland-server.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
struct wlsc_matrix {
GLfloat d[16];
};
struct wlsc_vector {
GLfloat f[4];
};
void
wlsc_matrix_init(struct wlsc_matrix *matrix);
void
wlsc_matrix_scale(struct wlsc_matrix *matrix, GLfloat x, GLfloat y, GLfloat z);
void
wlsc_matrix_translate(struct wlsc_matrix *matrix,
GLfloat x, GLfloat y, GLfloat z);
void
wlsc_matrix_transform(struct wlsc_matrix *matrix, struct wlsc_vector *v);
struct wlsc_transform {
struct wlsc_matrix matrix;
struct wlsc_matrix inverse;
};
struct wlsc_surface;
struct wlsc_input_device;
struct wlsc_mode {
uint32_t flags;
int32_t width, height;
uint32_t refresh;
struct wl_list link;
};
struct wlsc_output {
struct wl_list link;
struct wlsc_compositor *compositor;
struct wlsc_matrix matrix;
struct wl_list frame_callback_list;
int32_t x, y, mm_width, mm_height;
pixman_region32_t region;
pixman_region32_t previous_damage;
uint32_t flags;
int repaint_needed;
int repaint_scheduled;
char *make, *model;
uint32_t subpixel;
struct wlsc_mode *current;
struct wl_list mode_list;
struct wl_buffer *scanout_buffer;
struct wl_listener scanout_buffer_destroy_listener;
struct wl_buffer *pending_scanout_buffer;
struct wl_listener pending_scanout_buffer_destroy_listener;
int (*prepare_render)(struct wlsc_output *output);
int (*present)(struct wlsc_output *output);
int (*prepare_scanout_surface)(struct wlsc_output *output,
struct wlsc_surface *es);
int (*set_hardware_cursor)(struct wlsc_output *output,
struct wlsc_input_device *input);
void (*destroy)(struct wlsc_output *output);
};
struct wlsc_input_device {
struct wl_input_device input_device;
struct wlsc_compositor *compositor;
struct wlsc_surface *sprite;
int32_t hotspot_x, hotspot_y;
struct wl_list link;
uint32_t modifier_state;
struct wl_selection *selection;
struct wl_list drag_resource_list;
struct wlsc_data_source *drag_data_source;
struct wl_surface *drag_focus;
struct wl_resource *drag_focus_resource;
struct wl_listener drag_focus_listener;
struct wlsc_data_source *selection_data_source;
struct wl_listener selection_data_source_listener;
struct wl_grab grab;
uint32_t num_tp;
struct wl_surface *touch_focus;
struct wl_listener touch_focus_listener;
struct wl_resource *touch_focus_resource;
struct wl_listener touch_focus_resource_listener;
};
enum wlsc_visual {
WLSC_NONE_VISUAL,
WLSC_ARGB_VISUAL,
WLSC_PREMUL_ARGB_VISUAL,
WLSC_RGB_VISUAL
};
struct wlsc_shader {
GLuint program;
GLuint vertex_shader, fragment_shader;
GLuint proj_uniform;
GLuint tex_uniform;
GLuint alpha_uniform;
GLuint color_uniform;
};
struct wlsc_animation {
void (*frame)(struct wlsc_animation *animation,
struct wlsc_output *output, uint32_t msecs);
struct wl_list link;
};
struct wlsc_spring {
double k;
double friction;
double current;
double target;
double previous;
uint32_t timestamp;
};
struct wlsc_shell {
void (*lock)(struct wlsc_shell *shell);
void (*unlock)(struct wlsc_shell *shell);
void (*map)(struct wlsc_shell *shell, struct wlsc_surface *surface,
int32_t width, int32_t height);
void (*configure)(struct wlsc_shell *shell,
struct wlsc_surface *surface,
int32_t x, int32_t y, int32_t width, int32_t height);
};
enum {
WLSC_COMPOSITOR_ACTIVE,
WLSC_COMPOSITOR_IDLE, /* shell->unlock called on activity */
WLSC_COMPOSITOR_SLEEPING /* no rendering, no frame events */
};
struct wlsc_compositor {
struct wl_shm *shm;
struct wlsc_xserver *wxs;
EGLDisplay display;
EGLContext context;
EGLConfig config;
GLuint fbo;
GLuint proj_uniform, tex_uniform, alpha_uniform;
uint32_t current_alpha;
struct wlsc_shader texture_shader;
struct wlsc_shader solid_shader;
struct wl_display *wl_display;
struct wlsc_shell *shell;
/* There can be more than one, but not right now... */
struct wl_input_device *input_device;
struct wl_list output_list;
struct wl_list input_device_list;
struct wl_list surface_list;
struct wl_list binding_list;
struct wl_list animation_list;
struct {
struct wlsc_spring spring;
struct wlsc_animation animation;
} fade;
uint32_t state;
struct wl_event_source *idle_source;
uint32_t idle_inhibit;
int option_idle_time; /* default timeout, s */
int idle_time; /* effective timeout, s */
/* Repaint state. */
struct timespec previous_swap;
struct wl_array vertices, indices;
struct wlsc_surface *overlay;
struct wlsc_switcher *switcher;
uint32_t focus;
PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC
image_target_renderbuffer_storage;
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC image_target_texture_2d;
PFNEGLCREATEIMAGEKHRPROC create_image;
PFNEGLDESTROYIMAGEKHRPROC destroy_image;
PFNEGLBINDWAYLANDDISPLAYWL bind_display;
PFNEGLUNBINDWAYLANDDISPLAYWL unbind_display;
int has_bind_display;
void (*destroy)(struct wlsc_compositor *ec);
int (*authenticate)(struct wlsc_compositor *c, uint32_t id);
EGLImageKHR (*create_cursor_image)(struct wlsc_compositor *c,
int32_t *width, int32_t *height);
};
#define MODIFIER_CTRL (1 << 8)
#define MODIFIER_ALT (1 << 9)
#define MODIFIER_SUPER (1 << 10)
enum wlsc_output_flags {
WL_OUTPUT_FLIPPED = 0x01
};
struct wlsc_surface {
struct wl_surface surface;
struct wlsc_compositor *compositor;
GLuint texture, saved_texture;
pixman_region32_t damage;
pixman_region32_t opaque;
int32_t x, y, width, height;
int32_t pitch;
struct wl_list link;
struct wl_list buffer_link;
struct wlsc_transform *transform;
uint32_t alpha;
uint32_t visual;
/*
* Which output to vsync this surface to.
* Used to determine, whether to send or queue frame events.
* Must be NULL, if 'link' is not in wlsc_compositor::surface_list.
*/
struct wlsc_output *output;
struct wlsc_output *fullscreen_output;
struct wl_list frame_callback_list;
EGLImageKHR image;
struct wl_buffer *buffer;
struct wl_listener buffer_destroy_listener;
};
struct wlsc_data_source {
struct wl_resource resource;
struct wl_array mime_types;
int refcount;
void *data;
struct wl_resource *(*create_offer)(struct wlsc_data_source *source,
struct wl_resource *target);
void (*cancel)(struct wlsc_data_source *source);
};
void
wlsc_data_source_unref(struct wlsc_data_source *source);
void
wlsc_input_device_set_selection(struct wlsc_input_device *device,
struct wlsc_data_source *source,
uint32_t time);
void
wlsc_spring_init(struct wlsc_spring *spring,
double k, double current, double target);
void
wlsc_spring_update(struct wlsc_spring *spring, uint32_t msec);
int
wlsc_spring_done(struct wlsc_spring *spring);
void
wlsc_surface_activate(struct wlsc_surface *surface,
struct wlsc_input_device *device, uint32_t time);
void
notify_motion(struct wl_input_device *device,
uint32_t time, int x, int y);
void
notify_button(struct wl_input_device *device,
uint32_t time, int32_t button, int32_t state);
void
notify_key(struct wl_input_device *device,
uint32_t time, uint32_t key, uint32_t state);
void
notify_pointer_focus(struct wl_input_device *device,
uint32_t time,
struct wlsc_output *output,
int32_t x, int32_t y);
void
notify_keyboard_focus(struct wl_input_device *device,
uint32_t time, struct wlsc_output *output,
struct wl_array *keys);
void
notify_touch(struct wl_input_device *device, uint32_t time, int touch_id,
int x, int y, int touch_type);
void
wlsc_output_finish_frame(struct wlsc_output *output, int msecs);
void
wlsc_output_damage(struct wlsc_output *output);
void
wlsc_compositor_repick(struct wlsc_compositor *compositor);
void
wlsc_compositor_schedule_repaint(struct wlsc_compositor *compositor);
void
wlsc_compositor_fade(struct wlsc_compositor *compositor, float tint);
void
wlsc_compositor_damage_all(struct wlsc_compositor *compositor);
void
wlsc_compositor_unlock(struct wlsc_compositor *compositor);
void
wlsc_compositor_wake(struct wlsc_compositor *compositor);
void
wlsc_compositor_activity(struct wlsc_compositor *compositor);
struct wlsc_binding;
typedef void (*wlsc_binding_handler_t)(struct wl_input_device *device,
uint32_t time, uint32_t key,
uint32_t button,
uint32_t state, void *data);
struct wlsc_binding *
wlsc_compositor_add_binding(struct wlsc_compositor *compositor,
uint32_t key, uint32_t button, uint32_t modifier,
wlsc_binding_handler_t binding, void *data);
void
wlsc_binding_destroy(struct wlsc_binding *binding);
void
wlsc_compositor_run_binding(struct wlsc_compositor *compositor,
struct wlsc_input_device *device,
uint32_t time,
uint32_t key, uint32_t button, int32_t state);
struct wlsc_surface *
wlsc_surface_create(struct wlsc_compositor *compositor,
int32_t x, int32_t y, int32_t width, int32_t height);
void
wlsc_surface_configure(struct wlsc_surface *surface,
int x, int y, int width, int height);
void
wlsc_surface_assign_output(struct wlsc_surface *surface);
void
wlsc_surface_damage(struct wlsc_surface *surface);
void
wlsc_surface_damage_below(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);
struct wlsc_surface *
pick_surface(struct wl_input_device *device, int32_t *sx, int32_t *sy);
uint32_t
wlsc_compositor_get_time(void);
int
wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display);
void
wlsc_compositor_shutdown(struct wlsc_compositor *ec);
void
wlsc_output_move(struct wlsc_output *output, int x, int y);
void
wlsc_output_init(struct wlsc_output *output, struct wlsc_compositor *c,
int x, int y, int width, int height, uint32_t flags);
void
wlsc_output_destroy(struct wlsc_output *output);
void
wlsc_input_device_init(struct wlsc_input_device *device,
struct wlsc_compositor *ec);
void
wlsc_switcher_init(struct wlsc_compositor *compositor);
enum {
TTY_ENTER_VT,
TTY_LEAVE_VT
};
typedef void (*tty_vt_func_t)(struct wlsc_compositor *compositor, int event);
struct tty *
tty_create(struct wlsc_compositor *compositor, tty_vt_func_t vt_func,
int tty_nr);
void
tty_destroy(struct tty *tty);
void
screenshooter_create(struct wlsc_compositor *ec);
uint32_t *
wlsc_load_image(const char *filename,
int32_t *width_arg, int32_t *height_arg, uint32_t *stride_arg);
struct wlsc_process;
typedef void (*wlsc_process_cleanup_func_t)(struct wlsc_process *process,
int status);
struct wlsc_process {
pid_t pid;
wlsc_process_cleanup_func_t cleanup;
struct wl_list link;
};
struct wl_client *
wlsc_client_launch(struct wlsc_compositor *compositor,
struct wlsc_process *proc,
const char *path,
wlsc_process_cleanup_func_t cleanup);
int
wlsc_data_device_manager_init(struct wlsc_compositor *compositor);
void
wlsc_data_device_set_keyboard_focus(struct wlsc_input_device *device);
void
wlsc_watch_process(struct wlsc_process *process);
int
wlsc_xserver_init(struct wlsc_compositor *compositor);
void
wlsc_xserver_destroy(struct wlsc_compositor *compositor);
void
wlsc_xserver_surface_activate(struct wlsc_surface *surface);
void
wlsc_xserver_set_selection(struct wlsc_input_device *device);
struct wlsc_zoom;
typedef void (*wlsc_zoom_done_func_t)(struct wlsc_zoom *zoom, void *data);
struct wlsc_zoom *
wlsc_zoom_run(struct wlsc_surface *surface, GLfloat start, GLfloat stop,
wlsc_zoom_done_func_t done, void *data);
#endif

@ -141,7 +141,7 @@ WAYLAND_SCANNER_RULES(['$(top_srcdir)/protocol'])
AC_CONFIG_FILES([Makefile AC_CONFIG_FILES([Makefile
shared/Makefile shared/Makefile
compositor/Makefile src/Makefile
clients/Makefile clients/Makefile
data/Makefile]) data/Makefile])
AC_OUTPUT AC_OUTPUT

@ -1,6 +1,6 @@
waylanddatadir = $(datadir)/wayland westondatadir = $(datadir)/weston
dist_waylanddata_DATA = \ dist_westondata_DATA = \
bottom_left_corner.png \ bottom_left_corner.png \
bottom_right_corner.png \ bottom_right_corner.png \
bottom_side.png \ bottom_side.png \

@ -1,4 +1,4 @@
bin_PROGRAMS = wayland-compositor bin_PROGRAMS = weston
AM_CPPFLAGS = \ AM_CPPFLAGS = \
-DDATADIR='"$(datadir)"' \ -DDATADIR='"$(datadir)"' \
@ -7,12 +7,12 @@ AM_CPPFLAGS = \
-DXSERVER_PATH='"@XSERVER_PATH@"' \ -DXSERVER_PATH='"@XSERVER_PATH@"' \
$(COMPOSITOR_CFLAGS) $(COMPOSITOR_CFLAGS)
wayland_compositor_LDFLAGS = -export-dynamic weston_LDFLAGS = -export-dynamic
wayland_compositor_CFLAGS = $(GCC_CFLAGS) weston_CFLAGS = $(GCC_CFLAGS)
wayland_compositor_LDADD = \ weston_LDADD = \
$(COMPOSITOR_LIBS) $(DLOPEN_LIBS) $(XSERVER_LAUNCHER_LIBS) $(COMPOSITOR_LIBS) $(DLOPEN_LIBS) $(XSERVER_LAUNCHER_LIBS)
wayland_compositor_SOURCES = \ weston_SOURCES = \
compositor.c \ compositor.c \
compositor.h \ compositor.h \
image-loader.c \ image-loader.c \
@ -32,7 +32,7 @@ xserver_launcher_sources = \
hash.h hash.h
endif endif
moduledir = @libdir@/wayland moduledir = @libdir@/weston
module_LTLIBRARIES = \ module_LTLIBRARIES = \
$(desktop_shell) \ $(desktop_shell) \
$(tablet_shell) \ $(tablet_shell) \

@ -38,7 +38,7 @@
#include "evdev.h" #include "evdev.h"
struct drm_compositor { struct drm_compositor {
struct wlsc_compositor base; struct weston_compositor base;
struct udev *udev; struct udev *udev;
struct wl_event_source *drm_source; struct wl_event_source *drm_source;
@ -58,12 +58,12 @@ struct drm_compositor {
}; };
struct drm_mode { struct drm_mode {
struct wlsc_mode base; struct weston_mode base;
drmModeModeInfo mode_info; drmModeModeInfo mode_info;
}; };
struct drm_output { struct drm_output {
struct wlsc_output base; struct weston_output base;
uint32_t crtc_id; uint32_t crtc_id;
uint32_t connector_id; uint32_t connector_id;
@ -79,7 +79,7 @@ struct drm_output {
}; };
static int static int
drm_output_prepare_render(struct wlsc_output *output_base) drm_output_prepare_render(struct weston_output *output_base)
{ {
struct drm_output *output = (struct drm_output *) output_base; struct drm_output *output = (struct drm_output *) output_base;
@ -95,7 +95,7 @@ drm_output_prepare_render(struct wlsc_output *output_base)
} }
static int static int
drm_output_present(struct wlsc_output *output_base) drm_output_present(struct weston_output *output_base)
{ {
struct drm_output *output = (struct drm_output *) output_base; struct drm_output *output = (struct drm_output *) output_base;
struct drm_compositor *c = struct drm_compositor *c =
@ -139,12 +139,12 @@ page_flip_handler(int fd, unsigned int frame,
} }
msecs = sec * 1000 + usec / 1000; msecs = sec * 1000 + usec / 1000;
wlsc_output_finish_frame(&output->base, msecs); weston_output_finish_frame(&output->base, msecs);
} }
static int static int
drm_output_prepare_scanout_surface(struct wlsc_output *output_base, drm_output_prepare_scanout_surface(struct weston_output *output_base,
struct wlsc_surface *es) struct weston_surface *es)
{ {
struct drm_output *output = (struct drm_output *) output_base; struct drm_output *output = (struct drm_output *) output_base;
struct drm_compositor *c = struct drm_compositor *c =
@ -188,8 +188,8 @@ drm_output_prepare_scanout_surface(struct wlsc_output *output_base,
} }
static int static int
drm_output_set_cursor(struct wlsc_output *output_base, drm_output_set_cursor(struct weston_output *output_base,
struct wlsc_input_device *eid) struct weston_input_device *eid)
{ {
struct drm_output *output = (struct drm_output *) output_base; struct drm_output *output = (struct drm_output *) output_base;
struct drm_compositor *c = struct drm_compositor *c =
@ -259,7 +259,7 @@ out:
} }
static void static void
drm_output_destroy(struct wlsc_output *output_base) drm_output_destroy(struct weston_output *output_base)
{ {
struct drm_output *output = (struct drm_output *) output_base; struct drm_output *output = (struct drm_output *) output_base;
struct drm_compositor *c = struct drm_compositor *c =
@ -294,7 +294,7 @@ drm_output_destroy(struct wlsc_output *output_base)
c->crtc_allocator &= ~(1 << output->crtc_id); c->crtc_allocator &= ~(1 << output->crtc_id);
c->connector_allocator &= ~(1 << output->connector_id); c->connector_allocator &= ~(1 << output->connector_id);
wlsc_output_destroy(&output->base); weston_output_destroy(&output->base);
wl_list_remove(&output->base.link); wl_list_remove(&output->base.link);
free(output); free(output);
@ -542,7 +542,7 @@ create_output_for_connector(struct drm_compositor *ec,
goto err_fb; goto err_fb;
} }
wlsc_output_init(&output->base, &ec->base, x, y, weston_output_init(&output->base, &ec->base, x, y,
connector->mmWidth, connector->mmHeight, 0); connector->mmWidth, connector->mmHeight, 0);
wl_list_insert(ec->base.output_list.prev, &output->base.link); wl_list_insert(ec->base.output_list.prev, &output->base.link);
@ -619,7 +619,7 @@ create_outputs(struct drm_compositor *ec, int option_connector)
} }
x += container_of(ec->base.output_list.prev, x += container_of(ec->base.output_list.prev,
struct wlsc_output, struct weston_output,
link)->current->width; link)->current->width;
} }
@ -669,9 +669,9 @@ update_outputs(struct drm_compositor *ec)
connected |= (1 << connector_id); connected |= (1 << connector_id);
if (!(ec->connector_allocator & (1 << connector_id))) { if (!(ec->connector_allocator & (1 << connector_id))) {
struct wlsc_output *last = struct weston_output *last =
container_of(ec->base.output_list.prev, container_of(ec->base.output_list.prev,
struct wlsc_output, link); struct weston_output, link);
/* XXX: not yet needed, we die with 0 outputs */ /* XXX: not yet needed, we die with 0 outputs */
if (!wl_list_empty(&ec->base.output_list)) if (!wl_list_empty(&ec->base.output_list))
@ -693,7 +693,7 @@ update_outputs(struct drm_compositor *ec)
wl_list_for_each_safe(output, next, &ec->base.output_list, wl_list_for_each_safe(output, next, &ec->base.output_list,
base.link) { base.link) {
if (x_offset != 0 || y_offset != 0) { if (x_offset != 0 || y_offset != 0) {
wlsc_output_move(&output->base, weston_output_move(&output->base,
output->base.x - x_offset, output->base.x - x_offset,
output->base.y - y_offset); output->base.y - y_offset);
} }
@ -744,7 +744,7 @@ udev_drm_event(int fd, uint32_t mask, void *data)
} }
static EGLImageKHR static EGLImageKHR
drm_compositor_create_cursor_image(struct wlsc_compositor *ec, drm_compositor_create_cursor_image(struct weston_compositor *ec,
int32_t *width, int32_t *height) int32_t *width, int32_t *height)
{ {
struct drm_compositor *c = (struct drm_compositor *) ec; struct drm_compositor *c = (struct drm_compositor *) ec;
@ -770,12 +770,12 @@ drm_compositor_create_cursor_image(struct wlsc_compositor *ec,
} }
static void static void
drm_destroy(struct wlsc_compositor *ec) drm_destroy(struct weston_compositor *ec)
{ {
struct drm_compositor *d = (struct drm_compositor *) ec; struct drm_compositor *d = (struct drm_compositor *) ec;
struct wlsc_input_device *input, *next; struct weston_input_device *input, *next;
wlsc_compositor_shutdown(ec); weston_compositor_shutdown(ec);
gbm_device_destroy(d->gbm); gbm_device_destroy(d->gbm);
tty_destroy(d->tty); tty_destroy(d->tty);
@ -786,25 +786,25 @@ drm_destroy(struct wlsc_compositor *ec)
} }
static void static void
vt_func(struct wlsc_compositor *compositor, int event) vt_func(struct weston_compositor *compositor, int event)
{ {
struct drm_compositor *ec = (struct drm_compositor *) compositor; struct drm_compositor *ec = (struct drm_compositor *) compositor;
struct wlsc_output *output; struct weston_output *output;
struct wlsc_input_device *input; struct weston_input_device *input;
switch (event) { switch (event) {
case TTY_ENTER_VT: case TTY_ENTER_VT:
compositor->focus = 1; compositor->focus = 1;
drmSetMaster(ec->drm.fd); drmSetMaster(ec->drm.fd);
compositor->state = ec->prev_state; compositor->state = ec->prev_state;
wlsc_compositor_damage_all(compositor); weston_compositor_damage_all(compositor);
wl_list_for_each(input, &compositor->input_device_list, link) wl_list_for_each(input, &compositor->input_device_list, link)
evdev_add_devices(ec->udev, input); evdev_add_devices(ec->udev, input);
break; break;
case TTY_LEAVE_VT: case TTY_LEAVE_VT:
compositor->focus = 0; compositor->focus = 0;
ec->prev_state = compositor->state; ec->prev_state = compositor->state;
compositor->state = WLSC_COMPOSITOR_SLEEPING; compositor->state = WESTON_COMPOSITOR_SLEEPING;
wl_list_for_each(input, &compositor->input_device_list, link) wl_list_for_each(input, &compositor->input_device_list, link)
evdev_remove_devices(input); evdev_remove_devices(input);
@ -818,7 +818,7 @@ vt_func(struct wlsc_compositor *compositor, int event)
static const char default_seat[] = "seat0"; static const char default_seat[] = "seat0";
static struct wlsc_compositor * static struct weston_compositor *
drm_compositor_create(struct wl_display *display, drm_compositor_create(struct wl_display *display,
int connector, const char *seat, int tty) int connector, const char *seat, int tty)
{ {
@ -878,13 +878,13 @@ drm_compositor_create(struct wl_display *display,
ec->base.focus = 1; ec->base.focus = 1;
ec->prev_state = WLSC_COMPOSITOR_ACTIVE; ec->prev_state = WESTON_COMPOSITOR_ACTIVE;
glGenFramebuffers(1, &ec->base.fbo); glGenFramebuffers(1, &ec->base.fbo);
glBindFramebuffer(GL_FRAMEBUFFER, ec->base.fbo); glBindFramebuffer(GL_FRAMEBUFFER, ec->base.fbo);
/* Can't init base class until we have a current egl context */ /* Can't init base class until we have a current egl context */
if (wlsc_compositor_init(&ec->base, display) < 0) if (weston_compositor_init(&ec->base, display) < 0)
return NULL; return NULL;
if (create_outputs(ec, connector) < 0) { if (create_outputs(ec, connector) < 0) {
@ -923,10 +923,10 @@ drm_compositor_create(struct wl_display *display,
return &ec->base; return &ec->base;
} }
struct wlsc_compositor * struct weston_compositor *
backend_init(struct wl_display *display, char *options); backend_init(struct wl_display *display, char *options);
WL_EXPORT struct wlsc_compositor * WL_EXPORT struct weston_compositor *
backend_init(struct wl_display *display, char *options) backend_init(struct wl_display *display, char *options)
{ {
int connector = 0, i; int connector = 0, i;

@ -43,7 +43,7 @@
#include "compositor.h" #include "compositor.h"
struct wayland_compositor { struct wayland_compositor {
struct wlsc_compositor base; struct weston_compositor base;
struct { struct {
struct wl_display *display; struct wl_display *display;
@ -63,7 +63,7 @@ struct wayland_compositor {
}; };
struct wayland_output { struct wayland_output {
struct wlsc_output base; struct weston_output base;
struct { struct {
struct wl_surface *surface; struct wl_surface *surface;
@ -71,7 +71,7 @@ struct wayland_output {
struct wl_egl_window *egl_window; struct wl_egl_window *egl_window;
} parent; } parent;
EGLSurface egl_surface; EGLSurface egl_surface;
struct wlsc_mode mode; struct weston_mode mode;
}; };
struct wayland_input { struct wayland_input {
@ -83,14 +83,14 @@ struct wayland_input {
static int static int
wayland_input_create(struct wayland_compositor *c) wayland_input_create(struct wayland_compositor *c)
{ {
struct wlsc_input_device *input; struct weston_input_device *input;
input = malloc(sizeof *input); input = malloc(sizeof *input);
if (input == NULL) if (input == NULL)
return -1; return -1;
memset(input, 0, sizeof *input); memset(input, 0, sizeof *input);
wlsc_input_device_init(input, &c->base); weston_input_device_init(input, &c->base);
c->base.input_device = &input->input_device; c->base.input_device = &input->input_device;
@ -162,10 +162,10 @@ wayland_compositor_init_egl(struct wayland_compositor *c)
} }
static int static int
wayland_output_prepare_render(struct wlsc_output *output_base) wayland_output_prepare_render(struct weston_output *output_base)
{ {
struct wayland_output *output = (struct wayland_output *) output_base; struct wayland_output *output = (struct wayland_output *) output_base;
struct wlsc_compositor *ec = output->base.compositor; struct weston_compositor *ec = output->base.compositor;
if (!eglMakeCurrent(ec->display, output->egl_surface, if (!eglMakeCurrent(ec->display, output->egl_surface,
output->egl_surface, ec->context)) { output->egl_surface, ec->context)) {
@ -179,9 +179,9 @@ wayland_output_prepare_render(struct wlsc_output *output_base)
static void static void
frame_done(void *data, struct wl_callback *wl_callback, uint32_t time) frame_done(void *data, struct wl_callback *wl_callback, uint32_t time)
{ {
struct wlsc_output *output = data; struct weston_output *output = data;
wlsc_output_finish_frame(output, time); weston_output_finish_frame(output, time);
} }
static const struct wl_callback_listener frame_listener = { static const struct wl_callback_listener frame_listener = {
@ -189,7 +189,7 @@ static const struct wl_callback_listener frame_listener = {
}; };
static int static int
wayland_output_present(struct wlsc_output *output_base) wayland_output_present(struct weston_output *output_base)
{ {
struct wayland_output *output = (struct wayland_output *) output_base; struct wayland_output *output = (struct wayland_output *) output_base;
struct wayland_compositor *c = struct wayland_compositor *c =
@ -207,24 +207,24 @@ wayland_output_present(struct wlsc_output *output_base)
} }
static int static int
wayland_output_prepare_scanout_surface(struct wlsc_output *output_base, wayland_output_prepare_scanout_surface(struct weston_output *output_base,
struct wlsc_surface *es) struct weston_surface *es)
{ {
return -1; return -1;
} }
static int static int
wayland_output_set_cursor(struct wlsc_output *output_base, wayland_output_set_cursor(struct weston_output *output_base,
struct wlsc_input_device *input) struct weston_input_device *input)
{ {
return -1; return -1;
} }
static void static void
wayland_output_destroy(struct wlsc_output *output_base) wayland_output_destroy(struct weston_output *output_base)
{ {
struct wayland_output *output = (struct wayland_output *) output_base; struct wayland_output *output = (struct wayland_output *) output_base;
struct wlsc_compositor *ec = output->base.compositor; struct weston_compositor *ec = output->base.compositor;
eglDestroySurface(ec->display, output->egl_surface); eglDestroySurface(ec->display, output->egl_surface);
wl_egl_window_destroy(output->parent.egl_window); wl_egl_window_destroy(output->parent.egl_window);
@ -253,7 +253,7 @@ wayland_compositor_create_output(struct wayland_compositor *c,
wl_list_insert(&output->base.mode_list, &output->mode.link); wl_list_insert(&output->base.mode_list, &output->mode.link);
output->base.current = &output->mode; output->base.current = &output->mode;
wlsc_output_init(&output->base, &c->base, 0, 0, width, height, weston_output_init(&output->base, &c->base, 0, 0, width, height,
WL_OUTPUT_FLIPPED); WL_OUTPUT_FLIPPED);
output->parent.surface = output->parent.surface =
@ -306,7 +306,7 @@ cleanup_surface:
cleanup_window: cleanup_window:
wl_egl_window_destroy(output->parent.egl_window); wl_egl_window_destroy(output->parent.egl_window);
cleanup_output: cleanup_output:
/* FIXME: cleanup wlsc_output */ /* FIXME: cleanup weston_output */
free(output); free(output);
return -1; return -1;
@ -499,14 +499,14 @@ wayland_compositor_handle_event(int fd, uint32_t mask, void *data)
} }
static void static void
wayland_destroy(struct wlsc_compositor *ec) wayland_destroy(struct weston_compositor *ec)
{ {
wlsc_compositor_shutdown(ec); weston_compositor_shutdown(ec);
free(ec); free(ec);
} }
static struct wlsc_compositor * static struct weston_compositor *
wayland_compositor_create(struct wl_display *display, int width, int height) wayland_compositor_create(struct wl_display *display, int width, int height)
{ {
struct wayland_compositor *c; struct wayland_compositor *c;
@ -539,7 +539,7 @@ wayland_compositor_create(struct wl_display *display, int width, int height)
c->base.destroy = wayland_destroy; c->base.destroy = wayland_destroy;
/* Can't init base class until we have a current egl context */ /* Can't init base class until we have a current egl context */
if (wlsc_compositor_init(&c->base, display) < 0) if (weston_compositor_init(&c->base, display) < 0)
return NULL; return NULL;
if (wayland_compositor_create_output(c, width, height) < 0) if (wayland_compositor_create_output(c, width, height) < 0)
@ -560,10 +560,10 @@ wayland_compositor_create(struct wl_display *display, int width, int height)
return &c->base; return &c->base;
} }
struct wlsc_compositor * struct weston_compositor *
backend_init(struct wl_display *display, char *options); backend_init(struct wl_display *display, char *options);
WL_EXPORT struct wlsc_compositor * WL_EXPORT struct weston_compositor *
backend_init(struct wl_display *display, char *options) backend_init(struct wl_display *display, char *options)
{ {
int width = 1024, height = 640, i; int width = 1024, height = 640, i;

@ -45,7 +45,7 @@
#include "compositor.h" #include "compositor.h"
struct x11_compositor { struct x11_compositor {
struct wlsc_compositor base; struct weston_compositor base;
Display *dpy; Display *dpy;
xcb_connection_t *conn; xcb_connection_t *conn;
@ -70,16 +70,16 @@ struct x11_compositor {
}; };
struct x11_output { struct x11_output {
struct wlsc_output base; struct weston_output base;
xcb_window_t window; xcb_window_t window;
EGLSurface egl_surface; EGLSurface egl_surface;
struct wlsc_mode mode; struct weston_mode mode;
struct wl_event_source *finish_frame_timer; struct wl_event_source *finish_frame_timer;
}; };
struct x11_input { struct x11_input {
struct wlsc_input_device base; struct weston_input_device base;
}; };
@ -93,7 +93,7 @@ x11_input_create(struct x11_compositor *c)
return -1; return -1;
memset(input, 0, sizeof *input); memset(input, 0, sizeof *input);
wlsc_input_device_init(&input->base, &c->base); weston_input_device_init(&input->base, &c->base);
c->base.input_device = &input->base.input_device; c->base.input_device = &input->base.input_device;
@ -164,10 +164,10 @@ x11_compositor_init_egl(struct x11_compositor *c)
} }
static int static int
x11_output_prepare_render(struct wlsc_output *output_base) x11_output_prepare_render(struct weston_output *output_base)
{ {
struct x11_output *output = (struct x11_output *) output_base; struct x11_output *output = (struct x11_output *) output_base;
struct wlsc_compositor *ec = output->base.compositor; struct weston_compositor *ec = output->base.compositor;
if (!eglMakeCurrent(ec->display, output->egl_surface, if (!eglMakeCurrent(ec->display, output->egl_surface,
output->egl_surface, ec->context)) { output->egl_surface, ec->context)) {
@ -187,16 +187,16 @@ finish_frame_handler(void *data)
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
msec = tv.tv_sec * 1000 + tv.tv_usec / 1000; msec = tv.tv_sec * 1000 + tv.tv_usec / 1000;
wlsc_output_finish_frame(&output->base, msec); weston_output_finish_frame(&output->base, msec);
return 1; return 1;
} }
static int static int
x11_output_present(struct wlsc_output *output_base) x11_output_present(struct weston_output *output_base)
{ {
struct x11_output *output = (struct x11_output *) output_base; struct x11_output *output = (struct x11_output *) output_base;
struct wlsc_compositor *ec = output->base.compositor; struct weston_compositor *ec = output->base.compositor;
if (x11_output_prepare_render(&output->base)) if (x11_output_prepare_render(&output->base))
return -1; return -1;
@ -209,21 +209,21 @@ x11_output_present(struct wlsc_output *output_base)
} }
static int static int
x11_output_prepare_scanout_surface(struct wlsc_output *output_base, x11_output_prepare_scanout_surface(struct weston_output *output_base,
struct wlsc_surface *es) struct weston_surface *es)
{ {
return -1; return -1;
} }
static int static int
x11_output_set_cursor(struct wlsc_output *output_base, x11_output_set_cursor(struct weston_output *output_base,
struct wlsc_input_device *input) struct weston_input_device *input)
{ {
return -1; return -1;
} }
static void static void
x11_output_destroy(struct wlsc_output *output_base) x11_output_destroy(struct weston_output *output_base)
{ {
return; return;
} }
@ -300,7 +300,7 @@ x11_output_set_icon(struct x11_compositor *c,
uint32_t *icon, *pixels, stride; uint32_t *icon, *pixels, stride;
int32_t width, height; int32_t width, height;
pixels = wlsc_load_image(filename, &width, &height, &stride); pixels = weston_load_image(filename, &width, &height, &stride);
if (!pixels) if (!pixels)
return; return;
icon = malloc(width * height * 4 + 8); icon = malloc(width * height * 4 + 8);
@ -360,7 +360,7 @@ x11_compositor_create_output(struct x11_compositor *c, int x, int y,
wl_list_insert(&output->base.mode_list, &output->mode.link); wl_list_insert(&output->base.mode_list, &output->mode.link);
output->base.current = &output->mode; output->base.current = &output->mode;
wlsc_output_init(&output->base, &c->base, x, y, width, height, weston_output_init(&output->base, &c->base, x, y, width, height,
WL_OUTPUT_FLIPPED); WL_OUTPUT_FLIPPED);
values[1] = c->null_cursor; values[1] = c->null_cursor;
@ -482,7 +482,7 @@ x11_compositor_deliver_button_event(struct x11_compositor *c,
} }
notify_button(c->base.input_device, notify_button(c->base.input_device,
wlsc_compositor_get_time(), button, state); weston_compositor_get_time(), button, state);
} }
static int static int
@ -538,7 +538,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
* and fall through and handle the new * and fall through and handle the new
* event below. */ * event below. */
notify_key(c->base.input_device, notify_key(c->base.input_device,
wlsc_compositor_get_time(), weston_compositor_get_time(),
key_release->detail - 8, 0); key_release->detail - 8, 0);
free(prev); free(prev);
prev = NULL; prev = NULL;
@ -561,7 +561,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
output = x11_compositor_find_output(c, focus_in->event); output = x11_compositor_find_output(c, focus_in->event);
notify_keyboard_focus(c->base.input_device, notify_keyboard_focus(c->base.input_device,
wlsc_compositor_get_time(), weston_compositor_get_time(),
&output->base, &c->keys); &output->base, &c->keys);
free(prev); free(prev);
@ -577,7 +577,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
case XCB_KEY_PRESS: case XCB_KEY_PRESS:
key_press = (xcb_key_press_event_t *) event; key_press = (xcb_key_press_event_t *) event;
notify_key(c->base.input_device, notify_key(c->base.input_device,
wlsc_compositor_get_time(), weston_compositor_get_time(),
key_press->detail - 8, 1); key_press->detail - 8, 1);
break; break;
case XCB_KEY_RELEASE: case XCB_KEY_RELEASE:
@ -593,7 +593,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
motion_notify = (xcb_motion_notify_event_t *) event; motion_notify = (xcb_motion_notify_event_t *) event;
output = x11_compositor_find_output(c, motion_notify->event); output = x11_compositor_find_output(c, motion_notify->event);
notify_motion(c->base.input_device, notify_motion(c->base.input_device,
wlsc_compositor_get_time(), weston_compositor_get_time(),
output->base.x + motion_notify->event_x, output->base.x + motion_notify->event_x,
output->base.y + motion_notify->event_y); output->base.y + motion_notify->event_y);
break; break;
@ -602,7 +602,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
/* FIXME: schedule output repaint */ /* FIXME: schedule output repaint */
/* output = x11_compositor_find_output(c, expose->window); */ /* output = x11_compositor_find_output(c, expose->window); */
wlsc_compositor_schedule_repaint(&c->base); weston_compositor_schedule_repaint(&c->base);
break; break;
case XCB_ENTER_NOTIFY: case XCB_ENTER_NOTIFY:
@ -611,7 +611,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
break; break;
output = x11_compositor_find_output(c, enter_notify->event); output = x11_compositor_find_output(c, enter_notify->event);
notify_pointer_focus(c->base.input_device, notify_pointer_focus(c->base.input_device,
wlsc_compositor_get_time(), weston_compositor_get_time(),
&output->base, &output->base,
output->base.x + enter_notify->event_x, output->base.x + enter_notify->event_x,
output->base.y + enter_notify->event_y); output->base.y + enter_notify->event_y);
@ -623,7 +623,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
break; break;
output = x11_compositor_find_output(c, enter_notify->event); output = x11_compositor_find_output(c, enter_notify->event);
notify_pointer_focus(c->base.input_device, notify_pointer_focus(c->base.input_device,
wlsc_compositor_get_time(), weston_compositor_get_time(),
NULL, NULL,
output->base.x + enter_notify->event_x, output->base.x + enter_notify->event_x,
output->base.y + enter_notify->event_y); output->base.y + enter_notify->event_y);
@ -650,7 +650,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
focus_in->mode == XCB_NOTIFY_MODE_UNGRAB) focus_in->mode == XCB_NOTIFY_MODE_UNGRAB)
break; break;
notify_keyboard_focus(c->base.input_device, notify_keyboard_focus(c->base.input_device,
wlsc_compositor_get_time(), weston_compositor_get_time(),
NULL, NULL); NULL, NULL);
break; break;
@ -666,7 +666,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
case XCB_KEY_RELEASE: case XCB_KEY_RELEASE:
key_release = (xcb_key_press_event_t *) prev; key_release = (xcb_key_press_event_t *) prev;
notify_key(c->base.input_device, notify_key(c->base.input_device,
wlsc_compositor_get_time(), weston_compositor_get_time(),
key_release->detail - 8, 0); key_release->detail - 8, 0);
free(prev); free(prev);
prev = NULL; prev = NULL;
@ -730,14 +730,14 @@ x11_compositor_get_resources(struct x11_compositor *c)
} }
static void static void
x11_destroy(struct wlsc_compositor *ec) x11_destroy(struct weston_compositor *ec)
{ {
wlsc_compositor_shutdown(ec); weston_compositor_shutdown(ec);
free(ec); free(ec);
} }
static struct wlsc_compositor * static struct weston_compositor *
x11_compositor_create(struct wl_display *display, x11_compositor_create(struct wl_display *display,
int width, int height, int count, int fullscreen) int width, int height, int count, int fullscreen)
{ {
@ -775,7 +775,7 @@ x11_compositor_create(struct wl_display *display,
c->base.destroy = x11_destroy; c->base.destroy = x11_destroy;
/* Can't init base class until we have a current egl context */ /* Can't init base class until we have a current egl context */
if (wlsc_compositor_init(&c->base, display) < 0) if (weston_compositor_init(&c->base, display) < 0)
return NULL; return NULL;
for (i = 0, x = 0; i < count; i++) { for (i = 0, x = 0; i < count; i++) {
@ -799,10 +799,10 @@ x11_compositor_create(struct wl_display *display,
return &c->base; return &c->base;
} }
struct wlsc_compositor * struct weston_compositor *
backend_init(struct wl_display *display, char *options); backend_init(struct wl_display *display, char *options);
WL_EXPORT struct wlsc_compositor * WL_EXPORT struct weston_compositor *
backend_init(struct wl_display *display, char *options) backend_init(struct wl_display *display, char *options)
{ {
int width = 1024, height = 640, fullscreen = 0, count = 1, i; int width = 1024, height = 640, fullscreen = 0, count = 1, i;

File diff suppressed because it is too large Load Diff

@ -0,0 +1,471 @@
/*
* Copyright © 2008-2011 Kristian Høgsberg
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of the copyright holders not be used in
* advertising or publicity pertaining to distribution of the software
* without specific, written prior permission. The copyright holders make
* no representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _WAYLAND_SYSTEM_COMPOSITOR_H_
#define _WAYLAND_SYSTEM_COMPOSITOR_H_
#include <libudev.h>
#include <pixman.h>
#include <wayland-server.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
struct weston_matrix {
GLfloat d[16];
};
struct weston_vector {
GLfloat f[4];
};
void
weston_matrix_init(struct weston_matrix *matrix);
void
weston_matrix_scale(struct weston_matrix *matrix, GLfloat x, GLfloat y, GLfloat z);
void
weston_matrix_translate(struct weston_matrix *matrix,
GLfloat x, GLfloat y, GLfloat z);
void
weston_matrix_transform(struct weston_matrix *matrix, struct weston_vector *v);
struct weston_transform {
struct weston_matrix matrix;
struct weston_matrix inverse;
};
struct weston_surface;
struct weston_input_device;
struct weston_mode {
uint32_t flags;
int32_t width, height;
uint32_t refresh;
struct wl_list link;
};
struct weston_output {
struct wl_list link;
struct weston_compositor *compositor;
struct weston_matrix matrix;
struct wl_list frame_callback_list;
int32_t x, y, mm_width, mm_height;
pixman_region32_t region;
pixman_region32_t previous_damage;
uint32_t flags;
int repaint_needed;
int repaint_scheduled;
char *make, *model;
uint32_t subpixel;
struct weston_mode *current;
struct wl_list mode_list;
struct wl_buffer *scanout_buffer;
struct wl_listener scanout_buffer_destroy_listener;
struct wl_buffer *pending_scanout_buffer;
struct wl_listener pending_scanout_buffer_destroy_listener;
int (*prepare_render)(struct weston_output *output);
int (*present)(struct weston_output *output);
int (*prepare_scanout_surface)(struct weston_output *output,
struct weston_surface *es);
int (*set_hardware_cursor)(struct weston_output *output,
struct weston_input_device *input);
void (*destroy)(struct weston_output *output);
};
struct weston_input_device {
struct wl_input_device input_device;
struct weston_compositor *compositor;
struct weston_surface *sprite;
int32_t hotspot_x, hotspot_y;
struct wl_list link;
uint32_t modifier_state;
struct wl_selection *selection;
struct wl_list drag_resource_list;
struct weston_data_source *drag_data_source;
struct wl_surface *drag_focus;
struct wl_resource *drag_focus_resource;
struct wl_listener drag_focus_listener;
struct weston_data_source *selection_data_source;
struct wl_listener selection_data_source_listener;
struct wl_grab grab;
uint32_t num_tp;
struct wl_surface *touch_focus;
struct wl_listener touch_focus_listener;
struct wl_resource *touch_focus_resource;
struct wl_listener touch_focus_resource_listener;
};
enum weston_visual {
WESTON_NONE_VISUAL,
WESTON_ARGB_VISUAL,
WESTON_PREMUL_ARGB_VISUAL,
WESTON_RGB_VISUAL
};
struct weston_shader {
GLuint program;
GLuint vertex_shader, fragment_shader;
GLuint proj_uniform;
GLuint tex_uniform;
GLuint alpha_uniform;
GLuint color_uniform;
};
struct weston_animation {
void (*frame)(struct weston_animation *animation,
struct weston_output *output, uint32_t msecs);
struct wl_list link;
};
struct weston_spring {
double k;
double friction;
double current;
double target;
double previous;
uint32_t timestamp;
};
struct weston_shell {
void (*lock)(struct weston_shell *shell);
void (*unlock)(struct weston_shell *shell);
void (*map)(struct weston_shell *shell, struct weston_surface *surface,
int32_t width, int32_t height);
void (*configure)(struct weston_shell *shell,
struct weston_surface *surface,
int32_t x, int32_t y, int32_t width, int32_t height);
};
enum {
WESTON_COMPOSITOR_ACTIVE,
WESTON_COMPOSITOR_IDLE, /* shell->unlock called on activity */
WESTON_COMPOSITOR_SLEEPING /* no rendering, no frame events */
};
struct weston_compositor {
struct wl_shm *shm;
struct weston_xserver *wxs;
EGLDisplay display;
EGLContext context;
EGLConfig config;
GLuint fbo;
GLuint proj_uniform, tex_uniform, alpha_uniform;
uint32_t current_alpha;
struct weston_shader texture_shader;
struct weston_shader solid_shader;
struct wl_display *wl_display;
struct weston_shell *shell;
/* There can be more than one, but not right now... */
struct wl_input_device *input_device;
struct wl_list output_list;
struct wl_list input_device_list;
struct wl_list surface_list;
struct wl_list binding_list;
struct wl_list animation_list;
struct {
struct weston_spring spring;
struct weston_animation animation;
} fade;
uint32_t state;
struct wl_event_source *idle_source;
uint32_t idle_inhibit;
int option_idle_time; /* default timeout, s */
int idle_time; /* effective timeout, s */
/* Repaint state. */
struct timespec previous_swap;
struct wl_array vertices, indices;
struct weston_surface *overlay;
struct weston_switcher *switcher;
uint32_t focus;
PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC
image_target_renderbuffer_storage;
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC image_target_texture_2d;
PFNEGLCREATEIMAGEKHRPROC create_image;
PFNEGLDESTROYIMAGEKHRPROC destroy_image;
PFNEGLBINDWAYLANDDISPLAYWL bind_display;
PFNEGLUNBINDWAYLANDDISPLAYWL unbind_display;
int has_bind_display;
void (*destroy)(struct weston_compositor *ec);
int (*authenticate)(struct weston_compositor *c, uint32_t id);
EGLImageKHR (*create_cursor_image)(struct weston_compositor *c,
int32_t *width, int32_t *height);
};
#define MODIFIER_CTRL (1 << 8)
#define MODIFIER_ALT (1 << 9)
#define MODIFIER_SUPER (1 << 10)
enum weston_output_flags {
WL_OUTPUT_FLIPPED = 0x01
};
struct weston_surface {
struct wl_surface surface;
struct weston_compositor *compositor;
GLuint texture, saved_texture;
pixman_region32_t damage;
pixman_region32_t opaque;
int32_t x, y, width, height;
int32_t pitch;
struct wl_list link;
struct wl_list buffer_link;
struct weston_transform *transform;
uint32_t alpha;
uint32_t visual;
/*
* Which output to vsync this surface to.
* Used to determine, whether to send or queue frame events.
* Must be NULL, if 'link' is not in weston_compositor::surface_list.
*/
struct weston_output *output;
struct weston_output *fullscreen_output;
struct wl_list frame_callback_list;
EGLImageKHR image;
struct wl_buffer *buffer;
struct wl_listener buffer_destroy_listener;
};
struct weston_data_source {
struct wl_resource resource;
struct wl_array mime_types;
int refcount;
void *data;
struct wl_resource *(*create_offer)(struct weston_data_source *source,
struct wl_resource *target);
void (*cancel)(struct weston_data_source *source);
};
void
weston_data_source_unref(struct weston_data_source *source);
void
weston_input_device_set_selection(struct weston_input_device *device,
struct weston_data_source *source,
uint32_t time);
void
weston_spring_init(struct weston_spring *spring,
double k, double current, double target);
void
weston_spring_update(struct weston_spring *spring, uint32_t msec);
int
weston_spring_done(struct weston_spring *spring);
void
weston_surface_activate(struct weston_surface *surface,
struct weston_input_device *device, uint32_t time);
void
notify_motion(struct wl_input_device *device,
uint32_t time, int x, int y);
void
notify_button(struct wl_input_device *device,
uint32_t time, int32_t button, int32_t state);
void
notify_key(struct wl_input_device *device,
uint32_t time, uint32_t key, uint32_t state);
void
notify_pointer_focus(struct wl_input_device *device,
uint32_t time,
struct weston_output *output,
int32_t x, int32_t y);
void
notify_keyboard_focus(struct wl_input_device *device,
uint32_t time, struct weston_output *output,
struct wl_array *keys);
void
notify_touch(struct wl_input_device *device, uint32_t time, int touch_id,
int x, int y, int touch_type);
void
weston_output_finish_frame(struct weston_output *output, int msecs);
void
weston_output_damage(struct weston_output *output);
void
weston_compositor_repick(struct weston_compositor *compositor);
void
weston_compositor_schedule_repaint(struct weston_compositor *compositor);
void
weston_compositor_fade(struct weston_compositor *compositor, float tint);
void
weston_compositor_damage_all(struct weston_compositor *compositor);
void
weston_compositor_unlock(struct weston_compositor *compositor);
void
weston_compositor_wake(struct weston_compositor *compositor);
void
weston_compositor_activity(struct weston_compositor *compositor);
struct weston_binding;
typedef void (*weston_binding_handler_t)(struct wl_input_device *device,
uint32_t time, uint32_t key,
uint32_t button,
uint32_t state, void *data);
struct weston_binding *
weston_compositor_add_binding(struct weston_compositor *compositor,
uint32_t key, uint32_t button, uint32_t modifier,
weston_binding_handler_t binding, void *data);
void
weston_binding_destroy(struct weston_binding *binding);
void
weston_compositor_run_binding(struct weston_compositor *compositor,
struct weston_input_device *device,
uint32_t time,
uint32_t key, uint32_t button, int32_t state);
struct weston_surface *
weston_surface_create(struct weston_compositor *compositor,
int32_t x, int32_t y, int32_t width, int32_t height);
void
weston_surface_configure(struct weston_surface *surface,
int x, int y, int width, int height);
void
weston_surface_assign_output(struct weston_surface *surface);
void
weston_surface_damage(struct weston_surface *surface);
void
weston_surface_damage_below(struct weston_surface *surface);
void
weston_surface_damage_rectangle(struct weston_surface *surface,
int32_t x, int32_t y,
int32_t width, int32_t height);
struct weston_surface *
pick_surface(struct wl_input_device *device, int32_t *sx, int32_t *sy);
uint32_t
weston_compositor_get_time(void);
int
weston_compositor_init(struct weston_compositor *ec, struct wl_display *display);
void
weston_compositor_shutdown(struct weston_compositor *ec);
void
weston_output_move(struct weston_output *output, int x, int y);
void
weston_output_init(struct weston_output *output, struct weston_compositor *c,
int x, int y, int width, int height, uint32_t flags);
void
weston_output_destroy(struct weston_output *output);
void
weston_input_device_init(struct weston_input_device *device,
struct weston_compositor *ec);
void
weston_switcher_init(struct weston_compositor *compositor);
enum {
TTY_ENTER_VT,
TTY_LEAVE_VT
};
typedef void (*tty_vt_func_t)(struct weston_compositor *compositor, int event);
struct tty *
tty_create(struct weston_compositor *compositor,
tty_vt_func_t vt_func, int tty_nr);
void
tty_destroy(struct tty *tty);
void
screenshooter_create(struct weston_compositor *ec);
uint32_t *
weston_load_image(const char *filename,
int32_t *width_arg, int32_t *height_arg,
uint32_t *stride_arg);
struct weston_process;
typedef void (*weston_process_cleanup_func_t)(struct weston_process *process,
int status);
struct weston_process {
pid_t pid;
weston_process_cleanup_func_t cleanup;
struct wl_list link;
};
struct wl_client *
weston_client_launch(struct weston_compositor *compositor,
struct weston_process *proc,
const char *path,
weston_process_cleanup_func_t cleanup);
int
weston_data_device_manager_init(struct weston_compositor *compositor);
void
weston_data_device_set_keyboard_focus(struct weston_input_device *device);
void
weston_watch_process(struct weston_process *process);
int
weston_xserver_init(struct weston_compositor *compositor);
void
weston_xserver_destroy(struct weston_compositor *compositor);
void
weston_xserver_surface_activate(struct weston_surface *surface);
void
weston_xserver_set_selection(struct weston_input_device *device);
struct weston_zoom;
typedef void (*weston_zoom_done_func_t)(struct weston_zoom *zoom, void *data);
struct weston_zoom *
weston_zoom_run(struct weston_surface *surface, GLfloat start, GLfloat stop,
weston_zoom_done_func_t done, void *data);
#endif

@ -28,7 +28,7 @@
#include "compositor.h" #include "compositor.h"
void void
wlsc_data_source_unref(struct wlsc_data_source *source) weston_data_source_unref(struct weston_data_source *source)
{ {
source->refcount--; source->refcount--;
if (source->refcount == 0) if (source->refcount == 0)
@ -39,7 +39,7 @@ static void
data_offer_accept(struct wl_client *client, struct wl_resource *resource, data_offer_accept(struct wl_client *client, struct wl_resource *resource,
uint32_t time, const char *mime_type) uint32_t time, const char *mime_type)
{ {
struct wlsc_data_source *source = resource->data; struct weston_data_source *source = resource->data;
/* FIXME: Check that client is currently focused by the input /* FIXME: Check that client is currently focused by the input
* device that is currently dragging this data source. Should * device that is currently dragging this data source. Should
@ -53,7 +53,7 @@ static void
data_offer_receive(struct wl_client *client, struct wl_resource *resource, data_offer_receive(struct wl_client *client, struct wl_resource *resource,
const char *mime_type, int32_t fd) const char *mime_type, int32_t fd)
{ {
struct wlsc_data_source *source = resource->data; struct weston_data_source *source = resource->data;
wl_resource_post_event(&source->resource, wl_resource_post_event(&source->resource,
WL_DATA_SOURCE_SEND, mime_type, fd); WL_DATA_SOURCE_SEND, mime_type, fd);
@ -63,15 +63,15 @@ data_offer_receive(struct wl_client *client, struct wl_resource *resource,
static void static void
data_offer_destroy(struct wl_client *client, struct wl_resource *resource) data_offer_destroy(struct wl_client *client, struct wl_resource *resource)
{ {
wl_resource_destroy(resource, wlsc_compositor_get_time()); wl_resource_destroy(resource, weston_compositor_get_time());
} }
static void static void
destroy_data_offer(struct wl_resource *resource) destroy_data_offer(struct wl_resource *resource)
{ {
struct wlsc_data_source *source = resource->data; struct weston_data_source *source = resource->data;
wlsc_data_source_unref(source); weston_data_source_unref(source);
free(resource); free(resource);
} }
@ -82,7 +82,7 @@ static const struct wl_data_offer_interface data_offer_interface = {
}; };
static struct wl_resource * static struct wl_resource *
data_source_create_offer(struct wlsc_data_source *source, data_source_create_offer(struct weston_data_source *source,
struct wl_resource *target) struct wl_resource *target)
{ {
struct wl_resource *resource; struct wl_resource *resource;
@ -96,13 +96,13 @@ data_source_create_offer(struct wlsc_data_source *source,
} }
static void static void
data_source_cancel(struct wlsc_data_source *source) data_source_cancel(struct weston_data_source *source)
{ {
wl_resource_post_event(&source->resource, WL_DATA_SOURCE_CANCELLED); wl_resource_post_event(&source->resource, WL_DATA_SOURCE_CANCELLED);
} }
static struct wl_resource * static struct wl_resource *
wlsc_data_source_send_offer(struct wlsc_data_source *source, weston_data_source_send_offer(struct weston_data_source *source,
struct wl_resource *target) struct wl_resource *target)
{ {
struct wl_resource *resource; struct wl_resource *resource;
@ -125,7 +125,7 @@ data_source_offer(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *resource,
const char *type) const char *type)
{ {
struct wlsc_data_source *source = resource->data; struct weston_data_source *source = resource->data;
char **p; char **p;
p = wl_array_add(&source->mime_types, sizeof *p); p = wl_array_add(&source->mime_types, sizeof *p);
@ -138,7 +138,7 @@ data_source_offer(struct wl_client *client,
static void static void
data_source_destroy(struct wl_client *client, struct wl_resource *resource) data_source_destroy(struct wl_client *client, struct wl_resource *resource)
{ {
wl_resource_destroy(resource, wlsc_compositor_get_time()); wl_resource_destroy(resource, weston_compositor_get_time());
} }
static struct wl_data_source_interface data_source_interface = { static struct wl_data_source_interface data_source_interface = {
@ -163,15 +163,15 @@ static void
destroy_drag_focus(struct wl_listener *listener, destroy_drag_focus(struct wl_listener *listener,
struct wl_resource *resource, uint32_t time) struct wl_resource *resource, uint32_t time)
{ {
struct wlsc_input_device *device = struct weston_input_device *device =
container_of(listener, struct wlsc_input_device, container_of(listener, struct weston_input_device,
drag_focus_listener); drag_focus_listener);
device->drag_focus_resource = NULL; device->drag_focus_resource = NULL;
} }
static void static void
drag_set_focus(struct wlsc_input_device *device, drag_set_focus(struct weston_input_device *device,
struct wl_surface *surface, uint32_t time, struct wl_surface *surface, uint32_t time,
int32_t x, int32_t y) int32_t x, int32_t y)
{ {
@ -192,7 +192,7 @@ drag_set_focus(struct wlsc_input_device *device,
resource = find_resource(&device->drag_resource_list, resource = find_resource(&device->drag_resource_list,
surface->resource.client); surface->resource.client);
if (surface && resource) { if (surface && resource) {
offer = wlsc_data_source_send_offer(device->drag_data_source, offer = weston_data_source_send_offer(device->drag_data_source,
resource); resource);
wl_resource_post_event(resource, wl_resource_post_event(resource,
@ -211,9 +211,9 @@ static void
drag_grab_motion(struct wl_grab *grab, drag_grab_motion(struct wl_grab *grab,
uint32_t time, int32_t x, int32_t y) uint32_t time, int32_t x, int32_t y)
{ {
struct wlsc_input_device *device = struct weston_input_device *device =
container_of(grab, struct wlsc_input_device, grab); container_of(grab, struct weston_input_device, grab);
struct wlsc_surface *es; struct weston_surface *es;
es = pick_surface(&device->input_device, &x, &y); es = pick_surface(&device->input_device, &x, &y);
drag_set_focus(device, &es->surface, time, x, y); drag_set_focus(device, &es->surface, time, x, y);
@ -232,15 +232,15 @@ drag_grab_button(struct wl_grab *grab,
static void static void
drag_grab_end(struct wl_grab *grab, uint32_t time) drag_grab_end(struct wl_grab *grab, uint32_t time)
{ {
struct wlsc_input_device *device = struct weston_input_device *device =
container_of(grab, struct wlsc_input_device, grab); container_of(grab, struct weston_input_device, grab);
if (device->drag_focus_resource) if (device->drag_focus_resource)
wl_resource_post_event(device->drag_focus_resource, wl_resource_post_event(device->drag_focus_resource,
WL_DATA_DEVICE_DROP); WL_DATA_DEVICE_DROP);
drag_set_focus(device, NULL, time, 0, 0); drag_set_focus(device, NULL, time, 0, 0);
wlsc_data_source_unref(device->drag_data_source); weston_data_source_unref(device->drag_data_source);
device->drag_data_source = NULL; device->drag_data_source = NULL;
} }
@ -255,9 +255,9 @@ data_device_start_drag(struct wl_client *client, struct wl_resource *resource,
struct wl_resource *source_resource, struct wl_resource *source_resource,
struct wl_resource *surface_resource, uint32_t time) struct wl_resource *surface_resource, uint32_t time)
{ {
struct wlsc_input_device *device = resource->data; struct weston_input_device *device = resource->data;
struct wlsc_surface *surface = surface_resource->data; struct weston_surface *surface = surface_resource->data;
struct wlsc_surface *target; struct weston_surface *target;
int32_t sx, sy; int32_t sx, sy;
/* FIXME: Check that client has implicit grab on the surface /* FIXME: Check that client has implicit grab on the surface
@ -290,8 +290,8 @@ static void
destroy_selection_data_source(struct wl_listener *listener, destroy_selection_data_source(struct wl_listener *listener,
struct wl_resource *resource, uint32_t time) struct wl_resource *resource, uint32_t time)
{ {
struct wlsc_input_device *device = struct weston_input_device *device =
container_of(listener, struct wlsc_input_device, container_of(listener, struct weston_input_device,
selection_data_source_listener); selection_data_source_listener);
struct wl_resource *data_device, *focus; struct wl_resource *data_device, *focus;
@ -307,8 +307,8 @@ destroy_selection_data_source(struct wl_listener *listener,
} }
void void
wlsc_input_device_set_selection(struct wlsc_input_device *device, weston_input_device_set_selection(struct weston_input_device *device,
struct wlsc_data_source *source, uint32_t time) struct weston_data_source *source, uint32_t time)
{ {
struct wl_resource *data_device, *focus, *offer; struct wl_resource *data_device, *focus, *offer;
@ -319,7 +319,7 @@ wlsc_input_device_set_selection(struct wlsc_input_device *device,
* won't get destroyed until every client has been * won't get destroyed until every client has been
* activated and seen the new selection event. */ * activated and seen the new selection event. */
wl_list_remove(&device->selection_data_source_listener.link); wl_list_remove(&device->selection_data_source_listener.link);
wlsc_data_source_unref(device->selection_data_source); weston_data_source_unref(device->selection_data_source);
device->selection_data_source = NULL; device->selection_data_source = NULL;
} }
@ -331,7 +331,7 @@ wlsc_input_device_set_selection(struct wlsc_input_device *device,
data_device = find_resource(&device->drag_resource_list, data_device = find_resource(&device->drag_resource_list,
focus->client); focus->client);
if (data_device) { if (data_device) {
offer = wlsc_data_source_send_offer(device->selection_data_source, offer = weston_data_source_send_offer(device->selection_data_source,
data_device); data_device);
wl_resource_post_event(data_device, wl_resource_post_event(data_device,
WL_DATA_DEVICE_SELECTION, WL_DATA_DEVICE_SELECTION,
@ -339,7 +339,7 @@ wlsc_input_device_set_selection(struct wlsc_input_device *device,
} }
} }
wlsc_xserver_set_selection(device); weston_xserver_set_selection(device);
device->selection_data_source_listener.func = device->selection_data_source_listener.func =
destroy_selection_data_source; destroy_selection_data_source;
@ -355,7 +355,7 @@ data_device_set_selection(struct wl_client *client,
if (!source_resource) if (!source_resource)
return; return;
wlsc_input_device_set_selection(resource->data, weston_input_device_set_selection(resource->data,
source_resource->data, time); source_resource->data, time);
} }
@ -368,8 +368,8 @@ static const struct wl_data_device_interface data_device_interface = {
static void static void
destroy_data_source(struct wl_resource *resource) destroy_data_source(struct wl_resource *resource)
{ {
struct wlsc_data_source *source = struct weston_data_source *source =
container_of(resource, struct wlsc_data_source, resource); container_of(resource, struct weston_data_source, resource);
char **p, **end; char **p, **end;
end = source->mime_types.data + source->mime_types.size; end = source->mime_types.data + source->mime_types.size;
@ -379,14 +379,14 @@ destroy_data_source(struct wl_resource *resource)
wl_array_release(&source->mime_types); wl_array_release(&source->mime_types);
source->resource.object.id = 0; source->resource.object.id = 0;
wlsc_data_source_unref(source); weston_data_source_unref(source);
} }
static void static void
create_data_source(struct wl_client *client, create_data_source(struct wl_client *client,
struct wl_resource *resource, uint32_t id) struct wl_resource *resource, uint32_t id)
{ {
struct wlsc_data_source *source; struct weston_data_source *source;
source = malloc(sizeof *source); source = malloc(sizeof *source);
if (source == NULL) { if (source == NULL) {
@ -419,7 +419,7 @@ get_data_device(struct wl_client *client,
struct wl_resource *manager_resource, struct wl_resource *manager_resource,
uint32_t id, struct wl_resource *input_device) uint32_t id, struct wl_resource *input_device)
{ {
struct wlsc_input_device *device = input_device->data; struct weston_input_device *device = input_device->data;
struct wl_resource *resource; struct wl_resource *resource;
resource = resource =
@ -444,10 +444,10 @@ bind_manager(struct wl_client *client,
} }
WL_EXPORT void WL_EXPORT void
wlsc_data_device_set_keyboard_focus(struct wlsc_input_device *device) weston_data_device_set_keyboard_focus(struct weston_input_device *device)
{ {
struct wl_resource *data_device, *focus, *offer; struct wl_resource *data_device, *focus, *offer;
struct wlsc_data_source *source; struct weston_data_source *source;
focus = device->input_device.keyboard_focus_resource; focus = device->input_device.keyboard_focus_resource;
if (!focus) if (!focus)
@ -460,14 +460,14 @@ wlsc_data_device_set_keyboard_focus(struct wlsc_input_device *device)
source = device->selection_data_source; source = device->selection_data_source;
if (source) { if (source) {
offer = wlsc_data_source_send_offer(source, data_device); offer = weston_data_source_send_offer(source, data_device);
wl_resource_post_event(data_device, wl_resource_post_event(data_device,
WL_DATA_DEVICE_SELECTION, offer); WL_DATA_DEVICE_SELECTION, offer);
} }
} }
WL_EXPORT int WL_EXPORT int
wlsc_data_device_manager_init(struct wlsc_compositor *compositor) weston_data_device_manager_init(struct weston_compositor *compositor)
{ {
if (wl_display_add_global(compositor->wl_display, if (wl_display_add_global(compositor->wl_display,
&wl_data_device_manager_interface, &wl_data_device_manager_interface,

@ -31,7 +31,7 @@
#include "evdev.h" #include "evdev.h"
struct evdev_input { struct evdev_input {
struct wlsc_input_device base; struct weston_input_device base;
struct wl_list devices_list; struct wl_list devices_list;
struct udev_monitor *udev_monitor; struct udev_monitor *udev_monitor;
char *seat_id; char *seat_id;
@ -43,7 +43,7 @@ struct evdev_input_device {
struct evdev_input *master; struct evdev_input *master;
struct wl_list link; struct wl_list link;
struct wl_event_source *source; struct wl_event_source *source;
struct wlsc_output *output; struct weston_output *output;
char *devnode; char *devnode;
int fd; int fd;
struct { struct {
@ -324,7 +324,7 @@ evdev_flush_motion(struct evdev_input_device *device, uint32_t time)
static int static int
evdev_input_device_data(int fd, uint32_t mask, void *data) evdev_input_device_data(int fd, uint32_t mask, void *data)
{ {
struct wlsc_compositor *ec; struct weston_compositor *ec;
struct evdev_input_device *device = data; struct evdev_input_device *device = data;
struct input_event ev[8], *e, *end; struct input_event ev[8], *e, *end;
int len; int len;
@ -436,7 +436,7 @@ evdev_input_device_create(struct evdev_input *master,
{ {
struct evdev_input_device *device; struct evdev_input_device *device;
struct wl_event_loop *loop; struct wl_event_loop *loop;
struct wlsc_compositor *ec; struct weston_compositor *ec;
device = malloc(sizeof *device); device = malloc(sizeof *device);
if (device == NULL) if (device == NULL)
@ -444,7 +444,7 @@ evdev_input_device_create(struct evdev_input *master,
ec = master->base.compositor; ec = master->base.compositor;
device->output = device->output =
container_of(ec->output_list.next, struct wlsc_output, link); container_of(ec->output_list.next, struct weston_output, link);
device->master = master; device->master = master;
device->is_touchpad = 0; device->is_touchpad = 0;
@ -485,7 +485,7 @@ static const char default_seat[] = "seat0";
static void static void
device_added(struct udev_device *udev_device, struct evdev_input *master) device_added(struct udev_device *udev_device, struct evdev_input *master)
{ {
struct wlsc_compositor *c; struct weston_compositor *c;
const char *devnode; const char *devnode;
const char *device_seat; const char *device_seat;
@ -522,7 +522,7 @@ device_removed(struct udev_device *udev_device, struct evdev_input *master)
} }
void void
evdev_add_devices(struct udev *udev, struct wlsc_input_device *input_base) evdev_add_devices(struct udev *udev, struct weston_input_device *input_base)
{ {
struct evdev_input *input = (struct evdev_input *) input_base; struct evdev_input *input = (struct evdev_input *) input_base;
struct udev_enumerate *e; struct udev_enumerate *e;
@ -578,7 +578,7 @@ static int
evdev_config_udev_monitor(struct udev *udev, struct evdev_input *master) evdev_config_udev_monitor(struct udev *udev, struct evdev_input *master)
{ {
struct wl_event_loop *loop; struct wl_event_loop *loop;
struct wlsc_compositor *c = master->base.compositor; struct weston_compositor *c = master->base.compositor;
master->udev_monitor = udev_monitor_new_from_netlink(udev, "udev"); master->udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
if (!master->udev_monitor) if (!master->udev_monitor)
@ -600,7 +600,7 @@ evdev_config_udev_monitor(struct udev *udev, struct evdev_input *master)
} }
void void
evdev_input_create(struct wlsc_compositor *c, struct udev *udev, evdev_input_create(struct weston_compositor *c, struct udev *udev,
const char *seat) const char *seat)
{ {
struct evdev_input *input; struct evdev_input *input;
@ -610,7 +610,7 @@ evdev_input_create(struct wlsc_compositor *c, struct udev *udev,
return; return;
memset(input, 0, sizeof *input); memset(input, 0, sizeof *input);
wlsc_input_device_init(&input->base, c); weston_input_device_init(&input->base, c);
wl_list_init(&input->devices_list); wl_list_init(&input->devices_list);
input->seat_id = strdup(seat); input->seat_id = strdup(seat);
@ -626,7 +626,7 @@ evdev_input_create(struct wlsc_compositor *c, struct udev *udev,
} }
void void
evdev_remove_devices(struct wlsc_input_device *input_base) evdev_remove_devices(struct weston_input_device *input_base)
{ {
struct evdev_input *input = (struct evdev_input *) input_base; struct evdev_input *input = (struct evdev_input *) input_base;
struct evdev_input_device *device, *next; struct evdev_input_device *device, *next;
@ -642,7 +642,7 @@ evdev_remove_devices(struct wlsc_input_device *input_base)
} }
void void
evdev_input_destroy(struct wlsc_input_device *input_base) evdev_input_destroy(struct weston_input_device *input_base)
{ {
struct evdev_input *input = (struct evdev_input *) input_base; struct evdev_input *input = (struct evdev_input *) input_base;

@ -21,15 +21,15 @@
*/ */
void void
evdev_add_devices(struct udev *udev, struct wlsc_input_device evdev_add_devices(struct udev *udev, struct weston_input_device
*input_base); *input_base);
void void
evdev_remove_devices(struct wlsc_input_device *input_base); evdev_remove_devices(struct weston_input_device *input_base);
void void
evdev_input_create(struct wlsc_compositor *c, struct udev *udev, evdev_input_create(struct weston_compositor *c, struct udev *udev,
const char *seat); const char *seat);
void void
evdev_input_destroy(struct wlsc_input_device *input_base); evdev_input_destroy(struct weston_input_device *input_base);

@ -27,7 +27,7 @@
struct screenshooter { struct screenshooter {
struct wl_object base; struct wl_object base;
struct wlsc_compositor *ec; struct weston_compositor *ec;
}; };
static void static void
@ -36,7 +36,7 @@ screenshooter_shoot(struct wl_client *client,
struct wl_resource *output_resource, struct wl_resource *output_resource,
struct wl_resource *buffer_resource) struct wl_resource *buffer_resource)
{ {
struct wlsc_output *output = output_resource->data; struct weston_output *output = output_resource->data;
struct wl_buffer *buffer = buffer_resource->data; struct wl_buffer *buffer = buffer_resource->data;
if (!wl_buffer_is_shm(buffer)) if (!wl_buffer_is_shm(buffer))
@ -65,7 +65,7 @@ bind_shooter(struct wl_client *client,
} }
void void
screenshooter_create(struct wlsc_compositor *ec) screenshooter_create(struct weston_compositor *ec)
{ {
struct screenshooter *shooter; struct screenshooter *shooter;

@ -38,11 +38,11 @@
struct shell_surface; struct shell_surface;
struct wl_shell { struct wl_shell {
struct wlsc_compositor *compositor; struct weston_compositor *compositor;
struct wlsc_shell shell; struct weston_shell shell;
struct { struct {
struct wlsc_process process; struct weston_process process;
struct wl_client *client; struct wl_client *client;
struct wl_resource *desktop_shell; struct wl_resource *desktop_shell;
} child; } child;
@ -62,7 +62,7 @@ struct wl_shell {
int duration; int duration;
struct wl_resource *binding; struct wl_resource *binding;
struct wl_list surfaces; struct wl_list surfaces;
struct wlsc_process process; struct weston_process process;
} screensaver; } screensaver;
}; };
@ -82,19 +82,19 @@ enum shell_surface_type {
struct shell_surface { struct shell_surface {
struct wl_resource resource; struct wl_resource resource;
struct wlsc_surface *surface; struct weston_surface *surface;
struct wl_listener surface_destroy_listener; struct wl_listener surface_destroy_listener;
enum shell_surface_type type; enum shell_surface_type type;
int32_t saved_x, saved_y; int32_t saved_x, saved_y;
struct wlsc_output *output; struct weston_output *output;
struct wl_list link; struct wl_list link;
}; };
struct wlsc_move_grab { struct weston_move_grab {
struct wl_grab grab; struct wl_grab grab;
struct wlsc_surface *surface; struct weston_surface *surface;
int32_t dx, dy; int32_t dx, dy;
}; };
@ -130,10 +130,10 @@ static void
move_grab_motion(struct wl_grab *grab, move_grab_motion(struct wl_grab *grab,
uint32_t time, int32_t x, int32_t y) uint32_t time, int32_t x, int32_t y)
{ {
struct wlsc_move_grab *move = (struct wlsc_move_grab *) grab; struct weston_move_grab *move = (struct weston_move_grab *) grab;
struct wlsc_surface *es = move->surface; struct weston_surface *es = move->surface;
wlsc_surface_configure(es, x + move->dx, y + move->dy, weston_surface_configure(es, x + move->dx, y + move->dy,
es->width, es->height); es->width, es->height);
} }
@ -156,10 +156,10 @@ static const struct wl_grab_interface move_grab_interface = {
}; };
static int static int
wlsc_surface_move(struct wlsc_surface *es, weston_surface_move(struct weston_surface *es,
struct wlsc_input_device *wd, uint32_t time) struct weston_input_device *wd, uint32_t time)
{ {
struct wlsc_move_grab *move; struct weston_move_grab *move;
move = malloc(sizeof *move); move = malloc(sizeof *move);
if (!move) if (!move)
@ -184,14 +184,14 @@ static void
shell_surface_move(struct wl_client *client, struct wl_resource *resource, shell_surface_move(struct wl_client *client, struct wl_resource *resource,
struct wl_resource *input_resource, uint32_t time) struct wl_resource *input_resource, uint32_t time)
{ {
struct wlsc_input_device *wd = input_resource->data; struct weston_input_device *wd = input_resource->data;
struct shell_surface *shsurf = resource->data; struct shell_surface *shsurf = resource->data;
if (wlsc_surface_move(shsurf->surface, wd, time) < 0) if (weston_surface_move(shsurf->surface, wd, time) < 0)
wl_resource_post_no_memory(resource); wl_resource_post_no_memory(resource);
} }
struct wlsc_resize_grab { struct weston_resize_grab {
struct wl_grab grab; struct wl_grab grab;
uint32_t edges; uint32_t edges;
int32_t dx, dy, width, height; int32_t dx, dy, width, height;
@ -202,7 +202,7 @@ static void
resize_grab_motion(struct wl_grab *grab, resize_grab_motion(struct wl_grab *grab,
uint32_t time, int32_t x, int32_t y) uint32_t time, int32_t x, int32_t y)
{ {
struct wlsc_resize_grab *resize = (struct wlsc_resize_grab *) grab; struct weston_resize_grab *resize = (struct weston_resize_grab *) grab;
struct wl_input_device *device = grab->input_device; struct wl_input_device *device = grab->input_device;
int32_t width, height; int32_t width, height;
@ -246,12 +246,12 @@ static const struct wl_grab_interface resize_grab_interface = {
}; };
static int static int
wlsc_surface_resize(struct shell_surface *shsurf, weston_surface_resize(struct shell_surface *shsurf,
struct wlsc_input_device *wd, struct weston_input_device *wd,
uint32_t time, uint32_t edges) uint32_t time, uint32_t edges)
{ {
struct wlsc_resize_grab *resize; struct weston_resize_grab *resize;
struct wlsc_surface *es = shsurf->surface; struct weston_surface *es = shsurf->surface;
/* FIXME: Reject if fullscreen */ /* FIXME: Reject if fullscreen */
@ -286,12 +286,12 @@ shell_surface_resize(struct wl_client *client, struct wl_resource *resource,
struct wl_resource *input_resource, uint32_t time, struct wl_resource *input_resource, uint32_t time,
uint32_t edges) uint32_t edges)
{ {
struct wlsc_input_device *wd = input_resource->data; struct weston_input_device *wd = input_resource->data;
struct shell_surface *shsurf = resource->data; struct shell_surface *shsurf = resource->data;
/* FIXME: Reject if fullscreen */ /* FIXME: Reject if fullscreen */
if (wlsc_surface_resize(shsurf, wd, time, edges) < 0) if (weston_surface_resize(shsurf, wd, time, edges) < 0)
wl_resource_post_no_memory(resource); wl_resource_post_no_memory(resource);
} }
@ -335,7 +335,7 @@ shell_surface_set_toplevel(struct wl_client *client,
if (reset_shell_surface_type(surface)) if (reset_shell_surface_type(surface))
return; return;
wlsc_surface_damage(surface->surface); weston_surface_damage(surface->surface);
surface->type = SHELL_SURFACE_TOPLEVEL; surface->type = SHELL_SURFACE_TOPLEVEL;
} }
@ -346,9 +346,9 @@ shell_surface_set_transient(struct wl_client *client,
int x, int y, uint32_t flags) int x, int y, uint32_t flags)
{ {
struct shell_surface *shsurf = resource->data; struct shell_surface *shsurf = resource->data;
struct wlsc_surface *es = shsurf->surface; struct weston_surface *es = shsurf->surface;
struct shell_surface *pshsurf = parent_resource->data; struct shell_surface *pshsurf = parent_resource->data;
struct wlsc_surface *pes = pshsurf->surface; struct weston_surface *pes = pshsurf->surface;
if (reset_shell_surface_type(shsurf)) if (reset_shell_surface_type(shsurf))
return; return;
@ -359,15 +359,15 @@ shell_surface_set_transient(struct wl_client *client,
es->x = pes->x + x; es->x = pes->x + x;
es->y = pes->y + y; es->y = pes->y + y;
wlsc_surface_damage(es); weston_surface_damage(es);
shsurf->type = SHELL_SURFACE_TRANSIENT; shsurf->type = SHELL_SURFACE_TRANSIENT;
} }
static struct wlsc_output * static struct weston_output *
get_default_output(struct wlsc_compositor *compositor) get_default_output(struct weston_compositor *compositor)
{ {
return container_of(compositor->output_list.next, return container_of(compositor->output_list.next,
struct wlsc_output, link); struct weston_output, link);
} }
static void static void
@ -376,8 +376,8 @@ shell_surface_set_fullscreen(struct wl_client *client,
{ {
struct shell_surface *shsurf = resource->data; struct shell_surface *shsurf = resource->data;
struct wlsc_surface *es = shsurf->surface; struct weston_surface *es = shsurf->surface;
struct wlsc_output *output; struct weston_output *output;
if (reset_shell_surface_type(shsurf)) if (reset_shell_surface_type(shsurf))
return; return;
@ -392,7 +392,7 @@ shell_surface_set_fullscreen(struct wl_client *client,
es->x = (output->current->width - es->width) / 2; es->x = (output->current->width - es->width) / 2;
es->y = (output->current->height - es->height) / 2; es->y = (output->current->height - es->height) / 2;
es->fullscreen_output = output; es->fullscreen_output = output;
wlsc_surface_damage(es); weston_surface_damage(es);
shsurf->type = SHELL_SURFACE_FULLSCREEN; shsurf->type = SHELL_SURFACE_FULLSCREEN;
} }
@ -430,7 +430,7 @@ shell_handle_surface_destroy(struct wl_listener *listener,
} }
static struct shell_surface * static struct shell_surface *
get_shell_surface(struct wlsc_surface *surface) get_shell_surface(struct weston_surface *surface)
{ {
struct wl_list *lst = &surface->surface.resource.destroy_listener_list; struct wl_list *lst = &surface->surface.resource.destroy_listener_list;
struct wl_listener *listener; struct wl_listener *listener;
@ -452,7 +452,7 @@ shell_get_shell_surface(struct wl_client *client,
uint32_t id, uint32_t id,
struct wl_resource *surface_resource) struct wl_resource *surface_resource)
{ {
struct wlsc_surface *surface = surface_resource->data; struct weston_surface *surface = surface_resource->data;
struct shell_surface *shsurf; struct shell_surface *shsurf;
if (get_shell_surface(surface)) { if (get_shell_surface(surface)) {
@ -493,7 +493,7 @@ static const struct wl_shell_interface shell_implementation = {
}; };
static void static void
handle_screensaver_sigchld(struct wlsc_process *proc, int status) handle_screensaver_sigchld(struct weston_process *proc, int status)
{ {
proc->pid = 0; proc->pid = 0;
} }
@ -507,7 +507,7 @@ launch_screensaver(struct wl_shell *shell)
if (!shell->screensaver.path) if (!shell->screensaver.path)
return; return;
wlsc_client_launch(shell->compositor, weston_client_launch(shell->compositor,
&shell->screensaver.process, &shell->screensaver.process,
shell->screensaver.path, shell->screensaver.path,
handle_screensaver_sigchld); handle_screensaver_sigchld);
@ -534,7 +534,7 @@ show_screensaver(struct wl_shell *shell, struct shell_surface *surface)
wl_list_remove(&surface->surface->link); wl_list_remove(&surface->surface->link);
wl_list_insert(list, &surface->surface->link); wl_list_insert(list, &surface->surface->link);
wlsc_surface_configure(surface->surface, weston_surface_configure(surface->surface,
surface->surface->x, surface->surface->x,
surface->surface->y, surface->surface->y,
surface->surface->width, surface->surface->width,
@ -558,7 +558,7 @@ desktop_shell_set_background(struct wl_client *client,
{ {
struct wl_shell *shell = resource->data; struct wl_shell *shell = resource->data;
struct shell_surface *shsurf = surface_resource->data; struct shell_surface *shsurf = surface_resource->data;
struct wlsc_surface *surface = shsurf->surface; struct weston_surface *surface = shsurf->surface;
struct shell_surface *priv; struct shell_surface *priv;
if (reset_shell_surface_type(shsurf)) if (reset_shell_surface_type(shsurf))
@ -583,7 +583,7 @@ desktop_shell_set_background(struct wl_client *client,
wl_resource_post_event(resource, wl_resource_post_event(resource,
DESKTOP_SHELL_CONFIGURE, DESKTOP_SHELL_CONFIGURE,
wlsc_compositor_get_time(), 0, surface_resource, weston_compositor_get_time(), 0, surface_resource,
shsurf->output->current->width, shsurf->output->current->width,
shsurf->output->current->height); shsurf->output->current->height);
} }
@ -596,7 +596,7 @@ desktop_shell_set_panel(struct wl_client *client,
{ {
struct wl_shell *shell = resource->data; struct wl_shell *shell = resource->data;
struct shell_surface *shsurf = surface_resource->data; struct shell_surface *shsurf = surface_resource->data;
struct wlsc_surface *surface = shsurf->surface; struct weston_surface *surface = shsurf->surface;
struct shell_surface *priv; struct shell_surface *priv;
if (reset_shell_surface_type(shsurf)) if (reset_shell_surface_type(shsurf))
@ -621,7 +621,7 @@ desktop_shell_set_panel(struct wl_client *client,
wl_resource_post_event(resource, wl_resource_post_event(resource,
DESKTOP_SHELL_CONFIGURE, DESKTOP_SHELL_CONFIGURE,
wlsc_compositor_get_time(), 0, surface_resource, weston_compositor_get_time(), 0, surface_resource,
shsurf->output->current->width, shsurf->output->current->width,
shsurf->output->current->height); shsurf->output->current->height);
} }
@ -665,7 +665,7 @@ desktop_shell_set_lock_surface(struct wl_client *client,
static void static void
resume_desktop(struct wl_shell *shell) resume_desktop(struct wl_shell *shell)
{ {
struct wlsc_surface *surface; struct weston_surface *surface;
struct wl_list *list; struct wl_list *list;
struct shell_surface *tmp; struct shell_surface *tmp;
@ -675,7 +675,7 @@ resume_desktop(struct wl_shell *shell)
terminate_screensaver(shell); terminate_screensaver(shell);
wl_list_for_each(surface, &shell->hidden_surface_list, link) wl_list_for_each(surface, &shell->hidden_surface_list, link)
wlsc_surface_configure(surface, surface->x, surface->y, weston_surface_configure(surface, surface->x, surface->y,
surface->width, surface->height); surface->width, surface->height);
if (wl_list_empty(&shell->backgrounds)) { if (wl_list_empty(&shell->backgrounds)) {
@ -692,9 +692,9 @@ resume_desktop(struct wl_shell *shell)
wl_list_init(&shell->hidden_surface_list); wl_list_init(&shell->hidden_surface_list);
shell->locked = false; shell->locked = false;
wlsc_compositor_repick(shell->compositor); weston_compositor_repick(shell->compositor);
shell->compositor->idle_time = shell->compositor->option_idle_time; shell->compositor->idle_time = shell->compositor->option_idle_time;
wlsc_compositor_wake(shell->compositor); weston_compositor_wake(shell->compositor);
} }
static void static void
@ -717,7 +717,7 @@ static const struct desktop_shell_interface desktop_shell_implementation = {
}; };
static enum shell_surface_type static enum shell_surface_type
get_shell_surface_type(struct wlsc_surface *surface) get_shell_surface_type(struct weston_surface *surface)
{ {
struct shell_surface *shsurf; struct shell_surface *shsurf;
@ -731,8 +731,8 @@ static void
move_binding(struct wl_input_device *device, uint32_t time, move_binding(struct wl_input_device *device, uint32_t time,
uint32_t key, uint32_t button, uint32_t state, void *data) uint32_t key, uint32_t button, uint32_t state, void *data)
{ {
struct wlsc_surface *surface = struct weston_surface *surface =
(struct wlsc_surface *) device->pointer_focus; (struct weston_surface *) device->pointer_focus;
if (surface == NULL) if (surface == NULL)
return; return;
@ -747,15 +747,15 @@ move_binding(struct wl_input_device *device, uint32_t time,
break; break;
} }
wlsc_surface_move(surface, (struct wlsc_input_device *) device, time); weston_surface_move(surface, (struct weston_input_device *) device, time);
} }
static void static void
resize_binding(struct wl_input_device *device, uint32_t time, resize_binding(struct wl_input_device *device, uint32_t time,
uint32_t key, uint32_t button, uint32_t state, void *data) uint32_t key, uint32_t button, uint32_t state, void *data)
{ {
struct wlsc_surface *surface = struct weston_surface *surface =
(struct wlsc_surface *) device->pointer_focus; (struct weston_surface *) device->pointer_focus;
uint32_t edges = 0; uint32_t edges = 0;
int32_t x, y; int32_t x, y;
struct shell_surface *shsurf; struct shell_surface *shsurf;
@ -794,7 +794,7 @@ resize_binding(struct wl_input_device *device, uint32_t time,
else else
edges |= WL_SHELL_SURFACE_RESIZE_BOTTOM; edges |= WL_SHELL_SURFACE_RESIZE_BOTTOM;
wlsc_surface_resize(shsurf, (struct wlsc_input_device *) device, weston_surface_resize(shsurf, (struct weston_input_device *) device,
time, edges); time, edges);
} }
@ -802,23 +802,23 @@ static void
terminate_binding(struct wl_input_device *device, uint32_t time, terminate_binding(struct wl_input_device *device, uint32_t time,
uint32_t key, uint32_t button, uint32_t state, void *data) uint32_t key, uint32_t button, uint32_t state, void *data)
{ {
struct wlsc_compositor *compositor = data; struct weston_compositor *compositor = data;
if (state) if (state)
wl_display_terminate(compositor->wl_display); wl_display_terminate(compositor->wl_display);
} }
static void static void
activate(struct wlsc_shell *base, struct wlsc_surface *es, activate(struct weston_shell *base, struct weston_surface *es,
struct wlsc_input_device *device, uint32_t time) struct weston_input_device *device, uint32_t time)
{ {
struct wl_shell *shell = container_of(base, struct wl_shell, shell); struct wl_shell *shell = container_of(base, struct wl_shell, shell);
struct wlsc_compositor *compositor = shell->compositor; struct weston_compositor *compositor = shell->compositor;
wlsc_surface_activate(es, device, time); weston_surface_activate(es, device, time);
if (compositor->wxs) if (compositor->wxs)
wlsc_xserver_surface_activate(es); weston_xserver_surface_activate(es);
switch (get_shell_surface_type(es)) { switch (get_shell_surface_type(es)) {
case SHELL_SURFACE_BACKGROUND: case SHELL_SURFACE_BACKGROUND:
@ -855,23 +855,23 @@ click_to_activate_binding(struct wl_input_device *device,
uint32_t time, uint32_t key, uint32_t time, uint32_t key,
uint32_t button, uint32_t state, void *data) uint32_t button, uint32_t state, void *data)
{ {
struct wlsc_input_device *wd = (struct wlsc_input_device *) device; struct weston_input_device *wd = (struct weston_input_device *) device;
struct wlsc_compositor *compositor = data; struct weston_compositor *compositor = data;
struct wlsc_surface *focus; struct weston_surface *focus;
focus = (struct wlsc_surface *) device->pointer_focus; focus = (struct weston_surface *) device->pointer_focus;
if (state && focus && device->grab == NULL) if (state && focus && device->grab == NULL)
activate(compositor->shell, focus, wd, time); activate(compositor->shell, focus, wd, time);
} }
static void static void
lock(struct wlsc_shell *base) lock(struct weston_shell *base)
{ {
struct wl_shell *shell = container_of(base, struct wl_shell, shell); struct wl_shell *shell = container_of(base, struct wl_shell, shell);
struct wl_list *surface_list = &shell->compositor->surface_list; struct wl_list *surface_list = &shell->compositor->surface_list;
struct wlsc_surface *cur; struct weston_surface *cur;
struct wlsc_surface *tmp; struct weston_surface *tmp;
struct wlsc_input_device *device; struct weston_input_device *device;
struct shell_surface *shsurf; struct shell_surface *shsurf;
uint32_t time; uint32_t time;
@ -910,15 +910,15 @@ lock(struct wlsc_shell *base)
if (!wl_list_empty(&shell->screensaver.surfaces)) { if (!wl_list_empty(&shell->screensaver.surfaces)) {
shell->compositor->idle_time = shell->screensaver.duration; shell->compositor->idle_time = shell->screensaver.duration;
wlsc_compositor_wake(shell->compositor); weston_compositor_wake(shell->compositor);
shell->compositor->state = WLSC_COMPOSITOR_IDLE; shell->compositor->state = WESTON_COMPOSITOR_IDLE;
} }
/* reset pointer foci */ /* reset pointer foci */
wlsc_compositor_repick(shell->compositor); weston_compositor_repick(shell->compositor);
/* reset keyboard foci */ /* reset keyboard foci */
time = wlsc_compositor_get_time(); time = weston_compositor_get_time();
wl_list_for_each(device, &shell->compositor->input_device_list, link) { wl_list_for_each(device, &shell->compositor->input_device_list, link) {
wl_input_device_set_keyboard_focus(&device->input_device, wl_input_device_set_keyboard_focus(&device->input_device,
NULL, time); NULL, time);
@ -930,12 +930,12 @@ lock(struct wlsc_shell *base)
} }
static void static void
unlock(struct wlsc_shell *base) unlock(struct weston_shell *base)
{ {
struct wl_shell *shell = container_of(base, struct wl_shell, shell); struct wl_shell *shell = container_of(base, struct wl_shell, shell);
if (!shell->locked || shell->lock_surface) { if (!shell->locked || shell->lock_surface) {
wlsc_compositor_wake(shell->compositor); weston_compositor_wake(shell->compositor);
return; return;
} }
@ -954,20 +954,20 @@ unlock(struct wlsc_shell *base)
} }
static void static void
center_on_output(struct wlsc_surface *surface, struct wlsc_output *output) center_on_output(struct weston_surface *surface, struct weston_output *output)
{ {
struct wlsc_mode *mode = output->current; struct weston_mode *mode = output->current;
surface->x = output->x + (mode->width - surface->width) / 2; surface->x = output->x + (mode->width - surface->width) / 2;
surface->y = output->y + (mode->height - surface->height) / 2; surface->y = output->y + (mode->height - surface->height) / 2;
} }
static void static void
map(struct wlsc_shell *base, map(struct weston_shell *base,
struct wlsc_surface *surface, int32_t width, int32_t height) struct weston_surface *surface, int32_t width, int32_t height)
{ {
struct wl_shell *shell = container_of(base, struct wl_shell, shell); struct wl_shell *shell = container_of(base, struct wl_shell, shell);
struct wlsc_compositor *compositor = shell->compositor; struct weston_compositor *compositor = shell->compositor;
struct wl_list *list; struct wl_list *list;
struct shell_surface *shsurf; struct shell_surface *shsurf;
enum shell_surface_type surface_type = SHELL_SURFACE_NONE; enum shell_surface_type surface_type = SHELL_SURFACE_NONE;
@ -1020,8 +1020,8 @@ map(struct wlsc_shell *base,
/* lock surface always visible, on top */ /* lock surface always visible, on top */
wl_list_insert(&compositor->surface_list, &surface->link); wl_list_insert(&compositor->surface_list, &surface->link);
wlsc_compositor_repick(compositor); weston_compositor_repick(compositor);
wlsc_compositor_wake(compositor); weston_compositor_wake(compositor);
do_configure = 1; do_configure = 1;
break; break;
case SHELL_SURFACE_SCREENSAVER: case SHELL_SURFACE_SCREENSAVER:
@ -1029,9 +1029,9 @@ map(struct wlsc_shell *base,
if (shell->locked) { if (shell->locked) {
show_screensaver(shell, shsurf); show_screensaver(shell, shsurf);
compositor->idle_time = shell->screensaver.duration; compositor->idle_time = shell->screensaver.duration;
wlsc_compositor_wake(compositor); weston_compositor_wake(compositor);
if (!shell->lock_surface) if (!shell->lock_surface)
compositor->state = WLSC_COMPOSITOR_IDLE; compositor->state = WESTON_COMPOSITOR_IDLE;
} }
do_configure = 0; do_configure = 0;
break; break;
@ -1048,7 +1048,7 @@ map(struct wlsc_shell *base,
} }
if (do_configure) if (do_configure)
wlsc_surface_configure(surface, weston_surface_configure(surface,
surface->x, surface->y, width, height); surface->x, surface->y, width, height);
switch (surface_type) { switch (surface_type) {
@ -1057,20 +1057,20 @@ map(struct wlsc_shell *base,
case SHELL_SURFACE_FULLSCREEN: case SHELL_SURFACE_FULLSCREEN:
if (!shell->locked) if (!shell->locked)
activate(base, surface, activate(base, surface,
(struct wlsc_input_device *) (struct weston_input_device *)
compositor->input_device, compositor->input_device,
wlsc_compositor_get_time()); weston_compositor_get_time());
break; break;
default: default:
break; break;
} }
if (surface_type == SHELL_SURFACE_TOPLEVEL) if (surface_type == SHELL_SURFACE_TOPLEVEL)
wlsc_zoom_run(surface, 0.8, 1.0, NULL, NULL); weston_zoom_run(surface, 0.8, 1.0, NULL, NULL);
} }
static void static void
configure(struct wlsc_shell *base, struct wlsc_surface *surface, configure(struct weston_shell *base, struct weston_surface *surface,
int32_t x, int32_t y, int32_t width, int32_t height) int32_t x, int32_t y, int32_t width, int32_t height)
{ {
struct wl_shell *shell = container_of(base, struct wl_shell, shell); struct wl_shell *shell = container_of(base, struct wl_shell, shell);
@ -1097,13 +1097,13 @@ configure(struct wlsc_shell *base, struct wlsc_surface *surface,
} }
/* /*
* wlsc_surface_configure() will assign an output, which means * weston_surface_configure() will assign an output, which means
* the surface is supposed to be in compositor->surface_list. * the surface is supposed to be in compositor->surface_list.
* Be careful with that, and make sure we stay on the right output. * Be careful with that, and make sure we stay on the right output.
* XXX: would a fullscreen surface need the same handling? * XXX: would a fullscreen surface need the same handling?
*/ */
if (do_configure) { if (do_configure) {
wlsc_surface_configure(surface, x, y, width, height); weston_surface_configure(surface, x, y, width, height);
if (surface_type == SHELL_SURFACE_SCREENSAVER) if (surface_type == SHELL_SURFACE_SCREENSAVER)
surface->output = shsurf->output; surface->output = shsurf->output;
@ -1111,7 +1111,7 @@ configure(struct wlsc_shell *base, struct wlsc_surface *surface,
} }
static void static void
desktop_shell_sigchld(struct wlsc_process *process, int status) desktop_shell_sigchld(struct weston_process *process, int status)
{ {
struct wl_shell *shell = struct wl_shell *shell =
container_of(process, struct wl_shell, child.process); container_of(process, struct wl_shell, child.process);
@ -1125,7 +1125,7 @@ launch_desktop_shell_process(struct wl_shell *shell)
{ {
const char *shell_exe = LIBEXECDIR "/wayland-desktop-shell"; const char *shell_exe = LIBEXECDIR "/wayland-desktop-shell";
shell->child.client = wlsc_client_launch(shell->compositor, shell->child.client = weston_client_launch(shell->compositor,
&shell->child.process, &shell->child.process,
shell_exe, shell_exe,
desktop_shell_sigchld); desktop_shell_sigchld);
@ -1187,7 +1187,7 @@ screensaver_set_surface(struct wl_client *client,
{ {
struct wl_shell *shell = resource->data; struct wl_shell *shell = resource->data;
struct shell_surface *surface = shell_surface_resource->data; struct shell_surface *surface = shell_surface_resource->data;
struct wlsc_output *output = output_resource->data; struct weston_output *output = output_resource->data;
if (reset_shell_surface_type(surface)) if (reset_shell_surface_type(surface))
return; return;
@ -1235,10 +1235,10 @@ bind_screensaver(struct wl_client *client,
} }
int int
shell_init(struct wlsc_compositor *ec); shell_init(struct weston_compositor *ec);
WL_EXPORT int WL_EXPORT int
shell_init(struct wlsc_compositor *ec) shell_init(struct weston_compositor *ec)
{ {
struct wl_shell *shell; struct wl_shell *shell;
@ -1277,14 +1277,14 @@ shell_init(struct wlsc_compositor *ec)
if (launch_desktop_shell_process(shell) != 0) if (launch_desktop_shell_process(shell) != 0)
return -1; return -1;
wlsc_compositor_add_binding(ec, 0, BTN_LEFT, MODIFIER_SUPER, weston_compositor_add_binding(ec, 0, BTN_LEFT, MODIFIER_SUPER,
move_binding, shell); move_binding, shell);
wlsc_compositor_add_binding(ec, 0, BTN_MIDDLE, MODIFIER_SUPER, weston_compositor_add_binding(ec, 0, BTN_MIDDLE, MODIFIER_SUPER,
resize_binding, shell); resize_binding, shell);
wlsc_compositor_add_binding(ec, KEY_BACKSPACE, 0, weston_compositor_add_binding(ec, KEY_BACKSPACE, 0,
MODIFIER_CTRL | MODIFIER_ALT, MODIFIER_CTRL | MODIFIER_ALT,
terminate_binding, ec); terminate_binding, ec);
wlsc_compositor_add_binding(ec, 0, BTN_LEFT, 0, weston_compositor_add_binding(ec, 0, BTN_LEFT, 0,
click_to_activate_binding, ec); click_to_activate_binding, ec);

@ -26,50 +26,50 @@
#include "compositor.h" #include "compositor.h"
struct wlsc_switcher { struct weston_switcher {
struct wlsc_compositor *compositor; struct weston_compositor *compositor;
struct wlsc_surface *current; struct weston_surface *current;
struct wl_listener listener; struct wl_listener listener;
}; };
static void static void
wlsc_switcher_next(struct wlsc_switcher *switcher) weston_switcher_next(struct weston_switcher *switcher)
{ {
struct wl_list *l; struct wl_list *l;
struct wl_surface *current; struct wl_surface *current;
wlsc_surface_damage(switcher->current); weston_surface_damage(switcher->current);
l = switcher->current->link.next; l = switcher->current->link.next;
if (l == &switcher->compositor->surface_list) if (l == &switcher->compositor->surface_list)
l = switcher->compositor->surface_list.next; l = switcher->compositor->surface_list.next;
switcher->current = container_of(l, struct wlsc_surface, link); switcher->current = container_of(l, struct weston_surface, link);
wl_list_remove(&switcher->listener.link); wl_list_remove(&switcher->listener.link);
current = &switcher->current->surface; current = &switcher->current->surface;
wl_list_insert(current->resource.destroy_listener_list.prev, wl_list_insert(current->resource.destroy_listener_list.prev,
&switcher->listener.link); &switcher->listener.link);
switcher->compositor->overlay = switcher->current; switcher->compositor->overlay = switcher->current;
wlsc_surface_damage(switcher->current); weston_surface_damage(switcher->current);
} }
static void static void
switcher_handle_surface_destroy(struct wl_listener *listener, switcher_handle_surface_destroy(struct wl_listener *listener,
struct wl_resource *resource, uint32_t time) struct wl_resource *resource, uint32_t time)
{ {
struct wlsc_switcher *switcher = struct weston_switcher *switcher =
container_of(listener, struct wlsc_switcher, listener); container_of(listener, struct weston_switcher, listener);
wlsc_switcher_next(switcher); weston_switcher_next(switcher);
} }
static struct wlsc_switcher * static struct weston_switcher *
wlsc_switcher_create(struct wlsc_compositor *compositor) weston_switcher_create(struct weston_compositor *compositor)
{ {
struct wlsc_switcher *switcher; struct weston_switcher *switcher;
switcher = malloc(sizeof *switcher); switcher = malloc(sizeof *switcher);
switcher->compositor = compositor; switcher->compositor = compositor;
switcher->current = container_of(compositor->surface_list.next, switcher->current = container_of(compositor->surface_list.next,
struct wlsc_surface, link); struct weston_surface, link);
switcher->listener.func = switcher_handle_surface_destroy; switcher->listener.func = switcher_handle_surface_destroy;
wl_list_init(&switcher->listener.link); wl_list_init(&switcher->listener.link);
@ -77,7 +77,7 @@ wlsc_switcher_create(struct wlsc_compositor *compositor)
} }
static void static void
wlsc_switcher_destroy(struct wlsc_switcher *switcher) weston_switcher_destroy(struct weston_switcher *switcher)
{ {
wl_list_remove(&switcher->listener.link); wl_list_remove(&switcher->listener.link);
free(switcher); free(switcher);
@ -88,16 +88,16 @@ switcher_next_binding(struct wl_input_device *device, uint32_t time,
uint32_t key, uint32_t button, uint32_t key, uint32_t button,
uint32_t state, void *data) uint32_t state, void *data)
{ {
struct wlsc_compositor *compositor = data; struct weston_compositor *compositor = data;
if (!state) if (!state)
return; return;
if (wl_list_empty(&compositor->surface_list)) if (wl_list_empty(&compositor->surface_list))
return; return;
if (compositor->switcher == NULL) if (compositor->switcher == NULL)
compositor->switcher = wlsc_switcher_create(compositor); compositor->switcher = weston_switcher_create(compositor);
wlsc_switcher_next(compositor->switcher); weston_switcher_next(compositor->switcher);
} }
static void static void
@ -105,27 +105,27 @@ switcher_terminate_binding(struct wl_input_device *device,
uint32_t time, uint32_t key, uint32_t button, uint32_t time, uint32_t key, uint32_t button,
uint32_t state, void *data) uint32_t state, void *data)
{ {
struct wlsc_compositor *compositor = data; struct weston_compositor *compositor = data;
struct wlsc_input_device *wd = (struct wlsc_input_device *) device; struct weston_input_device *wd = (struct weston_input_device *) device;
if (compositor->switcher && !state) { if (compositor->switcher && !state) {
wlsc_surface_activate(compositor->switcher->current, wd, time); weston_surface_activate(compositor->switcher->current, wd, time);
wlsc_switcher_destroy(compositor->switcher); weston_switcher_destroy(compositor->switcher);
compositor->switcher = NULL; compositor->switcher = NULL;
compositor->overlay = NULL; compositor->overlay = NULL;
} }
} }
void void
wlsc_switcher_init(struct wlsc_compositor *compositor) weston_switcher_init(struct weston_compositor *compositor)
{ {
wlsc_compositor_add_binding(compositor, weston_compositor_add_binding(compositor,
KEY_TAB, 0, MODIFIER_SUPER, KEY_TAB, 0, MODIFIER_SUPER,
switcher_next_binding, compositor); switcher_next_binding, compositor);
wlsc_compositor_add_binding(compositor, weston_compositor_add_binding(compositor,
KEY_LEFTMETA, 0, MODIFIER_SUPER, KEY_LEFTMETA, 0, MODIFIER_SUPER,
switcher_terminate_binding, compositor); switcher_terminate_binding, compositor);
wlsc_compositor_add_binding(compositor, weston_compositor_add_binding(compositor,
KEY_RIGHTMETA, 0, MODIFIER_SUPER, KEY_RIGHTMETA, 0, MODIFIER_SUPER,
switcher_terminate_binding, compositor); switcher_terminate_binding, compositor);
} }

@ -46,21 +46,21 @@ enum {
struct tablet_shell { struct tablet_shell {
struct wl_resource resource; struct wl_resource resource;
struct wlsc_shell shell; struct weston_shell shell;
struct wlsc_compositor *compositor; struct weston_compositor *compositor;
struct wlsc_process process; struct weston_process process;
struct wlsc_input_device *device; struct weston_input_device *device;
struct wl_client *client; struct wl_client *client;
struct wlsc_surface *surface; struct weston_surface *surface;
struct wlsc_surface *lockscreen_surface; struct weston_surface *lockscreen_surface;
struct wl_listener lockscreen_listener; struct wl_listener lockscreen_listener;
struct wlsc_surface *home_surface; struct weston_surface *home_surface;
struct wlsc_surface *switcher_surface; struct weston_surface *switcher_surface;
struct wl_listener switcher_listener; struct wl_listener switcher_listener;
struct tablet_client *current_client; struct tablet_client *current_client;
@ -74,12 +74,12 @@ struct tablet_client {
struct wl_resource resource; struct wl_resource resource;
struct tablet_shell *shell; struct tablet_shell *shell;
struct wl_client *client; struct wl_client *client;
struct wlsc_surface *surface; struct weston_surface *surface;
char *name; char *name;
}; };
static void static void
tablet_shell_sigchld(struct wlsc_process *process, int status) tablet_shell_sigchld(struct weston_process *process, int status)
{ {
struct tablet_shell *shell = struct tablet_shell *shell =
container_of(process, struct tablet_shell, process); container_of(process, struct tablet_shell, process);
@ -104,7 +104,7 @@ tablet_shell_set_state(struct tablet_shell *shell, int state)
} }
static void static void
tablet_shell_map(struct wlsc_shell *base, struct wlsc_surface *surface, tablet_shell_map(struct weston_shell *base, struct weston_surface *surface,
int32_t width, int32_t height) int32_t width, int32_t height)
{ {
struct tablet_shell *shell = struct tablet_shell *shell =
@ -129,20 +129,20 @@ tablet_shell_map(struct wlsc_shell *base, struct wlsc_surface *surface,
shell->current_client->client == surface->surface.resource.client) { shell->current_client->client == surface->surface.resource.client) {
tablet_shell_set_state(shell, STATE_TASK); tablet_shell_set_state(shell, STATE_TASK);
shell->current_client->surface = surface; shell->current_client->surface = surface;
wlsc_zoom_run(surface, 0.3, 1.0, NULL, NULL); weston_zoom_run(surface, 0.3, 1.0, NULL, NULL);
} }
wl_list_insert(&shell->compositor->surface_list, &surface->link); wl_list_insert(&shell->compositor->surface_list, &surface->link);
wlsc_surface_configure(surface, surface->x, surface->y, width, height); weston_surface_configure(surface, surface->x, surface->y, width, height);
} }
static void static void
tablet_shell_configure(struct wlsc_shell *base, tablet_shell_configure(struct weston_shell *base,
struct wlsc_surface *surface, struct weston_surface *surface,
int32_t x, int32_t y, int32_t x, int32_t y,
int32_t width, int32_t height) int32_t width, int32_t height)
{ {
wlsc_surface_configure(surface, x, y, width, height); weston_surface_configure(surface, x, y, width, height);
} }
static void static void
@ -163,7 +163,7 @@ tablet_shell_set_lockscreen(struct wl_client *client,
struct wl_resource *surface_resource) struct wl_resource *surface_resource)
{ {
struct tablet_shell *shell = resource->data; struct tablet_shell *shell = resource->data;
struct wlsc_surface *es = surface_resource->data; struct weston_surface *es = surface_resource->data;
es->x = 0; es->x = 0;
es->y = 0; es->y = 0;
@ -192,7 +192,7 @@ tablet_shell_set_switcher(struct wl_client *client,
struct wl_resource *surface_resource) struct wl_resource *surface_resource)
{ {
struct tablet_shell *shell = resource->data; struct tablet_shell *shell = resource->data;
struct wlsc_surface *es = surface_resource->data; struct weston_surface *es = surface_resource->data;
/* FIXME: Switcher should be centered and the compositor /* FIXME: Switcher should be centered and the compositor
* should do the tinting of the background. With the cache * should do the tinting of the background. With the cache
@ -220,25 +220,25 @@ tablet_shell_set_homescreen(struct wl_client *client,
} }
static void static void
minimize_zoom_done(struct wlsc_zoom *zoom, void *data) minimize_zoom_done(struct weston_zoom *zoom, void *data)
{ {
struct tablet_shell *shell = data; struct tablet_shell *shell = data;
struct wlsc_compositor *compositor = shell->compositor; struct weston_compositor *compositor = shell->compositor;
struct wlsc_input_device *device = struct weston_input_device *device =
(struct wlsc_input_device *) compositor->input_device; (struct weston_input_device *) compositor->input_device;
wlsc_surface_activate(shell->home_surface, weston_surface_activate(shell->home_surface,
device, wlsc_compositor_get_time()); device, weston_compositor_get_time());
} }
static void static void
tablet_shell_switch_to(struct tablet_shell *shell, tablet_shell_switch_to(struct tablet_shell *shell,
struct wlsc_surface *surface) struct weston_surface *surface)
{ {
struct wlsc_compositor *compositor = shell->compositor; struct weston_compositor *compositor = shell->compositor;
struct wlsc_input_device *device = struct weston_input_device *device =
(struct wlsc_input_device *) compositor->input_device; (struct weston_input_device *) compositor->input_device;
struct wlsc_surface *current; struct weston_surface *current;
if (shell->state == STATE_SWITCHER) { if (shell->state == STATE_SWITCHER) {
wl_list_remove(&shell->switcher_listener.link); wl_list_remove(&shell->switcher_listener.link);
@ -250,15 +250,15 @@ tablet_shell_switch_to(struct tablet_shell *shell,
if (shell->current_client && shell->current_client->surface) { if (shell->current_client && shell->current_client->surface) {
current = shell->current_client->surface; current = shell->current_client->surface;
wlsc_zoom_run(current, 1.0, 0.3, weston_zoom_run(current, 1.0, 0.3,
minimize_zoom_done, shell); minimize_zoom_done, shell);
} }
} else { } else {
fprintf(stderr, "switch to %p\n", surface); fprintf(stderr, "switch to %p\n", surface);
wlsc_surface_activate(surface, device, weston_surface_activate(surface, device,
wlsc_compositor_get_time()); weston_compositor_get_time());
tablet_shell_set_state(shell, STATE_TASK); tablet_shell_set_state(shell, STATE_TASK);
wlsc_zoom_run(surface, 0.3, 1.0, NULL, NULL); weston_zoom_run(surface, 0.3, 1.0, NULL, NULL);
} }
} }
@ -268,7 +268,7 @@ tablet_shell_show_grid(struct wl_client *client,
struct wl_resource *surface_resource) struct wl_resource *surface_resource)
{ {
struct tablet_shell *shell = resource->data; struct tablet_shell *shell = resource->data;
struct wlsc_surface *es = surface_resource->data; struct weston_surface *es = surface_resource->data;
tablet_shell_switch_to(shell, es); tablet_shell_switch_to(shell, es);
} }
@ -279,7 +279,7 @@ tablet_shell_show_panels(struct wl_client *client,
struct wl_resource *surface_resource) struct wl_resource *surface_resource)
{ {
struct tablet_shell *shell = resource->data; struct tablet_shell *shell = resource->data;
struct wlsc_surface *es = surface_resource->data; struct weston_surface *es = surface_resource->data;
tablet_shell_switch_to(shell, es); tablet_shell_switch_to(shell, es);
} }
@ -298,7 +298,7 @@ static void
tablet_client_destroy(struct wl_client *client, tablet_client_destroy(struct wl_client *client,
struct wl_resource *resource) struct wl_resource *resource)
{ {
wl_resource_destroy(resource, wlsc_compositor_get_time()); wl_resource_destroy(resource, weston_compositor_get_time());
} }
static void static void
@ -325,7 +325,7 @@ tablet_shell_create_client(struct wl_client *client,
uint32_t id, const char *name, int fd) uint32_t id, const char *name, int fd)
{ {
struct tablet_shell *shell = resource->data; struct tablet_shell *shell = resource->data;
struct wlsc_compositor *compositor = shell->compositor; struct weston_compositor *compositor = shell->compositor;
struct tablet_client *tablet_client; struct tablet_client *tablet_client;
tablet_client = malloc(sizeof *tablet_client); tablet_client = malloc(sizeof *tablet_client);
@ -367,7 +367,7 @@ launch_ux_daemon(struct tablet_shell *shell)
{ {
const char *shell_exe = LIBEXECDIR "/wayland-tablet-shell"; const char *shell_exe = LIBEXECDIR "/wayland-tablet-shell";
shell->client = wlsc_client_launch(shell->compositor, shell->client = weston_client_launch(shell->compositor,
&shell->process, &shell->process,
shell_exe, tablet_shell_sigchld); shell_exe, tablet_shell_sigchld);
} }
@ -389,7 +389,7 @@ toggle_switcher(struct tablet_shell *shell)
} }
static void static void
tablet_shell_lock(struct wlsc_shell *base) tablet_shell_lock(struct weston_shell *base)
{ {
struct tablet_shell *shell = struct tablet_shell *shell =
container_of(base, struct tablet_shell, shell); container_of(base, struct tablet_shell, shell);
@ -407,26 +407,26 @@ tablet_shell_lock(struct wlsc_shell *base)
} }
static void static void
tablet_shell_unlock(struct wlsc_shell *base) tablet_shell_unlock(struct weston_shell *base)
{ {
struct tablet_shell *shell = struct tablet_shell *shell =
container_of(base, struct tablet_shell, shell); container_of(base, struct tablet_shell, shell);
wlsc_compositor_wake(shell->compositor); weston_compositor_wake(shell->compositor);
} }
static void static void
go_home(struct tablet_shell *shell) go_home(struct tablet_shell *shell)
{ {
struct wlsc_input_device *device = struct weston_input_device *device =
(struct wlsc_input_device *) shell->compositor->input_device; (struct weston_input_device *) shell->compositor->input_device;
if (shell->state == STATE_SWITCHER) if (shell->state == STATE_SWITCHER)
wl_resource_post_event(&shell->resource, wl_resource_post_event(&shell->resource,
TABLET_SHELL_HIDE_SWITCHER); TABLET_SHELL_HIDE_SWITCHER);
wlsc_surface_activate(shell->home_surface, device, weston_surface_activate(shell->home_surface, device,
wlsc_compositor_get_time()); weston_compositor_get_time());
tablet_shell_set_state(shell, STATE_HOME); tablet_shell_set_state(shell, STATE_HOME);
} }
@ -464,7 +464,7 @@ home_key_binding(struct wl_input_device *device, uint32_t time,
if (shell->state == STATE_LOCKED) if (shell->state == STATE_LOCKED)
return; return;
shell->device = (struct wlsc_input_device *) device; shell->device = (struct weston_input_device *) device;
if (state) { if (state) {
wl_event_source_timer_update(shell->long_press_source, 500); wl_event_source_timer_update(shell->long_press_source, 500);
@ -512,10 +512,10 @@ bind_shell(struct wl_client *client, void *data, uint32_t version, uint32_t id)
} }
void void
shell_init(struct wlsc_compositor *compositor); shell_init(struct weston_compositor *compositor);
WL_EXPORT void WL_EXPORT void
shell_init(struct wlsc_compositor *compositor) shell_init(struct weston_compositor *compositor)
{ {
struct tablet_shell *shell; struct tablet_shell *shell;
struct wl_event_loop *loop; struct wl_event_loop *loop;
@ -535,15 +535,15 @@ shell_init(struct wlsc_compositor *compositor)
shell->long_press_source = shell->long_press_source =
wl_event_loop_add_timer(loop, long_press_handler, shell); wl_event_loop_add_timer(loop, long_press_handler, shell);
wlsc_compositor_add_binding(compositor, KEY_LEFTMETA, 0, 0, weston_compositor_add_binding(compositor, KEY_LEFTMETA, 0, 0,
home_key_binding, shell); home_key_binding, shell);
wlsc_compositor_add_binding(compositor, KEY_RIGHTMETA, 0, 0, weston_compositor_add_binding(compositor, KEY_RIGHTMETA, 0, 0,
home_key_binding, shell); home_key_binding, shell);
wlsc_compositor_add_binding(compositor, KEY_LEFTMETA, 0, weston_compositor_add_binding(compositor, KEY_LEFTMETA, 0,
MODIFIER_SUPER, home_key_binding, shell); MODIFIER_SUPER, home_key_binding, shell);
wlsc_compositor_add_binding(compositor, KEY_RIGHTMETA, 0, weston_compositor_add_binding(compositor, KEY_RIGHTMETA, 0,
MODIFIER_SUPER, home_key_binding, shell); MODIFIER_SUPER, home_key_binding, shell);
wlsc_compositor_add_binding(compositor, KEY_COMPOSE, 0, 0, weston_compositor_add_binding(compositor, KEY_COMPOSE, 0, 0,
menu_key_binding, shell); menu_key_binding, shell);
compositor->shell = &shell->shell; compositor->shell = &shell->shell;

@ -34,7 +34,7 @@
#include "compositor.h" #include "compositor.h"
struct tty { struct tty {
struct wlsc_compositor *compositor; struct weston_compositor *compositor;
int fd; int fd;
struct termios terminal_attributes; struct termios terminal_attributes;
@ -89,7 +89,7 @@ on_tty_input(int fd, uint32_t mask, void *data)
} }
struct tty * struct tty *
tty_create(struct wlsc_compositor *compositor, tty_vt_func_t vt_func, tty_create(struct weston_compositor *compositor, tty_vt_func_t vt_func,
int tty_nr) int tty_nr)
{ {
struct termios raw_attributes; struct termios raw_attributes;

@ -28,9 +28,9 @@
#include "compositor.h" #include "compositor.h"
WL_EXPORT void WL_EXPORT void
wlsc_matrix_init(struct wlsc_matrix *matrix) weston_matrix_init(struct weston_matrix *matrix)
{ {
static const struct wlsc_matrix identity = { static const struct weston_matrix identity = {
{ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 } { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }
}; };
@ -38,9 +38,9 @@ wlsc_matrix_init(struct wlsc_matrix *matrix)
} }
static void static void
wlsc_matrix_multiply(struct wlsc_matrix *m, const struct wlsc_matrix *n) weston_matrix_multiply(struct weston_matrix *m, const struct weston_matrix *n)
{ {
struct wlsc_matrix tmp; struct weston_matrix tmp;
const GLfloat *row, *column; const GLfloat *row, *column;
div_t d; div_t d;
int i, j; int i, j;
@ -57,30 +57,30 @@ wlsc_matrix_multiply(struct wlsc_matrix *m, const struct wlsc_matrix *n)
} }
WL_EXPORT void WL_EXPORT void
wlsc_matrix_translate(struct wlsc_matrix *matrix, GLfloat x, GLfloat y, GLfloat z) weston_matrix_translate(struct weston_matrix *matrix, GLfloat x, GLfloat y, GLfloat z)
{ {
struct wlsc_matrix translate = { struct weston_matrix translate = {
{ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, z, 1 } { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, z, 1 }
}; };
wlsc_matrix_multiply(matrix, &translate); weston_matrix_multiply(matrix, &translate);
} }
WL_EXPORT void WL_EXPORT void
wlsc_matrix_scale(struct wlsc_matrix *matrix, GLfloat x, GLfloat y, GLfloat z) weston_matrix_scale(struct weston_matrix *matrix, GLfloat x, GLfloat y, GLfloat z)
{ {
struct wlsc_matrix scale = { struct weston_matrix scale = {
{ x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0, 0, 0, 0, 1 } { x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0, 0, 0, 0, 1 }
}; };
wlsc_matrix_multiply(matrix, &scale); weston_matrix_multiply(matrix, &scale);
} }
WL_EXPORT void WL_EXPORT void
wlsc_matrix_transform(struct wlsc_matrix *matrix, struct wlsc_vector *v) weston_matrix_transform(struct weston_matrix *matrix, struct weston_vector *v)
{ {
int i, j; int i, j;
struct wlsc_vector t; struct weston_vector t;
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
t.f[i] = 0; t.f[i] = 0;
@ -92,7 +92,7 @@ wlsc_matrix_transform(struct wlsc_matrix *matrix, struct wlsc_vector *v)
} }
WL_EXPORT void WL_EXPORT void
wlsc_spring_init(struct wlsc_spring *spring, weston_spring_init(struct weston_spring *spring,
double k, double current, double target) double k, double current, double target)
{ {
spring->k = k; spring->k = k;
@ -103,7 +103,7 @@ wlsc_spring_init(struct wlsc_spring *spring,
} }
WL_EXPORT void WL_EXPORT void
wlsc_spring_update(struct wlsc_spring *spring, uint32_t msec) weston_spring_update(struct weston_spring *spring, uint32_t msec)
{ {
double force, v, current, step; double force, v, current, step;
@ -140,25 +140,25 @@ wlsc_spring_update(struct wlsc_spring *spring, uint32_t msec)
} }
WL_EXPORT int WL_EXPORT int
wlsc_spring_done(struct wlsc_spring *spring) weston_spring_done(struct weston_spring *spring)
{ {
return fabs(spring->previous - spring->target) < 0.0002 && return fabs(spring->previous - spring->target) < 0.0002 &&
fabs(spring->current - spring->target) < 0.0002; fabs(spring->current - spring->target) < 0.0002;
} }
struct wlsc_zoom { struct weston_zoom {
struct wlsc_surface *surface; struct weston_surface *surface;
struct wlsc_animation animation; struct weston_animation animation;
struct wlsc_spring spring; struct weston_spring spring;
struct wlsc_transform transform; struct weston_transform transform;
struct wl_listener listener; struct wl_listener listener;
GLfloat start, stop; GLfloat start, stop;
void (*done)(struct wlsc_zoom *zoom, void *data); void (*done)(struct weston_zoom *zoom, void *data);
void *data; void *data;
}; };
static void static void
wlsc_zoom_destroy(struct wlsc_zoom *zoom) weston_zoom_destroy(struct weston_zoom *zoom)
{ {
wl_list_remove(&zoom->animation.link); wl_list_remove(&zoom->animation.link);
wl_list_remove(&zoom->listener.link); wl_list_remove(&zoom->listener.link);
@ -172,34 +172,34 @@ static void
handle_zoom_surface_destroy(struct wl_listener *listener, handle_zoom_surface_destroy(struct wl_listener *listener,
struct wl_resource *resource, uint32_t time) struct wl_resource *resource, uint32_t time)
{ {
struct wlsc_zoom *zoom = struct weston_zoom *zoom =
container_of(listener, struct wlsc_zoom, listener); container_of(listener, struct weston_zoom, listener);
wlsc_zoom_destroy(zoom); weston_zoom_destroy(zoom);
} }
static void static void
wlsc_zoom_frame(struct wlsc_animation *animation, weston_zoom_frame(struct weston_animation *animation,
struct wlsc_output *output, uint32_t msecs) struct weston_output *output, uint32_t msecs)
{ {
struct wlsc_zoom *zoom = struct weston_zoom *zoom =
container_of(animation, struct wlsc_zoom, animation); container_of(animation, struct weston_zoom, animation);
struct wlsc_surface *es = zoom->surface; struct weston_surface *es = zoom->surface;
GLfloat scale; GLfloat scale;
wlsc_spring_update(&zoom->spring, msecs); weston_spring_update(&zoom->spring, msecs);
if (wlsc_spring_done(&zoom->spring)) if (weston_spring_done(&zoom->spring))
wlsc_zoom_destroy(zoom); weston_zoom_destroy(zoom);
scale = zoom->start + scale = zoom->start +
(zoom->stop - zoom->start) * zoom->spring.current; (zoom->stop - zoom->start) * zoom->spring.current;
wlsc_matrix_init(&zoom->transform.matrix); weston_matrix_init(&zoom->transform.matrix);
wlsc_matrix_translate(&zoom->transform.matrix, weston_matrix_translate(&zoom->transform.matrix,
-(es->x + es->width / 2.0), -(es->x + es->width / 2.0),
-(es->y + es->height / 2.0), 0); -(es->y + es->height / 2.0), 0);
wlsc_matrix_scale(&zoom->transform.matrix, scale, scale, scale); weston_matrix_scale(&zoom->transform.matrix, scale, scale, scale);
wlsc_matrix_translate(&zoom->transform.matrix, weston_matrix_translate(&zoom->transform.matrix,
es->x + es->width / 2.0, es->x + es->width / 2.0,
es->y + es->height / 2.0, 0); es->y + es->height / 2.0, 0);
@ -207,17 +207,17 @@ wlsc_zoom_frame(struct wlsc_animation *animation,
if (es->alpha > 255) if (es->alpha > 255)
es->alpha = 255; es->alpha = 255;
scale = 1.0 / zoom->spring.current; scale = 1.0 / zoom->spring.current;
wlsc_matrix_init(&zoom->transform.inverse); weston_matrix_init(&zoom->transform.inverse);
wlsc_matrix_scale(&zoom->transform.inverse, scale, scale, scale); weston_matrix_scale(&zoom->transform.inverse, scale, scale, scale);
wlsc_compositor_damage_all(es->compositor); weston_compositor_damage_all(es->compositor);
} }
WL_EXPORT struct wlsc_zoom * WL_EXPORT struct weston_zoom *
wlsc_zoom_run(struct wlsc_surface *surface, GLfloat start, GLfloat stop, weston_zoom_run(struct weston_surface *surface, GLfloat start, GLfloat stop,
wlsc_zoom_done_func_t done, void *data) weston_zoom_done_func_t done, void *data)
{ {
struct wlsc_zoom *zoom; struct weston_zoom *zoom;
zoom = malloc(sizeof *zoom); zoom = malloc(sizeof *zoom);
if (!zoom) if (!zoom)
@ -229,11 +229,11 @@ wlsc_zoom_run(struct wlsc_surface *surface, GLfloat start, GLfloat stop,
zoom->start = start; zoom->start = start;
zoom->stop = stop; zoom->stop = stop;
surface->transform = &zoom->transform; surface->transform = &zoom->transform;
wlsc_spring_init(&zoom->spring, 200.0, 0.0, 1.0); weston_spring_init(&zoom->spring, 200.0, 0.0, 1.0);
zoom->spring.friction = 700; zoom->spring.friction = 700;
zoom->spring.timestamp = wlsc_compositor_get_time(); zoom->spring.timestamp = weston_compositor_get_time();
zoom->animation.frame = wlsc_zoom_frame; zoom->animation.frame = weston_zoom_frame;
wlsc_zoom_frame(&zoom->animation, NULL, zoom->spring.timestamp); weston_zoom_frame(&zoom->animation, NULL, zoom->spring.timestamp);
zoom->listener.func = handle_zoom_surface_destroy; zoom->listener.func = handle_zoom_surface_destroy;
wl_list_insert(surface->surface.resource.destroy_listener_list.prev, wl_list_insert(surface->surface.resource.destroy_listener_list.prev,
@ -245,21 +245,21 @@ wlsc_zoom_run(struct wlsc_surface *surface, GLfloat start, GLfloat stop,
return zoom; return zoom;
} }
struct wlsc_binding { struct weston_binding {
uint32_t key; uint32_t key;
uint32_t button; uint32_t button;
uint32_t modifier; uint32_t modifier;
wlsc_binding_handler_t handler; weston_binding_handler_t handler;
void *data; void *data;
struct wl_list link; struct wl_list link;
}; };
WL_EXPORT struct wlsc_binding * WL_EXPORT struct weston_binding *
wlsc_compositor_add_binding(struct wlsc_compositor *compositor, weston_compositor_add_binding(struct weston_compositor *compositor,
uint32_t key, uint32_t button, uint32_t modifier, uint32_t key, uint32_t button, uint32_t modifier,
wlsc_binding_handler_t handler, void *data) weston_binding_handler_t handler, void *data)
{ {
struct wlsc_binding *binding; struct weston_binding *binding;
binding = malloc(sizeof *binding); binding = malloc(sizeof *binding);
if (binding == NULL) if (binding == NULL)
@ -276,19 +276,19 @@ wlsc_compositor_add_binding(struct wlsc_compositor *compositor,
} }
WL_EXPORT void WL_EXPORT void
wlsc_binding_destroy(struct wlsc_binding *binding) weston_binding_destroy(struct weston_binding *binding)
{ {
wl_list_remove(&binding->link); wl_list_remove(&binding->link);
free(binding); free(binding);
} }
WL_EXPORT void WL_EXPORT void
wlsc_compositor_run_binding(struct wlsc_compositor *compositor, weston_compositor_run_binding(struct weston_compositor *compositor,
struct wlsc_input_device *device, struct weston_input_device *device,
uint32_t time, uint32_t time,
uint32_t key, uint32_t button, int32_t state) uint32_t key, uint32_t button, int32_t state)
{ {
struct wlsc_binding *b; struct weston_binding *b;
wl_list_for_each(b, &compositor->binding_list, link) { wl_list_for_each(b, &compositor->binding_list, link) {
if (b->key == key && b->button == button && if (b->key == key && b->button == button &&

@ -45,7 +45,7 @@ struct xserver {
struct wl_resource resource; struct wl_resource resource;
}; };
struct wlsc_xserver { struct weston_xserver {
struct wl_display *wl_display; struct wl_display *wl_display;
struct wl_event_loop *loop; struct wl_event_loop *loop;
struct wl_event_source *sigchld_source; struct wl_event_source *sigchld_source;
@ -54,20 +54,20 @@ struct wlsc_xserver {
int unix_fd; int unix_fd;
struct wl_event_source *unix_source; struct wl_event_source *unix_source;
int display; int display;
struct wlsc_process process; struct weston_process process;
struct wl_resource *resource; struct wl_resource *resource;
struct wl_client *client; struct wl_client *client;
struct wlsc_compositor *compositor; struct weston_compositor *compositor;
struct wlsc_wm *wm; struct weston_wm *wm;
}; };
struct wlsc_wm { struct weston_wm {
xcb_connection_t *conn; xcb_connection_t *conn;
const xcb_query_extension_reply_t *xfixes; const xcb_query_extension_reply_t *xfixes;
struct wl_event_source *source; struct wl_event_source *source;
xcb_screen_t *screen; xcb_screen_t *screen;
struct hash_table *window_hash; struct hash_table *window_hash;
struct wlsc_xserver *server; struct weston_xserver *server;
xcb_window_t selection_window; xcb_window_t selection_window;
int incr; int incr;
@ -108,19 +108,19 @@ struct wlsc_wm {
} atom; } atom;
}; };
struct wlsc_wm_window { struct weston_wm_window {
xcb_window_t id; xcb_window_t id;
struct wlsc_surface *surface; struct weston_surface *surface;
struct wl_listener surface_destroy_listener; struct wl_listener surface_destroy_listener;
char *class; char *class;
char *name; char *name;
struct wlsc_wm_window *transient_for; struct weston_wm_window *transient_for;
uint32_t protocols; uint32_t protocols;
xcb_atom_t type; xcb_atom_t type;
}; };
static struct wlsc_wm_window * static struct weston_wm_window *
get_wm_window(struct wlsc_surface *surface); get_wm_window(struct weston_surface *surface);
static const char * static const char *
get_atom_name(xcb_connection_t *c, xcb_atom_t atom) get_atom_name(xcb_connection_t *c, xcb_atom_t atom)
@ -144,7 +144,7 @@ get_atom_name(xcb_connection_t *c, xcb_atom_t atom)
} }
static void static void
dump_property(struct wlsc_wm *wm, xcb_atom_t property, dump_property(struct weston_wm *wm, xcb_atom_t property,
xcb_get_property_reply_t *reply) xcb_get_property_reply_t *reply)
{ {
int32_t *incr_value; int32_t *incr_value;
@ -196,7 +196,7 @@ dump_property(struct wlsc_wm *wm, xcb_atom_t property,
} }
static void static void
dump_window_properties(struct wlsc_wm *wm, xcb_window_t window) dump_window_properties(struct weston_wm *wm, xcb_window_t window)
{ {
xcb_list_properties_cookie_t list_cookie; xcb_list_properties_cookie_t list_cookie;
xcb_list_properties_reply_t *list_reply; xcb_list_properties_reply_t *list_reply;
@ -237,7 +237,7 @@ static void
data_offer_accept(struct wl_client *client, struct wl_resource *resource, data_offer_accept(struct wl_client *client, struct wl_resource *resource,
uint32_t time, const char *mime_type) uint32_t time, const char *mime_type)
{ {
struct wlsc_data_source *source = resource->data; struct weston_data_source *source = resource->data;
wl_resource_post_event(&source->resource, wl_resource_post_event(&source->resource,
WL_DATA_SOURCE_TARGET, mime_type); WL_DATA_SOURCE_TARGET, mime_type);
@ -247,8 +247,8 @@ static void
data_offer_receive(struct wl_client *client, struct wl_resource *resource, data_offer_receive(struct wl_client *client, struct wl_resource *resource,
const char *mime_type, int32_t fd) const char *mime_type, int32_t fd)
{ {
struct wlsc_data_source *source = resource->data; struct weston_data_source *source = resource->data;
struct wlsc_wm *wm = source->data; struct weston_wm *wm = source->data;
if (strcmp(mime_type, "text/plain;charset=utf-8") == 0) { if (strcmp(mime_type, "text/plain;charset=utf-8") == 0) {
/* Get data for the utf8_string target */ /* Get data for the utf8_string target */
@ -271,15 +271,15 @@ data_offer_receive(struct wl_client *client, struct wl_resource *resource,
static void static void
data_offer_destroy(struct wl_client *client, struct wl_resource *resource) data_offer_destroy(struct wl_client *client, struct wl_resource *resource)
{ {
wl_resource_destroy(resource, wlsc_compositor_get_time()); wl_resource_destroy(resource, weston_compositor_get_time());
} }
static void static void
destroy_data_offer(struct wl_resource *resource) destroy_data_offer(struct wl_resource *resource)
{ {
struct wlsc_data_source *source = resource->data; struct weston_data_source *source = resource->data;
wlsc_data_source_unref(source); weston_data_source_unref(source);
free(resource); free(resource);
} }
@ -290,7 +290,7 @@ static const struct wl_data_offer_interface data_offer_interface = {
}; };
static struct wl_resource * static struct wl_resource *
data_source_create_offer(struct wlsc_data_source *source, data_source_create_offer(struct weston_data_source *source,
struct wl_resource *target) struct wl_resource *target)
{ {
struct wl_resource *resource; struct wl_resource *resource;
@ -304,15 +304,15 @@ data_source_create_offer(struct wlsc_data_source *source,
} }
static void static void
data_source_cancel(struct wlsc_data_source *source) data_source_cancel(struct weston_data_source *source)
{ {
} }
static void static void
wlsc_wm_get_selection_targets(struct wlsc_wm *wm) weston_wm_get_selection_targets(struct weston_wm *wm)
{ {
struct wlsc_data_source *source; struct weston_data_source *source;
struct wlsc_input_device *device; struct weston_input_device *device;
xcb_get_property_cookie_t cookie; xcb_get_property_cookie_t cookie;
xcb_get_property_reply_t *reply; xcb_get_property_reply_t *reply;
xcb_atom_t *value; xcb_atom_t *value;
@ -356,19 +356,19 @@ wlsc_wm_get_selection_targets(struct wlsc_wm *wm)
} }
} }
device = (struct wlsc_input_device *) device = (struct weston_input_device *)
wm->server->compositor->input_device; wm->server->compositor->input_device;
wlsc_input_device_set_selection(device, source, weston_input_device_set_selection(device, source,
wlsc_compositor_get_time()); weston_compositor_get_time());
wlsc_data_source_unref(source); weston_data_source_unref(source);
free(reply); free(reply);
} }
static int static int
wlsc_wm_write_property(int fd, uint32_t mask, void *data) weston_wm_write_property(int fd, uint32_t mask, void *data)
{ {
struct wlsc_wm *wm = data; struct weston_wm *wm = data;
unsigned char *property; unsigned char *property;
int len, remainder; int len, remainder;
@ -408,7 +408,7 @@ wlsc_wm_write_property(int fd, uint32_t mask, void *data)
} }
static void static void
wlsc_wm_get_selection_data(struct wlsc_wm *wm) weston_wm_get_selection_data(struct weston_wm *wm)
{ {
xcb_get_property_cookie_t cookie; xcb_get_property_cookie_t cookie;
xcb_get_property_reply_t *reply; xcb_get_property_reply_t *reply;
@ -435,14 +435,14 @@ wlsc_wm_get_selection_data(struct wlsc_wm *wm)
wl_event_loop_add_fd(wm->server->loop, wl_event_loop_add_fd(wm->server->loop,
wm->data_source_fd, wm->data_source_fd,
WL_EVENT_WRITABLE, WL_EVENT_WRITABLE,
wlsc_wm_write_property, weston_wm_write_property,
wm); wm);
wm->property_reply = reply; wm->property_reply = reply;
} }
} }
static void static void
wlsc_wm_get_incr_chunk(struct wlsc_wm *wm) weston_wm_get_incr_chunk(struct weston_wm *wm)
{ {
xcb_get_property_cookie_t cookie; xcb_get_property_cookie_t cookie;
xcb_get_property_reply_t *reply; xcb_get_property_reply_t *reply;
@ -465,7 +465,7 @@ wlsc_wm_get_incr_chunk(struct wlsc_wm *wm)
wl_event_loop_add_fd(wm->server->loop, wl_event_loop_add_fd(wm->server->loop,
wm->data_source_fd, wm->data_source_fd,
WL_EVENT_WRITABLE, WL_EVENT_WRITABLE,
wlsc_wm_write_property, weston_wm_write_property,
wm); wm);
wm->property_reply = reply; wm->property_reply = reply;
} else { } else {
@ -476,11 +476,11 @@ wlsc_wm_get_incr_chunk(struct wlsc_wm *wm)
} }
void void
wlsc_xserver_set_selection(struct wlsc_input_device *device) weston_xserver_set_selection(struct weston_input_device *device)
{ {
struct wlsc_xserver *wxs = device->compositor->wxs; struct weston_xserver *wxs = device->compositor->wxs;
struct wlsc_wm *wm = wxs->wm; struct weston_wm *wm = wxs->wm;
struct wlsc_data_source *source; struct weston_data_source *source;
const char **p, **end; const char **p, **end;
int has_text_plain = 0; int has_text_plain = 0;
@ -514,7 +514,7 @@ wlsc_xserver_set_selection(struct wlsc_input_device *device)
} }
static void static void
wlsc_wm_handle_configure_request(struct wlsc_wm *wm, xcb_generic_event_t *event) weston_wm_handle_configure_request(struct weston_wm *wm, xcb_generic_event_t *event)
{ {
xcb_configure_request_event_t *configure_request = xcb_configure_request_event_t *configure_request =
(xcb_configure_request_event_t *) event; (xcb_configure_request_event_t *) event;
@ -547,7 +547,7 @@ wlsc_wm_handle_configure_request(struct wlsc_wm *wm, xcb_generic_event_t *event)
} }
static void static void
wlsc_wm_handle_configure_notify(struct wlsc_wm *wm, xcb_generic_event_t *event) weston_wm_handle_configure_notify(struct weston_wm *wm, xcb_generic_event_t *event)
{ {
xcb_configure_notify_event_t *configure_notify = xcb_configure_notify_event_t *configure_notify =
(xcb_configure_notify_event_t *) event; (xcb_configure_notify_event_t *) event;
@ -559,8 +559,8 @@ wlsc_wm_handle_configure_notify(struct wlsc_wm *wm, xcb_generic_event_t *event)
} }
static void static void
wlsc_wm_activate(struct wlsc_wm *wm, weston_wm_activate(struct weston_wm *wm,
struct wlsc_wm_window *window, xcb_timestamp_t time) struct weston_wm_window *window, xcb_timestamp_t time)
{ {
xcb_client_message_event_t client_message; xcb_client_message_event_t client_message;
@ -580,13 +580,13 @@ wlsc_wm_activate(struct wlsc_wm *wm,
} }
WL_EXPORT void WL_EXPORT void
wlsc_xserver_surface_activate(struct wlsc_surface *surface) weston_xserver_surface_activate(struct weston_surface *surface)
{ {
struct wlsc_wm_window *window = get_wm_window(surface); struct weston_wm_window *window = get_wm_window(surface);
struct wlsc_xserver *wxs = surface->compositor->wxs; struct weston_xserver *wxs = surface->compositor->wxs;
if (window) if (window)
wlsc_wm_activate(wxs->wm, window, XCB_TIME_CURRENT_TIME); weston_wm_activate(wxs->wm, window, XCB_TIME_CURRENT_TIME);
else if (wxs && wxs->wm) else if (wxs && wxs->wm)
xcb_set_input_focus (wxs->wm->conn, xcb_set_input_focus (wxs->wm->conn,
XCB_INPUT_FOCUS_POINTER_ROOT, XCB_INPUT_FOCUS_POINTER_ROOT,
@ -595,7 +595,7 @@ wlsc_xserver_surface_activate(struct wlsc_surface *surface)
} }
static void static void
wlsc_wm_handle_map_request(struct wlsc_wm *wm, xcb_generic_event_t *event) weston_wm_handle_map_request(struct weston_wm *wm, xcb_generic_event_t *event)
{ {
xcb_map_request_event_t *map_request = xcb_map_request_event_t *map_request =
(xcb_map_request_event_t *) event; (xcb_map_request_event_t *) event;
@ -609,9 +609,9 @@ wlsc_wm_handle_map_request(struct wlsc_wm *wm, xcb_generic_event_t *event)
#define TYPE_WM_PROTOCOLS XCB_ATOM_CUT_BUFFER0 #define TYPE_WM_PROTOCOLS XCB_ATOM_CUT_BUFFER0
static void static void
wlsc_wm_handle_map_notify(struct wlsc_wm *wm, xcb_generic_event_t *event) weston_wm_handle_map_notify(struct weston_wm *wm, xcb_generic_event_t *event)
{ {
#define F(field) offsetof(struct wlsc_wm_window, field) #define F(field) offsetof(struct weston_wm_window, field)
const struct { const struct {
xcb_atom_t atom; xcb_atom_t atom;
@ -629,7 +629,7 @@ wlsc_wm_handle_map_notify(struct wlsc_wm *wm, xcb_generic_event_t *event)
xcb_map_notify_event_t *map_notify = (xcb_map_notify_event_t *) event; xcb_map_notify_event_t *map_notify = (xcb_map_notify_event_t *) event;
xcb_get_property_cookie_t cookie[ARRAY_LENGTH(props)]; xcb_get_property_cookie_t cookie[ARRAY_LENGTH(props)];
xcb_get_property_reply_t *reply; xcb_get_property_reply_t *reply;
struct wlsc_wm_window *window; struct weston_wm_window *window;
void *p; void *p;
uint32_t *xid; uint32_t *xid;
xcb_atom_t *atom; xcb_atom_t *atom;
@ -666,7 +666,7 @@ wlsc_wm_handle_map_notify(struct wlsc_wm *wm, xcb_generic_event_t *event)
break; break;
case XCB_ATOM_WINDOW: case XCB_ATOM_WINDOW:
xid = xcb_get_property_value(reply); xid = xcb_get_property_value(reply);
*(struct wlsc_wm_window **) p = *(struct weston_wm_window **) p =
hash_table_lookup(wm->window_hash, *xid); hash_table_lookup(wm->window_hash, *xid);
break; break;
case XCB_ATOM_ATOM: case XCB_ATOM_ATOM:
@ -684,13 +684,13 @@ wlsc_wm_handle_map_notify(struct wlsc_wm *wm, xcb_generic_event_t *event)
fprintf(stderr, "window %d: name %s, class %s, transient_for %d\n", fprintf(stderr, "window %d: name %s, class %s, transient_for %d\n",
window->id, window->name, window->class, window->id, window->name, window->class,
window->transient_for ? window->transient_for->id : 0); window->transient_for ? window->transient_for->id : 0);
wlsc_wm_activate(wm, window, XCB_TIME_CURRENT_TIME); weston_wm_activate(wm, window, XCB_TIME_CURRENT_TIME);
} }
static const int incr_chunk_size = 64 * 1024; static const int incr_chunk_size = 64 * 1024;
static void static void
wlsc_wm_send_selection_notify(struct wlsc_wm *wm, xcb_atom_t property) weston_wm_send_selection_notify(struct weston_wm *wm, xcb_atom_t property)
{ {
xcb_selection_notify_event_t selection_notify; xcb_selection_notify_event_t selection_notify;
@ -709,7 +709,7 @@ wlsc_wm_send_selection_notify(struct wlsc_wm *wm, xcb_atom_t property)
} }
static void static void
wlsc_wm_send_targets(struct wlsc_wm *wm) weston_wm_send_targets(struct weston_wm *wm)
{ {
xcb_atom_t targets[] = { xcb_atom_t targets[] = {
wm->atom.timestamp, wm->atom.timestamp,
@ -728,11 +728,11 @@ wlsc_wm_send_targets(struct wlsc_wm *wm)
32, /* format */ 32, /* format */
ARRAY_LENGTH(targets), targets); ARRAY_LENGTH(targets), targets);
wlsc_wm_send_selection_notify(wm, wm->selection_request.property); weston_wm_send_selection_notify(wm, wm->selection_request.property);
} }
static void static void
wlsc_wm_send_timestamp(struct wlsc_wm *wm) weston_wm_send_timestamp(struct weston_wm *wm)
{ {
xcb_change_property(wm->conn, xcb_change_property(wm->conn,
XCB_PROP_MODE_REPLACE, XCB_PROP_MODE_REPLACE,
@ -742,11 +742,11 @@ wlsc_wm_send_timestamp(struct wlsc_wm *wm)
32, /* format */ 32, /* format */
1, &wm->selection_timestamp); 1, &wm->selection_timestamp);
wlsc_wm_send_selection_notify(wm, wm->selection_request.property); weston_wm_send_selection_notify(wm, wm->selection_request.property);
} }
static int static int
wlsc_wm_flush_source_data(struct wlsc_wm *wm) weston_wm_flush_source_data(struct weston_wm *wm)
{ {
int length; int length;
@ -766,9 +766,9 @@ wlsc_wm_flush_source_data(struct wlsc_wm *wm)
} }
static int static int
wlsc_wm_read_data_source(int fd, uint32_t mask, void *data) weston_wm_read_data_source(int fd, uint32_t mask, void *data)
{ {
struct wlsc_wm *wm = data; struct weston_wm *wm = data;
int len, current, available; int len, current, available;
void *p; void *p;
@ -782,7 +782,7 @@ wlsc_wm_read_data_source(int fd, uint32_t mask, void *data)
len = read(fd, p, available); len = read(fd, p, available);
if (len == -1) { if (len == -1) {
fprintf(stderr, "read error from data source: %m\n"); fprintf(stderr, "read error from data source: %m\n");
wlsc_wm_send_selection_notify(wm, XCB_ATOM_NONE); weston_wm_send_selection_notify(wm, XCB_ATOM_NONE);
wl_event_source_remove(wm->property_source); wl_event_source_remove(wm->property_source);
close(fd); close(fd);
wl_array_release(&wm->source_data); wl_array_release(&wm->source_data);
@ -807,7 +807,7 @@ wlsc_wm_read_data_source(int fd, uint32_t mask, void *data)
wm->selection_property_set = 1; wm->selection_property_set = 1;
wm->flush_property_on_delete = 1; wm->flush_property_on_delete = 1;
wl_event_source_remove(wm->property_source); wl_event_source_remove(wm->property_source);
wlsc_wm_send_selection_notify(wm, wm->selection_request.property); weston_wm_send_selection_notify(wm, wm->selection_request.property);
} else if (wm->selection_property_set) { } else if (wm->selection_property_set) {
fprintf(stderr, "got %d bytes, waiting for " fprintf(stderr, "got %d bytes, waiting for "
"property delete\n", wm->source_data.size); "property delete\n", wm->source_data.size);
@ -818,13 +818,13 @@ wlsc_wm_read_data_source(int fd, uint32_t mask, void *data)
fprintf(stderr, "got %d bytes, " fprintf(stderr, "got %d bytes, "
"property deleted, seting new property\n", "property deleted, seting new property\n",
wm->source_data.size); wm->source_data.size);
wlsc_wm_flush_source_data(wm); weston_wm_flush_source_data(wm);
} }
} else if (len == 0 && !wm->incr) { } else if (len == 0 && !wm->incr) {
fprintf(stderr, "non-incr transfer complete\n"); fprintf(stderr, "non-incr transfer complete\n");
/* Non-incr transfer all done. */ /* Non-incr transfer all done. */
wlsc_wm_flush_source_data(wm); weston_wm_flush_source_data(wm);
wlsc_wm_send_selection_notify(wm, wm->selection_request.property); weston_wm_send_selection_notify(wm, wm->selection_request.property);
xcb_flush(wm->conn); xcb_flush(wm->conn);
wl_event_source_remove(wm->property_source); wl_event_source_remove(wm->property_source);
close(fd); close(fd);
@ -841,7 +841,7 @@ wlsc_wm_read_data_source(int fd, uint32_t mask, void *data)
fprintf(stderr, "got %d bytes, " fprintf(stderr, "got %d bytes, "
"property deleted, seting new property\n", "property deleted, seting new property\n",
wm->source_data.size); wm->source_data.size);
wlsc_wm_flush_source_data(wm); weston_wm_flush_source_data(wm);
} }
xcb_flush(wm->conn); xcb_flush(wm->conn);
wl_event_source_remove(wm->property_source); wl_event_source_remove(wm->property_source);
@ -855,15 +855,15 @@ wlsc_wm_read_data_source(int fd, uint32_t mask, void *data)
} }
static void static void
wlsc_wm_send_data(struct wlsc_wm *wm, xcb_atom_t target, const char *mime_type) weston_wm_send_data(struct weston_wm *wm, xcb_atom_t target, const char *mime_type)
{ {
struct wlsc_input_device *device = (struct wlsc_input_device *) struct weston_input_device *device = (struct weston_input_device *)
wm->server->compositor->input_device; wm->server->compositor->input_device;
int p[2]; int p[2];
if (pipe2(p, O_CLOEXEC | O_NONBLOCK) == -1) { if (pipe2(p, O_CLOEXEC | O_NONBLOCK) == -1) {
fprintf(stderr, "pipe2 failed: %m\n"); fprintf(stderr, "pipe2 failed: %m\n");
wlsc_wm_send_selection_notify(wm, XCB_ATOM_NONE); weston_wm_send_selection_notify(wm, XCB_ATOM_NONE);
return; return;
} }
@ -873,7 +873,7 @@ wlsc_wm_send_data(struct wlsc_wm *wm, xcb_atom_t target, const char *mime_type)
wm->property_source = wl_event_loop_add_fd(wm->server->loop, wm->property_source = wl_event_loop_add_fd(wm->server->loop,
wm->data_source_fd, wm->data_source_fd,
WL_EVENT_READABLE, WL_EVENT_READABLE,
wlsc_wm_read_data_source, weston_wm_read_data_source,
wm); wm);
wl_resource_post_event(&device->selection_data_source->resource, wl_resource_post_event(&device->selection_data_source->resource,
@ -882,7 +882,7 @@ wlsc_wm_send_data(struct wlsc_wm *wm, xcb_atom_t target, const char *mime_type)
} }
static void static void
wlsc_wm_send_incr_chunk(struct wlsc_wm *wm) weston_wm_send_incr_chunk(struct weston_wm *wm)
{ {
fprintf(stderr, "property deleted\n"); fprintf(stderr, "property deleted\n");
int length; int length;
@ -892,14 +892,14 @@ wlsc_wm_send_incr_chunk(struct wlsc_wm *wm)
fprintf(stderr, "setting new property, %d bytes\n", fprintf(stderr, "setting new property, %d bytes\n",
wm->source_data.size); wm->source_data.size);
wm->flush_property_on_delete = 0; wm->flush_property_on_delete = 0;
length = wlsc_wm_flush_source_data(wm); length = weston_wm_flush_source_data(wm);
if (wm->data_source_fd >= 0) { if (wm->data_source_fd >= 0) {
wm->property_source = wm->property_source =
wl_event_loop_add_fd(wm->server->loop, wl_event_loop_add_fd(wm->server->loop,
wm->data_source_fd, wm->data_source_fd,
WL_EVENT_READABLE, WL_EVENT_READABLE,
wlsc_wm_read_data_source, weston_wm_read_data_source,
wm); wm);
} else if (length > 0) { } else if (length > 0) {
/* Transfer is all done, but queue a flush for /* Transfer is all done, but queue a flush for
@ -915,7 +915,7 @@ wlsc_wm_send_incr_chunk(struct wlsc_wm *wm)
} }
static void static void
wlsc_wm_handle_selection_request(struct wlsc_wm *wm, weston_wm_handle_selection_request(struct weston_wm *wm,
xcb_generic_event_t *event) xcb_generic_event_t *event)
{ {
xcb_selection_request_event_t *selection_request = xcb_selection_request_event_t *selection_request =
@ -933,21 +933,21 @@ wlsc_wm_handle_selection_request(struct wlsc_wm *wm,
wm->flush_property_on_delete = 0; wm->flush_property_on_delete = 0;
if (selection_request->target == wm->atom.targets) { if (selection_request->target == wm->atom.targets) {
wlsc_wm_send_targets(wm); weston_wm_send_targets(wm);
} else if (selection_request->target == wm->atom.timestamp) { } else if (selection_request->target == wm->atom.timestamp) {
wlsc_wm_send_timestamp(wm); weston_wm_send_timestamp(wm);
} else if (selection_request->target == wm->atom.utf8_string || } else if (selection_request->target == wm->atom.utf8_string ||
selection_request->target == wm->atom.text) { selection_request->target == wm->atom.text) {
wlsc_wm_send_data(wm, wm->atom.utf8_string, weston_wm_send_data(wm, wm->atom.utf8_string,
"text/plain;charset=utf-8"); "text/plain;charset=utf-8");
} else { } else {
fprintf(stderr, "can only handle UTF8_STRING targets...\n"); fprintf(stderr, "can only handle UTF8_STRING targets...\n");
wlsc_wm_send_selection_notify(wm, XCB_ATOM_NONE); weston_wm_send_selection_notify(wm, XCB_ATOM_NONE);
} }
} }
static void static void
wlsc_wm_handle_property_notify(struct wlsc_wm *wm, xcb_generic_event_t *event) weston_wm_handle_property_notify(struct weston_wm *wm, xcb_generic_event_t *event)
{ {
xcb_property_notify_event_t *property_notify = xcb_property_notify_event_t *property_notify =
(xcb_property_notify_event_t *) event; (xcb_property_notify_event_t *) event;
@ -956,12 +956,12 @@ wlsc_wm_handle_property_notify(struct wlsc_wm *wm, xcb_generic_event_t *event)
if (property_notify->state == XCB_PROPERTY_NEW_VALUE && if (property_notify->state == XCB_PROPERTY_NEW_VALUE &&
property_notify->atom == wm->atom.wl_selection && property_notify->atom == wm->atom.wl_selection &&
wm->incr) wm->incr)
wlsc_wm_get_incr_chunk(wm); weston_wm_get_incr_chunk(wm);
} else if (property_notify->window == wm->selection_request.requestor) { } else if (property_notify->window == wm->selection_request.requestor) {
if (property_notify->state == XCB_PROPERTY_DELETE && if (property_notify->state == XCB_PROPERTY_DELETE &&
property_notify->atom == wm->selection_request.property && property_notify->atom == wm->selection_request.property &&
wm->incr) wm->incr)
wlsc_wm_send_incr_chunk(wm); weston_wm_send_incr_chunk(wm);
} else if (property_notify->atom == XCB_ATOM_WM_CLASS) { } else if (property_notify->atom == XCB_ATOM_WM_CLASS) {
fprintf(stderr, "wm_class changed\n"); fprintf(stderr, "wm_class changed\n");
} else if (property_notify->atom == XCB_ATOM_WM_TRANSIENT_FOR) { } else if (property_notify->atom == XCB_ATOM_WM_TRANSIENT_FOR) {
@ -986,11 +986,11 @@ wlsc_wm_handle_property_notify(struct wlsc_wm *wm, xcb_generic_event_t *event)
} }
static void static void
wlsc_wm_handle_create_notify(struct wlsc_wm *wm, xcb_generic_event_t *event) weston_wm_handle_create_notify(struct weston_wm *wm, xcb_generic_event_t *event)
{ {
xcb_create_notify_event_t *create_notify = xcb_create_notify_event_t *create_notify =
(xcb_create_notify_event_t *) event; (xcb_create_notify_event_t *) event;
struct wlsc_wm_window *window; struct weston_wm_window *window;
uint32_t values[1]; uint32_t values[1];
fprintf(stderr, "XCB_CREATE_NOTIFY (window %d)\n", fprintf(stderr, "XCB_CREATE_NOTIFY (window %d)\n",
@ -1012,11 +1012,11 @@ wlsc_wm_handle_create_notify(struct wlsc_wm *wm, xcb_generic_event_t *event)
} }
static void static void
wlsc_wm_handle_destroy_notify(struct wlsc_wm *wm, xcb_generic_event_t *event) weston_wm_handle_destroy_notify(struct weston_wm *wm, xcb_generic_event_t *event)
{ {
xcb_destroy_notify_event_t *destroy_notify = xcb_destroy_notify_event_t *destroy_notify =
(xcb_destroy_notify_event_t *) event; (xcb_destroy_notify_event_t *) event;
struct wlsc_wm_window *window; struct weston_wm_window *window;
fprintf(stderr, "XCB_DESTROY_NOTIFY, win %d\n", fprintf(stderr, "XCB_DESTROY_NOTIFY, win %d\n",
destroy_notify->window); destroy_notify->window);
@ -1036,7 +1036,7 @@ wlsc_wm_handle_destroy_notify(struct wlsc_wm *wm, xcb_generic_event_t *event)
} }
static void static void
wlsc_wm_handle_selection_notify(struct wlsc_wm *wm, weston_wm_handle_selection_notify(struct weston_wm *wm,
xcb_generic_event_t *event) xcb_generic_event_t *event)
{ {
xcb_selection_notify_event_t *selection_notify = xcb_selection_notify_event_t *selection_notify =
@ -1045,14 +1045,14 @@ wlsc_wm_handle_selection_notify(struct wlsc_wm *wm,
if (selection_notify->property == XCB_ATOM_NONE) { if (selection_notify->property == XCB_ATOM_NONE) {
/* convert selection failed */ /* convert selection failed */
} else if (selection_notify->target == wm->atom.targets) { } else if (selection_notify->target == wm->atom.targets) {
wlsc_wm_get_selection_targets(wm); weston_wm_get_selection_targets(wm);
} else { } else {
wlsc_wm_get_selection_data(wm); weston_wm_get_selection_data(wm);
} }
} }
static void static void
wlsc_wm_handle_xfixes_selection_notify(struct wlsc_wm *wm, weston_wm_handle_xfixes_selection_notify(struct weston_wm *wm,
xcb_generic_event_t *event) xcb_generic_event_t *event)
{ {
xcb_xfixes_selection_notify_event_t *xfixes_selection_notify = xcb_xfixes_selection_notify_event_t *xfixes_selection_notify =
@ -1080,52 +1080,52 @@ wlsc_wm_handle_xfixes_selection_notify(struct wlsc_wm *wm,
} }
static int static int
wlsc_wm_handle_event(int fd, uint32_t mask, void *data) weston_wm_handle_event(int fd, uint32_t mask, void *data)
{ {
struct wlsc_wm *wm = data; struct weston_wm *wm = data;
xcb_generic_event_t *event; xcb_generic_event_t *event;
int count = 0; int count = 0;
while (event = xcb_poll_for_event(wm->conn), event != NULL) { while (event = xcb_poll_for_event(wm->conn), event != NULL) {
switch (event->response_type & ~0x80) { switch (event->response_type & ~0x80) {
case XCB_CREATE_NOTIFY: case XCB_CREATE_NOTIFY:
wlsc_wm_handle_create_notify(wm, event); weston_wm_handle_create_notify(wm, event);
break; break;
case XCB_MAP_REQUEST: case XCB_MAP_REQUEST:
wlsc_wm_handle_map_request(wm, event); weston_wm_handle_map_request(wm, event);
break; break;
case XCB_MAP_NOTIFY: case XCB_MAP_NOTIFY:
wlsc_wm_handle_map_notify(wm, event); weston_wm_handle_map_notify(wm, event);
break; break;
case XCB_UNMAP_NOTIFY: case XCB_UNMAP_NOTIFY:
fprintf(stderr, "XCB_UNMAP_NOTIFY\n"); fprintf(stderr, "XCB_UNMAP_NOTIFY\n");
break; break;
case XCB_CONFIGURE_REQUEST: case XCB_CONFIGURE_REQUEST:
wlsc_wm_handle_configure_request(wm, event); weston_wm_handle_configure_request(wm, event);
break; break;
case XCB_CONFIGURE_NOTIFY: case XCB_CONFIGURE_NOTIFY:
wlsc_wm_handle_configure_notify(wm, event); weston_wm_handle_configure_notify(wm, event);
break; break;
case XCB_DESTROY_NOTIFY: case XCB_DESTROY_NOTIFY:
wlsc_wm_handle_destroy_notify(wm, event); weston_wm_handle_destroy_notify(wm, event);
break; break;
case XCB_MAPPING_NOTIFY: case XCB_MAPPING_NOTIFY:
fprintf(stderr, "XCB_MAPPING_NOTIFY\n"); fprintf(stderr, "XCB_MAPPING_NOTIFY\n");
break; break;
case XCB_PROPERTY_NOTIFY: case XCB_PROPERTY_NOTIFY:
wlsc_wm_handle_property_notify(wm, event); weston_wm_handle_property_notify(wm, event);
break; break;
case XCB_SELECTION_NOTIFY: case XCB_SELECTION_NOTIFY:
wlsc_wm_handle_selection_notify(wm, event); weston_wm_handle_selection_notify(wm, event);
break; break;
case XCB_SELECTION_REQUEST: case XCB_SELECTION_REQUEST:
wlsc_wm_handle_selection_request(wm, event); weston_wm_handle_selection_request(wm, event);
break; break;
} }
switch (event->response_type - wm->xfixes->first_event) { switch (event->response_type - wm->xfixes->first_event) {
case XCB_XFIXES_SELECTION_NOTIFY: case XCB_XFIXES_SELECTION_NOTIFY:
wlsc_wm_handle_xfixes_selection_notify(wm, event); weston_wm_handle_xfixes_selection_notify(wm, event);
break; break;
} }
@ -1140,10 +1140,10 @@ wlsc_wm_handle_event(int fd, uint32_t mask, void *data)
} }
static void static void
wxs_wm_get_resources(struct wlsc_wm *wm) wxs_wm_get_resources(struct weston_wm *wm)
{ {
#define F(field) offsetof(struct wlsc_wm, field) #define F(field) offsetof(struct weston_wm, field)
static const struct { const char *name; int offset; } atoms[] = { static const struct { const char *name; int offset; } atoms[] = {
{ "WM_PROTOCOLS", F(atom.wm_protocols) }, { "WM_PROTOCOLS", F(atom.wm_protocols) },
@ -1206,10 +1206,10 @@ wxs_wm_get_resources(struct wlsc_wm *wm)
free(xfixes_reply); free(xfixes_reply);
} }
static struct wlsc_wm * static struct weston_wm *
wlsc_wm_create(struct wlsc_xserver *wxs) weston_wm_create(struct weston_xserver *wxs)
{ {
struct wlsc_wm *wm; struct weston_wm *wm;
struct wl_event_loop *loop; struct wl_event_loop *loop;
xcb_screen_iterator_t s; xcb_screen_iterator_t s;
uint32_t values[1], mask; uint32_t values[1], mask;
@ -1254,7 +1254,7 @@ wlsc_wm_create(struct wlsc_xserver *wxs)
wm->source = wm->source =
wl_event_loop_add_fd(loop, sv[0], wl_event_loop_add_fd(loop, sv[0],
WL_EVENT_READABLE, WL_EVENT_READABLE,
wlsc_wm_handle_event, wm); weston_wm_handle_event, wm);
wl_event_source_check(wm->source); wl_event_source_check(wm->source);
wxs_wm_get_resources(wm); wxs_wm_get_resources(wm);
@ -1297,7 +1297,7 @@ wlsc_wm_create(struct wlsc_xserver *wxs)
} }
static void static void
wlsc_wm_destroy(struct wlsc_wm *wm) weston_wm_destroy(struct weston_wm *wm)
{ {
/* FIXME: Free windows in hash. */ /* FIXME: Free windows in hash. */
hash_table_destroy(wm->window_hash); hash_table_destroy(wm->window_hash);
@ -1307,9 +1307,9 @@ wlsc_wm_destroy(struct wlsc_wm *wm)
} }
static int static int
wlsc_xserver_handle_event(int listen_fd, uint32_t mask, void *data) weston_xserver_handle_event(int listen_fd, uint32_t mask, void *data)
{ {
struct wlsc_xserver *mxs = data; struct weston_xserver *mxs = data;
char display[8], s[8], logfile[32]; char display[8], s[8], logfile[32];
int sv[2], flags; int sv[2], flags;
@ -1353,7 +1353,7 @@ wlsc_xserver_handle_event(int listen_fd, uint32_t mask, void *data)
close(sv[1]); close(sv[1]);
mxs->client = wl_client_create(mxs->wl_display, sv[0]); mxs->client = wl_client_create(mxs->wl_display, sv[0]);
wlsc_watch_process(&mxs->process); weston_watch_process(&mxs->process);
wl_event_source_remove(mxs->abstract_source); wl_event_source_remove(mxs->abstract_source);
wl_event_source_remove(mxs->unix_source); wl_event_source_remove(mxs->unix_source);
@ -1368,7 +1368,7 @@ wlsc_xserver_handle_event(int listen_fd, uint32_t mask, void *data)
} }
static void static void
wlsc_xserver_shutdown(struct wlsc_xserver *wxs) weston_xserver_shutdown(struct weston_xserver *wxs)
{ {
char path[256]; char path[256];
@ -1383,15 +1383,15 @@ wlsc_xserver_shutdown(struct wlsc_xserver *wxs)
close(wxs->abstract_fd); close(wxs->abstract_fd);
close(wxs->unix_fd); close(wxs->unix_fd);
if (wxs->wm) if (wxs->wm)
wlsc_wm_destroy(wxs->wm); weston_wm_destroy(wxs->wm);
wxs->loop = NULL; wxs->loop = NULL;
} }
static void static void
wlsc_xserver_cleanup(struct wlsc_process *process, int status) weston_xserver_cleanup(struct weston_process *process, int status)
{ {
struct wlsc_xserver *mxs = struct weston_xserver *mxs =
container_of(process, struct wlsc_xserver, process); container_of(process, struct weston_xserver, process);
mxs->process.pid = 0; mxs->process.pid = 0;
mxs->client = NULL; mxs->client = NULL;
@ -1400,23 +1400,23 @@ wlsc_xserver_cleanup(struct wlsc_process *process, int status)
mxs->abstract_source = mxs->abstract_source =
wl_event_loop_add_fd(mxs->loop, mxs->abstract_fd, wl_event_loop_add_fd(mxs->loop, mxs->abstract_fd,
WL_EVENT_READABLE, WL_EVENT_READABLE,
wlsc_xserver_handle_event, mxs); weston_xserver_handle_event, mxs);
mxs->unix_source = mxs->unix_source =
wl_event_loop_add_fd(mxs->loop, mxs->unix_fd, wl_event_loop_add_fd(mxs->loop, mxs->unix_fd,
WL_EVENT_READABLE, WL_EVENT_READABLE,
wlsc_xserver_handle_event, mxs); weston_xserver_handle_event, mxs);
if (mxs->wm) { if (mxs->wm) {
fprintf(stderr, "xserver exited, code %d\n", status); fprintf(stderr, "xserver exited, code %d\n", status);
wlsc_wm_destroy(mxs->wm); weston_wm_destroy(mxs->wm);
mxs->wm = NULL; mxs->wm = NULL;
} else { } else {
/* If the X server crashes before it binds to the /* If the X server crashes before it binds to the
* xserver interface, shut down and don't try * xserver interface, shut down and don't try
* again. */ * again. */
fprintf(stderr, "xserver crashing too fast: %d\n", status); fprintf(stderr, "xserver crashing too fast: %d\n", status);
wlsc_xserver_shutdown(mxs); weston_xserver_shutdown(mxs);
} }
} }
@ -1424,15 +1424,15 @@ static void
surface_destroy(struct wl_listener *listener, surface_destroy(struct wl_listener *listener,
struct wl_resource *resource, uint32_t time) struct wl_resource *resource, uint32_t time)
{ {
struct wlsc_wm_window *window = struct weston_wm_window *window =
container_of(listener, container_of(listener,
struct wlsc_wm_window, surface_destroy_listener); struct weston_wm_window, surface_destroy_listener);
fprintf(stderr, "surface for xid %d destroyed\n", window->id); fprintf(stderr, "surface for xid %d destroyed\n", window->id);
} }
static struct wlsc_wm_window * static struct weston_wm_window *
get_wm_window(struct wlsc_surface *surface) get_wm_window(struct weston_surface *surface)
{ {
struct wl_resource *resource = &surface->surface.resource; struct wl_resource *resource = &surface->surface.resource;
struct wl_listener *listener; struct wl_listener *listener;
@ -1440,7 +1440,7 @@ get_wm_window(struct wlsc_surface *surface)
wl_list_for_each(listener, &resource->destroy_listener_list, link) { wl_list_for_each(listener, &resource->destroy_listener_list, link) {
if (listener->func == surface_destroy) if (listener->func == surface_destroy)
return container_of(listener, return container_of(listener,
struct wlsc_wm_window, struct weston_wm_window,
surface_destroy_listener); surface_destroy_listener);
} }
@ -1451,10 +1451,10 @@ static void
xserver_set_window_id(struct wl_client *client, struct wl_resource *resource, xserver_set_window_id(struct wl_client *client, struct wl_resource *resource,
struct wl_resource *surface_resource, uint32_t id) struct wl_resource *surface_resource, uint32_t id)
{ {
struct wlsc_xserver *wxs = resource->data; struct weston_xserver *wxs = resource->data;
struct wlsc_wm *wm = wxs->wm; struct weston_wm *wm = wxs->wm;
struct wl_surface *surface = surface_resource->data; struct wl_surface *surface = surface_resource->data;
struct wlsc_wm_window *window; struct weston_wm_window *window;
if (client != wxs->client) if (client != wxs->client)
return; return;
@ -1467,7 +1467,7 @@ xserver_set_window_id(struct wl_client *client, struct wl_resource *resource,
fprintf(stderr, "set_window_id %d for surface %p\n", id, surface); fprintf(stderr, "set_window_id %d for surface %p\n", id, surface);
window->surface = (struct wlsc_surface *) surface; window->surface = (struct weston_surface *) surface;
window->surface_destroy_listener.func = surface_destroy; window->surface_destroy_listener.func = surface_destroy;
wl_list_insert(surface->resource.destroy_listener_list.prev, wl_list_insert(surface->resource.destroy_listener_list.prev,
&window->surface_destroy_listener.link); &window->surface_destroy_listener.link);
@ -1481,7 +1481,7 @@ static void
bind_xserver(struct wl_client *client, bind_xserver(struct wl_client *client,
void *data, uint32_t version, uint32_t id) void *data, uint32_t version, uint32_t id)
{ {
struct wlsc_xserver *wxs = data; struct weston_xserver *wxs = data;
/* If it's a different client than the xserver we launched, /* If it's a different client than the xserver we launched,
* don't start the wm. */ * don't start the wm. */
@ -1492,7 +1492,7 @@ bind_xserver(struct wl_client *client,
wl_client_add_object(client, &xserver_interface, wl_client_add_object(client, &xserver_interface,
&xserver_implementation, id, wxs); &xserver_implementation, id, wxs);
wxs->wm = wlsc_wm_create(wxs); wxs->wm = weston_wm_create(wxs);
if (wxs->wm == NULL) { if (wxs->wm == NULL) {
fprintf(stderr, "failed to create wm\n"); fprintf(stderr, "failed to create wm\n");
} }
@ -1624,16 +1624,16 @@ create_lockfile(int display, char *lockfile, size_t lsize)
} }
int int
wlsc_xserver_init(struct wlsc_compositor *compositor) weston_xserver_init(struct weston_compositor *compositor)
{ {
struct wl_display *display = compositor->wl_display; struct wl_display *display = compositor->wl_display;
struct wlsc_xserver *mxs; struct weston_xserver *mxs;
char lockfile[256]; char lockfile[256];
mxs = malloc(sizeof *mxs); mxs = malloc(sizeof *mxs);
memset(mxs, 0, sizeof *mxs); memset(mxs, 0, sizeof *mxs);
mxs->process.cleanup = wlsc_xserver_cleanup; mxs->process.cleanup = weston_xserver_cleanup;
mxs->wl_display = display; mxs->wl_display = display;
mxs->compositor = compositor; mxs->compositor = compositor;
@ -1673,11 +1673,11 @@ wlsc_xserver_init(struct wlsc_compositor *compositor)
mxs->abstract_source = mxs->abstract_source =
wl_event_loop_add_fd(mxs->loop, mxs->abstract_fd, wl_event_loop_add_fd(mxs->loop, mxs->abstract_fd,
WL_EVENT_READABLE, WL_EVENT_READABLE,
wlsc_xserver_handle_event, mxs); weston_xserver_handle_event, mxs);
mxs->unix_source = mxs->unix_source =
wl_event_loop_add_fd(mxs->loop, mxs->unix_fd, wl_event_loop_add_fd(mxs->loop, mxs->unix_fd,
WL_EVENT_READABLE, WL_EVENT_READABLE,
wlsc_xserver_handle_event, mxs); weston_xserver_handle_event, mxs);
wl_display_add_global(display, &xserver_interface, mxs, bind_xserver); wl_display_add_global(display, &xserver_interface, mxs, bind_xserver);
@ -1687,15 +1687,15 @@ wlsc_xserver_init(struct wlsc_compositor *compositor)
} }
void void
wlsc_xserver_destroy(struct wlsc_compositor *compositor) weston_xserver_destroy(struct weston_compositor *compositor)
{ {
struct wlsc_xserver *wxs = compositor->wxs; struct weston_xserver *wxs = compositor->wxs;
if (!wxs) if (!wxs)
return; return;
if (wxs->loop) if (wxs->loop)
wlsc_xserver_shutdown(wxs); weston_xserver_shutdown(wxs);
free(wxs); free(wxs);
} }
Loading…
Cancel
Save