9,9 → 9,9 |
|
include 'mousepointer.inc' |
|
;================================ |
;/////// public functions /////// |
;================================ |
;============================================================================== |
;///// public functions /////////////////////////////////////////////////////// |
;============================================================================== |
|
mouse.LEFT_BUTTON_FLAG = 0001b |
mouse.RIGHT_BUTTON_FLAG = 0010b |
36,10 → 36,14 |
mouse.WINDOW_RESIZE_E_FLAG |
|
align 4 |
;----------------------------------------------------------------- |
mouse_check_events: |
; Check if mouse buttons state or cursor position has changed |
;------------------------------------------------------------------------------ |
mouse_check_events: ;////////////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Check if mouse buttons state or cursor position has changed and call |
;? appropriate handlers |
;------------------------------------------------------------------------------ |
push eax ebx |
|
mov al, [BTN_DOWN] |
mov bl, [mouse.state.buttons] |
and al, mouse.BUTTONS_MASK |
59,8 → 63,8 |
; yes it is, activate window user is pointing at, if needed |
call mouse._.activate_sys_window_under_cursor |
|
; NOTE: this code wouldn't be necessary if we knew |
; that window did already redraw itself after call above |
; NOTE: this code wouldn't be necessary if we knew window did |
; already redraw itself after call above |
or eax, eax |
jnz .exit |
|
158,9 → 162,9 |
jnz mouse._.middle_button_press_handler |
jmp mouse._.middle_button_release_handler |
|
;=============================== |
;////// private functions ////// |
;=============================== |
;============================================================================== |
;///// private functions ////////////////////////////////////////////////////// |
;============================================================================== |
|
uglobal |
mouse.state: |
168,7 → 172,7 |
.buttons db ? |
|
; NOTE: since there's no unique and lifetime-constant button identifiers, |
; we are using two dwords to identify each of them: |
; we're using two dwords to identify each of them: |
; * pbid - process slot (high 8 bits) and button id (low 24 bits) pack |
; * coord - left (high 16 bits) and top (low 16 bits) coordinates pack |
align 4 |
188,19 → 192,11 |
endg |
|
align 4 |
;----------------------------------------------------------------- |
mouse._.left_button_press_handler: |
; Called when left mouse button has been pressed down |
bts word [BTN_DOWN], 8 |
mov eax, [timer_ticks] |
mov ebx, eax |
xchg ebx, [mouse.active_sys_window.last_ticks] |
sub eax, ebx |
movzx ebx, [mouse_doubleclick_delay] |
cmp eax, ebx |
jg @f |
bts dword [BTN_DOWN], 24 |
@@: |
;------------------------------------------------------------------------------ |
mouse._.left_button_press_handler: ;/////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Called when left mouse button has been pressed down |
;------------------------------------------------------------------------------ |
test [mouse.state.buttons], not mouse.LEFT_BUTTON_FLAG |
jnz .exit |
|
214,8 → 210,12 |
test dl, mouse.WINDOW_MOVE_FLAG |
jz @f |
|
bt dword [BTN_DOWN], 24 |
jnc @f |
mov eax, [timer_ticks] |
mov ebx, eax |
xchg ebx, [mouse.active_sys_window.last_ticks] |
sub eax, ebx |
cmp eax, 50 |
jg @f |
|
mov [mouse.active_sys_window.last_ticks], 0 |
call sys_window_maximize_handler |
254,6 → 254,9 |
call .calculate_e_delta |
|
.call_window_handler: |
; mov eax, mouse.active_sys_window.old_box |
; call sys_window_start_moving_handler |
|
.exit: |
ret |
|
284,10 → 287,11 |
ret |
|
align 4 |
;----------------------------------------------------------------- |
mouse._.left_button_release_handler: |
; Called when left mouse button has been released |
bts dword [BTN_DOWN], 16 |
;------------------------------------------------------------------------------ |
mouse._.left_button_release_handler: ;///////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Called when left mouse button has been released |
;------------------------------------------------------------------------------ |
xor esi, esi |
xchg esi, [mouse.active_sys_window.pslot] |
or esi, esi |
308,35 → 312,58 |
and [mouse.active_sys_window.action], 0 |
ret |
|
mouse._.right_button_press_handler: |
bts word [BTN_DOWN], 9 |
align 4 |
;------------------------------------------------------------------------------ |
mouse._.right_button_press_handler: ;////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Called when right mouse button has been pressed down |
;------------------------------------------------------------------------------ |
test [mouse.state.buttons], not mouse.RIGHT_BUTTON_FLAG |
jnz @f |
jnz .exit |
|
call mouse._.find_sys_window_under_cursor |
call mouse._.check_sys_window_actions |
test al, mouse.WINDOW_MOVE_FLAG |
jz @f |
jmp sys_window_rollup_handler |
jz .exit |
|
mouse._.right_button_release_handler: |
bts dword [BTN_DOWN], 17 |
@@: |
call sys_window_rollup_handler |
|
.exit: |
ret |
|
mouse._.middle_button_press_handler: |
bts word [BTN_DOWN], 10 |
align 4 |
;------------------------------------------------------------------------------ |
mouse._.right_button_release_handler: ;//////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Called when right mouse button has been released |
;------------------------------------------------------------------------------ |
ret |
|
mouse._.middle_button_release_handler: |
bts dword [BTN_DOWN], 18 |
align 4 |
;------------------------------------------------------------------------------ |
mouse._.middle_button_press_handler: ;///////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Called when middle mouse button has been pressed down |
;------------------------------------------------------------------------------ |
ret |
|
align 4 |
;----------------------------------------------------------------- |
mouse._.move_handler: |
; Called when cursor has been moved |
;------------------------------------------------------------------------------ |
mouse._.middle_button_release_handler: ;/////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Called when middle mouse button has been released |
;------------------------------------------------------------------------------ |
ret |
|
align 4 |
;------------------------------------------------------------------------------ |
mouse._.move_handler: ;//////////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Called when cursor has been moved |
;------------------------------------------------------------------------------ |
;> eax = old x coord |
;> ebx = old y coord |
;------------------------------------------------------------------------------ |
cmp [mouse.active_sys_button.pbid], 0 |
jnz .exit |
|
487,12 → 514,15 |
ret |
|
align 4 |
;----------------------------------------------------------------- |
mouse._.find_sys_window_under_cursor: |
; Find system window object which is currently visible on screen |
; and has mouse cursor within its bounds |
;------------------------------------------------------------------------------ |
mouse._.find_sys_window_under_cursor: ;//////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Find system window object which is currently visible on screen and has |
;? mouse cursor within its bounds |
;------------------------------------------------------------------------------ |
;< esi = process slot |
;< edi = pointer to WDATA struct |
;------------------------------------------------------------------------------ |
mov esi, [mouse.state.pos.y] |
mov esi, [d_width_calc_area + esi*4] |
|
505,8 → 535,11 |
ret |
|
align 4 |
;----------------------------------------------------------------- |
mouse._.activate_sys_window_under_cursor: |
;------------------------------------------------------------------------------ |
mouse._.activate_sys_window_under_cursor: ;//////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
; activate and redraw window under cursor (if necessary) |
call mouse._.find_sys_window_under_cursor |
movzx esi, word[WIN_STACK + esi * 2] |
514,12 → 547,15 |
jmp waredraw |
|
align 4 |
;----------------------------------------------------------------- |
mouse._.find_sys_button_under_cursor: |
; Find system button object which is currently visible on screen |
; and has mouse cursor within its bounds |
;------------------------------------------------------------------------------ |
mouse._.find_sys_button_under_cursor: ;//////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Find system button object which is currently visible on screen and has |
;? mouse cursor within its bounds |
;------------------------------------------------------------------------------ |
;< eax = pack[8(process slot), 24(button id)] or 0 |
;< ebx = pack[16(button x coord), 16(button y coord)] |
;------------------------------------------------------------------------------ |
push ecx edx esi edi |
|
call mouse._.find_sys_window_under_cursor |
576,9 → 612,13 |
ret |
|
align 4 |
;----------------------------------------------------------------- |
mouse._.check_sys_window_actions: |
;------------------------------------------------------------------------------ |
mouse._.check_sys_window_actions: ;//////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
;< eax = action flags or 0 |
;------------------------------------------------------------------------------ |
; is window movable? |
test byte[edi + WDATA.cl_titlebar + 3], 0x01 |
jnz .no_action |
598,7 → 638,7 |
; no there isn't, can it be resized then? |
mov dl, [edi + WDATA.fl_wstyle] |
and dl, 0x0f |
; NOTE: dangerous optimization, revise if window types changed |
; NOTE: dangerous optimization, revise if window types changed; |
; this currently implies only types 2 and 3 could be resized |
test dl, 2 |
jz .no_action |