Subversion Repositories Kolibri OS

Rev

Rev 1369 | Rev 1424 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1369 Rev 1391
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2009. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2010. All rights reserved. ;;
4
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa      ;;
4
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa      ;;
5
;; Distributed under terms of the GNU General Public License    ;;
5
;; Distributed under terms of the GNU General Public License    ;;
6
;;                                                              ;;
6
;;                                                              ;;
7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 8... Line 8...
8
 
8
 
9
$Revision: 1369 $
-
 
Line 10... Line 9...
10
 
9
$Revision: 1391 $
11
 
10
 
12
;==============================================================================
11
;==============================================================================
Line -... Line 12...
-
 
12
;///// public functions ///////////////////////////////////////////////////////
-
 
13
;==============================================================================
13
;///// public functions ///////////////////////////////////////////////////////
14
 
14
;==============================================================================
15
window.BORDER_SIZE = 5
15
 
16
 
16
macro FuncTable name, [label]
17
macro FuncTable name, table_name, [label]
17
{
18
{
18
  common
19
  common
19
    align 4
20
    align 4
20
    \label name#.ftable dword
21
    \label name#.#table_name dword
21
  forward
22
  forward
22
    dd name#.#label
23
    dd name#.#label
Line 23... Line -...
23
  common
-
 
24
    name#.sizeof.ftable = $ - name#.ftable
-
 
25
}
-
 
26
 
-
 
27
iglobal
-
 
28
  FuncTable syscall_display_settings, \
24
  common
29
    00, 01, 02, 03, 04, 05, 06, 07, 08
25
    name#.sizeof.#table_name = $ - name#.#table_name
30
endg
-
 
31
 
-
 
32
uglobal
-
 
33
  common_colours            rd 32
-
 
34
  new_window_starting       dd ?
-
 
35
  latest_window_touch       dd ?
26
}
36
  latest_window_touch_delta dd ?
-
 
37
  old_window_pos            BOX
-
 
38
  new_window_pos            BOX
-
 
39
  draw_limits               RECT
-
 
40
  bPressedMouseXY_W         db ?
27
 
Line 41... Line 28...
41
  do_resize                 db ?
28
uglobal
42
  do_resize_from_corner     db ?
29
  common_colours rd 32
-
 
30
  draw_limits    RECT
-
 
31
endg
-
 
32
 
-
 
33
align 4
-
 
34
;------------------------------------------------------------------------------
-
 
35
syscall_draw_window: ;///// system function 0 /////////////////////////////////
-
 
36
;------------------------------------------------------------------------------
-
 
37
;? 
-
 
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
 
43
  reposition                db ?
85
  .exit:
44
endg
86
        ret
45
 
87
 
46
align 4
88
align 4
47
;------------------------------------------------------------------------------
89
;------------------------------------------------------------------------------
Line 267... Line 309...
267
  .exit:
309
  .exit:
268
        ret
310
        ret
Line 269... Line 311...
269
 
311
 
270
align 4
312
align 4
-
 
313
;------------------------------------------------------------------------------
-
 
314
syscall_move_window: ;///// system function 67 ////////////////////////////////
-
 
315
;------------------------------------------------------------------------------
-
 
316
;? 
-
 
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
;? 
-
 
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
271
;------------------------------------------------------------------------------
390
;------------------------------------------------------------------------------
272
set_window_defaults: ;/////////////////////////////////////////////////////////
391
set_window_defaults: ;/////////////////////////////////////////////////////////
273
;------------------------------------------------------------------------------
392
;------------------------------------------------------------------------------
274
;? 
393
;? 
275
;------------------------------------------------------------------------------
394
;------------------------------------------------------------------------------
Line 427... Line 546...
427
        sub     eax, [screen_workarea.bottom]
546
        sub     eax, [screen_workarea.bottom]
428
        neg     eax
547
        neg     eax
429
        mov     [edi + WDATA.box.height], eax
548
        mov     [edi + WDATA.box.height], eax
Line 430... Line 549...
430
 
549
 
431
  .fix_client_box:
550
  .fix_client_box:
Line 432... Line 551...
432
        call    set_window_clientbox
551
        call    window._.set_window_clientbox
433
 
552
 
Line 434... Line 553...
434
        add     edi, WDATA.sizeof
553
        add     edi, WDATA.sizeof
435
        loop    .next_window
554
        loop    .next_window
Line 436... Line 555...
436
 
555
 
437
  .exit:
556
  .exit:
438
        ret
-
 
439
 
-
 
440
align 4
-
 
441
;------------------------------------------------------------------------------
-
 
442
check_window_position: ;///////////////////////////////////////////////////////
-
 
443
;------------------------------------------------------------------------------
-
 
444
;? Check if window is inside screen area
-
 
445
;------------------------------------------------------------------------------
-
 
446
;> edi = pointer to WDATA
-
 
447
;------------------------------------------------------------------------------
-
 
448
        push    eax ebx ecx edx esi
-
 
449
 
-
 
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, esi
-
 
457
        ja      .fix_width
-
 
458
 
-
 
459
  .check_left:
-
 
460
        or      eax, eax
-
 
461
        jl      .fix_left_low
-
 
462
        add     eax, ecx
-
 
463
        cmp     eax, esi
-
 
464
        jg      .fix_left_high
-
 
465
 
-
 
466
  .check_height:
-
 
467
        mov     esi, [Screen_Max_Y]
-
 
468
        cmp     edx, esi
-
 
469
        ja      .fix_height
-
 
470
 
-
 
471
  .check_top:
-
 
472
        or      ebx, ebx
-
 
473
        jl      .fix_top_low
-
 
474
        add     ebx, edx
-
 
475
        cmp     ebx, esi
-
 
476
        jg      .fix_top_high
-
 
477
 
-
 
478
  .exit:
-
 
479
        pop     esi edx ecx ebx eax
-
 
480
        ret
-
 
481
 
-
 
482
  .fix_width:
-
 
483
        mov     ecx, esi
-
 
484
        mov     [edi + WDATA.box.width], esi
-
 
485
        jmp     .check_left
-
 
486
 
-
 
487
  .fix_left_low:
-
 
488
        xor     eax, eax
-
 
489
        mov     [edi + WDATA.box.left], eax
-
 
490
        jmp     .check_height
-
 
491
 
-
 
492
  .fix_left_high:
-
 
493
        mov     eax, esi
-
 
494
        sub     eax, ecx
-
 
495
        mov     [edi + WDATA.box.left], eax
-
 
496
        jmp     .check_height
-
 
497
 
-
 
498
  .fix_height:
-
 
499
        mov     edx, esi
-
 
500
        mov     [edi + WDATA.box.height], esi
-
 
501
        jmp     .check_top
-
 
502
 
-
 
503
  .fix_top_low:
-
 
504
        xor     ebx, ebx
-
 
505
        mov     [edi + WDATA.box.top], ebx
-
 
506
        jmp     .exit
-
 
507
 
-
 
508
  .fix_top_high:
-
 
509
        mov     ebx, esi
-
 
510
        sub     ebx, edx
-
 
511
        mov     [edi + WDATA.box.top], ebx
-
 
512
        jmp     .exit
557
        ret
513
 
558
 
514
align 4
559
align 4
515
;------------------------------------------------------------------------------
560
;------------------------------------------------------------------------------
-
 
561
sys_window_mouse: ;////////////////////////////////////////////////////////////
-
 
562
;------------------------------------------------------------------------------
516
sys_window_mouse: ;////////////////////////////////////////////////////////////
563
;? 
517
;------------------------------------------------------------------------------
564
;------------------------------------------------------------------------------
518
;? 
565
        ; NOTE: commented out since doesn't provide necessary functionality
519
;------------------------------------------------------------------------------
566
        ;       anyway, to be reworked
520
        push    eax
567
;       push    eax
521
 
568
;
522
        mov     eax, [timer_ticks]
569
;       mov     eax, [timer_ticks]
523
        cmp     [new_window_starting], eax
570
;       cmp     [new_window_starting], eax
524
        jb      .exit
571
;       jb      .exit
525
 
572
;
526
        mov     byte[MOUSE_BACKGROUND], 0
573
;       mov     byte[MOUSE_BACKGROUND], 0
527
        mov     byte[DONT_DRAW_MOUSE], 0
574
;       mov     byte[DONT_DRAW_MOUSE], 0
528
 
575
;
529
        mov     [new_window_starting], eax
576
;       mov     [new_window_starting], eax
Line 530... Line 577...
530
 
577
;
531
  .exit:
578
; .exit:
532
        pop     eax
579
;       pop     eax
Line 807... Line 854...
807
;------------------------------------------------------------------------------
854
;------------------------------------------------------------------------------
808
waredraw: ;////////////////////////////////////////////////////////////////////
855
waredraw: ;////////////////////////////////////////////////////////////////////
809
;------------------------------------------------------------------------------
856
;------------------------------------------------------------------------------
810
;? Activate window, redrawing if necessary
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
        ; is it overlapped by another window now?
866
        ; is it overlapped by another window now?
813
        push    ecx
867
        push    ecx
814
        call    window._.check_window_draw
868
        call    window._.check_window_draw
815
        test    ecx, ecx
869
        test    ecx, ecx
816
        pop     ecx
870
        pop     ecx
Line 839... Line 893...
839
        call    window._.set_screen
893
        call    window._.set_screen
840
        popad
894
        popad
Line 841... Line 895...
841
 
895
 
842
        ; tell application to redraw itself
896
        ; tell application to redraw itself
843
        mov     [edi + WDATA.fl_redraw], 1
897
        mov     [edi + WDATA.fl_redraw], 1
844
        mov     byte[MOUSE_DOWN], 0
898
        xor     eax, eax
Line 845... Line 899...
845
        ret
899
        jmp     .exit
846
 
900
 
847
  .do_not_draw:
901
  .do_not_draw:
848
        ; no it's not, just activate the window
-
 
849
        call    window._.window_activate
902
        ; no it's not, just activate the window
850
        mov     byte[MOUSE_DOWN], 0
903
        call    window._.window_activate
-
 
904
        mov     byte[MOUSE_BACKGROUND], 0
-
 
905
        mov     byte[DONT_DRAW_MOUSE], 0
-
 
906
        xor     eax, eax
-
 
907
 
-
 
908
  .exit:
851
        mov     byte[MOUSE_BACKGROUND], 0
909
        mov     byte[MOUSE_DOWN], 0
Line 852... Line 910...
852
        mov     byte[DONT_DRAW_MOUSE], 0
910
        inc     eax
853
        ret
911
        ret
854
 
912
 
Line 938... Line 996...
938
        popfd
996
        popfd
939
        popad
997
        popad
940
        ret
998
        ret
Line 941... Line 999...
941
 
999
 
-
 
1000
align 4
942
align 4
1001
; TODO: remove this proc
943
;------------------------------------------------------------------------------
1002
;------------------------------------------------------------------------------
944
checkwindows: ;////////////////////////////////////////////////////////////////
1003
window_check_events: ;/////////////////////////////////////////////////////////
945
;------------------------------------------------------------------------------
1004
;------------------------------------------------------------------------------
946
;? Check for user-initiated window operations
1005
;? 
947
;------------------------------------------------------------------------------
-
 
948
        pushad
-
 
949
 
1006
;------------------------------------------------------------------------------
950
        ; do we have window minimize/restore request?
1007
        ; do we have window minimize/restore request?
951
        cmp     [window_minimize], 0
1008
        cmp     [window_minimize], 0
Line 952... Line 1009...
952
        je      .check_for_mouse_buttons_state
1009
        je      .exit
953
 
1010
 
954
        ; okay, minimize or restore top-most window and exit
1011
        ; okay, minimize or restore top-most window and exit
955
        mov     eax, [TASK_COUNT]
1012
        mov     eax, [TASK_COUNT]
956
        mov     bl, 0
1013
        mov     bl, 0
957
        xchg    [window_minimize], bl
1014
        xchg    [window_minimize], bl
958
        dec     bl
1015
        dec     bl
959
        jnz     @f
1016
        jnz     @f
960
        call    minimize_window
-
 
Line 961... Line -...
961
        jmp     .check_for_mouse_buttons_state
-
 
962
    @@: call    restore_minimized_window
-
 
963
 
-
 
964
  .check_for_mouse_buttons_state:
1017
        call    minimize_window
Line 965... Line 1018...
965
        ; do we have any mouse buttons pressed?
1018
        jmp     .exit
966
        cmp     byte[BTN_DOWN], 0
1019
 
Line -... Line 1020...
-
 
1020
    @@: call    restore_minimized_window
-
 
1021
 
-
 
1022
  .exit:
-
 
1023
        ret
967
        jne     .mouse_buttons_pressed
1024
 
-
 
1025
align 4
968
 
1026
;------------------------------------------------------------------------------
-
 
1027
sys_window_maximize_handler: ;/////////////////////////////////////////////////
969
        mov     [bPressedMouseXY_W], 0
