vfs: check userland buffers before reading them.
[haiku.git] / docs / develop / servers / app_server / AppServer.htm
blob9b1ad587d79045484876422a29f2261818ac1387
1 <HTML>
2 <HEAD>
3 <TITLE>AppServer.htm</TITLE>
4 <style type="text/css">
5 <!--
6 .Default {background-color: rgb(255,255,255); color: rgb(0,0,0); font-family: 'Dutch801 Rm BT'; font-size: 12pt}
7 .OBOS-Function-Def {background-color: rgb(255,255,255); color: rgb(0,0,0); font-family: 'Dutch801 Rm BT'; font-size: 16pt}
8 .OBOS-Title {background-color: rgb(255,255,255); color: rgb(0,128,0); font-family: 'Dutch801 Rm BT'; font-size: 24pt}
9 .Text-Background {background-color: rgb(255,255,255)}
10 .GR-Default {}
11 .Body {margin: 0px}
12 .Footer {margin: 0px}
13 .Header {margin: 0px}
14 .WP-Default {text-align: left; text-indent: 0px; margin-left: 0px; margin-right: 0px}
15 -->
16 </style>
17 </HEAD>
18 <BODY BGCOLOR="#ffffff">
19 <DIV class="sheet" id="Sheet 1">
20 <P class="Body" style="margin: 0px"><span class="OBOS-Title">AppServer class</span><span style="color: rgb(0,0,0); font-size: 24pt"></span></P>
21 <P class="Body" style="margin: 0px"><BR>
22 </P>
23 <P class="Body" style="margin: 0px">The AppServer class sits at the top of the hierarchy, starting and stopping services, monitoring for messages, and so forth.</P>
24 <P class="Body" style="margin: 0px"><BR>
25 <BR>
26 <HR>
27 </P>
28 <P class="Body" style="margin: 0px"><BR>
29 Member Functions</P>
30 <P class="Body" style="margin: 0px"><BR>
31 </P>
32 <TABLE WIDTH=617 HEIGHT=113 BORDER=1 CELLPADDING=1 CELLSPACING=2>
33 <TR>
34 <TD WIDTH=203 HEIGHT=17>
35 <P class="Body" style="margin: 0px">AppServer(void)</P>
36 </TD>
37 <TD WIDTH=260 HEIGHT=17>
38 <P class="Body" style="margin: 0px">~AppServer(void)</P>
39 </TD>
40 </TR>
41 <TR>
42 <TD WIDTH=203 HEIGHT=17>
43 <P class="Body" style="margin: 0px">static int32 Poller(void *data)</P>
44 </TD>
45 <TD WIDTH=260 HEIGHT=17>
46 <P class="Body" style="margin: 0px">static int32 Picasso(void *data)</P>
47 </TD>
48 </TR>
49 <TR>
50 <TD WIDTH=203 HEIGHT=17>
51 <P class="Body" style="margin: 0px">thread_id Run(void)</P>
52 </TD>
53 <TD WIDTH=260 HEIGHT=17>
54 <P class="Body" style="margin: 0px">void MainLoop(void)</P>
55 </TD>
56 </TR>
57 <TR>
58 <TD WIDTH=203 HEIGHT=17>
59 <P class="Body" style="margin: 0px">bool LoadDecorator(const char *path)</P>
60 </TD>
61 <TD WIDTH=260 HEIGHT=17>
62 <P class="Body" style="margin: 0px">void DispatchMessage(int32 code, int8 *buffer)</P>
63 </TD>
64 </TR>
65 <TR>
66 <TD WIDTH=203 HEIGHT=17>
67 <P class="Body" style="margin: 0px">void Broadcast(int32 code)</P>
68 </TD>
69 <TD WIDTH=260 HEIGHT=17>
70 <P class="Body" style="margin: 0px"><span style="color: rgb(0,0,0)">void HandleKeyMessage(int32 code, int8 *buffer)</span></P>
71 </TD>
72 </TR>
73 </TABLE>
74 <P class="Body" style="margin: 0px"><BR>
75 <BR>
76 Global Functions</P>
77 <P class="Body" style="margin: 0px"><BR>
78 Decorator * instantiate_decorator(Layer *owner, uint32 wflags, uint32 wlook)</P>
79 <P class="Body" style="margin: 0px"><BR>
80 <BR>
81 <HR>
82 </P>
83 <P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">AppServer(void)</span><span style="font-size: 16pt"></span></P>
84 <P class="Body" style="margin: 0px"><BR>
85 1) Create the message and input ports</P>
86 <P class="Body" style="margin: 0px">2) Create any necessary semaphores for regulating the 3 main threads</P>
87 <P class="Body" style="margin: 0px">3) Initialize all member variables</P>
88 <P class="Body" style="margin: 0px">4) Allocate the application BList</P>
89 <P class="Body" style="margin: 0px">5) Read in and process all configuration data</P>
90 <P class="Body" style="margin: 0px">6) Initialize the desktop</P>
91 <P class="Body" style="margin: 0px">7) Spawn the Picasso and Poller threads</P>
92 <P class="Body" style="margin: 0px"><BR>
93 <BR>
94 <span class="OBOS-Function-Def">~AppServer(void)</span></P>
95 <P class="Body" style="margin: 0px"><BR>
96 1) Shut down the desktop</P>
97 <P class="Body" style="margin: 0px">2) Empty and delete the application list</P>
98 <P class="Body" style="margin: 0px">3) Wait for Picasso and Poller to exit</P>
99 <P class="Body" style="margin: 0px">4) Free any allocated heap space</P>
100 <P class="Body" style="margin: 0px"><BR>
101 <BR>
102 <span class="OBOS-Function-Def">void MainLoop(void)</span></P>
103 <P class="Body" style="margin: 0px"><BR>
104 MainLoop is one large loop used to monitor the main message port in the app_server thread. This is a standard port-monitoring loop code:</P>
105 <P class="Body" style="margin: 0px"><BR>
106 1) Call port_buffer_size - which will block if the port is empty</P>
107 <P class="Body" style="margin: 0px">2) Allocate a buffer on the heap if the port buffer size is greater than 0</P>
108 <P class="Body" style="margin: 0px">3) Read the port</P>
109 <P class="Body" style="margin: 0px">4) Pass specified messages to DispatchMessage() for processing, spitting out an error message to stderr if the message's code is unrecognized</P>
110 <P class="Body" style="margin: 0px">5) Return from DispatchMessage() and free the message buffer if one was allocated</P>
111 <P class="Body" style="margin: 0px">6) If the message code matches the B_QUIT_REQUESTED definition and the quit_server flag is true, fall out of the infinite message-monitoring loop</P>
112 <P class="Body" style="margin: 0px"><BR>
113 <BR>
114 <span class="OBOS-Function-Def">void DispatchMessage(int32 code, int8 *buffer)</span></P>
115 <P class="Body" style="margin: 0px"><BR>
116 DispatchMessage implements all the code necessary to respond to a given message sent to the app_server on its main port. This allows for clearer and more manageable code.</P>
117 <P class="Body" style="margin: 0px"><BR>
118 CREATE_APP:</P>
119 <P class="Body" style="margin: 0px"><BR>
120 Sent by a new BApplication object via synchronous PortLink messaging. Set up the corresponding ServerApp and reply to the BApplication with the new port to which it will send future communications with the App Server.</P>
121 <P class="Body" style="margin: 0px"><BR>
122 Attached Data:</P>
123 <P class="Body" style="margin: 0px"><BR>
124 </P>
125 <P class="Body" style="text-align: center; margin: 0px"></P>
126 <TABLE WIDTH=573 HEIGHT=110 BORDER=1 CELLPADDING=1 CELLSPACING=2>
127 <TR>
128 <TD WIDTH=112 HEIGHT=32>
129 <P class="Body" style="margin: 0px">port_id reply_port</P>
130 </TD>
131 <TD WIDTH=318 HEIGHT=32>
132 <P class="Body" style="margin: 0px">port to which the server is to reply in response to the current message</P>
133 </TD>
134 </TR>
135 <TR>
136 <TD WIDTH=112 HEIGHT=17>
137 <P class="Body" style="margin: 0px">port_id app_port</P>
138 </TD>
139 <TD WIDTH=318 HEIGHT=17>
140 <P class="Body" style="margin: 0px">message port for the requesting BApplication</P>
141 </TD>
142 </TR>
143 <TR>
144 <TD WIDTH=112 HEIGHT=17>
145 <P class="Body" style="margin: 0px">int16 sig_length</P>
146 </TD>
147 <TD WIDTH=318 HEIGHT=17>
148 <P class="Body" style="margin: 0px">length of the following application signature</P>
149 </TD>
150 </TR>
151 <TR>
152 <TD WIDTH=112 HEIGHT=17>
153 <P class="Body" style="margin: 0px">const char *signature</P>
154 </TD>
155 <TD WIDTH=318 HEIGHT=17>
156 <P class="Body" style="margin: 0px">Signature of the requesting BApplication</P>
157 </TD>
158 </TR>
159 </TABLE>
160 <P class="Body" style="text-align: center; margin: 0px"><BR>
161 </P>
162 <P class="Body" style="margin: 0px"><BR>
163 1) Get all attached data</P>
164 <P class="Body" style="margin: 0px">2) Acquire the application list lock</P>
165 <P class="Body" style="margin: 0px">3) Allocate a ServerApp object and add it to the list</P>
166 <P class="Body" style="margin: 0px">4) Release application list lock</P>
167 <P class="Body" style="margin: 0px">5) Acquire active application pointer lock</P>
168 <P class="Body" style="margin: 0px">6) Update active application pointer</P>
169 <P class="Body" style="margin: 0px">7) Release active application lock</P>
170 <P class="Body" style="margin: 0px">8) Send the message SET_SERVER_PORT (with the ServerApp's receiver port attached) to the reply port</P>
171 <P class="Body" style="margin: 0px">9) Run() the new ServerApp instance</P>
172 <P class="Body" style="margin: 0px"><BR>
173 <BR>
174 DELETE_APP:</P>
175 <P class="Body" style="margin: 0px"><BR>
176 Sent by a ServerApp when told to quit either by its BApplication or the Server itself (during shutdown). It is identified by the unique ID assigned to its thread.</P>
177 <P class="Body" style="margin: 0px"><BR>
178 Attached Data:</P>
179 <P class="Body" style="margin: 0px"><BR>
180 </P>
181 <P class="Body" style="text-align: center; margin: 0px"></P>
182 <TABLE WIDTH=568 HEIGHT=22 BORDER=1 CELLPADDING=1 CELLSPACING=2>
183 <TR>
184 <TD WIDTH=132 HEIGHT=17>
185 <P class="Body" style="margin: 0px">thread_id app_thread</P>
186 </TD>
187 <TD WIDTH=294 HEIGHT=17>
188 <P class="Body" style="margin: 0px">Thread id of the ServerApp sending this message</P>
189 </TD>
190 </TR>
191 </TABLE>
192 <P class="Body" style="text-align: center; margin: 0px"><BR>
193 </P>
194 <P class="Body" style="text-align: left; margin: 0px"><BR>
195 1) Get app's thread_id</P>
196 <P class="Body" style="text-align: left; margin: 0px">2) Acquire application list lock</P>
197 <P class="Body" style="text-align: left; margin: 0px">3) Iterate through the application list, searching for the ServerApp object with the sent thread_id</P>
198 <P class="Body" style="text-align: left; margin: 0px">4) Remove the object from the list and delete it</P>
199 <P class="Body" style="text-align: left; margin: 0px">5) Acquire active application lock</P>
200 <P class="Body" style="text-align: left; margin: 0px">6) Check to see if the application is active</P>
201 <P class="Body" style="text-align: left; margin: 0px">7) If application is/was active, set it to the previous application in the list or NULL if there are no other active applications</P>
202 <P class="Body" style="text-align: left; margin: 0px">8) Release application list lock</P>
203 <P class="Body" style="text-align: left; margin: 0px">9) Release active application lock</P>
204 <P class="Body" style="text-align: left; margin: 0px"><BR>
205 <BR>
206 GET_SCREEN_MODE:</P>
207 <P class="Body" style="text-align: left; margin: 0px"><BR>
208 Received from the OpenBeOS Input Server when requesting the current screen settings via synchronous PortLink messaging. This is a temporary solution which will be deprecated as soon as the BScreen class is complete.</P>
209 <P class="Body" style="text-align: left; margin: 0px"><BR>
210 </P>
211 <P class="Body" style="margin: 0px">Attached Data:</P>
212 <P class="Body" style="margin: 0px"><BR>
213 </P>
214 <P class="Body" style="text-align: center; margin: 0px"></P>
215 <TABLE WIDTH=573 HEIGHT=42 BORDER=1 CELLPADDING=1 CELLSPACING=2>
216 <TR>
217 <TD WIDTH=112 HEIGHT=32>
218 <P class="Body" style="margin: 0px">port_id reply_port</P>
219 </TD>
220 <TD WIDTH=318 HEIGHT=32>
221 <P class="Body" style="margin: 0px">port to which the server is to reply in response to the current message</P>
222 </TD>
223 </TR>
224 </TABLE>
225 <P class="Body" style="text-align: center; margin: 0px"><BR>
226 </P>
227 <P class="Body" style="text-align: left; margin: 0px"><BR>
228 1) Get height, width, and color depth from the global graphics driver object</P>
229 <P class="Body" style="text-align: left; margin: 0px">2) Attach via PortLink and reply to sender</P>
230 <P class="Body" style="text-align: left; margin: 0px"><BR>
231 B_QUIT_REQUESTED:</P>
232 <P class="Body" style="text-align: left; margin: 0px"><BR>
233 Encountered only under testing situations where the Server is told to quit.</P>
234 <P class="Body" style="text-align: left; margin: 0px"><BR>
235 Attached Data: None</P>
236 <P class="Body" style="text-align: left; margin: 0px"><BR>
237 1) Set quit_server flag to true</P>
238 <P class="Body" style="text-align: left; margin: 0px">2) Call Broadcast(QUIT_APP)</P>
239 <P class="Body" style="text-align: left; margin: 0px"><BR>
240 <BR>
241 SET_DECORATOR:</P>
242 <P class="Body" style="text-align: left; margin: 0px"><BR>
243 Received from just about anything when a new window decorator is chosen</P>
244 <P class="Body" style="text-align: left; margin: 0px"><BR>
245 </P>
246 <P class="Body" style="margin: 0px">Attached Data:</P>
247 <P class="Body" style="margin: 0px"><BR>
248 </P>
249 <P class="Body" style="text-align: center; margin: 0px"></P>
250 <TABLE WIDTH=548 HEIGHT=22 BORDER=1 CELLPADDING=1 CELLSPACING=2>
251 <TR>
252 <TD WIDTH=117 HEIGHT=17>
253 <P class="Body" style="margin: 0px">const char *path</P>
254 </TD>
255 <TD WIDTH=294 HEIGHT=17>
256 <P class="Body" style="margin: 0px">Path to the proposed new decorator</P>
257 </TD>
258 </TR>
259 </TABLE>
260 <P class="Body" style="text-align: center; margin: 0px"><BR>
261 </P>
262 <P class="Body" style="text-align: left; margin: 0px"><BR>
263 1) Get the path from the buffer</P>
264 <P class="Body" style="text-align: left; margin: 0px">2) Call LoadDecorator()</P>
265 <P class="Body" style="text-align: left; margin: 0px"><BR>
266 <BR>
267 <span class="OBOS-Function-Def">void Run(void)</span></P>
268 <P class="Body" style="text-align: left; margin: 0px"><BR>
269 Run() exists mostly for consistency with other regular applications.</P>
270 <P class="Body" style="text-align: left; margin: 0px"><BR>
271 1) Call MainLoop()</P>
272 <P class="Body" style="text-align: left; margin: 0px"><BR>
273 <BR>
274 <span class="OBOS-Function-Def">bool LoadDecorator(const char *path)</span></P>
275 <P class="Body" style="text-align: left; margin: 0px"><BR>
276 Allows for a simple way to change the current window decorator systemwide simply by specifying the path to the desired Decorator addon.</P>
277 <P class="Body" style="text-align: left; margin: 0px"><BR>
278 1) Load the passed string as the path to an addon.</P>
279 <P class="Body" style="text-align: left; margin: 0px">2) Load all necessary symbols for the decorator</P>
280 <P class="Body" style="text-align: left; margin: 0px">3) Return false if things didn't go so well</P>
281 <P class="Body" style="text-align: left; margin: 0px">4) Call Broadcast(UPDATE_DECORATOR)</P>
282 <P class="Body" style="text-align: left; margin: 0px">5) Return true</P>
283 <P class="Body" style="text-align: left; margin: 0px"><BR>
284 <span class="OBOS-Function-Def">static int32 Picasso(void *data)</span></P>
285 <P class="Body" style="text-align: left; margin: 0px"><BR>
286 Picasso is a function, despite its name, dedicated to ensuring that the server deallocates resources to a dead application. It consists of a while(!quit_server) loop as follows:</P>
287 <P class="Body" style="text-align: left; margin: 0px"><BR>
288 1) Acquire the appliction list lock</P>
289 <P class="Body" style="text-align: left; margin: 0px">2) Iterate through the list, calling each ServerApp object's PingTarget() method.</P>
290 <P class="Body" style="text-align: left; margin: 0px">3) If PingTarget returns false, remove the ServerApp from the list and delete it.</P>
291 <P class="Body" style="text-align: left; margin: 0px">4) Release the appliction list lock</P>
292 <P class="Body" style="text-align: left; margin: 0px">5) snooze for 3 seconds</P>
293 <P class="Body" style="text-align: left; margin: 0px"><BR>
294 <span class="OBOS-Function-Def">static int32 Poller(void *data)</span></P>
295 <P class="Body" style="text-align: left; margin: 0px"><BR>
296 Poller is the main workhorse of the AppServer class, polling the Server's input port constantly for any messages from the Input Server and calling the appropriate handlers. Like Picasso, it, too, is mostly a while(!quit_server) loop.</P>
297 <P class="Body" style="text-align: left; margin: 0px"><BR>
298 </P>
299 <P class="Body" style="margin: 0px">1) Call port_buffer_size_etc() with a timeout of 3 seconds.</P>
300 <P class="Body" style="margin: 0px">2) Check to see if the port_buffer_size_etc() timed out and do a continue to next iteration if it did.</P>
301 <P class="Body" style="margin: 0px">3) Allocate a buffer on the heap if the port buffer size is greater than 0</P>
302 <P class="Body" style="margin: 0px">4) Read the port</P>
303 <P class="Body" style="margin: 0px">5) Pass specified messages to DispatchMessage() for processing, spitting out an error message to stderr if the message's code is unrecognized</P>
304 <P class="Body" style="margin: 0px">6) Return from DispatchMessage() and free the message buffer if one was allocated</P>
305 <P class="Body" style="margin: 0px"><BR>
306 <BR>
307 <HR>
308 </P>
309 <P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">Decorator * instantiate_decorator(Layer *owner, uint32 wflags, uint32 wlook)</span></P>
310 <P class="Body" style="margin: 0px"><BR>
311 instantiate_decorator returns a new instance of the decorator currently in use. The caller is responsible for the memory allocated for the returned object.</P>
312 <P class="Body" style="margin: 0px"><BR>
313 1) Acquire the decorator lock</P>
314 <P class="Body" style="margin: 0px">2) If create_decorator is NULL, create a new instance of the default decorator</P>
315 <P class="Body" style="margin: 0px">3) If create_decorator is non-NULL, create a new decorator instance by calling AppServer::create_decorator().</P>
316 <P class="Body" style="margin: 0px">4) Release the decorator lock</P>
317 <P class="Body" style="margin: 0px">5) Return the newly allocated instance</P>
318 <P class="Body" style="margin: 0px"><BR>
319 <span class="OBOS-Function-Def">void Broadcast(int32 code)</span></P>
320 <P class="Body" style="margin: 0px"><BR>
321 Broadcast() provides the AppServer class with an easy way to send a quick message to all ServerApps. Primarily, this is called when a font or decorator has changed, or when the server is shutting down. It is not intended to do anything except send a quick message which requires no extra data, such as for some upadate signalling.</P>
322 <P class="Body" style="margin: 0px"><BR>
323 </P>
324 <P class="Body" style="text-align: left; margin: 0px">1) Acquire application list lock</P>
325 <P class="Body" style="text-align: left; margin: 0px">2) Create a PortLink instance and set its message code to the passed parameter.</P>
326 <P class="Body" style="text-align: left; margin: 0px">3) Iterate through the application list, targeting the PortLink instance to each ServerApp's message port and calling Flush().</P>
327 <P class="Body" style="text-align: left; margin: 0px">4) Release application list lock</P>
328 <P class="Body" style="text-align: left; margin: 0px"><BR>
329 <span class="OBOS-Function-Def">void HandleKeyMessage(int32 code, int8 *buffer)</span></P>
330 <P class="Body" style="text-align: left; margin: 0px"><BR>
331 </P>
332 <P class="Body" style="margin: 0px">Called from DispatchMessage to filter out App Server events and otherwise send keystrokes to the active application. </P>
333 <P class="Body" style="margin: 0px"><BR>
334 B_KEY_DOWN:</P>
335 <P class="Body" style="margin: 0px"><BR>
336 Sent when the user presses (or holds down) a key that's been mapped to a character.</P>
337 <P class="Body" style="margin: 0px"><BR>
338 Attached Data:</P>
339 <P class="Body" style="margin: 0px"><BR>
340 </P>
341 <P class="Body" style="text-align: center; margin: 0px"></P>
342 <TABLE WIDTH=573 HEIGHT=246 BORDER=1 CELLPADDING=1 CELLSPACING=2>
343 <TR>
344 <TD WIDTH=112 HEIGHT=17>
345 <P class="Body" style="margin: 0px">int64 when</P>
346 </TD>
347 <TD WIDTH=318 HEIGHT=17>
348 <P class="Body" style="margin: 0px">event time in seconds since 1/1/70</P>
349 </TD>
350 </TR>
351 <TR>
352 <TD WIDTH=112 HEIGHT=17>
353 <P class="Body" style="margin: 0px">int32 rawcode</P>
354 </TD>
355 <TD WIDTH=318 HEIGHT=17>
356 <P class="Body" style="margin: 0px">code for the physical key pressed</P>
357 </TD>
358 </TR>
359 <TR>
360 <TD WIDTH=112 HEIGHT=17>
361 <P class="Body" style="margin: 0px">int32 repeat_count</P>
362 </TD>
363 <TD WIDTH=318 HEIGHT=17>
364 <P class="Body" style="margin: 0px">number of times a key has been repeated</P>
365 </TD>
366 </TR>
367 <TR>
368 <TD WIDTH=112 HEIGHT=17>
369 <P class="Body" style="margin: 0px">int32 modifiers</P>
370 </TD>
371 <TD WIDTH=318 HEIGHT=17>
372 <P class="Body" style="margin: 0px">flags signifying the states of the modifier keys</P>
373 </TD>
374 </TR>
375 <TR>
376 <TD WIDTH=112 HEIGHT=17>
377 <P class="Body" style="margin: 0px">int32 state_count</P>
378 </TD>
379 <TD WIDTH=318 HEIGHT=17>
380 <P class="Body" style="margin: 0px">number of bytes to follow containing the state of all keys</P>
381 </TD>
382 </TR>
383 <TR>
384 <TD WIDTH=112 HEIGHT=17>
385 <P class="Body" style="margin: 0px">int8 *states</P>
386 </TD>
387 <TD WIDTH=318 HEIGHT=17>
388 <P class="Body" style="margin: 0px">array of the state of all keys at the time of the event</P>
389 </TD>
390 </TR>
391 <TR>
392 <TD WIDTH=112 HEIGHT=17>
393 <P class="Body" style="margin: 0px">int8 utf8data[3]</P>
394 </TD>
395 <TD WIDTH=318 HEIGHT=17>
396 <P class="Body" style="margin: 0px">UTF-8 data generated</P>
397 </TD>
398 </TR>
399 <TR>
400 <TD WIDTH=112 HEIGHT=32>
401 <P class="Body" style="margin: 0px">int8 charcount</P>
402 </TD>
403 <TD WIDTH=318 HEIGHT=32>
404 <P class="Body" style="margin: 0px">number of bytes to follow containing the string generated (usually 1)</P>
405 </TD>
406 </TR>
407 <TR>
408 <TD WIDTH=112 HEIGHT=17>
409 <P class="Body" style="margin: 0px">const char *string</P>
410 </TD>
411 <TD WIDTH=318 HEIGHT=17>
412 <P class="Body" style="margin: 0px">null-terminated string generated by the keystroke</P>
413 </TD>
414 </TR>
415 <TR>
416 <TD WIDTH=112 HEIGHT=17>
417 <P class="Body" style="margin: 0px">int32 raw_char</P>
418 </TD>
419 <TD WIDTH=318 HEIGHT=17>
420 <P class="Body" style="margin: 0px">modifier-independent ASCII code for the character</P>
421 </TD>
422 </TR>
423 </TABLE>
424 <P class="Body" style="text-align: center; margin: 0px"><BR>
425 </P>
426 <P class="Body" style="margin: 0px"><BR>
427 1) Get all attached data</P>
428 <P class="Body" style="margin: 0px">2) If the command modifier is down, check for Left Ctrl+Left Alt+Left Shift+F12 and reset the workspace to 640 x 480 x 256 @ 60Hz and return if true</P>
429 <P class="Body" style="margin: 0px">3) If the command modifier is down, check for Alt+F1 through Alt+F12 and set workspace and return if true</P>
430 <P class="Body" style="margin: 0px">4) If the control modifier is true, check for B_CONTROL_KEY+Tab and, if true, find and send to the Deskbar.</P>
431 <P class="Body" style="margin: 0px">4) Acquire the active application lock</P>
432 <P class="Body" style="margin: 0px">5) Create a PortLink instance, target the active ServerApp's sender port, set the opcode to B_KEY_DOWN, attach the buffer <span style="font-style: italic">en masse</span>, and send it to the BApplication.</P>
433 <P class="Body" style="margin: 0px">6) Release the active application lock</P>
434 <P class="Body" style="margin: 0px"><BR>
435 </P>
436 <P class="Body" style="text-align: left; margin: 0px">B_KEY_UP:</P>
437 <P class="Body" style="text-align: left; margin: 0px"><BR>
438 </P>
439 <P class="Body" style="margin: 0px">Sent when the user releases a key that's been mapped to a character.</P>
440 <P class="Body" style="margin: 0px"><BR>
441 Attached Data:</P>
442 <P class="Body" style="margin: 0px"><BR>
443 </P>
444 <P class="Body" style="text-align: center; margin: 0px"></P>
445 <TABLE WIDTH=573 HEIGHT=224 BORDER=1 CELLPADDING=1 CELLSPACING=2>
446 <TR>
447 <TD WIDTH=112 HEIGHT=17>
448 <P class="Body" style="margin: 0px">int64 when</P>
449 </TD>
450 <TD WIDTH=318 HEIGHT=17>
451 <P class="Body" style="margin: 0px">event time in seconds since 1/1/70</P>
452 </TD>
453 </TR>
454 <TR>
455 <TD WIDTH=112 HEIGHT=17>
456 <P class="Body" style="margin: 0px">int32 rawcode</P>
457 </TD>
458 <TD WIDTH=318 HEIGHT=17>
459 <P class="Body" style="margin: 0px">code for the physical key pressed</P>
460 </TD>
461 </TR>
462 <TR>
463 <TD WIDTH=112 HEIGHT=17>
464 <P class="Body" style="margin: 0px">int32 modifiers</P>
465 </TD>
466 <TD WIDTH=318 HEIGHT=17>
467 <P class="Body" style="margin: 0px">flags signifying the states of the modifier keys</P>
468 </TD>
469 </TR>
470 <TR>
471 <TD WIDTH=112 HEIGHT=17>
472 <P class="Body" style="margin: 0px">int32 state_count</P>
473 </TD>
474 <TD WIDTH=318 HEIGHT=17>
475 <P class="Body" style="margin: 0px">number of bytes to follow containing the state of all keys</P>
476 </TD>
477 </TR>
478 <TR>
479 <TD WIDTH=112 HEIGHT=17>
480 <P class="Body" style="margin: 0px">int8 *states</P>
481 </TD>
482 <TD WIDTH=318 HEIGHT=17>
483 <P class="Body" style="margin: 0px">array of the state of all keys at the time of the event</P>
484 </TD>
485 </TR>
486 <TR>
487 <TD WIDTH=112 HEIGHT=17>
488 <P class="Body" style="margin: 0px">int8 utf8data[3]</P>
489 </TD>
490 <TD WIDTH=318 HEIGHT=17>
491 <P class="Body" style="margin: 0px">UTF-8 data generated</P>
492 </TD>
493 </TR>
494 <TR>
495 <TD WIDTH=112 HEIGHT=32>
496 <P class="Body" style="margin: 0px">int8 charcount</P>
497 </TD>
498 <TD WIDTH=318 HEIGHT=32>
499 <P class="Body" style="margin: 0px">number of bytes to follow containing the string generated (usually 1)</P>
500 </TD>
501 </TR>
502 <TR>
503 <TD WIDTH=112 HEIGHT=17>
504 <P class="Body" style="margin: 0px">const char *string</P>
505 </TD>
506 <TD WIDTH=318 HEIGHT=17>
507 <P class="Body" style="margin: 0px">null-terminated string generated by the keystroke</P>
508 </TD>
509 </TR>
510 <TR>
511 <TD WIDTH=112 HEIGHT=17>
512 <P class="Body" style="margin: 0px">int32 raw_char</P>
513 </TD>
514 <TD WIDTH=318 HEIGHT=17>
515 <P class="Body" style="margin: 0px">modifier-independent ASCII code for the character</P>
516 </TD>
517 </TR>
518 </TABLE>
519 <P class="Body" style="text-align: center; margin: 0px"><BR>
520 </P>
521 <P class="Body" style="margin: 0px"><BR>
522 1) Get all attached data</P>
523 <P class="Body" style="margin: 0px">2) Acquire the active application lock</P>
524 <P class="Body" style="margin: 0px">3) Create a PortLink instance, target the active ServerApp's sender port, set the opcode to B_KEY_UP, attach the buffer <span style="font-style: italic">en masse</span>, and send it to the BApplication.</P>
525 <P class="Body" style="margin: 0px">4) Release the active application lock</P>
526 <P class="Body" style="text-align: left; margin: 0px"><BR>
527 B_UNMAPPED_KEY_DOWN:</P>
528 <P class="Body" style="text-align: left; margin: 0px"><BR>
529 </P>
530 <P class="Body" style="margin: 0px">Sent when the user presses a key that has not been mapped to a character.</P>
531 <P class="Body" style="margin: 0px"><BR>
532 Attached Data:</P>
533 <P class="Body" style="margin: 0px"><BR>
534 </P>
535 <P class="Body" style="text-align: center; margin: 0px"></P>
536 <TABLE WIDTH=573 HEIGHT=113 BORDER=1 CELLPADDING=1 CELLSPACING=2>
537 <TR>
538 <TD WIDTH=112 HEIGHT=17>
539 <P class="Body" style="margin: 0px">int64 when</P>
540 </TD>
541 <TD WIDTH=318 HEIGHT=17>
542 <P class="Body" style="margin: 0px">event time in seconds since 1/1/70</P>
543 </TD>
544 </TR>
545 <TR>
546 <TD WIDTH=112 HEIGHT=17>
547 <P class="Body" style="margin: 0px">int32 rawcode</P>
548 </TD>
549 <TD WIDTH=318 HEIGHT=17>
550 <P class="Body" style="margin: 0px">code for the physical key pressed</P>
551 </TD>
552 </TR>
553 <TR>
554 <TD WIDTH=112 HEIGHT=17>
555 <P class="Body" style="margin: 0px">int32 modifiers</P>
556 </TD>
557 <TD WIDTH=318 HEIGHT=17>
558 <P class="Body" style="margin: 0px">flags signifying the states of the modifier keys</P>
559 </TD>
560 </TR>
561 <TR>
562 <TD WIDTH=112 HEIGHT=17>
563 <P class="Body" style="margin: 0px">int8 state_count</P>
564 </TD>
565 <TD WIDTH=318 HEIGHT=17>
566 <P class="Body" style="margin: 0px">number of bytes to follow containing the state of all keys</P>
567 </TD>
568 </TR>
569 <TR>
570 <TD WIDTH=112 HEIGHT=17>
571 <P class="Body" style="margin: 0px">int8 *states</P>
572 </TD>
573 <TD WIDTH=318 HEIGHT=17>
574 <P class="Body" style="margin: 0px">array of the state of all keys at the time of the event</P>
575 </TD>
576 </TR>
577 </TABLE>
578 <P class="Body" style="text-align: center; margin: 0px"><BR>
579 </P>
580 <P class="Body" style="margin: 0px"><BR>
581 1) Acquire the active application lock</P>
582 <P class="Body" style="margin: 0px">2) Create a PortLink instance, target the active ServerApp's sender port, set the opcode to B_UNMAPPED_KEY_DOWN, attach the buffer <span style="font-style: italic">en masse</span>, and send it to the BApplication.</P>
583 <P class="Body" style="margin: 0px">3) Release the active application lock</P>
584 <P class="Body" style="text-align: left; margin: 0px"><BR>
585 B_UNMAPPED_KEY_UP:</P>
586 <P class="Body" style="text-align: left; margin: 0px"><BR>
587 </P>
588 <P class="Body" style="margin: 0px">Sent when the user presses a key that has not been mapped to a character.</P>
589 <P class="Body" style="margin: 0px"><BR>
590 Attached Data:</P>
591 <P class="Body" style="margin: 0px"><BR>
592 </P>
593 <P class="Body" style="text-align: center; margin: 0px"></P>
594 <TABLE WIDTH=573 HEIGHT=113 BORDER=1 CELLPADDING=1 CELLSPACING=2>
595 <TR>
596 <TD WIDTH=112 HEIGHT=17>
597 <P class="Body" style="margin: 0px">int64 when</P>
598 </TD>
599 <TD WIDTH=318 HEIGHT=17>
600 <P class="Body" style="margin: 0px">event time in seconds since 1/1/70</P>
601 </TD>
602 </TR>
603 <TR>
604 <TD WIDTH=112 HEIGHT=17>
605 <P class="Body" style="margin: 0px">int32 rawcode</P>
606 </TD>
607 <TD WIDTH=318 HEIGHT=17>
608 <P class="Body" style="margin: 0px">code for the physical key pressed</P>
609 </TD>
610 </TR>
611 <TR>
612 <TD WIDTH=112 HEIGHT=17>
613 <P class="Body" style="margin: 0px">int32 modifiers</P>
614 </TD>
615 <TD WIDTH=318 HEIGHT=17>
616 <P class="Body" style="margin: 0px">flags signifying the states of the modifier keys</P>
617 </TD>
618 </TR>
619 <TR>
620 <TD WIDTH=112 HEIGHT=17>
621 <P class="Body" style="margin: 0px">int8 state_count</P>
622 </TD>
623 <TD WIDTH=318 HEIGHT=17>
624 <P class="Body" style="margin: 0px">number of bytes to follow containing the state of all keys</P>
625 </TD>
626 </TR>
627 <TR>
628 <TD WIDTH=112 HEIGHT=17>
629 <P class="Body" style="margin: 0px">int8 *states</P>
630 </TD>
631 <TD WIDTH=318 HEIGHT=17>
632 <P class="Body" style="margin: 0px">array of the state of all keys at the time of the event</P>
633 </TD>
634 </TR>
635 </TABLE>
636 <P class="Body" style="text-align: center; margin: 0px"><BR>
637 </P>
638 <P class="Body" style="margin: 0px"><BR>
639 1) Acquire the active application lock</P>
640 <P class="Body" style="margin: 0px">2) Create a PortLink instance, target the active ServerApp's sender port, set the opcode to B_UNMAPPED_KEY_UP, attach the buffer <span style="font-style: italic">en masse</span>, and send it to the BApplication.</P>
641 <P class="Body" style="margin: 0px">3) Release the active application lock</P>
642 <P class="Body" style="margin: 0px"><BR>
643 </P>
644 <P class="Body" style="text-align: left; margin: 0px">B_MODIFIERS_CHANGED:</P>
645 <P class="Body" style="text-align: left; margin: 0px"><BR>
646 </P>
647 <P class="Body" style="margin: 0px">Sent when the user presses or releases one of the modifier keys</P>
648 <P class="Body" style="margin: 0px"><BR>
649 Attached Data:</P>
650 <P class="Body" style="margin: 0px"><BR>
651 </P>
652 <P class="Body" style="text-align: center; margin: 0px"></P>
653 <TABLE WIDTH=573 HEIGHT=113 BORDER=1 CELLPADDING=1 CELLSPACING=2>
654 <TR>
655 <TD WIDTH=112 HEIGHT=17>
656 <P class="Body" style="margin: 0px">int64 when</P>
657 </TD>
658 <TD WIDTH=318 HEIGHT=17>
659 <P class="Body" style="margin: 0px">event time in seconds since 1/1/70</P>
660 </TD>
661 </TR>
662 <TR>
663 <TD WIDTH=112 HEIGHT=17>
664 <P class="Body" style="margin: 0px">int32 modifiers</P>
665 </TD>
666 <TD WIDTH=318 HEIGHT=17>
667 <P class="Body" style="margin: 0px">flags signifying the states of the modifier keys</P>
668 </TD>
669 </TR>
670 <TR>
671 <TD WIDTH=112 HEIGHT=17>
672 <P class="Body" style="margin: 0px">int32 old_modifiers</P>
673 </TD>
674 <TD WIDTH=318 HEIGHT=17>
675 <P class="Body" style="margin: 0px">former states of the modifier keys</P>
676 </TD>
677 </TR>
678 <TR>
679 <TD WIDTH=112 HEIGHT=17>
680 <P class="Body" style="margin: 0px">int8 state_count</P>
681 </TD>
682 <TD WIDTH=318 HEIGHT=17>
683 <P class="Body" style="margin: 0px">number of bytes to follow containing the state of all keys</P>
684 </TD>
685 </TR>
686 <TR>
687 <TD WIDTH=112 HEIGHT=17>
688 <P class="Body" style="margin: 0px">int8 *states</P>
689 </TD>
690 <TD WIDTH=318 HEIGHT=17>
691 <P class="Body" style="margin: 0px">array of the state of all keys at the time of the event</P>
692 </TD>
693 </TR>
694 </TABLE>
695 <P class="Body" style="text-align: center; margin: 0px"><BR>
696 </P>
697 <P class="Body" style="margin: 0px"><BR>
698 1) Acquire the active application lock</P>
699 <P class="Body" style="margin: 0px">2) Create a PortLink instance, target the active ServerApp's sender port, set the opcode to B_MODIFIERS_CHANGED, attach the buffer <span style="font-style: italic">en masse</span>, and send it to the BApplication.</P>
700 <P class="Body" style="margin: 0px">3) Release the active application lock</P>
701 <DIV class="layer" id="Layer 1">
702 </DIV>
703 </DIV>
704 </BODY>
705 </HTML>