Beispiel #1
0
int main(int argc, char * argv[])
{
	int i;
	for (i = 1; i < argc; i++) {
		if (strcmp(argv[i], "-help") == 0
		    || strcmp(argv[i], "-h") == 0)
		{
			show_help(argc, argv);
			return 0;
		}
		else if (strcmp(argv[i], "-res") == 0) {
			show_resources();
			return 0;
		}
	}

	init_appres(argc, argv);
	the_bar.realized = 0;

	if (!get_display_info() ||
	    !init_resources() ||
	    !create_main_window())
		exit (1);

	set_signals();
	XMapWindow(gdi.display, gdi.mainw);

	set_keybindings();

	XEvent evt;
	while (1) {
		XNextEvent(gdi.display, &evt);
#ifdef DEBUG
		printf("wid %08X\t%s\n", (int)(evt.xany.window),
		       event_names[evt.type]);
		fflush(stdout);
#endif

		switch(evt.type){
		case KeyPress:
			handle_key_press(&evt);
			break;
		case ReparentNotify:
			handle_reparent(&evt);
			break;
		case MapRequest:
			/* add a new tab */
			handle_maprequest(&evt);
			break;
		case DestroyNotify:
			/* remove a tab */
			handle_destroy(&evt);
			break;
		case ConfigureNotify:
			handle_configure_notify(&evt);
			break;
		case ConfigureRequest:
			handle_configure_request(&evt);
			break;
		case Expose:
			if (evt.xexpose.window != gdi.mainw)
				bar_handle_expose(&(evt.xexpose));
			break;
		case ButtonPress:
			bar_handle_button(&(evt.xbutton));
			break;
		case PropertyNotify:
			bar_handle_prop(&evt);
			break;
		case MapNotify:
			if (evt.xmap.window == gdi.mainw) {
				if (init_stage == 0) {
					init_stage ++;
					spawn_xterm();
				}
			}
			break;
		case UnmapNotify:
			if (the_bar.tab_group.tab_count == 0)
				exit(0);
			break;
		case EnterNotify:
			set_focus();
			break;
		default:
			break;
		}
		XFlush(gdi.display);
	};
	return 0;
}
Beispiel #2
0
status_t virtio_gpu_start(struct virtio_device *dev)
{
    status_t err;

    LTRACEF("dev %p\n", dev);

    struct virtio_gpu_dev *gdev = (struct virtio_gpu_dev *)dev->priv;

    /* get the display info and see if we find a valid pmode */
    err = get_display_info(gdev);
    if (err < 0) {
        LTRACEF("failed to get display info\n");
        return err;
    }

    if (gdev->pmode_id < 0) {
        LTRACEF("we failed to find a pmode, exiting\n");
        return ERR_NOT_FOUND;
    }

    /* allocate a resource */
    err = allocate_2d_resource(gdev, &gdev->display_resource_id, gdev->pmode.r.width, gdev->pmode.r.height);
    if (err < 0) {
        LTRACEF("failed to allocate 2d resource\n");
        return err;
    }

    /* attach a backing store to the resource */
    size_t len = gdev->pmode.r.width * gdev->pmode.r.height * 4;
    gdev->fb = pmm_alloc_kpages(ROUNDUP(len, PAGE_SIZE) / PAGE_SIZE, NULL);
    if (!gdev->fb) {
        TRACEF("failed to allocate framebuffer, wanted 0x%zx bytes\n", len);
        return ERR_NO_MEMORY;
    }

    printf("virtio-gpu: framebuffer at %p, 0x%zx bytes\n", gdev->fb, len);

    err = attach_backing(gdev, gdev->display_resource_id, gdev->fb, len);
    if (err < 0) {
        LTRACEF("failed to attach backing store\n");
        return err;
    }

    /* attach this resource as a scanout */
    err = set_scanout(gdev, gdev->pmode_id, gdev->display_resource_id, gdev->pmode.r.width, gdev->pmode.r.height);
    if (err < 0) {
        LTRACEF("failed to set scanout\n");
        return err;
    }

    /* create the flush thread */
    thread_t *t;
    t = thread_create("virtio gpu flusher", &virtio_gpu_flush_thread, (void *)gdev, HIGH_PRIORITY, DEFAULT_STACK_SIZE);
    thread_detach_and_resume(t);

    /* kick it once */
    event_signal(&gdev->flush_event, true);

    LTRACE_EXIT;

    return NO_ERROR;
}