1028
;------------------------------------------------------------------------------
970
        jmp     .exit
1029
;? 
-
 
1030
;------------------------------------------------------------------------------
Line 971... Line -...
971
 
-
 
972
  .mouse_buttons_pressed:
1031
;> esi = process slot
973
        ; yes we do, iterate and ...
1032
;------------------------------------------------------------------------------
974
        mov     esi, [TASK_COUNT]
1033
        mov     edi, esi
975
        inc     esi
1034
        shl     edi, 5
976
 
1035
        add     edi, window_data
Line 977... Line 1036...
977
        cmp     [bPressedMouseXY_W], 1
1036
 
978
        ja      .next_window
1037
        ; can window change its height?
979
        inc     [bPressedMouseXY_W]
1038
        mov     dl, [edi + WDATA.fl_wstyle]
Line -... Line 1039...
-
 
1039
        and     dl, 0x0f
-
 
1040
        cmp     dl, 0x04
980
        jnc     .next_window
1041
        je      .exit
Line 981... Line 1042...
981
        push    dword[MOUSE_X]
1042
 
982
        pop     dword[mx]
1043
        ; toggle normal/maximized window state
-
 
1044
        mov     bl, [edi + WDATA.fl_wstate]
-
 
1045
        xor     bl, WSTATE_MAXIMIZED
983
 
1046
 
-
 
1047
        ; calculate and set appropriate window bounds
984
  .next_window:
1048
        test    bl, WSTATE_MAXIMIZED
985
        cmp     esi, 2
1049
        jz      .restore_size
-
 
1050
 
986
        jb      .exit
1051
        mov     eax, [screen_workarea.left]
Line -... Line 1052...
-
 
1052
        mov     ecx, [screen_workarea.top]
987
 
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
988
        dec     esi
1060
        jmp     .set_box
Line 989... Line -...
989
 
-
 
990
        ; is that window not minimized?
-
 
991
        movzx   edi, word[WIN_POS + esi * 2]
-
 
992
        shl     edi, 5
-
 
993
        add     edi, window_data
1061
 
994
        test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
-
 
995
        jnz     .next_window
1062
  .restore_size:
996
 
-
 
997
        movzx   eax, [mx]
-
 
998
        movzx   ebx, [my]
1063
        mov     eax, esi
999
 
-
 
1000
        ; is the cursor inside screen bounds of that window?
-
 
1001
        mov     ecx, [edi + WDATA.box.left]
-
 
Line 1002... Line -...
1002
        mov     edx, [edi + WDATA.box.top]
-
 
1003
        cmp     eax, ecx
1064
        shl     eax, 8
1004
        jl      .next_window
1065
        add     eax, SLOT_BASE + APPDATA.saved_box
1005
        cmp     ebx, edx
-
 
1006
        jl      .next_window
-
 
1007
        add     ecx, [edi + WDATA.box.width]
-
 
1008
        add     edx, [edi + WDATA.box.height]
1066
        push    [eax + BOX.height] \
1009
        cmp     eax, ecx
1067
                [eax + BOX.width] \
Line 1010... Line -...
1010
        jge     .next_window
-
 
1011
        cmp     ebx, edx
-
 
1012
        jge     .next_window
1068
                [eax + BOX.top] \
1013
 
1069
                [eax + BOX.left]
Line 1014... Line 1070...
1014
        ; is that a top-most (which means active) window?
1070
        mov     eax, esp
1015
        cmp     esi, [TASK_COUNT]
-
 
1016
        je      .check_for_moving_or_resizing
-
 
1017
 
1071
 
Line -... Line 1072...
-
 
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
1018
        ; no it's not, did we just press mouse button down above it or was it
1080
 
1019
        ; already pressed before?
1081
    @@: call    window._.set_window_box
1020
        cmp     [bPressedMouseXY_W], 1
1082
        add     esp, BOX.sizeof
Line 1021... Line 1083...
1021
        ja      .exit
1083
 
1022
 
-
 
1023
        ; okay, we just pressed the button, activate this window and exit
1084
  .exit:
1024
        lea     esi, [WIN_POS + esi * 2]
-
 
1025
        call    waredraw
1085
        ret
1026
        jmp     .exit
-
 
1027
 
-
 
1028
  .check_for_moving_or_resizing:
-
 
1029
        ; is that window movable?
-
 
1030
        test    byte[edi + WDATA.cl_titlebar + 3], 0x01
-
 
Line 1031... Line 1086...
1031
        jnz     .exit
1086
 
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
1087
align 4
1039
        mov     dl, [edi + WDATA.fl_wstyle]
-
 
1040
        and     dl, 0x0f
1088
;------------------------------------------------------------------------------
Line 1041... Line -...
1041
        cmp     dl, 0x00
-
 
1042
        je      .check_for_cursor_on_caption
1089
sys_window_rollup_handler: ;///////////////////////////////////////////////////
1043
        cmp     dl, 0x01
1090
;------------------------------------------------------------------------------
1044
        je      .check_for_cursor_on_caption
1091
;? 
1045
        cmp     dl, 0x04
1092
;------------------------------------------------------------------------------
1046
        je      .check_for_cursor_on_caption
1093
;> esi = process slot
1047
 
1094
;------------------------------------------------------------------------------
1048
        ; are we going to resize it?
1095
        mov     edx, esi
Line 1049... Line -...
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
1096
        shl     edx, 8
1057
        jmp     .set_move_resize_flag
1097
        add     edx, SLOT_BASE
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]
1098
 
1064
        cmp     ebx, eax
-
 
1065
        pop     eax
-
 
1066
        jge     .exit
1099
        ; toggle normal/rolled up window state
1067
 
1100
        mov     bl, [edi + WDATA.fl_wstate]
1068
        ; calculate duration between two clicks
-
 
1069
        mov     ecx, [timer_ticks]
-
 
1070
        mov     edx, ecx
1101
        xor     bl, WSTATE_ROLLEDUP
Line -... Line 1102...
-
 
1102
 
1071
        sub     edx, [latest_window_touch]
1103
        ; calculate and set appropriate window bounds
-
 
1104
        test    bl, WSTATE_ROLLEDUP
1072
        mov     [latest_window_touch], ecx
1105
        jz      .restore_size
-
 
1106
 
-
 
1107
        call    window._.get_rolledup_height
1073
        mov     [latest_window_touch_delta], edx
1108
        push    eax \
Line -... Line 1109...
-
 
1109
                [edi + WDATA.box.width] \
1074
 
1110
                [edi + WDATA.box.top] \
