Changeset 1391
- Timestamp:
- 02/06/2010 09:08:19 PM (5 weeks ago)
- Location:
- kernel/trunk
- Files:
-
- 1 added
- 6 modified
- 1 copied
-
core/syscall.inc (modified) (3 diffs)
-
gui/button.inc (modified) (9 diffs)
-
gui/event.inc (modified) (2 diffs)
-
gui/mouse.inc (added)
-
gui/mousepointer.inc (copied) (copied from kernel/trunk/gui/mouse.inc)
-
gui/window.inc (modified) (14 diffs)
-
kernel.asm (modified) (3 diffs)
-
kernel32.inc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kernel/trunk/core/syscall.inc
r1375 r1391 170 170 dd syscall_putimage_palette; 65-PutImagePalette 171 171 dd sys_process_def ; 66-Process definitions - keyboard 172 dd sys_window_move ; 67-Window move or resize172 dd 0 173 173 dd 0 174 174 dd 0 … … 181 181 servetable2: 182 182 183 dd sys _drawwindow; 0-DrawWindow183 dd syscall_draw_window ; 0-DrawWindow 184 184 dd syscall_setpixel ; 1-SetPixel 185 185 dd sys_getkey ; 2-GetKey … … 248 248 dd cross_order ; 65-PutImagePalette 249 249 dd cross_order ; 66-Process definitions - keyboard 250 dd cross_order; 67-Window move or resize250 dd syscall_move_window ; 67-Window move or resize 251 251 dd f68 ; 68-Some internal services 252 252 dd sys_debug_services ; 69-Debug 253 253 dd cross_order ; 70-Common file system interface, version 2 254 dd syscall_window settings; 71-Window settings254 dd syscall_window_settings ; 71-Window settings 255 255 dd sys_sendwindowmsg ; 72-Send window message 256 256 times 255 - ( ($-servetable2) /4 ) dd undefined_syscall -
kernel/trunk/gui/button.inc
r1381 r1391 1 1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 2 ;; ;; 3 ;; Copyright (C) KolibriOS team 2004-20 08. All rights reserved. ;;3 ;; Copyright (C) KolibriOS team 2004-2010. All rights reserved. ;; 4 4 ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; 5 5 ;; Distributed under terms of the GNU General Public License ;; … … 9 9 $Revision$ 10 10 11 12 button._.MAX_BUTTONS = 409513 14 15 11 ;============================================================================== 16 12 ;///// public functions /////////////////////////////////////////////////////// 17 13 ;============================================================================== 14 15 button.MAX_BUTTONS = 4095 18 16 19 17 struc SYS_BUTTON … … 26 24 .height dw ? 27 25 .id_hi dw ? 28 .aligndw ?26 dw ? 29 27 .sizeof: 30 28 } … … 32 30 SYS_BUTTON SYS_BUTTON 33 31 end virtual 34 35 iglobal36 mx dw 0x0 ; keeps the x mouse's position when it was clicked37 my dw 0x0 ; keeps the y mouse's position when it was clicked38 bPressedMouseXY_B db 0x039 btn_down_determ db 0x040 endg41 32 42 33 align 4 … … 68 59 mov edi, [BTN_ADDR] 69 60 mov eax, [edi] 70 cmp eax, button. _.MAX_BUTTONS61 cmp eax, button.MAX_BUTTONS 71 62 jge .exit 72 63 … … 229 220 xor ecx, ecx 230 221 add ecx, -SYS_BUTTON.sizeof 222 add esi, SYS_BUTTON.sizeof 231 223 232 224 .next_button: … … 264 256 align 4 265 257 ;------------------------------------------------------------------------------ 266 check_buttons: ;/////////////////////////////////////////////////////////////// 267 ;------------------------------------------------------------------------------ 268 ;? <description> 269 ;------------------------------------------------------------------------------ 270 cmp byte[BTN_DOWN], 0 ; mouse buttons pressed 271 jnz @f 272 mov [bPressedMouseXY_B], 0 273 ret 274 275 @@: pushad 276 xor esi, esi 277 mov edi, [BTN_ADDR] 278 mov edx, [edi] 279 test edx, edx 280 jne @f 281 popad 282 ret 283 284 ;here i catch the coordinates when the mouse's button is clicked 285 @@: push ax 286 cmp [bPressedMouseXY_B], 0 ; FALSE 287 jnz @f 288 mov [bPressedMouseXY_B], 1 ; TRUE - it was already clicked 289 mov ax, [MOUSE_X] 290 mov [mx], ax 291 mov ax, [MOUSE_Y] 292 mov [my], ax 293 @@: pop ax 294 ;and it is only refreshed after the mouse's button release 295 296 push esi 297 inc edx 298 push edx 299 300 .buttonnewcheck: 301 pop edx 302 pop esi 303 inc esi 304 cmp edx, esi 305 jge .bch 306 307 popad 308 ret 309 310 .bch: 311 push esi 312 push edx 313 mov eax, esi 314 shl eax, 4 315 add eax, edi 316 317 ; check that button is at top of windowing stack 318 movzx ebx, [eax + SYS_BUTTON.pslot] 319 movzx ecx, word[WIN_STACK + ebx * 2] 320 cmp ecx, [TASK_COUNT] 321 jne .buttonnewcheck 322 323 ; check that button start is inside window x/y end 324 shl ebx, 5 325 326 test [ebx + window_data + WDATA.fl_wstate], WSTATE_MINIMIZED 327 jnz .buttonnewcheck 328 329 movzx edx, [eax + SYS_BUTTON.left] 330 cmp edx, [window_data + ebx + WDATA.box.width] ;ecx 331 jge .buttonnewcheck 332 333 movzx edx, [eax + SYS_BUTTON.top] 334 cmp edx, [window_data + ebx + WDATA.box.height] ;ecx 335 jge .buttonnewcheck 336 337 ; check coordinates 338 339 ; mouse x >= button x ? 340 add ebx, window_data 341 mov ecx, [ebx + WDATA.box.left] 342 movzx edx, [eax + SYS_BUTTON.left] 343 add edx, ecx 344 mov cx, [mx] ;mov cx,[MOUSE_X] 345 cmp edx, ecx 346 jg .buttonnewcheck 347 348 movzx ebx, [eax + SYS_BUTTON.width] 349 add edx, ebx 350 cmp ecx, edx 351 jg .buttonnewcheck 352 353 ; mouse y >= button y ? 354 movzx ebx, [eax + SYS_BUTTON.pslot] 355 shl ebx, 5 356 add ebx, window_data 357 mov ecx, [ebx + WDATA.box.top] 358 movzx edx, [eax + SYS_BUTTON.top] 359 add edx, ecx 360 mov cx, [my] ;mov cx,[MOUSE_Y] 361 cmp edx, ecx 362 jg .buttonnewcheck 363 364 movzx ebx, [eax + SYS_BUTTON.height] 365 add edx, ebx 366 cmp ecx, edx 367 jg .buttonnewcheck 368 369 ; mouse on button 370 371 pop edx 372 pop esi 373 374 mov ebx, dword[eax + SYS_BUTTON.id_hi - 2] ; button id : bits 16-31 375 mov bx, [eax + SYS_BUTTON.id_lo] ; button id : bits 00-16 376 push ebx 377 378 mov byte[MOUSE_DOWN], 1 ; no mouse down checks 258 sys_button_activate_handler: ;///////////////////////////////////////////////// 259 ;------------------------------------------------------------------------------ 260 ;? <description> 261 ;------------------------------------------------------------------------------ 262 ;> eax = pack[8(process slot), 24(button id)] 263 ;> ebx = pack[16(button x coord), 16(button y coord)] 264 ;> cl = mouse button mask this system button was pressed with 265 ;------------------------------------------------------------------------------ 266 call button._.find_button 267 or eax, eax 268 jz .exit 269 270 mov ebx, dword[eax + SYS_BUTTON.id_hi - 2] 379 271 call button._.negative_button 380 272 381 pushad382 push eax383 mov al, [BTN_DOWN] 384 mov byte[btn_down_determ], al 385 pop eax 386 387 .cbwaitmouseup: 388 call checkidle 389 call [draw_pointer] 390 391 pushad 392 call stack_handler 393 popad 394 395 cmp byte[BTN_DOWN], 0 ; mouse buttons pressed ?396 j nz .cbwaitmouseup397 popad 398 273 .exit: 274 ret 275 276 align 4 277 ;------------------------------------------------------------------------------ 278 sys_button_deactivate_handler: ;/////////////////////////////////////////////// 279 ;------------------------------------------------------------------------------ 280 ;? <description> 281 ;------------------------------------------------------------------------------ 282 ;> eax = pack[8(process slot), 24(button id)] 283 ;> ebx = pack[16(button x coord), 16(button y coord)] 284 ;> cl = mouse button mask this system button was pressed with 285 ;------------------------------------------------------------------------------ 286 call button._.find_button 287 or eax, eax 288 jz .exit 289 290 mov ebx, dword[eax + SYS_BUTTON.id_hi - 2] 399 291 call button._.negative_button 400 mov byte[MOUSE_BACKGROUND], 0 ; no mouse background 401 mov byte[DONT_DRAW_MOUSE], 0 ; draw mouse 402 403 ; check coordinates 404 pusha 405 406 ; mouse x >= button x ? 407 movzx ebx, [eax + SYS_BUTTON.pslot] 408 shl ebx, 5 409 add ebx, window_data 410 mov ecx, [ebx + WDATA.box.left] 411 movzx edx, [eax + SYS_BUTTON.left] 412 add edx, ecx 413 mov cx, [MOUSE_X] 414 cmp edx, ecx 415 jg .no_on_button ;if we release the pointer out of the button area 416 417 movzx ebx, [eax + SYS_BUTTON.width] 418 add edx, ebx 419 cmp ecx, edx 420 jg .no_on_button 421 422 ; mouse y >= button y ? 423 movzx ebx, [eax + SYS_BUTTON.pslot] 424 shl ebx, 5 425 add ebx, window_data 426 mov ecx, [ebx + WDATA.box.top] 427 movzx edx, [eax + SYS_BUTTON.top] 428 add edx, ecx 429 mov cx, [MOUSE_Y] 430 cmp edx, ecx 431 jg .no_on_button 432 433 movzx ebx, [eax + SYS_BUTTON.height] 434 add edx, ebx 435 cmp ecx, edx 436 jg .no_on_button 437 438 popa 439 440 mov byte[BTN_COUNT], 1 ; no of buttons in buffer 441 pop ebx 442 mov [BTN_BUFF], ebx ; lets put the button id in buffer 443 push ebx 444 pusha 445 jmp .yes_on_button 446 447 .no_on_button: 448 mov byte[BTN_COUNT], 0 ; no of buttons in buffer 449 450 .yes_on_button: 451 mov byte[MOUSE_DOWN], 0 ; mouse down -> do not draw 452 popa 453 pop ebx 454 popa 292 293 .exit: 294 ret 295 296 align 4 297 ;------------------------------------------------------------------------------ 298 sys_button_perform_handler: ;////////////////////////////////////////////////// 299 ;------------------------------------------------------------------------------ 300 ;? <description> 301 ;------------------------------------------------------------------------------ 302 ;> eax = pack[8(process slot), 24(button id)] 303 ;> ebx = pack[16(button x coord), 16(button y coord)] 304 ;> cl = mouse button mask this system button was pressed with 305 ;------------------------------------------------------------------------------ 306 shl eax, 8 307 mov al, cl 308 movzx ebx, byte[BTN_COUNT] 309 mov [BTN_BUFF + ebx * 4], eax 310 inc bl 311 mov [BTN_COUNT], bl 455 312 ret 456 313 … … 458 315 ;///// private functions ////////////////////////////////////////////////////// 459 316 ;============================================================================== 317 318 ;------------------------------------------------------------------------------ 319 button._.find_button: ;//////////////////////////////////////////////////////// 320 ;------------------------------------------------------------------------------ 321 ;? Find system button by specified process slot, id and coordinates 322 ;------------------------------------------------------------------------------ 323 ;> eax = pack[8(process slot), 24(button id)] or 0 324 ;> ebx = pack[16(button x coord), 16(button y coord)] 325 ;------------------------------------------------------------------------------ 326 ;< eax = pointer to SYS_BUTTON struct or 0 327 ;------------------------------------------------------------------------------ 328 push ecx edx esi edi 329 330 mov edx, eax 331 shr edx, 24 332 and eax, 0x0ffffff 333 334 mov edi, [BTN_ADDR] 335 mov ecx, [edi] 336 imul esi, ecx, SYS_BUTTON.sizeof 337 add esi, edi 338 inc ecx 339 add esi, SYS_BUTTON.sizeof 340 341 .next_button: 342 dec ecx 343 jz .not_found 344 345 add esi, -SYS_BUTTON.sizeof 346 347 ; does it belong to our process? 348 cmp dx, [esi + SYS_BUTTON.pslot] 349 jne .next_button 350 351 ; does id match? 352 mov edi, dword[esi + SYS_BUTTON.id_hi - 2] 353 mov di, [esi + SYS_BUTTON.id_lo] 354 and edi, 0x0ffffff 355 cmp eax, edi 356 jne .next_button 357 358 ; does coordinates match? 359 mov edi, dword[esi + SYS_BUTTON.left - 2] 360 mov di, [esi + SYS_BUTTON.top] 361 cmp ebx, edi 362 jne .next_button 363 364 ; okay, return it 365 mov eax, esi 366 jmp .exit 367 368 .not_found: 369 xor eax, eax 370 371 .exit: 372 pop edi esi edx ecx 373 ret 460 374 461 375 ;------------------------------------------------------------------------------ … … 547 461 button._.negative_button: ;//////////////////////////////////////////////////// 548 462 ;------------------------------------------------------------------------------ 549 ;? <description>463 ;? Invert system button border 550 464 ;------------------------------------------------------------------------------ 551 465 ; if requested, do not display button border on press. -
kernel/trunk/gui/event.inc
r1067 r1391 369 369 sub ecx,2 370 370 je .sendkey 371 loop .retf 371 dec ecx 372 jnz .retf 372 373 .sendbtn: 373 374 cmp byte[BTN_COUNT],1 374 375 jae .result ;overflow 375 376 inc byte[BTN_COUNT] 377 shl edx, 8 376 378 mov [BTN_BUFF],edx 377 379 jmp .result … … 468 470 cmp edx,[TASK_COUNT] 469 471 jne .loop ; not Top ??? 470 cmp dword[BTN_BUFF],0xFFFF ;-ID for Minimize-Button of Form 472 mov edx, [BTN_BUFF] 473 shr edx, 8 474 cmp edx, 0xFFFF ;-ID for Minimize-Button of Form 471 475 jne .result 472 476 mov [window_minimize],1 -
kernel/trunk/gui/window.inc
r1369 r1391 1 1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 2 ;; ;; 3 ;; Copyright (C) KolibriOS team 2004-20 09. All rights reserved. ;;3 ;; Copyright (C) KolibriOS team 2004-2010. All rights reserved. ;; 4 4 ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; 5 5 ;; Distributed under terms of the GNU General Public License ;; … … 9 9 $Revision$ 10 10 11 12 11 ;============================================================================== 13 12 ;///// public functions /////////////////////////////////////////////////////// 14 13 ;============================================================================== 15 14 16 macro FuncTable name, [label] 15 window.BORDER_SIZE = 5 16 17 macro FuncTable name, table_name, [label] 17 18 { 18 19 common 19 20 align 4 20 \label name#. ftable dword21 \label name#.#table_name dword 21 22 forward 22 23 dd name#.#label 23 24 common 24 name#.sizeof. ftable = $ - name#.ftable25 name#.sizeof.#table_name = $ - name#.#table_name 25 26 } 26 27 27 iglobal28 FuncTable syscall_display_settings, \29 00, 01, 02, 03, 04, 05, 06, 07, 0828 uglobal 29 common_colours rd 32 30 draw_limits RECT 30 31 endg 31 32 32 uglobal 33 common_colours rd 32 34 new_window_starting dd ? 35 latest_window_touch dd ? 36 latest_window_touch_delta dd ? 37 old_window_pos BOX 38 new_window_pos BOX 39 draw_limits RECT 40 bPressedMouseXY_W db ? 41 do_resize db ? 42 do_resize_from_corner db ? 43 reposition db ? 44 endg 33 align 4 34 ;------------------------------------------------------------------------------ 35 syscall_draw_window: ;///// system function 0 ///////////////////////////////// 36 ;------------------------------------------------------------------------------ 37 ;? <description> 38 ;------------------------------------------------------------------------------ 39 mov eax, edx 40 shr eax, 24 41 and al, 0x0f 42 cmp al, 5 43 jae .exit 44 45 push eax 46 inc [mouse_pause] 47 call [_display.disable_mouse] 48 call window._.sys_set_window 49 call [_display.disable_mouse] 50 pop eax 51 52 or al, al 53 jnz @f 54 55 ; type I - original style 56 call drawwindow_I 57 jmp window._.draw_window_caption.2 58 59 @@: dec al 60 jnz @f 61 62 ; type II - only reserve area, no draw 63 call sys_window_mouse 64 dec [mouse_pause] 65 call [draw_pointer] 66 jmp .exit 67 68 @@: dec al 69 jnz @f 70 71 ; type III - new style 72 call drawwindow_III 73 jmp window._.draw_window_caption.2 74 75 ; type IV & V - skinned window (resizable & not) 76 @@: mov eax, [TASK_COUNT] 77 movzx eax, word[WIN_POS + eax * 2] 78 cmp eax, [CURRENT_TASK] 79 setz al 80 movzx eax, al 81 push eax 82 call drawwindow_IV 83 jmp window._.draw_window_caption.2 84 85 .exit: 86 ret 45 87 46 88 align 4 … … 270 312 align 4 271 313 ;------------------------------------------------------------------------------ 314 syscall_move_window: ;///// system function 67 //////////////////////////////// 315 ;------------------------------------------------------------------------------ 316 ;? <description> 317 ;------------------------------------------------------------------------------ 318 mov edi, [CURRENT_TASK] 319 shl edi, 5 320 add edi, window_data 321 322 test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED 323 jnz .exit 324 325 cmp ebx, -1 326 jne @f 327 mov ebx, [edi + WDATA.box.left] 328 @@: cmp ecx, -1 329 jne @f 330 mov ecx, [edi + WDATA.box.top] 331 @@: cmp edx, -1 332 jne @f 333 mov edx, [edi + WDATA.box.width] 334 @@: cmp esi, -1 335 jne @f 336 mov esi, [edi + WDATA.box.height] 337 338 @@: push esi edx ecx ebx 339 mov eax, esp 340 mov bl, [edi + WDATA.fl_wstate] 341 call window._.set_window_box 342 add esp, BOX.sizeof 343 344 ; NOTE: do we really need this? to be reworked 345 ; mov byte[DONT_DRAW_MOUSE], 0 ; mouse pointer 346 ; mov byte[MOUSE_BACKGROUND], 0 ; no mouse under 347 ; mov byte[MOUSE_DOWN], 0 ; react to mouse up/down 348 349 ; NOTE: do we really need this? to be reworked 350 ; call [draw_pointer] 351 352 .exit: 353 ret 354 355 align 4 356 ;------------------------------------------------------------------------------ 357 syscall_window_settings: ;///// system function 71 ///////////////////////////// 358 ;------------------------------------------------------------------------------ 359 ;? <description> 360 ;------------------------------------------------------------------------------ 361 dec ebx ; subfunction #1 - set window caption 362 jnz .exit_fail 363 364 ; NOTE: only window owner thread can set its caption, 365 ; so there's no parameter for PID/TID 366 367 mov edi, [CURRENT_TASK] 368 shl edi, 5 369 370 mov [edi * 8 + SLOT_BASE + APPDATA.wnd_caption], ecx 371 or [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION 372 373 call window._.draw_window_caption 374 375 xor eax, eax ; eax = 0 (success) 376 ret 377 378 ; .get_window_caption: 379 ; dec eax ; subfunction #2 - get window caption 380 ; jnz .exit_fail 381 382 ; not implemented yet 383 384 .exit_fail: 385 xor eax, eax 386 inc eax ; eax = 1 (fail) 387 ret 388 389 align 4 390 ;------------------------------------------------------------------------------ 272 391 set_window_defaults: ;///////////////////////////////////////////////////////// 273 392 ;------------------------------------------------------------------------------ … … 430 549 431 550 .fix_client_box: 432 call set_window_clientbox551 call window._.set_window_clientbox 433 552 434 553 add edi, WDATA.sizeof … … 440 559 align 4 441 560 ;------------------------------------------------------------------------------ 442 check_window_position: ;///////////////////////////////////////////////////////443 ;------------------------------------------------------------------------------444 ;? Check if window is inside screen area445 ;------------------------------------------------------------------------------446 ;> edi = pointer to WDATA447 ;------------------------------------------------------------------------------448 push eax ebx ecx edx esi449 450 mov eax, [edi + WDATA.box.left]451 mov ebx, [edi + WDATA.box.top]452 mov ecx, [edi + WDATA.box.width]453 mov edx, [edi + WDATA.box.height]454 455 mov esi, [Screen_Max_X]456 cmp ecx, esi457 ja .fix_width458 459 .check_left:460 or eax, eax461 jl .fix_left_low462 add eax, ecx463 cmp eax, esi464 jg .fix_left_high465 466 .check_height:467 mov esi, [Screen_Max_Y]468 cmp edx, esi469 ja .fix_height470 471 .check_top:472 or ebx, ebx473 jl .fix_top_low474 add ebx, edx475 cmp ebx, esi476 jg .fix_top_high477 478 .exit:479 pop esi edx ecx ebx eax480 ret481 482 .fix_width:483 mov ecx, esi484 mov [edi + WDATA.box.width], esi485 jmp .check_left486 487 .fix_left_low:488 xor eax, eax489 mov [edi + WDATA.box.left], eax490 jmp .check_height491 492 .fix_left_high:493 mov eax, esi494 sub eax, ecx495 mov [edi + WDATA.box.left], eax496 jmp .check_height497 498 .fix_height:499 mov edx, esi500 mov [edi + WDATA.box.height], esi501 jmp .check_top502 503 .fix_top_low:504 xor ebx, ebx505 mov [edi + WDATA.box.top], ebx506 jmp .exit507 508 .fix_top_high:509 mov ebx, esi510 sub ebx, edx511 mov [edi + WDATA.box.top], ebx512 jmp .exit513 514 align 4515 ;------------------------------------------------------------------------------516 561 sys_window_mouse: ;//////////////////////////////////////////////////////////// 517 562 ;------------------------------------------------------------------------------ 518 563 ;? <description> 519 564 ;------------------------------------------------------------------------------ 520 push eax 521 522 mov eax, [timer_ticks] 523 cmp [new_window_starting], eax 524 jb .exit 525 526 mov byte[MOUSE_BACKGROUND], 0 527 mov byte[DONT_DRAW_MOUSE], 0 528 529 mov [new_window_starting], eax 530 531 .exit: 532 pop eax 565 ; NOTE: commented out since doesn't provide necessary functionality 566 ; anyway, to be reworked 567 ; push eax 568 ; 569 ; mov eax, [timer_ticks] 570 ; cmp [new_window_starting], eax 571 ; jb .exit 572 ; 573 ; mov byte[MOUSE_BACKGROUND], 0 574 ; mov byte[DONT_DRAW_MOUSE], 0 575 ; 576 ; mov [new_window_starting], eax 577 ; 578 ; .exit: 579 ; pop eax 533 580 ret 534 581 … … 810 857 ;? Activate window, redrawing if necessary 811 858 ;------------------------------------------------------------------------------ 859 push -1 860 mov eax, [TASK_COUNT] 861 lea eax, [WIN_POS + eax * 2] 862 cmp eax, esi 863 pop eax 864 je .exit 865 812 866 ; is it overlapped by another window now? 813 867 push ecx … … 842 896 ; tell application to redraw itself 843 897 mov [edi + WDATA.fl_redraw], 1 844 mov byte[MOUSE_DOWN], 0845 ret898 xor eax, eax 899 jmp .exit 846 900 847 901 .do_not_draw: 848 902 ; no it's not, just activate the window 849 903 call window._.window_activate 850 mov byte[MOUSE_DOWN], 0851 904 mov byte[MOUSE_BACKGROUND], 0 852 905 mov byte[DONT_DRAW_MOUSE], 0 906 xor eax, eax 907 908 .exit: 909 mov byte[MOUSE_DOWN], 0 910 inc eax 853 911 ret 854 912 … … 941 999 942 1000 align 4 943 ;------------------------------------------------------------------------------ 944 checkwindows: ;//////////////////////////////////////////////////////////////// 945 ;------------------------------------------------------------------------------ 946 ;? Check for user-initiated window operations 947 ;------------------------------------------------------------------------------ 948 pushad 949 1001 ; TODO: remove this proc 1002 ;------------------------------------------------------------------------------ 1003 window_check_events: ;///////////////////////////////////////////////////////// 1004 ;------------------------------------------------------------------------------ 1005 ;? <description> 1006 ;------------------------------------------------------------------------------ 950 1007 ; do we have window minimize/restore request? 951 1008 cmp [window_minimize], 0 952 je . check_for_mouse_buttons_state1009 je .exit 953 1010 954 1011 ; okay, minimize or restore top-most window and exit … … 959 1016 jnz @f 960 1017 call minimize_window 961 jmp .check_for_mouse_buttons_state 1018 jmp .exit 1019 962 1020 @@: call restore_minimized_window 963 1021 964 .check_for_mouse_buttons_state: 965 ; do we have any mouse buttons pressed? 966 cmp byte[BTN_DOWN], 0 967 jne .mouse_buttons_pressed 968 969 mov [bPressedMouseXY_W], 0 970 jmp .exit 971 972 .mouse_buttons_pressed: 973 ; yes we do, iterate and ... 974 mov esi, [TASK_COUNT] 975 inc esi 976 977 cmp [bPressedMouseXY_W], 1 978 ja .next_window 979 inc [bPressedMouseXY_W] 980 jnc .next_window 981 push dword[MOUSE_X] 982 pop dword[mx] 983 984 .next_window: 985 cmp esi, 2 986 jb .exit 987 988 dec esi 989 990 ; is that window not minimized? 991 movzx edi, word[WIN_POS + esi * 2] 1022 .exit: 1023 ret 1024 1025 align 4 1026 ;------------------------------------------------------------------------------ 1027 sys_window_maximize_handler: ;///////////////////////////////////////////////// 1028 ;------------------------------------------------------------------------------ 1029 ;? <description> 1030 ;------------------------------------------------------------------------------ 1031 ;> esi = process slot 1032 ;------------------------------------------------------------------------------ 1033 mov edi, esi 992 1034 shl edi, 5 993 1035 add edi, window_data 994 test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED 995 jnz .next_window 996 997 movzx eax, [mx] 998 movzx ebx, [my] 999 1000 ; is the cursor inside screen bounds of that window? 1001 mov ecx, [edi + WDATA.box.left] 1002 mov edx, [edi + WDATA.box.top] 1003 cmp eax, ecx 1004 jl .next_window 1005 cmp ebx, edx 1006 jl .next_window 1007 add ecx, [edi + WDATA.box.width] 1008 add edx, [edi + WDATA.box.height] 1009 cmp eax, ecx 1010 jge .next_window 1011 cmp ebx, edx 1012 jge .next_window 1013 1014 ; is that a top-most (which means active) window? 1015 cmp esi, [TASK_COUNT] 1016 je .check_for_moving_or_resizing 1017 1018 ; no it's not, did we just press mouse button down above it or was it 1019 ; already pressed before? 1020 cmp [bPressedMouseXY_W], 1 1021 ja .exit 1022 1023 ; okay, we just pressed the button, activate this window and exit 1024 lea esi, [WIN_POS + esi * 2] 1025 call waredraw 1026 jmp .exit 1027 1028 .check_for_moving_or_resizing: 1029 ; is that window movable? 1030 test byte[edi + WDATA.cl_titlebar + 3], 0x01 1031 jnz .exit 1032 1033 ; yes it is, is it rolled up? 1034 test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP 1035 jnz .check_for_cursor_on_caption 1036 1037 ; no it's not, can it be resized then? 1038 mov [do_resize_from_corner], 0 1039 mov dl, [edi + WDATA.fl_wstyle] 1040 and dl, 0x0f 1041 cmp dl, 0x00 1042 je .check_for_cursor_on_caption 1043 cmp dl, 0x01 1044 je .check_for_cursor_on_caption 1045 cmp dl, 0x04 1046 je .check_for_cursor_on_caption 1047 1048 ; are we going to resize it? 1049 mov edx, [edi + WDATA.box.top] 1050 add edx, [edi + WDATA.box.height] 1051 sub edx, 6 1052 cmp ebx, edx 1053 jl .check_for_cursor_on_caption 1054 1055 ; yes we do, remember that 1056 mov [do_resize_from_corner], 1 1057 jmp .set_move_resize_flag 1058 1059 .check_for_cursor_on_caption: 1060 ; is the cursor inside window titlebar? 1061 push eax 1062 call window._.get_titlebar_height 1063 add eax, [edi + WDATA.box.top] 1064 cmp ebx, eax 1065 pop eax 1066 jge .exit 1067 1068 ; calculate duration between two clicks 1069 mov ecx, [timer_ticks] 1070 mov edx, ecx 1071 sub edx, [latest_window_touch] 1072 mov [latest_window_touch], ecx 1073 mov [latest_window_touch_delta], edx 1074 1075 .set_move_resize_flag: 1076 mov cl, [BTN_DOWN] 1077 mov [do_resize], cl 1078 1079 mov ecx, [edi + WDATA.box.left] 1080 mov edx, [edi + WDATA.box.top] 1081 1082 push ecx edx 1083 mov [draw_limits.left], ecx 1084 mov [draw_limits.top], edx 1085 add ecx, [edi + WDATA.box.width] 1086 add edx, [edi + WDATA.box.height] 1087 mov [draw_limits.right], ecx 1088 mov [draw_limits.bottom], edx 1089 pop edx ecx 1090 1091 ; calculate window-relative cursor coordinates 1092 sub eax, ecx 1093 sub ebx, edx 1094 1095 push dword[MOUSE_X] 1096 pop dword[WIN_TEMP_XY] 1097 1098 ; save old window coordinates 1099 push eax 1100 mov eax, [edi + WDATA.box.left] 1101 mov [old_window_pos.left], eax 1102 mov [new_window_pos.left], eax 1103 mov eax, [edi + WDATA.box.top] 1104 mov [old_window_pos.top], eax 1105 mov [new_window_pos.top], eax 1106 mov eax, [edi + WDATA.box.width] 1107 mov [old_window_pos.width], eax 1108 mov [new_window_pos.width], eax 1109 mov eax, [edi + WDATA.box.height] 1110 mov [old_window_pos.height], eax 1111 mov [new_window_pos.height], eax 1112 pop eax 1113 1114 ; draw negative moving/sizing frame 1115 call window._.draw_window_frames 1116 1117 mov [reposition], 0 1118 mov byte[MOUSE_DOWN], 1 1119 1120 .next_mouse_state_check: 1121 ; process OS events 1122 mov byte[DONT_DRAW_MOUSE], 1 1123 call checkidle 1124 call checkVga_N13 1125 mov byte[MOUSE_BACKGROUND], 0 1126 call [draw_pointer] 1127 pushad 1128 call stack_handler 1129 popad 1130 1131 ; did cursor position change? 1132 mov esi, [WIN_TEMP_XY] 1133 cmp esi, [MOUSE_X] 1134 je .check_for_new_mouse_buttons_state 1135 1136 ; yes it did, calculate window-relative cursor coordinates 1137 movzx ecx, word[MOUSE_X] 1138 movzx edx, word[MOUSE_Y] 1139 sub ecx, eax 1140 sub edx, ebx 1141 1142 push eax ebx 1143 1144 ; we're going to draw new frame, erasing the old one 1145 call window._.draw_window_frames 1146 1147 ; are we moving it right now? 1148 cmp [do_resize_from_corner], 0 1149 jne .resize_window 1150 1151 ; yes we do, check if it's inside the screen area 1152 mov eax, [Screen_Max_X] 1153 mov ebx, [Screen_Max_Y] 1154 1155 mov [new_window_pos.left], 0 1156 or ecx, ecx 1157 jle .check_for_new_vert_cursor_pos 1158 mov [reposition], 1 1159 sub eax, [new_window_pos.width] 1160 mov [new_window_pos.left], eax 1161 cmp ecx, eax 1162 jge .check_for_new_vert_cursor_pos 1163 mov [new_window_pos.left], ecx 1164 1165 .check_for_new_vert_cursor_pos: 1166 mov [new_window_pos.top], 0 1167 or edx, edx 1168 jle .draw_new_window_frame 1169 mov [reposition], 1 1170 sub ebx, [new_window_pos.height] 1171 mov [new_window_pos.top], ebx 1172 cmp edx, ebx 1173 jge .draw_new_window_frame 1174 mov [new_window_pos.top], edx 1175 jmp .draw_new_window_frame 1176 1177 .resize_window: 1178 push eax ebx edx 1179 1180 mov edx, edi 1181 sub edx, window_data 1182 lea edx, [SLOT_BASE + edx * 8] 1183 1184 movzx eax, word[MOUSE_X] 1185 cmp eax, [edi + WDATA.box.left] 1186 jb .fix_new_vert_size 1187 sub eax, [edi + WDATA.box.left] 1188 cmp eax, 32 1189 jge @f 1190 mov eax, 32 1191 @@: mov [new_window_pos.width], eax 1192 1193 .fix_new_vert_size: 1194 call window._.get_rolledup_height 1195 mov ebx, eax 1196 movzx eax, word[MOUSE_Y] 1197 cmp eax, [edi + WDATA.box.top] 1198 jb .set_reposition_flag 1199 sub eax, [edi + WDATA.box.top] 1200 cmp eax, ebx 1201 jge @f 1202 mov eax, ebx 1203 @@: mov [new_window_pos.height], eax 1204 1205 .set_reposition_flag: 1206 mov [reposition], 1 1207 1208 pop edx ebx eax 1209 1210 .draw_new_window_frame: 1211 pop ebx eax 1212 1213 ; draw new window moving/sizing frame 1214 call window._.draw_window_frames 1215 1216 mov esi, [MOUSE_X] 1217 mov [WIN_TEMP_XY], esi 1218 1219 .check_for_new_mouse_buttons_state: 1220 ; did user release mouse button(s)? 1221 cmp byte[BTN_DOWN], 0 1222 jne .next_mouse_state_check 1223 1224 ; yes he did, moving/sizing is over 1225 mov byte[DONT_DRAW_MOUSE], 1 1226 mov cl, 0 1227 test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED 1228 jnz .check_other_actions 1229 1230 mov cl, [reposition] 1231 1232 ; draw negative frame once again to hide it 1233 call window._.draw_window_frames 1234 1235 ; save new window bounds 1236 mov eax, [new_window_pos.left] 1237 mov [edi + WDATA.box.left], eax 1238 mov eax, [new_window_pos.top] 1239 mov [edi + WDATA.box.top], eax 1240 mov eax, [new_window_pos.width] 1241 mov [edi + WDATA.box.width], eax 1242 mov eax, [new_window_pos.height] 1243 mov [edi + WDATA.box.height], eax 1244 call set_window_clientbox 1245 1246 cmp cl, 1 1247 jne .check_other_actions 1248 push esi edi ecx 1249 mov esi, edi 1250 mov ecx, 2 1251 test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP or WSTATE_MAXIMIZED 1252 jnz @f 1253 add ecx, 2 1254 @@: sub edi, window_data 1255 shr edi, 5 1256 shl edi, 8 1257 add edi, SLOT_BASE + APPDATA.saved_box 1258 cld 1259 rep movsd 1260 pop ecx edi esi 1261 1262 .check_other_actions: 1263 mov [reposition], cl 1264 1265 pushad 1266 1267 mov dl, [edi + WDATA.fl_wstyle] 1268 and dl, 0x0f 1269 cmp dl, 0x00 1270 je .check_if_window_fits_screen 1271 cmp dl, 0x01 1272 je .check_if_window_fits_screen 1273 1274 cmp cl, 1 1275 je .no_window_sizing 1276 mov edx, edi 1277 sub edx, window_data 1278 shr edx, 5 1279 shl edx, 8 1280 add edx, SLOT_BASE 1281 1282 ; did we right-click on titlebar? 1283 cmp [do_resize], 2 1284 jne .check_maximization_request 1285 1286 ; yes we did, toggle normal/rolled up window state 1287 xor [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP 1288 mov [reposition], 1 1289 1290 ; calculate and set appropriate window height 1291 test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP 1292 jz @f 1293 call window._.get_rolledup_height 1294 jmp .set_new_window_height 1295 @@: mov eax, [edx + APPDATA.saved_box.height] 1296 test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED 1297 jz .set_new_window_height 1298 mov eax, [screen_workarea.bottom] 1299 sub eax, [screen_workarea.top] 1300 1301 .set_new_window_height: 1302 mov [edi + WDATA.box.height], eax 1303 add eax, [edi + WDATA.box.top] 1304 cmp eax, [Screen_Max_Y] 1305 jbe @f 1306 mov eax, [Screen_Max_Y] 1307 sub eax, [edi + WDATA.box.height] 1308 mov [edi + WDATA.box.top], eax 1309 @@: call check_window_position 1310 call set_window_clientbox 1311 1312 .check_maximization_request: 1036 1313 1037 ; can window change its height? 1314 push edx1315 1038 mov dl, [edi + WDATA.fl_wstyle] 1316 1039 and dl, 0x0f 1317 1040 cmp dl, 0x04 1318 pop edx 1319 je .check_if_window_fits_screen 1320 1321 ; was it really a maximize/restore request? 1322 cmp [do_resize], 1 1323 jne .check_if_window_fits_screen 1324 cmp [do_resize_from_corner], 0 1325 jne .check_if_window_fits_screen 1326 cmp [latest_window_touch_delta], 50 1327 jg .check_if_window_fits_screen 1328 1329 ; yes is was, toggle normal/maximized window state 1330 xor [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED 1331 mov [reposition], 1 1041 je .exit 1042 1043 ; toggle normal/maximized window state 1044 mov bl, [edi + WDATA.fl_wstate] 1045 xor bl, WSTATE_MAXIMIZED 1332 1046 1333 1047 ; calculate and set appropriate window bounds 1334 test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED 1335 jz .restore_normal_window_size 1048 test bl, WSTATE_MAXIMIZED 1049 jz .restore_size 1050 1336 1051 mov eax, [screen_workarea.left] 1337 mov [edi + WDATA.box.left], eax 1338 sub eax, [screen_workarea.right] 1052 mov ecx, [screen_workarea.top] 1053 push [screen_workarea.bottom] \ 1054 [screen_workarea.right] \ 1055 ecx \ 1056 eax 1057 sub [esp + BOX.width], eax 1058 sub [esp + BOX.height], ecx 1059 mov eax, esp 1060 jmp .set_box 1061 1062 .restore_size: 1063 mov eax, esi 1064 shl eax, 8 1065 add eax, SLOT_BASE + APPDATA.saved_box 1066 push [eax + BOX.height] \ 1067 [eax + BOX.width] \ 1068 [eax + BOX.top] \ 1069 [eax + BOX.left] 1070 mov eax, esp 1071 1072 .set_box: 1073 test bl, WSTATE_ROLLEDUP 1074 jz @f 1075 1076 xchg eax, ecx 1077 call window._.get_rolledup_height 1078 mov [ecx + BOX.height], eax 1079 xchg eax, ecx 1080 1081 @@: call window._.set_window_box 1082 add esp, BOX.sizeof 1083 1084 .exit: 1085 ret 1086 1087 align 4 1088 ;------------------------------------------------------------------------------ 1089 sys_window_rollup_handler: ;/////////////////////////////////////////////////// 1090 ;------------------------------------------------------------------------------ 1091 ;? <description> 1092 ;------------------------------------------------------------------------------ 1093 ;> esi = process slot 1094 ;------------------------------------------------------------------------------ 1095 mov edx, esi 1096 shl edx, 8 1097 add edx, SLOT_BASE 1098 1099 ; toggle normal/rolled up window state 1100 mov bl, [edi + WDATA.fl_wstate] 1101 xor bl, WSTATE_ROLLEDUP 1102 1103 ; calculate and set appropriate window bounds 1104 test bl, WSTATE_ROLLEDUP 1105 jz .restore_size 1106 1107 call window._.get_rolledup_height 1108 push eax \ 1109 [edi + WDATA.box.width] \ 1110 [edi + WDATA.box.top] \ 1111 [edi + WDATA.box.left] 1112 mov eax, esp 1113 jmp .set_box 1114 1115 .restore_size: 1116 test bl, WSTATE_MAXIMIZED 1117 jnz @f 1118 add esp, -BOX.sizeof 1119 lea eax, [edx + APPDATA.saved_box] 1120 jmp .set_box 1121 1122 @@: mov eax, [screen_workarea.top] 1123 push [screen_workarea.bottom] \ 1124 [edi + WDATA.box.width] \ 1125 eax \ 1126 [edi + WDATA.box.left] 1127 sub [esp + BOX.height], eax 1128 mov eax, esp 1129 1130 .set_box: 1131 call window._.set_window_box 1132 add esp, BOX.sizeof 1133 1134 ret 1135 1136 align 4 1137 ;------------------------------------------------------------------------------ 1138 sys_window_start_moving_handler: ;///////////////////////////////////////////// 1139 ;------------------------------------------------------------------------------ 1140 ;? <description> 1141 ;------------------------------------------------------------------------------ 1142 ;> eax = old (original) window box 1143 ;> esi = process slot 1144 ;------------------------------------------------------------------------------ 1145 mov edi, eax 1146 call window._.draw_negative_box 1147 1148 ret 1149 1150 align 4 1151 ;------------------------------------------------------------------------------ 1152 sys_window_end_moving_handler: ;/////////////////////////////////////////////// 1153 ;------------------------------------------------------------------------------ 1154 ;? <description> 1155 ;------------------------------------------------------------------------------ 1156 ;> eax = old (original) window box 1157 ;> ebx = new (final) window box 1158 ;> esi = process slot 1159 ;------------------------------------------------------------------------------ 1160 mov edi, ebx 1161 call window._.draw_negative_box 1162 1163 mov edi, esi 1164 shl edi, 5 1165 add edi, window_data 1166 1167 mov eax, ebx 1168 mov bl, [edi + WDATA.fl_wstate] 1169 call window._.set_window_box 1170 ret 1171 1172 align 4 1173 ;------------------------------------------------------------------------------ 1174 sys_window_moving_handler: ;/////////////////////////////////////////////////// 1175 ;------------------------------------------------------------------------------ 1176 ;? <description> 1177 ;------------------------------------------------------------------------------ 1178 ;> eax = old (from previous call) window box 1179 ;> ebx = new (current) window box 1180 ;> esi = process_slot 1181 ;------------------------------------------------------------------------------ 1182 mov edi, eax 1183 call window._.draw_negative_box 1184 mov edi, ebx 1185 call window._.draw_negative_box 1186 ret 1187 1188 ;============================================================================== 1189 ;///// private functions ////////////////////////////////////////////////////// 1190 ;============================================================================== 1191 1192 iglobal 1193 FuncTable syscall_display_settings, ftable, \ 1194 00, 01, 02, 03, 04, 05, 06, 07, 08 1195 1196 align 4 1197 window_topleft dd \ 1198 1, 21, \ ;type 0 1199 0, 0, \ ;type 1 1200 5, 20, \ ;type 2 1201 5, ?, \ ;type 3 {set by skin} 1202 5, ? ;type 4 {set by skin} 1203 endg 1204 1205 ;uglobal 1206 ; NOTE: commented out since doesn't provide necessary functionality anyway, 1207 ; to be reworked 1208 ; new_window_starting dd ? 1209 ;endg 1210 1211 align 4 1212 ;------------------------------------------------------------------------------ 1213 window._.invalidate_screen: ;////////////////////////////////////////////////// 1214 ;------------------------------------------------------------------------------ 1215 ;? <description> 1216 ;------------------------------------------------------------------------------ 1217 ;> eax = old (original) window box 1218 ;> ebx = new (final) window box 1219 ;> edi = pointer to WDATA struct 1220 ;------------------------------------------------------------------------------ 1221 push eax ebx 1222 1223 ; TODO: do we really need `draw_limits`? 1224 mov ecx, [eax + BOX.left] 1225 mov edx, [ebx + BOX.left] 1226 cmp ecx, edx 1227 jle @f 1228 xchg ecx, edx 1229 @@: mov [draw_limits.left], ecx 1230 mov ecx, [eax + BOX.width] 1231 cmp ecx, [ebx + BOX.width] 1232 jae @f 1233 mov ecx, [ebx + BOX.width] 1234 @@: add ecx, edx 1235 mov [draw_limits.right], ecx 1236 mov ecx, [eax + BOX.top] 1237 mov edx, [ebx + BOX.top] 1238 cmp ecx, edx 1239 jle @f 1240 xchg ecx, edx 1241 @@: mov [draw_limits.top], ecx 1242 mov ecx, [eax + BOX.height] 1243 cmp ecx, [ebx + BOX.height] 1244 jae @f 1245 mov ecx, [ebx + BOX.height] 1246 @@: add ecx, edx 1247 mov [draw_limits.bottom], ecx 1248 1249 ; recalculate screen buffer at old position 1250 push ebx 1251 mov edx, [eax + BOX.height] 1252 mov ecx, [eax + BOX.width] 1253 mov ebx, [eax + BOX.top] 1254 mov eax, [eax + BOX.left] 1255 add ecx, eax 1256 add edx, ebx 1257 call calculatescreen 1258 pop eax 1259 1260 ; recalculate screen buffer at new position 1261 mov edx, [eax + BOX.height] 1262 mov ecx, [eax + BOX.width] 1263 mov ebx, [eax + BOX.top] 1264 mov eax, [eax + BOX.left] 1265 add ecx, eax 1266 add edx, ebx 1267 call calculatescreen 1268 1269 mov eax, edi 1270 call redrawscreen 1271 1272 ; tell window to redraw itself 1273 mov [edi + WDATA.fl_redraw], 1 1274 1275 pop ebx eax 1276 ret 1277 1278 align 4 1279 ;------------------------------------------------------------------------------ 1280 window._.set_window_box: ;///////////////////////////////////////////////////// 1281 ;------------------------------------------------------------------------------ 1282 ;? <description> 1283 ;------------------------------------------------------------------------------ 1284 ;> eax = pointer to BOX struct 1285 ;> bl = new window state flags 1286 ;> edi = pointer to WDATA struct 1287 ;------------------------------------------------------------------------------ 1288 push eax ebx esi 1289 1290 add esp, -BOX.sizeof 1291 1292 mov ebx, esp 1293 lea esi, [edi + WDATA.box] 1294 xchg eax, esi 1295 mov ecx, BOX.sizeof 1296 call memmove 1297 xchg eax, esi 1298 xchg ebx, esi 1299 call memmove 1300 xchg ebx, esi 1301 1302 call window._.check_window_position 1303 call window._.set_window_clientbox 1304 call window._.invalidate_screen 1305 1306 add esp, BOX.sizeof 1307 1308 mov cl, [esp + 4] 1309 mov ch, cl 1310 xchg cl, [edi + WDATA.fl_wstate] 1311 1312 or cl, ch 1313 test cl, WSTATE_MAXIMIZED 1314 jnz .exit 1315 1316 mov eax, edi 1317 sub eax, window_data 1318 shl eax, 3 1319 add eax, SLOT_BASE 1320 1321 lea ebx, [edi + WDATA.box] 1322 xchg esp, ebx 1323 1324 pop [eax + APPDATA.saved_box.left] \ 1325 [eax + APPDATA.saved_box.top] \ 1326 [eax + APPDATA.saved_box.width] \ 1327 edx 1328 1329 xchg esp, ebx 1330 1331 test ch, WSTATE_ROLLEDUP 1332 jnz .exit 1333 1334 mov [eax + APPDATA.saved_box.height], edx 1335 1336 .exit: 1337 pop esi ebx eax 1338 ret 1339 1340 align 4 1341 ;------------------------------------------------------------------------------ 1342 window._.set_window_clientbox: ;/////////////////////////////////////////////// 1343 ;------------------------------------------------------------------------------ 1344 ;? <description> 1345 ;------------------------------------------------------------------------------ 1346 ;> edi = pointer to WDATA struct 1347 ;------------------------------------------------------------------------------ 1348 push eax ecx edi 1349 1350 mov eax, [_skinh] 1351 mov [window_topleft + 8 * 3 + 4], eax 1352 mov [window_topleft + 8 * 4 + 4], eax 1353 1354 mov ecx, edi 1355 sub edi, window_data 1356 shl edi, 3 1357 test [ecx + WDATA.fl_wstyle], WSTYLE_CLIENTRELATIVE 1358 jz .whole_window 1359 1360 movzx eax, [ecx + WDATA.fl_wstyle] 1361 and eax, 0x0F 1362 mov eax, [eax * 8 + window_topleft + 0] 1363 mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax 1364 shl eax, 1 1339 1365 neg eax 1366 add eax, [ecx + WDATA.box.width] 1367 mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax 1368 1369 movzx eax, [ecx + WDATA.fl_wstyle] 1370 and eax, 0x0F 1371 push [eax * 8 + window_topleft + 0] 1372 mov eax, [eax * 8 + window_topleft + 4] 1373 mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax 1374 neg eax 1375 sub eax, [esp] 1376 add eax, [ecx + WDATA.box.height] 1377 mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax 1378 add esp, 4 1379 jmp .exit 1380 1381 .whole_window: 1382 xor eax, eax 1383 mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax 1384 mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax 1385 mov eax, [ecx + WDATA.box.width] 1386 mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax 1387 mov eax, [ecx + WDATA.box.height] 1388 mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax 1389 1390 .exit: 1391 pop edi ecx eax 1392 ret 1393 1394 align 4 1395 ;------------------------------------------------------------------------------ 1396 window._.sys_set_window: ;///////////////////////////////////////////////////// 1397 ;------------------------------------------------------------------------------ 1398 ;? <description> 1399 ;------------------------------------------------------------------------------ 1400 ;< edx = pointer to WDATA struct 1401 ;------------------------------------------------------------------------------ 1402 mov eax, [CURRENT_TASK] 1403 shl eax, 5 1404 add eax, window_data 1405 1406 ; save window colors 1407 mov [eax + WDATA.cl_workarea], edx 1408 mov [eax + WDATA.cl_titlebar], esi 1409 mov [eax + WDATA.cl_frames], edi 1410 1411 mov edi, eax 1412 1413 ; was it already defined before? 1414 test [edi + WDATA.fl_wdrawn], 1 1415 jnz .set_client_box 1416 1417 ; NOTE: commented out since doesn't provide necessary functionality 1418 ; anyway, to be reworked 1419 ; mov eax, [timer_ticks] ; [0xfdf0] 1420 ; add eax, 100 1421 ; mov [new_window_starting], eax 1422 1423 ; no it wasn't, performing initial window definition 1424 movzx eax, bx 1340 1425 mov [edi + WDATA.box.width], eax 1341 mov eax, [screen_workarea.top] 1342 mov [edi + WDATA.box.top], eax 1343 test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP 1344 jnz .calculate_window_client_area 1345 sub eax, [screen_workarea.bottom] 1346 neg eax 1426 movzx eax, cx 1347 1427 mov [edi + WDATA.box.height], eax 1348 jmp .calculate_window_client_area 1349 1350 .restore_normal_window_size: 1351 push [edi + WDATA.box.height] 1352 push edi 1353 lea esi, [edx + APPDATA.saved_box] 1354 mov ecx, 4 1355 cld 1356 rep movsd 1357 pop edi 1358 pop eax 1359 test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP 1360 jz .calculate_window_client_area 1361 mov [edi + WDATA.box.height], eax 1362 1363 .calculate_window_client_area: 1364 call set_window_clientbox 1365 1366 .check_if_window_fits_screen: 1367 ; does window fit into screen area? 1368 mov eax, [edi + WDATA.box.top] 1369 add eax, [edi + WDATA.box.height] 1370 cmp eax, [Screen_Max_Y] 1371 jbe .no_window_sizing 1372 mov eax, [edi + WDATA.box.left] 1373 add eax, [edi + WDATA.box.width] 1374 cmp eax, [Screen_Max_X] 1375 jbe .no_window_sizing 1376 1377 ; no it doesn't, fix that 1378 mov eax, [Screen_Max_X] 1379 sub eax, [edi + WDATA.box.width] 1380 mov [edi + WDATA.box.left], eax 1381 mov eax, [Screen_Max_Y] 1382 sub eax, [edi + WDATA.box.height] 1383 mov [edi + WDATA.box.top], eax 1384 call set_window_clientbox 1385 1386 .no_window_sizing: 1387 popad 1388 1389 ; did somethins actually change its place? 1390 cmp [reposition], 0 1391 je .reset_vars 1392 1393 mov byte[DONT_DRAW_MOUSE], 1 1394 1395 push eax ebx ecx edx 1396 1397 ; recalculate screen buffer at new position 1428 sar ebx, 16 1429 sar ecx, 16 1430 mov [edi + WDATA.box.left], ebx 1431 mov [edi + WDATA.box.top], ecx 1432 1433 call window._.check_window_position 1434 1435 push ecx edi 1436 1437 mov cl, [edi + WDATA.fl_wstyle] 1438 mov eax, [edi + WDATA.cl_frames] 1439 1440 sub edi, window_data 1441 shl edi, 3 1442 add edi, SLOT_BASE 1443 1444 and cl, 0x0F 1445 cmp cl, 3 1446 je @f 1447 cmp cl, 4 1448 je @f 1449 1450 xor eax, eax 1451 1452 @@: mov [edi + APPDATA.wnd_caption], eax 1453 1454 mov esi, [esp] 1455 add edi, APPDATA.saved_box 1456 movsd 1457 movsd 1458 movsd 1459 movsd 1460 1461 pop edi ecx 1462 1463 mov esi, [CURRENT_TASK] 1464 movzx esi, word[WIN_STACK + esi * 2] 1465 lea esi, [WIN_POS + esi * 2] 1466 call waredraw 1467 1398 1468 mov eax, [edi + WDATA.box.left] 1399 1469 mov ebx, [edi + WDATA.box.top] … … 1404 1474 call calculatescreen 1405 1475 1406 ; recalculate screen buffer at old position 1407 mov eax, [old_window_pos.left] 1408 mov ebx, [old_window_pos.top] 1409 mov ecx, [old_window_pos.width] 1410 mov edx, [old_window_pos.height] 1411 add ecx, eax 1412 add edx, ebx 1413 call calculatescreen 1414 1415 pop edx ecx ebx eax 1416 1417 mov eax, edi 1418 call redrawscreen 1419 1420 ; tell window to redraw itself 1421 mov [edi + WDATA.fl_redraw], 1 1422 1423 ; wait a bit for window to redraw itself 1424 mov ecx, 100 1425 1426 .next_idle_cycle: 1427 mov byte[DONT_DRAW_MOUSE], 1 1428 call checkidle 1429 cmp [edi + WDATA.fl_redraw], 0 1430 jz .reset_vars 1431 loop .next_idle_cycle 1432 1433 .reset_vars: 1434 mov byte[DONT_DRAW_MOUSE], 0 ; mouse pointer 1435 mov byte[MOUSE_BACKGROUND], 0 ; no mouse under 1436 mov byte[MOUSE_DOWN], 0 ; react to mouse up/down 1476 mov byte[KEY_COUNT], 0 ; empty keyboard buffer 1477 mov byte[BTN_COUNT], 0 ; empty button buffer 1478 1479 .set_client_box: 1480 ; update window client box coordinates 1481 call window._.set_window_clientbox 1482 1483 ; reset window redraw flag and exit 1484 mov [edi + WDATA.fl_redraw], 0 1485 mov edx, edi 1486 ret 1487 1488 align 4 1489 ;------------------------------------------------------------------------------ 1490 window._.check_window_position: ;////////////////////////////////////////////// 1491 ;------------------------------------------------------------------------------ 1492 ;? Check if window is inside screen area 1493 ;------------------------------------------------------------------------------ 1494 ;> edi = pointer to WDATA 1495 ;------------------------------------------------------------------------------ 1496 push eax ebx ecx edx esi 1497 1498 mov eax, [edi + WDATA.box.left] 1499 mov ebx, [edi + WDATA.box.top] 1500 mov ecx, [edi + WDATA.box.width] 1501 mov edx, [edi + WDATA.box.height] 1502 1503 mov esi, [Screen_Max_X] 1504 cmp ecx, esi 1505 ja .fix_width_high 1506 1507 .check_left: 1508 or eax, eax 1509 jl .fix_left_low 1510 add eax, ecx 1511 cmp eax, esi 1512 jg .fix_left_high 1513 1514 .check_height: 1515 mov esi, [Screen_Max_Y] 1516 cmp edx, esi 1517 ja .fix_height_high 1518 1519 .check_top: 1520 or ebx, ebx 1521 jl .fix_top_low 1522 add ebx, edx 1523 cmp ebx, esi 1524 jg .fix_top_high 1437 1525 1438 1526 .exit: 1439 popad 1440 ret 1441 1442 ;============================================================================== 1443 ;///// private functions ////////////////////////////////////////////////////// 1444 ;============================================================================== 1527 pop esi edx ecx ebx eax 1528 ret 1529 1530 .fix_width_high: 1531 mov ecx, esi 1532 mov [edi + WDATA.box.width], esi 1533 jmp .check_left 1534 1535 .fix_left_low: 1536 xor eax, eax 1537 mov [edi + WDATA.box.left], eax 1538 jmp .check_height 1539 1540 .fix_left_high: 1541 mov eax, esi 1542 sub eax, ecx 1543 mov [edi + WDATA.box.left], eax 1544 jmp .check_height 1545 1546 .fix_height_high: 1547 mov edx, esi 1548 mov [edi + WDATA.box.height], esi 1549 jmp .check_top 1550 1551 .fix_top_low: 1552 xor ebx, ebx 1553 mov [edi + WDATA.box.top], ebx 1554 jmp .exit 1555 1556 .fix_top_high: 1557 mov ebx, esi 1558 sub ebx, edx 1559 mov [edi + WDATA.box.top], ebx 1560 jmp .exit 1445 1561 1446 1562 align 4 1447 1563 ;------------------------------------------------------------------------------ 1448 1564 window._.get_titlebar_height: ;//////////////////////////////////////////////// 1565 ;------------------------------------------------------------------------------ 1566 ;? <description> 1449 1567 ;------------------------------------------------------------------------------ 1450 1568 ;> edi = pointer to WDATA … … 1462 1580 ;------------------------------------------------------------------------------ 1463 1581 window._.get_rolledup_height: ;//////////////////////////////////////////////// 1582 ;------------------------------------------------------------------------------ 1583 ;? <description> 1464 1584 ;------------------------------------------------------------------------------ 1465 1585 ;> edi = pointer to WDATA … … 1733 1853 mov cl, [edi + WDATA.fl_wstyle] 1734 1854 and cl, 0x0f 1735 cmp cl, 0x031855 cmp cl, 3 1736 1856 je .exit.redraw ; window type 3 1737 cmp cl, 0x041857 cmp cl, 4 1738 1858 je .exit.redraw ; window type 4 1739 1859 … … 1743 1863 sub eax, window_data 1744 1864 shr eax, 5 1745 1746 ; esi = process number1747 1865 1748 1866 movzx eax, word[WIN_STACK + eax * 2] ; get value of the curr process … … 1799 1917 align 4 1800 1918 ;------------------------------------------------------------------------------ 1801 window._.draw_window_frames: ;///////////////////////////////////////////////// 1802 ;------------------------------------------------------------------------------ 1803 ;? Draw negative window frames 1804 ;------------------------------------------------------------------------------ 1805 ;> edi = pointer to WDATA 1806 ;------------------------------------------------------------------------------ 1807 push eax 1808 cli 1809 1810 test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED 1811 jnz .exit 1812 mov eax, [new_window_pos.left] 1813 cmp eax, [edi + WDATA.box.left] 1814 jnz .draw 1815 mov eax, [new_window_pos.width] 1816 cmp eax, [edi + WDATA.box.width] 1817 jnz .draw 1818 mov eax, [new_window_pos.top] 1819 cmp eax, [edi + WDATA.box.top] 1820 jnz .draw 1821 mov eax, [new_window_pos.height] 1822 cmp eax, [edi + WDATA.box.height] 1823 jnz .draw 1824 xor [edi + WDATA.fl_wdrawn], 2 1825 1826 .draw: 1827 push ebx esi 1828 mov eax, [new_window_pos.left - 2] 1829 mov ax, word[new_window_pos.left] 1830 add ax, word[new_window_pos.width] 1831 mov ebx, [new_window_pos.top - 2] 1832 mov bx, word[new_window_pos.top] 1833 add bx, word[new_window_pos.height] 1919 window._.draw_window_caption: ;//////////////////////////////////////////////// 1920 ;------------------------------------------------------------------------------ 1921 ;? <description> 1922 ;------------------------------------------------------------------------------ 1923 inc [mouse_pause] 1924 call [_display.disable_mouse] 1925 1926 xor eax, eax 1927 mov edx, [TASK_COUNT] 1928 movzx edx, word[WIN_POS + edx * 2] 1929 cmp edx, [CURRENT_TASK] 1930 jne @f 1931 inc eax 1932 @@: mov edx, [CURRENT_TASK] 1933 shl edx, 5 1934 add edx, window_data 1935 movzx ebx, [edx + WDATA.fl_wstyle] 1936 and bl, 0x0F 1937 cmp bl, 3 1938 je .draw_caption_style_3 1939 cmp bl, 4 1940 je .draw_caption_style_3 1941 1942 jmp .not_style_3 1943 1944 .draw_caption_style_3: 1945 push edx 1946 call drawwindow_IV_caption 1947 add esp, 4 1948 jmp .2 1949 1950 .not_style_3: 1951 cmp bl, 2 1952 jne .not_style_2 1953 1954 call drawwindow_III_caption 1955 jmp .2 1956 1957 .not_style_2: 1958 cmp bl, 0 1959 jne .2 1960 1961 call drawwindow_I_caption 1962 1963 .2: mov edi, [CURRENT_TASK] 1964 shl edi, 5 1965 test [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION 1966 jz .exit 1967 mov edx, [edi * 8 + SLOT_BASE + APPDATA.wnd_caption] 1968 or edx, edx 1969 jz .exit 1970 1971 movzx eax, [edi + window_data + WDATA.fl_wstyle] 1972 and al, 0x0F 1973 cmp al, 3 1974 je .skinned 1975 cmp al, 4 1976 je .skinned 1977 1978 jmp .not_skinned 1979 1980 .skinned: 1981 mov ebp, [edi + window_data + WDATA.box.left - 2] 1982 mov bp, word[edi + window_data + WDATA.box.top] 1983 movzx eax, word[edi + window_data + WDATA.box.width] 1984 sub ax, [_skinmargins.left] 1985 sub ax, [_skinmargins.right] 1986 push edx 1987 cwde 1988 cdq 1989 mov ebx, 6 1990 idiv ebx 1991 pop edx 1992 or eax, eax 1993 js .exit 1994 1995 mov esi, eax 1996 mov ebx, dword[_skinmargins.left - 2] 1997 mov bx, word[_skinh] 1998 sub bx, [_skinmargins.bottom] 1999 sub bx, [_skinmargins.top] 2000 sar bx, 1 2001 adc bx, 0 2002 add bx, [_skinmargins.top] 2003 add bx, -3 2004 add ebx, ebp 2005 jmp .dodraw 2006 2007 .not_skinned: 2008 cmp al, 1 2009 je .exit 2010 2011 mov ebp, [edi + window_data + WDATA.box.left - 2] 2012 mov bp, word[edi + window_data + WDATA.box.top] 2013 movzx eax, word[edi + window_data + WDATA.box.width] 2014 sub eax, 16 2015 push edx 2016 cwde 2017 cdq 2018 mov ebx, 6 2019 idiv ebx 2020 pop edx 2021 or eax, eax 2022 js .exit 2023 2024 mov esi, eax 2025 mov ebx, 0x00080007 2026 add ebx, ebp 2027 2028 .dodraw: 2029 mov ecx, [common_colours + 16] 2030 or ecx, 0x80000000 2031 xor edi, edi 2032 call dtext_asciiz_esi 2033 2034 .exit: 2035 dec [mouse_pause] 2036 call [draw_pointer] 2037 ret 2038 2039 align 4 2040 ;------------------------------------------------------------------------------ 2041 window._.draw_negative_box: ;////////////////////////////////////////////////// 2042 ;------------------------------------------------------------------------------ 2043 ;? Draw negative box 2044 ;------------------------------------------------------------------------------ 2045 ;> edi = pointer to BOX struct 2046 ;------------------------------------------------------------------------------ 2047 push eax ebx esi 2048 mov eax, [edi + BOX.left - 2] 2049 mov ax, word[edi + BOX.left] 2050 add ax, word[edi + BOX.width] 2051 mov ebx, [edi + BOX.top - 2] 2052 mov bx, word[edi + BOX.top] 2053 add bx, word[edi + BOX.height] 1834 2054 mov esi, 0x01000000 1835 2055 call draw_rectangle.forced 1836 pop esi ebx 1837 1838 .exit: 1839 sti 1840 pop eax 1841 ret 1842 1843 .forced: 1844 push eax 1845 cli 1846 jmp .draw 2056 pop esi ebx eax 2057 ret -
kernel/trunk/kernel.asm
r1380 r1391 1036 1036 osloop: 1037 1037 call [draw_pointer] 1038 call check_buttons 1039 call checkwindows 1040 ; call check_window_move_request 1038 call window_check_events 1039 call mouse_check_events 1041 1040 call checkmisc 1042 1041 call checkVga_N13 … … 2676 2675 jz .exit 2677 2676 mov eax, [BTN_BUFF] 2678 shl eax, 8 2679 ; // Alver 22.06.2008 // { 2680 mov al, byte [btn_down_determ] 2681 and al,0xFE ; delete left button bit 2682 ; } \\ Alver \\ 2677 and al, 0xFE ; delete left button bit 2683 2678 mov [BTN_COUNT], byte 0 2684 2679 mov [esp + 32], eax … … 2911 2906 srl1: 2912 2907 ret 2913 2914 2915 sys_drawwindow:2916 2917 mov eax,edx2918 shr eax,16+82919 and eax,152920 2921 ; cmp eax,0 ; type I - original style2922 jne nosyswI2923 inc [mouse_pause]2924 call [_display.disable_mouse]2925 call sys_set_window2926 call [_display.disable_mouse]2927 call drawwindow_I2928 ;dec [mouse_pause]2929 ;call [draw_pointer]2930 ;ret2931 jmp draw_window_caption.22932 nosyswI:2933 2934 cmp al,1 ; type II - only reserve area, no draw2935 jne nosyswII2936 inc [mouse_pause]2937 call [_display.disable_mouse]2938 call sys_set_window2939 call [_display.disable_mouse]2940 call sys_window_mouse2941 dec [mouse_pause]2942 call [draw_pointer]2943 ret2944 nosyswII:2945 2946 cmp al,2 ; type III - new style2947 jne nosyswIII2948 inc [mouse_pause]2949 call [_display.disable_mouse]2950 call sys_set_window2951 call [_display.disable_mouse]2952 call drawwindow_III2953 ;dec [mouse_pause]2954 ;call [draw_pointer]2955 ;ret2956 jmp draw_window_caption.22957 nosyswIII:2958 2959 cmp al,3 ; type IV - skinned window2960 je draw_skin_window2961 cmp al,4 ; type V - skinned window not sized! {not_sized_skin_window}2962 jne nosyswV2963 draw_skin_window:2964 2965 inc [mouse_pause]2966 call [_display.disable_mouse]2967 call sys_set_window2968 call [_display.disable_mouse]2969 mov eax, [TASK_COUNT]2970 movzx eax, word [WIN_POS + eax*2]2971 cmp eax, [CURRENT_TASK]2972 setz al2973 movzx eax, al2974 push eax2975 call drawwindow_IV2976 ;dec [mouse_pause]2977 ;call [draw_pointer]2978 ;ret2979 jmp draw_window_caption.22980 nosyswV:2981 2982 ret2983 2984 2985 draw_window_caption:2986 inc [mouse_pause]2987 call [_display.disable_mouse]2988 2989 xor eax,eax2990 mov edx,[TASK_COUNT]2991 movzx edx,word[WIN_POS+edx*2]2992 cmp edx,[CURRENT_TASK]2993 jne @f2994 inc eax2995 @@: mov edx,[CURRENT_TASK]2996 shl edx,52997 add edx,window_data2998 movzx ebx,[edx+WDATA.fl_wstyle]2999 and bl,0x0F3000 cmp bl,33001 je .draw_caption_style_3 ;{for 3 and 4 style write caption}3002 cmp bl,43003 je .draw_caption_style_33004 3005 jmp .not_style_33006 .draw_caption_style_3:3007 3008 push edx3009 call drawwindow_IV_caption3010 add esp,43011 jmp .23012 3013 .not_style_3:3014 cmp bl,23015 jne .not_style_23016 3017 call drawwindow_III_caption3018 jmp .23019 3020 .not_style_2:3021 cmp bl,03022 jne .23023 3024 call drawwindow_I_caption3025 3026 ;--------------------------------------------------------------3027 .2: ;jmp @f3028 mov edi,[CURRENT_TASK]3029 shl edi,53030 test [edi+window_data+WDATA.fl_wstyle],WSTYLE_HASCAPTION3031 jz @f3032 mov edx,[edi*8+SLOT_BASE+APPDATA.wnd_caption]3033 or edx,edx3034 jz @f3035 3036 movzx eax,[edi+window_data+WDATA.fl_wstyle]3037 and al,0x0F3038 cmp al,33039 je .skinned3040 cmp al,43041 je .skinned3042 3043 jmp .not_skinned3044 .skinned:3045 mov ebp,[edi+window_data+WDATA.box.left-2]3046 mov bp,word[edi+window_data+WDATA.box.top]3047 movzx eax,word[edi+window_data+WDATA.box.width]3048 sub ax,[_skinmargins.left]3049 sub ax,[_skinmargins.right]3050 push edx3051 cwde3052 cdq3053 mov ebx,63054 idiv ebx3055 pop edx3056 or eax,eax3057 js @f3058 mov esi,eax3059 mov ebx,dword[_skinmargins.left-2]3060 mov bx,word[_skinh]3061 sub bx,[_skinmargins.bottom]3062 sub bx,[_skinmargins.top]3063 sar bx,13064 adc bx,03065 add bx,[_skinmargins.top]3066 add bx,-33067 add ebx,ebp3068 jmp .dodraw3069 3070 .not_skinned:3071 cmp al,13072 je @f3073 3074 mov ebp,[edi+window_data+WDATA.box.left-2]3075 mov bp,word[edi+window_data+WDATA.box.top]3076 movzx eax,word[edi+window_data+WDATA.box.width]3077 sub eax,163078 push edx3079 cwde3080 cdq3081 mov ebx,63082 idiv ebx3083 pop edx3084 or eax,eax3085 js @f3086 mov esi,eax3087 mov ebx,0x000800073088 add ebx,ebp3089 .dodraw:3090 mov ecx,[common_colours+16];0x00FFFFFF3091 or ecx, 0x800000003092 xor edi,edi3093 ; // Alver 22.06.2008 // {3094 ; call dtext3095 call dtext_asciiz_esi3096 ; } \\ Alver \\3097 3098 @@:3099 ;--------------------------------------------------------------3100 dec [mouse_pause]3101 call [draw_pointer]3102 ret3103 3104 iglobal3105 align 43106 window_topleft dd \3107 1, 21,\ ;type 03108 0, 0,\ ;type 13109 5, 20,\ ;type 23110 5, ?,\ ;type 3 {set by skin}3111 5, ? ;type 4 {set by skin}3112 endg3113 3114 set_window_clientbox:3115 push eax ecx edi3116 3117 mov eax,[_skinh]3118 mov [window_topleft+4*7],eax3119 mov [window_topleft+4*9],eax3120 3121 mov ecx,edi3122 sub edi,window_data3123 shl edi,33124 test [ecx+WDATA.fl_wstyle],WSTYLE_CLIENTRELATIVE3125 jz @f3126 3127 movzx eax,[ecx+WDATA.fl_wstyle]3128 and eax,0x0F3129 mov eax,[eax*8+window_topleft+0]3130 mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.left],eax3131 shl eax,13132 neg eax3133 add eax,[ecx+WDATA.box.width]3134 mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.width],eax3135 3136 movzx eax,[ecx+WDATA.fl_wstyle]3137 and eax,0x0F3138 push [eax*8+window_topleft+0]3139 mov eax,[eax*8+window_topleft+4]3140 mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.top],eax3141 neg eax3142 sub eax,[esp]3143 add eax,[ecx+WDATA.box.height]3144 mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.height],eax3145 add esp,43146 3147 pop edi ecx eax3148 ret3149 @@:3150 xor eax,eax3151 mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.left],eax3152 mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.top],eax3153 mov eax,[ecx+WDATA.box.width]3154 mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.width],eax3155 mov eax,[ecx+WDATA.box.height]3156 mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.height],eax3157 3158 pop edi ecx eax3159 ret3160 3161 sys_set_window:3162 3163 mov eax,[CURRENT_TASK]3164 shl eax,53165 add eax,window_data3166 3167 ; colors3168 mov [eax+WDATA.cl_workarea],edx3169 mov [eax+WDATA.cl_titlebar],esi3170 mov [eax+WDATA.cl_frames],edi3171 3172 mov edi, eax3173 3174 ; check flag (?)3175 test [edi+WDATA.fl_wdrawn],13176 jnz newd3177 3178 mov eax,[timer_ticks] ;[0xfdf0]3179 add eax,1003180 mov [new_window_starting],eax3181 3182 movsx eax,bx3183 mov [edi+WDATA.box.width],eax3184 movsx eax,cx3185 mov [edi+WDATA.box.height],eax3186 sar ebx,163187 sar ecx,163188 mov [edi+WDATA.box.left],ebx3189 mov [edi+WDATA.box.top],ecx3190 3191 call check_window_position3192 3193 push ecx esi edi ; save for window fullscreen/resize3194 ;mov esi,edi3195 3196 mov cl, [edi+WDATA.fl_wstyle]3197 mov eax, [edi+WDATA.cl_frames]3198 3199 sub edi,window_data3200 shl edi,33201 add edi,SLOT_BASE3202 3203 and cl,0x0F3204 mov [edi+APPDATA.wnd_caption],03205 cmp cl,33206 je set_APPDATA_wnd_caption3207 cmp cl,4 ; {SPraid.simba}3208 je set_APPDATA_wnd_caption3209 3210 jmp @f3211 set_APPDATA_wnd_caption:3212 mov [edi+APPDATA.wnd_caption],eax3213 @@: mov esi,[esp+0]3214 3215 add edi, APPDATA.saved_box3216 movsd3217 movsd3218 movsd3219 movsd3220 pop edi esi ecx3221 3222 mov esi, [CURRENT_TASK]3223 movzx esi, word [WIN_STACK+esi*2]3224 lea esi, [WIN_POS+esi*2]3225 call waredraw3226 3227 ;;; mov ebx, 13228 ;;; call delay_hs3229 mov eax, [edi+WDATA.box.left]3230 mov ebx, [edi+WDATA.box.top]3231 mov ecx, [edi+WDATA.box.width]3232 mov edx, [edi+WDATA.box.height]3233 add ecx, eax3234 add edx, ebx3235 call calculatescreen3236 3237 mov [KEY_COUNT],byte 0 ; empty keyboard buffer3238 mov [BTN_COUNT],byte 0 ; empty button buffer3239 3240 newd:3241 call set_window_clientbox3242 3243 mov [edi+WDATA.fl_redraw],byte 0 ; no redraw3244 mov edx,edi3245 3246 ret3247 3248 syscall_windowsettings:3249 3250 .set_window_caption:3251 dec ebx ; subfunction #1 - set window caption3252 jnz .exit_fail3253 3254 ; NOTE: only window owner thread can set its caption,3255 ; so there's no parameter for PID/TID3256 3257 mov edi,[CURRENT_TASK]3258 shl edi,53259 3260 ; have to check if caption is within application memory limit3261 ; check is trivial, and if application resizes its memory,3262 ; caption still can become over bounds3263 ; diamond, 31.10.2006: check removed because with new memory manager3264 ; there can be valid data after APPDATA.mem_size bound3265 ; mov ecx,[edi*8+SLOT_BASE+APPDATA.mem_size]3266 ; add ecx,255 ; max caption length3267 ; cmp ebx,ecx3268 ; ja .exit_fail3269 3270 mov [edi*8+SLOT_BASE+APPDATA.wnd_caption],ecx3271 or [edi+window_data+WDATA.fl_wstyle],WSTYLE_HASCAPTION3272 3273 call draw_window_caption3274 3275 xor eax,eax ; eax = 0 (success)3276 ret3277 3278 ; .get_window_caption:3279 ; dec eax ; subfunction #2 - get window caption3280 ; jnz .exit_fail3281 3282 ; not implemented yet3283 3284 .exit_fail:3285 xor eax,eax3286 inc eax ; eax = 1 (fail)3287 ret3288 3289 3290 sys_window_move:3291 3292 mov edi,[CURRENT_TASK]3293 shl edi,53294 add edi,window_data3295 3296 test [edi+WDATA.fl_wstate],WSTATE_MAXIMIZED3297 jnz .window_move_return3298 3299 push dword [edi + WDATA.box.left] ; save old coordinates3300 push dword [edi + WDATA.box.top]3301 push dword [edi + WDATA.box.width]3302 push dword [edi + WDATA.box.height]3303 3304 cmp eax,-1 ; set new position and size3305 je .no_x_reposition3306 mov [edi + WDATA.box.left], eax3307 .no_x_reposition:3308 cmp ebx,-13309 je .no_y_reposition3310 mov [edi + WDATA.box.top], ebx3311 .no_y_reposition:3312 3313 test [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP3314 jnz .no_y_resizing3315 3316 cmp ecx,-13317 je .no_x_resizing3318 mov [edi + WDATA.box.width], ecx3319 .no_x_resizing:3320 cmp edx,-13321 je .no_y_resizing3322 mov [edi + WDATA.box.height], edx3323 .no_y_resizing:3324 3325 call check_window_position3326 call set_window_clientbox3327 3328 pushad ; save for window fullscreen/resize3329 mov esi,edi3330 sub edi,window_data3331 shr edi,53332 shl edi,83333 add edi, SLOT_BASE + APPDATA.saved_box3334 mov ecx,43335 cld3336 rep movsd3337 popad3338 3339 pushad ; calculcate screen at new position3340 mov eax, [edi + WDATA.box.left]3341 mov ebx, [edi + WDATA.box.top]3342 mov ecx, [edi + WDATA.box.width]3343 mov edx, [edi + WDATA.box.height]3344 add ecx,eax3345 add edx,ebx3346 3347 call calculatescreen3348 popad3349 3350 pop edx ; calculcate screen at old position3351 pop ecx3352 pop ebx3353 pop eax3354 add ecx,eax3355 add edx,ebx3356 mov [draw_limits.left],eax ; save for drawlimits3357 mov [draw_limits.top],ebx3358 mov [draw_limits.right],ecx3359 mov [draw_limits.bottom],edx3360 call calculatescreen3361 3362 mov [edi + WDATA.fl_redraw], 1 ; flag the process as redraw3363 3364 mov eax,edi ; redraw screen at old position3365 xor esi,esi3366 call redrawscreen3367 3368 mov [DONT_DRAW_MOUSE],byte 0 ; mouse pointer3369 mov [MOUSE_BACKGROUND],byte 0 ; no mouse under3370 mov [MOUSE_DOWN],byte 0 ; react to mouse up/down3371 3372 call [draw_pointer]3373 3374 mov [window_move_pr],03375 3376 .window_move_return:3377 3378 ret3379 3380 uglobal3381 window_move_pr dd 0x03382 window_move_eax dd 0x03383 window_move_ebx dd 0x03384 window_move_ecx dd 0x03385 window_move_edx dd 0x03386 endg3387 2908 3388 2909 ;ok - 100% work -
kernel/trunk/kernel32.inc
r1379 r1391 41 41 ; display 'not used dt: ',`.,13,10 42 42 ; end if } 43 44 struc POINT { 45 .x dd ? 46 .y dd ? 47 .sizeof: 48 } 49 virtual at 0 50 POINT POINT 51 end virtual 43 52 44 53 struc RECT { … … 47 56 .right dd ? 48 57 .bottom dd ? 58 .sizeof: 49 59 } 50 60 virtual at 0 … … 57 67 .width dd ? 58 68 .height dd ? 69 .sizeof: 59 70 } 60 71 virtual at 0
