Commit fbf91b9b authored by Kristian Høgsberg's avatar Kristian Høgsberg
Browse files

compositor: Rewrite stubs to take wl_resources as first argument

parent 96a43311
......@@ -981,7 +981,7 @@ wlsc_compositor_fade(struct wlsc_compositor *compositor, float tint)
}
static void
surface_destroy(struct wl_client *client, struct wl_resource *resource)
surface_destroy(struct wl_resource *resource, struct wl_surface *surface)
{
wl_resource_destroy(resource, wlsc_compositor_get_time());
}
......@@ -1012,11 +1012,12 @@ wlsc_surface_assign_output(struct wlsc_surface *es)
}
static void
surface_attach(struct wl_client *client,
struct wl_resource *resource, struct wl_buffer *buffer,
surface_attach(struct wl_resource *resource,
struct wl_surface *surface, struct wl_buffer *buffer,
int32_t x, int32_t y)
{
struct wlsc_surface *es = resource->data;
struct wlsc_surface *es =
container_of(surface, struct wlsc_surface, surface);
buffer->busy_count++;
wlsc_buffer_post_release(es->buffer);
......@@ -1041,11 +1042,12 @@ surface_attach(struct wl_client *client,
}
static void
surface_damage(struct wl_client *client,
struct wl_resource *resource,
surface_damage(struct wl_resource *resource,
struct wl_surface *surface,
int32_t x, int32_t y, int32_t width, int32_t height)
{
struct wlsc_surface *es = resource->data;
struct wlsc_surface *es =
container_of(surface, struct wlsc_surface, surface);
wlsc_surface_damage_rectangle(es, x, y, width, height);
}
......@@ -1060,26 +1062,27 @@ destroy_frame_callback(struct wl_resource *resource)
}
static void
surface_frame(struct wl_client *client,
struct wl_resource *resource, uint32_t callback)
surface_frame(struct wl_resource *resource,
struct wl_surface *surface, uint32_t callback)
{
struct wlsc_frame_callback *cb;
struct wlsc_surface *es = resource->data;
struct wlsc_surface *es =
container_of(surface, struct wlsc_surface, surface);
cb = malloc(sizeof *cb);
if (cb == NULL) {
wl_client_post_no_memory(client);
wl_client_post_no_memory(resource->client);
return;
}
cb->resource.object.interface = &wl_callback_interface;
cb->resource.object.id = callback;
cb->resource.destroy = destroy_frame_callback;
cb->resource.client = client;
cb->resource.client = resource->client;
cb->resource.data = cb;
wl_list_insert(es->output->frame_callback_list.prev, &cb->link);
wl_client_add_resource(client, &cb->resource);
wl_client_add_resource(resource->client, &cb->resource);
}
const static struct wl_surface_interface surface_interface = {
......@@ -1136,15 +1139,16 @@ wlsc_input_device_set_pointer_image(struct wlsc_input_device *device,
}
static void
compositor_create_surface(struct wl_client *client,
struct wl_resource *resource, uint32_t id)
compositor_create_surface(struct wl_resource *resource,
struct wl_compositor *compositor, uint32_t id)
{
struct wlsc_compositor *ec = resource->data;
struct wlsc_compositor *ec =
container_of(compositor, struct wlsc_compositor, compositor);
struct wlsc_surface *surface;
surface = wlsc_surface_create(ec, 0, 0, 0, 0);
if (surface == NULL) {
wl_client_post_no_memory(client);
wl_client_post_no_memory(resource->client);
return;
}
......@@ -1156,7 +1160,7 @@ compositor_create_surface(struct wl_client *client,
(void (**)(void)) &surface_interface;
surface->surface.resource.data = surface;
wl_client_add_resource(client, &surface->surface.resource);
wl_client_add_resource(resource->client, &surface->surface.resource);
}
const static struct wl_compositor_interface compositor_interface = {
......@@ -1598,18 +1602,20 @@ notify_keyboard_focus(struct wl_input_device *device,
static void
input_device_attach(struct wl_client *client,
struct wl_resource *resource,
input_device_attach(struct wl_resource *resource,
struct wl_input_device *input_device,
uint32_t time,
struct wl_buffer *buffer, int32_t x, int32_t y)
{
struct wlsc_input_device *device = resource->data;
struct wlsc_input_device *device =
container_of(input_device,
struct wlsc_input_device, input_device);
if (time < device->input_device.pointer_focus_time)
if (time < input_device->pointer_focus_time)
return;
if (device->input_device.pointer_focus == NULL)
if (input_device->pointer_focus == NULL)
return;
if (device->input_device.pointer_focus->resource.client != client)
if (input_device->pointer_focus->resource.client != resource->client)
return;
if (buffer == NULL) {
......
......@@ -249,11 +249,10 @@ handle_lockscreen_surface_destroy(struct wl_listener *listener,
}
static void
tablet_shell_set_lockscreen(struct wl_client *client,
struct wl_resource *resource,
tablet_shell_set_lockscreen(struct wl_resource *resource,
struct meego_tablet_shell *shell,
struct wl_surface *surface)
{
struct meego_tablet_shell *shell = resource->data;
struct wlsc_surface *es = (struct wlsc_surface *) surface;
struct wlsc_input_device *device =
(struct wlsc_input_device *) shell->compositor->input_device;
......@@ -282,11 +281,10 @@ handle_switcher_surface_destroy(struct wl_listener *listener,
}
static void
tablet_shell_set_switcher(struct wl_client *client,
struct wl_resource *resource,
tablet_shell_set_switcher(struct wl_resource *resource,
struct meego_tablet_shell *shell,
struct wl_surface *surface)
{
struct meego_tablet_shell *shell = resource->data;
struct wlsc_input_device *device =
(struct wlsc_input_device *) shell->compositor->input_device;
struct wlsc_surface *es = (struct wlsc_surface *) surface;
......@@ -307,11 +305,10 @@ tablet_shell_set_switcher(struct wl_client *client,
}
static void
tablet_shell_set_homescreen(struct wl_client *client,
struct wl_resource *resource,
tablet_shell_set_homescreen(struct wl_resource *resource,
struct meego_tablet_shell *shell,
struct wl_surface *surface)
{
struct meego_tablet_shell *shell = resource->data;
struct wlsc_input_device *device =
(struct wlsc_input_device *) shell->compositor->input_device;
......@@ -368,22 +365,18 @@ meego_tablet_shell_switch_to(struct meego_tablet_shell *shell,
}
static void
tablet_shell_show_grid(struct wl_client *client,
struct wl_resource *resource,
tablet_shell_show_grid(struct wl_resource *resource,
struct meego_tablet_shell *shell,
struct wl_surface *surface)
{
struct meego_tablet_shell *shell = resource->data;
meego_tablet_shell_switch_to(shell, (struct wlsc_surface *) surface);
}
static void
tablet_shell_show_panels(struct wl_client *client,
struct wl_resource *resource,
tablet_shell_show_panels(struct wl_resource *resource,
struct meego_tablet_shell *shell,
struct wl_surface *surface)
{
struct meego_tablet_shell *shell = resource->data;
meego_tablet_shell_switch_to(shell, (struct wlsc_surface *) surface);
}
......@@ -398,22 +391,23 @@ destroy_tablet_client(struct wl_resource *resource)
}
static void
tablet_client_destroy(struct wl_client *client, struct wl_resource *resource)
tablet_client_destroy(struct wl_resource *resource,
struct meego_tablet_client *client)
{
wl_resource_destroy(resource, wlsc_compositor_get_time());
}
static void
tablet_client_activate(struct wl_client *client, struct wl_resource *resource)
tablet_client_activate(struct wl_resource *resource,
struct meego_tablet_client *client)
{
struct meego_tablet_client *tablet_client = resource->data;
struct meego_tablet_shell *shell = tablet_client->shell;
struct meego_tablet_shell *shell = client->shell;
shell->current_client = tablet_client;
if (!tablet_client->surface)
shell->current_client = client;
if (!client->surface)
return;
meego_tablet_shell_switch_to(shell, tablet_client->surface);
meego_tablet_shell_switch_to(shell, client->surface);
}
static const struct meego_tablet_client_interface tablet_client_interface = {
......@@ -422,17 +416,16 @@ static const struct meego_tablet_client_interface tablet_client_interface = {
};
static void
tablet_shell_create_client(struct wl_client *client,
struct wl_resource *resource,
tablet_shell_create_client(struct wl_resource *resource,
struct meego_tablet_shell *shell,
uint32_t id, const char *name, int fd)
{
struct meego_tablet_shell *shell = resource->data;
struct wlsc_compositor *compositor = shell->compositor;
struct meego_tablet_client *tablet_client;
tablet_client = malloc(sizeof *tablet_client);
if (tablet_client == NULL) {
wl_client_post_no_memory(client);
wl_client_post_no_memory(resource->client);
return;
}
......@@ -447,7 +440,7 @@ tablet_shell_create_client(struct wl_client *client,
tablet_client->resource.object.implementation =
(void (**)(void)) &tablet_client_interface;
wl_client_add_resource(client, &tablet_client->resource);
wl_client_add_resource(resource->client, &tablet_client->resource);
tablet_client->surface = NULL;
shell->current_client = tablet_client;
......
......@@ -77,7 +77,7 @@ static const struct wl_grab_interface move_grab_interface = {
};
static void
shell_move(struct wl_client *client, struct wl_resource *resource,
shell_move(struct wl_resource *resource, struct wl_shell *shell,
struct wl_surface *surface,
struct wl_input_device *device, uint32_t time)
{
......@@ -89,7 +89,7 @@ shell_move(struct wl_client *client, struct wl_resource *resource,
move = malloc(sizeof *move);
if (!move) {
wl_client_post_no_memory(client);
wl_client_post_no_memory(resource->client);
return;
}
......@@ -112,7 +112,7 @@ struct wlsc_resize_grab {
int32_t dx, dy, width, height;
struct wlsc_surface *surface;
struct wl_shell *shell;
struct wl_resource resource;
struct wl_resource *resource;
};
static void
......@@ -140,7 +140,7 @@ resize_grab_motion(struct wl_grab *grab,
height = resize->height;
}
wl_resource_post_event(&resize->resource,
wl_resource_post_event(resize->resource,
WL_SHELL_CONFIGURE, time, resize->edges,
surface, width, height);
}
......@@ -172,11 +172,10 @@ static const struct wl_grab_interface resize_grab_interface = {
};
static void
shell_resize(struct wl_client *client, struct wl_resource *resource,
shell_resize(struct wl_resource *resource, struct wl_shell *shell,
struct wl_surface *surface,
struct wl_input_device *device, uint32_t time, uint32_t edges)
{
struct wl_shell *shell = resource->data;
struct wlsc_input_device *wd = (struct wlsc_input_device *) device;
struct wlsc_resize_grab *resize;
enum wlsc_pointer_type pointer = WLSC_POINTER_LEFT_PTR;
......@@ -186,7 +185,7 @@ shell_resize(struct wl_client *client, struct wl_resource *resource,
resize = malloc(sizeof *resize);
if (!resize) {
wl_client_post_no_memory(client);
wl_client_post_no_memory(resource->client);
return;
}
......@@ -199,8 +198,7 @@ shell_resize(struct wl_client *client, struct wl_resource *resource,
resize->surface = es;
resize->shell = shell;
resize->resource.object = resource->object;
resize->resource.client = client;
resize->resource = resource;
if (edges == 0 || edges > 15 ||
(edges & 3) == 3 || (edges & 12) == 12)
......@@ -242,9 +240,8 @@ shell_resize(struct wl_client *client, struct wl_resource *resource,
}
static void
shell_set_toplevel(struct wl_client *client,
struct wl_resource *resource,
struct wl_surface *surface)
shell_set_toplevel(struct wl_resource *resource,
struct wl_shell *shell, struct wl_surface *surface)
{
struct wlsc_surface *es = (struct wlsc_surface *) surface;
......@@ -267,8 +264,8 @@ shell_set_toplevel(struct wl_client *client,
}
static void
shell_set_transient(struct wl_client *client,
struct wl_resource *resource,
shell_set_transient(struct wl_resource *resource,
struct wl_shell *shell,
struct wl_surface *surface,
struct wl_surface *parent,
int x, int y, uint32_t flags)
......@@ -287,9 +284,8 @@ shell_set_transient(struct wl_client *client,
}
static void
shell_set_fullscreen(struct wl_client *client,
struct wl_resource *resource,
struct wl_surface *surface)
shell_set_fullscreen(struct wl_resource *resource,
struct wl_shell *shell, struct wl_surface *surface)
{
struct wlsc_surface *es = (struct wlsc_surface *) surface;
......@@ -372,10 +368,9 @@ wl_drag_set_pointer_focus(struct wl_drag *drag,
}
static void
drag_offer_accept(struct wl_client *client, struct wl_resource *resource,
drag_offer_accept(struct wl_resource *resource, struct wl_drag_offer *offer,
uint32_t time, const char *type)
{
struct wl_drag_offer *offer = resource->data;
struct wl_drag *drag = container_of(offer, struct wl_drag, drag_offer);
char **p, **end;
......@@ -387,7 +382,7 @@ drag_offer_accept(struct wl_client *client, struct wl_resource *resource,
if (time < drag->pointer_focus_time)
return;
drag->target = client;
drag->target = resource->client;
drag->type = NULL;
end = drag->types.data + drag->types.size;
for (p = drag->types.data; p < end; p++)
......@@ -398,10 +393,9 @@ drag_offer_accept(struct wl_client *client, struct wl_resource *resource,
}
static void
drag_offer_receive(struct wl_client *client,
struct wl_resource *resource, int fd)
drag_offer_receive(struct wl_resource *resource,
struct wl_drag_offer *offer, int fd)
{
struct wl_drag_offer *offer = resource->data;
struct wl_drag *drag = container_of(offer, struct wl_drag, drag_offer);
wl_resource_post_event(&drag->resource, WL_DRAG_FINISH, fd);
......@@ -409,9 +403,8 @@ drag_offer_receive(struct wl_client *client,
}
static void
drag_offer_reject(struct wl_client *client, struct wl_resource *resource)
drag_offer_reject(struct wl_resource *resource, struct wl_drag_offer *offer)
{
struct wl_drag_offer *offer = resource->data;
struct wl_drag *drag = container_of(offer, struct wl_drag, drag_offer);
wl_resource_post_event(&drag->resource, WL_DRAG_REJECT);
......@@ -424,17 +417,16 @@ static const struct wl_drag_offer_interface drag_offer_interface = {
};
static void
drag_offer(struct wl_client *client,
struct wl_resource *resource, const char *type)
drag_offer(struct wl_resource *resource,
struct wl_drag *drag, const char *type)
{
struct wl_drag *drag = resource->data;
char **p;
p = wl_array_add(&drag->types, sizeof *p);
if (p)
*p = strdup(type);
if (!p || !*p)
wl_client_post_no_memory(client);
wl_client_post_no_memory(resource->client);
}
static void
......@@ -494,13 +486,12 @@ bind_drag_offer(struct wl_client *client,
}
static void
drag_activate(struct wl_client *client,
struct wl_resource *resource,
drag_activate(struct wl_resource *resource,
struct wl_drag *drag,
struct wl_surface *surface,
struct wl_input_device *device, uint32_t time)
{
struct wl_drag *drag = resource->data;
struct wl_display *display = wl_client_get_display (client);
struct wl_display *display = wl_client_get_display(resource->client);
struct wlsc_surface *target;
int32_t sx, sy;
......@@ -522,7 +513,7 @@ drag_activate(struct wl_client *client,
}
static void
drag_destroy(struct wl_client *client, struct wl_resource *resource)
drag_destroy(struct wl_resource *resource, struct wl_drag *drag)
{
wl_resource_destroy(resource, wlsc_compositor_get_time());
}
......@@ -546,14 +537,14 @@ drag_handle_surface_destroy(struct wl_listener *listener,
}
static void
shell_create_drag(struct wl_client *client,
struct wl_resource *resource, uint32_t id)
shell_create_drag(struct wl_resource *resource,
struct wl_shell *shell, uint32_t id)
{
struct wl_drag *drag;
drag = malloc(sizeof *drag);
if (drag == NULL) {
wl_client_post_no_memory(client);
wl_client_post_no_memory(resource->client);
return;
}
......@@ -568,7 +559,7 @@ shell_create_drag(struct wl_client *client,
drag->drag_focus_listener.func = drag_handle_surface_destroy;
wl_list_init(&drag->drag_focus_listener.link);
wl_client_add_resource(client, &drag->resource);
wl_client_add_resource(resource->client, &drag->resource);
}
static void
......@@ -612,11 +603,10 @@ wlsc_selection_set_focus(struct wlsc_shell *shell,
}
static void
selection_offer_receive(struct wl_client *client,
struct wl_resource *resource,
selection_offer_receive(struct wl_resource *resource,
struct wl_selection_offer *offer,
const char *mime_type, int fd)
{
struct wl_selection_offer *offer = resource->data;
struct wl_selection *selection =
container_of(offer, struct wl_selection, selection_offer);
......@@ -630,17 +620,16 @@ static const struct wl_selection_offer_interface selection_offer_interface = {
};
static void
selection_offer(struct wl_client *client,
struct wl_resource *resource, const char *type)
selection_offer(struct wl_resource *resource,
struct wl_selection *selection, const char *type)
{
struct wl_selection *selection = resource->data;
char **p;
p = wl_array_add(&selection->types, sizeof *p);
if (p)
*p = strdup(type);
if (!p || !*p)
wl_client_post_no_memory(client);
wl_client_post_no_memory(resource->client);
}
static void
......@@ -652,13 +641,12 @@ bind_selection_offer(struct wl_client *client,
}
static void
selection_activate(struct wl_client *client,
struct wl_resource *resource,
selection_activate(struct wl_resource *resource,
struct wl_selection *selection,
struct wl_input_device *device, uint32_t time)
{
struct wl_selection *selection = resource->data;
struct wlsc_input_device *wd = (struct wlsc_input_device *) device;
struct wl_display *display = wl_client_get_display (client);
struct wl_display *display = wl_client_get_display(resource->client);
struct wlsc_compositor *compositor =
(struct wlsc_compositor *) device->compositor;
......@@ -678,7 +666,7 @@ selection_activate(struct wl_client *client,
}
static void
selection_destroy(struct wl_client *client, struct wl_resource *resource)
selection_destroy(struct wl_resource *resource, struct wl_selection *selection)
{
wl_resource_destroy(resource, wlsc_compositor_get_time());
}
......@@ -717,14 +705,14 @@ selection_handle_surface_destroy(struct wl_listener *listener,
}
static void
shell_create_selection(struct wl_client *client,
struct wl_resource *resource, uint32_t id)
shell_create_selection(struct wl_resource *resource,
struct wl_shell *shell, uint32_t id)
{
struct wl_selection *selection;
selection = malloc(sizeof *selection);
if (selection == NULL) {
wl_client_post_no_memory(client);
wl_client_post_no_memory(resource->client);
return;
}
......@@ -734,7 +722,7 @@ shell_create_selection(struct wl_client *client,
selection->resource.object.implementation =
(void (**)(void)) &selection_interface;
selection->client = client;
selection->client = resource->client;
selection->resource.destroy = destroy_selection;
selection->selection_focus = NULL;
......@@ -742,7 +730,7 @@ shell_create_selection(struct wl_client *client,
selection_handle_surface_destroy;
wl_list_init(&selection->selection_focus_listener.link);
wl_client_add_resource(client, &selection->resource);
wl_client_add_resource(resource->client, &selection->resource);
}
const static struct wl_shell_interface shell_interface = {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment