static void pointer_set_cursor (struct wl_client *client, struct wl_resource *resource, uint32_t serial, struct wl_resource *surface_resource, int32_t x, int32_t y) { ClaylandSeat *seat = wl_resource_get_user_data (resource); ClaylandSurface *surface; surface = (surface_resource ? wl_resource_get_user_data (surface_resource) : NULL); if (seat->pointer.focus == NULL) return; if (wl_resource_get_client (seat->pointer.focus->resource) != client) return; if (seat->pointer.focus_serial - serial > G_MAXUINT32 / 2) return; pointer_unmap_sprite (seat); if (!surface) return; wl_resource_add_destroy_listener (surface->resource, &seat->sprite_destroy_listener); seat->sprite = surface; seat->hotspot_x = x; seat->hotspot_y = y; }
static void xdg_cb_surface_set_parent(struct wl_client *client, struct wl_resource *resource, struct wl_resource *parent_resource) { (void)client; struct wlc_view *view; if (!(view = convert_from_wlc_handle((wlc_handle)wl_resource_get_user_data(resource), "view"))) return; struct wlc_view *parent = (parent_resource ? convert_from_wlc_handle((wlc_handle)wl_resource_get_user_data(parent_resource), "view") : NULL); wlc_view_set_parent_ptr(view, parent); }
static void data_device_set_selection(struct wl_client *client, struct wl_resource *resource, struct wl_resource *source_resource, uint32_t serial) { if (!source_resource) return; /* FIXME: Store serial and check against incoming serial here. */ weston_seat_set_selection(wl_resource_get_user_data(resource), wl_resource_get_user_data(source_resource), serial); }
static void get_xdg_popup(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *surface_resource, struct wl_resource *parent_resource, struct wl_resource *seat_resource, uint32_t serial, int32_t x, int32_t y) { struct surface *surface = wl_resource_get_user_data(surface_resource); struct surface *parent = wl_resource_get_user_data(parent_resource); struct xdg_popup *popup; popup = xdg_popup_new(client, wl_resource_get_version(resource), id, surface, parent, x, y); if (!popup) wl_resource_post_no_memory(resource); }
static bool subcomp_defer_handler( struct surface_request* req, struct arcan_shmif_cont* con) { if (!con){ trace(TRACE_SHELL, "reqfail"); wl_resource_post_no_memory(req->target); return false; } struct wl_resource* subsurf = wl_resource_create(req->client->client, &wl_subsurface_interface, wl_resource_get_version(req->target), req->id); if (!subsurf){ trace(TRACE_SHELL, "reqfail"); wl_resource_post_no_memory(req->target); return false; } struct comp_surf* surf = wl_resource_get_user_data(req->target); wl_resource_set_implementation(subsurf, &subsurf_if, surf, NULL); if (!surf){ trace(TRACE_SHELL, "reqfail"); wl_resource_post_no_memory(req->target); return false; } surf->acon = *con; surf->cookie = 0xfeedface; surf->shell_res = subsurf; surf->dispatch = subsurf_shmifev_handler; surf->sub_parent_res = req->parent; snprintf(surf->tracetag, SURF_TAGLEN, "subsurf"); if (req->parent){ struct comp_surf* psurf = wl_resource_get_user_data(req->parent); if (!psurf->acon.addr){ trace(TRACE_ALLOC, "bad subsurface, broken parent"); return false; } surf->viewport.ext.kind = ARCAN_EVENT(VIEWPORT); surf->viewport.ext.viewport.parent = psurf->acon.segment_token; arcan_shmif_enqueue(&surf->acon, &surf->viewport); } trace(TRACE_ALLOC, "subsurface"); return true; }
static void xdgpos_anchor(struct wl_client* cl, struct wl_resource* res, uint32_t anchor) { trace(TRACE_SHELL, "%"PRIu32, anchor); struct positioner* pos = wl_resource_get_user_data(res); pos->anchor = anchor; }
static void destroy_pool(struct wl_resource *resource) { struct wl_shm_pool *pool = wl_resource_get_user_data(resource); shm_pool_unref(pool); }
static void wl_cb_shell_surface_set_maximized(struct wl_client *client, struct wl_resource *resource, struct wl_resource *output_resource) { (void)client; struct wlc_view *view; if (!(view = convert_from_wlc_handle((wlc_handle)wl_resource_get_user_data(resource), "view"))) return; if (!wlc_view_request_state(view, WLC_BIT_MAXIMIZED, true)) return; struct wlc_output *output; if (output_resource && ((output = convert_from_wlc_handle((wlc_handle)wl_resource_get_user_data(output_resource), "output")))) wlc_view_set_output_ptr(view, output); }
static void seat_get_keyboard (struct wl_client *client, struct wl_resource *resource, uint32_t id) { ClaylandSeat *seat = wl_resource_get_user_data (resource); struct wl_resource *cr; cr = wl_client_add_object (client, &wl_keyboard_interface, NULL, id, seat); wl_list_insert (&seat->keyboard.resource_list, wl_resource_get_link (cr)); wl_resource_set_destructor (cr, unbind_resource); wl_keyboard_send_keymap (cr, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, seat->keyboard.xkb_info.keymap_fd, seat->keyboard.xkb_info.keymap_size); if (seat->keyboard.focus && wl_resource_get_client (seat->keyboard.focus->resource) == client) { clayland_keyboard_set_focus (&seat->keyboard, seat->keyboard.focus); clayland_data_device_set_keyboard_focus (seat); } }
static void xdgpos_consadj(struct wl_client* cl, struct wl_resource* res, uint32_t constraint_adjustment) { trace(TRACE_SHELL, "%"PRIu32, constraint_adjustment); struct positioner* pos = wl_resource_get_user_data(res); pos->constraints = constraint_adjustment; }
static void destroy_buffer(struct wl_resource *resource) { struct wl_gdl_buffer *buffer = wl_resource_get_user_data(resource); free(buffer); }
static void _e_shell_surface_destroy(struct wl_resource *resource) { E_Client *ec; /* DBG("Shell Surface Destroy: %d", wl_resource_get_id(resource)); */ /* get the client for this resource */ if ((ec = wl_resource_get_user_data(resource))) { if (!e_object_unref(E_OBJECT(ec))) return; if (e_object_is_del(E_OBJECT(ec))) return; if (ec->comp_data) { E_FREE(ec->comp_data->shell.data); if (ec->comp_data->mapped) { if ((ec->comp_data->shell.surface) && (ec->comp_data->shell.unmap)) ec->comp_data->shell.unmap(ec->comp_data->shell.surface); } if (ec->parent) { ec->parent->transients = eina_list_remove(ec->parent->transients, ec); } /* wl_resource_destroy(ec->comp_data->shell.surface); */ ec->comp_data->shell.surface = NULL; } } }
static void seat_get_pointer (struct wl_client *client, struct wl_resource *resource, uint32_t id) { ClaylandSeat *seat = wl_resource_get_user_data (resource); struct wl_resource *cr; cr = wl_client_add_object (client, &wl_pointer_interface, &pointer_interface, id, seat); wl_list_insert (&seat->pointer.resource_list, wl_resource_get_link (cr)); wl_resource_set_destructor (cr, unbind_resource); if (seat->pointer.focus && wl_resource_get_client (seat->pointer.focus->resource) == client) { ClaylandSurface *surface; wl_fixed_t sx, sy; surface = (ClaylandSurface *) seat->pointer.focus; transform_stage_point_fixed (surface, seat->pointer.x, seat->pointer.y, &sx, &sy); clayland_pointer_set_focus (&seat->pointer, seat->pointer.focus, sx, sy); } }
static void set_selection(struct wl_client * client, struct wl_resource * resource, struct wl_resource * data_source, uint32_t serial) { struct data_device * data_device = wl_resource_get_user_data(resource); /* Check if this data source is already the current selection. */ if (data_source == data_device->selection) return; if (data_device->selection) { wl_data_source_send_cancelled(data_device->selection); wl_list_remove(&data_device->selection_destroy_listener.link); } data_device->selection = data_source; if (data_source) { wl_resource_add_destroy_listener (data_source, &data_device->selection_destroy_listener); } swc_send_event(&data_device->event_signal, DATA_DEVICE_EVENT_SELECTION_CHANGED, NULL); }
static void runner_run_handler(struct wl_client *client, struct wl_resource *resource, const char *test_name) { struct test_launcher *launcher; const struct runner_test *t; assert(static_context.runner_resource == NULL || static_context.runner_resource == resource); launcher = wl_resource_get_user_data(resource); static_context.layout_interface = launcher->layout_interface; static_context.runner_resource = resource; t = find_runner_test(test_name); if (!t) { weston_log("Error: runner test \"%s\" not found.\n", test_name); wl_resource_post_error(resource, WESTON_TEST_RUNNER_ERROR_UNKNOWN_TEST, "weston_test_runner: unknown: '%s'", test_name); return; } weston_log("weston_test_runner.run(\"%s\")\n", test_name); t->run(&static_context); weston_test_runner_send_finished(resource); }
static void set_title(struct wl_client * client, struct wl_resource * resource, const char * title) { struct shell_surface * shell_surface = wl_resource_get_user_data(resource); window_set_title(&shell_surface->window, title, -1); }
static void cogland_compositor_create_surface (struct wl_client *wayland_client, struct wl_resource *wayland_compositor_resource, uint32_t id) { CoglandCompositor *compositor = wl_resource_get_user_data (wayland_compositor_resource); CoglandSurface *surface = g_slice_new0 (CoglandSurface); surface->compositor = compositor; wl_signal_init (&surface->destroy_signal); surface->resource = wl_client_add_object (wayland_client, &wl_surface_interface, &cogland_surface_interface, id, surface); wl_resource_set_destructor (surface->resource, cogland_surface_resource_destroy_cb); surface->pending.buffer_destroy_listener.notify = surface_handle_pending_buffer_destroy; wl_list_init (&surface->pending.frame_callback_list); region_init (&surface->pending.damage); compositor->surfaces = g_list_prepend (compositor->surfaces, surface); }
static void cogland_region_resource_destroy_cb (struct wl_resource *resource) { CoglandSharedRegion *region = wl_resource_get_user_data (resource); g_slice_free (CoglandSharedRegion, region); }
static void get_shell_surface (struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *surface_resource) { CoglandSurface *surface = wl_resource_get_user_data (surface_resource); CoglandShellSurface *shell_surface; if (surface->has_shell_surface) { wl_resource_post_error (surface_resource, WL_DISPLAY_ERROR_INVALID_OBJECT, "wl_shell::get_shell_surface already requested"); return; } shell_surface = g_new0 (CoglandShellSurface, 1); shell_surface->surface = surface; shell_surface->surface_destroy_listener.notify = shell_handle_surface_destroy; wl_signal_add (&surface->destroy_signal, &shell_surface->surface_destroy_listener); surface->has_shell_surface = TRUE; shell_surface->resource = wl_client_add_object (client, &wl_shell_surface_interface, &cogl_shell_surface_interface, id, shell_surface); wl_resource_set_destructor (shell_surface->resource, destroy_shell_surface_cb); }
static void cogland_surface_attach (struct wl_client *wayland_client, struct wl_resource *wayland_surface_resource, struct wl_resource *wayland_buffer_resource, int32_t sx, int32_t sy) { CoglandSurface *surface = wl_resource_get_user_data (wayland_surface_resource); CoglandBuffer *buffer; if (wayland_buffer_resource) buffer = cogland_buffer_from_resource (wayland_buffer_resource); else buffer = NULL; /* Attach without commit in between does not went wl_buffer.release */ if (surface->pending.buffer) wl_list_remove (&surface->pending.buffer_destroy_listener.link); surface->pending.sx = sx; surface->pending.sy = sy; surface->pending.buffer = buffer; surface->pending.newly_attached = TRUE; if (buffer) wl_signal_add (&buffer->destroy_signal, &surface->pending.buffer_destroy_listener); }
static void wp_viewporter_get_viewport (struct wl_client *client, struct wl_resource *resource, uint32_t viewport_id, struct wl_resource *surface_resource) { MetaWaylandSurface *surface; struct wl_resource *viewport_resource; surface = wl_resource_get_user_data (surface_resource); if (surface->viewport.resource) { wl_resource_post_error (resource, WP_VIEWPORTER_ERROR_VIEWPORT_EXISTS, "viewport already exists on surface"); return; } viewport_resource = wl_resource_create (client, &wp_viewport_interface, wl_resource_get_version (resource), viewport_id); wl_resource_set_implementation (viewport_resource, &meta_wayland_viewport_interface, surface, wp_viewport_destructor); surface->viewport.resource = viewport_resource; surface->viewport.destroy_handler_id = g_signal_connect (surface, "destroy", G_CALLBACK (on_surface_destroyed), NULL); }
static void wp_viewport_set_destination (struct wl_client *client, struct wl_resource *resource, int dst_width, int dst_height) { MetaWaylandSurface *surface; surface = wl_resource_get_user_data (resource); if (!surface) { wl_resource_post_error (resource, WP_VIEWPORT_ERROR_NO_SURFACE, "wl_surface for this viewport no longer exists"); return; } if ((dst_width > 0 && dst_height > 0) || (dst_width == -1 && dst_height == -1)) { surface->pending->viewport_dst_width = dst_width; surface->pending->viewport_dst_height = dst_height; surface->pending->has_new_viewport_dst_size = TRUE; } else { wl_resource_post_error (resource, WP_VIEWPORT_ERROR_BAD_VALUE, "all values must be either positive or -1"); } }
static void xdgpos_offset(struct wl_client* cl, struct wl_resource* res, int32_t x, int32_t y) { trace(TRACE_SHELL, "+x,y: %"PRId32", %"PRId32, x, y); struct positioner* pos = wl_resource_get_user_data(res); pos->ofs_x = x; pos->ofs_y = y; }
static void data_device_set_selection (struct wl_client *client, struct wl_resource *resource, struct wl_resource *source_resource, guint32 serial) { MetaWaylandDataDevice *data_device = wl_resource_get_user_data (resource); MetaWaylandDataSource *source; if (!source_resource) return; source = wl_resource_get_user_data (source_resource); /* FIXME: Store serial and check against incoming serial here. */ meta_wayland_data_device_set_selection (data_device, source, serial); }
/* * allocation is similar to a popup */ static void subcomp_subsurf(struct wl_client* client, struct wl_resource* res, uint32_t id, struct wl_resource* surf, struct wl_resource* parent) { trace(TRACE_ALLOC, "id: %"PRId32", parent: %"PRIxPTR, id, (uintptr_t)parent); struct comp_surf* csurf = wl_resource_get_user_data(surf); struct comp_surf* parent_surf = wl_resource_get_user_data(parent); request_surface(parent_surf->client, &(struct surface_request){ .segid = SEGID_MEDIA, .target = surf, .id = id, .trace = "subsurface", .dispatch = subcomp_defer_handler, .client = parent_surf->client, .source = csurf, .parent = parent }, 's');
static void xdgpos_gravity(struct wl_client* cl, struct wl_resource* res, uint32_t gravity) { trace(TRACE_SHELL, "%"PRIu32, gravity); struct positioner* pos = wl_resource_get_user_data(res); /* ENFORCE: if the gravity constraints are invalid, send invalid input */ pos->gravity = gravity; }
struct wld_buffer * wayland_buffer_get(struct wl_resource *resource) { if (wl_resource_instance_of(resource, &wl_buffer_interface, &buffer_implementation)) return wl_resource_get_user_data(resource); return NULL; }
static void output_resource_destroy (struct wl_resource *res) { MetaWaylandOutput *wayland_output; wayland_output = wl_resource_get_user_data (res); wayland_output->resources = g_list_remove (wayland_output->resources, res); }
static void wl_region_destructor (struct wl_resource *resource) { MetaWaylandRegion *region = wl_resource_get_user_data (resource); cairo_region_destroy (region->region); g_slice_free (MetaWaylandRegion, region); }
static void region_destroy(struct wl_resource *resource) { struct region *region = wl_resource_get_user_data(resource); pixman_region32_fini(®ion->region); free(region); }