Rev 5870 | Rev 8928 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1391 | mikedld | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
5363 | yogev_ezra | 3 | ;; Copyright (C) KolibriOS team 2010-2015. All rights reserved. ;; |
1391 | mikedld | 4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
||
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
7 | |||
1531 | diamond | 8 | $Revision: 6585 $ |
1391 | mikedld | 9 | |
10 | include 'mousepointer.inc' |
||
11 | |||
5851 | pathoswith | 12 | ;================================ |
13 | ;/////// public functions /////// |
||
14 | ;================================ |
||
1391 | mikedld | 15 | |
16 | mouse.LEFT_BUTTON_FLAG = 0001b |
||
17 | mouse.RIGHT_BUTTON_FLAG = 0010b |
||
18 | mouse.MIDDLE_BUTTON_FLAG = 0100b |
||
19 | |||
20 | mouse.BUTTONS_MASK = \ |
||
21 | mouse.LEFT_BUTTON_FLAG or \ |
||
22 | mouse.RIGHT_BUTTON_FLAG or \ |
||
23 | mouse.MIDDLE_BUTTON_FLAG |
||
24 | |||
25 | mouse.WINDOW_RESIZE_N_FLAG = 000001b |
||
26 | mouse.WINDOW_RESIZE_W_FLAG = 000010b |
||
27 | mouse.WINDOW_RESIZE_S_FLAG = 000100b |
||
28 | mouse.WINDOW_RESIZE_E_FLAG = 001000b |
||
29 | mouse.WINDOW_MOVE_FLAG = 010000b |
||
30 | |||
31 | mouse.WINDOW_RESIZE_SW_FLAG = \ |
||
32 | mouse.WINDOW_RESIZE_S_FLAG or \ |
||
33 | mouse.WINDOW_RESIZE_W_FLAG |
||
34 | mouse.WINDOW_RESIZE_SE_FLAG = \ |
||
35 | mouse.WINDOW_RESIZE_S_FLAG or \ |
||
36 | mouse.WINDOW_RESIZE_E_FLAG |
||
37 | |||
38 | align 4 |
||
5851 | pathoswith | 39 | ;----------------------------------------------------------------- |
40 | mouse_check_events: |
||
41 | ; Check if mouse buttons state or cursor position has changed |
||
1391 | mikedld | 42 | push eax ebx |
43 | mov al, [BTN_DOWN] |
||
44 | mov bl, [mouse.state.buttons] |
||
45 | and al, mouse.BUTTONS_MASK |
||
46 | mov cl, al |
||
47 | xchg cl, [mouse.state.buttons] |
||
48 | xor bl, al |
||
49 | push eax ebx |
||
50 | |||
51 | ; did any mouse button changed its state? |
||
52 | or bl, bl |
||
53 | jz .check_position |
||
54 | |||
55 | ; yes it did, is that the first button of all pressed down? |
||
56 | or cl, cl |
||
57 | jnz .check_buttons_released |
||
58 | |||
59 | ; yes it is, activate window user is pointing at, if needed |
||
60 | call mouse._.activate_sys_window_under_cursor |
||
61 | |||
62 | ; is there any system button under cursor? |
||
2288 | clevermous | 63 | call mouse._.find_sys_button_under_cursor |
1391 | mikedld | 64 | or eax, eax |
65 | jz .check_buttons_released |
||
66 | |||
67 | ; yes there is, activate it and exit |
||
68 | mov [mouse.active_sys_button.pbid], eax |
||
69 | mov [mouse.active_sys_button.coord], ebx |
||
70 | mov cl, [mouse.state.buttons] |
||
71 | mov [mouse.active_sys_button.buttons], cl |
||
72 | call sys_button_activate_handler |
||
73 | jmp .exit |
||
74 | |||
75 | .check_buttons_released: |
||
76 | cmp [mouse.state.buttons], 0 |
||
77 | jnz .buttons_changed |
||
78 | |||
79 | ; did we press some button earlier? |
||
80 | cmp [mouse.active_sys_button.pbid], 0 |
||
81 | je .buttons_changed |
||
82 | |||
83 | ; yes we did, deactivate it |
||
84 | xor eax, eax |
||
85 | xchg eax, [mouse.active_sys_button.pbid] |
||
86 | mov ebx, [mouse.active_sys_button.coord] |
||
87 | mov cl, [mouse.active_sys_button.buttons] |
||
88 | push eax ebx |
||
89 | call sys_button_deactivate_handler |
||
90 | pop edx ecx |
||
91 | |||
92 | ; is the button under cursor the one we deactivated? |
||
93 | call mouse._.find_sys_button_under_cursor |
||
94 | cmp eax, ecx |
||
95 | jne .exit |
||
96 | cmp ebx, edx |
||
97 | jne .exit |
||
98 | |||
99 | ; yes it is, perform associated action |
||
100 | mov cl, [mouse.active_sys_button.buttons] |
||
101 | call sys_button_perform_handler |
||
102 | jmp .exit |
||
103 | |||
104 | .buttons_changed: |
||
105 | test byte[esp], mouse.LEFT_BUTTON_FLAG |
||
106 | jz @f |
||
107 | mov eax, [esp + 4] |
||
108 | call .call_left_button_handler |
||
109 | |||
2288 | clevermous | 110 | @@: |
111 | test byte[esp], mouse.RIGHT_BUTTON_FLAG |
||
1391 | mikedld | 112 | jz @f |
113 | mov eax, [esp + 4] |
||
114 | call .call_right_button_handler |
||
115 | |||
2288 | clevermous | 116 | @@: |
117 | test byte[esp], mouse.MIDDLE_BUTTON_FLAG |
||
1391 | mikedld | 118 | jz .check_position |
119 | mov eax, [esp + 4] |
||
120 | call .call_middle_button_handler |
||
121 | |||
122 | .check_position: |
||
123 | movzx eax, word[MOUSE_X] |
||
124 | movzx ebx, word[MOUSE_Y] |
||
125 | cmp eax, [mouse.state.pos.x] |
||
126 | jne .position_changed |
||
127 | cmp ebx, [mouse.state.pos.y] |
||
128 | je .exit |
||
129 | |||
130 | .position_changed: |
||
131 | xchg eax, [mouse.state.pos.x] |
||
132 | xchg ebx, [mouse.state.pos.y] |
||
133 | |||
134 | call mouse._.move_handler |
||
135 | |||
136 | .exit: |
||
137 | add esp, 8 |
||
138 | pop ebx eax |
||
139 | ret |
||
140 | |||
141 | .call_left_button_handler: |
||
142 | test eax, mouse.LEFT_BUTTON_FLAG |
||
143 | jnz mouse._.left_button_press_handler |
||
144 | jmp mouse._.left_button_release_handler |
||
145 | |||
146 | .call_right_button_handler: |
||
147 | test eax, mouse.RIGHT_BUTTON_FLAG |
||
148 | jnz mouse._.right_button_press_handler |
||
149 | jmp mouse._.right_button_release_handler |
||
150 | |||
151 | .call_middle_button_handler: |
||
152 | test eax, mouse.MIDDLE_BUTTON_FLAG |
||
153 | jnz mouse._.middle_button_press_handler |
||
154 | jmp mouse._.middle_button_release_handler |
||
155 | |||
5851 | pathoswith | 156 | ;=============================== |
157 | ;////// private functions ////// |
||
158 | ;=============================== |
||
1391 | mikedld | 159 | |
160 | uglobal |
||
161 | mouse.state: |
||
162 | .pos POINT |
||
163 | .buttons db ? |
||
164 | |||
5851 | pathoswith | 165 | ; NOTE: since there's no unique and lifetime-constant button identifiers, |
166 | ; we are using two dwords to identify each of them: |
||
167 | ; * pbid - process slot (high 8 bits) and button id (low 24 bits) pack |
||
168 | ; * coord - left (high 16 bits) and top (low 16 bits) coordinates pack |
||
1391 | mikedld | 169 | align 4 |
170 | mouse.active_sys_button: |
||
171 | .pbid dd ? |
||
172 | .coord dd ? |
||
173 | .buttons db ? |
||
174 | |||
175 | align 4 |
||
176 | mouse.active_sys_window: |
||
177 | .pslot dd ? |
||
178 | .old_box BOX |
||
179 | .new_box BOX |
||
180 | .delta POINT |
||
181 | .last_ticks dd ? |
||
182 | .action db ? |
||
183 | endg |
||
184 | |||
5870 | GerdtR | 185 | iglobal |
186 | fl_moving db 0 |
||
187 | rb 3 |
||
188 | endg |
||
189 | |||
1391 | mikedld | 190 | align 4 |
5851 | pathoswith | 191 | ;----------------------------------------------------------------- |
192 | mouse._.left_button_press_handler: |
||
193 | ; Called when left mouse button has been pressed down |
||
194 | bts word [BTN_DOWN], 8 |
||
195 | mov eax, [timer_ticks] |
||
196 | mov ebx, eax |
||
197 | xchg ebx, [mouse.active_sys_window.last_ticks] |
||
198 | sub eax, ebx |
||
199 | movzx ebx, [mouse_doubleclick_delay] |
||
200 | cmp eax, ebx |
||
201 | jg @f |
||
202 | bts dword [BTN_DOWN], 24 |
||
203 | @@: |
||
1391 | mikedld | 204 | test [mouse.state.buttons], not mouse.LEFT_BUTTON_FLAG |
205 | jnz .exit |
||
206 | |||
207 | call mouse._.find_sys_window_under_cursor |
||
208 | call mouse._.check_sys_window_actions |
||
209 | mov [mouse.active_sys_window.action], al |
||
210 | or eax, eax |
||
211 | jz .exit |
||
212 | |||
213 | xchg eax, edx |
||
214 | test dl, mouse.WINDOW_MOVE_FLAG |
||
215 | jz @f |
||
216 | |||
5851 | pathoswith | 217 | bt dword [BTN_DOWN], 24 |
218 | jnc @f |
||
1391 | mikedld | 219 | |
220 | mov [mouse.active_sys_window.last_ticks], 0 |
||
221 | call sys_window_maximize_handler |
||
222 | jmp .exit |
||
223 | |||
2288 | clevermous | 224 | @@: |
225 | test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED |
||
1391 | mikedld | 226 | jnz .exit |
227 | mov [mouse.active_sys_window.pslot], esi |
||
228 | lea eax, [edi + WDATA.box] |
||
229 | mov ebx, mouse.active_sys_window.old_box |
||
2381 | hidnplayr | 230 | mov ecx, sizeof.BOX |
1391 | mikedld | 231 | call memmove |
232 | mov ebx, mouse.active_sys_window.new_box |
||
233 | call memmove |
||
234 | test edx, mouse.WINDOW_MOVE_FLAG |
||
235 | jz @f |
||
236 | |||
237 | call .calculate_n_delta |
||
238 | call .calculate_w_delta |
||
239 | jmp .call_window_handler |
||
240 | |||
2288 | clevermous | 241 | @@: |
242 | test dl, mouse.WINDOW_RESIZE_W_FLAG |
||
1391 | mikedld | 243 | jz @f |
244 | call .calculate_w_delta |
||
245 | |||
2288 | clevermous | 246 | @@: |
247 | test dl, mouse.WINDOW_RESIZE_S_FLAG |
||
1391 | mikedld | 248 | jz @f |
249 | call .calculate_s_delta |
||
250 | |||
2288 | clevermous | 251 | @@: |
252 | test dl, mouse.WINDOW_RESIZE_E_FLAG |
||
1391 | mikedld | 253 | jz .call_window_handler |
254 | call .calculate_e_delta |
||
255 | |||
256 | .call_window_handler: |
||
257 | .exit: |
||
258 | ret |
||
259 | |||
260 | .calculate_n_delta: |
||
261 | mov eax, [mouse.state.pos.y] |
||
262 | sub eax, [mouse.active_sys_window.old_box.top] |
||
263 | mov [mouse.active_sys_window.delta.y], eax |
||
264 | ret |
||
265 | |||
266 | .calculate_w_delta: |
||
267 | mov eax, [mouse.state.pos.x] |
||
268 | sub eax, [mouse.active_sys_window.old_box.left] |
||
269 | mov [mouse.active_sys_window.delta.x], eax |
||
270 | ret |
||
271 | |||
272 | .calculate_s_delta: |
||
273 | mov eax, [mouse.active_sys_window.old_box.top] |
||
274 | add eax, [mouse.active_sys_window.old_box.height] |
||
275 | sub eax, [mouse.state.pos.y] |
||
276 | mov [mouse.active_sys_window.delta.y], eax |
||
277 | ret |
||
278 | |||
279 | .calculate_e_delta: |
||
280 | mov eax, [mouse.active_sys_window.old_box.left] |
||
281 | add eax, [mouse.active_sys_window.old_box.width] |
||
282 | sub eax, [mouse.state.pos.x] |
||
283 | mov [mouse.active_sys_window.delta.x], eax |
||
284 | ret |
||
285 | |||
286 | align 4 |
||
5851 | pathoswith | 287 | ;----------------------------------------------------------------- |
288 | mouse._.left_button_release_handler: |
||
289 | ; Called when left mouse button has been released |
||
290 | bts dword [BTN_DOWN], 16 |
||
1391 | mikedld | 291 | xor esi, esi |
292 | xchg esi, [mouse.active_sys_window.pslot] |
||
293 | or esi, esi |
||
294 | jz .exit |
||
295 | |||
296 | mov eax, esi |
||
297 | shl eax, 5 |
||
298 | add eax, window_data + WDATA.box |
||
299 | mov ebx, mouse.active_sys_window.old_box |
||
2381 | hidnplayr | 300 | mov ecx, sizeof.BOX |
1391 | mikedld | 301 | call memmove |
302 | |||
303 | mov eax, mouse.active_sys_window.old_box |
||
304 | mov ebx, mouse.active_sys_window.new_box |
||
305 | call sys_window_end_moving_handler |
||
306 | |||
307 | .exit: |
||
2011 | mikedld | 308 | and [mouse.active_sys_window.action], 0 |
5870 | GerdtR | 309 | mov [fl_moving], 0 |
1391 | mikedld | 310 | ret |
311 | |||
5851 | pathoswith | 312 | mouse._.right_button_press_handler: |
313 | bts word [BTN_DOWN], 9 |
||
1391 | mikedld | 314 | test [mouse.state.buttons], not mouse.RIGHT_BUTTON_FLAG |
5851 | pathoswith | 315 | jnz @f |
1391 | mikedld | 316 | call mouse._.find_sys_window_under_cursor |
317 | call mouse._.check_sys_window_actions |
||
318 | test al, mouse.WINDOW_MOVE_FLAG |
||
5851 | pathoswith | 319 | jz @f |
320 | jmp sys_window_rollup_handler |
||
1391 | mikedld | 321 | |
5851 | pathoswith | 322 | mouse._.right_button_release_handler: |
323 | bts dword [BTN_DOWN], 17 |
||
324 | @@: |
||
1391 | mikedld | 325 | ret |
326 | |||
5851 | pathoswith | 327 | mouse._.middle_button_press_handler: |
328 | bts word [BTN_DOWN], 10 |
||
1391 | mikedld | 329 | ret |
330 | |||
5851 | pathoswith | 331 | mouse._.middle_button_release_handler: |
332 | bts dword [BTN_DOWN], 18 |
||
1391 | mikedld | 333 | ret |
334 | |||
335 | align 4 |
||
5851 | pathoswith | 336 | ;----------------------------------------------------------------- |
337 | mouse._.move_handler: |
||
338 | ; Called when cursor has been moved |
||
1391 | mikedld | 339 | ;> eax = old x coord |
340 | ;> ebx = old y coord |
||
341 | cmp [mouse.active_sys_button.pbid], 0 |
||
342 | jnz .exit |
||
343 | |||
344 | mov esi, [mouse.active_sys_window.pslot] |
||
345 | or esi, esi |
||
346 | jz .exit |
||
347 | |||
348 | mov eax, mouse.active_sys_window.new_box |
||
349 | mov ebx, mouse.active_sys_window.old_box |
||
2381 | hidnplayr | 350 | mov ecx, sizeof.BOX |
1391 | mikedld | 351 | call memmove |
352 | |||
353 | mov dl, [mouse.active_sys_window.action] |
||
354 | test dl, mouse.WINDOW_MOVE_FLAG |
||
355 | jz .check_resize_w |
||
356 | |||
357 | mov eax, [mouse.state.pos.x] |
||
358 | sub eax, [mouse.active_sys_window.delta.x] |
||
359 | mov [mouse.active_sys_window.new_box.left], eax |
||
360 | mov eax, [mouse.state.pos.y] |
||
361 | sub eax, [mouse.active_sys_window.delta.y] |
||
362 | mov [mouse.active_sys_window.new_box.top], eax |
||
363 | |||
364 | mov eax, [mouse.active_sys_window.new_box.left] |
||
365 | or eax, eax |
||
366 | jge @f |
||
367 | xor eax, eax |
||
368 | mov [mouse.active_sys_window.new_box.left], eax |
||
2288 | clevermous | 369 | @@: |
370 | add eax, [mouse.active_sys_window.new_box.width] |
||
5350 | serge | 371 | cmp eax, [_display.width] |
1391 | mikedld | 372 | jl @f |
5350 | serge | 373 | sub eax, [_display.width] |
1391 | mikedld | 374 | sub [mouse.active_sys_window.new_box.left], eax |
2288 | clevermous | 375 | @@: |
376 | mov eax, [mouse.active_sys_window.new_box.top] |
||
1391 | mikedld | 377 | or eax, eax |
378 | jge @f |
||
379 | xor eax, eax |
||
380 | mov [mouse.active_sys_window.new_box.top], eax |
||
2288 | clevermous | 381 | @@: |
382 | add eax, [mouse.active_sys_window.new_box.height] |
||
5350 | serge | 383 | cmp eax, [_display.height] |
384 | jl .call_window_handler |
||
385 | sub eax, [_display.height] |
||
1391 | mikedld | 386 | sub [mouse.active_sys_window.new_box.top], eax |
387 | jmp .call_window_handler |
||
388 | |||
389 | .check_resize_w: |
||
390 | test dl, mouse.WINDOW_RESIZE_W_FLAG |
||
391 | jz .check_resize_s |
||
392 | |||
393 | mov eax, [mouse.state.pos.x] |
||
394 | sub eax, [mouse.active_sys_window.delta.x] |
||
395 | mov [mouse.active_sys_window.new_box.left], eax |
||
396 | sub eax, [mouse.active_sys_window.old_box.left] |
||
397 | sub [mouse.active_sys_window.new_box.width], eax |
||
398 | |||
399 | mov eax, [mouse.active_sys_window.new_box.width] |
||
400 | sub eax, 127 |
||
401 | jge @f |
||
402 | add [mouse.active_sys_window.new_box.left], eax |
||
403 | mov [mouse.active_sys_window.new_box.width], 127 |
||
2288 | clevermous | 404 | @@: |
405 | mov eax, [mouse.active_sys_window.new_box.left] |
||
1391 | mikedld | 406 | or eax, eax |
407 | jge .check_resize_s |
||
408 | add [mouse.active_sys_window.new_box.width], eax |
||
409 | xor eax, eax |
||
410 | mov [mouse.active_sys_window.new_box.left], eax |
||
411 | |||
412 | .check_resize_s: |
||
413 | test dl, mouse.WINDOW_RESIZE_S_FLAG |
||
414 | jz .check_resize_e |
||
415 | |||
416 | mov eax, [mouse.state.pos.y] |
||
417 | add eax, [mouse.active_sys_window.delta.y] |
||
418 | sub eax, [mouse.active_sys_window.old_box.top] |
||
419 | mov [mouse.active_sys_window.new_box.height], eax |
||
420 | |||
421 | push eax |
||
422 | mov edi, esi |
||
423 | shl edi, 5 |
||
424 | add edi, window_data |
||
425 | call window._.get_rolledup_height |
||
426 | mov ecx, eax |
||
427 | pop eax |
||
428 | mov eax, [mouse.active_sys_window.new_box.height] |
||
429 | cmp eax, ecx |
||
430 | jge @f |
||
431 | mov eax, ecx |
||
432 | mov [mouse.active_sys_window.new_box.height], eax |
||
2288 | clevermous | 433 | @@: |
434 | add eax, [mouse.active_sys_window.new_box.top] |
||
5350 | serge | 435 | cmp eax, [_display.height] |
436 | jl .check_resize_e |
||
437 | sub eax, [_display.height] |
||
1391 | mikedld | 438 | neg eax |
439 | add [mouse.active_sys_window.new_box.height], eax |
||
5350 | serge | 440 | mov ecx, [_display.height] |
1391 | mikedld | 441 | cmp ecx, eax |
5350 | serge | 442 | jg .check_resize_e |
1391 | mikedld | 443 | mov [mouse.active_sys_window.new_box.height], ecx |
444 | |||
445 | .check_resize_e: |
||
446 | test dl, mouse.WINDOW_RESIZE_E_FLAG |
||
447 | jz .call_window_handler |
||
448 | |||
449 | mov eax, [mouse.state.pos.x] |
||
450 | add eax, [mouse.active_sys_window.delta.x] |
||
451 | sub eax, [mouse.active_sys_window.old_box.left] |
||
452 | mov [mouse.active_sys_window.new_box.width], eax |
||
453 | |||
454 | mov eax, [mouse.active_sys_window.new_box.width] |
||
455 | cmp eax, 127 |
||
456 | jge @f |
||
457 | mov eax, 127 |
||
458 | mov [mouse.active_sys_window.new_box.width], eax |
||
2288 | clevermous | 459 | @@: |
460 | add eax, [mouse.active_sys_window.new_box.left] |
||
5350 | serge | 461 | cmp eax, [_display.width] |
462 | jl .call_window_handler |
||
463 | sub eax, [_display.width] |
||
1391 | mikedld | 464 | neg eax |
465 | add [mouse.active_sys_window.new_box.width], eax |
||
5350 | serge | 466 | mov ecx, [_display.width] |
1391 | mikedld | 467 | cmp ecx, eax |
5350 | serge | 468 | jg .call_window_handler |
1391 | mikedld | 469 | mov [mouse.active_sys_window.new_box.width], ecx |
470 | |||
471 | .call_window_handler: |
||
472 | mov eax, mouse.active_sys_window.old_box |
||
473 | mov ebx, mouse.active_sys_window.new_box |
||
474 | |||
475 | push esi |
||
476 | mov esi, mouse.active_sys_window.old_box |
||
477 | mov edi, mouse.active_sys_window.new_box |
||
2381 | hidnplayr | 478 | mov ecx, sizeof.BOX / 4 |
1391 | mikedld | 479 | repe |
480 | cmpsd |
||
481 | pop esi |
||
482 | je .exit |
||
483 | |||
5870 | GerdtR | 484 | test [fl_moving], 1 |
485 | jnz @f |
||
486 | |||
487 | mov [fl_moving], 1 |
||
488 | push edi |
||
489 | mov edi, esi |
||
490 | shl edi, 5 |
||
491 | add edi, WDATA.box + window_data |
||
492 | call window._.draw_negative_box |
||
493 | pop edi |
||
494 | @@: |
||
495 | |||
496 | |||
1391 | mikedld | 497 | mov [mouse.active_sys_window.last_ticks], 0 |
498 | call sys_window_moving_handler |
||
499 | |||
500 | .exit: |
||
501 | ret |
||
502 | |||
503 | align 4 |
||
5851 | pathoswith | 504 | ;----------------------------------------------------------------- |
505 | mouse._.find_sys_window_under_cursor: |
||
506 | ; Find system window object which is currently visible on screen |
||
507 | ; and has mouse cursor within its bounds |
||
1391 | mikedld | 508 | ;< esi = process slot |
509 | ;< edi = pointer to WDATA struct |
||
2446 | mario79 | 510 | mov esi, [mouse.state.pos.y] |
511 | mov esi, [d_width_calc_area + esi*4] |
||
512 | |||
5351 | serge | 513 | add esi, [_display.win_map] |
1391 | mikedld | 514 | add esi, [mouse.state.pos.x] |
515 | movzx esi, byte[esi] |
||
516 | mov edi, esi |
||
517 | shl edi, 5 |
||
518 | add edi, window_data |
||
519 | ret |
||
520 | |||
521 | align 4 |
||
5851 | pathoswith | 522 | ;----------------------------------------------------------------- |
523 | mouse._.activate_sys_window_under_cursor: |
||
524 | ; activate and redraw window under cursor (if necessary) |
||
1391 | mikedld | 525 | call mouse._.find_sys_window_under_cursor |
526 | movzx esi, word[WIN_STACK + esi * 2] |
||
527 | lea esi, [WIN_POS + esi * 2] |
||
528 | jmp waredraw |
||
529 | |||
530 | align 4 |
||
5851 | pathoswith | 531 | ;----------------------------------------------------------------- |
532 | mouse._.find_sys_button_under_cursor: |
||
533 | ; Find system button object which is currently visible on screen |
||
534 | ; and has mouse cursor within its bounds |
||
1391 | mikedld | 535 | ;< eax = pack[8(process slot), 24(button id)] or 0 |
536 | ;< ebx = pack[16(button x coord), 16(button y coord)] |
||
537 | push ecx edx esi edi |
||
538 | |||
539 | call mouse._.find_sys_window_under_cursor |
||
540 | mov edx, esi |
||
541 | |||
542 | ; check if any process button contains cursor |
||
543 | mov eax, [BTN_ADDR] |
||
544 | mov ecx, [eax] |
||
2384 | hidnplayr | 545 | imul esi, ecx, sizeof.SYS_BUTTON |
1391 | mikedld | 546 | add esi, eax |
547 | inc ecx |
||
2384 | hidnplayr | 548 | add esi, sizeof.SYS_BUTTON |
1391 | mikedld | 549 | |
550 | .next_button: |
||
551 | dec ecx |
||
552 | jz .not_found |
||
553 | |||
2384 | hidnplayr | 554 | add esi, -sizeof.SYS_BUTTON |
1391 | mikedld | 555 | |
556 | ; does it belong to our process? |
||
557 | cmp dx, [esi + SYS_BUTTON.pslot] |
||
558 | jne .next_button |
||
559 | |||
560 | ; does it contain cursor coordinates? |
||
561 | mov eax, [mouse.state.pos.x] |
||
562 | sub eax, [edi + WDATA.box.left] |
||
563 | sub ax, [esi + SYS_BUTTON.left] |
||
564 | jl .next_button |
||
565 | sub ax, [esi + SYS_BUTTON.width] |
||
566 | jge .next_button |
||
567 | mov eax, [mouse.state.pos.y] |
||
568 | sub eax, [edi + WDATA.box.top] |
||
569 | sub ax, [esi + SYS_BUTTON.top] |
||
570 | jl .next_button |
||
571 | sub ax, [esi + SYS_BUTTON.height] |
||
572 | jge .next_button |
||
573 | |||
574 | ; okay, return it |
||
575 | shl edx, 24 |
||
576 | mov eax, dword[esi + SYS_BUTTON.id_hi - 2] |
||
577 | mov ax, [esi + SYS_BUTTON.id_lo] |
||
578 | and eax, 0x0ffffff |
||
579 | or eax, edx |
||
580 | mov ebx, dword[esi + SYS_BUTTON.left - 2] |
||
581 | mov bx, [esi + SYS_BUTTON.top] |
||
582 | jmp .exit |
||
583 | |||
584 | .not_found: |
||
585 | xor eax, eax |
||
586 | xor ebx, ebx |
||
587 | |||
588 | .exit: |
||
589 | pop edi esi edx ecx |
||
590 | ret |
||
591 | |||
592 | align 4 |
||
5851 | pathoswith | 593 | ;----------------------------------------------------------------- |
594 | mouse._.check_sys_window_actions: |
||
1391 | mikedld | 595 | ;< eax = action flags or 0 |
596 | ; is window movable? |
||
597 | test byte[edi + WDATA.cl_titlebar + 3], 0x01 |
||
598 | jnz .no_action |
||
599 | |||
600 | mov eax, [mouse.state.pos.x] |
||
601 | mov ebx, [mouse.state.pos.y] |
||
602 | sub eax, [edi + WDATA.box.left] |
||
603 | sub ebx, [edi + WDATA.box.top] |
||
604 | |||
605 | ; is there a window titlebar under cursor? |
||
606 | push eax |
||
607 | call window._.get_titlebar_height |
||
608 | cmp ebx, eax |
||
609 | pop eax |
||
610 | jl .move_action |
||
611 | |||
612 | ; no there isn't, can it be resized then? |
||
613 | mov dl, [edi + WDATA.fl_wstyle] |
||
614 | and dl, 0x0f |
||
5851 | pathoswith | 615 | ; NOTE: dangerous optimization, revise if window types changed |
616 | ; this currently implies only types 2 and 3 could be resized |
||
1391 | mikedld | 617 | test dl, 2 |
618 | jz .no_action |
||
619 | |||
620 | mov ecx, [edi + WDATA.box.width] |
||
621 | add ecx, -window.BORDER_SIZE |
||
622 | mov edx, [edi + WDATA.box.height] |
||
623 | add edx, -window.BORDER_SIZE |
||
624 | |||
625 | ; is it rolled up? |
||
626 | test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP |
||
627 | jnz .resize_w_or_e_action |
||
628 | |||
629 | cmp eax, window.BORDER_SIZE |
||
630 | jl .resize_w_action |
||
631 | cmp eax, ecx |
||
632 | jg .resize_e_action |
||
633 | cmp ebx, edx |
||
634 | jle .no_action |
||
635 | |||
636 | .resize_s_action: |
||
637 | cmp eax, window.BORDER_SIZE + 10 |
||
638 | jl .resize_sw_action |
||
639 | add ecx, -10 |
||
640 | cmp eax, ecx |
||
641 | jge .resize_se_action |
||
642 | mov eax, mouse.WINDOW_RESIZE_S_FLAG |
||
643 | jmp .exit |
||
644 | |||
645 | .resize_w_or_e_action: |
||
646 | cmp eax, window.BORDER_SIZE + 10 |
||
647 | jl .resize_w_action.direct |
||
648 | add ecx, -10 |
||
649 | cmp eax, ecx |
||
650 | jg .resize_e_action.direct |
||
651 | jmp .no_action |
||
652 | |||
653 | .resize_w_action: |
||
654 | add edx, -10 |
||
655 | cmp ebx, edx |
||
656 | jge .resize_sw_action |
||
657 | .resize_w_action.direct: |
||
658 | mov eax, mouse.WINDOW_RESIZE_W_FLAG |
||
659 | jmp .exit |
||
660 | |||
661 | .resize_e_action: |
||
662 | add edx, -10 |
||
663 | cmp ebx, edx |
||
664 | jge .resize_se_action |
||
665 | .resize_e_action.direct: |
||
666 | mov eax, mouse.WINDOW_RESIZE_E_FLAG |
||
667 | jmp .exit |
||
668 | |||
669 | .resize_sw_action: |
||
670 | mov eax, mouse.WINDOW_RESIZE_SW_FLAG |
||
671 | jmp .exit |
||
672 | |||
673 | .resize_se_action: |
||
674 | mov eax, mouse.WINDOW_RESIZE_SE_FLAG |
||
675 | jmp .exit |
||
676 | |||
677 | .move_action: |
||
678 | mov eax, mouse.WINDOW_MOVE_FLAG |
||
679 | jmp .exit |
||
680 | |||
681 | .no_action: |
||
682 | xor eax, eax |
||
683 | |||
684 | .exit: |
||
685 | ret>>>>> |