#ifndef _XSTUFF_H
#define _XSTUFF_H

#include <sys/types.h>
#include <malloc.h>
#include <string.h>
#include <sys/time.h>
#include <sys/fcntl.h>
#include <errno.h>
#include <math.h>
#include <stdio.h>

/* If you want, set these before calling start_x. */
extern int width;   /* defaults to 800 */
extern int height;  /* defaults to 600 */

/* To start, pass the argc and argv of main(), along with a title
** you want for the title bar.
*/
int start_x(int argc, char *argv[], char title[]);

/* Boolean: returns 0 if there are no events waiting to be handled,
** else non-0.
*/
int pending_x(void);

/* You must call this frequently to handle events (ie, whenever
** pending_x() returns non-0).
*/
void update_x(void);

/* Call this if you want to ensure all your commands have actually
** got to the screen.
*/
void flush_x(void);

/* Returns x,y position of mouse (relative to your window), and
** which is a boolean array of which mouse button is currently down.
** If you don't care about the buttons, which can be NULL.
*/
void mouse_info(int *px, int *py, int which[3]);

/* These do the obvious things.
*/
void drawdot(int x1, int y1);
void cleardot(int x1, int y1);

void drawline(int x1, int y1, int x2, int y2);
void clearline(int x1, int y1, int x2, int y2);

void rectangle(int x1, int y1, int x2, int y2);
void clear_area(int x1, int y1, int x2, int y2);

#endif  /* _XSTUFF_H */
