Пример #1
0
static void
cms_output_created(struct cms_static *cms, struct weston_output *o)
{
	struct weston_color_profile *p;
	struct weston_config_section *s;
	char *profile;

	weston_log("cms-static: output %i [%s] created\n", o->id, o->name);

	if (o->name == NULL)
		return;
	s = weston_config_get_section(cms->ec->config,
				      "output", "name", o->name);
	if (s == NULL)
		return;
	if (weston_config_section_get_string(s, "icc_profile", &profile, NULL) < 0)
		return;
	p = weston_cms_load_profile(profile);
	if (p == NULL) {
		weston_log("cms-static: failed to load %s\n", profile);
	} else {
		weston_log("cms-static: loading %s for %s\n",
			   profile, o->name);
		weston_cms_set_color_profile(o, p);
	}
}
Пример #2
0
int main(int argc, char *argv[])
{
	struct weston_config *config;
	struct weston_config_section *section;
	const char *name;
	char *s;
	int r, b, i;
	int32_t n;
	uint32_t u;

	config = run_test(t0);
	assert(config);
	weston_config_destroy(config);

	config = run_test(t1);
	assert(config);
	section = weston_config_get_section(config, "mollusc", NULL, NULL);
	assert(section == NULL);

	section = weston_config_get_section(config, "foo", NULL, NULL);
	r = weston_config_section_get_string(section, "a", &s, NULL);
	assert(r == 0 && strcmp(s, "b") == 0);
	free(s);

	section = weston_config_get_section(config, "foo", NULL, NULL);
	r = weston_config_section_get_string(section, "b", &s, NULL);
	assert(r == -1 && errno == ENOENT && s == NULL);

	section = weston_config_get_section(config, "foo", NULL, NULL);
	r = weston_config_section_get_string(section, "name", &s, NULL);
	assert(r == 0 && strcmp(s, "Roy Batty") == 0);
	free(s);

	section = weston_config_get_section(config, "bar", NULL, NULL);
	r = weston_config_section_get_string(section, "a", &s, "boo");
	assert(r == -1 && errno == ENOENT && strcmp(s, "boo") == 0);
	free(s);

	section = weston_config_get_section(config, "bar", NULL, NULL);
	r = weston_config_section_get_int(section, "number", &n, 600);
	assert(r == 0 && n == 5252);

	section = weston_config_get_section(config, "bar", NULL, NULL);
	r = weston_config_section_get_int(section, "+++", &n, 700);
	assert(r == -1 && errno == ENOENT && n == 700);

	section = weston_config_get_section(config, "bar", NULL, NULL);
	r = weston_config_section_get_uint(section, "number", &u, 600);
	assert(r == 0 && u == 5252);

	section = weston_config_get_section(config, "bar", NULL, NULL);
	r = weston_config_section_get_uint(section, "+++", &u, 600);
	assert(r == -1 && errno == ENOENT && u == 600);

	section = weston_config_get_section(config, "bar", NULL, NULL);
	r = weston_config_section_get_bool(section, "flag", &b, 600);
	assert(r == 0 && b == 0);

	section = weston_config_get_section(config, "stuff", NULL, NULL);
	r = weston_config_section_get_bool(section, "flag", &b, -1);
	assert(r == 0 && b == 1);

	section = weston_config_get_section(config, "stuff", NULL, NULL);
	r = weston_config_section_get_bool(section, "bonk", &b, -1);
	assert(r == -1 && errno == ENOENT && b == -1);

	section = weston_config_get_section(config, "bucket", "color", "blue");
	r = weston_config_section_get_string(section, "contents", &s, NULL);
	assert(r == 0 && strcmp(s, "live crabs") == 0);
	free(s);

	section = weston_config_get_section(config, "bucket", "color", "red");
	r = weston_config_section_get_string(section, "contents", &s, NULL);
	assert(r == 0 && strcmp(s, "sand") == 0);
	free(s);

	section = weston_config_get_section(config, "bucket", "color", "pink");
	assert(section == NULL);
	r = weston_config_section_get_string(section, "contents", &s, "eels");
	assert(r == -1 && errno == ENOENT && strcmp(s, "eels") == 0);
	free(s);

	section = NULL;
	i = 0;
	while (weston_config_next_section(config, &section, &name))
		assert(strcmp(section_names[i++], name) == 0);
	assert(i == 5);

	weston_config_destroy(config);

	config = run_test(t2);
	assert(config == NULL);

	config = run_test(t3);
	assert(config == NULL);

	config = run_test(t4);
	assert(config == NULL);

	weston_config_destroy(NULL);
	assert(weston_config_next_section(NULL, NULL, NULL) == 0);

	section = weston_config_get_section(NULL, "bucket", NULL, NULL);
	assert(section == NULL);

	return 0;
}
Пример #3
0
static int
weston_xserver_handle_event(int listen_fd, uint32_t mask, void *data)
{
	struct weston_xserver *wxs = data;
	char display[8], s[8], abstract_fd[8], unix_fd[8], wm_fd[8];
	int sv[2], wm[2], fd;
	char *xserver = NULL;
	struct weston_config_section *section;

	if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sv) < 0) {
		weston_log("wl connection socketpair failed\n");
		return 1;
	}

	if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, wm) < 0) {
		weston_log("X wm connection socketpair failed\n");
		return 1;
	}

	wxs->process.pid = fork();
	switch (wxs->process.pid) {
	case 0:
		/* SOCK_CLOEXEC closes both ends, so we need to unset
		 * the flag on the client fd. */
		fd = dup(sv[1]);
		if (fd < 0)
			goto fail;
		snprintf(s, sizeof s, "%d", fd);
		setenv("WAYLAND_SOCKET", s, 1);

		snprintf(display, sizeof display, ":%d", wxs->display);

		fd = dup(wxs->abstract_fd);
		if (fd < 0)
			goto fail;
		snprintf(abstract_fd, sizeof abstract_fd, "%d", fd);
		fd = dup(wxs->unix_fd);
		if (fd < 0)
			goto fail;
		snprintf(unix_fd, sizeof unix_fd, "%d", fd);
		fd = dup(wm[1]);
		if (fd < 0)
			goto fail;
		snprintf(wm_fd, sizeof wm_fd, "%d", fd);

		section = weston_config_get_section(wxs->compositor->config,
						    "xwayland", NULL, NULL);
		weston_config_section_get_string(section, "path",
						 &xserver, XSERVER_PATH);

		/* Ignore SIGUSR1 in the child, which will make the X
		 * server send SIGUSR1 to the parent (weston) when
		 * it's done with initialization.  During
		 * initialization the X server will round trip and
		 * block on the wayland compositor, so avoid making
		 * blocking requests (like xcb_connect_to_fd) until
		 * it's done with that. */
		signal(SIGUSR1, SIG_IGN);

		if (execl(xserver,
			  xserver,
			  display,
			  "-rootless",
			  "-listen", abstract_fd,
			  "-listen", unix_fd,
			  "-wm", wm_fd,
			  "-terminate",
			  NULL) < 0)
			weston_log("exec of '%s %s -rootless "
                                   "-listen %s -listen %s -wm %s "
                                   "-terminate' failed: %m\n",
                                   xserver, display,
                                   abstract_fd, unix_fd, wm_fd);
	fail:
		_exit(EXIT_FAILURE);

	default:
		weston_log("forked X server, pid %d\n", wxs->process.pid);

		close(sv[1]);
		wxs->client = wl_client_create(wxs->wl_display, sv[0]);

		close(wm[1]);
		wxs->wm_fd = wm[0];

		weston_watch_process(&wxs->process);

		wl_event_source_remove(wxs->abstract_source);
		wl_event_source_remove(wxs->unix_source);
		break;

	case -1:
		weston_log( "failed to fork\n");
		break;
	}

	return 1;
}