Subversion Repositories Kolibri OS

Rev

Rev 9941 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2288 clevermous 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
10051 ace_dent 3
;; Copyright (C) KolibriOS team 2004-2024. All rights reserved. ;;
2288 clevermous 4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
8
 
9
;   check mouse
10
;
11
;
12
;   FB00  ->   FB0F   mouse memory 00 chunk count - FB0A-B x - FB0C-D y
13
;   FB10  ->   FB17   mouse color mem
14
;   FB21              x move
15
;   FB22              y move
16
;   FB30              color temp
17
;   FB28              high bits temp
18
;   FB4A  ->   FB4D   FB4A-B x-under - FB4C-D y-under
19
;   FC00  ->   FCFE   com1/ps2 buffer
20
;   FCFF              com1/ps2 buffer count starting from FC00
21
 
22
uglobal
2430 mario79 23
;--------------------------------------
24
align 4
5154 hidnplayr 25
mousecount                      dd ?
26
mousedata                       dd ?
27
Y_UNDER_sub_CUR_hot_y_add_curh  dw ?
28
Y_UNDER_subtraction_CUR_hot_y   dw ?
29
X_UNDER_sub_CUR_hot_x_add_curh  dw ?
30
X_UNDER_subtraction_CUR_hot_x   dw ?
2288 clevermous 31
endg
32
 
33
iglobal
2430 mario79 34
;--------------------------------------
35
align 4
6230 pathoswith 36
mouse_speed_factor      dw 4
37
mouse_delay             db 3
5851 pathoswith 38
mouse_doubleclick_delay db 64
2288 clevermous 39
endg
5154 hidnplayr 40
 
2430 mario79 41
;-----------------------------------------------------------------------------
5154 hidnplayr 42
 
2430 mario79 43
align 4
2288 clevermous 44
draw_mouse_under:
5154 hidnplayr 45
 
2288 clevermous 46
        ; return old picture
47
        cmp     [_display.restore_cursor], 0
48
        je      @F
49
 
50
        pushad
51
        movzx   eax, word [X_UNDER]
52
        movzx   ebx, word [Y_UNDER]
53
        stdcall [_display.restore_cursor], eax, ebx
54
        popad
9941 Doczom 55
@@:
2288 clevermous 56
        ret
5154 hidnplayr 57
 
2430 mario79 58
;-----------------------------------------------------------------------------
5154 hidnplayr 59
 
2430 mario79 60
align 4
2288 clevermous 61
save_draw_mouse:
62
        cmp     [_display.move_cursor], 0
9941 Doczom 63
        je      .exit
2288 clevermous 64
        pushad
65
 
66
        mov     [X_UNDER], ax
67
        mov     [Y_UNDER], bx
68
        movzx   eax, word [MOUSE_Y]
69
        movzx   ebx, word [MOUSE_X]
70
        push    eax
71
        push    ebx
72
 
2446 mario79 73
        mov     eax, [d_width_calc_area + eax*4]
74
 
5351 serge 75
        add     eax, [_display.win_map]
9715 Doczom 76
        movzx   edx, byte [ebx + eax]
9930 Doczom 77
        shl     edx, BSF sizeof.WDATA
9848 rgimad 78
        ; edx - thread slot of window under cursor
9930 Doczom 79
        mov     esi, [window_data + edx + WDATA.cursor] ; cursor of window under cursor
2288 clevermous 80
 
9848 rgimad 81
        ; if cursor of window under cursor already equal to the
82
        ; current_cursor then just draw it
2288 clevermous 83
        cmp     esi, [current_cursor]
84
        je      .draw
85
 
9848 rgimad 86
        ; eax = thread slot of current active window
8866 rgimad 87
        mov     eax, [thread_count]
9715 Doczom 88
        movzx   eax, word [WIN_POS + eax*2]
9930 Doczom 89
        shl     eax, BSF sizeof.WDATA
3069 serge 90
 
9848 rgimad 91
        ; window under cursor == active window ?
3069 serge 92
        cmp     eax, edx
9850 rgimad 93
        je      @f
3069 serge 94
 
9850 rgimad 95
        ; check whether active window is being resized now:
9848 rgimad 96
        mov     bl, [mouse.active_sys_window.action]
