static struct weston_compositor *
headless_compositor_create(struct wl_display *display,
			   struct headless_parameters *param,
			   const char *display_name,
			   int *argc, char *argv[],
			   struct weston_config *config)
{
	struct headless_compositor *c;

	c = zalloc(sizeof *c);
	if (c == NULL)
		return NULL;

	if (weston_compositor_init(&c->base, display, argc, argv, config) < 0)
		goto err_free;

	if (weston_compositor_set_presentation_clock_software(&c->base) < 0)
		goto err_compositor;

	if (headless_input_create(c) < 0)
		goto err_compositor;

	c->base.destroy = headless_destroy;
	c->base.restore = headless_restore;

	c->use_pixman = param->use_pixman;
	if (c->use_pixman) {
		pixman_renderer_init(&c->base);
	}
	if (headless_compositor_create_output(c, param) < 0)
		goto err_input;

	if (!c->use_pixman && noop_renderer_init(&c->base) < 0)
		goto err_input;

	return &c->base;

err_input:
	headless_input_destroy(c);
err_compositor:
	weston_compositor_shutdown(&c->base);
err_free:
	free(c);
	return NULL;
}
Exemplo n.º 2
0
static struct weston_compositor *
headless_compositor_create(struct wl_display *display,
			  int width, int height, const char *display_name,
			  int argc, char *argv[], const char *config_file)
{
	struct headless_compositor *c;

	c = calloc(1, sizeof *c);
	if (c == NULL)
		return NULL;

	memset(c, 0, sizeof *c);

	if (weston_compositor_init(&c->base, display, argc, argv,
				   config_file) < 0)
		goto err_free;

	weston_seat_init(&c->fake_seat, &c->base);

	c->base.destroy = headless_destroy;
	c->base.restore = headless_restore;

	if (headless_compositor_create_output(c, width, height) < 0)
		goto err_compositor;

	if (noop_renderer_init(&c->base) < 0)
		goto err_compositor;

	return &c->base;

err_compositor:
	weston_compositor_shutdown(&c->base);
err_free:
	free(c);
	return NULL;
}
Exemplo n.º 3
0
static struct weston_compositor *
wayland_compositor_create(struct wl_display *display,
			  int width, int height, const char *display_name,
			  int *argc, char *argv[],
			  struct weston_config *config)
{
	struct wayland_compositor *c;
	struct wl_event_loop *loop;
	int fd;

	c = malloc(sizeof *c);
	if (c == NULL)
		return NULL;

	memset(c, 0, sizeof *c);

	if (weston_compositor_init(&c->base, display, argc, argv,
				   config) < 0)
		goto err_free;

	c->parent.wl_display = wl_display_connect(display_name);

	if (c->parent.wl_display == NULL) {
		weston_log("failed to create display: %m\n");
		goto err_compositor;
	}

	wl_list_init(&c->input_list);
	c->parent.registry = wl_display_get_registry(c->parent.wl_display);
	wl_registry_add_listener(c->parent.registry, &registry_listener, c);
	wl_display_dispatch(c->parent.wl_display);

	c->base.wl_display = display;
	if (gl_renderer_create(&c->base, c->parent.wl_display,
			gl_renderer_alpha_attribs,
			NULL) < 0)
		goto err_display;

	c->base.destroy = wayland_destroy;
	c->base.restore = wayland_restore;

	c->border.top = 30;
	c->border.bottom = 24;
	c->border.left = 25;
	c->border.right = 26;

	/* requires border fields */
	if (wayland_compositor_create_output(c, width, height) < 0)
		goto err_gl;

	/* requires gl_renderer_output_state_create called
	 * by wayland_compositor_create_output */
	create_border(c);

	loop = wl_display_get_event_loop(c->base.wl_display);

	fd = wl_display_get_fd(c->parent.wl_display);
	c->parent.wl_source =
		wl_event_loop_add_fd(loop, fd, WL_EVENT_READABLE,
				     wayland_compositor_handle_event, c);
	if (c->parent.wl_source == NULL)
		goto err_gl;

	wl_event_source_check(c->parent.wl_source);

	return &c->base;

err_gl:
	c->base.renderer->destroy(&c->base);
err_display:
	wl_display_disconnect(c->parent.wl_display);
err_compositor:
	weston_compositor_shutdown(&c->base);
err_free:
	free(c);
	return NULL;
}