hg clone http://hg.4l77.com/patch9/rio/

patch9/rio

view dat.h @ 1:0f5800109226

Added the riows rc script to run several rios as workspaces
author yiyus@yiyus
date Fri Jun 05 21:27:05 2009 -0500 (2009-06-05 ago)
parents
children

1 enum
2 {
3 Qdir, /* /dev for this window */
4 Qcons,
5 Qconsctl,
6 Qcursor,
7 Qwdir,
8 Qwinid,
9 Qwinname,
10 Qkbdin,
11 Qlabel,
12 Qmouse,
13 Qnew,
14 Qscreen,
15 Qsnarf,
16 Qtext,
17 Qwctl,
18 Qwindow,
19 Qwsys, /* directory of window directories */
20 Qwsysdir, /* window directory, child of wsys */
22 QMAX,
23 };
25 enum
26 {
27 Kscrolloneup = KF|0x20,
28 Kscrollonedown = KF|0x21,
29 };
31 #define STACK 8192
33 typedef struct Consreadmesg Consreadmesg;
34 typedef struct Conswritemesg Conswritemesg;
35 typedef struct Stringpair Stringpair;
36 typedef struct Dirtab Dirtab;
37 typedef struct Fid Fid;
38 typedef struct Filsys Filsys;
39 typedef struct Mouseinfo Mouseinfo;
40 typedef struct Mousereadmesg Mousereadmesg;
41 typedef struct Mousestate Mousestate;
42 typedef struct Ref Ref;
43 typedef struct Timer Timer;
44 typedef struct Wctlmesg Wctlmesg;
45 typedef struct Window Window;
46 typedef struct Xfid Xfid;
48 enum
49 {
50 Selborder = 4, /* border of selected window */
51 Unselborder = 1, /* border of unselected window */
52 Scrollwid = 12, /* width of scroll bar */
53 Scrollgap = 4, /* gap right of scroll bar */
54 BIG = 3, /* factor by which window dimension can exceed screen */
55 TRUE = 1,
56 FALSE = 0,
57 };
59 #define QID(w,q) ((w<<8)|(q))
60 #define WIN(q) ((((ulong)(q).path)>>8) & 0xFFFFFF)
61 #define FILE(q) (((ulong)(q).path) & 0xFF)
63 enum /* control messages */
64 {
65 Wakeup,
66 Reshaped,
67 Moved,
68 Refresh,
69 Movemouse,
70 Rawon,
71 Rawoff,
72 Holdon,
73 Holdoff,
74 Deleted,
75 Exited,
76 };
78 struct Wctlmesg
79 {
80 int type;
81 Rectangle r;
82 Image *image;
83 };
85 struct Conswritemesg
86 {
87 Channel *cw; /* chan(Stringpair) */
88 };
90 struct Consreadmesg
91 {
92 Channel *c1; /* chan(tuple(char*, int) == Stringpair) */
93 Channel *c2; /* chan(tuple(char*, int) == Stringpair) */
94 };
96 struct Mousereadmesg
97 {
98 Channel *cm; /* chan(Mouse) */
99 };
101 struct Stringpair /* rune and nrune or byte and nbyte */
102 {
103 void *s;
104 int ns;
105 };
107 struct Mousestate
108 {
109 Mouse;
110 ulong counter; /* serial no. of mouse event */
111 };
113 struct Mouseinfo
114 {
115 Mousestate queue[16];
116 int ri; /* read index into queue */
117 int wi; /* write index */
118 ulong counter; /* serial no. of last mouse event we received */
119 ulong lastcounter; /* serial no. of last mouse event sent to client */
120 int lastb; /* last button state we received */
121 uchar qfull; /* filled the queue; no more recording until client comes back */
122 };
124 struct Window
125 {
126 Ref;
127 QLock;
128 Frame;
129 Image *i;
130 Mousectl mc;
131 Mouseinfo mouse;
132 Channel *ck; /* chan(Rune[10]) */
133 Channel *cctl; /* chan(Wctlmesg)[20] */
134 Channel *conswrite; /* chan(Conswritemesg) */
135 Channel *consread; /* chan(Consreadmesg) */
136 Channel *mouseread; /* chan(Mousereadmesg) */
137 Channel *wctlread; /* chan(Consreadmesg) */
138 uint nr; /* number of runes in window */
139 uint maxr; /* number of runes allocated in r */
140 Rune *r;
141 uint nraw;
142 Rune *raw;
143 uint org;
144 uint q0;
145 uint q1;
146 uint qh;
147 int id;
148 char name[32];
149 uint namecount;
150 Rectangle scrollr;
151 /*
152 * Rio once used originwindow, so screenr could be different from i->r.
153 * Now they're always the same but the code doesn't assume so.
154 */
155 Rectangle screenr; /* screen coordinates of window */
156 int resized;
157 int wctlready;
158 Rectangle lastsr;
159 int topped;
160 int notefd;
161 uchar scrolling;
162 Cursor cursor;
163 Cursor *cursorp;
164 uchar holding;
165 uchar rawing;
166 uchar ctlopen;
167 uchar wctlopen;
168 uchar deleted;
169 uchar mouseopen;
170 char *label;
171 int pid;
172 char *dir;
173 };
175 int winborder(Window*, Point);
176 void winctl(void*);
177 void winshell(void*);
178 Window* wlookid(int);
179 Window* wmk(Image*, Mousectl*, Channel*, Channel*, int);
180 Window* wpointto(Point);
181 Window* wtop(Point);
182 void wtopme(Window*);
183 void wbottomme(Window*);
184 char* wcontents(Window*, int*);
185 int wbswidth(Window*, Rune);
186 int wclickmatch(Window*, int, int, int, uint*);
187 int wclose(Window*);
188 int wctlmesg(Window*, int, Rectangle, Image*);
189 int wctlmesg(Window*, int, Rectangle, Image*);
190 uint wbacknl(Window*, uint, uint);
191 uint winsert(Window*, Rune*, int, uint);
192 void waddraw(Window*, Rune*, int);
193 void wborder(Window*, int);
194 void wclosewin(Window*);
195 void wcurrent(Window*);
196 void wcut(Window*);
197 void wdelete(Window*, uint, uint);
198 void wdoubleclick(Window*, uint*, uint*);
199 void wfill(Window*);
200 void wframescroll(Window*, int);
201 void wkeyctl(Window*, Rune);
202 void wmousectl(Window*);
203 void wmovemouse(Window*, Point);
204 void wpaste(Window*);
205 void wplumb(Window*);
206 void wrefresh(Window*, Rectangle);
207 void wrepaint(Window*);
208 void wresize(Window*, Image*, int);
209 void wscrdraw(Window*);
210 void wscroll(Window*, int);
211 void wselect(Window*);
212 void wsendctlmesg(Window*, int, Rectangle, Image*);
213 void wsetcursor(Window*, int);
214 void wsetname(Window*);
215 void wsetorigin(Window*, uint, int);
216 void wsetpid(Window*, int, int);
217 void wsetselect(Window*, uint, uint);
218 void wshow(Window*, uint);
219 void wsnarf(Window*);
220 void wscrsleep(Window*, uint);
221 void wsetcols(Window*);
223 struct Dirtab
224 {
225 char *name;
226 uchar type;
227 uint qid;
228 uint perm;
229 };
231 struct Fid
232 {
233 int fid;
234 int busy;
235 int open;
236 int mode;
237 Qid qid;
238 Window *w;
239 Dirtab *dir;
240 Fid *next;
241 int nrpart;
242 uchar rpart[UTFmax];
243 };
245 struct Xfid
246 {
247 Ref;
248 Xfid *next;
249 Xfid *free;
250 Fcall;
251 Channel *c; /* chan(void(*)(Xfid*)) */
252 Fid *f;
253 uchar *buf;
254 Filsys *fs;
255 QLock active;
256 int flushing; /* another Xfid is trying to flush us */
257 int flushtag; /* our tag, so flush can find us */
258 Channel *flushc; /* channel(int) to notify us we're being flushed */
259 };
261 Channel* xfidinit(void);
262 void xfidctl(void*);
263 void xfidflush(Xfid*);
264 void xfidattach(Xfid*);
265 void xfidopen(Xfid*);
266 void xfidclose(Xfid*);
267 void xfidread(Xfid*);
268 void xfidwrite(Xfid*);
270 enum
271 {
272 Nhash = 16,
273 };
275 struct Filsys
276 {
277 int cfd;
278 int sfd;
279 int pid;
280 char *user;
281 Channel *cxfidalloc; /* chan(Xfid*) */
282 Fid *fids[Nhash];
283 };
285 Filsys* filsysinit(Channel*);
286 int filsysmount(Filsys*, int);
287 Xfid* filsysrespond(Filsys*, Xfid*, Fcall*, char*);
288 void filsyscancel(Xfid*);
290 void wctlproc(void*);
291 void wctlthread(void*);
293 void deletetimeoutproc(void*);
295 struct Timer
296 {
297 int dt;
298 int cancel;
299 Channel *c; /* chan(int) */
300 Timer *next;
301 };
303 Font *font;
304 Mousectl *mousectl;
305 Mouse *mouse;
306 Keyboardctl *keyboardctl;
307 Display *display;
308 Image *view;
309 Screen *wscreen;
310 Cursor boxcursor;
311 Cursor crosscursor;
312 Cursor sightcursor;
313 Cursor whitearrow;
314 Cursor query;
315 Cursor *corners[9];
316 Image *background;
317 Image *lightgrey;
318 Image *red;
319 Window **window;
320 Window *wkeyboard; /* window of simulated keyboard */
321 Window *wroot; /* root window */
322 int nwindow;
323 int snarffd;
324 Window *input;
325 QLock all; /* BUG */
326 Filsys *filsys;
327 Window *hidden[100];
328 int nhidden;
329 int nsnarf;
330 Rune* snarf;
331 int selborder;
332 int scrolling;
333 int maxtab;
334 Channel* winclosechan;
335 Channel* deletechan;
336 char *startdir;
337 int sweeping;
338 int wctlfd;
339 char srvpipe[];
340 char srvwctl[];
341 int errorshouldabort;
342 int menuing; /* menu action is pending; waiting for window to be indicated */
343 int snarfversion; /* updated each time it is written */
344 int messagesize; /* negotiated in 9P version setup */
hg clone http://hg.4l77.com/patch9/rio/