compositor: The compositor is now jiust a regular global object

We have to provide our own bind callback and add a wlsc_compositor pointer
to wlsc_input_device, but on the whole it's nice cleanup.
dev
Kristian Høgsberg 13 years ago
parent 6b5fc3bac0
commit a8873120c4
  1. 39
      compositor/compositor.c
  2. 3
      compositor/compositor.h
  3. 10
      compositor/evdev.c
  4. 6
      compositor/shell.c

@ -1230,8 +1230,7 @@ WL_EXPORT void
wlsc_input_device_set_pointer_image(struct wlsc_input_device *device,
enum wlsc_pointer_type type)
{
struct wlsc_compositor *compositor =
(struct wlsc_compositor *) device->input_device.compositor;
struct wlsc_compositor *compositor = device->compositor;
wlsc_input_device_attach_sprite(device,
compositor->pointer_sprites[type],
@ -1278,8 +1277,8 @@ wlsc_surface_transform(struct wlsc_surface *surface,
WL_EXPORT struct wlsc_surface *
pick_surface(struct wl_input_device *device, int32_t *sx, int32_t *sy)
{
struct wlsc_compositor *ec =
(struct wlsc_compositor *) device->compositor;
struct wlsc_input_device *wd = (struct wlsc_input_device *) device;
struct wlsc_compositor *ec = wd->compositor;
struct wlsc_surface *es;
wl_list_for_each(es, &ec->surface_list, link) {
@ -1388,11 +1387,10 @@ WL_EXPORT void
notify_motion(struct wl_input_device *device, uint32_t time, int x, int y)
{
struct wlsc_surface *es;
struct wlsc_compositor *ec =
(struct wlsc_compositor *) device->compositor;
struct wlsc_output *output;
const struct wl_grab_interface *interface;
struct wlsc_input_device *wd = (struct wlsc_input_device *) device;
struct wlsc_compositor *ec = wd->compositor;
int32_t sx, sy;
int x_valid = 0, y_valid = 0;
int min_x = INT_MAX, min_y = INT_MAX, max_x = INT_MIN, max_y = INT_MIN;
@ -1487,8 +1485,7 @@ notify_button(struct wl_input_device *device,
uint32_t time, int32_t button, int32_t state)
{
struct wlsc_input_device *wd = (struct wlsc_input_device *) device;
struct wlsc_compositor *compositor =
(struct wlsc_compositor *) device->compositor;
struct wlsc_compositor *compositor = wd->compositor;
struct wlsc_binding *b;
struct wlsc_surface *surface =
(struct wlsc_surface *) device->pointer_focus;
@ -1605,8 +1602,7 @@ notify_key(struct wl_input_device *device,
uint32_t time, uint32_t key, uint32_t state)
{
struct wlsc_input_device *wd = (struct wlsc_input_device *) device;
struct wlsc_compositor *compositor =
(struct wlsc_compositor *) device->compositor;
struct wlsc_compositor *compositor = wd->compositor;
uint32_t *k, *end;
struct wlsc_binding *b;
@ -1647,8 +1643,7 @@ notify_pointer_focus(struct wl_input_device *device,
int32_t x, int32_t y)
{
struct wlsc_input_device *wd = (struct wlsc_input_device *) device;
struct wlsc_compositor *compositor =
(struct wlsc_compositor *) device->compositor;
struct wlsc_compositor *compositor = wd->compositor;
struct wlsc_surface *es;
int32_t sx, sy;
@ -1680,8 +1675,7 @@ notify_keyboard_focus(struct wl_input_device *device,
{
struct wlsc_input_device *wd =
(struct wlsc_input_device *) device;
struct wlsc_compositor *compositor =
(struct wlsc_compositor *) device->compositor;
struct wlsc_compositor *compositor = wd->compositor;
struct wlsc_surface *es;
uint32_t *k, *end;
@ -1768,7 +1762,7 @@ WL_EXPORT void
wlsc_input_device_init(struct wlsc_input_device *device,
struct wlsc_compositor *ec)
{
wl_input_device_init(&device->input_device, &ec->compositor);
wl_input_device_init(&device->input_device);
wl_display_add_global(ec->wl_display, &wl_input_device_interface,
device, bind_input_device);
@ -1778,6 +1772,7 @@ wlsc_input_device_init(struct wlsc_input_device *device,
device->input_device.y, 32, 32);
wl_list_insert(&ec->surface_list, &device->sprite->link);
device->compositor = ec;
device->hotspot_x = 16;
device->hotspot_y = 16;
device->modifier_state = 0;
@ -2042,6 +2037,16 @@ const static struct wl_shm_callbacks shm_callbacks = {
shm_buffer_destroyed
};
static void
compositor_bind(struct wl_client *client,
void *data, uint32_t version, uint32_t id)
{
struct wlsc_compositor *compositor = data;
wl_client_add_object(client, &wl_compositor_interface,
&compositor_interface, id, compositor);
}
WL_EXPORT int
wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display)
{
@ -2050,7 +2055,9 @@ wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display)
ec->wl_display = display;
wl_compositor_init(&ec->compositor, &compositor_interface, display);
if (!wl_display_add_global(display, &wl_compositor_interface,
ec, compositor_bind))
return -1;
ec->shm = wl_shm_init(display, &shm_callbacks);

@ -106,6 +106,7 @@ enum wlsc_pointer_type {
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;
@ -173,8 +174,6 @@ enum {
};
struct wlsc_compositor {
struct wl_compositor compositor;
struct wl_shm *shm;
struct wlsc_xserver *wxs;

@ -226,8 +226,7 @@ evdev_input_device_data(int fd, uint32_t mask, void *data)
struct evdev_motion_accumulator accumulator;
uint32_t time;
ec = (struct wlsc_compositor *)
device->master->base.input_device.compositor;
ec = device->master->base.compositor;
if (!ec->focus)
return 1;
@ -344,7 +343,7 @@ evdev_input_device_create(struct evdev_input *master,
if (device == NULL)
return NULL;
ec = (struct wlsc_compositor *) master->base.input_device.compositor;
ec = master->base.compositor;
device->output =
container_of(ec->output_list.next, struct wlsc_output, link);
@ -394,7 +393,7 @@ device_added(struct udev_device *udev_device, struct evdev_input *master)
if (strcmp(device_seat, master->seat_id))
return;
c = (struct wlsc_compositor *) master->base.input_device.compositor;
c = master->base.compositor;
devnode = udev_device_get_devnode(udev_device);
if (evdev_input_device_create(master, c->wl_display, devnode))
fprintf(stderr, "evdev input device: added: %s\n", devnode);
@ -450,8 +449,7 @@ static int
evdev_config_udev_monitor(struct udev *udev, struct evdev_input *master)
{
struct wl_event_loop *loop;
struct wlsc_compositor *c =
(struct wlsc_compositor *) master->base.input_device.compositor;
struct wlsc_compositor *c = master->base.compositor;
master->udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
if (!master->udev_monitor)

@ -660,8 +660,7 @@ selection_activate(struct wl_client *client,
struct wl_selection *selection = resource->data;
struct wlsc_input_device *wd = input_resource->data;
struct wl_display *display = wl_client_get_display (client);
struct wlsc_compositor *compositor =
(struct wlsc_compositor *) wd->input_device.compositor;
struct wlsc_compositor *compositor = wd->compositor;
selection->input_device = &wd->input_device;
@ -702,8 +701,7 @@ destroy_selection(struct wl_resource *resource)
container_of(resource, struct wl_selection, resource);
struct wlsc_input_device *wd =
(struct wlsc_input_device *) selection->input_device;
struct wlsc_compositor *compositor =
(struct wlsc_compositor *) wd->input_device.compositor;
struct wlsc_compositor *compositor = wd->compositor;
if (wd && wd->selection == selection) {
wd->selection = NULL;

Loading…
Cancel
Save