示例#1
0
void _cursor(const char *arg) {
#ifdef module_cursor
	cursor_visible(toggle);
#else
	fprintf(stderr,"[SLIDER] Module \"cursor\" not included in this build.\n");
#endif
}
示例#2
0
    void Raspi_App::draw_internal()
    {
        // clear framebuffer
        gl::clear();

        // fire user draw-callback
        draw();

        // draw tweakbar
        if(displayTweakBar())
        {
            // console output
            outstream_gl().draw();
        }

        if(cursor_visible() && (m_mouse_fd || m_touch_fd))
        {
             gl::draw_points_2D({current_mouse_pos}, gl::COLOR_RED, 5.f);
        }
    }
示例#3
0
int render_pdf_page(int pdf, int pg, Window win, bool fixed) {
	if (pg >= _pdf[pdf].npage) return 1;
	cairo_t *ctx;
	cairo_surface_t *s, *img;
	double pdfw, pdfh, scx, scy;
	int ig;
	unsigned int uig, ww, wh;
	/* get page size and scale to window */
	PopplerPage *page = poppler_document_get_page(_pdf[pdf].doc, pg);
	poppler_page_get_size(page, &pdfw, &pdfh);
	XGetGeometry(dpy, win, (Window *) &ig, &ig, &ig, &ww, &wh, &uig, &uig);
	scx = ww / pdfw; scy = wh / pdfh;
	//if (pdf == 0) { _ww = ww; _wh = wh; }
	if (fixed) { /* adjust window size for fixed aspect ratio */
		scx = (scx < scy ? (scy=scx) : scy);
		ww = scx * pdfw + 0.5; wh = scy * pdfh + 0.5;
		XResizeWindow(dpy, win, ww, wh);
	}
	/* create background pixmap and render page to it */
	Pixmap pix = XCreatePixmap(dpy, win, ww, wh, DefaultDepth(dpy,scr));
	s = cairo_xlib_surface_create(dpy, pix, DefaultVisual(dpy,scr), ww, wh);
	ctx = cairo_create(s);
	cairo_surface_destroy(s);
	cairo_scale(ctx, scx, scy);
	cairo_set_source_rgb(ctx, 1, 1, 1);
	cairo_paint(ctx);
	poppler_page_render(page, ctx);
	cairo_destroy(ctx);
	/* if this is the fader window, fade in */
	if (win == _fade_win) {
		/* hide cursor for fade transitions */
#ifdef module_cursor
		bool pre = cursor_visible(query);
		cursor_visible(false);
#endif
		/* get image, set up context, and render page */
		img = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, ww, wh);
		ctx = cairo_create(img);
		cairo_scale(ctx, scx, scy);
		cairo_set_source_rgb(ctx, 1, 1, 1);
		cairo_paint(ctx);
		poppler_page_render(page, ctx);
		cairo_destroy(ctx);
		/* get window surface, reset context to draw img to window */
		s = cairo_xlib_surface_create(dpy, win, DefaultVisual(dpy,scr), ww, wh);
		ctx = cairo_create(s);
		cairo_surface_destroy(s);
		cairo_set_source_surface(ctx, img, 0, 0); // memory leak?!
		/* fade in */
		for (ig = _fade_steps; ig; --ig) {
			cairo_paint_with_alpha(ctx, 1 / (float) ig); // memory leak?!
			//XFlush(dpy);
			usleep(200);
		}
		/* clean up */
		cairo_destroy(ctx);
		cairo_surface_destroy(img);
#ifdef module_cursor
		cursor_visible(pre);
#endif
	}
	g_object_unref(page);
	/* set the pixmap to be the window background */
	XSetWindowBackgroundPixmap(dpy, win, pix);
	XFreePixmap(dpy, pix);
	XClearWindow(dpy, win);
#ifdef module_cursor
	if (pdf == 0) cursor_draw(-1, -1);
#endif
	return 0;
}