示例#1
0
static void monitor_event(struct uterm_monitor *mon,
				struct uterm_monitor_event *ev,
				void *data)
{
	int ret;

	if (ev->type == UTERM_MONITOR_NEW_SEAT) {
		if (strcmp(ev->seat_name, "seat0"))
			return;

		ret = uterm_input_new(&input, eloop,
				      input_conf.xkb_model,
				      input_conf.xkb_layout,
				      input_conf.xkb_variant,
				      input_conf.xkb_options,
				      0, 0);
		if (ret)
			return;
		ret = uterm_input_register_cb(input, input_arrived, NULL);
		if (ret)
			return;
		uterm_input_wake_up(input);
	} else if (ev->type == UTERM_MONITOR_FREE_SEAT) {
		uterm_input_unregister_cb(input, input_arrived, NULL);
		uterm_input_unref(input);
	} else if (ev->type == UTERM_MONITOR_NEW_DEV) {
		if (ev->dev_type == UTERM_MONITOR_INPUT)
			uterm_input_add_dev(input, ev->dev_node);
	} else if (ev->type == UTERM_MONITOR_FREE_DEV) {
		if (ev->dev_type == UTERM_MONITOR_INPUT)
			uterm_input_remove_dev(input, ev->dev_node);
	}
}
示例#2
0
void uterm_vt_deallocate(struct uterm_vt *vt)
{
	unsigned int mode;

	if (!vt || !vt->vtm || vt->mode == UTERM_VT_DEAD)
		return;

	mode = vt->mode;
	vt->mode = UTERM_VT_DEAD;

	if (mode == UTERM_VT_REAL) {
		real_close(vt);
	} else if (mode == UTERM_VT_FAKE) {
		ev_eloop_unregister_idle_cb(vt->vtm->eloop, vt_idle_event,
					    vt);
		vt_call(vt, UTERM_VT_DEACTIVATE);
	}
	ev_eloop_unregister_signal_cb(vt->vtm->eloop, SIGUSR2, vt_sigusr2, vt);
	ev_eloop_unregister_signal_cb(vt->vtm->eloop, SIGUSR1, vt_sigusr1, vt);
	kmscon_dlist_unlink(&vt->list);
	uterm_input_sleep(vt->input);
	uterm_input_unref(vt->input);
	vt->vtm = NULL;
	uterm_vt_unref(vt);
}
示例#3
0
int main(int argc, char **argv)
{
	int ret;
	struct ev_eloop *eloop;
	struct uterm_vt_master *vtm;
	struct uterm_input *input;
	struct uterm_vt *vt;
	size_t onum;

	onum = sizeof(options) / sizeof(*options);
	ret = test_prepare(options, onum, argc, argv, &eloop);
	if (ret)
		goto err_fail;

	ret = uterm_vt_master_new(&vtm, eloop);
	if (ret)
		goto err_exit;

	ret = uterm_input_new(&input, eloop, "", "", "", "", "", 0, 0,
			      log_llog, NULL);
	if (ret)
		goto err_vtm;

	ret = uterm_vt_allocate(vtm, &vt, UTERM_VT_FAKE | UTERM_VT_REAL,
				"seat0", input, vtpath, NULL, NULL);
	if (ret)
		goto err_input;

	if (switchvt) {
		ret = uterm_vt_activate(vt);
		if (ret == -EINPROGRESS)
			log_debug("VT switch in progress");
		else if (ret)
			log_warn("cannot switch to VT: %d", ret);
	}

	ev_eloop_run(eloop, -1);

	log_debug("Terminating");

	/* switch back to previous VT but wait for eloop to process SIGUSR0 */
	if (switchvt) {
		ret = uterm_vt_deactivate(vt);
		if (ret == -EINPROGRESS)
			ev_eloop_run(eloop, 50);
	}

	uterm_vt_unref(vt);
err_input:
	uterm_input_unref(input);
err_vtm:
	uterm_vt_master_unref(vtm);
err_exit:
	test_exit(options, onum, eloop);
err_fail:
	if (ret != -ECANCELED)
		test_fail(ret);
	return abs(ret);
}