Blob


1 #define STACK 32768
2 #undef Borderwidth
3 #define Borderwidth 0
5 #undef TRUE /* OS X */
6 #undef FALSE
8 typedef struct Consreadmesg Consreadmesg;
9 typedef struct Conswritemesg Conswritemesg;
10 typedef struct Stringpair Stringpair;
11 typedef struct Dirtab Dirtab;
12 typedef struct Mouseinfo Mouseinfo;
13 typedef struct Mousereadmesg Mousereadmesg;
14 typedef struct Mousestate Mousestate;
15 typedef struct Timer Timer;
16 typedef struct Wctlmesg Wctlmesg;
17 typedef struct Window Window;
19 enum
20 {
21 Selborder = 0, /* border of selected window */
22 Unselborder = 0, /* border of unselected window */
23 Scrollwid = 12, /* width of scroll bar */
24 Scrollgap = 4, /* gap right of scroll bar */
25 BIG = 3, /* factor by which window dimension can exceed screen */
26 TRUE = 1,
27 FALSE = 0
28 };
30 enum
31 {
32 Kscrolloneup = KF|0x20,
33 Kscrollonedown = KF|0x21
34 };
36 enum /* control messages */
37 {
38 Wakeup,
39 Reshaped,
40 Moved,
41 Refresh,
42 Movemouse,
43 Rawon,
44 Rawoff,
45 Holdon,
46 Holdoff,
47 Deleted,
48 Exited
49 };
51 struct Wctlmesg
52 {
53 int type;
54 Rectangle r;
55 Image *image;
56 };
58 struct Conswritemesg
59 {
60 Channel *cw; /* chan(Stringpair) */
61 };
63 struct Consreadmesg
64 {
65 Channel *c1; /* chan(tuple(char*, int) == Stringpair) */
66 Channel *c2; /* chan(tuple(char*, int) == Stringpair) */
67 };
69 struct Mousereadmesg
70 {
71 Channel *cm; /* chan(Mouse) */
72 };
74 struct Stringpair /* rune and nrune or byte and nbyte */
75 {
76 void *s;
77 int ns;
78 };
80 struct Mousestate
81 {
82 Mouse m;
83 ulong counter; /* serial no. of mouse event */
84 };
86 struct Mouseinfo
87 {
88 Mousestate queue[16];
89 int ri; /* read index into queue */
90 int wi; /* write index */
91 ulong counter; /* serial no. of last mouse event we received */
92 ulong lastcounter; /* serial no. of last mouse event sent to client */
93 int lastb; /* last button state we received */
94 uchar qfull; /* filled the queue; no more recording until client comes back */
95 };
97 struct Window
98 {
99 Ref ref;
100 QLock lk;
101 Frame f;
102 Image *i;
103 Mousectl mc;
104 Mouseinfo mouse;
105 Channel *ck; /* chan(Rune[10]) */
106 Channel *cctl; /* chan(Wctlmesg)[20] */
107 Channel *conswrite; /* chan(Conswritemesg) */
108 Channel *consread; /* chan(Consreadmesg) */
109 Channel *mouseread; /* chan(Mousereadmesg) */
110 Channel *wctlread; /* chan(Consreadmesg) */
111 uint nr; /* number of runes in window */
112 uint maxr; /* number of runes allocated in r */
113 Rune *r;
114 uint nraw;
115 Rune *raw;
116 uint org;
117 uint q0;
118 uint q1;
119 uint qh;
120 uint iq1; /* last input position */
121 int id;
122 char name[32];
123 uint namecount;
124 Rectangle scrollr;
125 /*
126 * Rio once used originwindow, so screenr could be different from i->r.
127 * Now they're always the same but the code doesn't assume so.
128 */
129 Rectangle screenr; /* screen coordinates of window */
130 int resized;
131 int wctlready;
132 Rectangle lastsr;
133 int topped;
134 int notefd;
135 uchar scrolling;
136 Cursor cursor;
137 Cursor *cursorp;
138 uchar holding;
139 uchar rawing;
140 uchar ctlopen;
141 uchar wctlopen;
142 uchar deleted;
143 uchar mouseopen;
144 char *label;
145 int pid;
146 char *dir;
147 };
149 int winborder(Window*, Point);
150 void winctl(void*);
151 void winshell(void*);
152 Window* wlookid(int);
153 Window* wmk(Image*, Mousectl*, Channel*, Channel*, int);
154 Window* wpointto(Point);
155 Window* wtop(Point);
156 void wtopme(Window*);
157 void wbottomme(Window*);
158 char* wcontents(Window*, int*);
159 int wbswidth(Window*, Rune);
160 int wclickmatch(Window*, int, int, int, uint*);
161 int wclose(Window*);
162 int wctlmesg(Window*, int, Rectangle, Image*);
163 int wctlmesg(Window*, int, Rectangle, Image*);
164 uint wbacknl(Window*, uint, uint);
165 uint winsert(Window*, Rune*, int, uint);
166 void waddraw(Window*, Rune*, int);
167 void wborder(Window*, int);
168 void wclosewin(Window*);
169 void wcurrent(Window*);
170 void wcut(Window*);
171 void wdelete(Window*, uint, uint);
172 void wdoubleclick(Window*, uint*, uint*);
173 void wfill(Window*);
174 void wframescroll(Window*, int);
175 void wkeyctl(Window*, Rune);
176 void wmousectl(Window*);
177 void wmovemouse(Window*, Point);
178 void wpaste(Window*);
179 void wplumb(Window*);
180 void wrefresh(Window*, Rectangle);
181 void wrepaint(Window*);
182 void wresize(Window*, Image*, int);
183 void wscrdraw(Window*);
184 void wscroll(Window*, int);
185 void wselect(Window*);
186 void wsendctlmesg(Window*, int, Rectangle, Image*);
187 void wsetcursor(Window*, int);
188 void wsetname(Window*);
189 void wsetorigin(Window*, uint, int);
190 void wsetpid(Window*, int, int);
191 void wsetselect(Window*, uint, uint);
192 void wshow(Window*, uint);
193 void wsnarf(Window*);
194 void wscrsleep(Window*, uint);
195 void wsetcols(Window*);
197 void deletetimeoutproc(void*);
199 struct Timer
201 int dt;
202 int cancel;
203 Channel *c; /* chan(int) */
204 Timer *next;
205 };
207 #ifndef Extern
208 #define Extern extern
209 #endif
211 Extern Font *font;
212 Extern Mousectl *mousectl;
213 Extern Mouse *mouse;
214 Extern Keyboardctl *keyboardctl;
215 Extern Display *display;
216 Extern Image *view;
217 Extern Screen *wscreen;
218 Extern Cursor boxcursor;
219 Extern Cursor crosscursor;
220 Extern Cursor sightcursor;
221 Extern Cursor whitearrow;
222 Extern Cursor query;
223 Extern Cursor *corners[9];
224 Extern Image *background;
225 Extern Image *lightgrey;
226 Extern Image *red;
227 Extern Window **window;
228 Extern Window *wkeyboard; /* window of simulated keyboard */
229 Extern int nwindow;
230 Extern int snarffd;
231 Extern Window *input;
232 Extern QLock all; /* BUG */
233 Extern Window *hidden[100];
234 Extern int nhidden;
235 Extern int nsnarf;
236 Extern Rune* snarf;
237 Extern int scrolling;
238 Extern int maxtab;
239 Extern Channel* winclosechan;
240 Extern Channel* deletechan;
241 Extern char *startdir;
242 Extern int sweeping;
243 Extern int wctlfd;
244 Extern int errorshouldabort;
245 Extern int menuing; /* menu action is pending; waiting for window to be indicated */
246 Extern int snarfversion; /* updated each time it is written */
247 Extern int messagesize; /* negotiated in 9P version setup */