Rev 3396 | Rev 3534 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2288 | clevermous | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
2455 | mario79 | 3 | ;; Copyright (C) KolibriOS team 2004-2012. 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: 3451 $ |
||
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 ; "виртуальный" event, используются только поля: |
||
25 | ; FreeEvents.fd=event_start и 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 |
||
32 | ; eax - current event, ebx - previos event below |
||
33 | mov ecx, EV_SPACE ; current - in allocated space |
||
34 | mov ebx, FreeEvents ; previos - начало списка |
||
35 | push ebx ; оно же и конец потом будет |
||
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 |
44 | pop eax ; вот оно концом и стало |
||
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 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 52 | EVENT_WATCHED equ 0x10000000 ;бит 28 |
53 | EVENT_SIGNALED equ 0x20000000 ;бит 29 |
||
54 | MANUAL_RESET equ 0x40000000 ;бит 30 |
||
55 | MANUAL_DESTROY equ 0x80000000 ;бит 31 |
||
2513 | mario79 | 56 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 57 | align 4 |
58 | create_event: ;; EXPORT use |
||
59 | ;info: |
||
60 | ; Переносим EVENT из списка FreeEvents в список ObjList текущего слота |
||
61 | ; EVENT.state устанавливаем из ecx, EVENT.code косвенно из esi (если 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, [TASK_BASE] |
||
72 | mov edx, [edx+TASKDATA.pid] |
||
73 | pushfd |
||
74 | cli |
||
2513 | mario79 | 75 | ;-------------------------------------- |
76 | align 4 |
||
2288 | clevermous | 77 | set_event: ;; INTERNAL use !!! don't use for Call |
78 | ;info: |
||
79 | ; Берем новый event из FreeEvents, заполняем его поля, как указано в ecx,edx,esi |
||
80 | ; и устанавливаем в список, указанный в ebx. |
||
81 | ; Возвращаем сам event (в eax), и его uid (в edx) |
||
82 | ;param: |
||
83 | ; ebx - start-chain "virtual" event for entry new event Right of him |
||
84 | ; ecx - flags (copied to EVENT.state) |
||
85 | ; edx - pid (copied to EVENT.pid) |
||
86 | ; esi - event data (copied to EVENT.code indirect, =0 => skip) |
||
87 | ;retval: |
||
88 | ; eax - event (=0 => fail) |
||
89 | ; edx - uid |
||
90 | ;scratched: ebx,ecx,esi,edi |
||
91 | mov eax, FreeEvents |
||
92 | cmp eax, [eax+EVENT.fd] |
||
93 | jne @f ; not empty ??? |
||
94 | pushad |
||
95 | call init_events |
||
96 | popad |
||
97 | jz RemoveEventTo.break ; POPF+RET |
||
2513 | mario79 | 98 | ;-------------------------------------- |
99 | align 4 |
||
100 | @@: |
||
2288 | clevermous | 101 | mov eax, [eax+EVENT.fd] |
102 | mov [eax+EVENT.magic], 'EVNT' |
||
103 | mov [eax+EVENT.destroy], destroy_event.internal |
||
104 | mov [eax+EVENT.state], ecx |
||
105 | mov [eax+EVENT.pid], edx |
||
106 | inc [event_uid] |
||
107 | Mov [eax+EVENT.id],edx,[event_uid] |
||
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: |
||
118 | ; eax - указатель на event, КОТОРЫЙ вставляем |
||
119 | ; ebx - указатель на event, ПОСЛЕ которого вставляем |
||
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 ; стоп, себе думаю... |
||
124 | je .break ; - а не дурак ли я? |
||
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 |
||
2288 | clevermous | 145 | .small: ; криво как-то... |
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 ; штатный возврат |
||
2513 | mario79 | 153 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 154 | align 4 |
155 | raise_event: ;; EXPORT use |
||
156 | ;info: |
||
157 | ; Устанавливаем данные EVENT.code |
||
158 | ; Если там флаг EVENT_SIGNALED уже активен - больше ничего |
||
159 | ; Иначе: этот флаг взводится, за исключением случая наличия флага EVENT_WATCHED в edx |
||
160 | ; В этом случае EVENT_SIGNALED взводится лишь при наличие EVENT_WATCHED в самом событии |
||
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: |
||
208 | ; Создает новый EVENT (вытаскивает из списка FreeEvents) в списке EventList |
||
209 | ; целевого слота (eax=pid), с данными из esi косвенно, и 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 |
||
2513 | mario79 | 227 | ;----------------------------------------------- |