dd88d5bff6
git-svn-id: svn://kolibrios.org@2540 a494cfbc-eb01-0410-851d-a64ba20cac60
596 lines
21 KiB
PHP
596 lines
21 KiB
PHP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; ;;
|
|
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
|
|
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
$Revision $
|
|
|
|
WINDOW_MOVE_AND_RESIZE_FLAGS = \
|
|
mouse.WINDOW_RESIZE_N_FLAG + \
|
|
mouse.WINDOW_RESIZE_W_FLAG + \
|
|
mouse.WINDOW_RESIZE_S_FLAG + \
|
|
mouse.WINDOW_RESIZE_E_FLAG + \
|
|
mouse.WINDOW_MOVE_FLAG
|
|
|
|
uglobal
|
|
align 4
|
|
event_start dd ?
|
|
event_end dd ?
|
|
event_uid dd 0
|
|
endg
|
|
EV_SPACE = 512
|
|
FreeEvents = event_start-EVENT.fd ; "âèðòóàëüíûé" event, èñïîëüçóþòñÿ òîëüêî ïîëÿ:
|
|
; FreeEvents.fd=event_start è FreeEvents.bk=event_end
|
|
;-----------------------------------------------------------------------------
|
|
align 4
|
|
init_events: ;; used from kernel.asm
|
|
stdcall kernel_alloc, EV_SPACE*sizeof.EVENT
|
|
or eax, eax
|
|
jz .fail
|
|
; eax - current event, ebx - previos event below
|
|
mov ecx, EV_SPACE ; current - in allocated space
|
|
mov ebx, FreeEvents ; previos - íà÷àëî ñïèñêà
|
|
push ebx ; îíî æå è êîíåö ïîòîì áóäåò
|
|
;--------------------------------------
|
|
align 4
|
|
@@:
|
|
mov [ebx+EVENT.fd], eax
|
|
mov [eax+EVENT.bk], ebx
|
|
mov ebx, eax ; previos <- current
|
|
add eax, sizeof.EVENT ; new current
|
|
loop @b
|
|
pop eax ; âîò îíî êîíöîì è ñòàëî
|
|
mov [ebx+EVENT.fd], eax
|
|
mov [eax+EVENT.bk], ebx
|
|
;--------------------------------------
|
|
align 4
|
|
.fail:
|
|
ret
|
|
;-----------------------------------------------------------------------------
|
|
EVENT_WATCHED equ 0x10000000 ;áèò 28
|
|
EVENT_SIGNALED equ 0x20000000 ;áèò 29
|
|
MANUAL_RESET equ 0x40000000 ;áèò 30
|
|
MANUAL_DESTROY equ 0x80000000 ;áèò 31
|
|
;-----------------------------------------------------------------------------
|
|
align 4
|
|
create_event: ;; EXPORT use
|
|
;info:
|
|
; Ïåðåíîñèì EVENT èç ñïèñêà FreeEvents â ñïèñîê ObjList òåêóùåãî ñëîòà
|
|
; EVENT.state óñòàíàâëèâàåì èç ecx, EVENT.code êîñâåííî èç esi (åñëè esi<>0)
|
|
;param:
|
|
; esi - event data
|
|
; ecx - flags
|
|
;retval:
|
|
; eax - event (=0 => fail)
|
|
; edx - uid
|
|
;scratched: ebx,ecx,esi,edi
|
|
mov ebx, [current_slot]
|
|
add ebx, APP_OBJ_OFFSET
|
|
mov edx, [TASK_BASE]
|
|
mov edx, [edx+TASKDATA.pid]
|
|
pushfd
|
|
cli
|
|
;--------------------------------------
|
|
align 4
|
|
set_event: ;; INTERNAL use !!! don't use for Call
|
|
;info:
|
|
; Áåðåì íîâûé event èç FreeEvents, çàïîëíÿåì åãî ïîëÿ, êàê óêàçàíî â ecx,edx,esi
|
|
; è óñòàíàâëèâàåì â ñïèñîê, óêàçàííûé â ebx.
|
|
; Âîçâðàùàåì ñàì event (â eax), è åãî uid (â edx)
|
|
;param:
|
|
; ebx - start-chain "virtual" event for entry new event Right of him
|
|
; ecx - flags (copied to EVENT.state)
|
|
; edx - pid (copied to EVENT.pid)
|
|
; esi - event data (copied to EVENT.code indirect, =0 => skip)
|
|
;retval:
|
|
; eax - event (=0 => fail)
|
|
; edx - uid
|
|
;scratched: ebx,ecx,esi,edi
|
|
mov eax, FreeEvents
|
|
cmp eax, [eax+EVENT.fd]
|
|
jne @f ; not empty ???
|
|
pushad
|
|
call init_events
|
|
popad
|
|
jz RemoveEventTo.break ; POPF+RET
|
|
;--------------------------------------
|
|
align 4
|
|
@@:
|
|
mov eax, [eax+EVENT.fd]
|
|
mov [eax+EVENT.magic], 'EVNT'
|
|
mov [eax+EVENT.destroy], destroy_event.internal
|
|
mov [eax+EVENT.state], ecx
|
|
mov [eax+EVENT.pid], edx
|
|
inc [event_uid]
|
|
Mov [eax+EVENT.id],edx,[event_uid]
|
|
or esi, esi
|
|
jz RemoveEventTo
|
|
lea edi, [eax+EVENT.code]
|
|
mov ecx, (sizeof.EVENT -EVENT.code)/4
|
|
cld
|
|
rep movsd
|
|
;--------------------------------------
|
|
align 4
|
|
RemoveEventTo: ;; INTERNAL use !!! don't use for Call
|
|
;param:
|
|
; eax - óêàçàòåëü íà event, ÊÎÒÎÐÛÉ âñòàâëÿåì
|
|
; ebx - óêàçàòåëü íà event, ÏÎÑËÅ êîòîðîãî âñòàâëÿåì
|
|
;scratched: ebx,ecx
|
|
mov ecx, eax ; ecx=eax=Self, ebx=NewLeft
|
|
xchg ecx, [ebx+EVENT.fd] ; NewLeft.fd=Self, ecx=NewRight
|
|
cmp eax, ecx ; ñòîï, ñåáå äóìàþ...
|
|
je .break ; - à íå äóðàê ëè ÿ?
|
|
mov [ecx+EVENT.bk], eax ; NewRight.bk=Self
|
|
xchg ebx, [eax+EVENT.bk] ; Self.bk=NewLeft, ebx=OldLeft
|
|
xchg ecx, [eax+EVENT.fd] ; Self.fd=NewRight, ecx=OldRight
|
|
mov [ebx+EVENT.fd], ecx ; OldLeft.fd=OldRight
|
|
mov [ecx+EVENT.bk], ebx ; OldRight.bk=OldLeft
|
|
;--------------------------------------
|
|
align 4
|
|
.break:
|
|
popfd
|
|
ret
|
|
;-----------------------------------------------------------------------------
|
|
align 4
|
|
NotDummyTest: ;; INTERNAL use (not returned for fail !!!)
|
|
pop edi
|
|
call DummyTest ; not returned for fail !!!
|
|
mov ebx, eax
|
|
mov eax, [ebx+EVENT.pid]
|
|
push edi
|
|
;--------------------------------------
|
|
align 4
|
|
.small: ; êðèâî êàê-òî...
|
|
pop edi
|
|
pushfd
|
|
cli
|
|
call pid_to_slot ; saved all registers (eax - retval)
|
|
shl eax, 8
|
|
jz RemoveEventTo.break ; POPF+RET
|
|
jmp edi ; øòàòíûé âîçâðàò
|
|
;-----------------------------------------------------------------------------
|
|
align 4
|
|
raise_event: ;; EXPORT use
|
|
;info:
|
|
; Óñòàíàâëèâàåì äàííûå EVENT.code
|
|
; Åñëè òàì ôëàã EVENT_SIGNALED óæå àêòèâåí - áîëüøå íè÷åãî
|
|
; Èíà÷å: ýòîò ôëàã âçâîäèòñÿ, çà èñêëþ÷åíèåì ñëó÷àÿ íàëè÷èÿ ôëàãà EVENT_WATCHED â edx
|
|
;  ýòîì ñëó÷àå EVENT_SIGNALED âçâîäèòñÿ ëèøü ïðè íàëè÷èå EVENT_WATCHED â ñàìîì ñîáûòèè
|
|
;param:
|
|
; eax - event
|
|
; ebx - uid (for Dummy testing)
|
|
; edx - flags
|
|
; esi - event data (=0 => skip)
|
|
;scratched: ebx,ecx,esi,edi
|
|
call NotDummyTest ; not returned for fail !!!
|
|
or esi, esi
|
|
jz @f
|
|
lea edi, [ebx+EVENT.code]
|
|
mov ecx, (sizeof.EVENT -EVENT.code)/4
|
|
cld
|
|
rep movsd
|
|
;--------------------------------------
|
|
align 4
|
|
@@:
|
|
test byte[ebx+EVENT.state+3], EVENT_SIGNALED shr 24
|
|
jnz RemoveEventTo.break ; POPF+RET
|
|
bt edx, 28 ;EVENT_WATCHED
|
|
jnc @f
|
|
test byte[ebx+EVENT.state+3], EVENT_WATCHED shr 24
|
|
jz RemoveEventTo.break ; POPF+RET
|
|
;--------------------------------------
|
|
align 4
|
|
@@:
|
|
or byte[ebx+EVENT.state+3], EVENT_SIGNALED shr 24
|
|
add eax, SLOT_BASE+APP_EV_OFFSET
|
|
xchg eax, ebx
|
|
jmp RemoveEventTo
|
|
;-----------------------------------------------------------------------------
|
|
align 4
|
|
clear_event: ;; EXPORT use
|
|
;info:
|
|
;
|
|
;param:
|
|
; eax - event
|
|
; ebx - uid (for Dummy testing)
|
|
;scratched: ebx,ecx
|
|
call NotDummyTest ; not returned for fail !!!
|
|
add eax, SLOT_BASE+APP_OBJ_OFFSET
|
|
and byte[ebx+EVENT.state+3], not((EVENT_SIGNALED+EVENT_WATCHED)shr 24)
|
|
xchg eax, ebx
|
|
jmp RemoveEventTo
|
|
;-----------------------------------------------------------------------------
|
|
align 4
|
|
send_event: ;; EXPORT use
|
|
;info:
|
|
; Ñîçäàåò íîâûé EVENT (âûòàñêèâàåò èç ñïèñêà FreeEvents) â ñïèñêå EventList
|
|
; öåëåâîãî ñëîòà (eax=pid), ñ äàííûìè èç esi êîñâåííî, è state=EVENT_SIGNALED
|
|
;param:
|
|
; eax - slots pid, to sending new event
|
|
; esi - pointer to sending data (in code field of new event)
|
|
;retval:
|
|
; eax - event (=0 => fail)
|
|
; edx - uid
|
|
;warning:
|
|
; may be used as CDECL with such prefix...
|
|
; mov esi,[esp+8]
|
|
; mov eax,[esp+4]
|
|
; but not as STDCALL :(
|
|
;scratched: ebx,ecx,esi,edi
|
|
mov edx, eax
|
|
call NotDummyTest.small ; not returned for fail !!!
|
|
lea ebx, [eax+SLOT_BASE+APP_EV_OFFSET]
|
|
mov ecx, EVENT_SIGNALED
|
|
jmp set_event
|
|
;-----------------------------------------------------------------------------
|
|
align 4
|
|
DummyTest: ;; INTERNAL use (not returned for fail !!!)
|
|
;param:
|
|
; eax - event
|
|
; ebx - uid (for Dummy testing)
|
|
cmp [eax+EVENT.magic], 'EVNT'
|
|
jne @f
|
|
cmp [eax+EVENT.id], ebx
|
|
je .ret
|
|
;--------------------------------------
|
|
align 4
|
|
@@:
|
|
pop eax
|
|
xor eax, eax
|
|
;--------------------------------------
|
|
align 4
|
|
.ret:
|
|
ret
|
|
;-----------------------------------------------------------------------------
|
|
align 4
|
|
Wait_events:
|
|
or ebx, -1; infinite timeout
|
|
;--------------------------------------
|
|
align 4
|
|
Wait_events_ex:
|
|
;info:
|
|
; Îæèäàíèå "àáñòðàêòíîãî" ñîáûòèÿ ÷åðåç ïåðåâîä ñëîòà â 5-þ ïîçèöèþ.
|
|
; Àáñòðàêòíîñòü çàêëþ÷åíà â òîì, ÷òî ôàêò ñîáûòèÿ îïðåäåëÿåòñÿ ôóíêöèåé APPDATA.wait_test,
|
|
; êîòîðàÿ çàäàåòñÿ êëèåíòîì è ìîæåò áûòü ôàêòè÷åñêè ëþáîé.
|
|
; Ýòî ïîçâîëÿåò shed-ó íàäåæíî îïðåäåëèòü ôàêò ñîáûòèÿ, è íå ñîâåðøàòü "õîëîñòûõ" ïåðåêëþ÷åíèé,
|
|
; ïðåäíàçíà÷åííûõ äëÿ ðàçáîðîê òèïà "ñâîé/÷óæîé" âíóòðè çàäà÷è.
|
|
;param:
|
|
; edx - wait_test, êëèåíòñêàÿ ô-ÿ òåñòèðîâàíèÿ (àäðåñ êîäà)
|
|
; ecx - wait_param, äîïîëíèòåëüíûé ïàðàìåòð, âîçìîæíî íåîáõîäèìûé äëÿ [wait_test]
|
|
; ebx - wait_timeout
|
|
;retval:
|
|
; eax - ðåçóëüòàò âûçîâà [wait_test] (=0 => timeout)
|
|
;scratched: esi
|
|
mov esi, [current_slot]
|
|
mov [esi+APPDATA.wait_param], ecx
|
|
pushad
|
|
mov ebx, esi;ïîêà ýòî âîïðîñ, ÷åãî êóäû ñóâàòü..........
|
|
pushfd ; ýòî ñëåäñòâèå îáùåé êîíöåïöèè: ïóñòü ô-ÿ òåñòèðîâàíèÿ èìååò
|
|
cli ; ïðàâî ðàññ÷èòûâàòü íà çàêðûòûå ïðåðûâàíèÿ, êàê ïðè âûçîâå èç shed
|
|
call edx
|
|
popfd
|
|
mov [esp+28], eax
|
|
popad
|
|
or eax, eax
|
|
jnz @f ;RET
|
|
mov [esi+APPDATA.wait_test], edx
|
|
mov [esi+APPDATA.wait_timeout], ebx
|
|
Mov [esi+APPDATA.wait_begin],eax,[timer_ticks]
|
|
mov eax, [TASK_BASE]
|
|
mov [eax+TASKDATA.state], 5
|
|
call change_task
|
|
mov eax, [esi+APPDATA.wait_param]
|
|
;--------------------------------------
|
|
align 4
|
|
@@:
|
|
ret
|
|
;-----------------------------------------------------------------------------
|
|
align 4
|
|
wait_event: ;; EXPORT use
|
|
;info:
|
|
; Îæèäàíèå ôëàãà EVENT_SIGNALED â ñîâåðøåííî êîíêðåòíîì Event
|
|
; (óñòàíàâëèâàåìîãî, íàäî ïîëàãàòü, ÷åðåç raise_event)
|
|
; Ïðè àêòèâíîì ôëàãå MANUAL_RESET - áîëüøå íè÷åãî
|
|
; Èíà÷å: ôëàãè EVENT_SIGNALED è EVENT_WATCHED ó ïîëó÷åííîãî ñîáûòèÿ ñáðàñûâàþòñÿ,
|
|
; è, ïðè àêòèâíîì MANUAL_DESTROY - ïåðåìåùàåòñÿ â ñïèñîê ObjList òåêóùåãî ñëîòà,
|
|
; à ïðè íå àêòèâíîì - óíè÷òîæàåòñÿ øòàòíî (destroy_event.internal)
|
|
;param:
|
|
; eax - event
|
|
; ebx - uid (for Dummy testing)
|
|
;scratched: ecx,edx,esi
|
|
call DummyTest
|
|
mov ecx, eax ; wait_param
|
|
mov edx, get_event_alone ; wait_test
|
|
call Wait_events ; timeout ignored
|
|
jmp wait_finish
|
|
;-----------------------------------------------------------------------------
|
|
align 4
|
|
get_event_ex: ;; f68:14
|
|
;info:
|
|
; Îæèäàíèå ëþáîãî ñîáûòèÿ â î÷åðåäè EventList òåêóùåãî ñëîòà
|
|
; Äàííûå ñîáûòèÿ code - êîïèðóþòñÿ â ïàìÿòü ïðèëîæåíèÿ (êîñâåííî ïî edi)
|
|
; Ïðè àêòèâíîì ôëàãå MANUAL_RESET - áîëüøå íè÷åãî
|
|
; Èíà÷å: ôëàãè EVENT_SIGNALED è EVENT_WATCHED ó ïîëó÷åííîãî ñîáûòèÿ ñáðàñûâàþòñÿ,
|
|
; è, ïðè àêòèâíîì MANUAL_DESTROY - ïåðåìåùàåòñÿ â ñïèñîê ObjList òåêóùåãî ñëîòà,
|
|
; à ïðè íå àêòèâíîì - óíè÷òîæàåòñÿ øòàòíî (destroy_event.internal)
|
|
;param:
|
|
; edi - àäðåñ â êîäå ïðèëîæåíèÿ äëÿ êîïèðîâàíèÿ äàííûõ èç EVENT.code
|
|
;retval:
|
|
; eax - ñîáñòâåííî EVENT (áóäåì íàçûâàòü ýòî åãî õýíäëîì)
|
|
;scratched: ebx,ecx,edx,esi,edi
|
|
mov edx, get_event_queue ; wait_test
|
|
call Wait_events ; timeout ignored
|
|
lea esi, [eax+EVENT.code]
|
|
mov ecx, (sizeof.EVENT-EVENT.code)/4
|
|
cld
|
|
rep movsd
|
|
mov byte[edi-(sizeof.EVENT-EVENT.code)+2], cl;clear priority field
|
|
;--------------------------------------
|
|
align 4
|
|
wait_finish:
|
|
test byte[eax+EVENT.state+3], MANUAL_RESET shr 24
|
|
jnz get_event_queue.ret ; RET
|
|
and byte[eax+EVENT.state+3], not((EVENT_SIGNALED+EVENT_WATCHED)shr 24)
|
|
test byte[eax+EVENT.state+3], MANUAL_DESTROY shr 24
|
|
jz destroy_event.internal
|
|
mov ebx, [current_slot]
|
|
add ebx, APP_OBJ_OFFSET
|
|
pushfd
|
|
cli
|
|
jmp RemoveEventTo
|
|
;-----------------------------------------------------------------------------
|
|
align 4
|
|
destroy_event: ;; EXPORT use
|
|
;info:
|
|
; Ïåðåíîñèì EVENT â ñïèñîê FreeEvents, ÷èñòèì ïîëÿ magic,destroy,pid,id
|
|
;param:
|
|
; eax - event
|
|
; ebx - uid (for Dummy testing)
|
|
;retval:
|
|
; eax - àäðåñ îáúåêòà EVENT (=0 => fail)
|
|
;scratched: ebx,ecx
|
|
call DummyTest ; not returned for fail !!!
|
|
;--------------------------------------
|
|
align 4
|
|
.internal:
|
|
xor ecx, ecx ; clear common header
|
|
pushfd
|
|
cli
|
|
mov [eax+EVENT.magic], ecx
|
|
mov [eax+EVENT.destroy], ecx
|
|
mov [eax+EVENT.pid], ecx
|
|
mov [eax+EVENT.id], ecx
|
|
mov ebx, FreeEvents
|
|
jmp RemoveEventTo
|
|
;-----------------------------------------------------------------------------
|
|
align 4
|
|
get_event_queue:
|
|
;info:
|
|
; êëèåíòñêàÿ ô-ÿ òåñòèðîâàíèÿ äëÿ get_event_ex
|
|
;warning:
|
|
; -don't use [TASK_BASE],[current_slot],[CURRENT_TASK] - it is not for your slot
|
|
; -may be assumed, that interrupt are disabled
|
|
; -it is not restriction for scratched registers
|
|
;param:
|
|
; ebx - àäðåñ APPDATA ñëîòà òåñòèðîâàíèÿ
|
|
;retval:
|
|
; eax - àäðåñ îáúåêòà EVENT (=0 => fail)
|
|
add ebx, APP_EV_OFFSET
|
|
mov eax, [ebx+APPOBJ.bk] ; âûáèðàåì ñ êîíöà, ïî ïðèíöèïó FIFO
|
|
cmp eax, ebx ; empty ???
|
|
je get_event_alone.ret0
|
|
;--------------------------------------
|
|
align 4
|
|
.ret:
|
|
ret
|
|
;-----------------------------------------------------------------------------
|
|
align 4
|
|
get_event_alone:
|
|
;info:
|
|
; êëèåíòñêàÿ ô-ÿ òåñòèðîâàíèÿ äëÿ wait_event
|
|
;warning:
|
|
; -don't use [TASK_BASE],[current_slot],[CURRENT_TASK] - it is not for your slot
|
|
; -may be assumed, that interrupt are disabled
|
|
; -it is not restriction for scratched registers
|
|
;param:
|
|
; ebx - àäðåñ APPDATA ñëîòà òåñòèðîâàíèÿ
|
|
;retval:
|
|
; eax - àäðåñ îáúåêòà EVENT (=0 => fail)
|
|
mov eax, [ebx+APPDATA.wait_param]
|
|
test byte[eax+EVENT.state+3], EVENT_SIGNALED shr 24
|
|
jnz .ret
|
|
or byte[eax+EVENT.state+3], EVENT_WATCHED shr 24
|
|
;--------------------------------------
|
|
align 4
|
|
.ret0:
|
|
xor eax, eax; NO event!!!
|
|
;--------------------------------------
|
|
align 4
|
|
.ret:
|
|
ret
|
|
;-----------------------------------------------------------------------------
|
|
align 4
|
|
sys_sendwindowmsg: ;; f72
|
|
dec ebx
|
|
jnz .ret ;subfunction==1 ?
|
|
pushfd
|
|
cli
|
|
sub ecx, 2
|
|
je .sendkey
|
|
dec ecx
|
|
jnz .retf
|
|
;--------------------------------------
|
|
align 4
|
|
.sendbtn:
|
|
cmp byte[BTN_COUNT], 1
|
|
jae .result ;overflow
|
|
inc byte[BTN_COUNT]
|
|
shl edx, 8
|
|
mov [BTN_BUFF], edx
|
|
jmp .result
|
|
;--------------------------------------
|
|
align 4
|
|
.sendkey:
|
|
movzx eax, byte[KEY_COUNT]
|
|
cmp al, 120
|
|
jae .result ;overflow
|
|
inc byte[KEY_COUNT]
|
|
mov [KEY_COUNT+1+eax], dl
|
|
;--------------------------------------
|
|
align 4
|
|
.result:
|
|
setae byte[esp+32] ;ñ÷èòàåì, ÷òî èñõîäíî: dword[esp+32]==72
|
|
;--------------------------------------
|
|
align 4
|
|
.retf:
|
|
popfd
|
|
;--------------------------------------
|
|
align 4
|
|
.ret:
|
|
ret
|
|
;-----------------------------------------------------------------------------
|
|
align 4
|
|
sys_getevent: ;; f11
|
|
mov ebx, [current_slot];ïîêà ýòî âîïðîñ, ÷åãî êóäû ñóâàòü..........
|
|
pushfd ; ýòî ñëåäñòâèå îáùåé êîíöåïöèè: ïóñòü ô-ÿ òåñòèðîâàíèÿ èìååò
|
|
cli ; ïðàâî ðàññ÷èòûâàòü íà çàêðûòûå ïðåðûâàíèÿ, êàê ïðè âûçîâå èç shed
|
|
call get_event_for_app
|
|
popfd
|
|
mov [esp+32], eax
|
|
ret
|
|
;-----------------------------------------------------------------------------
|
|
align 4
|
|
sys_waitforevent: ;; f10
|
|
or ebx, -1; infinite timeout
|
|
;--------------------------------------
|
|
align 4
|
|
sys_wait_event_timeout: ;; f23
|
|
mov edx, get_event_for_app; wait_test
|
|
call Wait_events_ex ; ebx - timeout
|
|
mov [esp+32], eax
|
|
ret
|
|
;-----------------------------------------------------------------------------
|
|
align 4
|
|
get_event_for_app: ;; used from f10,f11,f23
|
|
;info:
|
|
; êëèåíòñêàÿ ô-ÿ òåñòèðîâàíèÿ äëÿ ïðèëîæåíèé (f10,f23)
|
|
;warning:
|
|
; -don't use [TASK_BASE],[current_slot],[CURRENT_TASK] - it is not for your slot
|
|
; -may be assumed, that interrupt are disabled
|
|
; -it is not restriction for scratched registers
|
|
;param:
|
|
; ebx - àäðåñ APPDATA ñëîòà òåñòèðîâàíèÿ
|
|
;retval:
|
|
; eax - íîìåð ñîáûòèÿ (=0 => no events)
|
|
movzx edi, bh ; bh is assumed as [CURRENT_TASK]
|
|
shl edi, 5
|
|
add edi, CURRENT_TASK ; edi is assumed as [TASK_BASE]
|
|
mov ecx, [edi+TASKDATA.event_mask]
|
|
and ecx, 0x7FFFFFFF
|
|
;--------------------------------------
|
|
align 4
|
|
.loop: ; ïîêà íå èñ÷åðïàåì âñå áèòû ìàñêè
|
|
bsr eax, ecx ; íàõîäèì íåíóëåâîé áèò ìàñêè (31 -> 0)
|
|
jz .no_events ; èñ÷åðïàëè âñå áèòû ìàñêè, íî íè÷åãî íå íàøëè ???
|
|
btr ecx, eax ; ñáðàñûâàåì ïðîâåðÿåìûé áèò ìàñêè
|
|
; ïåðåõîäèì íà îáðàáîò÷èê ýòîãî (eax) áèòà
|
|
cmp eax, 9
|
|
jae .loop ; eax=[9..31], ignored (event 10...32)
|
|
|
|
cmp eax, 3
|
|
je .loop ; eax=3, ignored (event 4)
|
|
|
|
cmp eax, 4
|
|
je .FlagAutoReset ; eax=4, retvals=eax+1 (event 5)
|
|
|
|
cmp eax, 5
|
|
je .mouse_check ; eax=5, retvals=eax+1 (event 6)
|
|
|
|
ja .FlagAutoReset ; eax=[6..8], retvals=eax+1 (event 7...9)
|
|
|
|
cmp eax, 1
|
|
jae .BtKy ; eax=[1,2], retvals=eax+1 (event 2,3)
|
|
;--------------------------------------
|
|
align 4
|
|
.WndRedraw: ; eax=0, retval WndRedraw=1
|
|
cmp [edi-twdw+WDATA.fl_redraw], al;al==0
|
|
jne .result
|
|
jmp .loop
|
|
;--------------------------------------
|
|
align 4
|
|
.no_events:
|
|
xor eax, eax
|
|
ret
|
|
;--------------------------------------
|
|
align 4
|
|
.mouse_check: ; Mouse 5+1=6
|
|
push eax
|
|
mov eax, [TASK_BASE]
|
|
mov eax, [eax + TASKDATA.event_mask]
|
|
test eax, 0x80000000 ; bit 31: active/inactive filter f.40
|
|
jz @f
|
|
pop eax
|
|
jmp .FlagAutoReset
|
|
;--------------------------------------
|
|
align 4
|
|
@@:
|
|
; If the window is captured and moved by the user, then no mouse events!!!
|
|
mov al, [mouse.active_sys_window.action]
|
|
and al, WINDOW_MOVE_AND_RESIZE_FLAGS
|
|
test al, al
|
|
pop eax
|
|
jnz .loop
|
|
;--------------------------------------
|
|
align 4
|
|
.FlagAutoReset: ; retvals: BgrRedraw=5, IPC=7, Stack=8, Debug=9
|
|
btr [ebx+APPDATA.event_mask], eax
|
|
jnc .loop
|
|
;--------------------------------------
|
|
align 4
|
|
.result: ; retval = eax+1
|
|
inc eax
|
|
ret
|
|
;--------------------------------------
|
|
align 4
|
|
.BtKy:
|
|
movzx edx, bh
|
|
movzx edx, word[WIN_STACK+edx*2]
|
|
je .Keys ; eax=1, retval Keys=2
|
|
;--------------------------------------
|
|
align 4
|
|
.Buttons: ; eax=2, retval Buttons=3
|
|
cmp byte[BTN_COUNT], 0
|
|
je .loop ; empty ???
|
|
cmp edx, [TASK_COUNT]
|
|
jne .loop ; not Top ???
|
|
mov edx, [BTN_BUFF]
|
|
shr edx, 8
|
|
cmp edx, 0xFFFF ;-ID for Minimize-Button of Form
|
|
jne .result
|
|
mov [window_minimize], 1
|
|
dec byte[BTN_COUNT]
|
|
jmp .loop
|
|
;--------------------------------------
|
|
align 4
|
|
.Keys: ; eax==1
|
|
cmp edx, [TASK_COUNT]
|
|
jne @f ; not Top ???
|
|
cmp [KEY_COUNT], al; al==1
|
|
jae .result ; not empty ???
|
|
;--------------------------------------
|
|
align 4
|
|
@@:
|
|
mov edx, hotkey_buffer
|
|
;--------------------------------------
|
|
align 4
|
|
@@:
|
|
cmp [edx], bh ; bh - slot for testing
|
|
je .result
|
|
add edx, 8
|
|
cmp edx, hotkey_buffer+120*8
|
|
jb @b
|
|
jmp .loop
|
|
;end.
|
|
;----------------------------------------------------------------------------- |