-
Notifications
You must be signed in to change notification settings - Fork 0
/
cursor.c
181 lines (164 loc) · 6.12 KB
/
cursor.c
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/* Copyright (c) 1994 David Hogan, 2000 Benjamin Drieu, see README for licence details */
#include <stdio.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "dat.h"
#include "fns.h"
Cursor target;
Cursor sweep0;
Cursor boxcurs;
Cursor arrow;
Pixmap root_pixmap;
typedef struct {
int width;
int hot[2];
unsigned char mask[64];
unsigned char fore[64];
} Cursordata;
Cursordata sweep0data = {
16,
{7, 7},
{0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x03,
0xC0, 0x03, 0xC0, 0x03, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x03, 0xC0, 0x03,
0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x03},
{0x00, 0x00, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xFE, 0x7F,
0xFE, 0x7F, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x00, 0x00}
};
Cursordata boxcursdata = {
16,
{7, 7},
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FE, 0x00, 0xF6, 0x01, 0xE6, 0x03,
0xC2, 0x07, 0x82, 0x0F, 0x00, 0x1F, 0x00, 0x3E,
0x00, 0x7C, 0x00, 0x38, 0x00, 0x10, 0x00, 0x00,}
};
Cursordata whitearrow = {
16,
{0, 0},
{0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x03, 0xFF, 0x00,
0xFF, 0x00, 0xFF, 0x01, 0xFF, 0x03, 0xFF, 0x07,
0xE7, 0x0F, 0xC7, 0x1F, 0x83, 0x3F, 0x00, 0x7F,
0x00, 0xFE, 0x00, 0x7C, 0x00, 0x38, 0x00, 0x10,},
{0xFF, 0x07, 0xFF, 0x07, 0x83, 0x03, 0xC3, 0x00,
0xC3, 0x00, 0x83, 0x01, 0x1B, 0x03, 0x3F, 0x06,
0x67, 0x0C, 0xC7, 0x18, 0x83, 0x31, 0x00, 0x63,
0x00, 0xC6, 0x00, 0x6C, 0x00, 0x38, 0x00, 0x10,}
};
Cursordata blittarget = {
18,
{8, 8},
{0xe0, 0x1f, 0x00, 0xf0, 0x3f, 0x00, 0xf8, 0x7f, 0x00,
0xfc, 0xff, 0x00, 0xfe, 0xff, 0x01, 0xff, 0xff, 0x03,
0xff, 0xff, 0x03, 0xff, 0xff, 0x03, 0xff, 0xff, 0x03,
0xff, 0xff, 0x03, 0xff, 0xff, 0x03, 0xff, 0xff, 0x03,
0xff, 0xff, 0x03, 0xfe, 0xff, 0x01, 0xfc, 0xff, 0x00,
0xf8, 0x7f, 0x00, 0xf0, 0x3f, 0x00, 0xe0, 0x1f, 0x00},
{0x00, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0xf0, 0x3f, 0x00,
0x38, 0x73, 0x00, 0x8c, 0xc7, 0x00, 0xec, 0xdf, 0x00,
0x66, 0x9b, 0x01, 0x36, 0xb3, 0x01, 0xfe, 0xff, 0x01,
0xfe, 0xff, 0x01, 0x36, 0xb3, 0x01, 0x66, 0x9b, 0x01,
0xec, 0xdf, 0x00, 0x8c, 0xc7, 0x00, 0x38, 0x73, 0x00,
0xf0, 0x3f, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0x00, 0x00}
};
Cursordata blitarrow = {
18,
{1, 1},
{0xff, 0x0f, 0x00, 0xff, 0x07, 0x00, 0xff, 0x03, 0x00,
0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x01, 0x00,
0xff, 0x03, 0x00, 0xff, 0x07, 0x00, 0xe7, 0x0f, 0x00,
0xc7, 0x1f, 0x00, 0x87, 0x3f, 0x00, 0x03, 0x7f, 0x00,
0x01, 0xfe, 0x00, 0x00, 0xfc, 0x01, 0x00, 0xf8, 0x03,
0x00, 0xf0, 0x01, 0x00, 0xe0, 0x00, 0x00, 0x40, 0x00},
{0x00, 0x00, 0x00, 0xfe, 0x03, 0x00, 0xfe, 0x00, 0x00,
0x3e, 0x00, 0x00, 0x7e, 0x00, 0x00, 0xfe, 0x00, 0x00,
0xf6, 0x01, 0x00, 0xe6, 0x03, 0x00, 0xc2, 0x07, 0x00,
0x82, 0x0f, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x3e, 0x00,
0x00, 0x7c, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf0, 0x01,
0x00, 0xe0, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00}
};
Cursordata blitsweep = {
18,
{8, 8},
{0xc4, 0xff, 0x03, 0xce, 0xff, 0x03, 0xdf, 0xff, 0x03,
0x3e, 0x80, 0x03, 0x7c, 0x83, 0x03, 0xf8, 0x83, 0x03,
0xf7, 0x83, 0x03, 0xe7, 0x83, 0x03, 0xf7, 0x83, 0x03,
0xf7, 0x83, 0x03, 0x07, 0x80, 0x03, 0x07, 0x80, 0x03,
0x07, 0x80, 0x03, 0x07, 0x80, 0x03, 0x07, 0x80, 0x03,
0xff, 0xff, 0x03, 0xff, 0xff, 0x03, 0xff, 0xff, 0x03},
{0x00, 0x00, 0x00, 0x84, 0xff, 0x01, 0x0e, 0x00, 0x01,
0x1c, 0x00, 0x01, 0x38, 0x00, 0x01, 0x70, 0x01, 0x01,
0xe0, 0x01, 0x01, 0xc2, 0x01, 0x01, 0xe2, 0x01, 0x01,
0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01,
0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01,
0x02, 0x00, 0x01, 0xfe, 0xff, 0x01, 0x00, 0x00, 0x00}
};
/*
* Grey tile pattern for root background
*/
#define grey_width 4
#define grey_height 2
static char grey_bits[] = {
0x01, 0x04};
Cursor
getcursor(c)
Cursordata *c;
{
Pixmap f, m;
XColor bc, fc, d;
f = XCreatePixmapFromBitmapData(dpy, root, (char *)c->fore, c->width, c->width, 1, 0, 1);
m = XCreatePixmapFromBitmapData(dpy, root, (char *)c->mask, c->width, c->width, 1, 0, 1);
XAllocNamedColor(dpy, DefaultColormap(dpy, screen), "white", &bc, &d);
XAllocNamedColor(dpy, DefaultColormap(dpy, screen), "red", &fc, &d);
return XCreatePixmapCursor(dpy, f, m, &fc, &bc, c->hot[0], c->hot[1]);
}
void
initcurs()
{
if (nostalgia) {
arrow = getcursor(&blitarrow);
target = getcursor(&blittarget);
sweep0 = getcursor(&blitsweep);
boxcurs = getcursor(&blitsweep);
}
else {
arrow = getcursor(&arrowdata);
target = getcursor(&sightdata);
sweep0 = getcursor(&sweep0data);
boxcurs = getcursor(&boxcursdata);
}
root_pixmap = XCreatePixmapFromBitmapData(dpy, root,
grey_bits, grey_width, grey_height,
black, white, DefaultDepth(dpy, screen));
}