commit 8e1d3bf12a4cdeda4de3dd3e6da8474108fb247e
parent 1bb790d66fd78a1a310b20ae9f46fdc330ed1626
Author: Michael Forney <mforney@mforney.org>
Date: Wed, 1 Oct 2014 00:42:46 -0700
Version resources properly
Diffstat:
23 files changed, 80 insertions(+), 46 deletions(-)
diff --git a/libswc/compositor.c b/libswc/compositor.c
@@ -815,7 +815,7 @@ static void create_region(struct wl_client * client,
{
struct swc_region * region;
- region = swc_region_new(client, id);
+ region = swc_region_new(client, wl_resource_get_version(resource), id);
if (!region)
wl_resource_post_no_memory(resource);
diff --git a/libswc/data.c b/libswc/data.c
@@ -139,7 +139,8 @@ static struct data * data_new()
return data;
}
-struct wl_resource * data_source_new(struct wl_client * client, uint32_t id)
+struct wl_resource * data_source_new(struct wl_client * client,
+ uint32_t version, uint32_t id)
{
struct data * data;
@@ -149,7 +150,8 @@ struct wl_resource * data_source_new(struct wl_client * client, uint32_t id)
return NULL;
/* Add the data source to the client. */
- data->source = wl_resource_create(client, &wl_data_source_interface, 1, id);
+ data->source = wl_resource_create(client, &wl_data_source_interface,
+ version, id);
/* Destroy the data object when the source disappears. */
wl_resource_set_implementation(data->source, &data_source_implementation,
@@ -159,12 +161,13 @@ struct wl_resource * data_source_new(struct wl_client * client, uint32_t id)
}
struct wl_resource * data_offer_new(struct wl_client * client,
- struct wl_resource * source)
+ struct wl_resource * source,
+ uint32_t version)
{
struct data * data = wl_resource_get_user_data(source);
struct wl_resource * offer;
- offer = wl_resource_create(client, &wl_data_offer_interface, 1, 0);
+ offer = wl_resource_create(client, &wl_data_offer_interface, version, 0);
wl_resource_set_implementation(offer, &data_offer_implementation,
data, &swc_remove_resource);
wl_list_insert(&data->offers, wl_resource_get_link(offer));
diff --git a/libswc/data.h b/libswc/data.h
@@ -28,10 +28,12 @@
struct wl_client;
-struct wl_resource * data_source_new(struct wl_client * client, uint32_t id);
+struct wl_resource * data_source_new(struct wl_client * client,
+ uint32_t version, uint32_t id);
struct wl_resource * data_offer_new(struct wl_client * client,
- struct wl_resource * source);
+ struct wl_resource * source,
+ uint32_t version);
void data_send_mime_types(struct wl_resource * source,
struct wl_resource * offer);
diff --git a/libswc/data_device.c b/libswc/data_device.c
@@ -94,11 +94,12 @@ void data_device_finalize(struct data_device * data_device)
}
void data_device_bind(struct data_device * data_device,
- struct wl_client * client, uint32_t id)
+ struct wl_client * client, uint32_t version, uint32_t id)
{
struct wl_resource * resource;
- resource = wl_resource_create(client, &wl_data_device_interface, 1, id);
+ resource = wl_resource_create(client, &wl_data_device_interface,
+ version, id);
wl_resource_set_implementation(resource, &data_device_implementation,
data_device, &swc_remove_resource);
wl_list_insert(&data_device->resources, &resource->link);
@@ -110,7 +111,7 @@ static struct wl_resource * new_offer(struct wl_resource * resource,
{
struct wl_resource * offer;
- offer = data_offer_new(client, source);
+ offer = data_offer_new(client, source, wl_resource_get_version(resource));
wl_data_device_send_data_offer(resource, offer);
data_send_mime_types(source, offer);
diff --git a/libswc/data_device.h b/libswc/data_device.h
@@ -48,7 +48,7 @@ bool data_device_initialize(struct data_device * data_device);
void data_device_finalize(struct data_device * data_device);
void data_device_bind(struct data_device * data_device,
- struct wl_client * client, uint32_t id);
+ struct wl_client * client, uint32_t version, uint32_t id);
void data_device_offer_selection(struct data_device * data_device,
struct wl_client * client);
diff --git a/libswc/data_device_manager.c b/libswc/data_device_manager.c
@@ -37,7 +37,8 @@ static void create_data_source(struct wl_client * client,
{
struct wl_resource * data_source;
- data_source = data_source_new(client, id);
+ data_source = data_source_new(client,
+ wl_resource_get_version(resource), id);
if (!data_source)
wl_resource_post_no_memory(resource);
@@ -47,7 +48,8 @@ static void get_data_device(struct wl_client * client,
struct wl_resource * resource, uint32_t id,
struct wl_resource * seat_resource)
{
- data_device_bind(swc.seat->data_device, client, id);
+ data_device_bind(swc.seat->data_device, client,
+ wl_resource_get_version(resource), id);
}
static struct wl_data_device_manager_interface
@@ -61,8 +63,11 @@ static void bind_data_device_manager(struct wl_client * client, void * data,
{
struct wl_resource * resource;
+ if (version >= 1)
+ version = 1;
+
resource = wl_resource_create(client, &wl_data_device_manager_interface,
- 1, id);
+ version, id);
wl_resource_set_implementation
(resource, &data_device_manager_implementation, NULL, NULL);
}
diff --git a/libswc/drm.c b/libswc/drm.c
@@ -84,7 +84,8 @@ static void create_buffer(struct wl_client * client,
if (!buffer)
goto error0;
- buffer_resource = swc_wayland_buffer_create_resource(client, id, buffer);
+ buffer_resource = swc_wayland_buffer_create_resource
+ (client, wl_resource_get_version(resource), id, buffer);
if (!buffer_resource)
goto error1;
@@ -128,7 +129,8 @@ static void create_prime_buffer(struct wl_client * client,
if (!buffer)
goto error0;
- buffer_resource = swc_wayland_buffer_create_resource(client, id, buffer);
+ buffer_resource = swc_wayland_buffer_create_resource
+ (client, wl_resource_get_version(resource), id, buffer);
if (!buffer_resource)
goto error1;
diff --git a/libswc/keyboard.c b/libswc/keyboard.c
@@ -204,11 +204,13 @@ static void unbind(struct wl_resource * resource)
}
struct wl_resource * keyboard_bind(struct keyboard * keyboard,
- struct wl_client * client, uint32_t id)
+ struct wl_client * client,
+ uint32_t version, uint32_t id)
{
struct wl_resource * client_resource;
- client_resource = wl_resource_create(client, &wl_keyboard_interface, 3, id);
+ client_resource = wl_resource_create(client, &wl_keyboard_interface,
+ version, id);
wl_resource_set_implementation(client_resource, &keyboard_implementation,
keyboard, &unbind);
input_focus_add_resource(&keyboard->focus, client_resource);
diff --git a/libswc/keyboard.h b/libswc/keyboard.h
@@ -78,7 +78,8 @@ void keyboard_reset(struct keyboard * keyboard);
void keyboard_set_focus(struct keyboard * keyboard,
struct compositor_view * view);
struct wl_resource * keyboard_bind(struct keyboard * keyboard,
- struct wl_client * client, uint32_t id);
+ struct wl_client * client,
+ uint32_t version, uint32_t id);
void keyboard_handle_key(struct keyboard * keyboard, uint32_t time,
uint32_t key, uint32_t state);
diff --git a/libswc/panel.c b/libswc/panel.c
@@ -226,8 +226,8 @@ static void handle_surface_destroy(struct wl_listener * listener, void * data)
wl_resource_destroy(panel->resource);
}
-struct panel * panel_new(struct wl_client * client, uint32_t id,
- struct swc_surface * surface)
+struct panel * panel_new(struct wl_client * client, uint32_t version,
+ uint32_t id, struct swc_surface * surface)
{
struct panel * panel;
@@ -236,7 +236,8 @@ struct panel * panel_new(struct wl_client * client, uint32_t id,
if (!panel)
goto error0;
- panel->resource = wl_resource_create(client, &swc_panel_interface, 1, id);
+ panel->resource = wl_resource_create(client, &swc_panel_interface,
+ version, id);
if (!panel->resource)
goto error1;
diff --git a/libswc/panel.h b/libswc/panel.h
@@ -29,8 +29,8 @@
#include <stdbool.h>
#include <wayland-server.h>
-struct panel * panel_new(struct wl_client * client, uint32_t id,
- struct swc_surface * surface);
+struct panel * panel_new(struct wl_client * client, uint32_t version,
+ uint32_t id, struct swc_surface * surface);
#endif
diff --git a/libswc/panel_manager.c b/libswc/panel_manager.c
@@ -39,7 +39,7 @@ static void create_panel(struct wl_client * client,
{
struct swc_surface * surface = wl_resource_get_user_data(surface_resource);
- if (!panel_new(client, id, surface))
+ if (!panel_new(client, wl_resource_get_version(resource), id, surface))
wl_client_post_no_memory(client);
}
@@ -52,7 +52,11 @@ static void bind_panel_manager(struct wl_client * client, void * data,
{
struct wl_resource * resource;
- resource = wl_resource_create(client, &swc_panel_manager_interface, 1, id);
+ if (version >= 1)
+ version = 1;
+
+ resource = wl_resource_create(client, &swc_panel_manager_interface,
+ version, id);
wl_resource_set_implementation(resource, &panel_manager_implementation,
NULL, NULL);
}
diff --git a/libswc/pointer.c b/libswc/pointer.c
@@ -325,11 +325,13 @@ static void unbind(struct wl_resource * resource)
}
struct wl_resource * pointer_bind(struct pointer * pointer,
- struct wl_client * client, uint32_t id)
+ struct wl_client * client,
+ uint32_t version, uint32_t id)
{
struct wl_resource * client_resource;
- client_resource = wl_resource_create(client, &wl_pointer_interface, 3, id);
+ client_resource = wl_resource_create(client, &wl_pointer_interface,
+ version, id);
wl_resource_set_implementation(client_resource, &pointer_implementation,
pointer, &unbind);
input_focus_add_resource(&pointer->focus, client_resource);
diff --git a/libswc/pointer.h b/libswc/pointer.h
@@ -87,7 +87,8 @@ void pointer_set_cursor(struct pointer * pointer, uint32_t id);
struct button * pointer_get_button(struct pointer * pointer, uint32_t serial);
struct wl_resource * pointer_bind(struct pointer * pointer,
- struct wl_client * client, uint32_t id);
+ struct wl_client * client,
+ uint32_t version, uint32_t id);
void pointer_handle_button(struct pointer * pointer, uint32_t time,
uint32_t button, uint32_t state);
void pointer_handle_axis(struct pointer * pointer, uint32_t time,
diff --git a/libswc/region.c b/libswc/region.c
@@ -43,7 +43,8 @@ static void region_destroy(struct wl_resource * resource)
free(region);
}
-struct swc_region * swc_region_new(struct wl_client * client, uint32_t id)
+struct swc_region * swc_region_new(struct wl_client * client,
+ uint32_t version, uint32_t id)
{
struct swc_region * region;
@@ -56,7 +57,8 @@ struct swc_region * swc_region_new(struct wl_client * client, uint32_t id)
pixman_region32_init(®ion->region);
/* Add the region to the client. */
- region->resource = wl_resource_create(client, &wl_region_interface, 1, id);
+ region->resource = wl_resource_create(client, &wl_region_interface,
+ version, id);
wl_resource_set_implementation(region->resource, ®ion_implementation,
region, ®ion_destroy);
diff --git a/libswc/region.h b/libswc/region.h
@@ -12,7 +12,8 @@ struct swc_region
pixman_region32_t region;
};
-struct swc_region * swc_region_new(struct wl_client * client, uint32_t id);
+struct swc_region * swc_region_new(struct wl_client * client,
+ uint32_t version, uint32_t id);
#endif
diff --git a/libswc/seat.c b/libswc/seat.c
@@ -176,16 +176,17 @@ static struct wl_listener launch_listener = {
};
/* Wayland Seat Interface */
-static void get_pointer(struct wl_client * client, struct wl_resource * resource,
- uint32_t id)
+static void get_pointer(struct wl_client * client,
+ struct wl_resource * resource, uint32_t id)
{
- pointer_bind(&seat.pointer, client, id);
+ pointer_bind(&seat.pointer, client, wl_resource_get_version(resource), id);
}
-static void get_keyboard(struct wl_client * client, struct wl_resource * resource,
- uint32_t id)
+static void get_keyboard(struct wl_client * client,
+ struct wl_resource * resource, uint32_t id)
{
- keyboard_bind(&seat.keyboard, client, id);
+ keyboard_bind(&seat.keyboard, client,
+ wl_resource_get_version(resource), id);
}
static void get_touch(struct wl_client * client, struct wl_resource * resource,
diff --git a/libswc/shell.c b/libswc/shell.c
@@ -39,7 +39,8 @@ static void get_shell_surface(struct wl_client * client,
struct swc_surface * surface = wl_resource_get_user_data(surface_resource);
struct shell_surface * shell_surface;
- shell_surface = shell_surface_new(client, id, surface);
+ shell_surface = shell_surface_new(client, wl_resource_get_version(resource),
+ id, surface);
if (!shell_surface)
wl_resource_post_no_memory(resource);
diff --git a/libswc/shell_surface.c b/libswc/shell_surface.c
@@ -226,7 +226,8 @@ static void destroy_shell_surface(struct wl_resource * resource)
free(shell_surface);
}
-struct shell_surface * shell_surface_new(struct wl_client * client, uint32_t id,
+struct shell_surface * shell_surface_new(struct wl_client * client,
+ uint32_t version, uint32_t id,
struct swc_surface * surface)
{
struct shell_surface * shell_surface;
@@ -237,7 +238,7 @@ struct shell_surface * shell_surface_new(struct wl_client * client, uint32_t id,
goto error0;
shell_surface->resource = wl_resource_create
- (client, &wl_shell_surface_interface, 1, id);
+ (client, &wl_shell_surface_interface, version, id);
if (!shell_surface->resource)
goto error1;
diff --git a/libswc/shell_surface.h b/libswc/shell_surface.h
@@ -29,7 +29,8 @@
struct swc_surface;
struct wl_client;
-struct shell_surface * shell_surface_new(struct wl_client * client, uint32_t id,
+struct shell_surface * shell_surface_new(struct wl_client * client,
+ uint32_t version, uint32_t id,
struct swc_surface * surface);
#endif
diff --git a/libswc/shm.c b/libswc/shm.c
@@ -121,7 +121,8 @@ static void create_buffer(struct wl_client * client,
if (!buffer)
goto error0;
- buffer_resource = swc_wayland_buffer_create_resource(client, id, buffer);
+ buffer_resource = swc_wayland_buffer_create_resource
+ (client, wl_resource_get_version(resource), id, buffer);
if (!buffer_resource)
goto error1;
diff --git a/libswc/wayland_buffer.c b/libswc/wayland_buffer.c
@@ -57,11 +57,12 @@ static void destroy_buffer(struct wl_resource * resource)
}
struct wl_resource * swc_wayland_buffer_create_resource
- (struct wl_client * client, uint32_t id, struct wld_buffer * buffer)
+ (struct wl_client * client, uint32_t version, uint32_t id,
+ struct wld_buffer * buffer)
{
struct wl_resource * resource;
- resource = wl_resource_create(client, &wl_buffer_interface, 1, id);
+ resource = wl_resource_create(client, &wl_buffer_interface, version, id);
if (!resource)
{
diff --git a/libswc/wayland_buffer.h b/libswc/wayland_buffer.h
@@ -32,7 +32,8 @@ struct wl_resource;
struct wld_buffer * swc_wayland_buffer_get(struct wl_resource * resource);
struct wl_resource * swc_wayland_buffer_create_resource
- (struct wl_client * client, uint32_t id, struct wld_buffer * buffer);
+ (struct wl_client * client, uint32_t version, uint32_t id,
+ struct wld_buffer * buffer);
#endif