351 lines
9.1 KiB
C
351 lines
9.1 KiB
C
/*
|
|
* Minimal Xlib declarations for the bit-address spike.
|
|
*
|
|
* Only the parts a small X client touches. The layouts follow X11R4/Xlib.h;
|
|
* the point is to exercise pointer-bearing structs and the standard
|
|
* ScreenOfDisplay()/RootWindow()/DefaultVisual() macros, not to be a complete
|
|
* Xlib.
|
|
*/
|
|
#ifndef XLIB_MIN_H
|
|
#define XLIB_MIN_H
|
|
|
|
typedef unsigned long XID;
|
|
typedef XID Window;
|
|
typedef XID Drawable;
|
|
typedef XID Pixmap;
|
|
typedef XID Atom;
|
|
typedef XID Colormap;
|
|
typedef XID Cursor;
|
|
typedef XID Font;
|
|
typedef XID GContext;
|
|
typedef XID KeySym;
|
|
typedef int Bool;
|
|
typedef unsigned char KeyCode;
|
|
typedef unsigned long Mask;
|
|
|
|
typedef struct _Display Display;
|
|
typedef struct _Screen Screen;
|
|
typedef struct _Visual Visual;
|
|
typedef struct _XImage XImage;
|
|
typedef struct _XScreenFormat ScreenFormat;
|
|
typedef struct _XExtData XExtData;
|
|
|
|
struct _XScreenFormat {
|
|
int depth;
|
|
int bits_per_pixel;
|
|
int scanline_pad;
|
|
};
|
|
|
|
struct _XExtData {
|
|
int number;
|
|
XExtData *next;
|
|
int (*free_private)(XExtData *);
|
|
char *private_data;
|
|
};
|
|
|
|
struct _Visual {
|
|
XExtData *ext_data;
|
|
Visual *visualid; /* really VisualID, but size/alignment is what matters */
|
|
int class;
|
|
unsigned long red_mask;
|
|
unsigned long green_mask;
|
|
unsigned long blue_mask;
|
|
int bits_per_rgb;
|
|
int map_entries;
|
|
};
|
|
|
|
struct _Screen {
|
|
XExtData *ext_data;
|
|
Display *display;
|
|
Window root;
|
|
int width, height;
|
|
int mwidth, mheight;
|
|
int ndepths;
|
|
void *depths;
|
|
int root_depth;
|
|
Visual *root_visual;
|
|
GContext default_gc;
|
|
Colormap cmap;
|
|
unsigned long white_pixel;
|
|
unsigned long black_pixel;
|
|
int max_maps, min_maps;
|
|
int backing_store;
|
|
Bool save_unders;
|
|
long root_input_mask;
|
|
};
|
|
|
|
struct _Display {
|
|
XExtData *ext_data;
|
|
void *private1;
|
|
int fd;
|
|
int private2;
|
|
int proto_major_version;
|
|
int proto_minor_version;
|
|
char *vendor;
|
|
XID private3;
|
|
XID private4;
|
|
XID private5;
|
|
int private6;
|
|
XID (*resource_alloc)(Display *);
|
|
int byte_order;
|
|
int bitmap_unit;
|
|
int bitmap_pad;
|
|
int bitmap_bit_order;
|
|
int nformats;
|
|
ScreenFormat *pixmap_format;
|
|
int private8;
|
|
int release;
|
|
void *private9;
|
|
void *private10;
|
|
int qlen;
|
|
unsigned long last_request_read;
|
|
unsigned long request;
|
|
void *private11;
|
|
void *private12;
|
|
void *private13;
|
|
void *private14;
|
|
unsigned max_request_size;
|
|
void *db;
|
|
int default_screen;
|
|
int nscreens;
|
|
Screen *screens;
|
|
unsigned long motion_buffer;
|
|
};
|
|
|
|
struct _XImage {
|
|
int width, height;
|
|
int xoffset;
|
|
int format;
|
|
char *data;
|
|
int byte_order;
|
|
int bitmap_unit;
|
|
int bitmap_bit_order;
|
|
int bitmap_pad;
|
|
int depth;
|
|
int bytes_per_line;
|
|
int bits_per_pixel;
|
|
unsigned long red_mask;
|
|
unsigned long green_mask;
|
|
unsigned long blue_mask;
|
|
void *obdata;
|
|
struct funcs {
|
|
XImage *(*create_image)(Display *, Visual *, unsigned int, int, int, char *,
|
|
unsigned int, unsigned int, int, int);
|
|
int (*destroy_image)(XImage *);
|
|
unsigned long (*get_pixel)(XImage *, int, int);
|
|
int (*put_pixel)(XImage *, int, int, unsigned long);
|
|
XImage *(*sub_image)(XImage *, int, int, unsigned int, unsigned int);
|
|
int (*add_pixel)(XImage *, long);
|
|
} f;
|
|
};
|
|
|
|
typedef struct {
|
|
int type;
|
|
unsigned long serial;
|
|
Bool send_event;
|
|
Display *display;
|
|
Window window;
|
|
} XAnyEvent;
|
|
|
|
typedef struct {
|
|
int type;
|
|
unsigned long serial;
|
|
Bool send_event;
|
|
Display *display;
|
|
Window window;
|
|
Window root;
|
|
Window subwindow;
|
|
unsigned long time;
|
|
int x, y;
|
|
int x_root, y_root;
|
|
unsigned int state;
|
|
unsigned int keycode;
|
|
Bool same_screen;
|
|
} XKeyEvent;
|
|
|
|
typedef struct {
|
|
int type;
|
|
unsigned long serial;
|
|
Bool send_event;
|
|
Display *display;
|
|
Window window;
|
|
Window root;
|
|
Window subwindow;
|
|
unsigned long time;
|
|
int x, y;
|
|
int x_root, y_root;
|
|
unsigned int state;
|
|
unsigned int button;
|
|
Bool same_screen;
|
|
} XButtonEvent;
|
|
|
|
typedef struct {
|
|
int type;
|
|
unsigned long serial;
|
|
Bool send_event;
|
|
Display *display;
|
|
Window window;
|
|
int x, y;
|
|
int width, height;
|
|
int count;
|
|
} XExposeEvent;
|
|
|
|
typedef struct {
|
|
int type;
|
|
unsigned long serial;
|
|
Bool send_event;
|
|
Display *display;
|
|
Window event;
|
|
Window window;
|
|
int x, y;
|
|
int width, height;
|
|
int border_width;
|
|
Window above;
|
|
Bool override_redirect;
|
|
} XConfigureEvent;
|
|
|
|
typedef struct {
|
|
int type;
|
|
unsigned long serial;
|
|
Bool send_event;
|
|
Display *display;
|
|
Window window;
|
|
Atom message_type;
|
|
int format;
|
|
union {
|
|
char b[20];
|
|
short s[10];
|
|
long l[5];
|
|
} data;
|
|
} XClientMessageEvent;
|
|
|
|
typedef struct {
|
|
int type;
|
|
Display *display;
|
|
XID resourceid;
|
|
unsigned long serial;
|
|
unsigned char error_code;
|
|
unsigned char request_code;
|
|
unsigned char minor_code;
|
|
} XErrorEvent;
|
|
|
|
typedef union _XEvent {
|
|
int type;
|
|
XAnyEvent xany;
|
|
XKeyEvent xkey;
|
|
XButtonEvent xbutton;
|
|
XExposeEvent xexpose;
|
|
XConfigureEvent xconfigure;
|
|
XClientMessageEvent xclient;
|
|
XErrorEvent xerror;
|
|
long pad[24];
|
|
} XEvent;
|
|
|
|
typedef struct {
|
|
unsigned char *value;
|
|
Atom encoding;
|
|
int format;
|
|
unsigned long nitems;
|
|
} XTextProperty;
|
|
|
|
typedef struct {
|
|
char *res_name;
|
|
char *res_class;
|
|
} XClassHint;
|
|
|
|
typedef struct {
|
|
long flags;
|
|
int x, y;
|
|
int width, height;
|
|
int min_width, min_height;
|
|
int max_width, max_height;
|
|
int width_inc, height_inc;
|
|
struct {
|
|
int x;
|
|
int y;
|
|
} min_aspect, max_aspect;
|
|
int base_width, base_height;
|
|
int win_gravity;
|
|
} XSizeHints;
|
|
|
|
typedef struct {
|
|
Pixmap background_pixmap;
|
|
unsigned long background_pixel;
|
|
Pixmap border_pixmap;
|
|
unsigned long border_pixel;
|
|
int bit_gravity;
|
|
int win_gravity;
|
|
int backing_store;
|
|
unsigned long backing_planes;
|
|
unsigned long backing_pixel;
|
|
Bool save_under;
|
|
long event_mask;
|
|
long do_not_propagate_mask;
|
|
Bool override_redirect;
|
|
Colormap colormap;
|
|
Cursor cursor;
|
|
} XSetWindowAttributes;
|
|
|
|
#define DefaultScreen(dpy) ((dpy)->default_screen)
|
|
#define ScreenOfDisplay(dpy, scr) ((dpy)->screens + (scr))
|
|
#define RootWindow(dpy, scr) (ScreenOfDisplay((dpy), (scr))->root)
|
|
#define DefaultVisual(dpy, scr) (ScreenOfDisplay((dpy), (scr))->root_visual)
|
|
#define DefaultDepth(dpy, scr) (ScreenOfDisplay((dpy), (scr))->root_depth)
|
|
#define DefaultGC(dpy, scr) (ScreenOfDisplay((dpy), (scr))->default_gc)
|
|
#define BlackPixel(dpy, scr) (ScreenOfDisplay((dpy), (scr))->black_pixel)
|
|
#define WhitePixel(dpy, scr) (ScreenOfDisplay((dpy), (scr))->white_pixel)
|
|
#define DisplayWidth(dpy, scr) (ScreenOfDisplay((dpy), (scr))->width)
|
|
#define DisplayHeight(dpy, scr) (ScreenOfDisplay((dpy), (scr))->height)
|
|
|
|
#define LSBFirst 0
|
|
#define MSBFirst 1
|
|
#define XYBitmap 0
|
|
#define XYPixmap 1
|
|
#define ZPixmap 2
|
|
|
|
#define KeyPress 2
|
|
#define Expose 12
|
|
#define ConfigureNotify 22
|
|
|
|
#define ExposureMask (1L << 15)
|
|
#define KeyPressMask (1L << 0)
|
|
#define ButtonPressMask (1L << 2)
|
|
#define StructureNotifyMask (1L << 17)
|
|
#define NoEventMask 0L
|
|
|
|
extern Display *XOpenDisplay(const char *);
|
|
extern int XCloseDisplay(Display *);
|
|
extern Window XCreateSimpleWindow(Display *, Window, int, int, unsigned int,
|
|
unsigned int, unsigned int, unsigned long,
|
|
unsigned long);
|
|
extern Window XCreateWindow(Display *, Window, int, int, unsigned int,
|
|
unsigned int, unsigned int, int, unsigned int,
|
|
Visual *, unsigned long, XSetWindowAttributes *);
|
|
extern int XChangeWindowAttributes(Display *, Window, unsigned long,
|
|
XSetWindowAttributes *);
|
|
extern int XStoreName(Display *, Window, const char *);
|
|
extern int XSelectInput(Display *, Window, long);
|
|
extern int XMapWindow(Display *, Window);
|
|
extern GContext XCreateGC(Display *, Drawable, unsigned long, void *);
|
|
extern int XSetForeground(Display *, GContext, unsigned long);
|
|
extern int XSetBackground(Display *, GContext, unsigned long);
|
|
extern XImage *XCreateImage(Display *, Visual *, unsigned int, int, int, char *,
|
|
unsigned int, unsigned int, int, int);
|
|
extern int XPutImage(Display *, Drawable, GContext, XImage *, int, int, int, int,
|
|
unsigned int, unsigned int);
|
|
extern int XSync(Display *, Bool);
|
|
extern int XNextEvent(Display *, XEvent *);
|
|
extern int XLookupString(XKeyEvent *, char *, int, KeySym *, void *);
|
|
extern int XGetWMName(Display *, Window, XTextProperty *);
|
|
extern int XmbTextPropertyToTextList(Display *, const XTextProperty *, char ***, int *);
|
|
extern void XFreeStringList(char **);
|
|
extern int XFree(void *);
|
|
extern int XSetClassHint(Display *, Window, XClassHint *);
|
|
extern int XSetWMProperties(Display *, Window, XTextProperty *, XTextProperty *,
|
|
char **, int, XSizeHints *, void *, XClassHint *);
|
|
extern void *malloc(unsigned long);
|
|
extern void *memset(void *, int, unsigned long);
|
|
extern void *memcpy(void *, const void *, unsigned long);
|
|
|
|
#endif
|