Rev 5363 | Rev 5870 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5363 | Rev 5851 | ||
---|---|---|---|
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: 5363 $ |
8 | $Revision: 5851 $ |
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 190... | Line 186... | ||
190 | .last_ticks dd ? |
186 | .last_ticks dd ? |
191 | .action db ? |
187 | .action db ? |
192 | endg |
188 | endg |
Line 193... | Line 189... | ||
193 | 189 | ||
194 | align 4 |
190 | align 4 |
195 | ;------------------------------------------------------------------------------ |
191 | ;----------------------------------------------------------------- |
196 | mouse._.left_button_press_handler: ;/////////////////////////////////////////// |
- | |
197 | ;------------------------------------------------------------------------------ |
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] |
|
198 | ;? Called when left mouse button has been pressed down |
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 |
|
199 | ;------------------------------------------------------------------------------ |
203 | @@: |
200 | test [mouse.state.buttons], not mouse.LEFT_BUTTON_FLAG |
204 | test [mouse.state.buttons], not mouse.LEFT_BUTTON_FLAG |
Line 201... | Line 205... | ||
201 | jnz .exit |
205 | jnz .exit |
202 | 206 | ||
Line 208... | Line 212... | ||
208 | 212 | ||
209 | xchg eax, edx |
213 | xchg eax, edx |
210 | test dl, mouse.WINDOW_MOVE_FLAG |
214 | test dl, mouse.WINDOW_MOVE_FLAG |
Line 211... | Line 215... | ||
211 | jz @f |
215 | 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 |
216 | |
Line 217... | Line 217... | ||
217 | cmp eax, 50 |
217 | bt dword [BTN_DOWN], 24 |
218 | jg @f |
218 | jnc @f |
219 | 219 | ||
Line 252... | Line 252... | ||
252 | test dl, mouse.WINDOW_RESIZE_E_FLAG |
252 | test dl, mouse.WINDOW_RESIZE_E_FLAG |
253 | jz .call_window_handler |
253 | jz .call_window_handler |
254 | call .calculate_e_delta |
254 | call .calculate_e_delta |
Line 255... | Line 255... | ||
255 | 255 | ||
256 | .call_window_handler: |
- | |
257 | ; mov eax, mouse.active_sys_window.old_box |
- | |
258 | ; call sys_window_start_moving_handler |
- | |
259 | 256 | .call_window_handler: |
|
260 | .exit: |
257 | .exit: |
Line 261... | Line 258... | ||
261 | ret |
258 | ret |
262 | 259 | ||
Line 285... | Line 282... | ||
285 | sub eax, [mouse.state.pos.x] |
282 | sub eax, [mouse.state.pos.x] |
286 | mov [mouse.active_sys_window.delta.x], eax |
283 | mov [mouse.active_sys_window.delta.x], eax |
287 | ret |
284 | ret |
Line 288... | Line 285... | ||
288 | 285 | ||
289 | align 4 |
286 | align 4 |
290 | ;------------------------------------------------------------------------------ |
287 | ;----------------------------------------------------------------- |
291 | mouse._.left_button_release_handler: ;///////////////////////////////////////// |
- | |
292 | ;------------------------------------------------------------------------------ |
288 | mouse._.left_button_release_handler: |
293 | ;? Called when left mouse button has been released |
289 | ; Called when left mouse button has been released |
294 | ;------------------------------------------------------------------------------ |
290 | bts dword [BTN_DOWN], 16 |
295 | xor esi, esi |
291 | xor esi, esi |
296 | xchg esi, [mouse.active_sys_window.pslot] |
292 | xchg esi, [mouse.active_sys_window.pslot] |
297 | or esi, esi |
293 | or esi, esi |
Line 310... | Line 306... | ||
310 | 306 | ||
311 | .exit: |
307 | .exit: |
312 | and [mouse.active_sys_window.action], 0 |
308 | and [mouse.active_sys_window.action], 0 |
Line 313... | Line -... | ||
313 | ret |
- | |
314 | - | ||
315 | align 4 |
309 | ret |
316 | ;------------------------------------------------------------------------------ |
- | |
317 | mouse._.right_button_press_handler: ;////////////////////////////////////////// |
310 | |
318 | ;------------------------------------------------------------------------------ |
- | |
319 | ;? Called when right mouse button has been pressed down |
311 | mouse._.right_button_press_handler: |
320 | ;------------------------------------------------------------------------------ |
312 | bts word [BTN_DOWN], 9 |
321 | test [mouse.state.buttons], not mouse.RIGHT_BUTTON_FLAG |
- | |
322 | jnz .exit |
313 | test [mouse.state.buttons], not mouse.RIGHT_BUTTON_FLAG |
323 | 314 | jnz @f |
|
324 | call mouse._.find_sys_window_under_cursor |
315 | call mouse._.find_sys_window_under_cursor |
325 | call mouse._.check_sys_window_actions |
316 | call mouse._.check_sys_window_actions |
326 | test al, mouse.WINDOW_MOVE_FLAG |
- | |
327 | jz .exit |
317 | test al, mouse.WINDOW_MOVE_FLAG |
328 | - | ||
329 | call sys_window_rollup_handler |
- | |
330 | - | ||
Line 331... | Line -... | ||
331 | .exit: |
- | |
332 | ret |
- | |
333 | 318 | jz @f |
|
334 | align 4 |
- | |
335 | ;------------------------------------------------------------------------------ |
319 | jmp sys_window_rollup_handler |
336 | mouse._.right_button_release_handler: ;//////////////////////////////////////// |
- | |
- | 320 | ||
337 | ;------------------------------------------------------------------------------ |
321 | mouse._.right_button_release_handler: |
Line 338... | Line -... | ||
338 | ;? Called when right mouse button has been released |
- | |
339 | ;------------------------------------------------------------------------------ |
- | |
340 | ret |
322 | bts dword [BTN_DOWN], 17 |
341 | - | ||
342 | align 4 |
323 | @@: |
343 | ;------------------------------------------------------------------------------ |
- | |
344 | mouse._.middle_button_press_handler: ;///////////////////////////////////////// |
324 | ret |
Line 345... | Line -... | ||
345 | ;------------------------------------------------------------------------------ |
- | |
346 | ;? Called when middle mouse button has been pressed down |
- | |
347 | ;------------------------------------------------------------------------------ |
325 | |
348 | ret |
- | |
349 | 326 | mouse._.middle_button_press_handler: |
|
350 | align 4 |
- | |
351 | ;------------------------------------------------------------------------------ |
327 | bts word [BTN_DOWN], 10 |
Line 352... | Line 328... | ||
352 | mouse._.middle_button_release_handler: ;/////////////////////////////////////// |
328 | ret |
353 | ;------------------------------------------------------------------------------ |
329 | |
354 | ;? Called when middle mouse button has been released |
330 | mouse._.middle_button_release_handler: |
355 | ;------------------------------------------------------------------------------ |
- | |
356 | ret |
331 | bts dword [BTN_DOWN], 18 |
357 | - | ||
358 | align 4 |
332 | ret |
359 | ;------------------------------------------------------------------------------ |
333 | |
360 | mouse._.move_handler: ;//////////////////////////////////////////////////////// |
- | |
361 | ;------------------------------------------------------------------------------ |
334 | align 4 |
362 | ;? Called when cursor has been moved |
335 | ;----------------------------------------------------------------- |
Line 363... | Line 336... | ||
363 | ;------------------------------------------------------------------------------ |
336 | mouse._.move_handler: |
364 | ;> eax = old x coord |
337 | ; Called when cursor has been moved |
Line 512... | Line 485... | ||
512 | 485 | ||
513 | .exit: |
486 | .exit: |
Line 514... | Line 487... | ||
514 | ret |
487 | ret |
515 | 488 | ||
516 | align 4 |
489 | align 4 |
517 | ;------------------------------------------------------------------------------ |
- | |
518 | mouse._.find_sys_window_under_cursor: ;//////////////////////////////////////// |
490 | ;----------------------------------------------------------------- |
519 | ;------------------------------------------------------------------------------ |
491 | mouse._.find_sys_window_under_cursor: |
520 | ;? Find system window object which is currently visible on screen and has |
- | |
521 | ;? mouse cursor within its bounds |
492 | ; Find system window object which is currently visible on screen |
522 | ;------------------------------------------------------------------------------ |
493 | ; and has mouse cursor within its bounds |
523 | ;< esi = process slot |
- | |
524 | ;< edi = pointer to WDATA struct |
494 | ;< esi = process slot |
525 | ;------------------------------------------------------------------------------ |
495 | ;< edi = pointer to WDATA struct |
Line 526... | Line 496... | ||
526 | mov esi, [mouse.state.pos.y] |
496 | mov esi, [mouse.state.pos.y] |
527 | mov esi, [d_width_calc_area + esi*4] |
497 | mov esi, [d_width_calc_area + esi*4] |
Line 533... | Line 503... | ||
533 | shl edi, 5 |
503 | shl edi, 5 |
534 | add edi, window_data |
504 | add edi, window_data |
535 | ret |
505 | ret |
Line 536... | Line 506... | ||
536 | 506 | ||
537 | align 4 |
507 | align 4 |
538 | ;------------------------------------------------------------------------------ |
508 | ;----------------------------------------------------------------- |
539 | mouse._.activate_sys_window_under_cursor: ;//////////////////////////////////// |
- | |
540 | ;------------------------------------------------------------------------------ |
- | |
541 | ;? |
- | |
542 | ;------------------------------------------------------------------------------ |
509 | mouse._.activate_sys_window_under_cursor: |
543 | ; activate and redraw window under cursor (if necessary) |
510 | ; activate and redraw window under cursor (if necessary) |
544 | call mouse._.find_sys_window_under_cursor |
511 | call mouse._.find_sys_window_under_cursor |
545 | movzx esi, word[WIN_STACK + esi * 2] |
512 | movzx esi, word[WIN_STACK + esi * 2] |
546 | lea esi, [WIN_POS + esi * 2] |
513 | lea esi, [WIN_POS + esi * 2] |
Line 547... | Line 514... | ||
547 | jmp waredraw |
514 | jmp waredraw |
548 | 515 | ||
549 | align 4 |
516 | align 4 |
550 | ;------------------------------------------------------------------------------ |
- | |
551 | mouse._.find_sys_button_under_cursor: ;//////////////////////////////////////// |
517 | ;----------------------------------------------------------------- |
552 | ;------------------------------------------------------------------------------ |
518 | 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 |
519 | ; Find system button object which is currently visible on screen |
555 | ;------------------------------------------------------------------------------ |
520 | ; 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)] |
521 | ;< eax = pack[8(process slot), 24(button id)] or 0 |
Line 558... | Line 522... | ||
558 | ;------------------------------------------------------------------------------ |
522 | ;< ebx = pack[16(button x coord), 16(button y coord)] |
559 | push ecx edx esi edi |
523 | push ecx edx esi edi |
Line 610... | Line 574... | ||
610 | .exit: |
574 | .exit: |
611 | pop edi esi edx ecx |
575 | pop edi esi edx ecx |
612 | ret |
576 | ret |
Line 613... | Line 577... | ||
613 | 577 | ||
614 | align 4 |
578 | align 4 |
615 | ;------------------------------------------------------------------------------ |
579 | ;----------------------------------------------------------------- |
616 | mouse._.check_sys_window_actions: ;//////////////////////////////////////////// |
- | |
617 | ;------------------------------------------------------------------------------ |
- | |
618 | ;? |
- | |
619 | ;------------------------------------------------------------------------------ |
580 | mouse._.check_sys_window_actions: |
620 | ;< eax = action flags or 0 |
- | |
621 | ;------------------------------------------------------------------------------ |
581 | ;< eax = action flags or 0 |
622 | ; is window movable? |
582 | ; is window movable? |
623 | test byte[edi + WDATA.cl_titlebar + 3], 0x01 |
583 | test byte[edi + WDATA.cl_titlebar + 3], 0x01 |
Line 624... | Line 584... | ||
624 | jnz .no_action |
584 | jnz .no_action |
Line 636... | Line 596... | ||
636 | jl .move_action |
596 | jl .move_action |
Line 637... | Line 597... | ||
637 | 597 | ||
638 | ; no there isn't, can it be resized then? |
598 | ; no there isn't, can it be resized then? |
639 | mov dl, [edi + WDATA.fl_wstyle] |
599 | mov dl, [edi + WDATA.fl_wstyle] |
640 | and dl, 0x0f |
600 | and dl, 0x0f |
641 | ; NOTE: dangerous optimization, revise if window types changed; |
601 | ; NOTE: dangerous optimization, revise if window types changed |
642 | ; this currently implies only types 2 and 3 could be resized |
602 | ; this currently implies only types 2 and 3 could be resized |
643 | test dl, 2 |
603 | test dl, 2 |
Line 644... | Line 604... | ||
644 | jz .no_action |
604 | jz .no_action |