};
struct shell_surface {
- struct wl_resource resource;
+ struct wl_resource *resource;
+ struct wl_signal destroy_signal;
struct weston_surface *surface;
struct wl_listener surface_destroy_listener;
grab->grab.interface = interface;
grab->shsurf = shsurf;
grab->shsurf_destroy_listener.notify = destroy_shell_grab_shsurf;
- wl_signal_add(&shsurf->resource.destroy_signal,
+ wl_signal_add(&shsurf->destroy_signal,
&grab->shsurf_destroy_listener);
grab->pointer = pointer;
wl_list_for_each(state, &ws->focus_list, link) {
if (state->seat == seat) {
surface = seat->keyboard->focus;
- state->keyboard_focus =
- (struct weston_surface *) surface;
+ state->keyboard_focus = surface;
return;
}
}
static void
broadcast_current_workspace_state(struct desktop_shell *shell)
{
- struct wl_resource *resource;
+ struct wl_list *link;
- wl_list_for_each(resource, &shell->workspaces.client_list, link)
- workspace_manager_send_state(resource,
+ for (link = shell->workspaces.client_list.next;
+ link != &shell->workspaces.client_list;
+ link = link->next) {
+ workspace_manager_send_state(wl_resource_from_link(link),
shell->workspaces.current,
shell->workspaces.num);
+ }
}
static void
struct wl_resource *surface_resource,
uint32_t workspace)
{
- struct desktop_shell *shell = resource->data;
+ struct desktop_shell *shell = wl_resource_get_user_data(resource);
struct weston_surface *surface =
wl_resource_get_user_data(surface_resource);
struct weston_surface *main_surface;
static void
unbind_resource(struct wl_resource *resource)
{
- wl_list_remove(&resource->link);
+ wl_list_remove(wl_resource_get_link(resource));
free(resource);
}
return;
}
- resource->destroy = unbind_resource;
- wl_list_insert(&shell->workspaces.client_list, &resource->link);
+ wl_resource_set_destructor(resource, unbind_resource);
+ wl_list_insert(&shell->workspaces.client_list,
+ wl_resource_get_link(resource));
workspace_manager_send_state(resource,
shell->workspaces.current,
struct wl_resource *seat_resource, uint32_t serial)
{
struct weston_seat *seat = seat_resource->data;
- struct shell_surface *shsurf = resource->data;
+ struct shell_surface *shsurf = wl_resource_get_user_data(resource);
struct weston_surface *surface;
surface = weston_surface_get_main_surface(seat->pointer->focus);
{
struct shell_surface *shsurf = get_shell_surface(surface);
- wl_shell_surface_send_configure(&shsurf->resource,
+ wl_shell_surface_send_configure(shsurf->resource,
edges, width, height);
}
uint32_t edges)
{
struct weston_seat *seat = seat_resource->data;
- struct shell_surface *shsurf = resource->data;
+ struct shell_surface *shsurf = wl_resource_get_user_data(resource);
struct weston_surface *surface;
if (shsurf->type == SHELL_SURFACE_FULLSCREEN)
if (!shsurf)
return;
- if (!shsurf->resource.client)
+ if (!shsurf->resource)
return;
if (shsurf->surface == shsurf->shell->grab_surface)
wl_event_loop_add_timer(loop, ping_timeout_handler, shsurf);
wl_event_source_timer_update(shsurf->ping_timer->source, ping_timeout);
- wl_shell_surface_send_ping(&shsurf->resource, serial);
+ wl_shell_surface_send_ping(shsurf->resource, serial);
}
}
handle_pointer_focus(struct wl_listener *listener, void *data)
{
struct weston_pointer *pointer = data;
- struct weston_surface *surface =
- (struct weston_surface *) pointer->focus;
+ struct weston_surface *surface = pointer->focus;
struct weston_compositor *compositor;
struct shell_surface *shsurf;
uint32_t serial;
shell_surface_pong(struct wl_client *client, struct wl_resource *resource,
uint32_t serial)
{
- struct shell_surface *shsurf = resource->data;
+ struct shell_surface *shsurf = wl_resource_get_user_data(resource);
struct weston_seat *seat;
struct weston_compositor *ec = shsurf->surface->compositor;
shell_surface_set_title(struct wl_client *client,
struct wl_resource *resource, const char *title)
{
- struct shell_surface *shsurf = resource->data;
+ struct shell_surface *shsurf = wl_resource_get_user_data(resource);
free(shsurf->title);
shsurf->title = strdup(title);
shell_surface_set_class(struct wl_client *client,
struct wl_resource *resource, const char *class)
{
- struct shell_surface *shsurf = resource->data;
+ struct shell_surface *shsurf = wl_resource_get_user_data(resource);
free(shsurf->class);
shsurf->class = strdup(class);
shell_surface_set_toplevel(struct wl_client *client,
struct wl_resource *resource)
{
- struct shell_surface *surface = resource->data;
+ struct shell_surface *surface = wl_resource_get_user_data(resource);
set_toplevel(surface);
}
struct wl_resource *parent_resource,
int x, int y, uint32_t flags)
{
- struct shell_surface *shsurf = resource->data;
+ struct shell_surface *shsurf = wl_resource_get_user_data(resource);
struct weston_surface *parent =
wl_resource_get_user_data(parent_resource);
struct wl_resource *resource,
struct wl_resource *output_resource )
{
- struct shell_surface *shsurf = resource->data;
+ struct shell_surface *shsurf = wl_resource_get_user_data(resource);
struct weston_surface *es = shsurf->surface;
struct desktop_shell *shell = NULL;
uint32_t edges = 0, panel_height = 0;
uint32_t framerate,
struct wl_resource *output_resource)
{
- struct shell_surface *shsurf = resource->data;
+ struct shell_surface *shsurf = wl_resource_get_user_data(resource);
struct weston_output *output;
if (output_resource)
resource = grab->pointer->focus_resource;
if (resource) {
- display = wl_client_get_display(resource->client);
+ display = wl_client_get_display(wl_resource_get_client(resource));
serial = wl_display_get_serial(display);
wl_pointer_send_button(resource, serial, time, button, state);
} else if (state == WL_POINTER_BUTTON_STATE_RELEASED &&
assert(!wl_list_empty(&shseat->popup_grab.surfaces_list));
/* Send the popup_done event to all the popups open */
wl_list_for_each(shsurf, &shseat->popup_grab.surfaces_list, popup.grab_link) {
- wl_shell_surface_send_popup_done(&shsurf->resource);
+ wl_shell_surface_send_popup_done(shsurf->resource);
shsurf->popup.shseat = NULL;
if (prev) {
wl_list_init(&prev->popup.grab_link);
struct weston_seat *seat = shseat->seat;
if (wl_list_empty(&shseat->popup_grab.surfaces_list)) {
- shseat->popup_grab.client = shsurf->resource.client;
+ shseat->popup_grab.client = wl_resource_get_client(shsurf->resource);
shseat->popup_grab.grab.interface = &popup_grab_interface;
/* We must make sure here that this popup was opened after
* a mouse press, and not just by moving around with other
if (shseat->seat->pointer->grab_serial == shsurf->popup.serial) {
add_popup_grab(shsurf, shseat);
} else {
- wl_shell_surface_send_popup_done(&shsurf->resource);
+ wl_shell_surface_send_popup_done(shsurf->resource);
shseat->popup_grab.client = NULL;
}
}
struct wl_resource *parent_resource,
int32_t x, int32_t y, uint32_t flags)
{
- struct shell_surface *shsurf = resource->data;
+ struct shell_surface *shsurf = wl_resource_get_user_data(resource);
shsurf->type = SHELL_SURFACE_POPUP;
- shsurf->parent = parent_resource->data;
+ shsurf->parent = wl_resource_get_user_data(parent_resource);
shsurf->popup.shseat = get_shell_seat(seat_resource->data);
shsurf->popup.serial = serial;
shsurf->popup.x = x;
static void
destroy_shell_surface(struct shell_surface *shsurf)
{
+ wl_signal_emit(&shsurf->destroy_signal, shsurf);
+
if (!wl_list_empty(&shsurf->popup.grab_link)) {
remove_popup_grab(shsurf);
}
static void
shell_destroy_shell_surface(struct wl_resource *resource)
{
- struct shell_surface *shsurf = resource->data;
+ struct shell_surface *shsurf = wl_resource_get_user_data(resource);
destroy_shell_surface(shsurf);
}
struct shell_surface,
surface_destroy_listener);
- if (shsurf->resource.client) {
- wl_resource_destroy(&shsurf->resource);
- } else {
- wl_signal_emit(&shsurf->resource.destroy_signal,
- &shsurf->resource);
+ if (shsurf->resource)
+ wl_resource_destroy(shsurf->resource);
+ else
destroy_shell_surface(shsurf);
- }
}
static void
shsurf->ping_timer = NULL;
wl_list_init(&shsurf->fullscreen.transform.link);
- wl_signal_init(&shsurf->resource.destroy_signal);
+ wl_signal_init(&shsurf->destroy_signal);
shsurf->surface_destroy_listener.notify = shell_handle_surface_destroy;
wl_signal_add(&surface->destroy_signal,
&shsurf->surface_destroy_listener);
{
struct weston_surface *surface =
wl_resource_get_user_data(surface_resource);
- struct desktop_shell *shell = resource->data;
+ struct desktop_shell *shell = wl_resource_get_user_data(resource);
struct shell_surface *shsurf;
if (get_shell_surface(surface)) {
return;
}
- shsurf->resource.destroy = shell_destroy_shell_surface;
- shsurf->resource.object.id = id;
- shsurf->resource.object.interface = &wl_shell_surface_interface;
- shsurf->resource.object.implementation =
- (void (**)(void)) &shell_surface_implementation;
- shsurf->resource.data = shsurf;
-
- wl_client_add_resource(client, &shsurf->resource);
+ 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);
}
static const struct wl_shell_interface shell_implementation = {
struct wl_resource *output_resource,
struct wl_resource *surface_resource)
{
- struct desktop_shell *shell = resource->data;
+ struct desktop_shell *shell = wl_resource_get_user_data(resource);
struct weston_surface *surface =
wl_resource_get_user_data(surface_resource);
struct wl_resource *output_resource,
struct wl_resource *surface_resource)
{
- struct desktop_shell *shell = resource->data;
+ struct desktop_shell *shell = wl_resource_get_user_data(resource);
struct weston_surface *surface =
wl_resource_get_user_data(surface_resource);
struct wl_resource *resource,
struct wl_resource *surface_resource)
{
- struct desktop_shell *shell = resource->data;
+ struct desktop_shell *shell = wl_resource_get_user_data(resource);
struct weston_surface *surface =
wl_resource_get_user_data(surface_resource);
shell->lock_surface = surface;
shell->lock_surface_listener.notify = handle_lock_surface_destroy;
- wl_signal_add(&surface_resource->destroy_signal,
+ wl_signal_add(&surface->destroy_signal,
&shell->lock_surface_listener);
surface->configure = lock_surface_configure;
desktop_shell_unlock(struct wl_client *client,
struct wl_resource *resource)
{
- struct desktop_shell *shell = resource->data;
+ struct desktop_shell *shell = wl_resource_get_user_data(resource);
shell->prepare_event_sent = false;
struct wl_resource *resource,
struct wl_resource *surface_resource)
{
- struct desktop_shell *shell = resource->data;
+ struct desktop_shell *shell = wl_resource_get_user_data(resource);
shell->grab_surface = wl_resource_get_user_data(surface_resource);
}
desktop_shell_desktop_ready(struct wl_client *client,
struct wl_resource *resource)
{
- struct desktop_shell *shell = resource->data;
+ struct desktop_shell *shell = wl_resource_get_user_data(resource);
shell_fade_startup(shell);
}
static void
unbind_desktop_shell(struct wl_resource *resource)
{
- struct desktop_shell *shell = resource->data;
+ struct desktop_shell *shell = wl_resource_get_user_data(resource);
if (shell->locked)
resume_desktop(shell);
id, shell);
if (client == shell->child.client) {
- resource->destroy = unbind_desktop_shell;
+ wl_resource_set_destructor(resource, unbind_desktop_shell);
shell->child.desktop_shell = resource;
if (version < 2)
struct wl_resource *surface_resource,
struct wl_resource *output_resource)
{
- struct desktop_shell *shell = resource->data;
+ struct desktop_shell *shell = wl_resource_get_user_data(resource);
struct weston_surface *surface =
wl_resource_get_user_data(surface_resource);
struct weston_output *output = output_resource->data;
static void
unbind_screensaver(struct wl_resource *resource)
{
- struct desktop_shell *shell = resource->data;
+ struct desktop_shell *shell = wl_resource_get_user_data(resource);
shell->screensaver.binding = NULL;
free(resource);
id, shell);
if (shell->screensaver.binding == NULL) {
- resource->destroy = unbind_screensaver;
+ wl_resource_set_destructor(resource, unbind_screensaver);
shell->screensaver.binding = resource;
return;
}
{
struct weston_surface *surface =
wl_resource_get_user_data(surface_resource);
- struct desktop_shell *shell = resource->data;
+ struct desktop_shell *shell = wl_resource_get_user_data(resource);
struct input_panel_surface *ipsurf;
if (get_input_panel_surface(surface)) {
static void
unbind_input_panel(struct wl_resource *resource)
{
- struct desktop_shell *shell = resource->data;
+ struct desktop_shell *shell = wl_resource_get_user_data(resource);
shell->input_panel.binding = NULL;
free(resource);
resource = grab->keyboard->focus_resource;
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);
}