diff options
author | Jason Ekstrand <jason@jlekstrand.net> | 2013-06-27 20:17:02 -0500 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2013-07-03 14:52:06 -0400 |
commit | a85118c1b85df6fbf8f896dca971a5b79a94da71 (patch) | |
tree | 30390d8883a0e823d62a1c7dc9872b33b7e8e111 /src/shell.c | |
parent | d27cb096adf71139734b434d60cbb28bd4a510b1 (diff) |
Use wl_resource_create() for creating resources
This commit sets the version numbers for all added/created objects. The
wl_compositor.create_surface implementation was altered to create a surface
with the same version as the underlying wl_compositor. Since no other
"child interfaces" have version greater than 1, they were all hard-coded to
version 1.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Diffstat (limited to 'src/shell.c')
-rw-r--r-- | src/shell.c | 68 |
1 files changed, 37 insertions, 31 deletions
diff --git a/src/shell.c b/src/shell.c index 9869db5b..aa2db3d1 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1015,16 +1015,17 @@ bind_workspace_manager(struct wl_client *client, struct desktop_shell *shell = data; struct wl_resource *resource; - resource = wl_client_add_object(client, &workspace_manager_interface, - &workspace_manager_implementation, - id, shell); + resource = wl_resource_create(client, + &workspace_manager_interface, 1, id); if (resource == NULL) { weston_log("couldn't add workspace manager object"); return; } - wl_resource_set_destructor(resource, unbind_resource); + wl_resource_set_implementation(resource, + &workspace_manager_implementation, + shell, unbind_resource); wl_list_insert(&shell->workspaces.client_list, wl_resource_get_link(resource)); @@ -2332,12 +2333,12 @@ shell_get_shell_surface(struct wl_client *client, return; } - shsurf->resource = wl_client_add_object(client, - &wl_shell_surface_interface, - &shell_surface_implementation, - id, shsurf); - wl_resource_set_destructor(shsurf->resource, - shell_destroy_shell_surface); + shsurf->resource = + wl_resource_create(client, + &wl_shell_surface_interface, 1, id); + wl_resource_set_implementation(shsurf->resource, + &shell_surface_implementation, + shsurf, shell_destroy_shell_surface); } static const struct wl_shell_interface shell_implementation = { @@ -3598,9 +3599,12 @@ static void bind_shell(struct wl_client *client, void *data, uint32_t version, uint32_t id) { struct desktop_shell *shell = data; + struct wl_resource *resource; - wl_client_add_object(client, &wl_shell_interface, - &shell_implementation, id, shell); + resource = wl_resource_create(client, &wl_shell_interface, 1, id); + if (resource) + wl_resource_set_implementation(resource, &shell_implementation, + shell, NULL); } static void @@ -3622,12 +3626,13 @@ bind_desktop_shell(struct wl_client *client, struct desktop_shell *shell = data; struct wl_resource *resource; - resource = wl_client_add_object(client, &desktop_shell_interface, - &desktop_shell_implementation, - id, shell); + resource = wl_resource_create(client, &desktop_shell_interface, + MIN(version, 2), id); if (client == shell->child.client) { - wl_resource_set_destructor(resource, unbind_desktop_shell); + wl_resource_set_implementation(resource, + &desktop_shell_implementation, + shell, unbind_desktop_shell); shell->child.desktop_shell = resource; if (version < 2) @@ -3700,12 +3705,12 @@ bind_screensaver(struct wl_client *client, struct desktop_shell *shell = data; struct wl_resource *resource; - resource = wl_client_add_object(client, &screensaver_interface, - &screensaver_implementation, - id, shell); + resource = wl_resource_create(client, &screensaver_interface, 1, id); if (shell->screensaver.binding == NULL) { - wl_resource_set_destructor(resource, unbind_screensaver); + wl_resource_set_implementation(resource, + &screensaver_implementation, + shell, unbind_screensaver); shell->screensaver.binding = resource; return; } @@ -3894,13 +3899,13 @@ input_panel_get_input_panel_surface(struct wl_client *client, return; } - ipsurf->resource = wl_client_add_object(client, - &wl_input_panel_surface_interface, - &input_panel_surface_implementation, - id, ipsurf); - - wl_resource_set_destructor(ipsurf->resource, - destroy_input_panel_surface_resource); + ipsurf->resource = + wl_resource_create(client, + &wl_input_panel_surface_interface, 1, id); + wl_resource_set_implementation(ipsurf->resource, + &input_panel_surface_implementation, + ipsurf, + destroy_input_panel_surface_resource); } static const struct wl_input_panel_interface input_panel_implementation = { @@ -3922,12 +3927,13 @@ bind_input_panel(struct wl_client *client, struct desktop_shell *shell = data; struct wl_resource *resource; - resource = wl_client_add_object(client, &wl_input_panel_interface, - &input_panel_implementation, - id, shell); + resource = wl_resource_create(client, + &wl_input_panel_interface, 1, id); if (shell->input_panel.binding == NULL) { - wl_resource_set_destructor(resource, unbind_input_panel); + wl_resource_set_implementation(resource, + &input_panel_implementation, + shell, unbind_input_panel); shell->input_panel.binding = resource; return; } |