2018-08-08 14:24:03 +00:00
|
|
|
#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>
|
|
|
|
|
2018-08-18 16:27:33 +00:00
|
|
|
#define STATUS_NOTHING 0
|
|
|
|
#define STATUS_REDRAW 1
|
|
|
|
#define STATUS_QUIT 2
|
|
|
|
|
2018-08-08 14:24:03 +00:00
|
|
|
typedef struct {
|
2018-08-17 13:41:17 +00:00
|
|
|
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;
|
2018-08-08 14:24:03 +00:00
|
|
|
Display *display;
|
|
|
|
Window win;
|
|
|
|
Colormap cmap;
|
|
|
|
Atom wm_protocols;
|
|
|
|
Atom wm_delete_window;
|
2018-08-17 13:41:17 +00:00
|
|
|
cairo_surface_t *surface;
|
2018-08-18 16:27:33 +00:00
|
|
|
cairo_t *front_context;
|
|
|
|
|
|
|
|
cairo_surface_t *buffer_surface;
|
|
|
|
unsigned char *buffer;
|
|
|
|
|
2018-08-08 14:24:03 +00:00
|
|
|
struct timeval start_time;
|
|
|
|
unsigned long frames;
|
|
|
|
double elapsed, frametime;
|
|
|
|
} GraphicsInfo;
|
|
|
|
|
2018-08-17 13:41:17 +00:00
|
|
|
GraphicsInfo *initCairo(int screen, int mask, int width, int height, const char *name);
|
2018-08-08 14:24:03 +00:00
|
|
|
void destroyCairo(GraphicsInfo *info);
|
|
|
|
|
|
|
|
void startTimer(GraphicsInfo *info);
|
|
|
|
void waitUpdateTimer(GraphicsInfo *info);
|
2018-08-17 13:41:17 +00:00
|
|
|
int checkEvents(GraphicsInfo *info, int (*process)(GraphicsInfo*, XEvent*), void (*draw)(DrawingContext *));
|
|
|
|
void updateDimensions(DrawingContext *ctx);
|
2018-08-08 14:24:03 +00:00
|
|
|
|
|
|
|
#endif
|