2 88ed92aa 2020-01-13 rsc #define NHASH (1<<5)
3 88ed92aa 2020-01-13 rsc #define HASHMASK (NHASH-1)
5 88ed92aa 2020-01-13 rsc typedef struct Kbdbuf Kbdbuf;
6 88ed92aa 2020-01-13 rsc typedef struct Mousebuf Mousebuf;
7 88ed92aa 2020-01-13 rsc typedef struct Tagbuf Tagbuf;
9 88ed92aa 2020-01-13 rsc typedef struct Client Client;
10 94d381ec 2020-05-18 rsc typedef struct ClientImpl ClientImpl;
11 88ed92aa 2020-01-13 rsc typedef struct DImage DImage;
12 88ed92aa 2020-01-13 rsc typedef struct DScreen DScreen;
13 88ed92aa 2020-01-13 rsc typedef struct CScreen CScreen;
14 88ed92aa 2020-01-13 rsc typedef struct FChar FChar;
15 88ed92aa 2020-01-13 rsc typedef struct Refresh Refresh;
16 88ed92aa 2020-01-13 rsc typedef struct Refx Refx;
17 88ed92aa 2020-01-13 rsc typedef struct DName DName;
19 88ed92aa 2020-01-13 rsc struct Kbdbuf
30 88ed92aa 2020-01-13 rsc struct Mousebuf
32 88ed92aa 2020-01-13 rsc Mouse m[256];
40 88ed92aa 2020-01-13 rsc struct Tagbuf
47 94d381ec 2020-05-18 rsc struct ClientImpl
49 94d381ec 2020-05-18 rsc void (*rpc_resizeimg)(Client*);
50 94d381ec 2020-05-18 rsc void (*rpc_resizewindow)(Client*, Rectangle);
51 94d381ec 2020-05-18 rsc void (*rpc_setcursor)(Client*, Cursor*, Cursor2*);
52 94d381ec 2020-05-18 rsc void (*rpc_setlabel)(Client*, char*);
53 94d381ec 2020-05-18 rsc void (*rpc_setmouse)(Client*, Point);
54 94d381ec 2020-05-18 rsc void (*rpc_topwin)(Client*);
55 94d381ec 2020-05-18 rsc void (*rpc_bouncemouse)(Client*, Mouse);
56 94d381ec 2020-05-18 rsc void (*rpc_flush)(Client*, Rectangle);
59 587933c1 2020-05-18 rsc extern QLock drawlk;
61 88ed92aa 2020-01-13 rsc struct Client
65 41547af3 2020-01-13 rsc // wfdlk protects writes to wfd, which can be issued from either
66 41547af3 2020-01-13 rsc // the RPC thread or the graphics thread.
72 892b3c46 2020-01-13 rsc char* wsysid;
74 587933c1 2020-05-18 rsc // drawlk protects the draw data structures for all clients.
75 41547af3 2020-01-13 rsc // It can be acquired by an RPC thread or a graphics thread
76 41547af3 2020-01-13 rsc // but must not be held on one thread while waiting for the other.
78 88ed92aa 2020-01-13 rsc DImage* dimage[NHASH];
79 88ed92aa 2020-01-13 rsc CScreen* cscreen;
80 88ed92aa 2020-01-13 rsc Refresh* refresh;
81 88ed92aa 2020-01-13 rsc Rendez refrend;
82 88ed92aa 2020-01-13 rsc uchar* readdata;
83 88ed92aa 2020-01-13 rsc int nreaddata;
85 88ed92aa 2020-01-13 rsc int clientid;
87 88ed92aa 2020-01-13 rsc int refreshme;
90 88ed92aa 2020-01-13 rsc int displaydpi;
91 88ed92aa 2020-01-13 rsc int forcedpi;
93 88ed92aa 2020-01-13 rsc Rectangle flushrect;
94 88ed92aa 2020-01-13 rsc Memimage *screenimage;
95 88ed92aa 2020-01-13 rsc DScreen* dscreen;
98 88ed92aa 2020-01-13 rsc int namevers;
99 94d381ec 2020-05-18 rsc ClientImpl* impl;
101 41547af3 2020-01-13 rsc // Only accessed/modified by the graphics thread.
102 b1a086de 2020-01-13 rsc const void* view;
104 41547af3 2020-01-13 rsc // eventlk protects the keyboard and mouse events.
105 41547af3 2020-01-13 rsc QLock eventlk;
107 88ed92aa 2020-01-13 rsc Mousebuf mouse;
108 88ed92aa 2020-01-13 rsc Tagbuf kbdtags;
109 88ed92aa 2020-01-13 rsc Tagbuf mousetags;
110 88ed92aa 2020-01-13 rsc Rectangle mouserect;
113 88ed92aa 2020-01-13 rsc struct Refresh
115 88ed92aa 2020-01-13 rsc DImage* dimage;
116 88ed92aa 2020-01-13 rsc Rectangle r;
117 88ed92aa 2020-01-13 rsc Refresh* next;
122 88ed92aa 2020-01-13 rsc Client* client;
123 88ed92aa 2020-01-13 rsc DImage* dimage;
126 88ed92aa 2020-01-13 rsc struct DName
129 88ed92aa 2020-01-13 rsc Client *client;
130 88ed92aa 2020-01-13 rsc DImage* dimage;
134 88ed92aa 2020-01-13 rsc struct FChar
136 88ed92aa 2020-01-13 rsc int minx; /* left edge of bits */
137 88ed92aa 2020-01-13 rsc int maxx; /* right edge of bits */
138 88ed92aa 2020-01-13 rsc uchar miny; /* first non-zero scan-line */
139 88ed92aa 2020-01-13 rsc uchar maxy; /* last non-zero scan-line + 1 */
140 88ed92aa 2020-01-13 rsc schar left; /* offset of baseline */
141 88ed92aa 2020-01-13 rsc uchar width; /* width of baseline */
145 88ed92aa 2020-01-13 rsc * Reference counts in DImages:
146 88ed92aa 2020-01-13 rsc * one per open by original client
147 88ed92aa 2020-01-13 rsc * one per screen image or fill
148 88ed92aa 2020-01-13 rsc * one per image derived from this one by name
150 88ed92aa 2020-01-13 rsc struct DImage
156 88ed92aa 2020-01-13 rsc Memimage* image;
159 88ed92aa 2020-01-13 rsc FChar* fchar;
160 88ed92aa 2020-01-13 rsc DScreen* dscreen; /* 0 if not a window */
161 88ed92aa 2020-01-13 rsc DImage* fromname; /* image this one is derived from, by name */
162 88ed92aa 2020-01-13 rsc DImage* next;
165 88ed92aa 2020-01-13 rsc struct CScreen
167 88ed92aa 2020-01-13 rsc DScreen* dscreen;
168 88ed92aa 2020-01-13 rsc CScreen* next;
171 88ed92aa 2020-01-13 rsc struct DScreen
176 88ed92aa 2020-01-13 rsc DImage *dimage;
177 88ed92aa 2020-01-13 rsc DImage *dfill;
178 88ed92aa 2020-01-13 rsc Memscreen* screen;
179 88ed92aa 2020-01-13 rsc Client* owner;
180 88ed92aa 2020-01-13 rsc DScreen* next;
183 41547af3 2020-01-13 rsc // For the most part, the graphics driver-specific code in files
184 41547af3 2020-01-13 rsc // like mac-screen.m runs in the graphics library's main thread,
185 41547af3 2020-01-13 rsc // while the RPC service code in srv.c runs on the RPC service thread.
186 41547af3 2020-01-13 rsc // The exceptions in each file, which are called by the other,
187 41547af3 2020-01-13 rsc // are marked with special prefixes: gfx_* indicates code that
188 41547af3 2020-01-13 rsc // is in srv.c but nonetheless runs on the main graphics thread,
189 41547af3 2020-01-13 rsc // while rpc_* indicates code that is in, say, mac-screen.m but
190 41547af3 2020-01-13 rsc // nonetheless runs on the RPC service thread.
192 41547af3 2020-01-13 rsc // The gfx_* and rpc_* calls typically synchronize with the other
193 41547af3 2020-01-13 rsc // code in the file by acquiring a lock (or running a callback on the
194 41547af3 2020-01-13 rsc // target thread, which amounts to the same thing).
195 41547af3 2020-01-13 rsc // To avoid deadlock, callers of those routines must not hold any locks.
197 41547af3 2020-01-13 rsc // gfx_* routines are called on the graphics thread,
198 41547af3 2020-01-13 rsc // invoked from graphics driver callbacks to do RPC work.
199 41547af3 2020-01-13 rsc // No locks are held on entry.
200 b1a086de 2020-01-13 rsc void gfx_abortcompose(Client*);
201 b1a086de 2020-01-13 rsc void gfx_keystroke(Client*, int);
202 41547af3 2020-01-13 rsc void gfx_main(void);
203 b1a086de 2020-01-13 rsc void gfx_mousetrack(Client*, int, int, int, uint);
204 41547af3 2020-01-13 rsc void gfx_replacescreenimage(Client*, Memimage*);
205 1f799495 2020-01-15 rsc void gfx_mouseresized(Client*);
206 41547af3 2020-01-13 rsc void gfx_started(void);
208 41547af3 2020-01-13 rsc // rpc_* routines are called on the RPC thread,
209 41547af3 2020-01-13 rsc // invoked by the RPC server code to do graphics work.
210 41547af3 2020-01-13 rsc // No locks are held on entry.
211 41547af3 2020-01-13 rsc Memimage *rpc_attach(Client*, char*, char*);
212 41547af3 2020-01-13 rsc char* rpc_getsnarf(void);
213 41547af3 2020-01-13 rsc void rpc_putsnarf(char*);
214 41547af3 2020-01-13 rsc void rpc_shutdown(void);
215 41547af3 2020-01-13 rsc void rpc_main(void);
217 50923426 2020-01-13 rsc // rpc_gfxdrawlock and rpc_gfxdrawunlock
218 50923426 2020-01-13 rsc // are called around drawing operations to lock and unlock
219 50923426 2020-01-13 rsc // access to the graphics display, for systems where the
220 50923426 2020-01-13 rsc // individual memdraw operations use the graphics display (X11, not macOS).
221 50923426 2020-01-13 rsc void rpc_gfxdrawlock(void);
222 50923426 2020-01-13 rsc void rpc_gfxdrawunlock(void);
224 41547af3 2020-01-13 rsc // draw* routines are called on the RPC thread,
225 41547af3 2020-01-13 rsc // invoked by the RPC server to do pixel pushing.
226 50923426 2020-01-13 rsc // No locks are held on entry.
227 41547af3 2020-01-13 rsc int draw_dataread(Client*, void*, int);
228 41547af3 2020-01-13 rsc int draw_datawrite(Client*, void*, int);
229 41547af3 2020-01-13 rsc void draw_initdisplaymemimage(Client*, Memimage*);
231 41547af3 2020-01-13 rsc // utility routines
232 41547af3 2020-01-13 rsc int latin1(Rune*, int);
233 41547af3 2020-01-13 rsc int mouseswap(int);
234 41547af3 2020-01-13 rsc int parsewinsize(char*, Rectangle*, int*);
236 892b3c46 2020-01-13 rsc extern Client *client0; // set in single-client mode