Exemplo n.º 1
0
Arquivo: ui.c Projeto: hbkk/sequencer
void
ui_destroy(ui_t *ui)
{
    int i;
    list_t *lp;
    note_t *note = NULL;
    char *command;

    endwin();

    display_destroy(ui->display);

    for (i = 0; i < 8; i++) {
        for (lp = ui->patterns[i]; lp; lp = list_next(lp)) {
            note = (note_t *)list_data(lp);
            free(note);
        }


        list_free(ui->patterns[i]);
    }

    for (lp = ui->history; lp; lp = list_next(lp)) {
        command = (char *)list_data(lp);
        free(command);
    }

    list_free(ui->history);

    free(ui);
}
Exemplo n.º 2
0
int
main(int argc, char *argv[])
{
	struct display *display;
	struct calibrator *calibrator;

	display = display_create(argc, argv);

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

	calibrator = calibrator_create(display);

	if (!calibrator)
		return -1;

	display_run(display);

	calibrator_destroy(calibrator);
	display_destroy(display);

	return 0;
}
Exemplo n.º 3
0
int
main(int argc, char *argv[])
{
	struct display *display;
	struct demoapp *app;

	parse_options(options, ARRAY_LENGTH(options), &argc, argv);
	if (option_help) {
		printf(help_text, argv[0]);
		return 0;
	}

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

	if (!display_has_subcompositor(display)) {
		fprintf(stderr, "compositor does not support "
			"the subcompositor extension\n");
		return -1;
	}

	app = demoapp_create(display);

	display_run(display);

	demoapp_destroy(app);
	display_destroy(display);

	return 0;
}
Exemplo n.º 4
0
int
main(int argc, char *argv[])
{
	struct stacking stacking;

	memset(&stacking, 0, sizeof stacking);

#ifdef HAVE_PANGO
	g_type_init();
#endif

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

	display_set_user_data(stacking.display, &stacking);

	stacking.root_window = new_window(&stacking, NULL);

	display_run(stacking.display);

	window_destroy(stacking.root_window);
	display_destroy(stacking.display);

	return 0;
}
Exemplo n.º 5
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;
}
Exemplo n.º 6
0
int
main(int argc, char *argv[])
{
	struct display *display;
	struct demoapp *app;

	parse_options(options, ARRAY_LENGTH(options), &argc, argv);
	if (option_help) {
		printf(help_text, argv[0]);
		return 0;
	}

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

	app = demoapp_create(display);

	display_run(display);

	demoapp_destroy(app);
	display_destroy(display);

	return 0;
}
Exemplo n.º 7
0
int
main(int argc, char *argv[])
{
	struct display *d;
	struct cliptest *cliptest;

	if (argc > 1) {
		if (argc == 2 && !strcmp(argv[1], "-b"))
			return benchmark();
		printf("Usage: %s [OPTIONS]\n  -b  run benchmark\n", argv[0]);
		return 1;
	}

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

	cliptest = cliptest_create(d);
	display_run(d);

	cliptest_destroy(cliptest);
	display_destroy(d);

	return 0;
}
Exemplo n.º 8
0
void client_destroy(struct client *client)
{
	window_destroy(client->w);
	display_destroy(client->d);
	close(client->sock_fd);
	free(client);

}
Exemplo n.º 9
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;
}
Exemplo n.º 10
0
int main(int argc, char *argv[])
{
	struct timespec ts;
	struct smoke smoke;
	struct display *d;
	int size;

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

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

	window_set_buffer_type(smoke.window, WINDOW_BUFFER_TYPE_SHM);
	clock_gettime(CLOCK_MONOTONIC, &ts);
	srandom(ts.tv_nsec);

	smoke.current = 0;
	size = smoke.height * smoke.width;
	smoke.b[0].d = calloc(size, sizeof(float));
	smoke.b[0].u = calloc(size, sizeof(float));
	smoke.b[0].v = calloc(size, sizeof(float));
	smoke.b[1].d = calloc(size, sizeof(float));
	smoke.b[1].u = calloc(size, sizeof(float));
	smoke.b[1].v = calloc(size, sizeof(float));

	widget_set_motion_handler(smoke.widget, mouse_motion_handler);
	widget_set_touch_motion_handler(smoke.widget, touch_motion_handler);
	widget_set_resize_handler(smoke.widget, resize_handler);
	widget_set_redraw_handler(smoke.widget, redraw_handler);

	window_set_user_data(smoke.window, &smoke);

	widget_schedule_resize(smoke.widget, smoke.width, smoke.height);

	display_run(d);

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

	return 0;
}
Exemplo n.º 11
0
int main(int argc, char *argv[])
{
	struct display *d;
	struct gears *gears;

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

	gears_destroy(gears);
	display_destroy(d);

	return 0;
}
Exemplo n.º 12
0
int
main(int argc, char *argv[])
{
	struct display *display;
	struct clickdot *clickdot;

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

	clickdot = clickdot_create(display);

	display_run(display);

	clickdot_destroy(clickdot);
	display_destroy(display);

	return 0;
}
Exemplo n.º 13
0
int
main(int argc, char *argv[])
{
	struct display *display;
	struct resizor *resizor;

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

	resizor = resizor_create(display);

	display_run(display);

	resizor_destroy(resizor);
	display_destroy(display);

	return 0;
}
Exemplo n.º 14
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);

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

	return 0;
}
Exemplo n.º 15
0
Arquivo: main.c Projeto: 33d/gbsim
int main(int argc, char* argv[]) {
	int r = 0;

	char* elf_file = NULL;
	int gdb_port = 0;

	for (char** arg = &argv[1]; *arg != NULL; ++arg) {
		if (strcmp("-d", *arg) == 0)
			gdb_port = atoi(*(++arg));
		else
			elf_file = *arg;
	}
	if (elf_file == NULL) {
		fprintf(stderr, "Give me a .elf file to load\n");
		return 1;
	}

	elf_firmware_t f;
	elf_read_firmware(elf_file, &f);
	avr_t* avr = avr_make_mcu_by_name("atmega328p");
	if (!avr) {
		fprintf(stderr, "Unsupported cpu atmega328p\n");
		return 1;
	}

	avr_init(avr);
	if (gdb_port != 0) {
		avr->gdb_port = gdb_port;
		avr_gdb_init(avr);
	}
	avr->frequency = 16000000;
	avr_load_firmware(avr, &f);

	pcd8544_init(avr, &lcd);
	avr_connect_irq(avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('C'), 2),
			lcd.irq + IRQ_PCD8544_DC);
	avr_connect_irq(avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('C'), 1),
			lcd.irq + IRQ_PCD8544_CS);
	avr_connect_irq(avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('C'), 0),
			lcd.irq + IRQ_PCD8544_RST);
	avr_connect_irq(avr_io_getirq(avr, AVR_IOCTL_SPI_GETIRQ(0), SPI_IRQ_OUTPUT),
			lcd.irq + IRQ_PCD8544_SPI_IN);

	gb_keypad_init(avr, &keypad);
	for (int i = 0; i < keydefs_length; i++) {
		const keydef_t *k = keydefs + i;
		avr_connect_irq(keypad.irq + k->keypad_key,
				avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ(k->port), k->pin));

		// Start with the pin high
		avr_ioport_t* port = (avr_ioport_t*) avr->io[k->avr_port].w.param;
		key_io[i].pin_mask = (1<<k->pin);
		key_io[i].pull_value = &port->external.pull_value;
		port->external.pull_mask |= key_io[i].pin_mask;
		port->external.pull_value |= key_io[i].pin_mask;
		gb_keypad_press(&keypad, k->keypad_key, 1);
	}

	if (display_init()) {
		lcd_ram_mutex = SDL_CreateMutex();
		SDL_Thread* avr_thread = SDL_CreateThread(avr_run_thread, "avr-thread", avr);
		main_loop();
		SDL_LockMutex(lcd_ram_mutex);
		quit_flag = 1;
		SDL_UnlockMutex(lcd_ram_mutex);
		int avr_thread_return;
		SDL_WaitThread(avr_thread, &avr_thread_return);
		SDL_DestroyMutex(lcd_ram_mutex);
	} else {
		r = 1;
		fprintf(stderr, "%s\n", display_error_message());
	}

	display_destroy();

	return r;
}
Exemplo n.º 16
0
Display::~Display()
{
	if (m_isOwner)
		display_destroy(m_display);
}
Exemplo n.º 17
0
int main(int ac, char** av)
{
	t_vm*		vm		= vm_initialize();
	t_process*	process = (t_process*) malloc(sizeof(t_process));
	int32		i;
	t_display*		display;
	int32			update_display = 0;
	int32			was_pressed = 0;
	t_ring_buffer*	ring_buffer;

	ring_buffer = ring_buffer_initialize(10, free);

	if (load_cores(vm, ac, av) <= 0)
		return -1;

	display = display_initialize(800, 600);
	vm_set_print_callback(vm, main_debug_print, ring_buffer);

	if (1)
	{
		while (vm->process_count && !display_should_exit(display))
		{
			vm->cycle_current++;
			update_display = 1;
			int process_count = vm->process_count;
			for (i = 0; i < process_count; ++i)
			{
				t_process* process = vm->processes[i];
				if (process->cycle_wait <= 0)
				{
					update_display = 0;

					vm_reset_process_io_op(process);
					if (process->current_opcode)
						vm_execute(vm, process);
					vm_get_opcode(vm, process);
				}
				else
					process->cycle_wait--;
			}

			if (vm->cycle_current > vm->cycle_to_die)
			{
				vm->cycle_current = 0;
				vm_kill_process_if_no_live(vm);
			}

			vm_clean_dead_process(vm);
//			update_display = 0;
			if (display_update_input(display) || update_display == 0)
			{
				display_print_ring_buffer(display, 0, 0, ring_buffer);
				display_step(vm, display);
			}

		}
	}
	else
	{
		int32 execute_one = 0;

		int32 current_keys_state[GLFW_KEY_LAST];
		int32 previous_keys_state[GLFW_KEY_LAST];

		memset(previous_keys_state, 0, GLFW_KEY_LAST * sizeof(int32));
		memset(current_keys_state, 0, GLFW_KEY_LAST * sizeof(int32));
		display_step(vm, display);
		while (vm->process_count && !display_should_exit(display))
		{
			int32 executed = 0;
			int32 print_processes;
			int32 process_count = 0;

			current_keys_state[GLFW_KEY_S] = display_key_pressed(display, GLFW_KEY_S);
			current_keys_state[GLFW_KEY_P] = display_key_pressed(display, GLFW_KEY_P);

			if (!execute_one)
				execute_one = previous_keys_state[GLFW_KEY_S] && !current_keys_state[GLFW_KEY_S];
			print_processes = previous_keys_state[GLFW_KEY_P] && !current_keys_state[GLFW_KEY_P];
			memcpy(previous_keys_state, current_keys_state, sizeof(int32) * GLFW_KEY_LAST);

			if (execute_one)
				vm->cycle_current++;
			for (i = 0; i < vm->process_count; ++i)
			{
				t_process* process = vm->processes[i];
				if (print_processes)
					vm_debug_print_process(vm, process);
				if (execute_one)
				{
					if (process->cycle_wait <= 0)
					{
						vm_reset_process_io_op(process);
						vm_execute(vm, process);
						vm_get_opcode(vm, process);
						executed++;
						if (vm->live_count >= NBR_LIVE)
						{
							vm->live_count = 0;
							vm->cycle_to_die -= vm->cycle_delta;
						}
					}
					process->cycle_wait--;
				}
			}
			if (executed)
				execute_one = 0;
			if (vm->cycle_current > vm->cycle_to_die)
			{
				vm->cycle_current = 0;
				vm_kill_process_if_no_live(vm);
			}
			vm_clean_dead_process(vm);
			executed += display_update_input(display);
			if (executed)
				display_step(vm, display);
			else
				glfwPollEvents();
		}
	}


	ring_buffer_destroy(ring_buffer);
	display_destroy(display);
	vm_destroy(vm);
}
Exemplo n.º 18
0
int main(int argc, char *argv[])
{
    struct transformed transformed;
    struct display *d;
    int i;

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

    for (i = 1; i < argc; i++) {
        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");

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

    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);
    widget_destroy(transformed.widget);
    window_destroy(transformed.window);
    display_destroy(d);

    return 0;
}
Exemplo n.º 19
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;
}