1075
  .set_move_resize_flag:
1111
                [edi + WDATA.box.left]
Line 1076... Line -...
1076
        mov     cl, [BTN_DOWN]
-
 
1077
        mov     [do_resize], cl
1112
        mov     eax, esp
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
 
-
 
Line -... Line 1113...
-
 
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
 
1091
        ; calculate window-relative cursor coordinates
1122
    @@: mov     eax, [screen_workarea.top]
1092
        sub     eax, ecx
1123
        push    [screen_workarea.bottom] \
Line 1093... Line 1124...
1093
        sub     ebx, edx
1124
                [edi + WDATA.box.width] \
1094
 
-
 
Line -... Line 1125...
-
 
1125
                eax \
-
 
1126
                [edi + WDATA.box.left]
1095
        push    dword[MOUSE_X]
1127
        sub     [esp + BOX.height], eax
-
 
1128
        mov     eax, esp
1096
        pop     dword[WIN_TEMP_XY]
1129
 
-
 
1130
  .set_box:
1097
 
1131
        call    window._.set_window_box
1098
        ; save old window coordinates
1132
        add     esp, BOX.sizeof
1099
        push    eax
1133
 
1100
        mov     eax, [edi + WDATA.box.left]
1134
        ret
1101
        mov     [old_window_pos.left], eax
1135
 
1102
        mov     [new_window_pos.left], eax
-
 
1103
        mov     eax, [edi + WDATA.box.top]
1136
align 4
1104
        mov     [old_window_pos.top], eax
-
 
Line 1105... Line -...
1105
        mov     [new_window_pos.top], eax
-
 
1106
        mov     eax, [edi + WDATA.box.width]
-
 
1107
        mov     [old_window_pos.width], eax
1137
;------------------------------------------------------------------------------
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
 
1138
sys_window_start_moving_handler: ;/////////////////////////////////////////////
1114
        ; draw negative moving/sizing frame
1139
;------------------------------------------------------------------------------
Line 1115... Line 1140...
1115
        call    window._.draw_window_frames
1140
;? 
-
 
1141
;------------------------------------------------------------------------------
-
 
1142
;> eax = old (original) window box
-
 
1143
;> esi = process slot
Line -... Line 1144...
-
 
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
;? 
1116
 
1155
;------------------------------------------------------------------------------
-
 
1156
;> eax = old (original) window box
1117
        mov     [reposition], 0
1157
;> ebx = new (final) window box
-
 
1158
;> esi = process slot
Line 1118... Line 1159...
1118
        mov     byte[MOUSE_DOWN], 1
1159
;------------------------------------------------------------------------------
1119
 
1160
        mov     edi, ebx
1120
  .next_mouse_state_check:
1161
        call    window._.draw_negative_box
Line -... Line 1162...
-
 
1162
 
1121
        ; process OS events
1163
        mov     edi, esi
1122
        mov     byte[DONT_DRAW_MOUSE], 1
1164
        shl     edi, 5
1123
        call    checkidle
-
 
Line -... Line 1165...
-
 
1165
        add     edi, window_data
1124
        call    checkVga_N13
1166
 
1125
        mov     byte[MOUSE_BACKGROUND], 0
1167
        mov     eax, ebx
1126
        call    [draw_pointer]
-
 
1127
        pushad
1168
        mov     bl, [edi + WDATA.fl_wstate]
1128
        call    stack_handler
-
 
1129
        popad
-
 
1130
 
1169
        call    window._.set_window_box
1131
        ; did cursor position change?
1170
        ret
1132
        mov     esi, [WIN_TEMP_XY]
1171
 
-
 
1172
align 4
Line 1133... Line -...
1133
        cmp     esi, [MOUSE_X]
-
 
1134
        je      .check_for_new_mouse_buttons_state
-
 
1135
 
1173
;------------------------------------------------------------------------------
1136
        ; yes it did, calculate window-relative cursor coordinates
-
 
1137
        movzx   ecx, word[MOUSE_X]
-
 
1138
        movzx   edx, word[MOUSE_Y]
1174
sys_window_moving_handler: ;///////////////////////////////////////////////////
1139
        sub     ecx, eax
-
 
1140
        sub     edx, ebx
1175
;------------------------------------------------------------------------------
1141
 
-
 
1142
        push    eax ebx
1176
;? 
1143
 
1177
;------------------------------------------------------------------------------
Line -... Line 1178...
-
 
1178
;> eax = old (from previous call) window box
-
 
1179
;> ebx = new (current) window box
-
 
1180
;> esi = process_slot
-
 
1181
;------------------------------------------------------------------------------
1144
        ; we're going to draw new frame, erasing the old one
1182
        mov     edi, eax
-
 
1183
        call    window._.draw_negative_box
-
 
1184
        mov     edi, ebx
-
 
1185
        call    window._.draw_negative_box
-
 
1186
        ret
-
 
1187
 
1145
        call    window._.draw_window_frames
1188
;==============================================================================
Line -... Line 1189...
-
 
1189
;///// private functions //////////////////////////////////////////////////////
-
 
1190
;==============================================================================
-
 
1191
 
1146
 
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}
1147
        ; are we moving it right now?
1202
    5,  ?    ;type 4 {set by skin}
1148
        cmp     [do_resize_from_corner], 0
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: ;//////////////////////////////////////////////////
Line -... Line 1214...
-
 
1214
;------------------------------------------------------------------------------
-
 
1215
;? 
1149
        jne     .resize_window
1216
;------------------------------------------------------------------------------
1150
 
1217
;> eax = old (original) window box
1151
        ; yes we do, check if it's inside the screen area
1218
;> ebx = new (final) window box
1152
        mov     eax, [Screen_Max_X]
1219
;> edi = pointer to WDATA struct
1153
        mov     ebx, [Screen_Max_Y]
1220
;------------------------------------------------------------------------------
1154
 
1221
        push    eax ebx
1155
        mov     [new_window_pos.left], 0
1222
 
1156
        or      ecx, ecx
1223
        ; TODO: do we really need `draw_limits`?
Line 1157... Line -...
1157
        jle     .check_for_new_vert_cursor_pos
-
 
1158
        mov     [reposition], 1
1224
        mov     ecx, [eax + BOX.left]
1159
        sub     eax, [new_window_pos.width]
1225
        mov     edx, [ebx + BOX.left]
1160
        mov     [new_window_pos.left], eax
1226
        cmp     ecx, edx
1161
        cmp     ecx, eax
1227
        jle     @f
1162
        jge     .check_for_new_vert_cursor_pos
