-
Notifications
You must be signed in to change notification settings - Fork 0
/
pannel.h
214 lines (184 loc) · 3.62 KB
/
pannel.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
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#ifndef PANNEL_H_
#define PANNEL_H_
#include <stdint.h>
#include <xcb/xcb_image.h>
#include "XCB-TRL/xcb_trl.h"
#include "util.h"
#include "fonts.h"
typedef struct Pannel Pannel;
typedef struct PannelWidget PannelWidget;
struct Pannel
{
uint16_t w;
uint16_t h;
uint8_t flags;
uint8_t running;
uint8_t pad[2];
XCBWindow win;
XCBGC gc;
XCBPixmap pix;
uint16_t pixw;
uint16_t pixh;
XCBDisplay *dpy;
int screen;
uint32_t widgetslen;
PannelWidget *widgets;
pthread_mutex_t *mut;
pthread_spinlock_t *qmut;
pthread_cond_t *cond;
XFFont *font;
void (*draw)(Pannel *);
};
struct PannelWidget
{
int16_t x;
int16_t y;
uint16_t w;
uint16_t h;
XCBPixmap pix;
uint16_t pixw;
uint16_t pixh;
};
/*
* Data is destroyed on resize.
*
* RETURN: 0 On Success.
* RETURN: 1 On Failure.
*/
int
PannelResizeBuff(
Pannel *pannel,
uint32_t w,
uint32_t h
);
void
PannelRedraw(
Pannel *p,
int32_t x,
int32_t y,
uint32_t w,
uint32_t h
);
/* Builtin pannel Stuff */
Pannel *
PannelCreate(
XCBWindow parent,
int32_t x,
int32_t y,
int32_t w,
int32_t h
);
void
PannelClear(
Pannel *pannel
);
/* Documentation Purposes.
* Automatically destroyed on Unmap/destroy notify.
* this function should not be used, aside from testing.
*/
void
PannelDestroy(
Pannel *pannel
);
void
PannelDrawText(
Pannel *pannel,
int32_t x,
int32_t y,
uint32_t len,
char *str
);
/* Data should not be freed instead to free all data use PannelDestroy();
* Do note that this pointer should be recycled and not thrown away as that would poison the pool.
*
* RETURN: PannelWidget * On Success.
* RETURN: NULL On Failure.
*/
PannelWidget *
PannelWidgetCreate(
Pannel *pannel,
int16_t x,
int16_t y,
uint16_t w,
uint16_t h
);
/* Data will be destroyed
*
* RETURN: 1 on Failure.
* RETURN: 0 on Success.
*/
int
PannelWidgetResize(
Pannel *pannel,
PannelWidget *widget,
uint16_t w,
uint16_t h
);
void
PannelWritePixel(
Pannel *pannel,
int16_t x,
int16_t y,
uint32_t colour
);
void
PannelDrawLine(
Pannel *pannel,
int32_t startx,
int32_t starty,
int32_t endx,
int32_t endy,
uint32_t colour
);
void
PannelDrawRectangle(
Pannel *pannel,
int32_t x,
int32_t y,
uint32_t w,
uint32_t h,
uint8_t fill,
uint32_t colour
);
/* Overflow results in undefined behaviour.
*/
void
PannelWidgetDrawLine(
Pannel *pannel,
PannelWidget *widget,
int32_t startx,
int32_t starty,
int32_t endx,
int32_t endy,
uint32_t colour
);
void
PannelWidgetDrawRectangle(
Pannel *pannel,
PannelWidget *wi,
int32_t x,
int32_t y,
uint32_t w,
uint32_t h,
uint8_t fill,
uint32_t colour
);
/* TOD */
XCBCookie
PannelDrawBuff(
Pannel *pannel,
int16_t xoffset,
int16_t yoffset,
const uint16_t w,
const uint16_t h
);
/*
* id1 id2 id3 * 256
* I think the only real solution is to have the client print from back to frot.
* EX:
* last lastfocus laststack
* And just print down from there disregardning the client, but the client just has info of the client .
* Some issues may arrise if the window is 0, this also is implementation reliant.
* TODO
*/
#endif