97
        and     bl, mouse.WINDOW_RESIZE_S_FLAG or mouse.WINDOW_RESIZE_W_FLAG or mouse.WINDOW_RESIZE_E_FLAG
98
        test    bl, bl
9850 rgimad 99
        jz      .active_isnt_resizing
9930 Doczom 100
        mov     esi, [window_data + eax + WDATA.cursor] ; esi = cursor of active window, it is resizing cursor
9850 rgimad 101
        jmp     @f
102
        .active_isnt_resizing:
9848 rgimad 103
 
9850 rgimad 104
        ; if cursor of window under the cursor is resizing cursor then draw it.
105
        cmp     esi, [def_cursor_hresize]
106
        je      @f
107
        cmp     esi, [def_cursor_vresize]
108
        je      @f
109
        cmp     esi, [def_cursor_dresize1]
110
        je      @f
111
        cmp     esi, [def_cursor_dresize2]
112
        je      @f
9848 rgimad 113
 
9850 rgimad 114
        ; set cursor of window under cursor
9930 Doczom 115
        mov     esi, [window_data + edx + WDATA.cursor]
3069 serge 116
        cmp     esi, [current_cursor]
117
        je      .draw
118
 
119
@@:
9941 Doczom 120
        cmp     [_display.select_cursor], 0
121
        jz      .error
122
 
123
        stdcall [_display.select_cursor], esi
2288 clevermous 124
        mov     [current_cursor], esi
2430 mario79 125
;--------------------------------------
126
align 4
2288 clevermous 127
.draw:
128
        stdcall [_display.move_cursor], esi
129
        popad
130
        ret
2430 mario79 131
;--------------------------------------
132
;align 4
133
;.fail:
134
;        mov     ecx, [def_cursor]
9930 Doczom 135
;        mov     [window_data + edx + WDATA.cursor], ecx
2430 mario79 136
;        stdcall [_display.move_cursor], ecx        ; stdcall: [esp]=ebx,eax
137
;        popad
138
;        ret
139
;--------------------------------------
140
align 4
9941 Doczom 141
.error:
2288 clevermous 142
        popad
9941 Doczom 143
.exit:
2288 clevermous 144
        ret
5154 hidnplayr 145
 
2430 mario79 146
;-----------------------------------------------------------------------------
5154 hidnplayr 147
 
2430 mario79 148
align 4
149
__sys_draw_pointer:
2288 clevermous 150
        pushad
151
        movzx   ecx, word [X_UNDER]
152
        movzx   edx, word [Y_UNDER]
153
        movzx   ebx, word [MOUSE_Y]
154
        movzx   eax, word [MOUSE_X]
2450 mario79 155
        cmp     [redrawmouse_unconditional], 0
156
        je      @f
157
        mov     [redrawmouse_unconditional], 0
9941 Doczom 158
        jmp     .redrawmouse
5154 hidnplayr 159
  @@:
2288 clevermous 160
        cmp     eax, ecx
9941 Doczom 161
        jne     .redrawmouse
2288 clevermous 162
        cmp     ebx, edx
9941 Doczom 163
        je      .nodmp
5154 hidnplayr 164
 
2430 mario79 165
;--------------------------------------
5154 hidnplayr 166
 
2430 mario79 167
align 4
9941 Doczom 168
.redrawmouse:
2288 clevermous 169
        pushfd
170
        cli
171
        call    draw_mouse_under
172
        call    save_draw_mouse
2430 mario79 173
 
2448 mario79 174
        cmp     [_display.select_cursor], select_cursor
175
        jne     @f
2430 mario79 176
 
177
        xor     eax, eax
178
        mov     esi, [current_cursor]
179
 
180
        mov     ax, [Y_UNDER]
9715 Doczom 181
        sub     eax, [esi + CURSOR.hot_y]
2575 mario79 182
        mov     [Y_UNDER_subtraction_CUR_hot_y], ax
2430 mario79 183
        add     eax, [cur.h]
2575 mario79 184
        mov     [Y_UNDER_sub_CUR_hot_y_add_curh], ax
2430 mario79 185
 
186
        mov     ax, [X_UNDER]
9715 Doczom 187
        sub     eax, [esi + CURSOR.hot_x]
2575 mario79 188
        mov     [X_UNDER_subtraction_CUR_hot_x], ax
2430 mario79 189
        add     eax, [cur.w]