-
 
1163
        mov     [new_window_pos.left], ecx
1228
        xchg    ecx, edx
1164
 
1229
    @@: mov     [draw_limits.left], ecx
1165
  .check_for_new_vert_cursor_pos:
-
 
1166
        mov     [new_window_pos.top], 0
1230
        mov     ecx, [eax + BOX.width]
1167
        or      edx, edx
1231
        cmp     ecx, [ebx + BOX.width]
Line 1168... Line 1232...
1168
        jle     .draw_new_window_frame
1232
        jae     @f
1169
        mov     [reposition], 1
1233
        mov     ecx, [ebx + BOX.width]
Line -... Line 1234...
-
 
1234
    @@: add     ecx, edx
1170
        sub     ebx, [new_window_pos.height]
1235
        mov     [draw_limits.right], ecx
Line 1171... Line -...
1171
        mov     [new_window_pos.top], ebx
-
 
1172
        cmp     edx, ebx
1236
        mov     ecx, [eax + BOX.top]
-
 
1237
        mov     edx, [ebx + BOX.top]
Line -... Line 1238...
-
 
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
1173
        jge     .draw_new_window_frame
1245
        mov     ecx, [ebx + BOX.height]
-
 
1246
    @@: add     ecx, edx
-
 
1247
        mov     [draw_limits.bottom], ecx
1174
        mov     [new_window_pos.top], edx
1248
 
Line 1175... Line 1249...
1175
        jmp     .draw_new_window_frame
1249
        ; recalculate screen buffer at old position
1176
 
-
 
Line 1177... Line 1250...
1177
  .resize_window:
1250
        push    ebx
1178
        push    eax ebx edx
1251
        mov     edx, [eax + BOX.height]
-
 
1252
        mov     ecx, [eax + BOX.width]
1179
 
1253
        mov     ebx, [eax + BOX.top]
-
 
1254
        mov     eax, [eax + BOX.left]
-
 
1255
        add     ecx, eax
-
 
1256
        add     edx, ebx
1180
        mov     edx, edi
1257
        call    calculatescreen
-
 
1258
        pop     eax
1181
        sub     edx, window_data
1259
 
-
 
1260
        ; recalculate screen buffer at new position
-
 
1261
        mov     edx, [eax + BOX.height]
1182
        lea     edx, [SLOT_BASE + edx * 8]
1262
        mov     ecx, [eax + BOX.width]
-
 
1263
        mov     ebx, [eax + BOX.top]
1183
 
1264
        mov     eax, [eax + BOX.left]
-
 
1265
        add     ecx, eax
1184
        movzx   eax, word[MOUSE_X]
1266
        add     edx, ebx
1185
        cmp     eax, [edi + WDATA.box.left]
1267
        call    calculatescreen
1186
        jb      .fix_new_vert_size
1268
 
Line 1187... Line 1269...
1187
        sub     eax, [edi + WDATA.box.left]
1269
        mov     eax, edi
-
 
1270
        call    redrawscreen
-
 
1271
 
Line 1188... Line 1272...
1188
        cmp     eax, 32
1272
        ; tell window to redraw itself
1189
        jge     @f
1273
        mov     [edi + WDATA.fl_redraw], 1
-
 
1274
 
-
 
1275
        pop     ebx eax
Line 1190... Line -...
1190
        mov     eax, 32
-
 
1191
    @@: mov     [new_window_pos.width], eax
-
 
1192
 
-
 
1193
  .fix_new_vert_size:
-
 
1194
        call    window._.get_rolledup_height
1276
        ret
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]
1277
 
Line 1200... Line -...
1200
        cmp     eax, ebx
-
 
1201
        jge     @f
1278
align 4
1202
        mov     eax, ebx
1279
;------------------------------------------------------------------------------
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
1280
window._.set_window_box: ;/////////////////////////////////////////////////////
1212
 
-
 
1213
        ; draw new window moving/sizing frame
1281
;------------------------------------------------------------------------------
1214
        call    window._.draw_window_frames
-
 
Line 1215... Line -...
1215
 
-
 
1216
        mov     esi, [MOUSE_X]
1282
;? 
Line -... Line 1283...
-
 
1283
;------------------------------------------------------------------------------
1217
        mov     [WIN_TEMP_XY], esi
1284
;> eax = pointer to BOX struct
Line 1218... Line 1285...
1218
 
1285
;> bl = new window state flags
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
 
-
 
Line 1224... Line 1286...
1224
        ; yes he did, moving/sizing is over
1286
;> edi = pointer to WDATA struct
1225
        mov     byte[DONT_DRAW_MOUSE], 1
-
 
1226
        mov     cl, 0
