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