Change weston_surface.resource to a wl_resource pointer.

This is the first in what will be a series of weston patches to convert
instances of wl_resource to pointers so we can make wl_resource opaque.
This patch handles weston_surface and should be the most invasive of the
entire series.  I am sending this one out ahead of the rest for review.

Specifically, my machine is not set up to build XWayland so I have no
ability to test it fully.  Could someone please test with XWayland and let
me know if this causes problems?

Because a surface may be created from XWayland, the resource may not always
exist.  Therefore, a destroy signal was added to weston_surface and
everything used to listen to surface->resource.destroy_signal now listens
to surface->destroy_signal.
dev
Jason Ekstrand 12 years ago committed by Kristian Høgsberg
parent a2ce68fd03
commit 26ed73cee8
  1. 2
      src/animation.c
  2. 65
      src/compositor.c
  3. 3
      src/compositor.h
  4. 9
      src/data-device.c
  5. 24
      src/input.c
  6. 13
      src/shell.c
  7. 7
      src/tablet-shell.c
  8. 2
      src/text-backend.c
  9. 12
      src/xwayland/window-manager.c
  10. 5
      src/zoom.c

@ -188,7 +188,7 @@ weston_surface_animation_run(struct weston_surface *surface,
weston_surface_animation_frame(&animation->animation, NULL, 0);
animation->listener.notify = handle_animation_surface_destroy;
wl_signal_add(&surface->resource.destroy_signal, &animation->listener);
wl_signal_add(&surface->destroy_signal, &animation->listener);
wl_list_insert(&surface->output->animation_list,
&animation->animation.link);

@ -276,13 +276,13 @@ weston_surface_create(struct weston_compositor *compositor)
if (surface == NULL)
return NULL;
wl_signal_init(&surface->resource.destroy_signal);
wl_signal_init(&surface->destroy_signal);
surface->resource = NULL;
wl_list_init(&surface->link);
wl_list_init(&surface->layer_link);
surface->resource.client = NULL;
surface->compositor = compositor;
surface->alpha = 1.0;
@ -523,14 +523,16 @@ weston_surface_update_output_mask(struct weston_surface *es, uint32_t mask)
uint32_t left = es->output_mask & different;
struct weston_output *output;
struct wl_resource *resource = NULL;
struct wl_client *client = es->resource.client;
struct wl_client *client;
es->output_mask = mask;
if (es->resource.client == NULL)
if (es->resource == NULL)
return;
if (different == 0)
return;
client = wl_resource_get_client(es->resource);
wl_list_for_each(output, &es->compositor->output_list, link) {
if (1 << output->id & different)
resource =
@ -539,9 +541,9 @@ weston_surface_update_output_mask(struct weston_surface *es, uint32_t mask)
if (resource == NULL)
continue;
if (1 << output->id & entered)
wl_surface_send_enter(&es->resource, resource);
wl_surface_send_enter(es->resource, resource);
if (1 << output->id & left)
wl_surface_send_leave(&es->resource, resource);
wl_surface_send_leave(es->resource, resource);
}
}
@ -882,7 +884,7 @@ weston_surface_set_transform_parent(struct weston_surface *surface,
surface->geometry.parent_destroy_listener.notify =
transform_parent_handle_parent_destroy;
if (parent) {
wl_signal_add(&parent->resource.destroy_signal,
wl_signal_add(&parent->destroy_signal,
&surface->geometry.parent_destroy_listener);
wl_list_insert(&parent->geometry.child_list,
&surface->geometry.parent_link);
@ -1004,11 +1006,15 @@ struct weston_frame_callback {
struct wl_list link;
};
static void
destroy_surface(struct wl_resource *resource)
WL_EXPORT void
weston_surface_destroy(struct weston_surface *surface)
{
struct weston_surface *surface =
container_of(resource, struct weston_surface, resource);
/* Not a valid way to destroy a client surface */
assert(surface->resource == NULL);
wl_signal_emit(&surface->destroy_signal, &surface->resource);
struct weston_compositor *compositor = surface->compositor;
struct weston_frame_callback *cb, *next;
@ -1048,14 +1054,13 @@ destroy_surface(struct wl_resource *resource)
free(surface);
}
WL_EXPORT void
weston_surface_destroy(struct weston_surface *surface)
static void
destroy_surface(struct wl_resource *resource)
{
/* Not a valid way to destroy a client surface */
assert(surface->resource.client == NULL);
struct weston_surface *surface = wl_resource_get_user_data(resource);
wl_signal_emit(&surface->resource.destroy_signal, &surface->resource);
destroy_surface(&surface->resource);
surface->resource = NULL;
weston_surface_destroy(surface);
}
static void
@ -1660,15 +1665,10 @@ compositor_create_surface(struct wl_client *client,
return;
}
surface->resource.destroy = destroy_surface;
surface->resource.object.id = id;
surface->resource.object.interface = &wl_surface_interface;
surface->resource.object.implementation =
(void (**)(void)) &surface_interface;
surface->resource.data = surface;
wl_client_add_resource(client, &surface->resource);
surface->resource = wl_client_add_object(client, &wl_surface_interface,
&surface_interface,
id, surface);
wl_resource_set_destructor(surface->resource, destroy_surface);
}
static void
@ -2035,7 +2035,7 @@ subsurface_sibling_check(struct weston_subsurface *sub,
wl_resource_post_error(sub->resource,
WL_SUBSURFACE_ERROR_BAD_SURFACE,
"%s: wl_surface@%d is not a parent or sibling",
request, surface->resource.object.id);
request, wl_resource_get_id(surface->resource));
return NULL;
}
@ -2043,7 +2043,7 @@ subsurface_sibling_check(struct weston_subsurface *sub,
wl_resource_post_error(sub->resource,
WL_SUBSURFACE_ERROR_BAD_SURFACE,
"%s: wl_surface@%d has a different parent",
request, surface->resource.object.id);
request, wl_resource_get_id(surface->resource));
return NULL;
}
@ -2204,7 +2204,7 @@ weston_subsurface_link_parent(struct weston_subsurface *sub,
{
sub->parent = parent;
sub->parent_destroy_listener.notify = subsurface_handle_parent_destroy;
wl_signal_add(&parent->resource.destroy_signal,
wl_signal_add(&parent->destroy_signal,
&sub->parent_destroy_listener);
wl_list_insert(&parent->subsurface_list, &sub->parent_link);
@ -2219,7 +2219,7 @@ weston_subsurface_link_surface(struct weston_subsurface *sub,
sub->surface = surface;
sub->surface_destroy_listener.notify =
subsurface_handle_surface_destroy;
wl_signal_add(&surface->resource.destroy_signal,
wl_signal_add(&surface->destroy_signal,
&sub->surface_destroy_listener);
}
@ -2266,12 +2266,13 @@ weston_subsurface_create(uint32_t id, struct weston_surface *surface,
struct weston_surface *parent)
{
struct weston_subsurface *sub;
struct wl_client *client = wl_resource_get_client(surface->resource);
sub = calloc(1, sizeof *sub);
if (!sub)
return NULL;
sub->resource = wl_client_add_object(surface->resource.client,
sub->resource = wl_client_add_object(client,
&wl_subsurface_interface,
&subsurface_implementation,
id, sub);

@ -651,7 +651,8 @@ struct weston_subsurface {
*/
struct weston_surface {
struct wl_resource resource;
struct wl_resource *resource;
struct wl_signal destroy_signal;
struct weston_compositor *compositor;
pixman_region32_t clip;
pixman_region32_t damage;

@ -230,11 +230,12 @@ weston_drag_set_focus(struct weston_drag *drag, struct weston_surface *surface,
if (!surface)
return;
if (!drag->data_source && surface->resource.client != drag->client)
if (!drag->data_source &&
wl_resource_get_client(surface->resource) != drag->client)
return;
resource = find_resource(&pointer->seat->drag_resource_list,
surface->resource.client);
wl_resource_get_client(surface->resource));
if (!resource)
return;
@ -244,7 +245,7 @@ weston_drag_set_focus(struct weston_drag *drag, struct weston_surface *surface,
if (drag->data_source)
offer = wl_data_source_send_offer(drag->data_source, resource);
wl_data_device_send_enter(resource, serial, &surface->resource,
wl_data_device_send_enter(resource, serial, surface->resource,
sx, sy, offer);
drag->focus = surface;
@ -405,7 +406,7 @@ data_device_start_drag(struct wl_client *client, struct wl_resource *resource,
if (icon) {
drag->icon = icon;
drag->icon_destroy_listener.notify = handle_drag_icon_destroy;
wl_signal_add(&icon->resource.destroy_signal,
wl_signal_add(&icon->destroy_signal,
&drag->icon_destroy_listener);
icon->configure = drag_surface_configure;

@ -178,7 +178,7 @@ default_grab_touch_down(struct weston_touch_grab *grab, uint32_t time,
display = wl_client_get_display(touch->focus_resource->client);
serial = wl_display_next_serial(display);
wl_touch_send_down(touch->focus_resource, serial, time,
&touch->focus->resource,
touch->focus->resource,
touch_id, sx, sy);
}
}
@ -242,7 +242,7 @@ find_resource_for_surface(struct wl_list *list, struct weston_surface *surface)
return NULL;
wl_list_for_each(r, list, link) {
if (r->client == surface->resource.client)
if (r->client == wl_resource_get_client(surface->resource))
return r;
}
@ -437,7 +437,7 @@ weston_pointer_set_focus(struct weston_pointer *pointer,
display = wl_client_get_display(resource->client);
serial = wl_display_next_serial(display);
wl_pointer_send_leave(resource, serial,
&pointer->focus->resource);
pointer->focus->resource);
wl_list_remove(&pointer->focus_listener.link);
}
@ -460,7 +460,7 @@ weston_pointer_set_focus(struct weston_pointer *pointer,
kbd->modifiers.group);
}
}
wl_pointer_send_enter(resource, serial, &surface->resource,
wl_pointer_send_enter(resource, serial, surface->resource,
sx, sy);
wl_signal_add(&resource->destroy_signal,
&pointer->focus_listener);
@ -485,7 +485,7 @@ weston_keyboard_set_focus(struct weston_keyboard *keyboard,
display = wl_client_get_display(resource->client);
serial = wl_display_next_serial(display);
wl_keyboard_send_leave(resource, serial,
&keyboard->focus->resource);
keyboard->focus->resource);
wl_list_remove(&keyboard->focus_listener.link);
}
@ -501,7 +501,7 @@ weston_keyboard_set_focus(struct weston_keyboard *keyboard,
keyboard->modifiers.mods_latched,
keyboard->modifiers.mods_locked,
keyboard->modifiers.group);
wl_keyboard_send_enter(resource, serial, &surface->resource,
wl_keyboard_send_enter(resource, serial, surface->resource,
&keyboard->keys);
wl_signal_add(&resource->destroy_signal,
&keyboard->focus_listener);
@ -963,7 +963,7 @@ notify_keyboard_focus_out(struct weston_seat *seat)
seat->saved_kbd_focus = keyboard->focus;
seat->saved_kbd_focus_listener.notify =
destroy_device_saved_kbd_focus;
wl_signal_add(&keyboard->focus->resource.destroy_signal,
wl_signal_add(&keyboard->focus->destroy_signal,
&seat->saved_kbd_focus_listener);
}
@ -1112,14 +1112,14 @@ pointer_set_cursor(struct wl_client *client, struct wl_resource *resource,
if (pointer->focus == NULL)
return;
if (pointer->focus->resource.client != client)
if (wl_resource_get_client(pointer->focus->resource) != client)
return;
if (pointer->focus_serial - serial > UINT32_MAX / 2)
return;
if (surface && surface != pointer->sprite) {
if (surface->configure) {
wl_resource_post_error(&surface->resource,
wl_resource_post_error(surface->resource,
WL_DISPLAY_ERROR_INVALID_OBJECT,
"surface->configure already "
"set");
@ -1133,7 +1133,7 @@ pointer_set_cursor(struct wl_client *client, struct wl_resource *resource,
if (!surface)
return;
wl_signal_add(&surface->resource.destroy_signal,
wl_signal_add(&surface->destroy_signal,
&pointer->sprite_destroy_listener);
surface->configure = pointer_cursor_surface_configure;
@ -1167,7 +1167,7 @@ seat_get_pointer(struct wl_client *client, struct wl_resource *resource,
cr->destroy = unbind_resource;
if (seat->pointer->focus &&
seat->pointer->focus->resource.client == client) {
wl_resource_get_client(seat->pointer->focus->resource) == client) {
struct weston_surface *surface;
wl_fixed_t sx, sy;
@ -1204,7 +1204,7 @@ seat_get_keyboard(struct wl_client *client, struct wl_resource *resource,
seat->xkb_info.keymap_size);
if (seat->keyboard->focus &&
seat->keyboard->focus->resource.client == client) {
wl_resource_get_client(seat->keyboard->focus->resource) == client) {
weston_keyboard_set_focus(seat->keyboard,
seat->keyboard->focus);
wl_data_device_set_keyboard_focus(seat);

@ -2001,7 +2001,7 @@ popup_grab_focus(struct weston_pointer_grab *grab)
pointer->x, pointer->y,
&sx, &sy);
if (surface && surface->resource.client == client) {
if (surface && wl_resource_get_client(surface->resource) == client) {
weston_pointer_set_focus(pointer, surface, sx, sy);
} else {
weston_pointer_set_focus(pointer, NULL,
@ -2263,7 +2263,7 @@ create_shell_surface(void *shell, struct weston_surface *surface,
wl_signal_init(&shsurf->resource.destroy_signal);
shsurf->surface_destroy_listener.notify = shell_handle_surface_destroy;
wl_signal_add(&surface->resource.destroy_signal,
wl_signal_add(&surface->destroy_signal,
&shsurf->surface_destroy_listener);
/* init link so its safe to always remove it in destroy_shell_surface */
@ -2937,8 +2937,7 @@ activate(struct desktop_shell *shell, struct weston_surface *es,
state->keyboard_focus = es;
wl_list_remove(&state->surface_destroy_listener.link);
wl_signal_add(&es->resource.destroy_signal,
&state->surface_destroy_listener);
wl_signal_add(&es->destroy_signal, &state->surface_destroy_listener);
switch (get_shell_surface_type(main_surface)) {
case SHELL_SURFACE_FULLSCREEN:
@ -3789,7 +3788,7 @@ create_input_panel_surface(struct desktop_shell *shell,
wl_signal_init(&input_panel_surface->resource.destroy_signal);
input_panel_surface->surface_destroy_listener.notify = input_panel_handle_surface_destroy;
wl_signal_add(&surface->resource.destroy_signal,
wl_signal_add(&surface->destroy_signal,
&input_panel_surface->surface_destroy_listener);
wl_list_init(&input_panel_surface->link);
@ -3956,7 +3955,7 @@ switcher_next(struct switcher *switcher)
return;
wl_list_remove(&switcher->listener.link);
wl_signal_add(&next->resource.destroy_signal, &switcher->listener);
wl_signal_add(&next->destroy_signal, &switcher->listener);
switcher->current = next;
next->alpha = 1.0;
@ -4213,7 +4212,7 @@ force_kill_binding(struct weston_seat *seat, uint32_t time, uint32_t key,
wl_signal_emit(&compositor->kill_signal, focus_surface);
client = focus_surface->resource.client;
client = wl_resource_get_client(focus_surface->resource);
wl_client_get_credentials(client, &pid, NULL, NULL);
/* Skip clients that we launched ourselves (the credentials of

@ -152,7 +152,7 @@ tablet_shell_surface_configure(struct weston_surface *surface,
}
} else if (shell->current_client &&
shell->current_client->surface != surface &&
shell->current_client->client == surface->resource.client) {
shell->current_client->client == wl_resource_get_client(surface->resource)) {
tablet_shell_set_state(shell, STATE_TASK);
shell->current_client->surface = surface;
weston_zoom_run(surface, 0.3, 1.0, NULL, NULL);
@ -186,8 +186,7 @@ tablet_shell_set_lockscreen(struct wl_client *client,
shell->lockscreen_surface = es;
shell->lockscreen_surface->configure = tablet_shell_surface_configure;
shell->lockscreen_listener.notify = handle_lockscreen_surface_destroy;
wl_signal_add(&es->resource.destroy_signal,
&shell->lockscreen_listener);
wl_signal_add(&es->destroy_signal, &shell->lockscreen_listener);
}
static void
@ -218,7 +217,7 @@ tablet_shell_set_switcher(struct wl_client *client,
weston_surface_set_position(shell->switcher_surface, 0, 0);
shell->switcher_listener.notify = handle_switcher_surface_destroy;
wl_signal_add(&es->resource.destroy_signal, &shell->switcher_listener);
wl_signal_add(&es->destroy_signal, &shell->switcher_listener);
}
static void

@ -197,7 +197,7 @@ text_input_activate(struct wl_client *client,
wl_signal_emit(&ec->update_input_panel_signal, &text_input->cursor_rectangle);
}
wl_text_input_send_enter(&text_input->resource, &text_input->surface->resource);
wl_text_input_send_enter(&text_input->resource, text_input->surface->resource);
}
static void

@ -1621,7 +1621,7 @@ weston_wm_create(struct weston_xserver *wxs)
}
xserver_send_client(wxs->resource, sv[1]);
wl_client_flush(wxs->resource->client);
wl_client_flush(wl_resource_get_client(wxs->resource));
close(sv[1]);
/* xcb_connect_to_fd takes ownership of the fd. */
@ -1715,10 +1715,9 @@ surface_destroy(struct wl_listener *listener, void *data)
static struct weston_wm_window *
get_wm_window(struct weston_surface *surface)
{
struct wl_resource *resource = &surface->resource;
struct wl_listener *listener;
listener = wl_signal_get(&resource->destroy_signal, surface_destroy);
listener = wl_signal_get(&surface->destroy_signal, surface_destroy);
if (listener)
return container_of(listener, struct weston_wm_window,
surface_destroy_listener);
@ -1850,9 +1849,10 @@ static void
xserver_set_window_id(struct wl_client *client, struct wl_resource *resource,
struct wl_resource *surface_resource, uint32_t id)
{
struct weston_xserver *wxs = resource->data;
struct weston_xserver *wxs = wl_resource_get_user_data(resource);
struct weston_wm *wm = wxs->wm;
struct weston_surface *surface = surface_resource->data;
struct weston_surface *surface =
wl_resource_get_user_data(surface_resource);
struct weston_wm_window *window;
if (client != wxs->client)
@ -1870,7 +1870,7 @@ xserver_set_window_id(struct wl_client *client, struct wl_resource *resource,
window->surface = (struct weston_surface *) surface;
window->surface_destroy_listener.notify = surface_destroy;
wl_signal_add(&surface->resource.destroy_signal,
wl_signal_add(&surface->destroy_signal,
&window->surface_destroy_listener);
weston_wm_window_schedule_repaint(window);

@ -40,7 +40,10 @@ text_cursor_position_notify(struct wl_client *client,
struct wl_resource *surface_resource,
wl_fixed_t x, wl_fixed_t y)
{
weston_text_cursor_position_notify((struct weston_surface *) surface_resource, x, y);
struct weston_surface *surface =
wl_resource_get_user_data(surface_resource);
weston_text_cursor_position_notify(surface, x, y);
}
struct text_cursor_position_interface text_cursor_position_implementation = {

Loading…
Cancel
Save