Subversion Repositories Kolibri OS

Rev

Rev 9926 | 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: 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
  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.         mov     edx, [ebx+APPDATA.tid]
  71.         add     ebx, APP_OBJ_OFFSET
  72.         pushfd
  73.         cli
  74. ;--------------------------------------
  75. align 4
  76. set_event:                                         ;; INTERNAL use !!! don't use for Call
  77. ;info:
  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)
  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
  97. ;--------------------------------------
  98. align 4
  99. @@:
  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]
  106.         mov     edx, [event_uid]
  107.         mov     [eax+EVENT.id], edx
  108.         or      esi, esi
  109.         jz      RemoveEventTo
  110.         lea     edi, [eax+EVENT.code]
  111.         mov     ecx, (sizeof.EVENT -EVENT.code)/4
  112.         cld
  113.         rep movsd
  114. ;--------------------------------------
  115. align 4
  116. RemoveEventTo:                                     ;; INTERNAL use !!! don't use for Call
  117. ;param:
  118. ;   eax - pointer to event, WHICH we will insert
  119. ;   ebx - pointer to event, AFTER which we will insert
  120. ;scratched: ebx,ecx
  121.         mov     ecx, eax             ; ecx=eax=Self,      ebx=NewLeft
  122.         xchg    ecx, [ebx+EVENT.fd]  ; NewLeft.fd=Self,   ecx=NewRight
  123.         cmp     eax, ecx             ; stop, I think...
  124.         je      .break               ; - am I not a fool?
  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
  130. ;--------------------------------------
  131. align 4
  132. .break:
  133.         popfd
  134.         ret
  135. ;-----------------------------------------------------------------------------
  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
  143. ;--------------------------------------
  144. align 4
  145. .small: ; somehow ugly...
  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
  152.         jmp     edi ; normal return
  153. ;-----------------------------------------------------------------------------
  154. align 4
  155. raise_event:                                       ;; EXPORT use
  156. ;info:
  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
  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]
  171.         mov     ecx, (sizeof.EVENT -EVENT.code)/4
  172.         cld
  173.         rep movsd
  174. ;--------------------------------------
  175. align 4
  176. @@:
  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
  183. ;--------------------------------------
  184. align 4
  185. @@:
  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
  190. ;-----------------------------------------------------------------------------
  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
  204. ;-----------------------------------------------------------------------------
  205. align 4
  206. send_event:                                        ;; EXPORT use
  207. ;info:
  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
  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
  227. ;-----------------------------------------------------------------------------
  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
  237. ;--------------------------------------
  238. align 4
  239. @@:
  240.         pop     eax
  241.         xor     eax, eax
  242. ;--------------------------------------
  243. align 4
  244. .ret:
  245.         ret
  246. ;-----------------------------------------------------------------------------
  247. align 4
  248. Wait_events:
  249.         or      ebx, -1; infinite timeout
  250. ;--------------------------------------
  251. align 4
  252. Wait_events_ex:
  253. ;info:
  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.
  259. ;param:
  260. ;   edx - wait_test, client testing function (code address)
  261. ;   ecx - wait_param, additional parameter, possibly needed for [wait_test]
  262. ;   ebx - wait_timeout
  263. ;retval:
  264. ;   eax - call result [wait_test] (=0 => timeout)
  265. ;scratched: esi
  266.         mov     esi, [current_slot]
  267.         mov     [esi+APPDATA.wait_param], ecx
  268.         pushad
  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
  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
  280.         mov     eax, [timer_ticks]
  281.         mov     [esi+APPDATA.wait_begin], eax
  282.         mov     [esi + APPDATA.state], TSTATE_WAITING
  283.         call    change_task
  284.         mov     eax, [esi+APPDATA.wait_param]
  285. ;--------------------------------------
  286. align 4
  287. @@:
  288.         ret
  289. ;-----------------------------------------------------------------------------
  290. align 4
  291. wait_event:                                        ;; EXPORT use
  292. ;info:
  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)
  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
  308. ;-----------------------------------------------------------------------------
  309. align 4
  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
  322.         test    eax, eax
  323.         jnz     wait_finish
  324.         ret
  325. ;-----------------------------------------------------------------------------
  326. align 4
  327. get_event_ex:                                      ;; f68:14
  328. ;info:
  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)
  335. ;param:
  336. ;   edi - address in the application code to copy data from EVENT.code
  337. ;retval:
  338. ;   eax - EVENT itself (we will call it a handle)
  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]
  343.         mov     ecx, (sizeof.EVENT-EVENT.code)/4
  344.         cld
  345.         rep movsd
  346.         mov     byte[edi-(sizeof.EVENT-EVENT.code)+2], cl;clear priority field
  347. ;--------------------------------------
  348. align 4
  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
  360. ;-----------------------------------------------------------------------------
  361. align 4
  362. destroy_event:                                     ;; EXPORT use
  363. ;info:
  364. ;   Move EVENT to the FreeEvents list, clear the magic, destroy, pid, id fields
  365. ;param:
  366. ;   eax - event
  367. ;   ebx - uid (for Dummy testing)
  368. ;retval:
  369. ;   eax - address of EVENT object (=0 => fail)
  370. ;scratched: ebx,ecx
  371.         call    DummyTest ; not returned for fail !!!
  372. ;--------------------------------------
  373. align 4
  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
  384. ;-----------------------------------------------------------------------------
  385. align 4
  386. get_event_queue:
  387. ;info:
  388. ;   client testing function for get_event_ex
  389. ;warning:
  390. ;  -don't use [current_slot],[current_slot_idx] - it is not for your slot
  391. ;  -may be assumed, that interrupt are disabled
  392. ;  -it is not restriction for scratched registers
  393. ;param:
  394. ;   ebx - APPDATA address of testing slot
  395. ;retval:
  396. ;   eax - address of EVENT object (=0 => fail)
  397.         add     ebx, APP_EV_OFFSET
  398.         mov     eax, [ebx+APPOBJ.bk] ; we choose from the end, according to the FIFO principle
  399.         cmp     eax, ebx ; empty ???
  400.         je      get_event_alone.ret0
  401. ;--------------------------------------
  402. align 4
  403. .ret:
  404.         ret
  405. ;-----------------------------------------------------------------------------
  406. align 4
  407. get_event_alone:
  408. ;info:
  409. ;   client testing function for wait_event
  410. ;warning:
  411. ;  -don't use [current_slot],[current_slot_idx] - it is not for your slot
  412. ;  -may be assumed, that interrupt are disabled
  413. ;  -it is not restriction for scratched registers
  414. ;param:
  415. ;   ebx - APPDATA address of testing slot
  416. ;retval:
  417. ;   eax - address of EVENT object (=0 => fail)
  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
  422. ;--------------------------------------
  423. align 4
  424. .ret0:
  425.         xor     eax, eax; NO event!!!
  426. ;--------------------------------------
  427. align 4
  428. .ret:
  429.         ret
  430. ;-----------------------------------------------------------------------------
  431. align 4
  432. sys_sendwindowmsg:                                 ;; f72
  433.         dec     ebx
  434.         jnz     .ret ;subfunction==1 ?
  435.         pushfd
  436.         cli
  437.         sub     ecx, 2
  438.         je      .sendkey
  439.         dec     ecx
  440.         jnz     .retf
  441. ;--------------------------------------
  442. align 4
  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
  450. ;--------------------------------------
  451. align 4
  452. .sendkey:
  453.         movzx   eax, byte[KEY_COUNT]
  454.         cmp     al, 120
  455.         jae     .result ;overflow
  456.         inc     byte[KEY_COUNT]
  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
  462. ;--------------------------------------
  463. align 4
  464. .result:
  465.         setae   byte[esp + SYSCALL_STACK.eax + 4] ;we consider that initially was: dword[esp+32+4]==72
  466. ;--------------------------------------
  467. align 4
  468. .retf:
  469.         popfd
  470. ;--------------------------------------
  471. align 4
  472. .ret:
  473.         ret
  474. ;-----------------------------------------------------------------------------
  475. align 4
  476. sys_getevent:                                      ;; f11
  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
  480.         call    get_event_for_app
  481.         popfd
  482.         mov     [esp + SYSCALL_STACK.eax], eax
  483.         ret
  484. ;-----------------------------------------------------------------------------
  485. align 4
  486. sys_waitforevent:                                  ;; f10
  487.         or      ebx, -1; infinite timeout
  488. ;--------------------------------------
  489. align 4
  490. sys_wait_event_timeout:                            ;; f23
  491.         call    unprotect_from_terminate
  492.         mov     edx, get_event_for_app; wait_test
  493.         call    Wait_events_ex        ; ebx - timeout
  494.         mov     [esp + SYSCALL_STACK.eax], eax
  495.         call    protect_from_terminate
  496.         ret
  497. ;-----------------------------------------------------------------------------
  498. align 4
  499. get_event_for_app:                                 ;; used from f10,f11,f23
  500. ;info:
  501. ;   client testing function for applications (f10,f23)
  502. ;warning:
  503. ;  -don't use [current_slot],[current_slot_idx] - it is not for your slot
  504. ;  -may be assumed, that interrupt are disabled
  505. ;  -it is not restriction for scratched registers
  506. ;param:
  507. ;   ebx - APPDATA address of testing slot
  508. ;retval:
  509. ;   eax - event number (=0 => no events)
  510.         movzx   edi, bh               ; bh  is assumed as [current_slot_idx]
  511.         mov     ecx, [ebx+APPDATA.event_mask]
  512.         shl     edi, BSF sizeof.WDATA
  513.         add     edi, window_data
  514.         and     ecx, 0x7FFFFFFF
  515. ;--------------------------------------
  516. align 4
  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
  522.         cmp     eax, 10
  523.         jae     .loop          ; eax=[10..31], ignored (event 11...32)
  524.  
  525.         cmp     eax, 3
  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.  
  534.         ja      .FlagAutoReset ; eax=[6..9], retvals=eax+1 (event 7...10)
  535.  
  536.         cmp     eax, 1
  537.         jae     .BtKy          ; eax=[1,2],  retvals=eax+1 (event 2,3)
  538. ;--------------------------------------
  539. align 4
  540. .WndRedraw:                    ; eax=0, retval WndRedraw=1
  541.         cmp     [edi + WDATA.fl_redraw], al;al==0
  542.         jne     .result
  543.         jmp     .loop
  544. ;--------------------------------------
  545. align 4
  546. .no_events:
  547.         xor     eax, eax
  548.         ret
  549. ;--------------------------------------
  550. align 4
  551. .mouse_check:    ; Mouse 5+1=6
  552.         push    eax
  553.         mov     eax, [current_slot]
  554.         mov     eax, [eax + APPDATA.event_mask]
  555.         test    eax, EVM_MOUSE_FILTER ; bit 31: active/inactive filter f.40
  556.         jz      @f
  557.         pop     eax
  558.         jmp     .FlagAutoReset
  559. ;--------------------------------------
  560. align 4
  561. @@:
  562. ; If the window is captured and moved by the user, then no mouse events!!!
  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
  568. ;--------------------------------------
  569. align 4
  570. .FlagAutoReset: ; retvals: BgrRedraw=5, IPC=7, Stack=8, Debug=9
  571.         btr     [ebx+APPDATA.occurred_events], eax
  572.         jnc     .loop
  573. ;--------------------------------------
  574. align 4
  575. .result:      ; retval = eax+1
  576.         inc     eax
  577.         ret
  578. ;--------------------------------------
  579. align 4
  580. .BtKy:
  581.         movzx   edx, bh
  582.         movzx   edx, word[WIN_STACK+edx*2]
  583.         je      .Keys          ; eax=1, retval Keys=2
  584. ;--------------------------------------
  585. align 4
  586. .Buttons:                      ; eax=2, retval Buttons=3
  587.         cmp     byte[BTN_COUNT], 0
  588.         je      .loop          ; empty ???
  589.         cmp     edx, [thread_count]
  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
  596.         call    wakeup_osloop
  597.         dec     byte[BTN_COUNT]
  598.         jmp     .loop
  599. ;--------------------------------------
  600. align 4
  601. .Keys:    ; eax==1
  602.         cmp     edx, [thread_count]
  603.         jne     @f             ; not Top ???
  604.         cmp     [KEY_COUNT], al; al==1
  605.         jae     .result        ; not empty ???
  606. ;--------------------------------------
  607. align 4
  608. @@:
  609.         mov     edx, hotkey_buffer
  610. ;--------------------------------------
  611. align 4
  612. @@:
  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.
  620. ;-----------------------------------------------------------------------------
  621.