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 int id;
121 char name[32];
122 uint namecount;
123 Rectangle scrollr;
124 /*
125 * Rio once used originwindow, so screenr could be different from i->r.
126 * Now they're always the same but the code doesn't assume so.
127 */
128 Rectangle screenr; /* screen coordinates of window */
129 int resized;
130 int wctlready;
131 Rectangle lastsr;
132 int topped;
133 int notefd;
134 Cursor cursor;
135 Cursor *cursorp;
136 uchar holding;
137 uchar rawing;
138 uchar ctlopen;
139 uchar wctlopen;
140 uchar deleted;
141 uchar mouseopen;
142 char *label;
143 int pid;
144 char *dir;
145 };
147 int winborder(Window*, Point);
148 void winctl(void*);
149 void winshell(void*);
150 Window* wlookid(int);
151 Window* wmk(Image*, Mousectl*, Channel*, Channel*);
152 Window* wpointto(Point);
153 Window* wtop(Point);
154 void wtopme(Window*);
155 void wbottomme(Window*);
156 char* wcontents(Window*, int*);
157 int wbswidth(Window*, Rune);
158 int wclickmatch(Window*, int, int, int, uint*);
159 int wclose(Window*);
160 int wctlmesg(Window*, int, Rectangle, Image*);
161 int wctlmesg(Window*, int, Rectangle, Image*);
162 uint wbacknl(Window*, uint, uint);
163 uint winsert(Window*, Rune*, int, uint);
164 void waddraw(Window*, Rune*, int);
165 void wborder(Window*, int);
166 void wclosewin(Window*);
167 void wcurrent(Window*);
168 void wcut(Window*);
169 void wdelete(Window*, uint, uint);
170 void wdoubleclick(Window*, uint*, uint*);
171 void wfill(Window*);
172 void wframescroll(Window*, int);
173 void wkeyctl(Window*, Rune);
174 void wmousectl(Window*);
175 void wmovemouse(Window*, Point);
176 void wpaste(Window*);
177 void wplumb(Window*);
178 void wrefresh(Window*, Rectangle);
179 void wrepaint(Window*);
180 void wresize(Window*, Image*, int);
181 void wscrdraw(Window*);
182 void wscroll(Window*, int);
183 void wselect(Window*);
184 void wsendctlmesg(Window*, int, Rectangle, Image*);
185 void wsetcursor(Window*, int);
186 void wsetname(Window*);
187 void wsetorigin(Window*, uint, int);
188 void wsetpid(Window*, int, int);
189 void wsetselect(Window*, uint, uint);
190 void wshow(Window*, uint);
191 void wsnarf(Window*);
192 void wscrsleep(Window*, uint);
193 void wsetcols(Window*);
195 void deletetimeoutproc(void*);
197 struct Timer
199 int dt;
200 int cancel;
201 Channel *c; /* chan(int) */
202 Timer *next;
203 };
205 #ifndef Extern
206 #define Extern extern
207 #endif
209 Extern Font *font;
210 Extern Mousectl *mousectl;
211 Extern Mouse *mouse;
212 Extern Keyboardctl *keyboardctl;
213 Extern Display *display;
214 Extern Image *view;
215 Extern Screen *wscreen;
216 Extern Cursor boxcursor;
217 Extern Cursor crosscursor;
218 Extern Cursor sightcursor;
219 Extern Cursor whitearrow;
220 Extern Cursor query;
221 Extern Cursor *corners[9];
222 Extern Image *background;
223 Extern Image *lightgrey;
224 Extern Image *red;
225 Extern Window **window;
226 Extern Window *wkeyboard; /* window of simulated keyboard */
227 Extern int nwindow;
228 Extern int snarffd;
229 Extern Window *input;
230 Extern QLock all; /* BUG */
231 Extern Window *hidden[100];
232 Extern int nhidden;
233 Extern int nsnarf;
234 Extern Rune* snarf;
235 Extern int scrolling;
236 Extern int maxtab;
237 Extern Channel* winclosechan;
238 Extern Channel* deletechan;
239 Extern char *startdir;
240 Extern int sweeping;
241 Extern int wctlfd;
242 Extern int errorshouldabort;
243 Extern int menuing; /* menu action is pending; waiting for window to be indicated */
244 Extern int snarfversion; /* updated each time it is written */
245 Extern int messagesize; /* negotiated in 9P version setup */