-
Notifications
You must be signed in to change notification settings - Fork 2
/
nxlib.h
126 lines (103 loc) · 3.34 KB
/
nxlib.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#ifndef _NXLIB_H_
#define _NXLIB_H_
/* Changeable options*/
#define USE_ALLOCA 1 /* set if system has alloca()*/
#define HAVE_STATICFONTS 0 /* set to include static buffered fonts when no filesystem*/
#define MALLOC_0_RETURNS_NULL 0 /* not yet needed*/
/* required settings*/
#define NeedFunctionPrototypes 1 /* ANSI C*/
#define XLIB_ILLEGAL_ACCESS 1 /* define real structures*/
/* deal with _Xconst differences in X11 header files*/
#ifndef XCONST
#define XCONST _Xconst
#endif
/*
* bet you never thought you'd see both of these in the same file ;-)
*/
#include "X11/Xlib.h"
#include <nano-X.h>
#include <stdio.h>
#include <strings.h>
#include <malloc.h>
/* malloc stuff*/
#if MALLOC_0_RETURNS_NULL
/* for machines that do not return a valid pointer for malloc(0)*/
# define Xmalloc(size) malloc(((size) == 0 ? 1 : (size)))
# define Xrealloc(ptr, size) realloc((ptr), ((size) == 0 ? 1 : (size)))
# define Xcalloc(nelem, elsize) calloc(((nelem) == 0 ? 1 : (nelem)), (elsize))
#else
# define Xmalloc(size) malloc((size))
# define Xrealloc(ptr, size) realloc((ptr), (size))
# define Xcalloc(nelem, elsize) calloc((nelem), (elsize))
#endif
#define Xfree(ptr) free((ptr))
#if USE_ALLOCA
/* alloca() is available, so use it for better performance */
#define ALLOCA(size) alloca(size)
#define FREEA(pmem)
#else
/* no alloca(), so use malloc()/free() instead */
#define ALLOCA(size) Xmalloc(size)
#define FREEA(pmem) Xfree(pmem)
#endif
/* defines for unmodified (Xrm) Xlib routines...*/
//#define bzero(mem, size) memset(mem, 0, size)
#define LockDisplay(dpy)
#define UnlockDisplay(dpy)
#define _XLockMutex(lock)
#define _XUnlockMutex(lock)
#define _XCreateMutex(lock)
#define _XFreeMutex(lock)
/* debug defines*/
#if DEBUG
#define DPRINTF(str, args...) fprintf(stderr, str, ##args) /* debug output*/
#else
#define DPRINTF(str, ...) /* no debug output*/
#endif
/* Used internally for the colormap */
typedef struct {
GR_PIXELVAL value;
int ref;
} nxColorval;
typedef struct _nxColormap {
int id;
int color_alloc;
int cur_color;
nxColorval * colorval;
struct _nxColormap * next;
} nxColormap;
/* Colormap.c */
nxColormap *_nxFindColormap(Colormap id);
Colormap _nxDefaultColormap(Display *dpy);
/* Colorname.c*/
GR_COLOR GrGetColorByName(char *colorname, int *retr, int *retg, int *retb);
/* AllocColor.c*/
void _nxPixel2RGB(Display * display, unsigned long color,
unsigned short *red, unsigned short *green, unsigned short *blue);
/* QueryColor.c*/
GR_COLOR _nxColorvalFromPixelval(Display *dpy, unsigned long pixelval);
/* font_find.c */
typedef struct {
char * file;
char * xlfd;
unsigned char *data;
int data_size;
} nxStaticFontList;
char **font_enumfonts(char *pattern, int maxnames, int *count_return, int chkalias);
void font_freefontnames(char **fontlist);
char * font_findfont(char *name, int height, int width, int *return_height);
int font_findstaticfont(char *fontname, unsigned char** data, int* size);
/* ChProperty.c */
int _nxDelAllProperty(Window w);
/* SelInput.c*/
GR_EVENT_MASK _nxTranslateEventMask(unsigned long mask);
/* CrCursor.c*/
GR_CURSOR_ID _nxCreateCursor(GR_WINDOW_ID cursor, GR_RECT * cbb,
GR_WINDOW_ID mask, GR_RECT * mbb, int hotx, int hoty,
GR_COLOR fg, GR_COLOR bg);
/* OpenDisp.c*/
void _XFreeDisplayStructure(Display *dpy);
extern Font _nxCursorFont;
/* CrGC.c*/
int _nxConvertROP(int Xrop);
#endif /* _NXLIB_H_*/