2010-02-06 20:08:19 +01:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2015-01-08 21:10:22 +01:00
|
|
|
;; Copyright (C) KolibriOS team 2010-2015. All rights reserved. ;;
|
2010-02-06 20:08:19 +01:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2010-07-28 13:41:05 +02:00
|
|
|
$Revision$
|
2010-02-06 20:08:19 +01:00
|
|
|
|
|
|
|
include 'mousepointer.inc'
|
|
|
|
|
2015-10-16 21:00:13 +02:00
|
|
|
;================================
|
|
|
|
;/////// public functions ///////
|
|
|
|
;================================
|
2010-02-06 20:08:19 +01:00
|
|
|
|
|
|
|
mouse.LEFT_BUTTON_FLAG = 0001b
|
|
|
|
mouse.RIGHT_BUTTON_FLAG = 0010b
|
|
|
|
mouse.MIDDLE_BUTTON_FLAG = 0100b
|
|
|
|
|
|
|
|
mouse.BUTTONS_MASK = \
|
|
|
|
mouse.LEFT_BUTTON_FLAG or \
|
|
|
|
mouse.RIGHT_BUTTON_FLAG or \
|
|
|
|
mouse.MIDDLE_BUTTON_FLAG
|
|
|
|
|
|
|
|
mouse.WINDOW_RESIZE_N_FLAG = 000001b
|
|
|
|
mouse.WINDOW_RESIZE_W_FLAG = 000010b
|
|
|
|
mouse.WINDOW_RESIZE_S_FLAG = 000100b
|
|
|
|
mouse.WINDOW_RESIZE_E_FLAG = 001000b
|
|
|
|
mouse.WINDOW_MOVE_FLAG = 010000b
|
|
|
|
|
|
|
|
mouse.WINDOW_RESIZE_SW_FLAG = \
|
|
|
|
mouse.WINDOW_RESIZE_S_FLAG or \
|
|
|
|
mouse.WINDOW_RESIZE_W_FLAG
|
|
|
|
mouse.WINDOW_RESIZE_SE_FLAG = \
|
|
|
|
mouse.WINDOW_RESIZE_S_FLAG or \
|
|
|
|
mouse.WINDOW_RESIZE_E_FLAG
|
|
|
|
|
|
|
|
align 4
|
2015-10-16 21:00:13 +02:00
|
|
|
;-----------------------------------------------------------------
|
|
|
|
mouse_check_events:
|
|
|
|
; Check if mouse buttons state or cursor position has changed
|
2010-02-06 20:08:19 +01:00
|
|
|
push eax ebx
|
|
|
|
mov al, [BTN_DOWN]
|
|
|
|
mov bl, [mouse.state.buttons]
|
|
|
|
and al, mouse.BUTTONS_MASK
|
|
|
|
mov cl, al
|
|
|
|
xchg cl, [mouse.state.buttons]
|
|
|
|
xor bl, al
|
|
|
|
push eax ebx
|
|
|
|
|
|
|
|
; did any mouse button changed its state?
|
|
|
|
or bl, bl
|
|
|
|
jz .check_position
|
|
|
|
|
|
|
|
; yes it did, is that the first button of all pressed down?
|
|
|
|
or cl, cl
|
|
|
|
jnz .check_buttons_released
|
|
|
|
|
|
|
|
; yes it is, activate window user is pointing at, if needed
|
|
|
|
call mouse._.activate_sys_window_under_cursor
|
|
|
|
|
|
|
|
; is there any system button under cursor?
|
2011-10-14 23:38:50 +02:00
|
|
|
call mouse._.find_sys_button_under_cursor
|
2010-02-06 20:08:19 +01:00
|
|
|
or eax, eax
|
|
|
|
jz .check_buttons_released
|
|
|
|
|
|
|
|
; yes there is, activate it and exit
|
|
|
|
mov [mouse.active_sys_button.pbid], eax
|
|
|
|
mov [mouse.active_sys_button.coord], ebx
|
|
|
|
mov cl, [mouse.state.buttons]
|
|
|
|
mov [mouse.active_sys_button.buttons], cl
|
|
|
|
call sys_button_activate_handler
|
|
|
|
jmp .exit
|
|
|
|
|
|
|
|
.check_buttons_released:
|
|
|
|
cmp [mouse.state.buttons], 0
|
|
|
|
jnz .buttons_changed
|
|
|
|
|
|
|
|
; did we press some button earlier?
|
|
|
|
cmp [mouse.active_sys_button.pbid], 0
|
|
|
|
je .buttons_changed
|
|
|
|
|
|
|
|
; yes we did, deactivate it
|
|
|
|
xor eax, eax
|
|
|
|
xchg eax, [mouse.active_sys_button.pbid]
|
|
|
|
mov ebx, [mouse.active_sys_button.coord]
|
|
|
|
mov cl, [mouse.active_sys_button.buttons]
|
|
|
|
push eax ebx
|
|
|
|
call sys_button_deactivate_handler
|
|
|
|
pop edx ecx
|
|
|
|
|
|
|
|
; is the button under cursor the one we deactivated?
|
|
|
|
call mouse._.find_sys_button_under_cursor
|
|
|
|
cmp eax, ecx
|
|
|
|
jne .exit
|
|
|
|
cmp ebx, edx
|
|
|
|
jne .exit
|
|
|
|
|
|
|
|
; yes it is, perform associated action
|
|
|
|
mov cl, [mouse.active_sys_button.buttons]
|
|
|
|
call sys_button_perform_handler
|
|
|
|
jmp .exit
|
|
|
|
|
|
|
|
.buttons_changed:
|
|
|
|
test byte[esp], mouse.LEFT_BUTTON_FLAG
|
|
|
|
jz @f
|
|
|
|
mov eax, [esp + 4]
|
|
|
|
call .call_left_button_handler
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
test byte[esp], mouse.RIGHT_BUTTON_FLAG
|
2010-02-06 20:08:19 +01:00
|
|
|
jz @f
|
|
|
|
mov eax, [esp + 4]
|
|
|
|
call .call_right_button_handler
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
test byte[esp], mouse.MIDDLE_BUTTON_FLAG
|
2010-02-06 20:08:19 +01:00
|
|
|
jz .check_position
|
|
|
|
mov eax, [esp + 4]
|
|
|
|
call .call_middle_button_handler
|
|
|
|
|
|
|
|
.check_position:
|
|
|
|
movzx eax, word[MOUSE_X]
|
|
|
|
movzx ebx, word[MOUSE_Y]
|
|
|
|
cmp eax, [mouse.state.pos.x]
|
|
|
|
jne .position_changed
|
|
|
|
cmp ebx, [mouse.state.pos.y]
|
|
|
|
je .exit
|
|
|
|
|
|
|
|
.position_changed:
|
|
|
|
xchg eax, [mouse.state.pos.x]
|
|
|
|
xchg ebx, [mouse.state.pos.y]
|
|
|
|
|
|
|
|
call mouse._.move_handler
|
|
|
|
|
|
|
|
.exit:
|
|
|
|
add esp, 8
|
|
|
|
pop ebx eax
|
|
|
|
ret
|
|
|
|
|
|
|
|
.call_left_button_handler:
|
|
|
|
test eax, mouse.LEFT_BUTTON_FLAG
|
|
|
|
jnz mouse._.left_button_press_handler
|
|
|
|
jmp mouse._.left_button_release_handler
|
|
|
|
|
|
|
|
.call_right_button_handler:
|
|
|
|
test eax, mouse.RIGHT_BUTTON_FLAG
|
|
|
|
jnz mouse._.right_button_press_handler
|
|
|
|
jmp mouse._.right_button_release_handler
|
|
|
|
|
|
|
|
.call_middle_button_handler:
|
|
|
|
test eax, mouse.MIDDLE_BUTTON_FLAG
|
|
|
|
jnz mouse._.middle_button_press_handler
|
|
|
|
jmp mouse._.middle_button_release_handler
|
|
|
|
|
2015-10-16 21:00:13 +02:00
|
|
|
;===============================
|
|
|
|
;////// private functions //////
|
|
|
|
;===============================
|
2010-02-06 20:08:19 +01:00
|
|
|
|
|
|
|
uglobal
|
|
|
|
mouse.state:
|
|
|
|
.pos POINT
|
|
|
|
.buttons db ?
|
|
|
|
|
2015-10-16 21:00:13 +02:00
|
|
|
; NOTE: since there's no unique and lifetime-constant button identifiers,
|
|
|
|
; we are 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
|
2010-02-06 20:08:19 +01:00
|
|
|
align 4
|
|
|
|
mouse.active_sys_button:
|
|
|
|
.pbid dd ?
|
|
|
|
.coord dd ?
|
|
|
|
.buttons db ?
|
|
|
|
|
|
|
|
align 4
|
|
|
|
mouse.active_sys_window:
|
|
|
|
.pslot dd ?
|
|
|
|
.old_box BOX
|
|
|
|
.new_box BOX
|
|
|
|
.delta POINT
|
|
|
|
.last_ticks dd ?
|
|
|
|
.action db ?
|
|
|
|
endg
|
|
|
|
|
2015-10-31 22:43:10 +01:00
|
|
|
iglobal
|
|
|
|
fl_moving db 0
|
|
|
|
rb 3
|
|
|
|
endg
|
|
|
|
|
2010-02-06 20:08:19 +01:00
|
|
|
align 4
|
2015-10-16 21:00:13 +02:00
|
|
|
;-----------------------------------------------------------------
|
|
|
|
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
|
|
|
|
@@:
|
2010-02-06 20:08:19 +01:00
|
|
|
test [mouse.state.buttons], not mouse.LEFT_BUTTON_FLAG
|
|
|
|
jnz .exit
|
|
|
|
|
|
|
|
call mouse._.find_sys_window_under_cursor
|
|
|
|
call mouse._.check_sys_window_actions
|
|
|
|
mov [mouse.active_sys_window.action], al
|
|
|
|
or eax, eax
|
|
|
|
jz .exit
|
|
|
|
|
|
|
|
xchg eax, edx
|
|
|
|
test dl, mouse.WINDOW_MOVE_FLAG
|
|
|
|
jz @f
|
|
|
|
|
2015-10-16 21:00:13 +02:00
|
|
|
bt dword [BTN_DOWN], 24
|
|
|
|
jnc @f
|
2010-02-06 20:08:19 +01:00
|
|
|
|
|
|
|
mov [mouse.active_sys_window.last_ticks], 0
|
|
|
|
call sys_window_maximize_handler
|
|
|
|
jmp .exit
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
|
2010-02-06 20:08:19 +01:00
|
|
|
jnz .exit
|
|
|
|
mov [mouse.active_sys_window.pslot], esi
|
|
|
|
lea eax, [edi + WDATA.box]
|
|
|
|
mov ebx, mouse.active_sys_window.old_box
|
2012-02-22 16:46:09 +01:00
|
|
|
mov ecx, sizeof.BOX
|
2010-02-06 20:08:19 +01:00
|
|
|
call memmove
|
|
|
|
mov ebx, mouse.active_sys_window.new_box
|
|
|
|
call memmove
|
|
|
|
test edx, mouse.WINDOW_MOVE_FLAG
|
|
|
|
jz @f
|
|
|
|
|
|
|
|
call .calculate_n_delta
|
|
|
|
call .calculate_w_delta
|
|
|
|
jmp .call_window_handler
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
test dl, mouse.WINDOW_RESIZE_W_FLAG
|
2010-02-06 20:08:19 +01:00
|
|
|
jz @f
|
|
|
|
call .calculate_w_delta
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
test dl, mouse.WINDOW_RESIZE_S_FLAG
|
2010-02-06 20:08:19 +01:00
|
|
|
jz @f
|
|
|
|
call .calculate_s_delta
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
test dl, mouse.WINDOW_RESIZE_E_FLAG
|
2010-02-06 20:08:19 +01:00
|
|
|
jz .call_window_handler
|
|
|
|
call .calculate_e_delta
|
|
|
|
|
|
|
|
.call_window_handler:
|
|
|
|
.exit:
|
|
|
|
ret
|
|
|
|
|
|
|
|
.calculate_n_delta:
|
|
|
|
mov eax, [mouse.state.pos.y]
|
|
|
|
sub eax, [mouse.active_sys_window.old_box.top]
|
|
|
|
mov [mouse.active_sys_window.delta.y], eax
|
|
|
|
ret
|
|
|
|
|
|
|
|
.calculate_w_delta:
|
|
|
|
mov eax, [mouse.state.pos.x]
|
|
|
|
sub eax, [mouse.active_sys_window.old_box.left]
|
|
|
|
mov [mouse.active_sys_window.delta.x], eax
|
|
|
|
ret
|
|
|
|
|
|
|
|
.calculate_s_delta:
|
|
|
|
mov eax, [mouse.active_sys_window.old_box.top]
|
|
|
|
add eax, [mouse.active_sys_window.old_box.height]
|
|
|
|
sub eax, [mouse.state.pos.y]
|
|
|
|
mov [mouse.active_sys_window.delta.y], eax
|
|
|
|
ret
|
|
|
|
|
|
|
|
.calculate_e_delta:
|
|
|
|
mov eax, [mouse.active_sys_window.old_box.left]
|
|
|
|
add eax, [mouse.active_sys_window.old_box.width]
|
|
|
|
sub eax, [mouse.state.pos.x]
|
|
|
|
mov [mouse.active_sys_window.delta.x], eax
|
|
|
|
ret
|
|
|
|
|
|
|
|
align 4
|
2015-10-16 21:00:13 +02:00
|
|
|
;-----------------------------------------------------------------
|
|
|
|
mouse._.left_button_release_handler:
|
|
|
|
; Called when left mouse button has been released
|
|
|
|
bts dword [BTN_DOWN], 16
|
2010-02-06 20:08:19 +01:00
|
|
|
xor esi, esi
|
|
|
|
xchg esi, [mouse.active_sys_window.pslot]
|
|
|
|
or esi, esi
|
|
|
|
jz .exit
|
|
|
|
|
|
|
|
mov eax, esi
|
|
|
|
shl eax, 5
|
|
|
|
add eax, window_data + WDATA.box
|
|
|
|
mov ebx, mouse.active_sys_window.old_box
|
2012-02-22 16:46:09 +01:00
|
|
|
mov ecx, sizeof.BOX
|
2010-02-06 20:08:19 +01:00
|
|
|
call memmove
|
|
|
|
|
|
|
|
mov eax, mouse.active_sys_window.old_box
|
|
|
|
mov ebx, mouse.active_sys_window.new_box
|
|
|
|
call sys_window_end_moving_handler
|
|
|
|
|
|
|
|
.exit:
|
2011-07-22 20:44:08 +02:00
|
|
|
and [mouse.active_sys_window.action], 0
|
2015-10-31 22:43:10 +01:00
|
|
|
mov [fl_moving], 0
|
2010-02-06 20:08:19 +01:00
|
|
|
ret
|
|
|
|
|
2015-10-16 21:00:13 +02:00
|
|
|
mouse._.right_button_press_handler:
|
|
|
|
bts word [BTN_DOWN], 9
|
2010-02-06 20:08:19 +01:00
|
|
|
test [mouse.state.buttons], not mouse.RIGHT_BUTTON_FLAG
|
2015-10-16 21:00:13 +02:00
|
|
|
jnz @f
|
2010-02-06 20:08:19 +01:00
|
|
|
call mouse._.find_sys_window_under_cursor
|
|
|
|
call mouse._.check_sys_window_actions
|
|
|
|
test al, mouse.WINDOW_MOVE_FLAG
|
2015-10-16 21:00:13 +02:00
|
|
|
jz @f
|
|
|
|
jmp sys_window_rollup_handler
|
2010-02-06 20:08:19 +01:00
|
|
|
|
2015-10-16 21:00:13 +02:00
|
|
|
mouse._.right_button_release_handler:
|
|
|
|
bts dword [BTN_DOWN], 17
|
|
|
|
@@:
|
2010-02-06 20:08:19 +01:00
|
|
|
ret
|
|
|
|
|
2015-10-16 21:00:13 +02:00
|
|
|
mouse._.middle_button_press_handler:
|
|
|
|
bts word [BTN_DOWN], 10
|
2010-02-06 20:08:19 +01:00
|
|
|
ret
|
|
|
|
|
2015-10-16 21:00:13 +02:00
|
|
|
mouse._.middle_button_release_handler:
|
|
|
|
bts dword [BTN_DOWN], 18
|
2010-02-06 20:08:19 +01:00
|
|
|
ret
|
|
|
|
|
|
|
|
align 4
|
2015-10-16 21:00:13 +02:00
|
|
|
;-----------------------------------------------------------------
|
|
|
|
mouse._.move_handler:
|
|
|
|
; Called when cursor has been moved
|
2010-02-06 20:08:19 +01:00
|
|
|
;> eax = old x coord
|
|
|
|
;> ebx = old y coord
|
|
|
|
cmp [mouse.active_sys_button.pbid], 0
|
|
|
|
jnz .exit
|
|
|
|
|
|
|
|
mov esi, [mouse.active_sys_window.pslot]
|
|
|
|
or esi, esi
|
|
|
|
jz .exit
|
|
|
|
|
|
|
|
mov eax, mouse.active_sys_window.new_box
|
|
|
|
mov ebx, mouse.active_sys_window.old_box
|
2012-02-22 16:46:09 +01:00
|
|
|
mov ecx, sizeof.BOX
|
2010-02-06 20:08:19 +01:00
|
|
|
call memmove
|
|
|
|
|
|
|
|
mov dl, [mouse.active_sys_window.action]
|
|
|
|
test dl, mouse.WINDOW_MOVE_FLAG
|
|
|
|
jz .check_resize_w
|
|
|
|
|
|
|
|
mov eax, [mouse.state.pos.x]
|
|
|
|
sub eax, [mouse.active_sys_window.delta.x]
|
|
|
|
mov [mouse.active_sys_window.new_box.left], eax
|
|
|
|
mov eax, [mouse.state.pos.y]
|
|
|
|
sub eax, [mouse.active_sys_window.delta.y]
|
|
|
|
mov [mouse.active_sys_window.new_box.top], eax
|
|
|
|
|
|
|
|
mov eax, [mouse.active_sys_window.new_box.left]
|
|
|
|
or eax, eax
|
|
|
|
jge @f
|
|
|
|
xor eax, eax
|
|
|
|
mov [mouse.active_sys_window.new_box.left], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
add eax, [mouse.active_sys_window.new_box.width]
|
2015-01-05 18:18:45 +01:00
|
|
|
cmp eax, [_display.width]
|
2010-02-06 20:08:19 +01:00
|
|
|
jl @f
|
2015-01-05 18:18:45 +01:00
|
|
|
sub eax, [_display.width]
|
2021-06-23 12:07:36 +02:00
|
|
|
inc eax
|
2010-02-06 20:08:19 +01:00
|
|
|
sub [mouse.active_sys_window.new_box.left], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
mov eax, [mouse.active_sys_window.new_box.top]
|
2010-02-06 20:08:19 +01:00
|
|
|
or eax, eax
|
|
|
|
jge @f
|
|
|
|
xor eax, eax
|
|
|
|
mov [mouse.active_sys_window.new_box.top], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
add eax, [mouse.active_sys_window.new_box.height]
|
2015-01-05 18:18:45 +01:00
|
|
|
cmp eax, [_display.height]
|
|
|
|
jl .call_window_handler
|
|
|
|
sub eax, [_display.height]
|
2021-06-23 12:07:36 +02:00
|
|
|
inc eax
|
2010-02-06 20:08:19 +01:00
|
|
|
sub [mouse.active_sys_window.new_box.top], eax
|
|
|
|
jmp .call_window_handler
|
|
|
|
|
|
|
|
.check_resize_w:
|
|
|
|
test dl, mouse.WINDOW_RESIZE_W_FLAG
|
|
|
|
jz .check_resize_s
|
|
|
|
|
|
|
|
mov eax, [mouse.state.pos.x]
|
|
|
|
sub eax, [mouse.active_sys_window.delta.x]
|
|
|
|
mov [mouse.active_sys_window.new_box.left], eax
|
|
|
|
sub eax, [mouse.active_sys_window.old_box.left]
|
|
|
|
sub [mouse.active_sys_window.new_box.width], eax
|
|
|
|
|
|
|
|
mov eax, [mouse.active_sys_window.new_box.width]
|
|
|
|
sub eax, 127
|
|
|
|
jge @f
|
|
|
|
add [mouse.active_sys_window.new_box.left], eax
|
|
|
|
mov [mouse.active_sys_window.new_box.width], 127
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
mov eax, [mouse.active_sys_window.new_box.left]
|
2010-02-06 20:08:19 +01:00
|
|
|
or eax, eax
|
|
|
|
jge .check_resize_s
|
|
|
|
add [mouse.active_sys_window.new_box.width], eax
|
|
|
|
xor eax, eax
|
|
|
|
mov [mouse.active_sys_window.new_box.left], eax
|
|
|
|
|
|
|
|
.check_resize_s:
|
|
|
|
test dl, mouse.WINDOW_RESIZE_S_FLAG
|
|
|
|
jz .check_resize_e
|
|
|
|
|
|
|
|
mov eax, [mouse.state.pos.y]
|
|
|
|
add eax, [mouse.active_sys_window.delta.y]
|
|
|
|
sub eax, [mouse.active_sys_window.old_box.top]
|
|
|
|
mov [mouse.active_sys_window.new_box.height], eax
|
|
|
|
|
|
|
|
push eax
|
|
|
|
mov edi, esi
|
|
|
|
shl edi, 5
|
|
|
|
add edi, window_data
|
|
|
|
call window._.get_rolledup_height
|
|
|
|
mov ecx, eax
|
|
|
|
pop eax
|
|
|
|
mov eax, [mouse.active_sys_window.new_box.height]
|
|
|
|
cmp eax, ecx
|
|
|
|
jge @f
|
|
|
|
mov eax, ecx
|
|
|
|
mov [mouse.active_sys_window.new_box.height], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
add eax, [mouse.active_sys_window.new_box.top]
|
2015-01-05 18:18:45 +01:00
|
|
|
cmp eax, [_display.height]
|
|
|
|
jl .check_resize_e
|
|
|
|
sub eax, [_display.height]
|
2010-02-06 20:08:19 +01:00
|
|
|
neg eax
|
|
|
|
add [mouse.active_sys_window.new_box.height], eax
|
2015-01-05 18:18:45 +01:00
|
|
|
mov ecx, [_display.height]
|
2010-02-06 20:08:19 +01:00
|
|
|
cmp ecx, eax
|
2015-01-05 18:18:45 +01:00
|
|
|
jg .check_resize_e
|
2010-02-06 20:08:19 +01:00
|
|
|
mov [mouse.active_sys_window.new_box.height], ecx
|
|
|
|
|
|
|
|
.check_resize_e:
|
|
|
|
test dl, mouse.WINDOW_RESIZE_E_FLAG
|
|
|
|
jz .call_window_handler
|
|
|
|
|
|
|
|
mov eax, [mouse.state.pos.x]
|
|
|
|
add eax, [mouse.active_sys_window.delta.x]
|
|
|
|
sub eax, [mouse.active_sys_window.old_box.left]
|
|
|
|
mov [mouse.active_sys_window.new_box.width], eax
|
|
|
|
|
|
|
|
mov eax, [mouse.active_sys_window.new_box.width]
|
|
|
|
cmp eax, 127
|
|
|
|
jge @f
|
|
|
|
mov eax, 127
|
|
|
|
mov [mouse.active_sys_window.new_box.width], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
add eax, [mouse.active_sys_window.new_box.left]
|
2015-01-05 18:18:45 +01:00
|
|
|
cmp eax, [_display.width]
|
|
|
|
jl .call_window_handler
|
|
|
|
sub eax, [_display.width]
|
2010-02-06 20:08:19 +01:00
|
|
|
neg eax
|
|
|
|
add [mouse.active_sys_window.new_box.width], eax
|
2015-01-05 18:18:45 +01:00
|
|
|
mov ecx, [_display.width]
|
2010-02-06 20:08:19 +01:00
|
|
|
cmp ecx, eax
|
2015-01-05 18:18:45 +01:00
|
|
|
jg .call_window_handler
|
2010-02-06 20:08:19 +01:00
|
|
|
mov [mouse.active_sys_window.new_box.width], ecx
|
|
|
|
|
|
|
|
.call_window_handler:
|
|
|
|
mov eax, mouse.active_sys_window.old_box
|
|
|
|
mov ebx, mouse.active_sys_window.new_box
|
|
|
|
|
|
|
|
push esi
|
|
|
|
mov esi, mouse.active_sys_window.old_box
|
|
|
|
mov edi, mouse.active_sys_window.new_box
|
2012-02-22 16:46:09 +01:00
|
|
|
mov ecx, sizeof.BOX / 4
|
2010-02-06 20:08:19 +01:00
|
|
|
repe
|
|
|
|
cmpsd
|
|
|
|
pop esi
|
|
|
|
je .exit
|
|
|
|
|
2015-10-31 22:43:10 +01:00
|
|
|
test [fl_moving], 1
|
|
|
|
jnz @f
|
|
|
|
|
|
|
|
mov [fl_moving], 1
|
|
|
|
push edi
|
|
|
|
mov edi, esi
|
|
|
|
shl edi, 5
|
|
|
|
add edi, WDATA.box + window_data
|
|
|
|
call window._.draw_negative_box
|
|
|
|
pop edi
|
|
|
|
@@:
|
|
|
|
|
|
|
|
|
2010-02-06 20:08:19 +01:00
|
|
|
mov [mouse.active_sys_window.last_ticks], 0
|
|
|
|
call sys_window_moving_handler
|
|
|
|
|
|
|
|
.exit:
|
|
|
|
ret
|
|
|
|
|
|
|
|
align 4
|
2015-10-16 21:00:13 +02:00
|
|
|
;-----------------------------------------------------------------
|
|
|
|
mouse._.find_sys_window_under_cursor:
|
|
|
|
; Find system window object which is currently visible on screen
|
|
|
|
; and has mouse cursor within its bounds
|
2010-02-06 20:08:19 +01:00
|
|
|
;< esi = process slot
|
|
|
|
;< edi = pointer to WDATA struct
|
2012-03-10 12:37:42 +01:00
|
|
|
mov esi, [mouse.state.pos.y]
|
|
|
|
mov esi, [d_width_calc_area + esi*4]
|
|
|
|
|
2015-01-05 18:59:03 +01:00
|
|
|
add esi, [_display.win_map]
|
2010-02-06 20:08:19 +01:00
|
|
|
add esi, [mouse.state.pos.x]
|
|
|
|
movzx esi, byte[esi]
|
|
|
|
mov edi, esi
|
|
|
|
shl edi, 5
|
|
|
|
add edi, window_data
|
|
|
|
ret
|
|
|
|
|
|
|
|
align 4
|
2015-10-16 21:00:13 +02:00
|
|
|
;-----------------------------------------------------------------
|
|
|
|
mouse._.activate_sys_window_under_cursor:
|
|
|
|
; activate and redraw window under cursor (if necessary)
|
2010-02-06 20:08:19 +01:00
|
|
|
call mouse._.find_sys_window_under_cursor
|
|
|
|
movzx esi, word[WIN_STACK + esi * 2]
|
|
|
|
lea esi, [WIN_POS + esi * 2]
|
|
|
|
jmp waredraw
|
|
|
|
|
|
|
|
align 4
|
2015-10-16 21:00:13 +02:00
|
|
|
;-----------------------------------------------------------------
|
|
|
|
mouse._.find_sys_button_under_cursor:
|
|
|
|
; Find system button object which is currently visible on screen
|
|
|
|
; and has mouse cursor within its bounds
|
2010-02-06 20:08:19 +01:00
|
|
|
;< 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
|
|
|
|
mov edx, esi
|
|
|
|
|
|
|
|
; check if any process button contains cursor
|
|
|
|
mov eax, [BTN_ADDR]
|
|
|
|
mov ecx, [eax]
|
2012-02-23 19:52:13 +01:00
|
|
|
imul esi, ecx, sizeof.SYS_BUTTON
|
2010-02-06 20:08:19 +01:00
|
|
|
add esi, eax
|
|
|
|
inc ecx
|
2012-02-23 19:52:13 +01:00
|
|
|
add esi, sizeof.SYS_BUTTON
|
2010-02-06 20:08:19 +01:00
|
|
|
|
|
|
|
.next_button:
|
|
|
|
dec ecx
|
|
|
|
jz .not_found
|
|
|
|
|
2012-02-23 19:52:13 +01:00
|
|
|
add esi, -sizeof.SYS_BUTTON
|
2010-02-06 20:08:19 +01:00
|
|
|
|
|
|
|
; does it belong to our process?
|
|
|
|
cmp dx, [esi + SYS_BUTTON.pslot]
|
|
|
|
jne .next_button
|
|
|
|
|
|
|
|
; does it contain cursor coordinates?
|
|
|
|
mov eax, [mouse.state.pos.x]
|
|
|
|
sub eax, [edi + WDATA.box.left]
|
|
|
|
sub ax, [esi + SYS_BUTTON.left]
|
|
|
|
jl .next_button
|
|
|
|
sub ax, [esi + SYS_BUTTON.width]
|
|
|
|
jge .next_button
|
|
|
|
mov eax, [mouse.state.pos.y]
|
|
|
|
sub eax, [edi + WDATA.box.top]
|
|
|
|
sub ax, [esi + SYS_BUTTON.top]
|
|
|
|
jl .next_button
|
|
|
|
sub ax, [esi + SYS_BUTTON.height]
|
|
|
|
jge .next_button
|
|
|
|
|
|
|
|
; okay, return it
|
|
|
|
shl edx, 24
|
|
|
|
mov eax, dword[esi + SYS_BUTTON.id_hi - 2]
|
|
|
|
mov ax, [esi + SYS_BUTTON.id_lo]
|
|
|
|
and eax, 0x0ffffff
|
|
|
|
or eax, edx
|
|
|
|
mov ebx, dword[esi + SYS_BUTTON.left - 2]
|
|
|
|
mov bx, [esi + SYS_BUTTON.top]
|
|
|
|
jmp .exit
|
|
|
|
|
|
|
|
.not_found:
|
|
|
|
xor eax, eax
|
|
|
|
xor ebx, ebx
|
|
|
|
|
|
|
|
.exit:
|
|
|
|
pop edi esi edx ecx
|
|
|
|
ret
|
|
|
|
|
|
|
|
align 4
|
2015-10-16 21:00:13 +02:00
|
|
|
;-----------------------------------------------------------------
|
|
|
|
mouse._.check_sys_window_actions:
|
2010-02-06 20:08:19 +01:00
|
|
|
;< eax = action flags or 0
|
|
|
|
; is window movable?
|
|
|
|
test byte[edi + WDATA.cl_titlebar + 3], 0x01
|
|
|
|
jnz .no_action
|
|
|
|
|
|
|
|
mov eax, [mouse.state.pos.x]
|
|
|
|
mov ebx, [mouse.state.pos.y]
|
|
|
|
sub eax, [edi + WDATA.box.left]
|
|
|
|
sub ebx, [edi + WDATA.box.top]
|
|
|
|
|
|
|
|
; is there a window titlebar under cursor?
|
|
|
|
push eax
|
|
|
|
call window._.get_titlebar_height
|
|
|
|
cmp ebx, eax
|
|
|
|
pop eax
|
|
|
|
jl .move_action
|
|
|
|
|
|
|
|
; no there isn't, can it be resized then?
|
|
|
|
mov dl, [edi + WDATA.fl_wstyle]
|
|
|
|
and dl, 0x0f
|
2015-10-16 21:00:13 +02:00
|
|
|
; NOTE: dangerous optimization, revise if window types changed
|
|
|
|
; this currently implies only types 2 and 3 could be resized
|
2010-02-06 20:08:19 +01:00
|
|
|
test dl, 2
|
|
|
|
jz .no_action
|
|
|
|
|
|
|
|
mov ecx, [edi + WDATA.box.width]
|
|
|
|
add ecx, -window.BORDER_SIZE
|
|
|
|
mov edx, [edi + WDATA.box.height]
|
|
|
|
add edx, -window.BORDER_SIZE
|
|
|
|
|
|
|
|
; is it rolled up?
|
|
|
|
test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
|
|
|
|
jnz .resize_w_or_e_action
|
|
|
|
|
|
|
|
cmp eax, window.BORDER_SIZE
|
|
|
|
jl .resize_w_action
|
|
|
|
cmp eax, ecx
|
|
|
|
jg .resize_e_action
|
|
|
|
cmp ebx, edx
|
|
|
|
jle .no_action
|
|
|
|
|
|
|
|
.resize_s_action:
|
|
|
|
cmp eax, window.BORDER_SIZE + 10
|
|
|
|
jl .resize_sw_action
|
|
|
|
add ecx, -10
|
|
|
|
cmp eax, ecx
|
|
|
|
jge .resize_se_action
|
|
|
|
mov eax, mouse.WINDOW_RESIZE_S_FLAG
|
|
|
|
jmp .exit
|
|
|
|
|
|
|
|
.resize_w_or_e_action:
|
|
|
|
cmp eax, window.BORDER_SIZE + 10
|
|
|
|
jl .resize_w_action.direct
|
|
|
|
add ecx, -10
|
|
|
|
cmp eax, ecx
|
|
|
|
jg .resize_e_action.direct
|
|
|
|
jmp .no_action
|
|
|
|
|
|
|
|
.resize_w_action:
|
|
|
|
add edx, -10
|
|
|
|
cmp ebx, edx
|
|
|
|
jge .resize_sw_action
|
|
|
|
.resize_w_action.direct:
|
|
|
|
mov eax, mouse.WINDOW_RESIZE_W_FLAG
|
|
|
|
jmp .exit
|
|
|
|
|
|
|
|
.resize_e_action:
|
|
|
|
add edx, -10
|
|
|
|
cmp ebx, edx
|
|
|
|
jge .resize_se_action
|
|
|
|
.resize_e_action.direct:
|
|
|
|
mov eax, mouse.WINDOW_RESIZE_E_FLAG
|
|
|
|
jmp .exit
|
|
|
|
|
|
|
|
.resize_sw_action:
|
|
|
|
mov eax, mouse.WINDOW_RESIZE_SW_FLAG
|
|
|
|
jmp .exit
|
|
|
|
|
|
|
|
.resize_se_action:
|
|
|
|
mov eax, mouse.WINDOW_RESIZE_SE_FLAG
|
|
|
|
jmp .exit
|
|
|
|
|
|
|
|
.move_action:
|
|
|
|
mov eax, mouse.WINDOW_MOVE_FLAG
|
|
|
|
jmp .exit
|
|
|
|
|
|
|
|
.no_action:
|
|
|
|
xor eax, eax
|
|
|
|
|
|
|
|
.exit:
|
|
|
|
ret
|
2021-12-28 16:19:24 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
align 4
|
|
|
|
readmousepos:
|
|
|
|
; eax=0 screen relative
|
|
|
|
; eax=1 window relative
|
|
|
|
; eax=2 buttons pressed
|
|
|
|
; eax=3 buttons pressed ext
|
|
|
|
; eax=4 load cursor
|
|
|
|
; eax=5 set cursor
|
|
|
|
; eax=6 delete cursor
|
|
|
|
; eax=7 get mouse_z
|
|
|
|
; eax=8 load cursor unicode
|
|
|
|
cmp ebx, 8
|
|
|
|
ja @f
|
|
|
|
jmp dword[.mousefn+ebx*4]
|
|
|
|
|
|
|
|
align 4
|
|
|
|
.mousefn:
|
|
|
|
dd .msscreen
|
|
|
|
dd .mswin
|
|
|
|
dd .msbutton
|
|
|
|
dd .msbuttonExt
|
|
|
|
dd .app_load_cursor
|
|
|
|
dd .app_set_cursor
|
|
|
|
dd .app_delete_cursor
|
|
|
|
dd .msz
|
|
|
|
dd .loadCursorUni
|
|
|
|
|
|
|
|
.msscreen:
|
|
|
|
mov eax, [MOUSE_X]
|
|
|
|
shl eax, 16
|
|
|
|
mov ax, [MOUSE_Y]
|
2022-06-05 16:41:51 +02:00
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2021-12-28 16:19:24 +01:00
|
|
|
@@:
|
|
|
|
ret
|
|
|
|
|
|
|
|
.mswin:
|
|
|
|
mov eax, [MOUSE_X]
|
|
|
|
shl eax, 16
|
|
|
|
mov ax, [MOUSE_Y]
|
2022-02-09 18:07:51 +01:00
|
|
|
mov esi, [current_slot_idx]
|
|
|
|
shl esi, BSF sizeof.WDATA
|
|
|
|
mov bx, word [esi + window_data + WDATA.box.left]
|
2021-12-28 16:19:24 +01:00
|
|
|
shl ebx, 16
|
2022-02-09 18:07:51 +01:00
|
|
|
mov bx, word [esi + window_data + WDATA.box.top]
|
2021-12-28 16:19:24 +01:00
|
|
|
sub eax, ebx
|
2022-06-04 01:34:04 +02:00
|
|
|
mov edi, [current_slot]
|
|
|
|
sub ax, word[edi + APPDATA.wnd_clientbox.top]
|
2021-12-28 16:19:24 +01:00
|
|
|
rol eax, 16
|
2022-06-04 01:34:04 +02:00
|
|
|
sub ax, word[edi + APPDATA.wnd_clientbox.left]
|
2021-12-28 16:19:24 +01:00
|
|
|
rol eax, 16
|
2022-06-05 16:41:51 +02:00
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2021-12-28 16:19:24 +01:00
|
|
|
ret
|
|
|
|
|
|
|
|
.msbutton:
|
|
|
|
movzx eax, byte [BTN_DOWN]
|
2022-06-05 16:41:51 +02:00
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2021-12-28 16:19:24 +01:00
|
|
|
ret
|
|
|
|
|
|
|
|
.msbuttonExt:
|
|
|
|
mov eax, [BTN_DOWN]
|
2022-06-05 16:41:51 +02:00
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2021-12-28 16:19:24 +01:00
|
|
|
ret
|
|
|
|
|
|
|
|
.app_load_cursor:
|
|
|
|
cmp ecx, OS_BASE
|
|
|
|
jae @f
|
|
|
|
stdcall load_cursor, ecx, edx
|
2022-06-05 16:41:51 +02:00
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2021-12-28 16:19:24 +01:00
|
|
|
@@:
|
|
|
|
ret
|
|
|
|
|
|
|
|
.loadCursorUni:
|
|
|
|
cmp ecx, OS_BASE
|
|
|
|
jae @b
|
|
|
|
push ecx edx
|
|
|
|
stdcall kernel_alloc, maxPathLength
|
|
|
|
mov edi, eax
|
|
|
|
pop eax esi
|
|
|
|
push edi
|
|
|
|
call getFullPath
|
|
|
|
pop ebp
|
|
|
|
test eax, eax
|
|
|
|
jz @f
|
|
|
|
stdcall load_cursor, ebp, LOAD_FROM_FILE
|
2022-06-05 16:41:51 +02:00
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2021-12-28 16:19:24 +01:00
|
|
|
@@:
|
|
|
|
stdcall kernel_free, ebp
|
|
|
|
ret
|
|
|
|
|
|
|
|
.app_set_cursor:
|
|
|
|
stdcall set_cursor, ecx
|
2022-06-05 16:41:51 +02:00
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2021-12-28 16:19:24 +01:00
|
|
|
ret
|
|
|
|
|
|
|
|
.app_delete_cursor:
|
|
|
|
stdcall delete_cursor, ecx
|
2022-06-05 16:41:51 +02:00
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2021-12-28 16:19:24 +01:00
|
|
|
ret
|
|
|
|
|
|
|
|
.msz:
|
|
|
|
mov edi, [thread_count]
|
|
|
|
movzx edi, word [WIN_POS + edi*2]
|
|
|
|
cmp edi, [current_slot_idx]
|
|
|
|
jne @f
|
|
|
|
mov ax, [MOUSE_SCROLL_H]
|
|
|
|
shl eax, 16
|
|
|
|
mov ax, [MOUSE_SCROLL_V]
|
2022-06-05 16:41:51 +02:00
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2021-12-28 16:19:24 +01:00
|
|
|
and [MOUSE_SCROLL_H], word 0
|
|
|
|
and [MOUSE_SCROLL_V], word 0
|
|
|
|
ret
|
|
|
|
@@:
|
2022-06-05 16:41:51 +02:00
|
|
|
and [esp + SYSCALL_STACK.eax], dword 0
|
|
|
|
ret
|