59 lines
1.2 KiB
C
59 lines
1.2 KiB
C
#ifndef INITCAIRO_H
|
|
#define INITCAIRO_H
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdbool.h>
|
|
#include <unistd.h>
|
|
|
|
#include <X11/Xlib.h>
|
|
#include <X11/Xutil.h>
|
|
#include <cairo.h>
|
|
#include <cairo-xlib.h>
|
|
|
|
#define STATUS_NOTHING 0
|
|
#define STATUS_REDRAW 1
|
|
#define STATUS_QUIT 2
|
|
|
|
typedef struct {
|
|
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;
|
|
} DimensionsInfo;
|
|
|
|
typedef struct {
|
|
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;
|
|
cairo_t *buffer_context;
|
|
unsigned char *buffer;
|
|
|
|
struct timeval start_time;
|
|
unsigned long frames;
|
|
double elapsed, frametime;
|
|
DimensionsInfo *dim;
|
|
} 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)(void *));
|
|
void updateDimensions(DimensionsInfo *ctx);
|
|
|
|
#endif
|