1287
;------------------------------------------------------------------------------
1227
        test    [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
-
 
1228
        jnz     .check_other_actions
1288
        push    eax ebx esi
1229
 
-
 
1230
        mov     cl, [reposition]
-
 
Line -... Line 1289...
-
 
1289
 
-
 
1290
        add     esp, -BOX.sizeof
1231
 
1291
 
-
 
1292
        mov     ebx, esp
1232
        ; draw negative frame once again to hide it
1293
        lea     esi, [edi + WDATA.box]
1233
        call    window._.draw_window_frames
1294
        xchg    eax, esi
1234
 
-
 
1235
        ; save new window bounds
1295
        mov     ecx, BOX.sizeof
1236
        mov     eax, [new_window_pos.left]
1296
        call    memmove
1237
        mov     [edi + WDATA.box.left], eax
1297
        xchg    eax, esi
Line 1238... Line -...
1238
        mov     eax, [new_window_pos.top]
-
 
1239
        mov     [edi + WDATA.box.top], eax
-
 
1240
        mov     eax, [new_window_pos.width]
1298
        xchg    ebx, esi
1241
        mov     [edi + WDATA.box.width], eax
1299
        call    memmove
1242
        mov     eax, [new_window_pos.height]
-
 
1243
        mov     [edi + WDATA.box.height], eax
-
 
1244
        call    set_window_clientbox
-
 
1245
 
-
 
1246
        cmp     cl, 1
1300
        xchg    ebx, esi
1247
        jne     .check_other_actions
-
 
Line 1248... Line 1301...
1248
        push    esi edi ecx
1301
 
1249
        mov     esi, edi
1302
        call    window._.check_window_position
1250
        mov     ecx, 2
1303
        call    window._.set_window_clientbox
-
 
1304
        call    window._.invalidate_screen
1251
        test    [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP or WSTATE_MAXIMIZED
1305
 
-
 
1306
        add     esp, BOX.sizeof
1252
        jnz     @f
1307
 
1253
        add     ecx, 2
1308
        mov     cl, [esp + 4]
1254
    @@: sub     edi, window_data
1309
        mov     ch, cl
1255
        shr     edi, 5
1310
        xchg    cl, [edi + WDATA.fl_wstate]
1256
        shl     edi, 8
1311
 
-
 
1312
        or      cl, ch
1257
        add     edi, SLOT_BASE + APPDATA.saved_box
1313
        test    cl, WSTATE_MAXIMIZED
-
 
1314
        jnz     .exit
Line 1258... Line 1315...
1258
        cld
1315
 
1259
        rep     movsd
1316
        mov     eax, edi
1260
        pop     ecx edi esi
1317
        sub     eax, window_data
1261
 
1318
        shl     eax, 3
-
 
1319
        add     eax, SLOT_BASE
1262
  .check_other_actions:
1320
 
1263
        mov     [reposition], cl
1321
        lea     ebx, [edi + WDATA.box]
-
 
1322
        xchg    esp, ebx
-
 
1323
 
1264
 
1324
        pop     [eax + APPDATA.saved_box.left] \
1265
        pushad
1325
                [eax + APPDATA.saved_box.top] \
Line 1266... Line 1326...
1266
 
1326
                [eax + APPDATA.saved_box.width] \
1267
        mov     dl, [edi + WDATA.fl_wstyle]
1327
                edx
1268
        and     dl, 0x0f
1328
 
1269
        cmp     dl, 0x00
1329
        xchg    esp, ebx
1270
        je      .check_if_window_fits_screen
1330
 
1271
        cmp     dl, 0x01
1331
        test    ch, WSTATE_ROLLEDUP
1272
        je      .check_if_window_fits_screen
1332
        jnz     .exit
1273
 
-
 
1274
        cmp     cl, 1
-
 
1275
        je      .no_window_sizing
1333
 
1276
        mov     edx, edi
-
 
Line -... Line 1334...
-
 
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
;? 
-
 
1345
;------------------------------------------------------------------------------
-
 
1346
;> edi = pointer to WDATA struct
-
 
1347
;------------------------------------------------------------------------------
-
 
1348
        push    eax ecx edi
-
 
1349
 
1277
        sub     edx, window_data
1350
        mov     eax, [_skinh]
1278
        shr     edx, 5
1351
        mov     [window_topleft + 8 * 3 + 4], eax
1279
        shl     edx, 8
1352
        mov     [window_topleft + 8 * 4 + 4], eax
1280
        add     edx, SLOT_BASE
1353
 
-
 
1354
        mov     ecx, edi
-
 
1355
        sub     edi, window_data
-
 
1356
        shl     edi, 3
-
 
1357
        test    [ecx + WDATA.fl_wstyle], WSTYLE_CLIENTRELATIVE
1281
 
1358
        jz      .whole_window
-
 
1359
 
-
 
1360
        movzx   eax, [ecx + WDATA.fl_wstyle]
-
 
1361
        and     eax, 0x0F
-
 
1362
        mov     eax, [eax * 8 + window_topleft + 0]
1282
        ; did we right-click on titlebar?
1363
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax
1283
        cmp     [do_resize], 2
1364
        shl     eax, 1
-
 
1365
        neg     eax
-
 
1366
        add     eax, [ecx + WDATA.box.width]
-
 
1367
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax
-
 
1368
 
1284
        jne     .check_maximization_request
1369
        movzx   eax, [ecx + WDATA.fl_wstyle]
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
1370
        and     eax, 0x0F
1291
        test    [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
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
1292
        jz      @f
1374
        neg     eax
-
 
1375
        sub     eax, [esp]
Line 1293... Line -...
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]
1376
        add     eax, [ecx + WDATA.box.height]
1304
        cmp     eax, [Screen_Max_Y]
-
 
Line 1305... Line -...
1305
        jbe     @f
-
 
1306
        mov     eax, [Screen_Max_Y]
1377
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax
Line 1307... Line -...
1307
        sub     eax, [edi + WDATA.box.height]
-
 
1308
        mov     [edi + WDATA.box.top], eax
-
 
1309
    @@: call    check_window_position
1378
        add     esp, 4
1310
        call    set_window_clientbox
-
 
1311
 
-
 
1312
  .check_maximization_request:
-
 
1313
        ; can window change its height?
1379
        jmp     .exit
1314
        push    edx
-
 
1315
        mov     dl, [edi + WDATA.fl_wstyle]
-
 
1316
        and     dl, 0x0f
-
 
Line 1317... Line 1380...
1317
        cmp     dl, 0x04
1380
 
1318
        pop     edx
1381
  .whole_window:
1319
        je      .check_if_window_fits_screen
-
 
1320
 
-
 
1321
        ; was it really a maximize/restore request?
1382
        xor     eax, eax
1322
        cmp     [do_resize], 1
-
 
1323
        jne     .check_if_window_fits_screen
-
 
1324
        cmp     [do_resize_from_corner], 0
-
 
Line 1325... Line 1383...
1325
        jne     .check_if_window_fits_screen
1383
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax
-
 
1384
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax
1326
        cmp     [latest_window_touch_delta], 50
1385
        mov     eax, [ecx + WDATA.box.width]
-
 
1386
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax
-
 
1387
        mov     eax, [ecx + WDATA.box.height]
Line 1327... Line -...
1327
        jg      .check_if_window_fits_screen
-
 
1328
 
-
 
1329
        ; yes is was, toggle normal/maximized window state
1388
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax
Line 1330... Line 1389...
1330
        xor     [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
1389
 
Line -... Line 1390...
-
 
1390
  .exit:
-
 
1391
        pop     edi ecx eax
-
 
1392
        ret
-
 
1393
 
-
 
1394
align 4
-
 
1395
;------------------------------------------------------------------------------
-
 
1396
window._.sys_set_window: ;/////////////////////////////////////////////////////
1331
        mov     [reposition], 1
1397
;------------------------------------------------------------------------------
-
 
1398
;? 
-
 
1399
;------------------------------------------------------------------------------
-
 
1400
;< edx = pointer to WDATA struct
-
 
1401
;------------------------------------------------------------------------------
-
 
1402
        mov     eax, [CURRENT_TASK]
Line 1332... Line -...
1332
 
-
 
1333
        ; calculate and set appropriate window bounds
1403
        shl     eax, 5
1334
        test    [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
1404
        add     eax, window_data
1335
        jz      .restore_normal_window_size
1405
 
1336
        mov     eax, [screen_workarea.left]
1406
        ; save window colors
1337
        mov     [edi + WDATA.box.left], eax
1407
        mov     [eax + WDATA.cl_workarea], edx
1338
        sub     eax, [screen_workarea.right]
1408
        mov     [eax + WDATA.cl_titlebar], esi
1339
        neg     eax
1409
        mov     [eax + WDATA.cl_frames], edi
Line 1340... Line -...
1340
        mov     [edi + WDATA.box.width], eax
-
 
1341
        mov     eax, [screen_workarea.top]
1410
 
1342
        mov     [edi + WDATA.box.top], eax
1411
        mov     edi, eax
1343
        test    [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
-
 
1344
        jnz     .calculate_window_client_area
-
 
1345
        sub     eax, [screen_workarea.bottom]
-
 
1346
        neg     eax
-
 
1347
        mov     [edi + WDATA.box.height], eax
-
 
Line -... Line 1412...
-
 
1412
 
1348
        jmp     .calculate_window_client_area
1413
        ; was it already defined before?
-
 
1414
        test    [edi + WDATA.fl_wdrawn], 1
Line -... Line 1415...
-
 
1415
        jnz     .set_client_box
-
 
1416
 
1349
 
1417
        ; NOTE: commented out since doesn't provide necessary functionality
1350
  .restore_normal_window_size:
1418
        ;       anyway, to be reworked
Line -... Line 1419...
-
 
1419
;       mov     eax, [timer_ticks] ; [0xfdf0]
-
 
1420
;       add     eax, 100
-
 
1421
;       mov     [new_window_starting], eax
-
 
1422
 
1351
        push    [edi + WDATA.box.height]
1423
        ; no it wasn't, performing initial window definition
-
 
1424
        movzx   eax, bx
-
 
1425
        mov     [edi + WDATA.box.width], eax
-
 
1426
        movzx   eax, cx
1352
        push    edi
1427
        mov     [edi + WDATA.box.height], eax
Line -... Line 1428...
-
 
1428
        sar     ebx, 16
1353
        lea     esi, [edx + APPDATA.saved_box]
1429
        sar     ecx, 16
1354
        mov     ecx, 4
1430
        mov     [edi + WDATA.box.left], ebx
-
 
1431
        mov     [edi + WDATA.box.top], ecx
Line 1355... Line -...
1355
        cld
-
 
1356
        rep     movsd
1432
 
1357
        pop     edi
1433
        call    window._.check_window_position
1358
        pop     eax
-
 
1359
        test    [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
1434
 
1360
        jz      .calculate_window_client_area
-
 
Line 1361... Line 1435...
1361
        mov     [edi + WDATA.box.height], eax
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
1362
 
1443
 
-
 
1444
        and     cl, 0x0F
-
 
1445
        cmp     cl, 3
-
 
1446
        je      @f
-
 
1447
        cmp     cl, 4
1363
  .calculate_window_client_area:
1448
        je      @f
1364
        call    set_window_clientbox
1449
 
-
 
1450
        xor     eax, eax
-
 
1451
 
-
 
1452
    @@: mov     [edi + APPDATA.wnd_caption], eax
Line 1365... Line 1453...
1365
 
1453
 
1366
  .check_if_window_fits_screen:
1454
        mov     esi, [esp]
1367
        ; does window fit into screen area?
1455
        add     edi, APPDATA.saved_box
Line -... Line 1456...
-
 
1456
        movsd
-
 
1457
        movsd
1368
        mov     eax, [edi + WDATA.box.top]
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
 
-
 
1468
        mov     eax, [edi + WDATA.box.left]
1369
        add     eax, [edi + WDATA.box.height]
1469
        mov     ebx, [edi + WDATA.box.top]
-
 
1470
        mov     ecx, [edi + WDATA.box.width]
-
 
1471
        mov     edx, [edi + WDATA.box.height]
-
 
1472
        add     ecx, eax
-
 
1473
        add     edx, ebx
1370
        cmp     eax, [Screen_Max_Y]
1474
        call    calculatescreen
-
 
1475
 
-
 
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
Line 1371... Line 1487...
1371
        jbe     .no_window_sizing
1487
 
1372
        mov     eax, [edi + WDATA.box.left]
1488
align 4
1373
        add     eax, [edi + WDATA.box.width]
1489
;------------------------------------------------------------------------------
1374
        cmp     eax, [Screen_Max_X]
1490
window._.check_window_position: ;//////////////////////////////////////////////
-
 
1491
;------------------------------------------------------------------------------
-
 
1492
;? Check if window is inside screen area
1375
        jbe     .no_window_sizing
1493
;------------------------------------------------------------------------------
1376
 
1494
;> edi = pointer to WDATA
1377
        ; no it doesn't, fix that
1495
;------------------------------------------------------------------------------
1378
        mov     eax, [Screen_Max_X]
1496
        push    eax ebx ecx edx esi
1379
        sub     eax, [edi + WDATA.box.width]
1497
 
Line 1460... Line 1578...
1460
 
1578
 
1461
align 4
1579
align 4
1462
;------------------------------------------------------------------------------
1580
;------------------------------------------------------------------------------
1463
window._.get_rolledup_height: ;////////////////////////////////////////////////
1581
window._.get_rolledup_height: ;////////////////////////////////////////////////
-
 
1582
;------------------------------------------------------------------------------
-
 
1583
;? 
1464
;------------------------------------------------------------------------------
1584
;------------------------------------------------------------------------------
1465
;> edi = pointer to WDATA
1585
;> edi = pointer to WDATA
1466
;------------------------------------------------------------------------------
1586
;------------------------------------------------------------------------------
1467
        mov     al, [edi + WDATA.fl_wstyle]
1587
        mov     al, [edi + WDATA.fl_wstyle]
1468
        and     al, 0x0f
1588
        and     al, 0x0f
Line 1730... Line 1850...
1730
;------------------------------------------------------------------------------
1850
;------------------------------------------------------------------------------
1731
;> edi = pointer to WDATA
1851
;> edi = pointer to WDATA
1732
;------------------------------------------------------------------------------
1852
;------------------------------------------------------------------------------
1733
        mov     cl, [edi + WDATA.fl_wstyle]
1853
        mov     cl, [edi + WDATA.fl_wstyle]
1734
        and     cl, 0x0f
1854
        and     cl, 0x0f
1735
        cmp     cl, 0x03
1855
        cmp     cl, 3
1736
        je      .exit.redraw      ; window type 3
1856
        je      .exit.redraw      ; window type 3
1737
        cmp     cl, 0x04
1857
        cmp     cl, 4
1738
        je      .exit.redraw      ; window type 4
1858
        je      .exit.redraw      ; window type 4
Line 1739... Line 1859...
1739
 
1859
 
Line 1740... Line 1860...
1740
        push    eax ebx edx esi
1860
        push    eax ebx edx esi
1741
 
1861
 
1742
        mov     eax, edi
1862
        mov     eax, edi
Line 1743... Line -...
1743
        sub     eax, window_data
-
 
1744
        shr     eax, 5
-
 
1745
 
1863
        sub     eax, window_data
1746
        ; esi = process number
1864
        shr     eax, 5
Line 1747... Line 1865...
1747
 
1865
 
1748
        movzx   eax, word[WIN_STACK + eax * 2]  ; get value of the curr process
1866
        movzx   eax, word[WIN_STACK + eax * 2]  ; get value of the curr process
Line 1796... Line 1914...
1796
        xor     ecx, ecx
1914
        xor     ecx, ecx
1797
        ret
1915
        ret
Line 1798... Line 1916...
1798
 
1916
 
1799
align 4
1917
align 4
1800
;------------------------------------------------------------------------------
1918
;------------------------------------------------------------------------------
1801
window._.draw_window_frames: ;/////////////////////////////////////////////////
-
 
1802
;------------------------------------------------------------------------------
-
 
1803
;? Draw negative window frames
1919
window._.draw_window_caption: ;////////////////////////////////////////////////
1804
;------------------------------------------------------------------------------
1920
;------------------------------------------------------------------------------
1805
;> edi = pointer to WDATA
1921
;? 
1806
;------------------------------------------------------------------------------
1922
;------------------------------------------------------------------------------
1807
        push    eax
1923
        inc     [mouse_pause]
Line -... Line 1924...
-
 
1924
        call    [_display.disable_mouse]
-
 
1925
 
1808
        cli
1926
        xor     eax, eax
-
 
1927
        mov     edx, [TASK_COUNT]
-
 
1928
        movzx   edx, word[WIN_POS + edx * 2]
1809
 
1929
        cmp     edx, [CURRENT_TASK]
-
 
1930
        jne     @f
-
 
1931
        inc     eax
1810
        test    [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
1932
    @@: mov     edx, [CURRENT_TASK]
1811
        jnz     .exit
1933
        shl     edx, 5
-
 
1934
        add     edx, window_data
1812
        mov     eax, [new_window_pos.left]
1935
        movzx   ebx, [edx + WDATA.fl_wstyle]
1813
        cmp     eax, [edi + WDATA.box.left]
1936
        and     bl, 0x0F
-
 
1937
        cmp     bl, 3
1814
        jnz     .draw
1938
        je      .draw_caption_style_3
-
 
1939
        cmp     bl, 4
-
 
1940
        je      .draw_caption_style_3
-
 
1941
 
-
 
1942
        jmp     .not_style_3
1815
        mov     eax, [new_window_pos.width]
1943
 
1816
        cmp     eax, [edi + WDATA.box.width]
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
1817
        jnz     .draw
1952
        jne     .not_style_2
-
 
1953
 
-
 
1954
        call    drawwindow_III_caption
-
 
1955
        jmp     .2
-
 
1956
 
1818
        mov     eax, [new_window_pos.top]
1957
  .not_style_2:
-
 
1958
        cmp     bl, 0
1819
        cmp     eax, [edi + WDATA.box.top]
1959
        jne     .2
-
 
1960
 
-
 
1961
        call    drawwindow_I_caption
-
 
1962
 
-
 
1963
  .2:   mov     edi, [CURRENT_TASK]
-
 
1964
        shl     edi, 5
1820
        jnz     .draw
1965
        test    [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
-
 
1966
        jz      .exit
1821
        mov     eax, [new_window_pos.height]
1967
        mov     edx, [edi * 8 + SLOT_BASE + APPDATA.wnd_caption]
-
 
1968
        or      edx, edx
1822
        cmp     eax, [edi + WDATA.box.height]
1969
        jz      .exit
-
 
1970
 
-
 
1971
        movzx   eax, [edi + window_data + WDATA.fl_wstyle]
-
 
1972
        and     al, 0x0F
-
 
1973
        cmp     al, 3
-
 
1974
        je      .skinned
1823
        jnz     .draw
1975
        cmp     al, 4
-
 
1976
        je      .skinned
-
 
1977
 
1824
        xor     [edi + WDATA.fl_wdrawn], 2
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]
1825
 
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
1826
  .draw:
1994
 
1827
        push    ebx esi
1995
        mov     esi, eax
1828
        mov     eax, [new_window_pos.left - 2]
1996
        mov     ebx, dword[_skinmargins.left - 2]
1829
        mov     ax, word[new_window_pos.left]
1997
        mov     bx, word[_skinh]
-
 
1998
        sub     bx, [_skinmargins.bottom]
-
 
1999
        sub     bx, [_skinmargins.top]
1830
        add     ax, word[new_window_pos.width]
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
1831
        mov     ebx, [new_window_pos.top - 2]
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
1832
        mov     bx, word[new_window_pos.top]
2023
 
-
 
2024
        mov     esi, eax
-
 
2025
        mov     ebx, 0x00080007
-
 
2026
        add     ebx, ebp
-
 
2027
 
1833
        add     bx, word[new_window_pos.height]
2028
  .dodraw:
1834
        mov     esi, 0x01000000
2029
        mov     ecx, [common_colours + 16]
-
 
2030
        or      ecx, 0x80000000
Line 1835... Line 2031...
1835
        call    draw_rectangle.forced
2031
        xor     edi, edi
1836
        pop     esi ebx
2032
        call    dtext_asciiz_esi
1837
 
2033
 
1838
  .exit:
2034
  .exit:
Line 1839... Line 2035...
1839
        sti
2035
        dec     [mouse_pause]
-
 
2036
        call    [draw_pointer]
-
 
2037
        ret
-
 
2038
 
-
 
2039
align 4
-
 
2040
;------------------------------------------------------------------------------
-
 
2041
window._.draw_negative_box: ;//////////////////////////////////////////////////
-
 
2042
;------------------------------------------------------------------------------
1840
        pop     eax
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]
1841
        ret
2050
        add     ax, word[edi + BOX.width]
-
 
2051
        mov     ebx, [edi + BOX.top - 2]
1842
 
2052
        mov     bx, word[edi + BOX.top]
-
 
2053
        add     bx, word[edi + BOX.height]