mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-15 06:59:49 -05:00
Chage the 'base' field to be the name of the super class instead
Instead of display->base.base we want display->proxy.object, or
buffer->buffer.resource.object.id = id;
which makes it clear what we end up addressing.
This commit is contained in:
parent
b71cd9e31d
commit
b313b02983
7 changed files with 212 additions and 206 deletions
|
|
@ -157,7 +157,7 @@ static void
|
||||||
destroy_surface(struct wl_resource *resource, struct wl_client *client)
|
destroy_surface(struct wl_resource *resource, struct wl_client *client)
|
||||||
{
|
{
|
||||||
struct wlsc_surface *surface =
|
struct wlsc_surface *surface =
|
||||||
container_of(resource, struct wlsc_surface, base.base);
|
container_of(resource, struct wlsc_surface, surface.resource);
|
||||||
struct wlsc_compositor *compositor = surface->compositor;
|
struct wlsc_compositor *compositor = surface->compositor;
|
||||||
struct wlsc_listener *l;
|
struct wlsc_listener *l;
|
||||||
|
|
||||||
|
|
@ -400,7 +400,7 @@ static void
|
||||||
surface_destroy(struct wl_client *client,
|
surface_destroy(struct wl_client *client,
|
||||||
struct wl_surface *surface)
|
struct wl_surface *surface)
|
||||||
{
|
{
|
||||||
wl_resource_destroy(&surface->base, client);
|
wl_resource_destroy(&surface->resource, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -453,7 +453,7 @@ wlsc_input_device_attach(struct wlsc_input_device *device,
|
||||||
{
|
{
|
||||||
struct wlsc_compositor *ec = device->ec;
|
struct wlsc_compositor *ec = device->ec;
|
||||||
|
|
||||||
buffer->attach(buffer, &device->sprite->base);
|
buffer->attach(buffer, &device->sprite->surface);
|
||||||
device->hotspot_x = x;
|
device->hotspot_x = x;
|
||||||
device->hotspot_y = y;
|
device->hotspot_y = y;
|
||||||
|
|
||||||
|
|
@ -474,7 +474,7 @@ wlsc_input_device_set_pointer_image(struct wlsc_input_device *device,
|
||||||
struct wlsc_compositor *compositor = device->ec;
|
struct wlsc_compositor *compositor = device->ec;
|
||||||
|
|
||||||
wlsc_input_device_attach(device,
|
wlsc_input_device_attach(device,
|
||||||
&compositor->pointer_buffers[type]->base,
|
&compositor->pointer_buffers[type]->buffer,
|
||||||
pointer_images[type].hotspot_x,
|
pointer_images[type].hotspot_x,
|
||||||
pointer_images[type].hotspot_y);
|
pointer_images[type].hotspot_y);
|
||||||
}
|
}
|
||||||
|
|
@ -485,7 +485,7 @@ wlsc_input_device_start_grab(struct wlsc_input_device *device,
|
||||||
enum wlsc_grab_type grab)
|
enum wlsc_grab_type grab)
|
||||||
{
|
{
|
||||||
struct wlsc_surface *focus =
|
struct wlsc_surface *focus =
|
||||||
(struct wlsc_surface *) device->base.pointer_focus;
|
(struct wlsc_surface *) device->input_device.pointer_focus;
|
||||||
|
|
||||||
device->grab = grab;
|
device->grab = grab;
|
||||||
device->grab_surface = focus;
|
device->grab_surface = focus;
|
||||||
|
|
@ -494,7 +494,7 @@ wlsc_input_device_start_grab(struct wlsc_input_device *device,
|
||||||
device->grab_width = focus->width;
|
device->grab_width = focus->width;
|
||||||
device->grab_height = focus->height;
|
device->grab_height = focus->height;
|
||||||
|
|
||||||
wl_input_device_set_pointer_focus(&device->base,
|
wl_input_device_set_pointer_focus(&device->input_device,
|
||||||
&wl_grab_surface, time, 0, 0, 0, 0);
|
&wl_grab_surface, time, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -507,7 +507,7 @@ shell_move(struct wl_client *client, struct wl_shell *shell,
|
||||||
|
|
||||||
if (wd->grab != WLSC_DEVICE_GRAB_MOTION ||
|
if (wd->grab != WLSC_DEVICE_GRAB_MOTION ||
|
||||||
wd->grab_time != time ||
|
wd->grab_time != time ||
|
||||||
wd->base.pointer_focus != surface)
|
wd->input_device.pointer_focus != surface)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wlsc_input_device_start_grab(wd, time, WLSC_DEVICE_GRAB_MOVE);
|
wlsc_input_device_start_grab(wd, time, WLSC_DEVICE_GRAB_MOVE);
|
||||||
|
|
@ -528,7 +528,7 @@ shell_resize(struct wl_client *client, struct wl_shell *shell,
|
||||||
|
|
||||||
if (wd->grab != WLSC_DEVICE_GRAB_MOTION ||
|
if (wd->grab != WLSC_DEVICE_GRAB_MOTION ||
|
||||||
wd->grab_time != time ||
|
wd->grab_time != time ||
|
||||||
wd->base.pointer_focus != surface)
|
wd->input_device.pointer_focus != surface)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (edges) {
|
switch (edges) {
|
||||||
|
|
@ -603,7 +603,7 @@ drag_handle_surface_destroy(struct wlsc_listener *listener,
|
||||||
container_of(listener, struct wlsc_drag, listener);
|
container_of(listener, struct wlsc_drag, listener);
|
||||||
uint32_t time = get_time();
|
uint32_t time = get_time();
|
||||||
|
|
||||||
if (drag->drag.pointer_focus == &surface->base)
|
if (drag->drag.pointer_focus == &surface->surface)
|
||||||
wl_drag_set_pointer_focus(&drag->drag, NULL, time, 0, 0, 0, 0);
|
wl_drag_set_pointer_focus(&drag->drag, NULL, time, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -622,9 +622,9 @@ shell_create_drag(struct wl_client *client,
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(drag, 0, sizeof *drag);
|
memset(drag, 0, sizeof *drag);
|
||||||
drag->drag.resource.base.id = id;
|
drag->drag.resource.object.id = id;
|
||||||
drag->drag.resource.base.interface = &wl_drag_interface;
|
drag->drag.resource.object.interface = &wl_drag_interface;
|
||||||
drag->drag.resource.base.implementation =
|
drag->drag.resource.object.implementation =
|
||||||
(void (**)(void)) &drag_interface;
|
(void (**)(void)) &drag_interface;
|
||||||
|
|
||||||
drag->drag.resource.destroy = destroy_drag;
|
drag->drag.resource.destroy = destroy_drag;
|
||||||
|
|
@ -656,15 +656,15 @@ compositor_create_surface(struct wl_client *client,
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_list_insert(ec->surface_list.prev, &surface->link);
|
wl_list_insert(ec->surface_list.prev, &surface->link);
|
||||||
surface->base.base.destroy = destroy_surface;
|
surface->surface.resource.destroy = destroy_surface;
|
||||||
|
|
||||||
surface->base.base.base.id = id;
|
surface->surface.resource.object.id = id;
|
||||||
surface->base.base.base.interface = &wl_surface_interface;
|
surface->surface.resource.object.interface = &wl_surface_interface;
|
||||||
surface->base.base.base.implementation =
|
surface->surface.resource.object.implementation =
|
||||||
(void (**)(void)) &surface_interface;
|
(void (**)(void)) &surface_interface;
|
||||||
surface->base.client = client;
|
surface->surface.client = client;
|
||||||
|
|
||||||
wl_client_add_resource(client, &surface->base.base);
|
wl_client_add_resource(client, &surface->surface.resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
const static struct wl_compositor_interface compositor_interface = {
|
const static struct wl_compositor_interface compositor_interface = {
|
||||||
|
|
@ -723,20 +723,21 @@ notify_motion(struct wlsc_input_device *device, uint32_t time, int x, int y)
|
||||||
switch (device->grab) {
|
switch (device->grab) {
|
||||||
case WLSC_DEVICE_GRAB_NONE:
|
case WLSC_DEVICE_GRAB_NONE:
|
||||||
es = pick_surface(device, &sx, &sy);
|
es = pick_surface(device, &sx, &sy);
|
||||||
wl_input_device_set_pointer_focus(&device->base, &es->base,
|
wl_input_device_set_pointer_focus(&device->input_device,
|
||||||
|
&es->surface,
|
||||||
time, x, y, sx, sy);
|
time, x, y, sx, sy);
|
||||||
if (es)
|
if (es)
|
||||||
wl_client_post_event(es->base.client,
|
wl_client_post_event(es->surface.client,
|
||||||
&device->base.base,
|
&device->input_device.object,
|
||||||
WL_INPUT_DEVICE_MOTION,
|
WL_INPUT_DEVICE_MOTION,
|
||||||
time, x, y, sx, sy);
|
time, x, y, sx, sy);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WLSC_DEVICE_GRAB_MOTION:
|
case WLSC_DEVICE_GRAB_MOTION:
|
||||||
es = (struct wlsc_surface *) device->base.pointer_focus;
|
es = (struct wlsc_surface *) device->input_device.pointer_focus;
|
||||||
wlsc_surface_transform(es, x, y, &sx, &sy);
|
wlsc_surface_transform(es, x, y, &sx, &sy);
|
||||||
wl_client_post_event(es->base.client,
|
wl_client_post_event(es->surface.client,
|
||||||
&device->base.base,
|
&device->input_device.object,
|
||||||
WL_INPUT_DEVICE_MOTION,
|
WL_INPUT_DEVICE_MOTION,
|
||||||
time, x, y, sx, sy);
|
time, x, y, sx, sy);
|
||||||
break;
|
break;
|
||||||
|
|
@ -745,11 +746,11 @@ notify_motion(struct wlsc_input_device *device, uint32_t time, int x, int y)
|
||||||
es = device->grab_surface;
|
es = device->grab_surface;
|
||||||
es->x = x + device->grab_dx;
|
es->x = x + device->grab_dx;
|
||||||
es->y = y + device->grab_dy;;
|
es->y = y + device->grab_dy;;
|
||||||
wl_client_post_event(es->base.client,
|
wl_client_post_event(es->surface.client,
|
||||||
&ec->shell.base,
|
&ec->shell.object,
|
||||||
WL_SHELL_CONFIGURE,
|
WL_SHELL_CONFIGURE,
|
||||||
time, device->grab,
|
time, device->grab,
|
||||||
&es->base, es->x, es->y,
|
&es->surface, es->x, es->y,
|
||||||
es->width, es->height);
|
es->width, es->height);
|
||||||
|
|
||||||
wlsc_surface_update_matrix(es);
|
wlsc_surface_update_matrix(es);
|
||||||
|
|
@ -789,10 +790,10 @@ notify_motion(struct wlsc_input_device *device, uint32_t time, int x, int y)
|
||||||
height = device->grab_height;
|
height = device->grab_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_client_post_event(es->base.client,
|
wl_client_post_event(es->surface.client,
|
||||||
&ec->shell.base,
|
&ec->shell.object,
|
||||||
WL_SHELL_CONFIGURE, time, device->grab,
|
WL_SHELL_CONFIGURE, time, device->grab,
|
||||||
&es->base, sx, sy, width, height);
|
&es->surface, sx, sy, width, height);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WLSC_DEVICE_GRAB_DRAG:
|
case WLSC_DEVICE_GRAB_DRAG:
|
||||||
|
|
@ -800,8 +801,8 @@ notify_motion(struct wlsc_input_device *device, uint32_t time, int x, int y)
|
||||||
wl_drag_set_pointer_focus(device->drag,
|
wl_drag_set_pointer_focus(device->drag,
|
||||||
es, time, x, y, sx, sy);
|
es, time, x, y, sx, sy);
|
||||||
if (es)
|
if (es)
|
||||||
wl_client_post_event(es->base.client,
|
wl_client_post_event(es->surface.client,
|
||||||
&device->drag->drag_offer.base,
|
&device->drag->drag_offer.object,
|
||||||
WL_DRAG_OFFER_MOTION,
|
WL_DRAG_OFFER_MOTION,
|
||||||
time, x, y, sx, sy);
|
time, x, y, sx, sy);
|
||||||
break;
|
break;
|
||||||
|
|
@ -826,7 +827,7 @@ wlsc_input_device_end_grab(struct wlsc_input_device *device, uint32_t time)
|
||||||
case WLSC_DEVICE_GRAB_DRAG:
|
case WLSC_DEVICE_GRAB_DRAG:
|
||||||
if (drag->target)
|
if (drag->target)
|
||||||
wl_client_post_event(drag->target,
|
wl_client_post_event(drag->target,
|
||||||
&drag->drag_offer.base,
|
&drag->drag_offer.object,
|
||||||
WL_DRAG_OFFER_DROP);
|
WL_DRAG_OFFER_DROP);
|
||||||
wl_drag_set_pointer_focus(drag, NULL, time, 0, 0, 0, 0);
|
wl_drag_set_pointer_focus(drag, NULL, time, 0, 0, 0, 0);
|
||||||
device->drag = NULL;
|
device->drag = NULL;
|
||||||
|
|
@ -837,7 +838,8 @@ wlsc_input_device_end_grab(struct wlsc_input_device *device, uint32_t time)
|
||||||
|
|
||||||
device->grab = WLSC_DEVICE_GRAB_NONE;
|
device->grab = WLSC_DEVICE_GRAB_NONE;
|
||||||
es = pick_surface(device, &sx, &sy);
|
es = pick_surface(device, &sx, &sy);
|
||||||
wl_input_device_set_pointer_focus(&device->base, &es->base, time,
|
wl_input_device_set_pointer_focus(&device->input_device,
|
||||||
|
&es->surface, time,
|
||||||
device->x, device->y, sx, sy);
|
device->x, device->y, sx, sy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -848,7 +850,7 @@ notify_button(struct wlsc_input_device *device,
|
||||||
struct wlsc_surface *surface;
|
struct wlsc_surface *surface;
|
||||||
struct wlsc_compositor *compositor = device->ec;
|
struct wlsc_compositor *compositor = device->ec;
|
||||||
|
|
||||||
surface = (struct wlsc_surface *) device->base.pointer_focus;
|
surface = (struct wlsc_surface *) device->input_device.pointer_focus;
|
||||||
if (surface) {
|
if (surface) {
|
||||||
if (state && device->grab == WLSC_DEVICE_GRAB_NONE) {
|
if (state && device->grab == WLSC_DEVICE_GRAB_NONE) {
|
||||||
wlsc_surface_raise(surface);
|
wlsc_surface_raise(surface);
|
||||||
|
|
@ -857,27 +859,30 @@ notify_button(struct wlsc_input_device *device,
|
||||||
device->grab_time = time;
|
device->grab_time = time;
|
||||||
device->grab_x = device->x;
|
device->grab_x = device->x;
|
||||||
device->grab_y = device->y;
|
device->grab_y = device->y;
|
||||||
wl_input_device_set_keyboard_focus(&device->base,
|
wl_input_device_set_keyboard_focus(&device->input_device,
|
||||||
&surface->base,
|
&surface->surface,
|
||||||
time);
|
time);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state && button == BTN_LEFT &&
|
if (state && button == BTN_LEFT &&
|
||||||
device->grab == WLSC_DEVICE_GRAB_MOTION &&
|
device->grab == WLSC_DEVICE_GRAB_MOTION &&
|
||||||
(device->modifier_state & MODIFIER_SUPER))
|
(device->modifier_state & MODIFIER_SUPER))
|
||||||
shell_move(NULL, (struct wl_shell *) &compositor->shell,
|
shell_move(NULL,
|
||||||
&surface->base, &device->base, time);
|
(struct wl_shell *) &compositor->shell,
|
||||||
|
&surface->surface,
|
||||||
|
&device->input_device, time);
|
||||||
else if (state && button == BTN_MIDDLE &&
|
else if (state && button == BTN_MIDDLE &&
|
||||||
device->grab == WLSC_DEVICE_GRAB_MOTION &&
|
device->grab == WLSC_DEVICE_GRAB_MOTION &&
|
||||||
(device->modifier_state & MODIFIER_SUPER))
|
(device->modifier_state & MODIFIER_SUPER))
|
||||||
shell_resize(NULL, (struct wl_shell *) &compositor->shell,
|
shell_resize(NULL,
|
||||||
|
(struct wl_shell *) &compositor->shell,
|
||||||
&surface->base, &device->base, time,
|
&surface->surface,
|
||||||
|
&device->input_device, time,
|
||||||
WLSC_DEVICE_GRAB_RESIZE_BOTTOM_RIGHT);
|
WLSC_DEVICE_GRAB_RESIZE_BOTTOM_RIGHT);
|
||||||
else if (device->grab == WLSC_DEVICE_GRAB_NONE ||
|
else if (device->grab == WLSC_DEVICE_GRAB_NONE ||
|
||||||
device->grab == WLSC_DEVICE_GRAB_MOTION)
|
device->grab == WLSC_DEVICE_GRAB_MOTION)
|
||||||
wl_client_post_event(surface->base.client,
|
wl_client_post_event(surface->surface.client,
|
||||||
&device->base.base,
|
&device->input_device.object,
|
||||||
WL_INPUT_DEVICE_BUTTON,
|
WL_INPUT_DEVICE_BUTTON,
|
||||||
time, button, state);
|
time, button, state);
|
||||||
|
|
||||||
|
|
@ -930,20 +935,20 @@ notify_key(struct wlsc_input_device *device,
|
||||||
else
|
else
|
||||||
device->modifier_state &= ~modifier;
|
device->modifier_state &= ~modifier;
|
||||||
|
|
||||||
end = device->base.keys.data + device->base.keys.size;
|
end = device->input_device.keys.data + device->input_device.keys.size;
|
||||||
for (k = device->base.keys.data; k < end; k++) {
|
for (k = device->input_device.keys.data; k < end; k++) {
|
||||||
if (*k == key)
|
if (*k == key)
|
||||||
*k = *--end;
|
*k = *--end;
|
||||||
}
|
}
|
||||||
device->base.keys.size = (void *) end - device->base.keys.data;
|
device->input_device.keys.size = (void *) end - device->input_device.keys.data;
|
||||||
if (state) {
|
if (state) {
|
||||||
k = wl_array_add(&device->base.keys, sizeof *k);
|
k = wl_array_add(&device->input_device.keys, sizeof *k);
|
||||||
*k = key;
|
*k = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device->base.keyboard_focus != NULL)
|
if (device->input_device.keyboard_focus != NULL)
|
||||||
wl_client_post_event(device->base.keyboard_focus->client,
|
wl_client_post_event(device->input_device.keyboard_focus->client,
|
||||||
&device->base.base,
|
&device->input_device.object,
|
||||||
WL_INPUT_DEVICE_KEY, time, key, state);
|
WL_INPUT_DEVICE_KEY, time, key, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -956,14 +961,14 @@ input_device_attach(struct wl_client *client,
|
||||||
struct wlsc_input_device *device =
|
struct wlsc_input_device *device =
|
||||||
(struct wlsc_input_device *) device_base;
|
(struct wlsc_input_device *) device_base;
|
||||||
|
|
||||||
if (time < device->base.pointer_focus_time)
|
if (time < device->input_device.pointer_focus_time)
|
||||||
return;
|
return;
|
||||||
if (device->base.pointer_focus == NULL)
|
if (device->input_device.pointer_focus == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (device->base.pointer_focus->client != client &&
|
if (device->input_device.pointer_focus->client != client &&
|
||||||
!(device->base.pointer_focus == &wl_grab_surface &&
|
!(device->input_device.pointer_focus == &wl_grab_surface &&
|
||||||
device->grab_surface->base.client == client))
|
device->grab_surface->surface.client == client))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
|
|
@ -987,13 +992,13 @@ handle_surface_destroy(struct wlsc_listener *listener,
|
||||||
container_of(listener, struct wlsc_input_device, listener);
|
container_of(listener, struct wlsc_input_device, listener);
|
||||||
uint32_t time = get_time();
|
uint32_t time = get_time();
|
||||||
|
|
||||||
if (device->base.keyboard_focus == &surface->base)
|
if (device->input_device.keyboard_focus == &surface->surface)
|
||||||
wl_input_device_set_keyboard_focus(&device->base, NULL, time);
|
wl_input_device_set_keyboard_focus(&device->input_device, NULL, time);
|
||||||
if (device->base.pointer_focus == &surface->base)
|
if (device->input_device.pointer_focus == &surface->surface)
|
||||||
wl_input_device_set_pointer_focus(&device->base, NULL, time,
|
wl_input_device_set_pointer_focus(&device->input_device, NULL, time,
|
||||||
0, 0, 0, 0);
|
0, 0, 0, 0);
|
||||||
if (device->base.pointer_focus == &surface->base ||
|
if (device->input_device.pointer_focus == &surface->surface ||
|
||||||
(device->base.pointer_focus == &wl_grab_surface &&
|
(device->input_device.pointer_focus == &wl_grab_surface &&
|
||||||
device->grab_surface == surface))
|
device->grab_surface == surface))
|
||||||
wlsc_input_device_end_grab(device, time);
|
wlsc_input_device_end_grab(device, time);
|
||||||
}
|
}
|
||||||
|
|
@ -1005,39 +1010,39 @@ wl_drag_set_pointer_focus(struct wl_drag *drag,
|
||||||
{
|
{
|
||||||
char **p, **end;
|
char **p, **end;
|
||||||
|
|
||||||
if (drag->pointer_focus == &surface->base)
|
if (drag->pointer_focus == &surface->surface)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (drag->pointer_focus &&
|
if (drag->pointer_focus &&
|
||||||
(!surface || drag->pointer_focus->client != surface->base.client))
|
(!surface || drag->pointer_focus->client != surface->surface.client))
|
||||||
wl_client_post_event(drag->pointer_focus->client,
|
wl_client_post_event(drag->pointer_focus->client,
|
||||||
&drag->drag_offer.base,
|
&drag->drag_offer.object,
|
||||||
WL_DRAG_OFFER_POINTER_FOCUS,
|
WL_DRAG_OFFER_POINTER_FOCUS,
|
||||||
time, NULL, 0, 0, 0, 0);
|
time, NULL, 0, 0, 0, 0);
|
||||||
|
|
||||||
if (surface &&
|
if (surface &&
|
||||||
(!drag->pointer_focus ||
|
(!drag->pointer_focus ||
|
||||||
drag->pointer_focus->client != surface->base.client)) {
|
drag->pointer_focus->client != surface->surface.client)) {
|
||||||
wl_client_post_global(surface->base.client,
|
wl_client_post_global(surface->surface.client,
|
||||||
&drag->drag_offer.base);
|
&drag->drag_offer.object);
|
||||||
|
|
||||||
end = drag->types.data + drag->types.size;
|
end = drag->types.data + drag->types.size;
|
||||||
for (p = drag->types.data; p < end; p++)
|
for (p = drag->types.data; p < end; p++)
|
||||||
wl_client_post_event(surface->base.client,
|
wl_client_post_event(surface->surface.client,
|
||||||
&drag->drag_offer.base,
|
&drag->drag_offer.object,
|
||||||
WL_DRAG_OFFER_OFFER, *p);
|
WL_DRAG_OFFER_OFFER, *p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (surface) {
|
if (surface) {
|
||||||
wl_client_post_event(surface->base.client,
|
wl_client_post_event(surface->surface.client,
|
||||||
&drag->drag_offer.base,
|
&drag->drag_offer.object,
|
||||||
WL_DRAG_OFFER_POINTER_FOCUS,
|
WL_DRAG_OFFER_POINTER_FOCUS,
|
||||||
time, &surface->base,
|
time, &surface->surface,
|
||||||
x, y, sx, sy);
|
x, y, sx, sy);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
drag->pointer_focus = &surface->base;
|
drag->pointer_focus = &surface->surface;
|
||||||
drag->pointer_focus_time = time;
|
drag->pointer_focus_time = time;
|
||||||
drag->target = NULL;
|
drag->target = NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -1064,7 +1069,7 @@ drag_offer_accept(struct wl_client *client,
|
||||||
if (type && strcmp(*p, type) == 0)
|
if (type && strcmp(*p, type) == 0)
|
||||||
drag->type = *p;
|
drag->type = *p;
|
||||||
|
|
||||||
wl_client_post_event(drag->source->client, &drag->resource.base,
|
wl_client_post_event(drag->source->client, &drag->resource.object,
|
||||||
WL_DRAG_TARGET, drag->type);
|
WL_DRAG_TARGET, drag->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1074,7 +1079,7 @@ drag_offer_receive(struct wl_client *client,
|
||||||
{
|
{
|
||||||
struct wl_drag *drag = container_of(offer, struct wl_drag, drag_offer);
|
struct wl_drag *drag = container_of(offer, struct wl_drag, drag_offer);
|
||||||
|
|
||||||
wl_client_post_event(drag->source->client, &drag->resource.base,
|
wl_client_post_event(drag->source->client, &drag->resource.object,
|
||||||
WL_DRAG_FINISH, fd);
|
WL_DRAG_FINISH, fd);
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
@ -1084,7 +1089,7 @@ drag_offer_reject(struct wl_client *client, struct wl_drag_offer *offer)
|
||||||
{
|
{
|
||||||
struct wl_drag *drag = container_of(offer, struct wl_drag, drag_offer);
|
struct wl_drag *drag = container_of(offer, struct wl_drag, drag_offer);
|
||||||
|
|
||||||
wl_client_post_event(drag->source->client, &drag->resource.base,
|
wl_client_post_event(drag->source->client, &drag->resource.object,
|
||||||
WL_DRAG_REJECT);
|
WL_DRAG_REJECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1119,18 +1124,18 @@ drag_activate(struct wl_client *client,
|
||||||
int32_t sx, sy;
|
int32_t sx, sy;
|
||||||
|
|
||||||
if (device->grab != WLSC_DEVICE_GRAB_MOTION ||
|
if (device->grab != WLSC_DEVICE_GRAB_MOTION ||
|
||||||
device->base.pointer_focus != surface ||
|
device->input_device.pointer_focus != surface ||
|
||||||
device->grab_time != time)
|
device->grab_time != time)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
drag->source = surface;
|
drag->source = surface;
|
||||||
drag->input_device = input_device;
|
drag->input_device = input_device;
|
||||||
|
|
||||||
drag->drag_offer.base.interface = &wl_drag_offer_interface;
|
drag->drag_offer.object.interface = &wl_drag_offer_interface;
|
||||||
drag->drag_offer.base.implementation =
|
drag->drag_offer.object.implementation =
|
||||||
(void (**)(void)) &drag_offer_interface;
|
(void (**)(void)) &drag_offer_interface;
|
||||||
|
|
||||||
wl_display_add_object(display, &drag->drag_offer.base);
|
wl_display_add_object(display, &drag->drag_offer.object);
|
||||||
|
|
||||||
wlsc_input_device_start_grab(device, time,
|
wlsc_input_device_start_grab(device, time,
|
||||||
WLSC_DEVICE_GRAB_DRAG);
|
WLSC_DEVICE_GRAB_DRAG);
|
||||||
|
|
@ -1164,11 +1169,11 @@ void
|
||||||
wlsc_input_device_init(struct wlsc_input_device *device,
|
wlsc_input_device_init(struct wlsc_input_device *device,
|
||||||
struct wlsc_compositor *ec)
|
struct wlsc_compositor *ec)
|
||||||
{
|
{
|
||||||
device->base.base.interface = &wl_input_device_interface;
|
device->input_device.object.interface = &wl_input_device_interface;
|
||||||
device->base.base.implementation =
|
device->input_device.object.implementation =
|
||||||
(void (**)(void)) &input_device_interface;
|
(void (**)(void)) &input_device_interface;
|
||||||
wl_display_add_object(ec->wl_display, &device->base.base);
|
wl_display_add_object(ec->wl_display, &device->input_device.object);
|
||||||
wl_display_add_global(ec->wl_display, &device->base.base, NULL);
|
wl_display_add_global(ec->wl_display, &device->input_device.object, NULL);
|
||||||
|
|
||||||
device->x = 100;
|
device->x = 100;
|
||||||
device->y = 100;
|
device->y = 100;
|
||||||
|
|
@ -1190,7 +1195,7 @@ static void
|
||||||
wlsc_output_post_geometry(struct wl_client *client, struct wl_object *global)
|
wlsc_output_post_geometry(struct wl_client *client, struct wl_object *global)
|
||||||
{
|
{
|
||||||
struct wlsc_output *output =
|
struct wlsc_output *output =
|
||||||
container_of(global, struct wlsc_output, base);
|
container_of(global, struct wlsc_output, object);
|
||||||
|
|
||||||
wl_client_post_event(client, global,
|
wl_client_post_event(client, global,
|
||||||
WL_OUTPUT_GEOMETRY,
|
WL_OUTPUT_GEOMETRY,
|
||||||
|
|
@ -1304,22 +1309,22 @@ static const struct wl_interface visual_interface = {
|
||||||
static void
|
static void
|
||||||
add_visuals(struct wlsc_compositor *ec)
|
add_visuals(struct wlsc_compositor *ec)
|
||||||
{
|
{
|
||||||
ec->argb_visual.base.interface = &visual_interface;
|
ec->argb_visual.object.interface = &visual_interface;
|
||||||
ec->argb_visual.base.implementation = NULL;
|
ec->argb_visual.object.implementation = NULL;
|
||||||
wl_display_add_object(ec->wl_display, &ec->argb_visual.base);
|
wl_display_add_object(ec->wl_display, &ec->argb_visual.object);
|
||||||
wl_display_add_global(ec->wl_display, &ec->argb_visual.base, NULL);
|
wl_display_add_global(ec->wl_display, &ec->argb_visual.object, NULL);
|
||||||
|
|
||||||
ec->premultiplied_argb_visual.base.interface = &visual_interface;
|
ec->premultiplied_argb_visual.object.interface = &visual_interface;
|
||||||
ec->premultiplied_argb_visual.base.implementation = NULL;
|
ec->premultiplied_argb_visual.object.implementation = NULL;
|
||||||
wl_display_add_object(ec->wl_display,
|
wl_display_add_object(ec->wl_display,
|
||||||
&ec->premultiplied_argb_visual.base);
|
&ec->premultiplied_argb_visual.object);
|
||||||
wl_display_add_global(ec->wl_display,
|
wl_display_add_global(ec->wl_display,
|
||||||
&ec->premultiplied_argb_visual.base, NULL);
|
&ec->premultiplied_argb_visual.object, NULL);
|
||||||
|
|
||||||
ec->rgb_visual.base.interface = &visual_interface;
|
ec->rgb_visual.object.interface = &visual_interface;
|
||||||
ec->rgb_visual.base.implementation = NULL;
|
ec->rgb_visual.object.implementation = NULL;
|
||||||
wl_display_add_object(ec->wl_display, &ec->rgb_visual.base);
|
wl_display_add_object(ec->wl_display, &ec->rgb_visual.object);
|
||||||
wl_display_add_global(ec->wl_display, &ec->rgb_visual.base, NULL);
|
wl_display_add_global(ec->wl_display, &ec->rgb_visual.object, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -1342,9 +1347,9 @@ wlsc_output_init(struct wlsc_output *output, struct wlsc_compositor *c,
|
||||||
wlsc_matrix_scale(&output->matrix,
|
wlsc_matrix_scale(&output->matrix,
|
||||||
2.0 / output->width, 2.0 / output->height, 1);
|
2.0 / output->width, 2.0 / output->height, 1);
|
||||||
|
|
||||||
output->base.interface = &wl_output_interface;
|
output->object.interface = &wl_output_interface;
|
||||||
wl_display_add_object(c->wl_display, &output->base);
|
wl_display_add_object(c->wl_display, &output->object);
|
||||||
wl_display_add_global(c->wl_display, &output->base,
|
wl_display_add_global(c->wl_display, &output->object,
|
||||||
wlsc_output_post_geometry);
|
wlsc_output_post_geometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1355,20 +1360,20 @@ wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display)
|
||||||
|
|
||||||
ec->wl_display = display;
|
ec->wl_display = display;
|
||||||
|
|
||||||
ec->base.base.interface = &wl_compositor_interface;
|
ec->compositor.object.interface = &wl_compositor_interface;
|
||||||
ec->base.base.implementation =
|
ec->compositor.object.implementation =
|
||||||
(void (**)(void)) &compositor_interface;
|
(void (**)(void)) &compositor_interface;
|
||||||
|
|
||||||
wl_display_add_object(display, &ec->base.base);
|
wl_display_add_object(display, &ec->compositor.object);
|
||||||
if (wl_display_add_global(display, &ec->base.base, NULL))
|
if (wl_display_add_global(display, &ec->compositor.object, NULL))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
wlsc_shm_init(ec);
|
wlsc_shm_init(ec);
|
||||||
|
|
||||||
ec->shell.base.interface = &wl_shell_interface;
|
ec->shell.object.interface = &wl_shell_interface;
|
||||||
ec->shell.base.implementation = (void (**)(void)) &shell_interface;
|
ec->shell.object.implementation = (void (**)(void)) &shell_interface;
|
||||||
wl_display_add_object(display, &ec->shell.base);
|
wl_display_add_object(display, &ec->shell.object);
|
||||||
if (wl_display_add_global(display, &ec->shell.base, NULL))
|
if (wl_display_add_global(display, &ec->shell.object, NULL))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
add_visuals(ec);
|
add_visuals(ec);
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ struct wlsc_listener {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlsc_output {
|
struct wlsc_output {
|
||||||
struct wl_object base;
|
struct wl_object object;
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
struct wlsc_compositor *compositor;
|
struct wlsc_compositor *compositor;
|
||||||
struct wlsc_surface *background;
|
struct wlsc_surface *background;
|
||||||
|
|
@ -88,7 +88,7 @@ enum wlsc_pointer_type {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlsc_input_device {
|
struct wlsc_input_device {
|
||||||
struct wl_input_device base;
|
struct wl_input_device input_device;
|
||||||
int32_t x, y;
|
int32_t x, y;
|
||||||
struct wlsc_compositor *ec;
|
struct wlsc_compositor *ec;
|
||||||
struct wlsc_surface *sprite;
|
struct wlsc_surface *sprite;
|
||||||
|
|
@ -110,28 +110,28 @@ struct wlsc_input_device {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlsc_drm {
|
struct wlsc_drm {
|
||||||
struct wl_object base;
|
struct wl_object object;
|
||||||
int fd;
|
int fd;
|
||||||
char *filename;
|
char *filename;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlsc_drm_buffer {
|
struct wlsc_drm_buffer {
|
||||||
struct wl_buffer base;
|
struct wl_buffer buffer;
|
||||||
EGLImageKHR image;
|
EGLImageKHR image;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlsc_shm {
|
struct wlsc_shm {
|
||||||
struct wl_object base;
|
struct wl_object object;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlsc_shm_buffer {
|
struct wlsc_shm_buffer {
|
||||||
struct wl_buffer base;
|
struct wl_buffer buffer;
|
||||||
int32_t stride;
|
int32_t stride;
|
||||||
void *data;
|
void *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlsc_compositor {
|
struct wlsc_compositor {
|
||||||
struct wl_compositor base;
|
struct wl_compositor compositor;
|
||||||
struct wl_visual argb_visual, premultiplied_argb_visual, rgb_visual;
|
struct wl_visual argb_visual, premultiplied_argb_visual, rgb_visual;
|
||||||
|
|
||||||
struct wlsc_drm drm;
|
struct wlsc_drm drm;
|
||||||
|
|
@ -177,7 +177,7 @@ struct wlsc_vector {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlsc_surface {
|
struct wlsc_surface {
|
||||||
struct wl_surface base;
|
struct wl_surface surface;
|
||||||
struct wlsc_compositor *compositor;
|
struct wlsc_compositor *compositor;
|
||||||
GLuint texture;
|
GLuint texture;
|
||||||
int32_t x, y, width, height;
|
int32_t x, y, width, height;
|
||||||
|
|
|
||||||
|
|
@ -35,16 +35,17 @@ drm_authenticate(struct wl_client *client,
|
||||||
(struct wl_object *) compositor->wl_display,
|
(struct wl_object *) compositor->wl_display,
|
||||||
WL_DISPLAY_INVALID_OBJECT, 0);
|
WL_DISPLAY_INVALID_OBJECT, 0);
|
||||||
else
|
else
|
||||||
wl_client_post_event(client, &drm->base, WL_DRM_AUTHENTICATED);
|
wl_client_post_event(client, &drm->object,
|
||||||
|
WL_DRM_AUTHENTICATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
destroy_buffer(struct wl_resource *resource, struct wl_client *client)
|
destroy_buffer(struct wl_resource *resource, struct wl_client *client)
|
||||||
{
|
{
|
||||||
struct wlsc_drm_buffer *buffer =
|
struct wlsc_drm_buffer *buffer =
|
||||||
container_of(resource, struct wlsc_drm_buffer, base.base);
|
container_of(resource, struct wlsc_drm_buffer, buffer.resource);
|
||||||
struct wlsc_compositor *compositor =
|
struct wlsc_compositor *compositor =
|
||||||
(struct wlsc_compositor *) buffer->base.compositor;
|
(struct wlsc_compositor *) buffer->buffer.compositor;
|
||||||
|
|
||||||
eglDestroyImageKHR(compositor->display, buffer->image);
|
eglDestroyImageKHR(compositor->display, buffer->image);
|
||||||
free(buffer);
|
free(buffer);
|
||||||
|
|
@ -53,7 +54,7 @@ destroy_buffer(struct wl_resource *resource, struct wl_client *client)
|
||||||
static void
|
static void
|
||||||
buffer_destroy(struct wl_client *client, struct wl_buffer *buffer)
|
buffer_destroy(struct wl_client *client, struct wl_buffer *buffer)
|
||||||
{
|
{
|
||||||
wl_resource_destroy(&buffer->base, client);
|
wl_resource_destroy(&buffer->resource, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
const static struct wl_buffer_interface buffer_interface = {
|
const static struct wl_buffer_interface buffer_interface = {
|
||||||
|
|
@ -69,7 +70,7 @@ drm_buffer_attach(struct wl_buffer *buffer_base, struct wl_surface *surface)
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, es->texture);
|
glBindTexture(GL_TEXTURE_2D, es->texture);
|
||||||
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, buffer->image);
|
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, buffer->image);
|
||||||
es->visual = buffer->base.visual;
|
es->visual = buffer->buffer.visual;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -118,12 +119,12 @@ drm_create_buffer(struct wl_client *client, struct wl_drm *drm_base,
|
||||||
attribs[3] = height;
|
attribs[3] = height;
|
||||||
attribs[5] = stride / 4;
|
attribs[5] = stride / 4;
|
||||||
|
|
||||||
buffer->base.compositor = &compositor->base;
|
buffer->buffer.compositor = &compositor->compositor;
|
||||||
buffer->base.width = width;
|
buffer->buffer.width = width;
|
||||||
buffer->base.height = height;
|
buffer->buffer.height = height;
|
||||||
buffer->base.visual = visual;
|
buffer->buffer.visual = visual;
|
||||||
buffer->base.attach = drm_buffer_attach;
|
buffer->buffer.attach = drm_buffer_attach;
|
||||||
buffer->base.damage = drm_buffer_damage;
|
buffer->buffer.damage = drm_buffer_damage;
|
||||||
buffer->image = eglCreateImageKHR(compositor->display,
|
buffer->image = eglCreateImageKHR(compositor->display,
|
||||||
compositor->context,
|
compositor->context,
|
||||||
EGL_DRM_BUFFER_MESA,
|
EGL_DRM_BUFFER_MESA,
|
||||||
|
|
@ -139,14 +140,14 @@ drm_create_buffer(struct wl_client *client, struct wl_drm *drm_base,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer->base.base.base.id = id;
|
buffer->buffer.resource.object.id = id;
|
||||||
buffer->base.base.base.interface = &wl_buffer_interface;
|
buffer->buffer.resource.object.interface = &wl_buffer_interface;
|
||||||
buffer->base.base.base.implementation = (void (**)(void))
|
buffer->buffer.resource.object.implementation = (void (**)(void))
|
||||||
&buffer_interface;
|
&buffer_interface;
|
||||||
|
|
||||||
buffer->base.base.destroy = destroy_buffer;
|
buffer->buffer.resource.destroy = destroy_buffer;
|
||||||
|
|
||||||
wl_client_add_resource(client, &buffer->base.base);
|
wl_client_add_resource(client, &buffer->buffer.resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
const static struct wl_drm_interface drm_interface = {
|
const static struct wl_drm_interface drm_interface = {
|
||||||
|
|
@ -157,7 +158,7 @@ const static struct wl_drm_interface drm_interface = {
|
||||||
static void
|
static void
|
||||||
post_drm_device(struct wl_client *client, struct wl_object *global)
|
post_drm_device(struct wl_client *client, struct wl_object *global)
|
||||||
{
|
{
|
||||||
struct wlsc_drm *drm = container_of(global, struct wlsc_drm, base);
|
struct wlsc_drm *drm = container_of(global, struct wlsc_drm, object);
|
||||||
|
|
||||||
wl_client_post_event(client, global, WL_DRM_DEVICE, drm->filename);
|
wl_client_post_event(client, global, WL_DRM_DEVICE, drm->filename);
|
||||||
}
|
}
|
||||||
|
|
@ -172,10 +173,10 @@ wlsc_drm_init(struct wlsc_compositor *ec, int fd, const char *filename)
|
||||||
if (drm->filename == NULL)
|
if (drm->filename == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
drm->base.interface = &wl_drm_interface;
|
drm->object.interface = &wl_drm_interface;
|
||||||
drm->base.implementation = (void (**)(void)) &drm_interface;
|
drm->object.implementation = (void (**)(void)) &drm_interface;
|
||||||
wl_display_add_object(ec->wl_display, &drm->base);
|
wl_display_add_object(ec->wl_display, &drm->object);
|
||||||
wl_display_add_global(ec->wl_display, &drm->base, post_drm_device);
|
wl_display_add_global(ec->wl_display, &drm->object, post_drm_device);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -208,11 +209,11 @@ wlsc_drm_buffer_create(struct wlsc_compositor *ec,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer->base.visual = visual;
|
buffer->buffer.visual = visual;
|
||||||
buffer->base.width = width;
|
buffer->buffer.width = width;
|
||||||
buffer->base.height = height;
|
buffer->buffer.height = height;
|
||||||
buffer->base.attach = drm_buffer_attach;
|
buffer->buffer.attach = drm_buffer_attach;
|
||||||
buffer->base.damage = drm_buffer_damage;
|
buffer->buffer.damage = drm_buffer_damage;
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,9 @@ static void
|
||||||
destroy_buffer(struct wl_resource *resource, struct wl_client *client)
|
destroy_buffer(struct wl_resource *resource, struct wl_client *client)
|
||||||
{
|
{
|
||||||
struct wlsc_shm_buffer *buffer =
|
struct wlsc_shm_buffer *buffer =
|
||||||
container_of(resource, struct wlsc_shm_buffer, base.base);
|
container_of(resource, struct wlsc_shm_buffer, buffer.resource);
|
||||||
|
|
||||||
munmap(buffer->data, buffer->stride * buffer->base.height);
|
munmap(buffer->data, buffer->stride * buffer->buffer.height);
|
||||||
free(buffer);
|
free(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,9 +59,9 @@ shm_buffer_attach(struct wl_buffer *buffer_base, struct wl_surface *surface)
|
||||||
0, 0, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, NULL);
|
0, 0, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, NULL);
|
||||||
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
|
||||||
buffer->base.width, buffer->base.height, 0,
|
buffer->buffer.width, buffer->buffer.height, 0,
|
||||||
GL_BGRA_EXT, GL_UNSIGNED_BYTE, buffer->data);
|
GL_BGRA_EXT, GL_UNSIGNED_BYTE, buffer->data);
|
||||||
es->visual = buffer->base.visual;
|
es->visual = buffer->buffer.visual;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -75,7 +75,7 @@ shm_buffer_damage(struct wl_buffer *buffer_base,
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, es->texture);
|
glBindTexture(GL_TEXTURE_2D, es->texture);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
|
||||||
buffer->base.width, buffer->base.height, 0,
|
buffer->buffer.width, buffer->buffer.height, 0,
|
||||||
GL_BGRA_EXT, GL_UNSIGNED_BYTE, buffer->data);
|
GL_BGRA_EXT, GL_UNSIGNED_BYTE, buffer->data);
|
||||||
|
|
||||||
/* Hmm, should use glTexSubImage2D() here but GLES2 doesn't
|
/* Hmm, should use glTexSubImage2D() here but GLES2 doesn't
|
||||||
|
|
@ -112,12 +112,12 @@ shm_create_buffer(struct wl_client *client, struct wl_shm *shm,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer->base.compositor = (struct wl_compositor *) compositor;
|
buffer->buffer.compositor = (struct wl_compositor *) compositor;
|
||||||
buffer->base.width = width;
|
buffer->buffer.width = width;
|
||||||
buffer->base.height = height;
|
buffer->buffer.height = height;
|
||||||
buffer->base.visual = visual;
|
buffer->buffer.visual = visual;
|
||||||
buffer->base.attach = shm_buffer_attach;
|
buffer->buffer.attach = shm_buffer_attach;
|
||||||
buffer->base.damage = shm_buffer_damage;
|
buffer->buffer.damage = shm_buffer_damage;
|
||||||
buffer->stride = stride;
|
buffer->stride = stride;
|
||||||
buffer->data =
|
buffer->data =
|
||||||
mmap(NULL, stride * height, PROT_READ, MAP_SHARED, fd, 0);
|
mmap(NULL, stride * height, PROT_READ, MAP_SHARED, fd, 0);
|
||||||
|
|
@ -133,14 +133,14 @@ shm_create_buffer(struct wl_client *client, struct wl_shm *shm,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer->base.base.base.id = id;
|
buffer->buffer.resource.object.id = id;
|
||||||
buffer->base.base.base.interface = &wl_buffer_interface;
|
buffer->buffer.resource.object.interface = &wl_buffer_interface;
|
||||||
buffer->base.base.base.implementation = (void (**)(void))
|
buffer->buffer.resource.object.implementation = (void (**)(void))
|
||||||
&buffer_interface;
|
&buffer_interface;
|
||||||
|
|
||||||
buffer->base.base.destroy = destroy_buffer;
|
buffer->buffer.resource.destroy = destroy_buffer;
|
||||||
|
|
||||||
wl_client_add_resource(client, &buffer->base.base);
|
wl_client_add_resource(client, &buffer->buffer.resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
const static struct wl_shm_interface shm_interface = {
|
const static struct wl_shm_interface shm_interface = {
|
||||||
|
|
@ -152,10 +152,10 @@ wlsc_shm_init(struct wlsc_compositor *ec)
|
||||||
{
|
{
|
||||||
struct wlsc_shm *shm = &ec->shm;
|
struct wlsc_shm *shm = &ec->shm;
|
||||||
|
|
||||||
shm->base.interface = &wl_shm_interface;
|
shm->object.interface = &wl_shm_interface;
|
||||||
shm->base.implementation = (void (**)(void)) &shm_interface;
|
shm->object.implementation = (void (**)(void)) &shm_interface;
|
||||||
wl_display_add_object(ec->wl_display, &shm->base);
|
wl_display_add_object(ec->wl_display, &shm->object);
|
||||||
wl_display_add_global(ec->wl_display, &shm->base, NULL);
|
wl_display_add_global(ec->wl_display, &shm->object, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ struct wl_listener {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wl_proxy {
|
struct wl_proxy {
|
||||||
struct wl_object base;
|
struct wl_object object;
|
||||||
struct wl_display *display;
|
struct wl_display *display;
|
||||||
struct wl_list listener_list;
|
struct wl_list listener_list;
|
||||||
void *user_data;
|
void *user_data;
|
||||||
|
|
@ -144,11 +144,11 @@ wl_proxy_create_for_id(struct wl_display *display,
|
||||||
if (proxy == NULL)
|
if (proxy == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
proxy->base.interface = interface;
|
proxy->object.interface = interface;
|
||||||
proxy->base.id = id;
|
proxy->object.id = id;
|
||||||
proxy->display = display;
|
proxy->display = display;
|
||||||
wl_list_init(&proxy->listener_list);
|
wl_list_init(&proxy->listener_list);
|
||||||
wl_hash_table_insert(display->objects, proxy->base.id, proxy);
|
wl_hash_table_insert(display->objects, proxy->object.id, proxy);
|
||||||
|
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
|
@ -169,7 +169,7 @@ wl_proxy_destroy(struct wl_proxy *proxy)
|
||||||
wl_list_for_each_safe(listener, next, &proxy->listener_list, link)
|
wl_list_for_each_safe(listener, next, &proxy->listener_list, link)
|
||||||
free(listener);
|
free(listener);
|
||||||
|
|
||||||
wl_hash_table_remove(proxy->display->objects, proxy->base.id);
|
wl_hash_table_remove(proxy->display->objects, proxy->object.id);
|
||||||
free(proxy);
|
free(proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -198,8 +198,8 @@ wl_proxy_marshal(struct wl_proxy *proxy, uint32_t opcode, ...)
|
||||||
|
|
||||||
va_start(ap, opcode);
|
va_start(ap, opcode);
|
||||||
closure = wl_connection_vmarshal(proxy->display->connection,
|
closure = wl_connection_vmarshal(proxy->display->connection,
|
||||||
&proxy->base, opcode, ap,
|
&proxy->object, opcode, ap,
|
||||||
&proxy->base.interface->methods[opcode]);
|
&proxy->object.interface->methods[opcode]);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
wl_closure_send(closure, proxy->display->connection);
|
wl_closure_send(closure, proxy->display->connection);
|
||||||
|
|
@ -273,7 +273,7 @@ display_handle_global(void *data,
|
||||||
|
|
||||||
if (strcmp(interface, "display") == 0)
|
if (strcmp(interface, "display") == 0)
|
||||||
wl_hash_table_insert(display->objects,
|
wl_hash_table_insert(display->objects,
|
||||||
id, &display->proxy.base);
|
id, &display->proxy.object);
|
||||||
else if (strcmp(interface, "visual") == 0)
|
else if (strcmp(interface, "visual") == 0)
|
||||||
add_visual(display, id);
|
add_visual(display, id);
|
||||||
|
|
||||||
|
|
@ -377,8 +377,8 @@ wl_display_connect(const char *name)
|
||||||
display->objects = wl_hash_table_create();
|
display->objects = wl_hash_table_create();
|
||||||
wl_list_init(&display->global_listener_list);
|
wl_list_init(&display->global_listener_list);
|
||||||
|
|
||||||
display->proxy.base.interface = &wl_display_interface;
|
display->proxy.object.interface = &wl_display_interface;
|
||||||
display->proxy.base.id = 1;
|
display->proxy.object.id = 1;
|
||||||
display->proxy.display = display;
|
display->proxy.display = display;
|
||||||
wl_list_init(&display->proxy.listener_list);
|
wl_list_init(&display->proxy.listener_list);
|
||||||
|
|
||||||
|
|
@ -476,12 +476,12 @@ handle_event(struct wl_display *display,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
message = &proxy->base.interface->events[opcode];
|
message = &proxy->object.interface->events[opcode];
|
||||||
closure = wl_connection_demarshal(display->connection,
|
closure = wl_connection_demarshal(display->connection,
|
||||||
size, display->objects, message);
|
size, display->objects, message);
|
||||||
|
|
||||||
wl_list_for_each(listener, &proxy->listener_list, link)
|
wl_list_for_each(listener, &proxy->listener_list, link)
|
||||||
wl_closure_invoke(closure, &proxy->base,
|
wl_closure_invoke(closure, &proxy->object,
|
||||||
listener->implementation[opcode],
|
listener->implementation[opcode],
|
||||||
listener->data);
|
listener->data);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ struct wl_client {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wl_display {
|
struct wl_display {
|
||||||
struct wl_object base;
|
struct wl_object object;
|
||||||
struct wl_event_loop *loop;
|
struct wl_event_loop *loop;
|
||||||
struct wl_hash_table *objects;
|
struct wl_hash_table *objects;
|
||||||
int run;
|
int run;
|
||||||
|
|
@ -142,7 +142,7 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
|
||||||
|
|
||||||
object = wl_hash_table_lookup(client->display->objects, p[0]);
|
object = wl_hash_table_lookup(client->display->objects, p[0]);
|
||||||
if (object == NULL) {
|
if (object == NULL) {
|
||||||
wl_client_post_event(client, &client->display->base,
|
wl_client_post_event(client, &client->display->object,
|
||||||
WL_DISPLAY_INVALID_OBJECT, p[0]);
|
WL_DISPLAY_INVALID_OBJECT, p[0]);
|
||||||
wl_connection_consume(connection, size);
|
wl_connection_consume(connection, size);
|
||||||
len -= size;
|
len -= size;
|
||||||
|
|
@ -150,7 +150,7 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opcode >= object->interface->method_count) {
|
if (opcode >= object->interface->method_count) {
|
||||||
wl_client_post_event(client, &client->display->base,
|
wl_client_post_event(client, &client->display->object,
|
||||||
WL_DISPLAY_INVALID_METHOD, p[0], opcode);
|
WL_DISPLAY_INVALID_METHOD, p[0], opcode);
|
||||||
wl_connection_consume(connection, size);
|
wl_connection_consume(connection, size);
|
||||||
len -= size;
|
len -= size;
|
||||||
|
|
@ -164,7 +164,7 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
|
||||||
len -= size;
|
len -= size;
|
||||||
|
|
||||||
if (closure == NULL && errno == EINVAL) {
|
if (closure == NULL && errno == EINVAL) {
|
||||||
wl_client_post_event(client, &client->display->base,
|
wl_client_post_event(client, &client->display->object,
|
||||||
WL_DISPLAY_INVALID_METHOD,
|
WL_DISPLAY_INVALID_METHOD,
|
||||||
p[0], opcode);
|
p[0], opcode);
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -208,7 +208,7 @@ wl_client_get_display(struct wl_client *client)
|
||||||
static void
|
static void
|
||||||
wl_display_post_range(struct wl_display *display, struct wl_client *client)
|
wl_display_post_range(struct wl_display *display, struct wl_client *client)
|
||||||
{
|
{
|
||||||
wl_client_post_event(client, &client->display->base,
|
wl_client_post_event(client, &client->display->object,
|
||||||
WL_DISPLAY_RANGE, display->client_id_range);
|
WL_DISPLAY_RANGE, display->client_id_range);
|
||||||
display->client_id_range += 256;
|
display->client_id_range += 256;
|
||||||
client->id_count += 256;
|
client->id_count += 256;
|
||||||
|
|
@ -237,7 +237,7 @@ wl_client_create(struct wl_display *display, int fd)
|
||||||
wl_display_post_range(display, client);
|
wl_display_post_range(display, client);
|
||||||
|
|
||||||
wl_list_for_each(global, &display->global_list, link)
|
wl_list_for_each(global, &display->global_list, link)
|
||||||
wl_client_post_event(client, &client->display->base,
|
wl_client_post_event(client, &client->display->object,
|
||||||
WL_DISPLAY_GLOBAL,
|
WL_DISPLAY_GLOBAL,
|
||||||
global->object,
|
global->object,
|
||||||
global->object->interface->name,
|
global->object->interface->name,
|
||||||
|
|
@ -260,7 +260,7 @@ wl_client_add_resource(struct wl_client *client,
|
||||||
wl_display_post_range(display, client);
|
wl_display_post_range(display, client);
|
||||||
|
|
||||||
wl_hash_table_insert(client->display->objects,
|
wl_hash_table_insert(client->display->objects,
|
||||||
resource->base.id, resource);
|
resource->object.id, resource);
|
||||||
wl_list_insert(client->resource_list.prev, &resource->link);
|
wl_list_insert(client->resource_list.prev, &resource->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -268,7 +268,7 @@ WL_EXPORT void
|
||||||
wl_client_post_no_memory(struct wl_client *client)
|
wl_client_post_no_memory(struct wl_client *client)
|
||||||
{
|
{
|
||||||
wl_client_post_event(client,
|
wl_client_post_event(client,
|
||||||
&client->display->base,
|
&client->display->object,
|
||||||
WL_DISPLAY_NO_MEMORY);
|
WL_DISPLAY_NO_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -276,7 +276,7 @@ WL_EXPORT void
|
||||||
wl_client_post_global(struct wl_client *client, struct wl_object *object)
|
wl_client_post_global(struct wl_client *client, struct wl_object *object)
|
||||||
{
|
{
|
||||||
wl_client_post_event(client,
|
wl_client_post_event(client,
|
||||||
&client->display->base,
|
&client->display->object,
|
||||||
WL_DISPLAY_GLOBAL,
|
WL_DISPLAY_GLOBAL,
|
||||||
object,
|
object,
|
||||||
object->interface->name,
|
object->interface->name,
|
||||||
|
|
@ -289,8 +289,8 @@ wl_resource_destroy(struct wl_resource *resource, struct wl_client *client)
|
||||||
struct wl_display *display = client->display;
|
struct wl_display *display = client->display;
|
||||||
|
|
||||||
wl_list_remove(&resource->link);
|
wl_list_remove(&resource->link);
|
||||||
if (resource->base.id > 0)
|
if (resource->object.id > 0)
|
||||||
wl_hash_table_remove(display->objects, resource->base.id);
|
wl_hash_table_remove(display->objects, resource->object.id);
|
||||||
resource->destroy(resource, client);
|
resource->destroy(resource, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -322,12 +322,12 @@ wl_input_device_set_pointer_focus(struct wl_input_device *device,
|
||||||
if (device->pointer_focus &&
|
if (device->pointer_focus &&
|
||||||
(!surface || device->pointer_focus->client != surface->client))
|
(!surface || device->pointer_focus->client != surface->client))
|
||||||
wl_client_post_event(device->pointer_focus->client,
|
wl_client_post_event(device->pointer_focus->client,
|
||||||
&device->base,
|
&device->object,
|
||||||
WL_INPUT_DEVICE_POINTER_FOCUS,
|
WL_INPUT_DEVICE_POINTER_FOCUS,
|
||||||
time, NULL, 0, 0, 0, 0);
|
time, NULL, 0, 0, 0, 0);
|
||||||
if (surface)
|
if (surface)
|
||||||
wl_client_post_event(surface->client,
|
wl_client_post_event(surface->client,
|
||||||
&device->base,
|
&device->object,
|
||||||
WL_INPUT_DEVICE_POINTER_FOCUS,
|
WL_INPUT_DEVICE_POINTER_FOCUS,
|
||||||
time, surface, x, y, sx, sy);
|
time, surface, x, y, sx, sy);
|
||||||
|
|
||||||
|
|
@ -346,13 +346,13 @@ wl_input_device_set_keyboard_focus(struct wl_input_device *device,
|
||||||
if (device->keyboard_focus &&
|
if (device->keyboard_focus &&
|
||||||
(!surface || device->keyboard_focus->client != surface->client))
|
(!surface || device->keyboard_focus->client != surface->client))
|
||||||
wl_client_post_event(device->keyboard_focus->client,
|
wl_client_post_event(device->keyboard_focus->client,
|
||||||
&device->base,
|
&device->object,
|
||||||
WL_INPUT_DEVICE_KEYBOARD_FOCUS,
|
WL_INPUT_DEVICE_KEYBOARD_FOCUS,
|
||||||
time, NULL, &device->keys);
|
time, NULL, &device->keys);
|
||||||
|
|
||||||
if (surface)
|
if (surface)
|
||||||
wl_client_post_event(surface->client,
|
wl_client_post_event(surface->client,
|
||||||
&device->base,
|
&device->object,
|
||||||
WL_INPUT_DEVICE_KEYBOARD_FOCUS,
|
WL_INPUT_DEVICE_KEYBOARD_FOCUS,
|
||||||
time, surface, &device->keys);
|
time, surface, &device->keys);
|
||||||
|
|
||||||
|
|
@ -364,7 +364,7 @@ static void
|
||||||
display_sync(struct wl_client *client,
|
display_sync(struct wl_client *client,
|
||||||
struct wl_display *display, uint32_t key)
|
struct wl_display *display, uint32_t key)
|
||||||
{
|
{
|
||||||
wl_client_post_event(client, &display->base, WL_DISPLAY_KEY, key, 0);
|
wl_client_post_event(client, &display->object, WL_DISPLAY_KEY, key, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -392,7 +392,7 @@ display_frame(struct wl_client *client,
|
||||||
/* The listener is a resource so we destroy it when the client
|
/* The listener is a resource so we destroy it when the client
|
||||||
* goes away. */
|
* goes away. */
|
||||||
listener->resource.destroy = destroy_frame_listener;
|
listener->resource.destroy = destroy_frame_listener;
|
||||||
listener->resource.base.id = 0;
|
listener->resource.object.id = 0;
|
||||||
listener->client = client;
|
listener->client = client;
|
||||||
listener->key = key;
|
listener->key = key;
|
||||||
wl_list_insert(client->resource_list.prev, &listener->resource.link);
|
wl_list_insert(client->resource_list.prev, &listener->resource.link);
|
||||||
|
|
@ -438,10 +438,10 @@ wl_display_create(void)
|
||||||
display->client_id_range = 256; /* Gah, arbitrary... */
|
display->client_id_range = 256; /* Gah, arbitrary... */
|
||||||
|
|
||||||
display->id = 1;
|
display->id = 1;
|
||||||
display->base.interface = &wl_display_interface;
|
display->object.interface = &wl_display_interface;
|
||||||
display->base.implementation = (void (**)(void)) &display_interface;
|
display->object.implementation = (void (**)(void)) &display_interface;
|
||||||
wl_display_add_object(display, &display->base);
|
wl_display_add_object(display, &display->object);
|
||||||
if (wl_display_add_global(display, &display->base, NULL)) {
|
if (wl_display_add_global(display, &display->object, NULL)) {
|
||||||
wl_event_loop_destroy(display->loop);
|
wl_event_loop_destroy(display->loop);
|
||||||
free(display);
|
free(display);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -497,7 +497,7 @@ wl_display_post_frame(struct wl_display *display, uint32_t time)
|
||||||
struct wl_frame_listener *listener, *next;
|
struct wl_frame_listener *listener, *next;
|
||||||
|
|
||||||
wl_list_for_each_safe(listener, next, &display->frame_list, link) {
|
wl_list_for_each_safe(listener, next, &display->frame_list, link) {
|
||||||
wl_client_post_event(listener->client, &display->base,
|
wl_client_post_event(listener->client, &display->object,
|
||||||
WL_DISPLAY_KEY, listener->key, time);
|
WL_DISPLAY_KEY, listener->key, time);
|
||||||
wl_resource_destroy(&listener->resource, listener->client);
|
wl_resource_destroy(&listener->resource, listener->client);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,18 +98,18 @@ void wl_client_post_no_memory(struct wl_client *client);
|
||||||
void wl_client_post_global(struct wl_client *client, struct wl_object *object);
|
void wl_client_post_global(struct wl_client *client, struct wl_object *object);
|
||||||
|
|
||||||
struct wl_compositor {
|
struct wl_compositor {
|
||||||
struct wl_object base;
|
struct wl_object object;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wl_resource {
|
struct wl_resource {
|
||||||
struct wl_object base;
|
struct wl_object object;
|
||||||
void (*destroy)(struct wl_resource *resource,
|
void (*destroy)(struct wl_resource *resource,
|
||||||
struct wl_client *client);
|
struct wl_client *client);
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wl_buffer {
|
struct wl_buffer {
|
||||||
struct wl_resource base;
|
struct wl_resource resource;
|
||||||
struct wl_compositor *compositor;
|
struct wl_compositor *compositor;
|
||||||
struct wl_visual *visual;
|
struct wl_visual *visual;
|
||||||
int32_t width, height;
|
int32_t width, height;
|
||||||
|
|
@ -120,16 +120,16 @@ struct wl_buffer {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wl_surface {
|
struct wl_surface {
|
||||||
struct wl_resource base;
|
struct wl_resource resource;
|
||||||
struct wl_client *client;
|
struct wl_client *client;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wl_shell {
|
struct wl_shell {
|
||||||
struct wl_object base;
|
struct wl_object object;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wl_input_device {
|
struct wl_input_device {
|
||||||
struct wl_object base;
|
struct wl_object object;
|
||||||
struct wl_surface *pointer_focus;
|
struct wl_surface *pointer_focus;
|
||||||
struct wl_surface *keyboard_focus;
|
struct wl_surface *keyboard_focus;
|
||||||
struct wl_array keys;
|
struct wl_array keys;
|
||||||
|
|
@ -138,11 +138,11 @@ struct wl_input_device {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wl_visual {
|
struct wl_visual {
|
||||||
struct wl_object base;
|
struct wl_object object;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wl_drag_offer {
|
struct wl_drag_offer {
|
||||||
struct wl_object base;
|
struct wl_object object;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wl_drag {
|
struct wl_drag {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue