Rev 9831 | Rev 9850 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1391 | mikedld | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
5363 | yogev_ezra | 3 | ;; Copyright (C) KolibriOS team 2010-2015. All rights reserved. ;; |
1391 | mikedld | 4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
||
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
7 | |||
1531 | diamond | 8 | $Revision: 9848 $ |
1391 | mikedld | 9 | |
10 | include 'mousepointer.inc' |
||
11 | |||
5851 | pathoswith | 12 | ;================================ |
13 | ;/////// public functions /////// |
||
14 | ;================================ |
||
1391 | mikedld | 15 | |
16 | mouse.LEFT_BUTTON_FLAG = 0001b |
||
17 | mouse.RIGHT_BUTTON_FLAG = 0010b |
||
18 | mouse.MIDDLE_BUTTON_FLAG = 0100b |
||
19 | |||
20 | mouse.BUTTONS_MASK = \ |
||
21 | mouse.LEFT_BUTTON_FLAG or \ |
||
22 | mouse.RIGHT_BUTTON_FLAG or \ |
||
23 | mouse.MIDDLE_BUTTON_FLAG |
||
24 | |||
25 | mouse.WINDOW_RESIZE_N_FLAG = 000001b |
||
26 | mouse.WINDOW_RESIZE_W_FLAG = 000010b |
||
27 | mouse.WINDOW_RESIZE_S_FLAG = 000100b |
||
28 | mouse.WINDOW_RESIZE_E_FLAG = 001000b |
||
29 | mouse.WINDOW_MOVE_FLAG = 010000b |
||
30 | |||
31 | mouse.WINDOW_RESIZE_SW_FLAG = \ |
||
32 | mouse.WINDOW_RESIZE_S_FLAG or \ |
||
33 | mouse.WINDOW_RESIZE_W_FLAG |
||
34 | mouse.WINDOW_RESIZE_SE_FLAG = \ |
||
35 | mouse.WINDOW_RESIZE_S_FLAG or \ |
||
36 | mouse.WINDOW_RESIZE_E_FLAG |
||
37 | |||
38 | align 4 |
||
5851 | pathoswith | 39 | ;----------------------------------------------------------------- |
40 | mouse_check_events: |
||
41 | ; Check if mouse buttons state or cursor position has changed |
||
1391 | mikedld | 42 | push eax ebx |
43 | mov al, [BTN_DOWN] |
||
44 | mov bl, [mouse.state.buttons] |
||
45 | and al, mouse.BUTTONS_MASK |
||
46 | mov cl, al |
||
47 | xchg cl, [mouse.state.buttons] |
||
48 | xor bl, al |
||
49 | push eax ebx |
||
50 | |||
51 | ; did any mouse button changed its state? |
||
52 | or bl, bl |
||
53 | jz .check_position |
||
54 | |||
55 | ; yes it did, is that the first button of all pressed down? |
||
56 | or cl, cl |
||
57 | jnz .check_buttons_released |
||
58 | |||
59 | ; yes it is, activate window user is pointing at, if needed |
||
60 | call mouse._.activate_sys_window_under_cursor |
||
61 | |||
62 | ; is there any system button under cursor? |
||
2288 | clevermous | 63 | call mouse._.find_sys_button_under_cursor |
1391 | mikedld | 64 | or eax, eax |
65 | jz .check_buttons_released |
||
66 | |||
67 | ; yes there is, activate it and exit |
||
68 | mov [mouse.active_sys_button.pbid], eax |
||
69 | mov [mouse.active_sys_button.coord], ebx |
||
70 | mov cl, [mouse.state.buttons] |
||
71 | mov [mouse.active_sys_button.buttons], cl |
||
72 | call sys_button_activate_handler |
||
73 | jmp .exit |
||
74 | |||
75 | .check_buttons_released: |
||
76 | cmp [mouse.state.buttons], 0 |
||
77 | jnz .buttons_changed |
||
78 | |||
79 | ; did we press some button earlier? |
||
80 | cmp [mouse.active_sys_button.pbid], 0 |
||
81 | je .buttons_changed |
||
82 | |||
83 | ; yes we did, deactivate it |
||
84 | xor eax, eax |
||
85 | xchg eax, [mouse.active_sys_button.pbid] |
||
86 | mov ebx, [mouse.active_sys_button.coord] |
||
87 | mov cl, [mouse.active_sys_button.buttons] |
||
88 | push eax ebx |
||
89 | call sys_button_deactivate_handler |
||
90 | pop edx ecx |
||
91 | |||
92 | ; is the button under cursor the one we deactivated? |
||
93 | call mouse._.find_sys_button_under_cursor |
||
94 | cmp eax, ecx |
||
95 | jne .exit |
||
96 | cmp ebx, edx |
||
97 | jne .exit |
||
98 | |||
99 | ; yes it is, perform associated action |
||
100 | mov cl, [mouse.active_sys_button.buttons] |
||
101 | call sys_button_perform_handler |
||
102 | jmp .exit |
||
103 | |||
104 | .buttons_changed: |
||
105 | test byte[esp], mouse.LEFT_BUTTON_FLAG |
||
106 | jz @f |
||
107 | mov eax, [esp + 4] |
||
108 | call .call_left_button_handler |
||
109 | |||
2288 | clevermous | 110 | @@: |
111 | test byte[esp], mouse.RIGHT_BUTTON_FLAG |
||
1391 | mikedld | 112 | jz @f |
113 | mov eax, [esp + 4] |
||
114 | call .call_right_button_handler |
||
115 | |||
2288 | clevermous | 116 | @@: |
117 | test byte[esp], mouse.MIDDLE_BUTTON_FLAG |
||
1391 | mikedld | 118 | jz .check_position |
119 | mov eax, [esp + 4] |
||
120 | call .call_middle_button_handler |
||
121 | |||
122 | .check_position: |
||
123 | movzx eax, word[MOUSE_X] |
||
124 | movzx ebx, word[MOUSE_Y] |
||
125 | cmp eax, [mouse.state.pos.x] |
||
126 | jne .position_changed |
||
127 | cmp ebx, [mouse.state.pos.y] |
||
128 | je .exit |
||
129 | |||
130 | .position_changed: |
||
131 | xchg eax, [mouse.state.pos.x] |
||
132 | xchg ebx, [mouse.state.pos.y] |
||
133 | |||
134 | call mouse._.move_handler |
||
135 | |||
136 | .exit: |
||
137 | add esp, 8 |
||
138 | pop ebx eax |
||
139 | ret |
||
140 | |||
141 | .call_left_button_handler: |
||
142 | test eax, mouse.LEFT_BUTTON_FLAG |
||
143 | jnz mouse._.left_button_press_handler |
||
144 | jmp mouse._.left_button_release_handler |
||
145 | |||
146 | .call_right_button_handler: |
||
147 | test eax, mouse.RIGHT_BUTTON_FLAG |
||
148 | jnz mouse._.right_button_press_handler |
||
149 | jmp mouse._.right_button_release_handler |
||
150 | |||
151 | .call_middle_button_handler: |
||
152 | test eax, mouse.MIDDLE_BUTTON_FLAG |
||
153 | jnz mouse._.middle_button_press_handler |
||
154 | jmp mouse._.middle_button_release_handler |
||
155 | |||
5851 | pathoswith | 156 | ;=============================== |
157 | ;////// private functions ////// |
||
158 | ;=============================== |
||
1391 | mikedld | 159 | |
160 | uglobal |
||
161 | mouse.state: |
||
162 | .pos POINT |
||
163 | .buttons db ? |
||
164 | |||
5851 | pathoswith | 165 | ; NOTE: since there's no unique and lifetime-constant button identifiers, |
166 | ; we are using two dwords to identify each of them: |
||
167 | ; * pbid - process slot (high 8 bits) and button id (low 24 bits) pack |
||
168 | ; * coord - left (high 16 bits) and top (low 16 bits) coordinates pack |
||
1391 | mikedld | 169 | align 4 |
170 | mouse.active_sys_button: |
||
171 | .pbid dd ? |
||
172 | .coord dd ? |
||
173 | .buttons db ? |
||
174 | |||
175 | align 4 |
||
176 | mouse.active_sys_window: |
||
177 | .pslot dd ? |
||
178 | .old_box BOX |
||
179 | .new_box BOX |
||
180 | .delta POINT |
||
181 | .last_ticks dd ? |
||
182 | .action db ? |
||
183 | endg |
||
184 | |||
5870 | GerdtR | 185 | iglobal |
186 | fl_moving db 0 |
||
187 | rb 3 |
||
188 | endg |
||
189 | |||
1391 | mikedld | 190 | align 4 |
5851 | pathoswith | 191 | ;----------------------------------------------------------------- |
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] |
||
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 |
||
203 | @@: |
||
1391 | mikedld | 204 | test [mouse.state.buttons], not mouse.LEFT_BUTTON_FLAG |
205 | jnz .exit |
||
206 | |||
207 | call mouse._.find_sys_window_under_cursor |
||
208 | call mouse._.check_sys_window_actions |
||
209 | mov [mouse.active_sys_window.action], al |
||
210 | or eax, eax |
||
211 | jz .exit |
||
212 | |||
213 | xchg eax, edx |
||
214 | test dl, mouse.WINDOW_MOVE_FLAG |
||
215 | jz @f |
||
216 | |||
5851 | pathoswith | 217 | bt dword [BTN_DOWN], 24 |
218 | jnc @f |
||
1391 | mikedld | 219 | |
220 | mov [mouse.active_sys_window.last_ticks], 0 |
||
221 | call sys_window_maximize_handler |
||
222 | jmp .exit |
||
223 | |||
2288 | clevermous | 224 | @@: |
225 | test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED |
||
1391 | mikedld | 226 | jnz .exit |
227 | mov [mouse.active_sys_window.pslot], esi |
||
228 | lea eax, [edi + WDATA.box] |
||
229 | mov ebx, mouse.active_sys_window.old_box |
||
2381 | hidnplayr | 230 | mov ecx, sizeof.BOX |
1391 | mikedld | 231 | call memmove |
232 | mov ebx, mouse.active_sys_window.new_box |
||
233 | call memmove |
||
234 | test edx, mouse.WINDOW_MOVE_FLAG |
||
235 | jz @f |
||
236 | |||
237 | call .calculate_n_delta |
||
238 | call .calculate_w_delta |
||
239 | jmp .call_window_handler |
||
240 | |||
2288 | clevermous | 241 | @@: |
242 | test dl, mouse.WINDOW_RESIZE_W_FLAG |
||
1391 | mikedld | 243 | jz @f |
244 | call .calculate_w_delta |
||
245 | |||
2288 | clevermous | 246 | @@: |
247 | test dl, mouse.WINDOW_RESIZE_S_FLAG |
||
1391 | mikedld | 248 | jz @f |
249 | call .calculate_s_delta |
||
250 | |||
2288 | clevermous | 251 | @@: |
252 | test dl, mouse.WINDOW_RESIZE_E_FLAG |
||
1391 | mikedld | 253 | jz .call_window_handler |
254 | call .calculate_e_delta |
||
255 | |||
256 | .call_window_handler: |
||
257 | .exit: |
||
258 | ret |
||
259 | |||
260 | .calculate_n_delta: |
||
261 | mov eax, [mouse.state.pos.y] |
||
262 | sub eax, [mouse.active_sys_window.old_box.top] |
||
263 | mov [mouse.active_sys_window.delta.y], eax |
||
264 | ret |
||
265 | |||
266 | .calculate_w_delta: |
||
267 | mov eax, [mouse.state.pos.x] |
||
268 | sub eax, [mouse.active_sys_window.old_box.left] |
||
269 | mov [mouse.active_sys_window.delta.x], eax |
||
270 | ret |
||
271 | |||
272 | .calculate_s_delta: |
||
273 | mov eax, [mouse.active_sys_window.old_box.top] |
||
274 | add eax, [mouse.active_sys_window.old_box.height] |
||
275 | sub eax, [mouse.state.pos.y] |
||
276 | mov [mouse.active_sys_window.delta.y], eax |
||
277 | ret |
||
278 | |||
279 | .calculate_e_delta: |
||
280 | mov eax, [mouse.active_sys_window.old_box.left] |
||
281 | add eax, [mouse.active_sys_window.old_box.width] |
||
282 | sub eax, [mouse.state.pos.x] |
||
283 | mov [mouse.active_sys_window.delta.x], eax |
||
284 | ret |
||
285 | |||
286 | align 4 |
||
5851 | pathoswith | 287 | ;----------------------------------------------------------------- |
288 | mouse._.left_button_release_handler: |
||
289 | ; Called when left mouse button has been released |
||
290 | bts dword [BTN_DOWN], 16 |
||
1391 | mikedld | 291 | xor esi, esi |
292 | xchg esi, [mouse.active_sys_window.pslot] |
||
293 | or esi, esi |
||
294 | jz .exit |
||
295 | |||
296 | mov eax, esi |
||
297 | shl eax, 5 |
||
298 | add eax, window_data + WDATA.box |
||
299 | mov ebx, mouse.active_sys_window.old_box |
||
2381 | hidnplayr | 300 | mov ecx, sizeof.BOX |
1391 | mikedld | 301 | call memmove |
302 | |||
303 | mov eax, mouse.active_sys_window.old_box |
||
304 | mov ebx, mouse.active_sys_window.new_box |
||
305 | call sys_window_end_moving_handler |
||
306 | |||
307 | .exit: |
||
2011 | mikedld | 308 | and [mouse.active_sys_window.action], 0 |
5870 | GerdtR | 309 | mov [fl_moving], 0 |
1391 | mikedld | 310 | ret |
311 | |||
5851 | pathoswith | 312 | mouse._.right_button_press_handler: |
313 | bts word [BTN_DOWN], 9 |
||
1391 | mikedld | 314 | test [mouse.state.buttons], not mouse.RIGHT_BUTTON_FLAG |
5851 | pathoswith | 315 | jnz @f |
1391 | mikedld | 316 | call mouse._.find_sys_window_under_cursor |
317 | call mouse._.check_sys_window_actions |
||
318 | test al, mouse.WINDOW_MOVE_FLAG |
||
5851 | pathoswith | 319 | jz @f |
320 | jmp sys_window_rollup_handler |
||
1391 | mikedld | 321 | |
5851 | pathoswith | 322 | mouse._.right_button_release_handler: |
323 | bts dword [BTN_DOWN], 17 |
||
324 | @@: |
||
1391 | mikedld | 325 | ret |
326 | |||
5851 | pathoswith | 327 | mouse._.middle_button_press_handler: |
328 | bts word [BTN_DOWN], 10 |
||
1391 | mikedld | 329 | ret |
330 | |||
5851 | pathoswith | 331 | mouse._.middle_button_release_handler: |
332 | bts dword [BTN_DOWN], 18 |
||
1391 | mikedld | 333 | ret |
334 | |||
335 | align 4 |
||
5851 | pathoswith | 336 | ;----------------------------------------------------------------- |
337 | mouse._.move_handler: |
||
338 | ; Called when cursor has been moved |
||
1391 | mikedld | 339 | ;> eax = old x coord |
340 | ;> ebx = old y coord |
||
9848 | rgimad | 341 | push eax ebx |
342 | |||
343 | call mouse._.find_sys_window_under_cursor |
||
344 | call mouse._.check_sys_window_actions |
||
345 | |||
346 | cmp al, mouse.WINDOW_RESIZE_SW_FLAG |
||
347 | jne .not_sw |
||
348 | ; DEBUGF 1, "RESIZE SOUTH-WEST\n" |
||
349 | |||
350 | mov eax, [def_cursor_dresize2] |
||
351 | |||
352 | jmp .set_resizing_cursor |
||
353 | .not_sw: |
||
354 | cmp al, mouse.WINDOW_RESIZE_SE_FLAG |
||
355 | jne .not_se |
||
356 | ; DEBUGF 1, "RESIZE SOUTH-EAST\n" |
||
357 | |||
358 | mov eax, [def_cursor_dresize1] |
||
359 | |||
360 | jmp .set_resizing_cursor |
||
361 | .not_se: |
||
362 | cmp al, mouse.WINDOW_RESIZE_W_FLAG |
||
363 | jne .not_w |
||
364 | ; DEBUGF 1, "RESIZE WEST\n" |
||
365 | |||
366 | mov eax, [def_cursor_hresize] |
||
367 | |||
368 | jmp .set_resizing_cursor |
||
369 | .not_w: |
||
370 | cmp al, mouse.WINDOW_RESIZE_S_FLAG |
||
371 | jne .not_s |
||
372 | ; DEBUGF 1, "RESIZE SOUTH\n" |
||
373 | |||
374 | mov eax, [def_cursor_vresize] |
||
375 | |||
376 | jmp .set_resizing_cursor |
||
377 | .not_s: |
||
378 | cmp al, mouse.WINDOW_RESIZE_E_FLAG |
||
379 | jne .not_in_resize_area |
||
380 | ; DEBUGF 1, "RESIZE EAST\n" |
||
381 | |||
382 | mov eax, [def_cursor_hresize] |
||
383 | |||
384 | .set_resizing_cursor: |
||
385 | ; change cursor to resizing cursor |
||
386 | shl esi, BSF sizeof.APPDATA |
||
387 | add esi, SLOT_BASE |
||
388 | |||
389 | ; if resizing cursor we need (eax) isnt set already, set it |
||
390 | cmp eax, [esi + APPDATA.cursor] |
||
391 | je @f |
||
392 | |||
393 | xchg eax, [esi + APPDATA.cursor] ; set resizing cursor, prev cursor goes to eax |
||
394 | ; save previous cursor (will be restored when we'll get out of the resizing area) |
||
395 | ; if we change resizing cursor to resizing cursor then dont update previous cursor |
||
396 | cmp eax, [def_cursor_hresize] |
||
397 | je @f |
||
398 | cmp eax, [def_cursor_vresize] |
||
399 | je @f |
||
400 | cmp eax, [def_cursor_dresize1] |
||
401 | je @f |
||
402 | cmp eax, [def_cursor_dresize2] |
||
403 | je @f |
||
404 | |||
405 | mov [esi + APPDATA.temp_cursor], eax ; save prev cursor |
||
406 | |||
407 | @@: |
||
408 | jmp .end1 |
||
409 | .not_in_resize_area: |
||
410 | shl esi, BSF sizeof.APPDATA |
||
411 | add esi, SLOT_BASE |
||
412 | mov eax, [esi + APPDATA.temp_cursor] |
||
413 | |||
414 | test eax, eax |
||
415 | jz .end1 |
||
416 | |||
417 | ; restore prev cursor |
||
418 | mov [esi + APPDATA.temp_cursor], 0 |
||
419 | mov [esi + APPDATA.cursor], eax |
||
420 | |||
421 | .end1: |
||
422 | pop ebx eax |
||
423 | |||
1391 | mikedld | 424 | cmp [mouse.active_sys_button.pbid], 0 |
425 | jnz .exit |
||
426 | |||
427 | mov esi, [mouse.active_sys_window.pslot] |
||
428 | or esi, esi |
||
429 | jz .exit |
||
430 | |||
431 | mov eax, mouse.active_sys_window.new_box |
||
432 | mov ebx, mouse.active_sys_window.old_box |
||
2381 | hidnplayr | 433 | mov ecx, sizeof.BOX |
1391 | mikedld | 434 | call memmove |
435 | |||
436 | mov dl, [mouse.active_sys_window.action] |
||
437 | test dl, mouse.WINDOW_MOVE_FLAG |
||
438 | jz .check_resize_w |
||
439 | |||
440 | mov eax, [mouse.state.pos.x] |
||
441 | sub eax, [mouse.active_sys_window.delta.x] |
||
442 | mov [mouse.active_sys_window.new_box.left], eax |
||
443 | mov eax, [mouse.state.pos.y] |
||
444 | sub eax, [mouse.active_sys_window.delta.y] |
||
445 | mov [mouse.active_sys_window.new_box.top], eax |
||
446 | |||
447 | mov eax, [mouse.active_sys_window.new_box.left] |
||
448 | or eax, eax |
||
449 | jge @f |
||
450 | xor eax, eax |
||
451 | mov [mouse.active_sys_window.new_box.left], eax |
||
2288 | clevermous | 452 | @@: |
453 | add eax, [mouse.active_sys_window.new_box.width] |
||
5350 | serge | 454 | cmp eax, [_display.width] |
1391 | mikedld | 455 | jl @f |
5350 | serge | 456 | sub eax, [_display.width] |
8928 | dunkaist | 457 | inc eax |
1391 | mikedld | 458 | sub [mouse.active_sys_window.new_box.left], eax |
2288 | clevermous | 459 | @@: |
460 | mov eax, [mouse.active_sys_window.new_box.top] |
||
1391 | mikedld | 461 | or eax, eax |
462 | jge @f |
||
463 | xor eax, eax |
||
464 | mov [mouse.active_sys_window.new_box.top], eax |
||
2288 | clevermous | 465 | @@: |
466 | add eax, [mouse.active_sys_window.new_box.height] |
||
5350 | serge | 467 | cmp eax, [_display.height] |
468 | jl .call_window_handler |
||
469 | sub eax, [_display.height] |
||
8928 | dunkaist | 470 | inc eax |
1391 | mikedld | 471 | sub [mouse.active_sys_window.new_box.top], eax |
472 | jmp .call_window_handler |
||
473 | |||
474 | .check_resize_w: |
||
475 | test dl, mouse.WINDOW_RESIZE_W_FLAG |
||
476 | jz .check_resize_s |
||
477 | |||
478 | mov eax, [mouse.state.pos.x] |
||
479 | sub eax, [mouse.active_sys_window.delta.x] |
||
480 | mov [mouse.active_sys_window.new_box.left], eax |
||
481 | sub eax, [mouse.active_sys_window.old_box.left] |
||
482 | sub [mouse.active_sys_window.new_box.width], eax |
||
483 | |||
484 | mov eax, [mouse.active_sys_window.new_box.width] |
||
485 | sub eax, 127 |
||
486 | jge @f |
||
487 | add [mouse.active_sys_window.new_box.left], eax |
||
488 | mov [mouse.active_sys_window.new_box.width], 127 |
||
2288 | clevermous | 489 | @@: |
490 | mov eax, [mouse.active_sys_window.new_box.left] |
||
1391 | mikedld | 491 | or eax, eax |
492 | jge .check_resize_s |
||
493 | add [mouse.active_sys_window.new_box.width], eax |
||
494 | xor eax, eax |
||
495 | mov [mouse.active_sys_window.new_box.left], eax |
||
496 | |||
497 | .check_resize_s: |
||
498 | test dl, mouse.WINDOW_RESIZE_S_FLAG |
||
499 | jz .check_resize_e |
||
500 | |||
501 | mov eax, [mouse.state.pos.y] |
||
502 | add eax, [mouse.active_sys_window.delta.y] |
||
503 | sub eax, [mouse.active_sys_window.old_box.top] |
||
504 | mov [mouse.active_sys_window.new_box.height], eax |
||
505 | |||
506 | push eax |
||
507 | mov edi, esi |
||
508 | shl edi, 5 |
||
509 | add edi, window_data |
||
510 | call window._.get_rolledup_height |
||
511 | mov ecx, eax |
||
512 | pop eax |
||
513 | mov eax, [mouse.active_sys_window.new_box.height] |
||
514 | cmp eax, ecx |
||
515 | jge @f |
||
516 | mov eax, ecx |
||
517 | mov [mouse.active_sys_window.new_box.height], eax |
||
2288 | clevermous | 518 | @@: |
519 | add eax, [mouse.active_sys_window.new_box.top] |
||
5350 | serge | 520 | cmp eax, [_display.height] |
521 | jl .check_resize_e |
||
522 | sub eax, [_display.height] |
||
1391 | mikedld | 523 | neg eax |
524 | add [mouse.active_sys_window.new_box.height], eax |
||
5350 | serge | 525 | mov ecx, [_display.height] |
1391 | mikedld | 526 | cmp ecx, eax |
5350 | serge | 527 | jg .check_resize_e |
1391 | mikedld | 528 | mov [mouse.active_sys_window.new_box.height], ecx |
529 | |||
530 | .check_resize_e: |
||
531 | test dl, mouse.WINDOW_RESIZE_E_FLAG |
||
532 | jz .call_window_handler |
||
533 | |||
534 | mov eax, [mouse.state.pos.x] |
||
535 | add eax, [mouse.active_sys_window.delta.x] |
||
536 | sub eax, [mouse.active_sys_window.old_box.left] |
||
537 | mov [mouse.active_sys_window.new_box.width], eax |
||
538 | |||
539 | mov eax, [mouse.active_sys_window.new_box.width] |
||
540 | cmp eax, 127 |
||
541 | jge @f |
||
542 | mov eax, 127 |
||
543 | mov [mouse.active_sys_window.new_box.width], eax |
||
2288 | clevermous | 544 | @@: |
545 | add eax, [mouse.active_sys_window.new_box.left] |
||
5350 | serge | 546 | cmp eax, [_display.width] |
547 | jl .call_window_handler |
||
548 | sub eax, [_display.width] |
||
1391 | mikedld | 549 | neg eax |
550 | add [mouse.active_sys_window.new_box.width], eax |
||
5350 | serge | 551 | mov ecx, [_display.width] |
1391 | mikedld | 552 | cmp ecx, eax |
5350 | serge | 553 | jg .call_window_handler |
1391 | mikedld | 554 | mov [mouse.active_sys_window.new_box.width], ecx |
555 | |||
556 | .call_window_handler: |
||
557 | mov eax, mouse.active_sys_window.old_box |
||
558 | mov ebx, mouse.active_sys_window.new_box |
||
559 | |||
560 | push esi |
||
561 | mov esi, mouse.active_sys_window.old_box |
||
562 | mov edi, mouse.active_sys_window.new_box |
||
2381 | hidnplayr | 563 | mov ecx, sizeof.BOX / 4 |
1391 | mikedld | 564 | repe |
565 | cmpsd |
||
566 | pop esi |
||
567 | je .exit |
||
568 | |||
5870 | GerdtR | 569 | test [fl_moving], 1 |
570 | jnz @f |
||
571 | |||
572 | mov [fl_moving], 1 |
||
573 | push edi |
||
574 | mov edi, esi |
||
575 | shl edi, 5 |
||
576 | add edi, WDATA.box + window_data |
||
577 | call window._.draw_negative_box |
||
578 | pop edi |
||
579 | @@: |
||
580 | |||
581 | |||
1391 | mikedld | 582 | mov [mouse.active_sys_window.last_ticks], 0 |
583 | call sys_window_moving_handler |
||
584 | |||
585 | .exit: |
||
586 | ret |
||
587 | |||
588 | align 4 |
||
5851 | pathoswith | 589 | ;----------------------------------------------------------------- |
590 | mouse._.find_sys_window_under_cursor: |
||
591 | ; Find system window object which is currently visible on screen |
||
592 | ; and has mouse cursor within its bounds |
||
1391 | mikedld | 593 | ;< esi = process slot |
594 | ;< edi = pointer to WDATA struct |
||
2446 | mario79 | 595 | mov esi, [mouse.state.pos.y] |
596 | mov esi, [d_width_calc_area + esi*4] |
||
597 | |||
5351 | serge | 598 | add esi, [_display.win_map] |
1391 | mikedld | 599 | add esi, [mouse.state.pos.x] |
600 | movzx esi, byte[esi] |
||
601 | mov edi, esi |
||
602 | shl edi, 5 |
||
603 | add edi, window_data |
||
604 | ret |
||
605 | |||
606 | align 4 |
||
5851 | pathoswith | 607 | ;----------------------------------------------------------------- |
608 | mouse._.activate_sys_window_under_cursor: |
||
609 | ; activate and redraw window under cursor (if necessary) |
||
1391 | mikedld | 610 | call mouse._.find_sys_window_under_cursor |
611 | movzx esi, word[WIN_STACK + esi * 2] |
||
612 | lea esi, [WIN_POS + esi * 2] |
||
613 | jmp waredraw |
||
614 | |||
615 | align 4 |
||
5851 | pathoswith | 616 | ;----------------------------------------------------------------- |
617 | mouse._.find_sys_button_under_cursor: |
||
618 | ; Find system button object which is currently visible on screen |
||
619 | ; and has mouse cursor within its bounds |
||
1391 | mikedld | 620 | ;< eax = pack[8(process slot), 24(button id)] or 0 |
621 | ;< ebx = pack[16(button x coord), 16(button y coord)] |
||
622 | push ecx edx esi edi |
||
623 | |||
624 | call mouse._.find_sys_window_under_cursor |
||
625 | mov edx, esi |
||
626 | |||
627 | ; check if any process button contains cursor |
||
628 | mov eax, [BTN_ADDR] |
||
629 | mov ecx, [eax] |
||
2384 | hidnplayr | 630 | imul esi, ecx, sizeof.SYS_BUTTON |
1391 | mikedld | 631 | add esi, eax |
632 | inc ecx |
||
2384 | hidnplayr | 633 | add esi, sizeof.SYS_BUTTON |
1391 | mikedld | 634 | |
635 | .next_button: |
||
636 | dec ecx |
||
637 | jz .not_found |
||
638 | |||
2384 | hidnplayr | 639 | add esi, -sizeof.SYS_BUTTON |
1391 | mikedld | 640 | |
641 | ; does it belong to our process? |
||
642 | cmp dx, [esi + SYS_BUTTON.pslot] |
||
643 | jne .next_button |
||
644 | |||
645 | ; does it contain cursor coordinates? |
||
646 | mov eax, [mouse.state.pos.x] |
||
647 | sub eax, [edi + WDATA.box.left] |
||
648 | sub ax, [esi + SYS_BUTTON.left] |
||
649 | jl .next_button |
||
650 | sub ax, [esi + SYS_BUTTON.width] |
||
651 | jge .next_button |
||
652 | mov eax, [mouse.state.pos.y] |
||
653 | sub eax, [edi + WDATA.box.top] |
||
654 | sub ax, [esi + SYS_BUTTON.top] |
||
655 | jl .next_button |
||
656 | sub ax, [esi + SYS_BUTTON.height] |
||
657 | jge .next_button |
||
658 | |||
659 | ; okay, return it |
||
660 | shl edx, 24 |
||
661 | mov eax, dword[esi + SYS_BUTTON.id_hi - 2] |
||
662 | mov ax, [esi + SYS_BUTTON.id_lo] |
||
663 | and eax, 0x0ffffff |
||
664 | or eax, edx |
||
665 | mov ebx, dword[esi + SYS_BUTTON.left - 2] |
||
666 | mov bx, [esi + SYS_BUTTON.top] |
||
667 | jmp .exit |
||
668 | |||
669 | .not_found: |
||
670 | xor eax, eax |
||
671 | xor ebx, ebx |
||
672 | |||
673 | .exit: |
||
674 | pop edi esi edx ecx |
||
675 | ret |
||
676 | |||
677 | align 4 |
||
5851 | pathoswith | 678 | ;----------------------------------------------------------------- |
679 | mouse._.check_sys_window_actions: |
||
1391 | mikedld | 680 | ;< eax = action flags or 0 |
681 | ; is window movable? |
||
682 | test byte[edi + WDATA.cl_titlebar + 3], 0x01 |
||
683 | jnz .no_action |
||
684 | |||
685 | mov eax, [mouse.state.pos.x] |
||
686 | mov ebx, [mouse.state.pos.y] |
||
687 | sub eax, [edi + WDATA.box.left] |
||
688 | sub ebx, [edi + WDATA.box.top] |
||
689 | |||
690 | ; is there a window titlebar under cursor? |
||
691 | push eax |
||
692 | call window._.get_titlebar_height |
||
693 | cmp ebx, eax |
||
694 | pop eax |
||
695 | jl .move_action |
||
696 | |||
697 | ; no there isn't, can it be resized then? |
||
698 | mov dl, [edi + WDATA.fl_wstyle] |
||
699 | and dl, 0x0f |
||
5851 | pathoswith | 700 | ; NOTE: dangerous optimization, revise if window types changed |
701 | ; this currently implies only types 2 and 3 could be resized |
||
1391 | mikedld | 702 | test dl, 2 |
703 | jz .no_action |
||
704 | |||
705 | mov ecx, [edi + WDATA.box.width] |
||
706 | add ecx, -window.BORDER_SIZE |
||
707 | mov edx, [edi + WDATA.box.height] |
||
708 | add edx, -window.BORDER_SIZE |
||
709 | |||
710 | ; is it rolled up? |
||
711 | test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP |
||
712 | jnz .resize_w_or_e_action |
||
713 | |||
714 | cmp eax, window.BORDER_SIZE |
||
715 | jl .resize_w_action |
||
716 | cmp eax, ecx |
||
717 | jg .resize_e_action |
||
718 | cmp ebx, edx |
||
719 | jle .no_action |
||
720 | |||
721 | .resize_s_action: |
||
722 | cmp eax, window.BORDER_SIZE + 10 |
||
723 | jl .resize_sw_action |
||
724 | add ecx, -10 |
||
725 | cmp eax, ecx |
||
726 | jge .resize_se_action |
||
727 | mov eax, mouse.WINDOW_RESIZE_S_FLAG |
||
728 | jmp .exit |
||
729 | |||
730 | .resize_w_or_e_action: |
||
731 | cmp eax, window.BORDER_SIZE + 10 |
||
732 | jl .resize_w_action.direct |
||
733 | add ecx, -10 |
||
734 | cmp eax, ecx |
||
735 | jg .resize_e_action.direct |
||
736 | jmp .no_action |
||
737 | |||
738 | .resize_w_action: |
||
739 | add edx, -10 |
||
740 | cmp ebx, edx |
||
741 | jge .resize_sw_action |
||
742 | .resize_w_action.direct: |
||
743 | mov eax, mouse.WINDOW_RESIZE_W_FLAG |
||
744 | jmp .exit |
||
745 | |||
746 | .resize_e_action: |
||
747 | add edx, -10 |
||
748 | cmp ebx, edx |
||
749 | jge .resize_se_action |
||
750 | .resize_e_action.direct: |
||
751 | mov eax, mouse.WINDOW_RESIZE_E_FLAG |
||
752 | jmp .exit |
||
753 | |||
754 | .resize_sw_action: |
||
755 | mov eax, mouse.WINDOW_RESIZE_SW_FLAG |
||
756 | jmp .exit |
||
757 | |||
758 | .resize_se_action: |
||
759 | mov eax, mouse.WINDOW_RESIZE_SE_FLAG |
||
760 | jmp .exit |
||
761 | |||
762 | .move_action: |
||
763 | mov eax, mouse.WINDOW_MOVE_FLAG |
||
764 | jmp .exit |
||
765 | |||
766 | .no_action: |
||
767 | xor eax, eax |
||
768 | |||
769 | .exit: |
||
770 | ret |
||
9514 | rgimad | 771 | ;----------------------------------------------------------------------------- |
772 | |||
773 | align 4 |
||
774 | readmousepos: |
||
775 | ; eax=0 screen relative |
||
776 | ; eax=1 window relative |
||
777 | ; eax=2 buttons pressed |
||
778 | ; eax=3 buttons pressed ext |
||
779 | ; eax=4 load cursor |
||
780 | ; eax=5 set cursor |
||
781 | ; eax=6 delete cursor |
||
782 | ; eax=7 get mouse_z |
||
783 | ; eax=8 load cursor unicode |
||
784 | cmp ebx, 8 |
||
785 | ja @f |
||
786 | jmp dword[.mousefn+ebx*4] |
||
787 | |||
788 | align 4 |
||
789 | .mousefn: |
||
790 | dd .msscreen |
||
791 | dd .mswin |
||
792 | dd .msbutton |
||
793 | dd .msbuttonExt |
||
794 | dd .app_load_cursor |
||
795 | dd .app_set_cursor |
||
796 | dd .app_delete_cursor |
||
797 | dd .msz |
||
798 | dd .loadCursorUni |
||
799 | |||
800 | .msscreen: |
||
801 | mov eax, [MOUSE_X] |
||
802 | shl eax, 16 |
||
803 | mov ax, [MOUSE_Y] |
||
9831 | dunkaist | 804 | mov [esp + SYSCALL_STACK.eax], eax |
9514 | rgimad | 805 | @@: |
806 | ret |
||
807 | |||
808 | .mswin: |
||
809 | mov eax, [MOUSE_X] |
||
810 | shl eax, 16 |
||
811 | mov ax, [MOUSE_Y] |
||
9709 | Doczom | 812 | mov esi, [current_slot_idx] |
813 | shl esi, BSF sizeof.WDATA |
||
814 | mov bx, word [esi + window_data + WDATA.box.left] |
||
9514 | rgimad | 815 | shl ebx, 16 |
9709 | Doczom | 816 | mov bx, word [esi + window_data + WDATA.box.top] |
9514 | rgimad | 817 | sub eax, ebx |
9828 | Doczom | 818 | mov edi, [current_slot] |
819 | sub ax, word[edi + APPDATA.wnd_clientbox.top] |
||
9514 | rgimad | 820 | rol eax, 16 |
9828 | Doczom | 821 | sub ax, word[edi + APPDATA.wnd_clientbox.left] |
9514 | rgimad | 822 | rol eax, 16 |
9831 | dunkaist | 823 | mov [esp + SYSCALL_STACK.eax], eax |
9514 | rgimad | 824 | ret |
825 | |||
826 | .msbutton: |
||
827 | movzx eax, byte [BTN_DOWN] |
||
9831 | dunkaist | 828 | mov [esp + SYSCALL_STACK.eax], eax |
9514 | rgimad | 829 | ret |
830 | |||
831 | .msbuttonExt: |
||
832 | mov eax, [BTN_DOWN] |
||
9831 | dunkaist | 833 | mov [esp + SYSCALL_STACK.eax], eax |
9514 | rgimad | 834 | ret |
835 | |||
836 | .app_load_cursor: |
||
837 | cmp ecx, OS_BASE |
||
838 | jae @f |
||
839 | stdcall load_cursor, ecx, edx |
||
9831 | dunkaist | 840 | mov [esp + SYSCALL_STACK.eax], eax |
9514 | rgimad | 841 | @@: |
842 | ret |
||
843 | |||
844 | .loadCursorUni: |
||
845 | cmp ecx, OS_BASE |
||
846 | jae @b |
||
847 | push ecx edx |
||
848 | stdcall kernel_alloc, maxPathLength |
||
849 | mov edi, eax |
||
850 | pop eax esi |
||
851 | push edi |
||
852 | call getFullPath |
||
853 | pop ebp |
||
854 | test eax, eax |
||
855 | jz @f |
||
856 | stdcall load_cursor, ebp, LOAD_FROM_FILE |
||
9831 | dunkaist | 857 | mov [esp + SYSCALL_STACK.eax], eax |
9514 | rgimad | 858 | @@: |
859 | stdcall kernel_free, ebp |
||
860 | ret |
||
861 | |||
862 | .app_set_cursor: |
||
863 | stdcall set_cursor, ecx |
||
9831 | dunkaist | 864 | mov [esp + SYSCALL_STACK.eax], eax |
9514 | rgimad | 865 | ret |
866 | |||
867 | .app_delete_cursor: |
||
868 | stdcall delete_cursor, ecx |
||
9831 | dunkaist | 869 | mov [esp + SYSCALL_STACK.eax], eax |
9514 | rgimad | 870 | ret |
871 | |||
872 | .msz: |
||
873 | mov edi, [thread_count] |
||
874 | movzx edi, word [WIN_POS + edi*2] |
||
875 | cmp edi, [current_slot_idx] |
||
876 | jne @f |
||
877 | mov ax, [MOUSE_SCROLL_H] |
||
878 | shl eax, 16 |
||
879 | mov ax, [MOUSE_SCROLL_V] |
||
9831 | dunkaist | 880 | mov [esp + SYSCALL_STACK.eax], eax |
9514 | rgimad | 881 | and [MOUSE_SCROLL_H], word 0 |
882 | and [MOUSE_SCROLL_V], word 0 |
||
883 | ret |
||
884 | @@: |
||
9831 | dunkaist | 885 | and [esp + SYSCALL_STACK.eax], dword 0 |
886 | ret>>>>> |