#ifndef INITCAIRO_H #define INITCAIRO_H #include #include #include #include #include #include #include #include #include #define STATUS_NOTHING 0 #define STATUS_REDRAW 1 #define STATUS_QUIT 2 typedef struct { cairo_t *cairo; cairo_matrix_t matrix; unsigned int width; unsigned int height; // these things will be written by updateDimensions() double scalefactor; double center_x; double center_y; double radius; } DrawingContext; typedef struct { DrawingContext *context; Display *display; Window win; Colormap cmap; Atom wm_protocols; Atom wm_delete_window; cairo_surface_t *surface; cairo_t *front_context; cairo_surface_t *buffer_surface; unsigned char *buffer; struct timeval start_time; unsigned long frames; double elapsed, frametime; } GraphicsInfo; GraphicsInfo *initCairo(int screen, int mask, int width, int height, const char *name); void destroyCairo(GraphicsInfo *info); void startTimer(GraphicsInfo *info); void waitUpdateTimer(GraphicsInfo *info); int checkEvents(GraphicsInfo *info, int (*process)(GraphicsInfo*, XEvent*), void (*draw)(DrawingContext *)); void updateDimensions(DrawingContext *ctx); #endif