]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/rio/dat.h
rio: move the test if w is allowed to change cursor into wsetcursor()
[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         Qlabel,
11         Qkbd,
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 */
21
22         QMAX,
23 };
24
25 #define STACK   8192
26 #define MAXSNARF        100*1024
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         Topped,
64         Repaint,
65         Refresh,
66         Movemouse,
67         Rawon,
68         Rawoff,
69         Holdon,
70         Holdoff,
71         Deleted,
72         Exited,
73 };
74
75 struct Wctlmesg
76 {
77         int             type;
78         Rectangle       r;
79         void            *p;
80 };
81
82 struct Conswritemesg
83 {
84         Channel *cw;            /* chan(Stringpair) */
85 };
86
87 struct Consreadmesg
88 {
89         Channel *c1;            /* chan(tuple(char*, int) == Stringpair) */
90         Channel *c2;            /* chan(tuple(char*, int) == Stringpair) */
91 };
92
93 struct Mousereadmesg
94 {
95         Channel *cm;            /* chan(Mouse) */
96 };
97
98 struct Stringpair       /* rune and nrune or byte and nbyte */
99 {
100         void            *s;
101         int             ns;
102 };
103
104 struct Mousestate
105 {
106         Mouse;
107         ulong   counter;        /* serial no. of mouse event */
108 };
109
110 struct Mouseinfo
111 {
112         Mousestate      queue[16];
113         int     ri;     /* read index into queue */
114         int     wi;     /* write index */
115         ulong   counter;        /* serial no. of last mouse event we received */
116         ulong   lastcounter;    /* serial no. of last mouse event sent to client */
117         int     lastb;  /* last button state we received */
118         uchar   qfull;  /* filled the queue; no more recording until client comes back */       
119 };      
120
121 struct Window
122 {
123         Ref;
124         QLock;
125         Frame;
126         Image           *i;             /* window image, nil when deleted */
127         Mousectl        mc;
128         Mouseinfo       mouse;
129         Channel         *ck;            /* chan(char*) */
130         Channel         *cctl;          /* chan(Wctlmesg)[4] */
131         Channel         *conswrite;     /* chan(Conswritemesg) */
132         Channel         *consread;      /* chan(Consreadmesg) */
133         Channel         *mouseread;     /* chan(Mousereadmesg) */
134         Channel         *wctlread;      /* chan(Consreadmesg) */
135         Channel         *kbdread;       /* chan(Consreadmesg) */
136         Channel         *complete;      /* chan(Completion*) */
137         Channel         *gone;          /* chan(char*) */
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         uchar           kbdopen;
171         char                    *label;
172         char                    *dir;
173 };
174
175 void            winctl(void*);
176 void            winshell(void*);
177 Window* wlookid(int);
178 Window* wmk(Image*, Mousectl*, Channel*, Channel*, int);
179 Window* wpointto(Point);
180 Window* wtop(Point);
181 void            wtopme(Window*);
182 void            wbottomme(Window*);
183 char*   wcontents(Window*, int*);
184 int             wbswidth(Window*, Rune);
185 int             wclickmatch(Window*, int, int, int, uint*);
186 int             wclose(Window*);
187 int             wctlmesg(Window*, int, Rectangle, void*);
188 uint            wbacknl(Window*, uint, uint);
189 uint            winsert(Window*, Rune*, int, uint);
190 void            waddraw(Window*, Rune*, int);
191 void            wborder(Window*, int);
192 void            wclunk(Window*);
193 void            wclosewin(Window*);
194 void            wcurrent(Window*);
195 void            wcut(Window*);
196 void            wdelete(Window*, uint, uint);
197 void            wdoubleclick(Window*, uint*, uint*);
198 void            wfill(Window*);
199 void            wframescroll(Window*, int);
200 void            wkeyctl(Window*, Rune);
201 void            wmousectl(Window*);
202 void            wmovemouse(Window*, Point);
203 void            wpaste(Window*);
204 void            wplumb(Window*);
205 void            wlook(Window*);
206 void            wrefresh(Window*);
207 void            wrepaint(Window*);
208 void            wresize(Window*, Image*);
209 void            wscrdraw(Window*);
210 void            wscroll(Window*, int);
211 void            wselect(Window*);
212 void            wsendctlmesg(Window*, int, Rectangle, void*);
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*, int);
222
223 struct Dirtab
224 {
225         char            *name;
226         uchar   type;
227         uint            qid;
228         uint            perm;
229 };
230
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 };
244
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                 int             flushtag;       /* our tag, so flush can find us */
256                 Channel *flushc;        /* channel(int) to notify us we're being flushed */
257 };
258
259 Channel*        xfidinit(void);
260 void            xfidctl(void*);
261 void            xfidflush(Xfid*);
262 void            xfidattach(Xfid*);
263 void            xfidopen(Xfid*);
264 void            xfidclose(Xfid*);
265 void            xfidread(Xfid*);
266 void            xfidwrite(Xfid*);
267
268 enum
269 {
270         Nhash   = 16,
271 };
272
273 struct Filsys
274 {
275                 int             cfd;
276                 int             sfd;
277                 int             pid;
278                 char            *user;
279                 Channel *cxfidalloc;    /* chan(Xfid*) */
280                 Channel *csyncflush;    /* chan(int) */
281                 Fid             *fids[Nhash];
282 };
283
284 Filsys* filsysinit(Channel*);
285 int             filsysmount(Filsys*, int);
286 Xfid*           filsysrespond(Filsys*, Xfid*, Fcall*, char*);
287 void            filsyscancel(Xfid*);
288
289 void            wctlproc(void*);
290 void            wctlthread(void*);
291
292 void            deletetimeoutproc(void*);
293
294 struct Timer
295 {
296         int             dt;
297         int             cancel;
298         Channel *c;     /* chan(int) */
299         Timer   *next;
300 };
301
302 Font            *font;
303 Mousectl        *mousectl;
304 Mouse   *mouse;
305 Display *display;
306 Image   *view;
307 Screen  *wscreen;
308 Cursor  boxcursor;
309 Cursor  crosscursor;
310 Cursor  sightcursor;
311 Cursor  whitearrow;
312 Cursor  query;
313 Cursor  *corners[9];
314
315 Image   *background;
316 Image   *cols[NCOL];
317 Image   *titlecol;
318 Image   *lighttitlecol;
319 Image   *dholdcol;
320 Image   *holdcol;
321 Image   *lightholdcol;
322 Image   *paleholdcol;
323 Image   *paletextcol;
324 Image   *sizecol;
325 int     reverse;        /* there are no pastel paints in the dungeons and dragons world -- rob pike */
326
327 Window  **window;
328 Window  *wkeyboard;     /* window of simulated keyboard */
329 int             nwindow;
330 int             snarffd;
331 int             gotscreen;
332 int             servekbd;
333 Window  *input;
334 QLock   all;                    /* BUG */
335 Filsys  *filsys;
336 Window  *hidden[100];
337 int             nhidden;
338 int             nsnarf;
339 Rune*   snarf;
340 int             scrolling;
341 int             maxtab;
342 Channel*        winclosechan;
343 Channel*        deletechan;
344 char            *startdir;
345 int             sweeping;
346 int             wctlfd;
347 char            srvpipe[];
348 char            srvwctl[];
349 int             errorshouldabort;
350 int             menuing;                /* menu action is pending; waiting for window to be indicated */
351 int             snarfversion;   /* updated each time it is written */
352 int             messagesize;            /* negotiated in 9P version setup */
353 int             shiftdown;
354 int             debug;