WL_EXPORT int wet_shell_init(struct weston_compositor *ec, int *argc, char *argv[]) { struct desktest_shell *dts; dts = zalloc(sizeof *dts); if (!dts) return -1; dts->compositor_destroy_listener.notify = shell_destroy; wl_signal_add(&ec->destroy_signal, &dts->compositor_destroy_listener); weston_layer_init(&dts->layer, ec); weston_layer_init(&dts->background_layer, ec); weston_layer_set_position(&dts->layer, WESTON_LAYER_POSITION_NORMAL); weston_layer_set_position(&dts->background_layer, WESTON_LAYER_POSITION_BACKGROUND); dts->background_surface = weston_surface_create(ec); if (dts->background_surface == NULL) goto out_free; dts->background_view = weston_view_create(dts->background_surface); if (dts->background_view == NULL) goto out_surface; weston_surface_set_color(dts->background_surface, 0.16, 0.32, 0.48, 1.); pixman_region32_fini(&dts->background_surface->opaque); pixman_region32_init_rect(&dts->background_surface->opaque, 0, 0, 2000, 2000); pixman_region32_fini(&dts->background_surface->input); pixman_region32_init_rect(&dts->background_surface->input, 0, 0, 2000, 2000); weston_surface_set_size(dts->background_surface, 2000, 2000); weston_view_set_position(dts->background_view, 0, 0); weston_layer_entry_insert(&dts->background_layer.view_list, &dts->background_view->layer_link); weston_view_update_transform(dts->background_view); dts->desktop = weston_desktop_create(ec, &shell_desktop_api, dts); if (dts->desktop == NULL) goto out_view; return 0; out_view: weston_view_destroy(dts->background_view); out_surface: weston_surface_destroy(dts->background_surface); out_free: free(dts); return -1; }
static void desktop_surface_removed(struct weston_desktop_surface *desktop_surface, void *shell) { struct desktest_shell *dts = shell; assert(dts->view); weston_desktop_surface_unlink_view(dts->view); weston_view_destroy(dts->view); dts->view = NULL; }
static void shell_destroy(struct wl_listener *listener, void *data) { struct desktest_shell *dts; dts = container_of(listener, struct desktest_shell, compositor_destroy_listener); weston_desktop_destroy(dts->desktop); weston_view_destroy(dts->background_view); weston_surface_destroy(dts->background_surface); free(dts); }
static void data_device_end_drag_grab(struct weston_drag *drag, struct weston_seat *seat) { if (drag->icon) { if (weston_view_is_mapped(drag->icon)) weston_view_unmap(drag->icon); drag->icon->surface->configure = NULL; empty_region(&drag->icon->surface->pending.input); wl_list_remove(&drag->icon_destroy_listener.link); weston_view_destroy(drag->icon); } weston_drag_set_focus(drag, seat, NULL, 0, 0); }