Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
	struct flower flower;
	struct display *d;
	struct timeval tv;

	d = display_create(&argc, argv);
	if (d == NULL) {
		fprintf(stderr, "failed to create display: %m\n");
		return -1;
	}

	gettimeofday(&tv, NULL);
	srandom(tv.tv_usec);

	flower.width = 200;
	flower.height = 200;
	flower.display = d;
	flower.window = window_create(d);
	flower.widget = window_add_widget(flower.window, &flower);
	window_set_title(flower.window, "Flower");

	widget_set_resize_handler(flower.widget, resize_handler);
	widget_set_redraw_handler(flower.widget, redraw_handler);
	widget_set_button_handler(flower.widget, button_handler);
	widget_set_default_cursor(flower.widget, CURSOR_HAND1);
	widget_set_touch_down_handler(flower.widget, touch_down_handler);

	window_schedule_resize(flower.window, flower.width, flower.height);

	display_run(d);

	return 0;
}
Ejemplo n.º 2
0
int main(int argc, char *argv[])
{
	struct fullscreen fullscreen;
	struct display *d;
	int i;

	fullscreen.width = 640;
	fullscreen.height = 480;
	fullscreen.fullscreen = 0;
	fullscreen.present_method = _WL_FULLSCREEN_SHELL_PRESENT_METHOD_DEFAULT;
	wl_list_init(&fullscreen.output_list);
	fullscreen.current_output = NULL;

	for (i = 1; i < argc; i++) {
		if (strcmp(argv[i], "-w") == 0) {
			if (++i >= argc)
				usage(EXIT_FAILURE);

			fullscreen.width = atol(argv[i]);
		} else if (strcmp(argv[i], "-h") == 0) {
			if (++i >= argc)
				usage(EXIT_FAILURE);

			fullscreen.height = atol(argv[i]);
		} else if (strcmp(argv[i], "--help") == 0)
			usage(EXIT_SUCCESS);
		else
			usage(EXIT_FAILURE);
	}

	d = display_create(&argc, argv);
	if (d == NULL) {
		fprintf(stderr, "failed to create display: %m\n");
		return -1;
	}

	fullscreen.display = d;
	fullscreen.fshell = NULL;
	display_set_user_data(fullscreen.display, &fullscreen);
	display_set_global_handler(fullscreen.display, global_handler);
	display_set_output_configure_handler(fullscreen.display, output_handler);

	if (fullscreen.fshell) {
		fullscreen.window = window_create_custom(d);
		_wl_fullscreen_shell_present_surface(fullscreen.fshell,
						     window_get_wl_surface(fullscreen.window),
						     fullscreen.present_method,
						     NULL);
		/* If we get the CURSOR_PLANE capability, we'll change this */
		fullscreen.draw_cursor = 1;
	} else {
		fullscreen.window = window_create(d);
		fullscreen.draw_cursor = 0;
	}

	fullscreen.widget =
		window_add_widget(fullscreen.window, &fullscreen);

	window_set_title(fullscreen.window, "Fullscreen");

	widget_set_transparent(fullscreen.widget, 0);

	widget_set_default_cursor(fullscreen.widget, CURSOR_LEFT_PTR);
	widget_set_redraw_handler(fullscreen.widget, redraw_handler);
	widget_set_button_handler(fullscreen.widget, button_handler);
	widget_set_motion_handler(fullscreen.widget, motion_handler);
	widget_set_enter_handler(fullscreen.widget, enter_handler);

	widget_set_touch_down_handler(fullscreen.widget, touch_handler);

	window_set_key_handler(fullscreen.window, key_handler);
	window_set_fullscreen_handler(fullscreen.window, fullscreen_handler);

	window_set_user_data(fullscreen.window, &fullscreen);
	/* Hack to set minimum allocation so we can shrink later */
	window_schedule_resize(fullscreen.window,
			       1, 1);
	window_schedule_resize(fullscreen.window,
			       fullscreen.width, fullscreen.height);

	display_run(d);

	return 0;
}
Ejemplo n.º 3
0
int main(int argc, char *argv[])
{
	struct transformed transformed;
	struct display *d;
	int i;

	transformed.width = 500;
	transformed.height = 250;
	transformed.fullscreen = 0;
	transformed.fullscreen_method =
		WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT;

	for (i = 1; i < argc; i++) {
		if (strcmp(argv[i], "-d") == 0) {
			transformed.fullscreen_method =
				WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER;
		} else if (strcmp(argv[i], "-w") == 0) {
			if (++i >= argc)
				usage(EXIT_FAILURE);

			transformed.width = atol(argv[i]);
		} else if (strcmp(argv[i], "-h") == 0) {
			if (++i >= argc)
				usage(EXIT_FAILURE);

			transformed.height = atol(argv[i]);
		} else if (strcmp(argv[i], "--help") == 0)
			usage(EXIT_SUCCESS);
		else
			usage(EXIT_FAILURE);
	}

	d = display_create(&argc, argv);
	if (d == NULL) {
		fprintf(stderr, "failed to create display: %m\n");
		return -1;
	}

	transformed.display = d;
	transformed.window = window_create(d);
	transformed.widget =
		window_add_widget(transformed.window, &transformed);

	window_set_title(transformed.window, "Transformed");
	window_set_fullscreen_method(transformed.window,
				     transformed.fullscreen_method);

	widget_set_transparent(transformed.widget, 0);
	widget_set_default_cursor(transformed.widget, CURSOR_BLANK);

	widget_set_resize_handler(transformed.widget, resize_handler);
	widget_set_redraw_handler(transformed.widget, redraw_handler);
	widget_set_button_handler(transformed.widget, button_handler);

	widget_set_touch_down_handler(transformed.widget, touch_handler);

	window_set_key_handler(transformed.window, key_handler);
	window_set_fullscreen_handler(transformed.window, fullscreen_handler);
	window_set_output_handler(transformed.window, output_handler);

	window_set_user_data(transformed.window, &transformed);
	window_schedule_resize(transformed.window,
			       transformed.width, transformed.height);

	display_run(d);

	return 0;
}
Ejemplo n.º 4
0
int
main(int argc, char *argv[])
{
	struct box box;
	struct display *d;
	struct timeval tv;
	int i;

	d = display_create(&argc, argv);
	if (d == NULL) {
		fprintf(stderr, "failed to create display: %m\n");
		return -1;
	}

	box.mode = MODE_SRC_DST;

	for (i = 1; i < argc; i++) {
		if (strcmp("-s", argv[i]) == 0)
			box.mode = MODE_SRC_ONLY;
		else if (strcmp("-d", argv[i]) == 0)
			box.mode = MODE_DST_ONLY;
		else if (strcmp("-b", argv[i]) == 0)
			box.mode = MODE_SRC_DST;
		else if (strcmp("-n", argv[i]) == 0)
			box.mode = MODE_NO_VIEWPORT;
		else {
			usage(argv[0]);
			exit(1);
		}
	}

	gettimeofday(&tv, NULL);
	srandom(tv.tv_usec);

	box.width = BUFFER_WIDTH / BUFFER_SCALE;
	box.height = BUFFER_HEIGHT / BUFFER_SCALE;
	box.display = d;
	box.window = window_create(d);
	box.widget = window_add_widget(box.window, &box);
	window_set_title(box.window, "Scaler Test Box");
	window_set_buffer_scale(box.window, BUFFER_SCALE);

	widget_set_resize_handler(box.widget, resize_handler);
	widget_set_redraw_handler(box.widget, redraw_handler);
	widget_set_button_handler(box.widget, button_handler);
	widget_set_default_cursor(box.widget, CURSOR_HAND1);
	widget_set_touch_down_handler(box.widget, touch_down_handler);

	window_schedule_resize(box.window, box.width, box.height);

	display_set_user_data(box.display, &box);
	display_set_global_handler(box.display, global_handler);

	display_run(d);

	widget_destroy(box.widget);
	window_destroy(box.window);
	display_destroy(d);

	return 0;
}