示例#1
0
/**
 * \brief Connects to the display, creates the window and hands over
 * to the main loop.
 */
int
main(int argc, char *argv[])
{
	struct display *d;
	struct eventdemo *e;

	parse_options(eventdemo_options,
		      ARRAY_LENGTH(eventdemo_options), &argc, argv);

	/* Connect to the display and have the arguments parsed */
	d = display_create(&argc, argv);
	if (d == NULL) {
		fprintf(stderr, "failed to create display: %m\n");
		return -1;
	}

	/* Create new eventdemo window */
	e = eventdemo_create(d);
	if (e == NULL) {
		fprintf(stderr, "failed to create eventdemo: %m\n");
		return -1;
	}

	display_run(d);

	/* Release resources */
	eventdemo_destroy(e);
	display_destroy(d);

	return 0;
}
示例#2
0
/**
 * \brief Connects to the display, creates the window and hands over
 * to the main loop.
 */
int
main(int argc, char *argv[])
{
	struct display *d;
	struct eventdemo *e;

	if (parse_options(eventdemo_options,
			  ARRAY_LENGTH(eventdemo_options), &argc, argv) > 1) {
		unsigned k;
		printf("Usage: %s [OPTIONS]\n\n", argv[0]);
		for (k = 0; k < ARRAY_LENGTH(eventdemo_options); k++) {
			const struct weston_option* p = &eventdemo_options[k];
			if (p->name) {
				printf("  --%s", p->name);
				if (p->type != WESTON_OPTION_BOOLEAN)
					printf("=VALUE");
				putchar('\n');
			}
			if (p->short_name) {
				printf("  -%c", p->short_name);
				if (p->type != WESTON_OPTION_BOOLEAN)
					printf("VALUE");
				putchar('\n');
			}
		}
		return 1;
	}

	if (!log_redraw && !log_resize && !log_focus && !log_key &&
	    !log_button && !log_axis && !log_motion)
	  log_redraw = log_resize = log_focus = log_key =
	    log_button = log_axis = log_motion = 1;

	/* Connect to the display and have the arguments parsed */
	d = display_create(&argc, argv);
	if (d == NULL) {
		fprintf(stderr, "failed to create display: %m\n");
		return -1;
	}

	/* Create new eventdemo window */
	e = eventdemo_create(d);
	if (e == NULL) {
		fprintf(stderr, "failed to create eventdemo: %m\n");
		return -1;
	}

	display_run(d);

	/* Release resources */
	eventdemo_destroy(e);
	display_destroy(d);

	return 0;
}