input_panel_surface: Change resource to a wl_resource pointer

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Jason Ekstrand 11 years ago committed by Kristian Høgsberg
parent fbbbec8ef5
commit 51e5b14952
  1. 38
      src/shell.c
  2. 59
      src/tablet-shell.c

@ -73,7 +73,8 @@ struct workspace {
};
struct input_panel_surface {
struct wl_resource resource;
struct wl_resource *resource;
struct wl_signal destroy_signal;
struct desktop_shell *shell;
@ -3763,6 +3764,8 @@ input_panel_configure(struct weston_surface *surface, int32_t sx, int32_t sy, in
static void
destroy_input_panel_surface(struct input_panel_surface *input_panel_surface)
{
wl_signal_emit(&input_panel_surface->destroy_signal, input_panel_surface);
wl_list_remove(&input_panel_surface->surface_destroy_listener.link);
wl_list_remove(&input_panel_surface->link);
@ -3788,14 +3791,13 @@ input_panel_handle_surface_destroy(struct wl_listener *listener, void *data)
struct input_panel_surface,
surface_destroy_listener);
if (ipsurface->resource.client) {
wl_resource_destroy(&ipsurface->resource);
if (ipsurface->resource) {
wl_resource_destroy(ipsurface->resource);
} else {
wl_signal_emit(&ipsurface->resource.destroy_signal,
&ipsurface->resource);
destroy_input_panel_surface(ipsurface);
}
}
static struct input_panel_surface *
create_input_panel_surface(struct desktop_shell *shell,
struct weston_surface *surface)
@ -3813,7 +3815,7 @@ create_input_panel_surface(struct desktop_shell *shell,
input_panel_surface->surface = surface;
wl_signal_init(&input_panel_surface->resource.destroy_signal);
wl_signal_init(&input_panel_surface->destroy_signal);
input_panel_surface->surface_destroy_listener.notify = input_panel_handle_surface_destroy;
wl_signal_add(&surface->destroy_signal,
&input_panel_surface->surface_destroy_listener);
@ -3829,7 +3831,8 @@ input_panel_surface_set_toplevel(struct wl_client *client,
struct wl_resource *output_resource,
uint32_t position)
{
struct input_panel_surface *input_panel_surface = resource->data;
struct input_panel_surface *input_panel_surface =
wl_resource_get_user_data(resource);
struct desktop_shell *shell = input_panel_surface->shell;
wl_list_insert(&shell->input_panel.surfaces,
@ -3843,7 +3846,8 @@ static void
input_panel_surface_set_overlay_panel(struct wl_client *client,
struct wl_resource *resource)
{
struct input_panel_surface *input_panel_surface = resource->data;
struct input_panel_surface *input_panel_surface =
wl_resource_get_user_data(resource);
struct desktop_shell *shell = input_panel_surface->shell;
wl_list_insert(&shell->input_panel.surfaces,
@ -3860,7 +3864,8 @@ static const struct wl_input_panel_surface_interface input_panel_surface_impleme
static void
destroy_input_panel_surface_resource(struct wl_resource *resource)
{
struct input_panel_surface *ipsurf = resource->data;
struct input_panel_surface *ipsurf =
wl_resource_get_user_data(resource);
destroy_input_panel_surface(ipsurf);
}
@ -3891,14 +3896,13 @@ input_panel_get_input_panel_surface(struct wl_client *client,
return;
}
ipsurf->resource.destroy = destroy_input_panel_surface_resource;
ipsurf->resource.object.id = id;
ipsurf->resource.object.interface = &wl_input_panel_surface_interface;
ipsurf->resource.object.implementation =
(void (**)(void)) &input_panel_surface_implementation;
ipsurf->resource.data = ipsurf;
ipsurf->resource = wl_client_add_object(client,
&wl_input_panel_surface_interface,
&input_panel_surface_implementation,
id, ipsurf);
wl_client_add_resource(client, &ipsurf->resource);
wl_resource_set_destructor(ipsurf->resource,
destroy_input_panel_surface_resource);
}
static const struct wl_input_panel_interface input_panel_implementation = {
@ -3926,7 +3930,7 @@ bind_input_panel(struct wl_client *client,
id, shell);
if (shell->input_panel.binding == NULL) {
resource->destroy = unbind_input_panel;
wl_resource_set_destructor(resource, unbind_input_panel);
shell->input_panel.binding = resource;
return;
}

@ -46,7 +46,7 @@ enum {
};
struct tablet_shell {
struct wl_resource resource;
struct wl_resource *resource;
struct wl_listener lock_listener;
struct wl_listener unlock_listener;
@ -78,7 +78,7 @@ struct tablet_shell {
};
struct tablet_client {
struct wl_resource resource;
struct wl_resource *resource;
struct tablet_shell *shell;
struct wl_client *client;
struct weston_surface *surface;
@ -148,7 +148,7 @@ tablet_shell_surface_configure(struct weston_surface *surface,
tablet_shell_set_state(shell, STATE_LOCKED);
shell->previous_state = STATE_HOME;
tablet_shell_send_show_lockscreen(&shell->resource);
tablet_shell_send_show_lockscreen(shell->resource);
}
} else if (shell->current_client &&
shell->current_client->surface != surface &&
@ -179,7 +179,7 @@ tablet_shell_set_lockscreen(struct wl_client *client,
struct wl_resource *resource,
struct wl_resource *surface_resource)
{
struct tablet_shell *shell = resource->data;
struct tablet_shell *shell = wl_resource_get_user_data(resource);
struct weston_surface *es = wl_resource_get_user_data(surface_resource);
weston_surface_set_position(es, 0, 0);
@ -206,7 +206,7 @@ tablet_shell_set_switcher(struct wl_client *client,
struct wl_resource *resource,
struct wl_resource *surface_resource)
{
struct tablet_shell *shell = resource->data;
struct tablet_shell *shell = wl_resource_get_user_data(resource);
struct weston_surface *es = wl_resource_get_user_data(surface_resource);
/* FIXME: Switcher should be centered and the compositor
@ -225,7 +225,7 @@ tablet_shell_set_homescreen(struct wl_client *client,
struct wl_resource *resource,
struct wl_resource *surface_resource)
{
struct tablet_shell *shell = resource->data;
struct tablet_shell *shell = wl_resource_get_user_data(resource);
shell->home_surface = wl_resource_get_user_data(surface_resource);
shell->home_surface->configure = tablet_shell_surface_configure;
@ -279,7 +279,7 @@ tablet_shell_show_grid(struct wl_client *client,
struct wl_resource *resource,
struct wl_resource *surface_resource)
{
struct tablet_shell *shell = resource->data;
struct tablet_shell *shell = wl_resource_get_user_data(resource);
struct weston_surface *es = wl_resource_get_user_data(surface_resource);
tablet_shell_switch_to(shell, es);
@ -290,7 +290,7 @@ tablet_shell_show_panels(struct wl_client *client,
struct wl_resource *resource,
struct wl_resource *surface_resource)
{
struct tablet_shell *shell = resource->data;
struct tablet_shell *shell = wl_resource_get_user_data(resource);
struct weston_surface *es = wl_resource_get_user_data(surface_resource);
tablet_shell_switch_to(shell, es);
@ -300,7 +300,7 @@ static void
destroy_tablet_client(struct wl_resource *resource)
{
struct tablet_client *tablet_client =
container_of(resource, struct tablet_client, resource);
wl_resource_get_user_data(resource);
free(tablet_client->name);
free(tablet_client);
@ -316,7 +316,7 @@ tablet_client_destroy(struct wl_client *client,
static void
tablet_client_activate(struct wl_client *client, struct wl_resource *resource)
{
struct tablet_client *tablet_client = resource->data;
struct tablet_client *tablet_client = wl_resource_get_user_data(resource);
struct tablet_shell *shell = tablet_client->shell;
shell->current_client = tablet_client;
@ -336,7 +336,7 @@ tablet_shell_create_client(struct wl_client *client,
struct wl_resource *resource,
uint32_t id, const char *name, int fd)
{
struct tablet_shell *shell = resource->data;
struct tablet_shell *shell = wl_resource_get_user_data(resource);
struct weston_compositor *compositor = shell->compositor;
struct tablet_client *tablet_client;
@ -350,14 +350,13 @@ tablet_shell_create_client(struct wl_client *client,
tablet_client->shell = shell;
tablet_client->name = strdup(name);
tablet_client->resource.destroy = destroy_tablet_client;
tablet_client->resource.object.id = id;
tablet_client->resource.object.interface =
&tablet_client_interface;
tablet_client->resource.object.implementation =
(void (**)(void)) &tablet_client_implementation;
tablet_client->resource = wl_client_add_object(client,
&tablet_client_interface,
&tablet_client_implementation,
id, tablet_client);
wl_resource_set_destructor(tablet_client->resource,
destroy_tablet_client);
wl_client_add_resource(client, &tablet_client->resource);
tablet_client->surface = NULL;
shell->current_client = tablet_client;
@ -389,10 +388,10 @@ toggle_switcher(struct tablet_shell *shell)
{
switch (shell->state) {
case STATE_SWITCHER:
tablet_shell_send_hide_switcher(&shell->resource);
tablet_shell_send_hide_switcher(shell->resource);
break;
default:
tablet_shell_send_show_switcher(&shell->resource);
tablet_shell_send_show_switcher(shell->resource);
tablet_shell_set_state(shell, STATE_SWITCHER);
break;
}
@ -407,9 +406,9 @@ tablet_shell_lock(struct wl_listener *listener, void *data)
if (shell->state == STATE_LOCKED)
return;
if (shell->state == STATE_SWITCHER)
tablet_shell_send_hide_switcher(&shell->resource);
tablet_shell_send_hide_switcher(shell->resource);
tablet_shell_send_show_lockscreen(&shell->resource);
tablet_shell_send_show_lockscreen(shell->resource);
tablet_shell_set_state(shell, STATE_LOCKED);
}
@ -426,7 +425,7 @@ static void
go_home(struct tablet_shell *shell, struct weston_seat *seat)
{
if (shell->state == STATE_SWITCHER)
tablet_shell_send_hide_switcher(&shell->resource);
tablet_shell_send_hide_switcher(shell->resource);
weston_surface_activate(shell->home_surface, seat);
@ -499,15 +498,11 @@ bind_tablet_shell(struct wl_client *client, void *data, uint32_t version,
* tries to access the object?. */
return;
shell->resource.object.id = id;
shell->resource.object.interface = &tablet_shell_interface;
shell->resource.object.implementation =
(void (**)(void)) &tablet_shell_implementation;
shell->resource.client = client;
shell->resource.data = shell;
shell->resource.destroy = destroy_tablet_shell;
wl_client_add_resource(client, &shell->resource);
shell->resource = wl_client_add_object(client,
&tablet_shell_interface,
&tablet_shell_implementation,
id, shell);
wl_resource_set_destructor(shell->resource, destroy_tablet_shell);
}
static void

Loading…
Cancel
Save