Subversion Repositories Kolibri OS

Rev

Rev 9613 | Rev 9692 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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