[RFC weston 12/12] Add a couple casts and wl_resource_get accessors
Jason Ekstrand
jason at jlekstrand.net
Fri Jun 14 08:08:03 PDT 2013
These are all changes that didn't really fit in another bigger category.
THIS PATCH SHOULD NOT GET COMMITTED TO WESTON MASTER!!!
Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
---
There is a slight issue here of how to properly handle wl_buffer. Right
now I am pointer-casting the resource to a buffer. If the resource really
is an old-school wl_buffer this is the right thing to do. If we ever
update SHM so that it hands out resources that are not old-school
wl_buffer's then this will be really bad. We probably need to simply store
buffers as resources and handle sorting them out somewhere else.
src/bindings.c | 2 +-
src/compositor.c | 4 ++--
src/screenshooter.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/bindings.c b/src/bindings.c
index 558208c..c983801 100644
--- a/src/bindings.c
+++ b/src/bindings.c
@@ -169,7 +169,7 @@ binding_key(struct weston_keyboard_grab *grab,
free(b);
}
} else if (resource) {
- display = wl_client_get_display(resource->client);
+ display = wl_client_get_display(wl_resource_get_client(resource));
serial = wl_display_next_serial(display);
wl_keyboard_send_key(resource, serial, time, key, state);
}
diff --git a/src/compositor.c b/src/compositor.c
index 320acd8..98411c1 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1399,7 +1399,7 @@ surface_attach(struct wl_client *client,
struct wl_buffer *buffer = NULL;
if (buffer_resource)
- buffer = buffer_resource->data;
+ buffer = (struct wl_buffer *)buffer_resource;
/* Attach, attach, without commit in between does not send
* wl_buffer.release. */
@@ -1640,7 +1640,7 @@ static void
compositor_create_surface(struct wl_client *client,
struct wl_resource *resource, uint32_t id)
{
- struct weston_compositor *ec = resource->data;
+ struct weston_compositor *ec = wl_resource_get_user_data(resource);
struct weston_surface *surface;
surface = weston_surface_create(ec);
diff --git a/src/screenshooter.c b/src/screenshooter.c
index 1fdfc9a..b86c159 100644
--- a/src/screenshooter.c
+++ b/src/screenshooter.c
@@ -178,7 +178,7 @@ screenshooter_shoot(struct wl_client *client,
struct weston_output *output =
wl_resource_get_user_data(output_resource);
struct screenshooter_frame_listener *l;
- struct wl_buffer *buffer = buffer_resource->data;
+ struct wl_buffer *buffer = (struct wl_buffer *)buffer_resource;
if (!wl_buffer_is_shm(buffer))
return;
--
1.8.1.4
More information about the wayland-devel
mailing list