2575 mario79 190
        mov     [X_UNDER_sub_CUR_hot_x_add_curh], ax
5154 hidnplayr 191
  @@:
2288 clevermous 192
        popfd
9941 Doczom 193
.nodmp:
2288 clevermous 194
        popad
195
        ret
5154 hidnplayr 196
 
2430 mario79 197
;-----------------------------------------------------------------------------
5154 hidnplayr 198
 
2430 mario79 199
align 4
6230 pathoswith 200
proc set_mouse_data stdcall uses ecx edx, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword
2288 clevermous 201
 
202
        mov     eax, [BtnState]
5154 hidnplayr 203
        and     eax, 0x3FFFFFFF         ; Top 2 bits are used to flag absolute movements
2288 clevermous 204
        mov     [BTN_DOWN], eax
4592 hidnplayr 205
;--------------------------------------
2288 clevermous 206
        mov     eax, [XMoving]
4529 hidnplayr 207
        test    [BtnState], 0x80000000
4592 hidnplayr 208
        jnz     .absolute_x
5853 pathoswith 209
        test    eax, eax
210
        jz      @f
2288 clevermous 211
        call    mouse_acceleration
4592 hidnplayr 212
        add     ax, [MOUSE_X]
5853 pathoswith 213
        jns     .check_x
214
        xor     eax, eax
4592 hidnplayr 215
        jmp     .set_x
216
 .absolute_x:
217
        mov     edx, [_display.width]
218
        mul     edx
219
        shr     eax, 15
220
 .check_x:
5350 serge 221
        cmp     ax, word[_display.width]
4592 hidnplayr 222
        jl      .set_x
5350 serge 223
        mov     ax, word[_display.width]
224
        dec     ax
4592 hidnplayr 225
 .set_x:
226
        mov     [MOUSE_X], ax
2430 mario79 227
;--------------------------------------
5853 pathoswith 228
@@:
2288 clevermous 229
        mov     eax, [YMoving]
4529 hidnplayr 230
        test    [BtnState], 0x40000000
4592 hidnplayr 231
        jnz     .absolute_y
5853 pathoswith 232
        test    eax, eax
233
        jz      @f
2288 clevermous 234
        neg     eax
235
        call    mouse_acceleration
4592 hidnplayr 236
        add     ax, [MOUSE_Y]
5853 pathoswith 237
        jns     .check_y
238
        xor     eax, eax
4592 hidnplayr 239
        jmp     .set_y
240
 .absolute_y:
241
        mov     edx, [_display.height]
242
        mul     edx
243
        shr     eax, 15
244
 .check_y:
5350 serge 245
        cmp     ax, word[_display.height]
4592 hidnplayr 246
        jl      .set_y
5350 serge 247
        mov     ax, word[_display.height]
248
        dec     ax
4592 hidnplayr 249
 .set_y:
250
        mov     [MOUSE_Y], ax
2430 mario79 251
;--------------------------------------
5853 pathoswith 252
@@:
2288 clevermous 253
        mov     eax, [VScroll]
5851 pathoswith 254
        test    eax, eax
255
        jz      @f
2288 clevermous 256
        add     [MOUSE_SCROLL_V], ax
5851 pathoswith 257
        bts     word [BTN_DOWN], 15
258
@@:
2288 clevermous 259
        mov     eax, [HScroll]
5851 pathoswith 260
        test    eax, eax
261
        jz      @f
2288 clevermous 262
        add     [MOUSE_SCROLL_H], ax
5851 pathoswith 263
        bts     dword [BTN_DOWN], 23
264
@@:
2288 clevermous 265
        mov     [mouse_active], 1
3534 clevermous 266
        call    wakeup_osloop
2288 clevermous 267
        ret
268
endp
5154 hidnplayr 269
 
2430 mario79 270
;-----------------------------------------------------------------------------
2288 clevermous 271
mouse_acceleration:
6230 pathoswith 272
        neg     ax
273
        jl      mouse_acceleration
274
        add     al, [mouse_delay]
275
        mul     al
276
        mov     cx, [mouse_speed_factor]
277
        dec     ax
278
        shr     ax, cl
279
        inc     ax
280
        test    eax, eax
281
        jns     @f
282
        neg     ax
5853 pathoswith 283
@@:
2288 clevermous 284
        ret