Rev 5596 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5596 | Rev 5984 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;; Copyright (C) KolibriOS team 2010-2015. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2010-2015. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 7... | Line 7... | ||
7 | 7 | ||
Line 8... | Line 8... | ||
8 | $Revision: 5596 $ |
8 | $Revision: 5984 $ |
Line 9... | Line 9... | ||
9 | 9 | ||
10 | include 'mousepointer.inc' |
10 | include 'mousepointer.inc' |
11 | 11 | ||
Line 12... | Line 12... | ||
12 | ;============================================================================== |
12 | ;================================ |
13 | ;///// public functions /////////////////////////////////////////////////////// |
13 | ;/////// public functions /////// |
14 | ;============================================================================== |
14 | ;================================ |
Line 34... | Line 34... | ||
34 | mouse.WINDOW_RESIZE_SE_FLAG = \ |
34 | mouse.WINDOW_RESIZE_SE_FLAG = \ |
35 | mouse.WINDOW_RESIZE_S_FLAG or \ |
35 | mouse.WINDOW_RESIZE_S_FLAG or \ |
36 | mouse.WINDOW_RESIZE_E_FLAG |
36 | mouse.WINDOW_RESIZE_E_FLAG |
Line 37... | Line 37... | ||
37 | 37 | ||
38 | align 4 |
38 | align 4 |
39 | ;------------------------------------------------------------------------------ |
39 | ;----------------------------------------------------------------- |
40 | mouse_check_events: ;////////////////////////////////////////////////////////// |
- | |
41 | ;------------------------------------------------------------------------------ |
40 | mouse_check_events: |
42 | ;? Check if mouse buttons state or cursor position has changed and call |
- | |
43 | ;? appropriate handlers |
- | |
44 | ;------------------------------------------------------------------------------ |
41 | ; Check if mouse buttons state or cursor position has changed |
45 | push eax ebx |
- | |
46 | 42 | push eax ebx |
|
47 | mov al, [BTN_DOWN] |
43 | mov al, [BTN_DOWN] |
48 | mov bl, [mouse.state.buttons] |
44 | mov bl, [mouse.state.buttons] |
49 | and al, mouse.BUTTONS_MASK |
45 | and al, mouse.BUTTONS_MASK |
50 | mov cl, al |
46 | mov cl, al |
Line 61... | Line 57... | ||
61 | jnz .check_buttons_released |
57 | jnz .check_buttons_released |
Line 62... | Line 58... | ||
62 | 58 | ||
63 | ; yes it is, activate window user is pointing at, if needed |
59 | ; yes it is, activate window user is pointing at, if needed |
Line 64... | Line 60... | ||
64 | call mouse._.activate_sys_window_under_cursor |
60 | call mouse._.activate_sys_window_under_cursor |
65 | 61 | ||
66 | ; NOTE: this code wouldn't be necessary if we knew window did |
62 | ; NOTE: this code wouldn't be necessary if we knew |
67 | ; already redraw itself after call above |
63 | ; that window did already redraw itself after call above |
Line 68... | Line 64... | ||
68 | or eax, eax |
64 | or eax, eax |
69 | jnz .exit |
65 | jnz .exit |
Line 160... | Line 156... | ||
160 | .call_middle_button_handler: |
156 | .call_middle_button_handler: |
161 | test eax, mouse.MIDDLE_BUTTON_FLAG |
157 | test eax, mouse.MIDDLE_BUTTON_FLAG |
162 | jnz mouse._.middle_button_press_handler |
158 | jnz mouse._.middle_button_press_handler |
163 | jmp mouse._.middle_button_release_handler |
159 | jmp mouse._.middle_button_release_handler |
Line 164... | Line 160... | ||
164 | 160 | ||
165 | ;============================================================================== |
161 | ;=============================== |
166 | ;///// private functions ////////////////////////////////////////////////////// |
162 | ;////// private functions ////// |
Line 167... | Line 163... | ||
167 | ;============================================================================== |
163 | ;=============================== |
168 | 164 | ||
169 | uglobal |
165 | uglobal |
170 | mouse.state: |
166 | mouse.state: |
Line 171... | Line 167... | ||
171 | .pos POINT |
167 | .pos POINT |
172 | .buttons db ? |
168 | .buttons db ? |
173 | 169 | ||
174 | ; NOTE: since there's no unique and lifetime-constant button identifiers, |
170 | ; NOTE: since there's no unique and lifetime-constant button identifiers, |
175 | ; we're using two dwords to identify each of them: |
171 | ; we are using two dwords to identify each of them: |
176 | ; * pbid - process slot (high 8 bits) and button id (low 24 bits) pack |
172 | ; * pbid - process slot (high 8 bits) and button id (low 24 bits) pack |
177 | ; * coord - left (high 16 bits) and top (low 16 bits) coordinates pack |
173 | ; * coord - left (high 16 bits) and top (low 16 bits) coordinates pack |
Line 189... | Line 185... | ||
189 | .delta POINT |
185 | .delta POINT |
190 | .last_ticks dd ? |
186 | .last_ticks dd ? |
191 | .action db ? |
187 | .action db ? |
192 | endg |
188 | endg |
Line -... | Line 189... | ||
- | 189 | ||
- | 190 | iglobal |
|
- | 191 | fl_moving db 0 |
|
- | 192 | rb 3 |
|
- | 193 | endg |
|
193 | 194 | ||
194 | align 4 |
195 | align 4 |
195 | ;------------------------------------------------------------------------------ |
196 | ;----------------------------------------------------------------- |
196 | mouse._.left_button_press_handler: ;/////////////////////////////////////////// |
- | |
197 | ;------------------------------------------------------------------------------ |
197 | mouse._.left_button_press_handler: |
- | 198 | ; Called when left mouse button has been pressed down |
|
- | 199 | bts word [BTN_DOWN], 8 |
|
- | 200 | mov eax, [timer_ticks] |
|
198 | ;? Called when left mouse button has been pressed down |
201 | mov ebx, eax |
- | 202 | xchg ebx, [mouse.active_sys_window.last_ticks] |
|
- | 203 | sub eax, ebx |
|
- | 204 | movzx ebx, [mouse_doubleclick_delay] |
|
- | 205 | cmp eax, ebx |
|
- | 206 | jg @f |
|
- | 207 | bts dword [BTN_DOWN], 24 |
|
199 | ;------------------------------------------------------------------------------ |
208 | @@: |
200 | test [mouse.state.buttons], not mouse.LEFT_BUTTON_FLAG |
209 | test [mouse.state.buttons], not mouse.LEFT_BUTTON_FLAG |
Line 201... | Line 210... | ||
201 | jnz .exit |
210 | jnz .exit |
202 | 211 | ||
Line 208... | Line 217... | ||
208 | 217 | ||
209 | xchg eax, edx |
218 | xchg eax, edx |
210 | test dl, mouse.WINDOW_MOVE_FLAG |
219 | test dl, mouse.WINDOW_MOVE_FLAG |
Line 211... | Line 220... | ||
211 | jz @f |
220 | jz @f |
212 | - | ||
213 | mov eax, [timer_ticks] |
- | |
214 | mov ebx, eax |
- | |
215 | xchg ebx, [mouse.active_sys_window.last_ticks] |
- | |
216 | sub eax, ebx |
221 | |
Line 217... | Line 222... | ||
217 | cmp eax, 50 |
222 | bt dword [BTN_DOWN], 24 |
218 | jg @f |
223 | jnc @f |
219 | 224 | ||
Line 252... | Line 257... | ||
252 | test dl, mouse.WINDOW_RESIZE_E_FLAG |
257 | test dl, mouse.WINDOW_RESIZE_E_FLAG |
253 | jz .call_window_handler |
258 | jz .call_window_handler |
254 | call .calculate_e_delta |
259 | call .calculate_e_delta |
Line 255... | Line 260... | ||
255 | 260 | ||
256 | .call_window_handler: |
- | |
257 | ; mov eax, mouse.active_sys_window.old_box |
- | |
258 | ; call sys_window_start_moving_handler |
- | |
259 | 261 | .call_window_handler: |
|
260 | .exit: |
262 | .exit: |
Line 261... | Line 263... | ||
261 | ret |
263 | ret |
262 | 264 | ||
Line 285... | Line 287... | ||
285 | sub eax, [mouse.state.pos.x] |
287 | sub eax, [mouse.state.pos.x] |
286 | mov [mouse.active_sys_window.delta.x], eax |
288 | mov [mouse.active_sys_window.delta.x], eax |
287 | ret |
289 | ret |
Line 288... | Line 290... | ||
288 | 290 | ||
289 | align 4 |
291 | align 4 |
290 | ;------------------------------------------------------------------------------ |
292 | ;----------------------------------------------------------------- |
291 | mouse._.left_button_release_handler: ;///////////////////////////////////////// |
- | |
292 | ;------------------------------------------------------------------------------ |
293 | mouse._.left_button_release_handler: |
293 | ;? Called when left mouse button has been released |
294 | ; Called when left mouse button has been released |
294 | ;------------------------------------------------------------------------------ |
295 | bts dword [BTN_DOWN], 16 |
295 | xor esi, esi |
296 | xor esi, esi |
296 | xchg esi, [mouse.active_sys_window.pslot] |
297 | xchg esi, [mouse.active_sys_window.pslot] |
297 | or esi, esi |
298 | or esi, esi |
Line 308... | Line 309... | ||
308 | mov ebx, mouse.active_sys_window.new_box |
309 | mov ebx, mouse.active_sys_window.new_box |
309 | call sys_window_end_moving_handler |
310 | call sys_window_end_moving_handler |
Line 310... | Line 311... | ||
310 | 311 | ||
311 | .exit: |
312 | .exit: |
- | 313 | and [mouse.active_sys_window.action], 0 |
|
312 | and [mouse.active_sys_window.action], 0 |
314 | mov [fl_moving], 0 |
Line 313... | Line -... | ||
313 | ret |
- | |
314 | - | ||
315 | align 4 |
315 | ret |
316 | ;------------------------------------------------------------------------------ |
- | |
317 | mouse._.right_button_press_handler: ;////////////////////////////////////////// |
316 | |
318 | ;------------------------------------------------------------------------------ |
- | |
319 | ;? Called when right mouse button has been pressed down |
317 | mouse._.right_button_press_handler: |
320 | ;------------------------------------------------------------------------------ |
318 | bts word [BTN_DOWN], 9 |
321 | test [mouse.state.buttons], not mouse.RIGHT_BUTTON_FLAG |
- | |
322 | jnz .exit |
319 | test [mouse.state.buttons], not mouse.RIGHT_BUTTON_FLAG |
323 | 320 | jnz @f |
|
324 | call mouse._.find_sys_window_under_cursor |
321 | call mouse._.find_sys_window_under_cursor |
325 | call mouse._.check_sys_window_actions |
322 | call mouse._.check_sys_window_actions |
326 | test al, mouse.WINDOW_MOVE_FLAG |
- | |
327 | jz .exit |
323 | test al, mouse.WINDOW_MOVE_FLAG |
Line -... | Line 324... | ||
- | 324 | jz @f |
|
- | 325 | jmp sys_window_rollup_handler |
|
328 | 326 | ||
329 | call sys_window_rollup_handler |
327 | mouse._.right_button_release_handler: |
Line 330... | Line -... | ||
330 | - | ||
331 | .exit: |
- | |
332 | ret |
328 | bts dword [BTN_DOWN], 17 |
333 | - | ||
334 | align 4 |
329 | @@: |
335 | ;------------------------------------------------------------------------------ |
- | |
336 | mouse._.right_button_release_handler: ;//////////////////////////////////////// |
330 | ret |
Line 337... | Line -... | ||
337 | ;------------------------------------------------------------------------------ |
- | |
338 | ;? Called when right mouse button has been released |
- | |
339 | ;------------------------------------------------------------------------------ |
331 | |
340 | ret |
- | |
341 | 332 | mouse._.middle_button_press_handler: |
|
342 | align 4 |
- | |
343 | ;------------------------------------------------------------------------------ |
333 | bts word [BTN_DOWN], 10 |
Line 344... | Line 334... | ||
344 | mouse._.middle_button_press_handler: ;///////////////////////////////////////// |
334 | ret |
345 | ;------------------------------------------------------------------------------ |
335 | |
346 | ;? Called when middle mouse button has been pressed down |
- | |
347 | ;------------------------------------------------------------------------------ |
- | |
348 | ret |
336 | mouse._.middle_button_release_handler: |
349 | - | ||
350 | align 4 |
- | |
351 | ;------------------------------------------------------------------------------ |
- | |
352 | mouse._.middle_button_release_handler: ;/////////////////////////////////////// |
- | |
353 | ;------------------------------------------------------------------------------ |
- | |
354 | ;? Called when middle mouse button has been released |
- | |
355 | ;------------------------------------------------------------------------------ |
- | |
356 | ret |
337 | bts dword [BTN_DOWN], 18 |
357 | - | ||
358 | align 4 |
338 | ret |
359 | ;------------------------------------------------------------------------------ |
339 | |
360 | mouse._.move_handler: ;//////////////////////////////////////////////////////// |
- | |
361 | ;------------------------------------------------------------------------------ |
340 | align 4 |
362 | ;? Called when cursor has been moved |
341 | ;----------------------------------------------------------------- |
Line 363... | Line 342... | ||
363 | ;------------------------------------------------------------------------------ |
342 | mouse._.move_handler: |
364 | ;> eax = old x coord |
343 | ; Called when cursor has been moved |
Line 505... | Line 484... | ||
505 | repe |
484 | repe |
506 | cmpsd |
485 | cmpsd |
507 | pop esi |
486 | pop esi |
508 | je .exit |
487 | je .exit |
Line -... | Line 488... | ||
- | 488 | ||
- | 489 | test [fl_moving], 1 |
|
- | 490 | jnz @f |
|
- | 491 | ||
- | 492 | mov [fl_moving], 1 |
|
- | 493 | push edi |
|
- | 494 | mov edi, esi |
|
- | 495 | shl edi, 5 |
|
- | 496 | add edi, WDATA.box + window_data |
|
- | 497 | call window._.draw_negative_box |
|
- | 498 | pop edi |
|
- | 499 | @@: |
|
- | 500 | ||
509 | 501 | ||
510 | mov [mouse.active_sys_window.last_ticks], 0 |
502 | mov [mouse.active_sys_window.last_ticks], 0 |
Line 511... | Line 503... | ||
511 | call sys_window_moving_handler |
503 | call sys_window_moving_handler |
512 | 504 | ||
Line 513... | Line 505... | ||
513 | .exit: |
505 | .exit: |
514 | ret |
506 | ret |
515 | 507 | ||
516 | align 4 |
- | |
517 | ;------------------------------------------------------------------------------ |
508 | align 4 |
518 | mouse._.find_sys_window_under_cursor: ;//////////////////////////////////////// |
509 | ;----------------------------------------------------------------- |
519 | ;------------------------------------------------------------------------------ |
- | |
520 | ;? Find system window object which is currently visible on screen and has |
510 | mouse._.find_sys_window_under_cursor: |
521 | ;? mouse cursor within its bounds |
511 | ; Find system window object which is currently visible on screen |
522 | ;------------------------------------------------------------------------------ |
- | |
523 | ;< esi = process slot |
512 | ; and has mouse cursor within its bounds |
524 | ;< edi = pointer to WDATA struct |
513 | ;< esi = process slot |
Line 525... | Line 514... | ||
525 | ;------------------------------------------------------------------------------ |
514 | ;< edi = pointer to WDATA struct |
526 | mov esi, [mouse.state.pos.y] |
515 | mov esi, [mouse.state.pos.y] |
Line 533... | Line 522... | ||
533 | shl edi, 5 |
522 | shl edi, 5 |
534 | add edi, window_data |
523 | add edi, window_data |
535 | ret |
524 | ret |
Line 536... | Line 525... | ||
536 | 525 | ||
537 | align 4 |
526 | align 4 |
538 | ;------------------------------------------------------------------------------ |
527 | ;----------------------------------------------------------------- |
539 | mouse._.activate_sys_window_under_cursor: ;//////////////////////////////////// |
- | |
540 | ;------------------------------------------------------------------------------ |
- | |
541 | ;? |
- | |
542 | ;------------------------------------------------------------------------------ |
528 | mouse._.activate_sys_window_under_cursor: |
543 | ; activate and redraw window under cursor (if necessary) |
529 | ; activate and redraw window under cursor (if necessary) |
544 | call mouse._.find_sys_window_under_cursor |
530 | call mouse._.find_sys_window_under_cursor |
545 | movzx esi, word[WIN_STACK + esi * 2] |
531 | movzx esi, word[WIN_STACK + esi * 2] |
546 | lea esi, [WIN_POS + esi * 2] |
532 | lea esi, [WIN_POS + esi * 2] |
Line 547... | Line 533... | ||
547 | jmp waredraw |
533 | jmp waredraw |
548 | 534 | ||
549 | align 4 |
535 | align 4 |
550 | ;------------------------------------------------------------------------------ |
- | |
551 | mouse._.find_sys_button_under_cursor: ;//////////////////////////////////////// |
536 | ;----------------------------------------------------------------- |
552 | ;------------------------------------------------------------------------------ |
537 | mouse._.find_sys_button_under_cursor: |
553 | ;? Find system button object which is currently visible on screen and has |
- | |
554 | ;? mouse cursor within its bounds |
538 | ; Find system button object which is currently visible on screen |
555 | ;------------------------------------------------------------------------------ |
539 | ; and has mouse cursor within its bounds |
556 | ;< eax = pack[8(process slot), 24(button id)] or 0 |
- | |
557 | ;< ebx = pack[16(button x coord), 16(button y coord)] |
540 | ;< eax = pack[8(process slot), 24(button id)] or 0 |
Line 558... | Line 541... | ||
558 | ;------------------------------------------------------------------------------ |
541 | ;< ebx = pack[16(button x coord), 16(button y coord)] |
559 | push ecx edx esi edi |
542 | push ecx edx esi edi |
Line 610... | Line 593... | ||
610 | .exit: |
593 | .exit: |
611 | pop edi esi edx ecx |
594 | pop edi esi edx ecx |
612 | ret |
595 | ret |
Line 613... | Line 596... | ||
613 | 596 | ||
614 | align 4 |
597 | align 4 |
615 | ;------------------------------------------------------------------------------ |
598 | ;----------------------------------------------------------------- |
616 | mouse._.check_sys_window_actions: ;//////////////////////////////////////////// |
- | |
617 | ;------------------------------------------------------------------------------ |
- | |
618 | ;? |
- | |
619 | ;------------------------------------------------------------------------------ |
599 | mouse._.check_sys_window_actions: |
620 | ;< eax = action flags or 0 |
- | |
621 | ;------------------------------------------------------------------------------ |
600 | ;< eax = action flags or 0 |
622 | ; is window movable? |
601 | ; is window movable? |
623 | test byte[edi + WDATA.cl_titlebar + 3], 0x01 |
602 | test byte[edi + WDATA.cl_titlebar + 3], 0x01 |
Line 624... | Line 603... | ||
624 | jnz .no_action |
603 | jnz .no_action |
Line 636... | Line 615... | ||
636 | jl .move_action |
615 | jl .move_action |
Line 637... | Line 616... | ||
637 | 616 | ||
638 | ; no there isn't, can it be resized then? |
617 | ; no there isn't, can it be resized then? |
639 | mov dl, [edi + WDATA.fl_wstyle] |
618 | mov dl, [edi + WDATA.fl_wstyle] |
640 | and dl, 0x0f |
619 | and dl, 0x0f |
641 | ; NOTE: dangerous optimization, revise if window types changed; |
620 | ; NOTE: dangerous optimization, revise if window types changed |
642 | ; this currently implies only types 2 and 3 could be resized |
621 | ; this currently implies only types 2 and 3 could be resized |
643 | test dl, 2 |
622 | test dl, 2 |
Line 644... | Line 623... | ||
644 | jz .no_action |
623 | jz .no_action |