Rev 9926 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2288 | clevermous | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
8866 | rgimad | 3 | ;; Copyright (C) KolibriOS team 2004-2021. All rights reserved. ;; |
2288 | clevermous | 4 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
||
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
7 | |||
8 | $Revision: 9949 $ |
||
9 | |||
10 | WINDOW_MOVE_AND_RESIZE_FLAGS = \ |
||
11 | mouse.WINDOW_RESIZE_N_FLAG + \ |
||
12 | mouse.WINDOW_RESIZE_W_FLAG + \ |
||
13 | mouse.WINDOW_RESIZE_S_FLAG + \ |
||
14 | mouse.WINDOW_RESIZE_E_FLAG + \ |
||
15 | mouse.WINDOW_MOVE_FLAG |
||
16 | |||
17 | uglobal |
||
18 | align 4 |
||
19 | event_start dd ? |
||
20 | event_end dd ? |
||
21 | event_uid dd 0 |
||
22 | endg |
||
23 | EV_SPACE = 512 |
||
8053 | rgimad | 24 | FreeEvents = event_start-EVENT.fd ; "virtual" event, only following field used: |
25 | ; FreeEvents.fd=event_start and FreeEvents.bk=event_end |
||
2513 | mario79 | 26 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 27 | align 4 |
28 | init_events: ;; used from kernel.asm |
||
2384 | hidnplayr | 29 | stdcall kernel_alloc, EV_SPACE*sizeof.EVENT |
2288 | clevermous | 30 | or eax, eax |
31 | jz .fail |
||
8053 | rgimad | 32 | ; eax - current event, ebx - previous event below |
2288 | clevermous | 33 | mov ecx, EV_SPACE ; current - in allocated space |
8053 | rgimad | 34 | mov ebx, FreeEvents ; previous - list beginning |
35 | push ebx ; it will be the end later |
||
2513 | mario79 | 36 | ;-------------------------------------- |
37 | align 4 |
||
38 | @@: |
||
2288 | clevermous | 39 | mov [ebx+EVENT.fd], eax |
40 | mov [eax+EVENT.bk], ebx |
||
41 | mov ebx, eax ; previos <- current |
||
2384 | hidnplayr | 42 | add eax, sizeof.EVENT ; new current |
2288 | clevermous | 43 | loop @b |
8053 | rgimad | 44 | pop eax ; here it became the end |
2288 | clevermous | 45 | mov [ebx+EVENT.fd], eax |
46 | mov [eax+EVENT.bk], ebx |
||
2513 | mario79 | 47 | ;-------------------------------------- |
48 | align 4 |
||
2288 | clevermous | 49 | .fail: |
50 | ret |
||
2513 | mario79 | 51 | ;----------------------------------------------------------------------------- |
7136 | dunkaist | 52 | EVENT_WATCHED = 0x10000000 ; bit 28 |
53 | EVENT_SIGNALED = 0x20000000 ; bit 29 |
||
54 | MANUAL_RESET = 0x40000000 ; bit 30 |
||
55 | MANUAL_DESTROY = 0x80000000 ; bit 31 |
||
2513 | mario79 | 56 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 57 | align 4 |
58 | create_event: ;; EXPORT use |
||
59 | ;info: |
||
8053 | rgimad | 60 | ; Move EVENT from the FreeEvents list to the ObjList list of the current slot; |
61 | ; EVENT.state is set from ecx, EVENT.code indirectly from esi (if esi <> 0) |
||
2288 | clevermous | 62 | ;param: |
63 | ; esi - event data |
||
64 | ; ecx - flags |
||
65 | ;retval: |
||
66 | ; eax - event (=0 => fail) |
||
67 | ; edx - uid |
||
68 | ;scratched: ebx,ecx,esi,edi |
||
69 | mov ebx, [current_slot] |
||
9926 | Doczom | 70 | mov edx, [ebx+APPDATA.tid] |
2288 | clevermous | 71 | add ebx, APP_OBJ_OFFSET |
72 | pushfd |
||
73 | cli |
||
2513 | mario79 | 74 | ;-------------------------------------- |
75 | align 4 |
||
2288 | clevermous | 76 | set_event: ;; INTERNAL use !!! don't use for Call |
77 | ;info: |
||
8053 | rgimad | 78 | ; We take a new event from FreeEvents, fill its fields from ecx, edx, esi |
79 | ; and add it to the list, which specified in ebx. |
||
80 | ; Return event (to eax), and it's uid (to edx) |
||
2288 | clevermous | 81 | ;param: |
82 | ; ebx - start-chain "virtual" event for entry new event Right of him |
||
83 | ; ecx - flags (copied to EVENT.state) |
||
84 | ; edx - pid (copied to EVENT.pid) |
||
85 | ; esi - event data (copied to EVENT.code indirect, =0 => skip) |
||
86 | ;retval: |
||
87 | ; eax - event (=0 => fail) |
||
88 | ; edx - uid |
||
89 | ;scratched: ebx,ecx,esi,edi |
||
90 | mov eax, FreeEvents |
||
91 | cmp eax, [eax+EVENT.fd] |
||
92 | jne @f ; not empty ??? |
||
93 | pushad |
||
94 | call init_events |
||
95 | popad |
||
96 | jz RemoveEventTo.break ; POPF+RET |
||
2513 | mario79 | 97 | ;-------------------------------------- |
98 | align 4 |
||
99 | @@: |
||
2288 | clevermous | 100 | mov eax, [eax+EVENT.fd] |
101 | mov [eax+EVENT.magic], 'EVNT' |
||
102 | mov [eax+EVENT.destroy], destroy_event.internal |
||
103 | mov [eax+EVENT.state], ecx |
||
104 | mov [eax+EVENT.pid], edx |
||
105 | inc [event_uid] |
||
5788 | serge | 106 | mov edx, [event_uid] |
107 | mov [eax+EVENT.id], edx |
||
2288 | clevermous | 108 | or esi, esi |
109 | jz RemoveEventTo |
||
110 | lea edi, [eax+EVENT.code] |
||
2384 | hidnplayr | 111 | mov ecx, (sizeof.EVENT -EVENT.code)/4 |
2288 | clevermous | 112 | cld |
113 | rep movsd |
||
2513 | mario79 | 114 | ;-------------------------------------- |
115 | align 4 |
||
2288 | clevermous | 116 | RemoveEventTo: ;; INTERNAL use !!! don't use for Call |
117 | ;param: |
||
8053 | rgimad | 118 | ; eax - pointer to event, WHICH we will insert |
119 | ; ebx - pointer to event, AFTER which we will insert |
||
2288 | clevermous | 120 | ;scratched: ebx,ecx |
121 | mov ecx, eax ; ecx=eax=Self, ebx=NewLeft |
||
122 | xchg ecx, [ebx+EVENT.fd] ; NewLeft.fd=Self, ecx=NewRight |
||
8053 | rgimad | 123 | cmp eax, ecx ; stop, I think... |
124 | je .break ; - am I not a fool? |
||
2288 | clevermous | 125 | mov [ecx+EVENT.bk], eax ; NewRight.bk=Self |
126 | xchg ebx, [eax+EVENT.bk] ; Self.bk=NewLeft, ebx=OldLeft |
||
127 | xchg ecx, [eax+EVENT.fd] ; Self.fd=NewRight, ecx=OldRight |
||
128 | mov [ebx+EVENT.fd], ecx ; OldLeft.fd=OldRight |
||
129 | mov [ecx+EVENT.bk], ebx ; OldRight.bk=OldLeft |
||
2513 | mario79 | 130 | ;-------------------------------------- |
131 | align 4 |
||
2288 | clevermous | 132 | .break: |
133 | popfd |
||
134 | ret |
||
2513 | mario79 | 135 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 136 | align 4 |
137 | NotDummyTest: ;; INTERNAL use (not returned for fail !!!) |
||
138 | pop edi |
||
139 | call DummyTest ; not returned for fail !!! |
||
140 | mov ebx, eax |
||
141 | mov eax, [ebx+EVENT.pid] |
||
142 | push edi |
||
2513 | mario79 | 143 | ;-------------------------------------- |
144 | align 4 |
||
8053 | rgimad | 145 | .small: ; somehow ugly... |
2288 | clevermous | 146 | pop edi |
147 | pushfd |
||
148 | cli |
||
149 | call pid_to_slot ; saved all registers (eax - retval) |
||
150 | shl eax, 8 |
||
151 | jz RemoveEventTo.break ; POPF+RET |
||
8053 | rgimad | 152 | jmp edi ; normal return |
2513 | mario79 | 153 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 154 | align 4 |
155 | raise_event: ;; EXPORT use |
||
156 | ;info: |
||
8053 | rgimad | 157 | ; Setting up EVENT.code data |
158 | ; If is has flag EVENT_SIGNALED activated - nothing else |
||
159 | ; Otherwise: activate this flag, except when the EVENT_WATCHED flag is present in edx |
||
160 | ; In this case EVENT_SIGNALED will activated only if EVENT_WATCHED presents in the event itself |
||
2288 | clevermous | 161 | ;param: |
162 | ; eax - event |
||
163 | ; ebx - uid (for Dummy testing) |
||
164 | ; edx - flags |
||
165 | ; esi - event data (=0 => skip) |
||
166 | ;scratched: ebx,ecx,esi,edi |
||
167 | call NotDummyTest ; not returned for fail !!! |
||
168 | or esi, esi |
||
169 | jz @f |
||
170 | lea edi, [ebx+EVENT.code] |
||
2384 | hidnplayr | 171 | mov ecx, (sizeof.EVENT -EVENT.code)/4 |
2288 | clevermous | 172 | cld |
173 | rep movsd |
||
2513 | mario79 | 174 | ;-------------------------------------- |
175 | align 4 |
||
176 | @@: |
||
2288 | clevermous | 177 | test byte[ebx+EVENT.state+3], EVENT_SIGNALED shr 24 |
178 | jnz RemoveEventTo.break ; POPF+RET |
||
179 | bt edx, 28 ;EVENT_WATCHED |
||
180 | jnc @f |
||
181 | test byte[ebx+EVENT.state+3], EVENT_WATCHED shr 24 |
||
182 | jz RemoveEventTo.break ; POPF+RET |
||
2513 | mario79 | 183 | ;-------------------------------------- |
184 | align 4 |
||
185 | @@: |
||
2288 | clevermous | 186 | or byte[ebx+EVENT.state+3], EVENT_SIGNALED shr 24 |
187 | add eax, SLOT_BASE+APP_EV_OFFSET |
||
188 | xchg eax, ebx |
||
189 | jmp RemoveEventTo |
||
2513 | mario79 | 190 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 191 | align 4 |
192 | clear_event: ;; EXPORT use |
||
193 | ;info: |
||
194 | ; |
||
195 | ;param: |
||
196 | ; eax - event |
||
197 | ; ebx - uid (for Dummy testing) |
||
198 | ;scratched: ebx,ecx |
||
199 | call NotDummyTest ; not returned for fail !!! |
||
200 | add eax, SLOT_BASE+APP_OBJ_OFFSET |
||
201 | and byte[ebx+EVENT.state+3], not((EVENT_SIGNALED+EVENT_WATCHED)shr 24) |
||
202 | xchg eax, ebx |
||
203 | jmp RemoveEventTo |
||
2513 | mario79 | 204 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 205 | align 4 |
206 | send_event: ;; EXPORT use |
||
207 | ;info: |
||
8053 | rgimad | 208 | ; Creates a new EVENT (pulls from the FreeEvents list) in the EventList list |
209 | ; of target slot (eax=pid), with data from esi indirectly, and state=EVENT_SIGNALED |
||
2288 | clevermous | 210 | ;param: |
211 | ; eax - slots pid, to sending new event |
||
212 | ; esi - pointer to sending data (in code field of new event) |
||
213 | ;retval: |
||
214 | ; eax - event (=0 => fail) |
||
215 | ; edx - uid |
||
216 | ;warning: |
||
217 | ; may be used as CDECL with such prefix... |
||
218 | ; mov esi,[esp+8] |
||
219 | ; mov eax,[esp+4] |
||
220 | ; but not as STDCALL :( |
||
221 | ;scratched: ebx,ecx,esi,edi |
||
222 | mov edx, eax |
||
223 | call NotDummyTest.small ; not returned for fail !!! |
||
224 | lea ebx, [eax+SLOT_BASE+APP_EV_OFFSET] |
||
225 | mov ecx, EVENT_SIGNALED |
||
226 | jmp set_event |
||
2513 | mario79 | 227 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 228 | align 4 |
229 | DummyTest: ;; INTERNAL use (not returned for fail !!!) |
||
230 | ;param: |
||
231 | ; eax - event |
||
232 | ; ebx - uid (for Dummy testing) |
||
233 | cmp [eax+EVENT.magic], 'EVNT' |
||
234 | jne @f |
||
235 | cmp [eax+EVENT.id], ebx |
||
236 | je .ret |
||
2513 | mario79 | 237 | ;-------------------------------------- |
238 | align 4 |
||
239 | @@: |
||
2288 | clevermous | 240 | pop eax |
241 | xor eax, eax |
||
2513 | mario79 | 242 | ;-------------------------------------- |
243 | align 4 |
||
2288 | clevermous | 244 | .ret: |
245 | ret |
||
2513 | mario79 | 246 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 247 | align 4 |
248 | Wait_events: |
||
249 | or ebx, -1; infinite timeout |
||
2513 | mario79 | 250 | ;-------------------------------------- |
251 | align 4 |
||
2288 | clevermous | 252 | Wait_events_ex: |
253 | ;info: |
||
8053 | rgimad | 254 | ; Waiting for an "abstract" event by moving the slot to the 5th position. |
255 | ; Abstractness lies in the fact, that the fact of an event is determined by the APPDATA.wait_test function, |
||
256 | ; which is set by the client and can be actually anything. |
||
257 | ; This allows the shed to reliably determine the fact of the event, and not make "idle" switches, |
||
258 | ; intended for showdowns like "friend / foe" within the problem. |
||
2288 | clevermous | 259 | ;param: |
8053 | rgimad | 260 | ; edx - wait_test, client testing function (code address) |
261 | ; ecx - wait_param, additional parameter, possibly needed for [wait_test] |
||
2288 | clevermous | 262 | ; ebx - wait_timeout |
263 | ;retval: |
||
8053 | rgimad | 264 | ; eax - call result [wait_test] (=0 => timeout) |
2288 | clevermous | 265 | ;scratched: esi |
266 | mov esi, [current_slot] |
||
267 | mov [esi+APPDATA.wait_param], ecx |
||
268 | pushad |
||
8053 | rgimad | 269 | mov ebx, esi ;now this is a question, what where to put.......... |
270 | pushfd ; this is a consequence of the general concept: let the test function have |
||
271 | cli ; the right to hope to disable interrupts, as when called from shed |
||
2288 | clevermous | 272 | call edx |
273 | popfd |
||
274 | mov [esp+28], eax |
||
275 | popad |
||
276 | or eax, eax |
||
277 | jnz @f ;RET |
||
278 | mov [esi+APPDATA.wait_test], edx |
||
279 | mov [esi+APPDATA.wait_timeout], ebx |
||
5788 | serge | 280 | mov eax, [timer_ticks] |
281 | mov [esi+APPDATA.wait_begin], eax |
||
9709 | Doczom | 282 | mov [esi + APPDATA.state], TSTATE_WAITING |
2288 | clevermous | 283 | call change_task |
284 | mov eax, [esi+APPDATA.wait_param] |
||
2513 | mario79 | 285 | ;-------------------------------------- |
286 | align 4 |
||
287 | @@: |
||
2288 | clevermous | 288 | ret |
2513 | mario79 | 289 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 290 | align 4 |
291 | wait_event: ;; EXPORT use |
||
292 | ;info: |
||
8053 | rgimad | 293 | ; Waiting for the EVENT_SIGNALED flag in a very specific Event |
294 | ; (set, presumably, via raise_event) |
||
295 | ; When the MANUAL_RESET flag is active, nothing else |
||
296 | ; Otherwise: the flags EVENT_SIGNALED and EVENT_WATCHED for the received event are cleared, |
||
297 | ; and, if MANUAL_DESTROY is active, it moves to the ObjList list of the current slot, |
||
298 | ; and if not active, it is destroyed normally (destroy_event.internal) |
||
2288 | clevermous | 299 | ;param: |
300 | ; eax - event |
||
301 | ; ebx - uid (for Dummy testing) |
||
302 | ;scratched: ecx,edx,esi |
||
303 | call DummyTest |
||
304 | mov ecx, eax ; wait_param |
||
305 | mov edx, get_event_alone ; wait_test |
||
306 | call Wait_events ; timeout ignored |
||
307 | jmp wait_finish |
||
2513 | mario79 | 308 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 309 | align 4 |
3390 | Serge | 310 | wait_event_timeout: |
311 | ;param: |
||
312 | ; eax - event |
||
313 | ; ebx - uid (for Dummy testing) |
||
314 | ; ecx - timeout in timer ticks |
||
315 | ;retval: |
||
316 | ; eax - EVENT handle or 0 if timeout |
||
317 | call DummyTest |
||
318 | mov ebx, ecx |
||
319 | mov ecx, eax ; wait_param |
||
320 | mov edx, get_event_alone ; wait_test |
||
321 | call Wait_events_ex |
||
3396 | clevermous | 322 | test eax, eax |
323 | jnz wait_finish |
||
324 | ret |
||
3390 | Serge | 325 | ;----------------------------------------------------------------------------- |
326 | align 4 |
||
2288 | clevermous | 327 | get_event_ex: ;; f68:14 |
328 | ;info: |
||
8053 | rgimad | 329 | ; Waiting for any event in the EventList of the current slot |
330 | ; Code event data - copied to application memory (indirectly by edi) |
||
331 | ; When the MANUAL_RESET flag is active, nothing else |
||
332 | ; Otherwise: the flags EVENT_SIGNALED and EVENT_WATCHED for the received event are cleared, |
||
333 | ; and, if MANUAL_DESTROY is active, it moves to the ObjList list of the current slot, |
||
334 | ; and if not active, it is destroyed normally (destroy_event.internal) |
||
2288 | clevermous | 335 | ;param: |
8053 | rgimad | 336 | ; edi - address in the application code to copy data from EVENT.code |
2288 | clevermous | 337 | ;retval: |
8053 | rgimad | 338 | ; eax - EVENT itself (we will call it a handle) |
2288 | clevermous | 339 | ;scratched: ebx,ecx,edx,esi,edi |
340 | mov edx, get_event_queue ; wait_test |
||
341 | call Wait_events ; timeout ignored |
||
342 | lea esi, [eax+EVENT.code] |
||
2384 | hidnplayr | 343 | mov ecx, (sizeof.EVENT-EVENT.code)/4 |
2288 | clevermous | 344 | cld |
345 | rep movsd |
||
2384 | hidnplayr | 346 | mov byte[edi-(sizeof.EVENT-EVENT.code)+2], cl;clear priority field |
2513 | mario79 | 347 | ;-------------------------------------- |
348 | align 4 |
||
2288 | clevermous | 349 | wait_finish: |
350 | test byte[eax+EVENT.state+3], MANUAL_RESET shr 24 |
||
351 | jnz get_event_queue.ret ; RET |
||
352 | and byte[eax+EVENT.state+3], not((EVENT_SIGNALED+EVENT_WATCHED)shr 24) |
||
353 | test byte[eax+EVENT.state+3], MANUAL_DESTROY shr 24 |
||
354 | jz destroy_event.internal |
||
355 | mov ebx, [current_slot] |
||
356 | add ebx, APP_OBJ_OFFSET |
||
357 | pushfd |
||
358 | cli |
||
359 | jmp RemoveEventTo |
||
2513 | mario79 | 360 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 361 | align 4 |
362 | destroy_event: ;; EXPORT use |
||
363 | ;info: |
||
8053 | rgimad | 364 | ; Move EVENT to the FreeEvents list, clear the magic, destroy, pid, id fields |
2288 | clevermous | 365 | ;param: |
366 | ; eax - event |
||
367 | ; ebx - uid (for Dummy testing) |
||
368 | ;retval: |
||
8053 | rgimad | 369 | ; eax - address of EVENT object (=0 => fail) |
2288 | clevermous | 370 | ;scratched: ebx,ecx |
371 | call DummyTest ; not returned for fail !!! |
||
2513 | mario79 | 372 | ;-------------------------------------- |
373 | align 4 |
||
2288 | clevermous | 374 | .internal: |
375 | xor ecx, ecx ; clear common header |
||
376 | pushfd |
||
377 | cli |
||
378 | mov [eax+EVENT.magic], ecx |
||
379 | mov [eax+EVENT.destroy], ecx |
||
380 | mov [eax+EVENT.pid], ecx |
||
381 | mov [eax+EVENT.id], ecx |
||
382 | mov ebx, FreeEvents |
||
383 | jmp RemoveEventTo |
||
2513 | mario79 | 384 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 385 | align 4 |
386 | get_event_queue: |
||
387 | ;info: |
||
8053 | rgimad | 388 | ; client testing function for get_event_ex |
2288 | clevermous | 389 | ;warning: |
9949 | Doczom | 390 | ; -don't use [current_slot],[current_slot_idx] - it is not for your slot |
2288 | clevermous | 391 | ; -may be assumed, that interrupt are disabled |
392 | ; -it is not restriction for scratched registers |
||
393 | ;param: |
||
8053 | rgimad | 394 | ; ebx - APPDATA address of testing slot |
2288 | clevermous | 395 | ;retval: |
8053 | rgimad | 396 | ; eax - address of EVENT object (=0 => fail) |
2288 | clevermous | 397 | add ebx, APP_EV_OFFSET |
8053 | rgimad | 398 | mov eax, [ebx+APPOBJ.bk] ; we choose from the end, according to the FIFO principle |
2288 | clevermous | 399 | cmp eax, ebx ; empty ??? |
400 | je get_event_alone.ret0 |
||
2513 | mario79 | 401 | ;-------------------------------------- |
402 | align 4 |
||
2288 | clevermous | 403 | .ret: |
404 | ret |
||
2513 | mario79 | 405 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 406 | align 4 |
407 | get_event_alone: |
||
408 | ;info: |
||
8053 | rgimad | 409 | ; client testing function for wait_event |
2288 | clevermous | 410 | ;warning: |
9949 | Doczom | 411 | ; -don't use [current_slot],[current_slot_idx] - it is not for your slot |
2288 | clevermous | 412 | ; -may be assumed, that interrupt are disabled |
413 | ; -it is not restriction for scratched registers |
||
414 | ;param: |
||
8053 | rgimad | 415 | ; ebx - APPDATA address of testing slot |
2288 | clevermous | 416 | ;retval: |
8053 | rgimad | 417 | ; eax - address of EVENT object (=0 => fail) |
2288 | clevermous | 418 | mov eax, [ebx+APPDATA.wait_param] |
419 | test byte[eax+EVENT.state+3], EVENT_SIGNALED shr 24 |
||
420 | jnz .ret |
||
421 | or byte[eax+EVENT.state+3], EVENT_WATCHED shr 24 |
||
2513 | mario79 | 422 | ;-------------------------------------- |
423 | align 4 |
||
2288 | clevermous | 424 | .ret0: |
425 | xor eax, eax; NO event!!! |
||
2513 | mario79 | 426 | ;-------------------------------------- |
427 | align 4 |
||
2288 | clevermous | 428 | .ret: |
429 | ret |
||
2513 | mario79 | 430 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 431 | align 4 |
432 | sys_sendwindowmsg: ;; f72 |
||
433 | dec ebx |
||
434 | jnz .ret ;subfunction==1 ? |
||
2508 | mario79 | 435 | pushfd |
2288 | clevermous | 436 | cli |
437 | sub ecx, 2 |
||
438 | je .sendkey |
||
439 | dec ecx |
||
440 | jnz .retf |
||
2513 | mario79 | 441 | ;-------------------------------------- |
442 | align 4 |
||
2288 | clevermous | 443 | .sendbtn: |
444 | cmp byte[BTN_COUNT], 1 |
||
445 | jae .result ;overflow |
||
446 | inc byte[BTN_COUNT] |
||
447 | shl edx, 8 |
||
448 | mov [BTN_BUFF], edx |
||
449 | jmp .result |
||
2513 | mario79 | 450 | ;-------------------------------------- |
451 | align 4 |
||
2288 | clevermous | 452 | .sendkey: |
453 | movzx eax, byte[KEY_COUNT] |
||
454 | cmp al, 120 |
||
455 | jae .result ;overflow |
||
456 | inc byte[KEY_COUNT] |
||
4588 | mario79 | 457 | mov [KEY_BUFF+eax], dl |
458 | ; store empty scancode |
||
459 | add eax, 120+2 |
||
460 | mov [KEY_BUFF+eax], byte 0 |
||
461 | sub eax, 120+2 |
||
2513 | mario79 | 462 | ;-------------------------------------- |
463 | align 4 |
||
2288 | clevermous | 464 | .result: |
9926 | Doczom | 465 | setae byte[esp + SYSCALL_STACK.eax + 4] ;we consider that initially was: dword[esp+32+4]==72 |
2513 | mario79 | 466 | ;-------------------------------------- |
467 | align 4 |
||
2508 | mario79 | 468 | .retf: |
469 | popfd |
||
2513 | mario79 | 470 | ;-------------------------------------- |
471 | align 4 |
||
2288 | clevermous | 472 | .ret: |
473 | ret |
||
2513 | mario79 | 474 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 475 | align 4 |
476 | sys_getevent: ;; f11 |
||
8053 | rgimad | 477 | mov ebx, [current_slot] ;now this is a question, what where to put...... |
478 | pushfd ; this is a consequence of the general concept: let the test function have |
||
479 | cli ; the right to hope to disable interrupts, as when called from shed |
||
2288 | clevermous | 480 | call get_event_for_app |
481 | popfd |
||
9910 | Doczom | 482 | mov [esp + SYSCALL_STACK.eax], eax |
2288 | clevermous | 483 | ret |
2513 | mario79 | 484 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 485 | align 4 |
486 | sys_waitforevent: ;; f10 |
||
487 | or ebx, -1; infinite timeout |
||
2513 | mario79 | 488 | ;-------------------------------------- |
489 | align 4 |
||
2288 | clevermous | 490 | sys_wait_event_timeout: ;; f23 |
3303 | clevermous | 491 | call unprotect_from_terminate |
2288 | clevermous | 492 | mov edx, get_event_for_app; wait_test |
493 | call Wait_events_ex ; ebx - timeout |
||
9910 | Doczom | 494 | mov [esp + SYSCALL_STACK.eax], eax |
3303 | clevermous | 495 | call protect_from_terminate |
2288 | clevermous | 496 | ret |
2513 | mario79 | 497 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 498 | align 4 |
499 | get_event_for_app: ;; used from f10,f11,f23 |
||
500 | ;info: |
||
8053 | rgimad | 501 | ; client testing function for applications (f10,f23) |
2288 | clevermous | 502 | ;warning: |
9949 | Doczom | 503 | ; -don't use [current_slot],[current_slot_idx] - it is not for your slot |
2288 | clevermous | 504 | ; -may be assumed, that interrupt are disabled |
505 | ; -it is not restriction for scratched registers |
||
506 | ;param: |
||
8053 | rgimad | 507 | ; ebx - APPDATA address of testing slot |
2288 | clevermous | 508 | ;retval: |
8053 | rgimad | 509 | ; eax - event number (=0 => no events) |
8869 | rgimad | 510 | movzx edi, bh ; bh is assumed as [current_slot_idx] |
9614 | Doczom | 511 | mov ecx, [ebx+APPDATA.event_mask] |
9926 | Doczom | 512 | shl edi, BSF sizeof.WDATA |
9709 | Doczom | 513 | add edi, window_data |
2411 | Serge | 514 | and ecx, 0x7FFFFFFF |
2513 | mario79 | 515 | ;-------------------------------------- |
516 | align 4 |
||
8053 | rgimad | 517 | .loop: ; until we run out all the bits of the mask |
518 | bsr eax, ecx ; find a non-zero bit of the mask (31 -> 0) |
||
519 | jz .no_events ; ran out all the bits of the mask but found nothing ??? |
||
520 | btr ecx, eax ; clear the current checking bit of the mask |
||
521 | ; go to the handler of this (eax) bit |
||
3545 | hidnplayr | 522 | cmp eax, 10 |
3565 | hidnplayr | 523 | jae .loop ; eax=[10..31], ignored (event 11...32) |
2534 | mario79 | 524 | |
2288 | clevermous | 525 | cmp eax, 3 |
2534 | mario79 | 526 | je .loop ; eax=3, ignored (event 4) |
527 | |||
528 | cmp eax, 4 |
||
529 | je .FlagAutoReset ; eax=4, retvals=eax+1 (event 5) |
||
530 | |||
531 | cmp eax, 5 |
||
532 | je .mouse_check ; eax=5, retvals=eax+1 (event 6) |
||
533 | |||
3545 | hidnplayr | 534 | ja .FlagAutoReset ; eax=[6..9], retvals=eax+1 (event 7...10) |
2534 | mario79 | 535 | |
2288 | clevermous | 536 | cmp eax, 1 |
2534 | mario79 | 537 | jae .BtKy ; eax=[1,2], retvals=eax+1 (event 2,3) |
2513 | mario79 | 538 | ;-------------------------------------- |
539 | align 4 |
||
2288 | clevermous | 540 | .WndRedraw: ; eax=0, retval WndRedraw=1 |
9709 | Doczom | 541 | cmp [edi + WDATA.fl_redraw], al;al==0 |
2288 | clevermous | 542 | jne .result |
543 | jmp .loop |
||
2513 | mario79 | 544 | ;-------------------------------------- |
545 | align 4 |
||
546 | .no_events: |
||
2288 | clevermous | 547 | xor eax, eax |
548 | ret |
||
2513 | mario79 | 549 | ;-------------------------------------- |
550 | align 4 |
||
2534 | mario79 | 551 | .mouse_check: ; Mouse 5+1=6 |
2424 | mario79 | 552 | push eax |
9614 | Doczom | 553 | mov eax, [current_slot] |
554 | mov eax, [eax + APPDATA.event_mask] |
||
9926 | Doczom | 555 | test eax, EVM_MOUSE_FILTER ; bit 31: active/inactive filter f.40 |
2426 | mario79 | 556 | jz @f |
557 | pop eax |
||
2534 | mario79 | 558 | jmp .FlagAutoReset |
2513 | mario79 | 559 | ;-------------------------------------- |
560 | align 4 |
||
2426 | mario79 | 561 | @@: |
2288 | clevermous | 562 | ; If the window is captured and moved by the user, then no mouse events!!! |
2424 | mario79 | 563 | mov al, [mouse.active_sys_window.action] |
564 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
||
565 | test al, al |
||
566 | pop eax |
||
567 | jnz .loop |
||
2513 | mario79 | 568 | ;-------------------------------------- |
569 | align 4 |
||
2534 | mario79 | 570 | .FlagAutoReset: ; retvals: BgrRedraw=5, IPC=7, Stack=8, Debug=9 |
8867 | rgimad | 571 | btr [ebx+APPDATA.occurred_events], eax |
2288 | clevermous | 572 | jnc .loop |
2513 | mario79 | 573 | ;-------------------------------------- |
574 | align 4 |
||
575 | .result: ; retval = eax+1 |
||
2288 | clevermous | 576 | inc eax |
577 | ret |
||
2513 | mario79 | 578 | ;-------------------------------------- |
579 | align 4 |
||
580 | .BtKy: |
||
2288 | clevermous | 581 | movzx edx, bh |
582 | movzx edx, word[WIN_STACK+edx*2] |
||
583 | je .Keys ; eax=1, retval Keys=2 |
||
2513 | mario79 | 584 | ;-------------------------------------- |
585 | align 4 |
||
2288 | clevermous | 586 | .Buttons: ; eax=2, retval Buttons=3 |
587 | cmp byte[BTN_COUNT], 0 |
||
588 | je .loop ; empty ??? |
||
8866 | rgimad | 589 | cmp edx, [thread_count] |
2288 | clevermous | 590 | jne .loop ; not Top ??? |
591 | mov edx, [BTN_BUFF] |
||
592 | shr edx, 8 |
||
593 | cmp edx, 0xFFFF ;-ID for Minimize-Button of Form |
||
594 | jne .result |
||
595 | mov [window_minimize], 1 |
||
3534 | clevermous | 596 | call wakeup_osloop |
2288 | clevermous | 597 | dec byte[BTN_COUNT] |
598 | jmp .loop |
||
2513 | mario79 | 599 | ;-------------------------------------- |
600 | align 4 |
||
2288 | clevermous | 601 | .Keys: ; eax==1 |
8866 | rgimad | 602 | cmp edx, [thread_count] |
2288 | clevermous | 603 | jne @f ; not Top ??? |
604 | cmp [KEY_COUNT], al; al==1 |
||
605 | jae .result ; not empty ??? |
||
2513 | mario79 | 606 | ;-------------------------------------- |
607 | align 4 |
||
608 | @@: |
||
2288 | clevermous | 609 | mov edx, hotkey_buffer |
2513 | mario79 | 610 | ;-------------------------------------- |
611 | align 4 |
||
612 | @@: |
||
2288 | clevermous | 613 | cmp [edx], bh ; bh - slot for testing |
614 | je .result |
||
615 | add edx, 8 |
||
616 | cmp edx, hotkey_buffer+120*8 |
||
617 | jb @b |
||
618 | jmp .loop |
||
619 | ;end. |
||
3390 | Serge | 620 | ;----------------------------------------------------------------------------->-> |