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 handle_surface(struct test_client *client) { uint32_t id; struct wl_resource *resource; struct weston_surface *surface; struct text_test_data *data = client->data; struct weston_seat *seat; assert(sscanf(client->buf, "surface %u", &id) == 1); fprintf(stderr, "got surface id %u\n", id); resource = wl_client_get_object(client->client, id); assert(resource); assert(strcmp(resource->object.interface->name, "wl_surface") == 0); surface = (struct weston_surface *) resource; weston_surface_configure(surface, 100, 100, 200, 200); weston_surface_update_transform(surface); weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1.0); data->layer = malloc(sizeof *data->layer); weston_layer_init(data->layer, &client->compositor->cursor_layer.link); wl_list_insert(&data->layer->surface_list, &surface->layer_link); weston_surface_damage(surface); seat = get_seat(client); client->compositor->focus = 1; /* Make it work even if pointer is * outside X window. */ wl_keyboard_set_focus(&seat->keyboard, &surface->surface); test_client_send(client, "create-text-model\n"); client->handle = handle_text_model; }