Subversion Repositories Kolibri OS

Rev

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

Rev 1376 Rev 2382
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: 1376 $
-
 
Line 10... Line 9...
10
 
9
$Revision: 2382 $
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
    @@:
-
 
60
        dec     al
-
 
61
        jnz     @f
-
 
62
 
-
 
63
        ; type II - only reserve area, no draw
-
 
64
        call    sys_window_mouse
-
 
65
        dec     [mouse_pause]
-
 
66
        call    [draw_pointer]
-
 
67
        jmp     .exit
-
 
68
 
-
 
69
    @@:
-
 
70
        dec     al
-
 
71
        jnz     @f
-
 
72
 
-
 
73
        ; type III  - new style
-
 
74
        call    drawwindow_III
-
 
75
        jmp     window._.draw_window_caption.2
-
 
76
 
-
 
77
        ; type IV & V - skinned window (resizable & not)
-
 
78
    @@:
-
 
79
        mov     eax, [TASK_COUNT]
-
 
80
        movzx   eax, word[WIN_POS + eax * 2]
-
 
81
        cmp     eax, [CURRENT_TASK]
-
 
82
        setz    al
-
 
83
        movzx   eax, al
-
 
84
        push    eax
-
 
85
        call    drawwindow_IV
-
 
86
        jmp     window._.draw_window_caption.2
-
 
87
 
43
  reposition                db ?
88
  .exit:
44
endg
89
        ret
45
 
90
 
46
align 4
91
align 4
47
;------------------------------------------------------------------------------
92
;------------------------------------------------------------------------------
Line 89... Line 134...
89
;> eax = FS error code
134
;> eax = FS error code
90
;------------------------------------------------------------------------------
135
;------------------------------------------------------------------------------
91
        cmp     ebx, .sizeof.ftable / 4
136
        cmp     ebx, .sizeof.ftable / 4
92
        ja      @f
137
        ja      @f
93
        jmp     [.ftable + ebx * 4]
138
        jmp     [.ftable + ebx * 4]
-
 
139
    @@:
94
    @@: ret
140
        ret
Line 95... Line 141...
95
 
141
 
96
 
142
 
97
align 4
143
align 4
Line 166... Line 212...
166
        jge     .check_horizontal
212
        jge     .check_horizontal
167
        inc     esi
213
        inc     esi
168
        or      eax, eax
214
        or      eax, eax
169
        jge     @f
215
        jge     @f
170
        xor     eax, eax
216
        xor     eax, eax
-
 
217
    @@:
171
    @@: mov     [screen_workarea.left], eax
218
        mov     [screen_workarea.left], eax
172
        cmp     ebx, edi
219
        cmp     ebx, edi
173
        jle     @f
220
        jle     @f
174
        mov     ebx, edi
221
        mov     ebx, edi
-
 
222
    @@:
175
    @@: mov     [screen_workarea.right], ebx
223
        mov     [screen_workarea.right], ebx
Line 176... Line 224...
176
 
224
 
177
  .check_horizontal:
225
  .check_horizontal:
178
        mov     edi, [Screen_Max_Y]
226
        mov     edi, [Screen_Max_Y]
179
        mov     eax, edx
227
        mov     eax, edx
Line 183... Line 231...
183
        jge     .check_if_redraw_needed
231
        jge     .check_if_redraw_needed
184
        inc     esi
232
        inc     esi
185
        or      eax, eax
233
        or      eax, eax
186
        jge     @f
234
        jge     @f
187
        xor     eax, eax
235
        xor     eax, eax
-
 
236
    @@:
188
    @@: mov     [screen_workarea.top], eax
237
        mov     [screen_workarea.top], eax
189
        cmp     ebx, edi
238
        cmp     ebx, edi
190
        jle     @f
239
        jle     @f
191
        mov     ebx, edi
240
        mov     ebx, edi
-
 
241
    @@:
192
    @@: mov     [screen_workarea.bottom], ebx
242
        mov     [screen_workarea.bottom], ebx
Line 193... Line 243...
193
 
243
 
194
  .check_if_redraw_needed:
244
  .check_if_redraw_needed:
195
        or      esi, esi
245
        or      esi, esi
Line 267... Line 317...
267
  .exit:
317
  .exit:
268
        ret
318
        ret
Line 269... Line 319...
269
 
319
 
270
align 4
320
align 4
-
 
321
;------------------------------------------------------------------------------
-
 
322
syscall_move_window: ;///// system function 67 ////////////////////////////////
-
 
323
;------------------------------------------------------------------------------
-
 
324
;? 
-
 
325
;------------------------------------------------------------------------------
-
 
326
        mov     edi, [CURRENT_TASK]
-
 
327
        shl     edi, 5
-
 
328
        add     edi, window_data
-
 
329
 
-
 
330
        test    [edi + WDATA.fl_wdrawn], 1
-
 
331
        jz      .exit
-
 
332
 
-
 
333
        test    [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
-
 
334
        jnz     .exit
-
 
335
 
-
 
336
        cmp     ebx, -1
-
 
337
        jne     @f
-
 
338
        mov     ebx, [edi + WDATA.box.left]
-
 
339
    @@:
-
 
340
        cmp     ecx, -1
-
 
341
        jne     @f
-
 
342
        mov     ecx, [edi + WDATA.box.top]
-
 
343
    @@:
-
 
344
        cmp     edx, -1
-
 
345
        jne     @f
-
 
346
        mov     edx, [edi + WDATA.box.width]
-
 
347
    @@:
-
 
348
        cmp     esi, -1
-
 
349
        jne     @f
-
 
350
        mov     esi, [edi + WDATA.box.height]
-
 
351
 
-
 
352
    @@:
-
 
353
        push    esi edx ecx ebx
-
 
354
        mov     eax, esp
-
 
355
        mov     bl, [edi + WDATA.fl_wstate]
-
 
356
        call    window._.set_window_box
-
 
357
        add     esp, sizeof.BOX
-
 
358
 
-
 
359
        ; NOTE: do we really need this? to be reworked
-
 
360
;       mov     byte[DONT_DRAW_MOUSE], 0 ; mouse pointer
-
 
361
;       mov     byte[MOUSE_BACKGROUND], 0 ; no mouse under
-
 
362
;       mov     byte[MOUSE_DOWN], 0 ; react to mouse up/down
-
 
363
 
-
 
364
        ; NOTE: do we really need this? to be reworked
-
 
365
;       call    [draw_pointer]
-
 
366
 
-
 
367
  .exit:
-
 
368
        ret
-
 
369
 
-
 
370
align 4
-
 
371
;------------------------------------------------------------------------------
-
 
372
syscall_window_settings: ;///// system function 71 /////////////////////////////
-
 
373
;------------------------------------------------------------------------------
-
 
374
;? 
-
 
375
;------------------------------------------------------------------------------
-
 
376
        dec     ebx     ; subfunction #1 - set window caption
-
 
377
        jnz     .exit_fail
-
 
378
 
-
 
379
        ; NOTE: only window owner thread can set its caption,
-
 
380
        ;       so there's no parameter for PID/TID
-
 
381
 
-
 
382
        mov     edi, [CURRENT_TASK]
-
 
383
        shl     edi, 5
-
 
384
 
-
 
385
        mov     [edi * 8 + SLOT_BASE + APPDATA.wnd_caption], ecx
-
 
386
        or      [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
-
 
387
 
-
 
388
        call    window._.draw_window_caption
-
 
389
 
-
 
390
        xor     eax, eax ; eax = 0 (success)
-
 
391
        ret
-
 
392
 
-
 
393
;  .get_window_caption:
-
 
394
;        dec     eax     ; subfunction #2 - get window caption
-
 
395
;        jnz     .exit_fail
-
 
396
 
-
 
397
        ; not implemented yet
-
 
398
 
-
 
399
  .exit_fail:
-
 
400
        xor     eax, eax
-
 
401
        inc     eax     ; eax = 1 (fail)
-
 
402
        ret
-
 
403
 
-
 
404
align 4
271
;------------------------------------------------------------------------------
405
;------------------------------------------------------------------------------
272
set_window_defaults: ;/////////////////////////////////////////////////////////
406
set_window_defaults: ;/////////////////////////////////////////////////////////
273
;------------------------------------------------------------------------------
407
;------------------------------------------------------------------------------
274
;? 
408
;? 
-
 
409
;------------------------------------------------------------------------------
275
;------------------------------------------------------------------------------
410
        mov     byte [window_data + 0x20 + WDATA.cl_titlebar + 3], 1 ; desktop is not movable
276
        push    eax ecx
411
        push    eax ecx
277
        xor     eax, eax
412
        xor     eax, eax
-
 
413
        mov     ecx, WIN_STACK
278
        mov     ecx, WIN_STACK
414
    @@:
279
    @@: inc     eax
415
        inc     eax
280
        add     ecx, 2
416
        add     ecx, 2
281
        ; process no
417
        ; process no
282
        mov     [ecx + 0x000], ax
418
        mov     [ecx + 0x000], ax
283
        ; positions in stack
419
        ; positions in stack
Line 341... Line 477...
341
        jl      .skip_window
477
        jl      .skip_window
Line 342... Line 478...
342
 
478
 
343
        cmp     eax, [esp + RECT.left]
479
        cmp     eax, [esp + RECT.left]
344
        jae     @f
480
        jae     @f
-
 
481
        mov     eax, [esp + RECT.left]
345
        mov     eax, [esp + RECT.left]
482
    @@:
346
    @@: cmp     ebx, [esp + RECT.top]
483
        cmp     ebx, [esp + RECT.top]
347
        jae     @f
484
        jae     @f
-
 
485
        mov     ebx, [esp + RECT.top]
348
        mov     ebx, [esp + RECT.top]
486
    @@:
349
    @@: cmp     ecx, [esp + RECT.right]
487
        cmp     ecx, [esp + RECT.right]
350
        jbe     @f
488
        jbe     @f
-
 
489
        mov     ecx, [esp + RECT.right]
351
        mov     ecx, [esp + RECT.right]
490
    @@:
352
    @@: cmp     edx, [esp + RECT.bottom]
491
        cmp     edx, [esp + RECT.bottom]
353
        jbe     @f
492
        jbe     @f
Line -... Line 493...
-
 
493
        mov     edx, [esp + RECT.bottom]
354
        mov     edx, [esp + RECT.bottom]
494
 
355
 
495
    @@:
356
    @@: push    esi
496
        push    esi
357
        movzx   esi, word[WIN_POS + esi * 2]
497
        movzx   esi, word[WIN_POS + esi * 2]
Line 358... Line 498...
358
        call    window._.set_screen
498
        call    window._.set_screen
Line 376... Line 516...
376
repos_windows: ;///////////////////////////////////////////////////////////////
516
repos_windows: ;///////////////////////////////////////////////////////////////
377
;------------------------------------------------------------------------------
517
;------------------------------------------------------------------------------
378
;? 
518
;? 
379
;------------------------------------------------------------------------------
519
;------------------------------------------------------------------------------
380
        mov     ecx, [TASK_COUNT]
520
        mov     ecx, [TASK_COUNT]
381
        mov     edi, window_data + WDATA.sizeof * 2
521
        mov     edi, window_data + sizeof.WDATA * 2
382
        call    force_redraw_background
522
        call    force_redraw_background
383
        dec     ecx
523
        dec     ecx
384
        jle     .exit
524
        jle     .exit
Line 385... Line 525...
385
 
525
 
Line 395... Line 535...
395
        jle     .fix_vertical
535
        jle     .fix_vertical
396
        mov     eax, [edi + WDATA.box.width]
536
        mov     eax, [edi + WDATA.box.width]
397
        sub     eax, ebx
537
        sub     eax, ebx
398
        jle     @f
538
        jle     @f
399
        mov     [edi + WDATA.box.width], ebx
539
        mov     [edi + WDATA.box.width], ebx
-
 
540
    @@:
400
    @@: sub     ebx, [edi + WDATA.box.width]
541
        sub     ebx, [edi + WDATA.box.width]
401
        mov     [edi + WDATA.box.left], ebx
542
        mov     [edi + WDATA.box.left], ebx
Line 402... Line 543...
402
 
543
 
403
  .fix_vertical:
544
  .fix_vertical:
404
        mov     eax, [edi + WDATA.box.top]
545
        mov     eax, [edi + WDATA.box.top]
Line 408... Line 549...
408
        jle     .fix_client_box
549
        jle     .fix_client_box
409
        mov     eax, [edi + WDATA.box.height]
550
        mov     eax, [edi + WDATA.box.height]
410
        sub     eax, ebx
551
        sub     eax, ebx
411
        jle     @f
552
        jle     @f
412
        mov     [edi + WDATA.box.height], ebx
553
        mov     [edi + WDATA.box.height], ebx
-
 
554
    @@:
413
    @@: sub     ebx, [edi + WDATA.box.height]
555
        sub     ebx, [edi + WDATA.box.height]
414
        mov     [edi + WDATA.box.top], ebx
556
        mov     [edi + WDATA.box.top], ebx
415
        jmp     .fix_client_box
557
        jmp     .fix_client_box
Line 416... Line 558...
416
 
558
 
417
  .fix_maximized:
559
  .fix_maximized:
Line 427... Line 569...
427
        sub     eax, [screen_workarea.bottom]
569
        sub     eax, [screen_workarea.bottom]
428
        neg     eax
570
        neg     eax
429
        mov     [edi + WDATA.box.height], eax
571
        mov     [edi + WDATA.box.height], eax
Line 430... Line 572...
430
 
572
 
431
  .fix_client_box:
573
  .fix_client_box:
Line 432... Line 574...
432
        call    set_window_clientbox
574
        call    window._.set_window_clientbox
433
 
575
 
Line 434... Line 576...
434
        add     edi, WDATA.sizeof
576
        add     edi, sizeof.WDATA
435
        loop    .next_window
577
        loop    .next_window
Line 436... Line 578...
436
 
578
 
437
  .exit:
579
  .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
580
        ret
513
 
581
 
514
align 4
582
align 4
515
;------------------------------------------------------------------------------
583
;------------------------------------------------------------------------------
-
 
584
sys_window_mouse: ;////////////////////////////////////////////////////////////
-
 
585
;------------------------------------------------------------------------------
516
sys_window_mouse: ;////////////////////////////////////////////////////////////
586
;? 
517
;------------------------------------------------------------------------------
587
;------------------------------------------------------------------------------
518
;? 
588
        ; NOTE: commented out since doesn't provide necessary functionality
519
;------------------------------------------------------------------------------
589
        ;       anyway, to be reworked
520
        push    eax
590
;       push    eax
521
 
591
;
522
        mov     eax, [timer_ticks]
592
;       mov     eax, [timer_ticks]
523
        cmp     [new_window_starting], eax
593
;       cmp     [new_window_starting], eax
524
        jb      .exit
594
;       jb      .exit
525
 
595
;
526
        mov     byte[MOUSE_BACKGROUND], 0
596
;       mov     byte[MOUSE_BACKGROUND], 0
527
        mov     byte[DONT_DRAW_MOUSE], 0
597
;       mov     byte[DONT_DRAW_MOUSE], 0
528
 
598
;
529
        mov     [new_window_starting], eax
599
;       mov     [new_window_starting], eax
Line 530... Line 600...
530
 
600
;
531
  .exit:
601
; .exit:
532
        pop     eax
602
;       pop     eax
Line 602... Line 672...
602
        add     eax, [esi + WDATA.box.height]
672
        add     eax, [esi + WDATA.box.height]
Line 603... Line 673...
603
 
673
 
604
        cmp     ebx, eax
674
        cmp     ebx, eax
605
        jbe     @f
675
        jbe     @f
-
 
676
        mov     ebx, eax
606
        mov     ebx, eax
677
    @@:
Line 607... Line 678...
607
    @@: push    ebx
678
        push    ebx
Line 608... Line 679...
608
 
679
 
609
        xor     edi, edi
680
        xor     edi, edi
Line 621... Line 692...
621
        mov     ecx, [esi + WDATA.cl_titlebar]
692
        mov     ecx, [esi + WDATA.cl_titlebar]
622
        test    ecx, 0x80000000
693
        test    ecx, 0x80000000
623
        jz      @f
694
        jz      @f
624
        sub     ecx, 0x00040404
695
        sub     ecx, 0x00040404
625
        mov     [esi + WDATA.cl_titlebar], ecx
696
        mov     [esi + WDATA.cl_titlebar], ecx
-
 
697
    @@:
626
    @@: and     ecx, 0x00ffffff
698
        and     ecx, 0x00ffffff
627
        call    [draw_line]
699
        call    [draw_line]
628
        inc     edx
700
        inc     edx
629
        cmp     edx, [esp]
701
        cmp     edx, [esp]
630
        jb      .next_line
702
        jb      .next_line
Line 700... Line 772...
700
        add     eax, [esi + WDATA.box.height]
772
        add     eax, [esi + WDATA.box.height]
Line 701... Line 773...
701
 
773
 
702
        cmp     ebx, eax
774
        cmp     ebx, eax
703
        jb      @f
775
        jb      @f
-
 
776
        mov     ebx, eax
704
        mov     ebx, eax
777
    @@:
Line 705... Line 778...
705
    @@: push    ebx
778
        push    ebx
Line 706... Line 779...
706
 
779
 
707
        xor     edi, edi
780
        xor     edi, edi
Line 717... Line 790...
717
        add     eax, 4 * 65536 - 4
790
        add     eax, 4 * 65536 - 4
718
        mov     ecx, [esi + WDATA.cl_titlebar]
791
        mov     ecx, [esi + WDATA.cl_titlebar]
719
        test    ecx, 0x40000000
792
        test    ecx, 0x40000000
720
        jz      @f
793
        jz      @f
721
        add     ecx, 0x00040404
794
        add     ecx, 0x00040404
-
 
795
    @@:
722
    @@: test    ecx, 0x80000000
796
        test    ecx, 0x80000000
723
        jz      @f
797
        jz      @f
724
        sub     ecx, 0x00040404
798
        sub     ecx, 0x00040404
-
 
799
    @@:
725
    @@: mov     [esi + WDATA.cl_titlebar], ecx
800
        mov     [esi + WDATA.cl_titlebar], ecx
726
        and     ecx, 0x00ffffff
801
        and     ecx, 0x00ffffff
727
        call    [draw_line]
802
        call    [draw_line]
728
        inc     edx
803
        inc     edx
729
        cmp     edx, [esp]
804
        cmp     edx, [esp]
730
        jb      .next_line
805
        jb      .next_line
Line 807... Line 882...
807
;------------------------------------------------------------------------------
882
;------------------------------------------------------------------------------
808
waredraw: ;////////////////////////////////////////////////////////////////////
883
waredraw: ;////////////////////////////////////////////////////////////////////
809
;------------------------------------------------------------------------------
884
;------------------------------------------------------------------------------
810
;? Activate window, redrawing if necessary
885
;? Activate window, redrawing if necessary
811
;------------------------------------------------------------------------------
886
;------------------------------------------------------------------------------
-
 
887
        push    -1
-
 
888
        mov     eax, [TASK_COUNT]
-
 
889
        lea     eax, [WIN_POS + eax * 2]
-
 
890
        cmp     eax, esi
-
 
891
        pop     eax
-
 
892
        je      .exit
-
 
893
 
812
        ; is it overlapped by another window now?
894
        ; is it overlapped by another window now?
813
        push    ecx
895
        push    ecx
814
        call    window._.check_window_draw
896
        call    window._.check_window_draw
815
        test    ecx, ecx
897
        test    ecx, ecx
816
        pop     ecx
898
        pop     ecx
Line 839... Line 921...
839
        call    window._.set_screen
921
        call    window._.set_screen
840
        popad
922
        popad
Line 841... Line 923...
841
 
923
 
842
        ; tell application to redraw itself
924
        ; tell application to redraw itself
843
        mov     [edi + WDATA.fl_redraw], 1
925
        mov     [edi + WDATA.fl_redraw], 1
844
        mov     byte[MOUSE_DOWN], 0
926
        xor     eax, eax
Line 845... Line 927...
845
        ret
927
        jmp     .exit
846
 
928
 
847
  .do_not_draw:
929
  .do_not_draw:
-
 
930
        ; no it's not, just activate the window
-
 
931
        call    window._.window_activate
-
 
932
        xor     eax, eax
-
 
933
        mov     byte[MOUSE_BACKGROUND], al
-
 
934
        mov     byte[DONT_DRAW_MOUSE], al
-
 
935
 
848
        ; no it's not, just activate the window
936
 
849
        call    window._.window_activate
-
 
850
        mov     byte[MOUSE_DOWN], 0
937
  .exit:
851
        mov     byte[MOUSE_BACKGROUND], 0
938
        mov     byte[MOUSE_DOWN], 0
Line 852... Line 939...
852
        mov     byte[DONT_DRAW_MOUSE], 0
939
        inc     eax
853
        ret
940
        ret
854
 
941
 
Line 922... Line 1009...
922
        and     [edi + WDATA.fl_wstate], not WSTATE_MINIMIZED
1009
        and     [edi + WDATA.fl_wstate], not WSTATE_MINIMIZED
923
        mov     ebp, window._.set_screen
1010
        mov     ebp, window._.set_screen
924
        cmp     eax, [TASK_COUNT]
1011
        cmp     eax, [TASK_COUNT]
925
        jz      @f
1012
        jz      @f
926
        mov     ebp, calculatescreen
1013
        mov     ebp, calculatescreen
-
 
1014
    @@:
927
    @@: mov     eax, [edi + WDATA.box.left]
1015
        mov     eax, [edi + WDATA.box.left]
928
        mov     ebx, [edi + WDATA.box.top]
1016
        mov     ebx, [edi + WDATA.box.top]
929
        mov     ecx, [edi + WDATA.box.width]
1017
        mov     ecx, [edi + WDATA.box.width]
930
        mov     edx, [edi + WDATA.box.height]
1018
        mov     edx, [edi + WDATA.box.height]
931
        add     ecx, eax
1019
        add     ecx, eax
932
        add     edx, ebx
1020
        add     edx, ebx
Line 938... Line 1026...
938
        popfd
1026
        popfd
939
        popad
1027
        popad
940
        ret
1028
        ret
Line 941... Line 1029...
941
 
1029
 
-
 
1030
align 4
942
align 4
1031
; TODO: remove this proc
943
;------------------------------------------------------------------------------
1032
;------------------------------------------------------------------------------
944
checkwindows: ;////////////////////////////////////////////////////////////////
1033
window_check_events: ;/////////////////////////////////////////////////////////
945
;------------------------------------------------------------------------------
1034
;------------------------------------------------------------------------------
946
;? Check for user-initiated window operations
1035
;? 
947
;------------------------------------------------------------------------------
-
 
948
        pushad
-
 
949
 
1036
;------------------------------------------------------------------------------
950
        ; do we have window minimize/restore request?
1037
        ; do we have window minimize/restore request?
951
        cmp     [window_minimize], 0
1038
        cmp     [window_minimize], 0
Line 952... Line 1039...
952
        je      .check_for_mouse_buttons_state
1039
        je      .exit
953
 
1040
 
954
        ; okay, minimize or restore top-most window and exit
1041
        ; okay, minimize or restore top-most window and exit
955
        mov     eax, [TASK_COUNT]
1042
        mov     eax, [TASK_COUNT]
956
        mov     bl, 0
1043
        mov     bl, 0
957
        xchg    [window_minimize], bl
1044
        xchg    [window_minimize], bl
958
        dec     bl
1045
        dec     bl
959
        jnz     @f
-
 
960
        call    minimize_window
-
 
961
        jmp     .check_for_mouse_buttons_state
-
 
962
    @@: call    restore_minimized_window
-
 
963
 
-
 
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
 
1046
        jnz     @f
Line 969... Line -...
969
        mov     [bPressedMouseXY_W], 0
-
 
970
        jmp     .exit
-
 
971
 
-
 
972
  .mouse_buttons_pressed:
1047
        call    minimize_window
973
        ; yes we do, iterate and ...
-
 
974
        mov     esi, [TASK_COUNT]
-
 
975
        inc     esi
1048
        jmp     .exit
976
 
-
 
977
        cmp     [bPressedMouseXY_W], 1
-
 
978
        ja      .next_window
-
 
979
        inc     [bPressedMouseXY_W]
-
 
Line 980... Line 1049...
980
        jnc     .next_window
1049
 
981
        push    dword[MOUSE_X]
-
 
982
        pop     dword[mx]
-
 
983
 
-
 
984
  .next_window:
1050
    @@:
Line -... Line 1051...
-
 
1051
        call    restore_minimized_window
-
 
1052
 
-
 
1053
  .exit:
-
 
1054
        ret
-
 
1055
 
-
 
1056
align 4
985
        cmp     esi, 2
1057
;------------------------------------------------------------------------------
-
 
1058
sys_window_maximize_handler: ;/////////////////////////////////////////////////
986
        jb      .exit
1059
;------------------------------------------------------------------------------
987
 
1060
;? 
988
        dec     esi
1061
;------------------------------------------------------------------------------
989
 
-
 
990
        ; is that window not minimized?
-
 
Line -... Line 1062...
-
 
1062
;> esi = process slot
-
 
1063
;------------------------------------------------------------------------------
-
 
1064
        mov     edi, esi
991
        movzx   edi, word[WIN_POS + esi * 2]
1065
        shl     edi, 5
992
        shl     edi, 5
1066
        add     edi, window_data
Line 993... Line 1067...
993
        add     edi, window_data
1067
 
994
        test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
1068
        ; can window change its height?
995
        jnz     .next_window
1069
        ; only types 2 and 3 can be resized
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
-
 
Line 1006... Line 1070...
1006
        jl      .next_window
1070
        mov     dl, [edi + WDATA.fl_wstyle]
1007
        add     ecx, [edi + WDATA.box.width]
1071
        test    dl, 2
1008
        add     edx, [edi + WDATA.box.height]
-
 
1009
        cmp     eax, ecx
-
 
1010
        jge     .next_window
-
 
1011
        cmp     ebx, edx
-
 
1012
        jge     .next_window
-
 
1013
 
1072
        jz      .exit
Line 1014... Line 1073...
1014
        ; is that a top-most (which means active) window?
1073
 
1015
        cmp     esi, [TASK_COUNT]
1074
        ; toggle normal/maximized window state
-
 
1075
        mov     bl, [edi + WDATA.fl_wstate]
-
 
1076
        xor     bl, WSTATE_MAXIMIZED
-
 
1077
 
-
 
1078
        ; calculate and set appropriate window bounds
-
 
1079
        test    bl, WSTATE_MAXIMIZED
-
 
1080
        jz      .restore_size
1016
        je      .check_for_moving_or_resizing
1081
 
1017
 
1082
        mov     eax, [screen_workarea.left]
Line 1018... Line 1083...
1018
        ; no it's not, did we just press mouse button down above it or was it
1083
        mov     ecx, [screen_workarea.top]
-
 
1084
        push    [screen_workarea.bottom] \
1019
        ; already pressed before?
1085
                [screen_workarea.right] \
-
 
1086
                ecx \
1020
        cmp     [bPressedMouseXY_W], 1
1087
                eax
-
 
1088
        sub     [esp + BOX.width], eax
-
 
1089
        sub     [esp + BOX.height], ecx
-
 
1090
        mov     eax, esp
1021
        ja      .exit
1091
        jmp     .set_box
Line 1022... Line 1092...
1022
 
1092
 
1023
        ; okay, we just pressed the button, activate this window and exit
1093
  .restore_size:
1024
        lea     esi, [WIN_POS + esi * 2]
1094
        mov     eax, esi
Line 1025... Line -...
1025
        call    waredraw
-
 
1026
        jmp     .exit
-
 
1027
 
-
 
1028
  .check_for_moving_or_resizing:
-
 
1029
        ; is that window movable?
1095
        shl     eax, 8
1030
        test    byte[edi + WDATA.cl_titlebar + 3], 0x01
1096
        add     eax, SLOT_BASE + APPDATA.saved_box
1031
        jnz     .exit
-
 
1032
 
1097
        push    [eax + BOX.height] \
1033
        ; yes it is, is it rolled up?
1098
                [eax + BOX.width] \
1034
        test    [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
-
 
Line 1035... Line -...
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
1099
                [eax + BOX.top] \
1039
        mov     dl, [edi + WDATA.fl_wstyle]
-
 
1040
        and     dl, 0x0f
1100
                [eax + BOX.left]
1041
        cmp     dl, 0x00
-
 
1042
        je      .check_for_cursor_on_caption
-
 
1043
        cmp     dl, 0x01
-
 
1044
        je      .check_for_cursor_on_caption
1101
        mov     eax, esp
Line 1045... Line -...
1045
        cmp     dl, 0x04
-
 
1046
        je      .check_for_cursor_on_caption
-
 
1047
 
1102
 
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
1103
  .set_box:
1052
        cmp     ebx, edx
-
 
Line -... Line 1104...
-
 
1104
        test    bl, WSTATE_ROLLEDUP
-
 
1105
        jz      @f
1053
        jl      .check_for_cursor_on_caption
1106
 
1054
 
1107
        xchg    eax, ecx
1055
        ; yes we do, remember that
1108
        call    window._.get_rolledup_height
1056
        mov     [do_resize_from_corner], 1
1109
        mov     [ecx + BOX.height], eax
1057
        jmp     .set_move_resize_flag
1110
        xchg    eax, ecx
1058
 
1111
 
1059
  .check_for_cursor_on_caption:
-
 
1060
        ; is the cursor inside window titlebar?
1112
    @@:
1061
        push    eax
1113
        call    window._.set_window_box
1062
        call    window._.get_titlebar_height
1114
        add     esp, sizeof.BOX
Line -... Line 1115...
-
 
1115
 
1063
        add     eax, [edi + WDATA.box.top]
1116
  .exit:
1064
        cmp     ebx, eax
1117
        ret
Line 1065... Line -...
1065
        pop     eax
-
 
1066
        jge     .exit
-
 
1067
 
-
 
1068
        ; calculate duration between two clicks
1118
 
1069
        mov     ecx, [timer_ticks]
1119
align 4
1070
        mov     edx, ecx
-
 
1071
        sub     edx, [latest_window_touch]
-
 
1072
        mov     [latest_window_touch], ecx
1120
;------------------------------------------------------------------------------
Line 1073... Line 1121...
1073
        mov     [latest_window_touch_delta], edx
1121
sys_window_rollup_handler: ;///////////////////////////////////////////////////
1074
 
1122
;------------------------------------------------------------------------------
-
 
1123
;? 
-
 
1124
;------------------------------------------------------------------------------
-
 
1125
;> esi = process slot
1075
  .set_move_resize_flag:
1126
;------------------------------------------------------------------------------
-
 
1127
        mov     edx, esi
Line -... Line 1128...
-
 
1128
        shl     edx, 8
1076
        mov     cl, [BTN_DOWN]
1129
        add     edx, SLOT_BASE
-
 
1130
 
1077
        mov     [do_resize], cl
1131
        ; toggle normal/rolled up window state
-
 
1132
        mov     bl, [edi + WDATA.fl_wstate]
-
 
1133
        xor     bl, WSTATE_ROLLEDUP
Line 1078... Line -...
1078
 
-
 
1079
        mov     ecx, [edi + WDATA.box.left]
1134
 
1080
        mov     edx, [edi + WDATA.box.top]
-
 
1081
 
-
 
1082
        push    ecx edx
-
 
1083
        mov     [draw_limits.left], ecx
1135
        ; calculate and set appropriate window bounds
1084
        mov     [draw_limits.top], edx
-
 
1085
        add     ecx, [edi + WDATA.box.width]
1136
        test    bl, WSTATE_ROLLEDUP
1086
        add     edx, [edi + WDATA.box.height]
1137
        jz      .restore_size
1087
        mov     [draw_limits.right], ecx
-
 
1088
        mov     [draw_limits.bottom], edx
1138
 
1089
        pop     edx ecx
1139
        call    window._.get_rolledup_height
1090
 
-
 
1091
        ; calculate window-relative cursor coordinates
1140
        push    eax \
1092
        sub     eax, ecx
1141
                [edi + WDATA.box.width] \
Line -... Line 1142...
-
 
1142
                [edi + WDATA.box.top] \
1093
        sub     ebx, edx
1143
                [edi + WDATA.box.left]
1094
 
1144
        mov     eax, esp
Line 1095... Line 1145...
1095
        push    dword[MOUSE_X]
1145
        jmp     .set_box
1096
        pop     dword[WIN_TEMP_XY]
-
 
Line -... Line 1146...
-
 
1146
 
-
 
1147
  .restore_size:
1097
 
1148
        test    bl, WSTATE_MAXIMIZED
-
 
1149
        jnz     @f
1098
        ; save old window coordinates
1150
        add     esp, -sizeof.BOX
1099
        push    eax
1151
        lea     eax, [edx + APPDATA.saved_box]
1100
        mov     eax, [edi + WDATA.box.left]
1152
        jmp     .set_box
1101
        mov     [old_window_pos.left], eax
1153
 
1102
        mov     [new_window_pos.left], eax
1154
    @@:
1103
        mov     eax, [edi + WDATA.box.top]
1155
        mov     eax, [screen_workarea.top]
1104
        mov     [old_window_pos.top], eax
-
 
1105
        mov     [new_window_pos.top], eax
1156
        push    [screen_workarea.bottom] \
1106
        mov     eax, [edi + WDATA.box.width]
-
 
Line 1107... Line -...
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
1157
                [edi + WDATA.box.width] \
1116
 
-
 
Line -... Line 1158...
-
 
1158
                eax \
-
 
1159
                [edi + WDATA.box.left]
-
 
1160
        sub     [esp + BOX.height], eax
-
 
1161
        mov     eax, esp
-
 
1162
 
-
 
1163
  .set_box:
-
 
1164
        call    window._.set_window_box
-
 
1165
        add     esp, sizeof.BOX
-
 
1166
 
-
 
1167
        ret
1117
        mov     [reposition], 0
1168
 
-
 
1169
align 4
Line 1118... Line 1170...
1118
        mov     byte[MOUSE_DOWN], 1
1170
;------------------------------------------------------------------------------
-
 
1171
sys_window_start_moving_handler: ;/////////////////////////////////////////////
1119
 
1172
;------------------------------------------------------------------------------
Line 1120... Line 1173...
1120
  .next_mouse_state_check:
1173
;? 
1121
        ; process OS events
1174
;------------------------------------------------------------------------------
1122
        mov     byte[DONT_DRAW_MOUSE], 1
1175
;> eax = old (original) window box
-
 
1176
;> esi = process slot
Line -... Line 1177...
-
 
1177
;------------------------------------------------------------------------------
-
 
1178
        mov     edi, eax
-
 
1179
        call    window._.draw_negative_box
-
 
1180
 
-
 
1181
        ret
-
 
1182
 
1123
        call    checkidle
1183
align 4
-
 
1184
;------------------------------------------------------------------------------
-
 
1185
sys_window_end_moving_handler: ;///////////////////////////////////////////////
-
 
1186
;------------------------------------------------------------------------------
1124
        call    checkVga_N13
1187
;? 
-
 
1188
;------------------------------------------------------------------------------
1125
        mov     byte[MOUSE_BACKGROUND], 0
1189
;> eax = old (original) window box
-
 
1190
;> ebx = new (final) window box
-
 
1191
;> esi = process slot
Line 1126... Line -...
1126
        call    [draw_pointer]
-
 
1127
        pushad
-
 
1128
        call    stack_handler
1192
;------------------------------------------------------------------------------
1129
        popad
-
 
1130
 
1193
        mov     edi, ebx
1131
        ; did cursor position change?
-
 
1132
        mov     esi, [WIN_TEMP_XY]
-
 
1133
        cmp     esi, [MOUSE_X]
1194
        call    window._.end_moving__box
1134
        je      .check_for_new_mouse_buttons_state
-
 
Line 1135... Line -...
1135
 
-
 
1136
        ; yes it did, calculate window-relative cursor coordinates
-
 
1137
        movzx   ecx, word[MOUSE_X]
1195
 
1138
        movzx   edx, word[MOUSE_Y]
1196
        mov     edi, esi
1139
        sub     ecx, eax
1197
        shl     edi, 5
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
-
 
Line -... Line 1198...
-
 
1198
        add     edi, window_data
1146
 
1199
 
-
 
1200
        mov     eax, ebx
1147
        ; are we moving it right now?
1201
        mov     bl, [edi + WDATA.fl_wstate]
-
 
1202
        call    window._.set_window_box
-
 
1203
        ret
-
 
1204
 
-
 
1205
align 4
Line -... Line 1206...
-
 
1206
;------------------------------------------------------------------------------
1148
        cmp     [do_resize_from_corner], 0
1207
sys_window_moving_handler: ;///////////////////////////////////////////////////
1149
        jne     .resize_window
1208
;------------------------------------------------------------------------------
1150
 
1209
;? 
-
 
1210
;------------------------------------------------------------------------------
Line -... Line 1211...
-
 
1211
;> eax = old (from previous call) window box
-
 
1212
;> ebx = new (current) window box
1151
        ; yes we do, check if it's inside the screen area
1213
;> esi = process_slot
1152
        mov     eax, [Screen_Max_X]
1214
;------------------------------------------------------------------------------
1153
        mov     ebx, [Screen_Max_Y]
1215
        mov     edi, eax
-
 
1216
        call    window._.draw_negative_box
1154
 
1217
        mov     edi, ebx
1155
        mov     [new_window_pos.left], 0
1218
        call    window._.draw_negative_box
1156
        or      ecx, ecx
1219
        ret
-
 
1220
 
1157
        jle     .check_for_new_vert_cursor_pos
1221
;==============================================================================
1158
        mov     [reposition], 1
-
 
Line -... Line 1222...
-
 
1222
;///// private functions //////////////////////////////////////////////////////
-
 
1223
;==============================================================================
-
 
1224
 
-
 
1225
iglobal
-
 
1226
  FuncTable syscall_display_settings, ftable, \
1159
        sub     eax, [new_window_pos.width]
1227
    00, 01, 02, 03, 04, 05, 06, 07, 08
-
 
1228
 
-
 
1229
  align 4
1160
        mov     [new_window_pos.left], eax
1230
  window_topleft dd \
-
 
1231
    1, 21, \ ;type 0
-
 
1232
    0,  0, \ ;type 1
-
 
1233
    5, 20, \ ;type 2
-
 
1234
    5,  ?, \ ;type 3 {set by skin}
-
 
1235
    5,  ?    ;type 4 {set by skin}
1161
        cmp     ecx, eax
1236
endg
-
 
1237
 
-
 
1238
;uglobal
1162
        jge     .check_for_new_vert_cursor_pos
1239
  ; NOTE: commented out since doesn't provide necessary functionality anyway,
1163
        mov     [new_window_pos.left], ecx
1240
  ;       to be reworked
-
 
1241
; new_window_starting       dd ?
-
 
1242
;endg
-
 
1243
 
-
 
1244
align 4
1164
 
1245
;------------------------------------------------------------------------------
1165
  .check_for_new_vert_cursor_pos:
1246
window._.invalidate_screen: ;//////////////////////////////////////////////////
-
 
1247
;------------------------------------------------------------------------------
-
 
1248
;? 
1166
        mov     [new_window_pos.top], 0
1249
;------------------------------------------------------------------------------
1167
        or      edx, edx
1250
;> eax = old (original) window box
1168
        jle     .draw_new_window_frame
1251
;> ebx = new (final) window box
-
 
1252
;> edi = pointer to WDATA struct
1169
        mov     [reposition], 1
1253
;------------------------------------------------------------------------------
-
 
1254
        push    eax ebx
-
 
1255
 
-
 
1256
        ; TODO: do we really need `draw_limits`?
-
 
1257
        ; Yes, they are used by background drawing code.
-
 
1258
        mov     ecx, [eax + BOX.left]
-
 
1259
        mov     edx, [ebx + BOX.left]
-
 
1260
        cmp     ecx, edx
-
 
1261
        jle     @f
-
 
1262
        mov     ecx, edx
-
 
1263
    @@:
-
 
1264
        mov     [draw_limits.left], ecx
-
 
1265
        mov     ecx, [eax + BOX.left]
-
 
1266
        add     ecx, [eax + BOX.width]
-
 
1267
        add     edx, [ebx + BOX.width]
-
 
1268
        cmp     ecx, edx
-
 
1269
        jae     @f
-
 
1270
        mov     ecx, edx
-
 
1271
    @@:
-
 
1272
        mov     [draw_limits.right], ecx
-
 
1273
        mov     ecx, [eax + BOX.top]
Line 1170... Line 1274...
1170
        sub     ebx, [new_window_pos.height]
1274
        mov     edx, [ebx + BOX.top]
1171
        mov     [new_window_pos.top], ebx
1275
        cmp     ecx, edx
Line -... Line 1276...
-
 
1276
        jle     @f
1172
        cmp     edx, ebx
1277
        mov     ecx, edx
Line 1173... Line -...
1173
        jge     .draw_new_window_frame
-
 
1174
        mov     [new_window_pos.top], edx
1278
    @@:
-
 
1279
        mov     [draw_limits.top], ecx
Line -... Line 1280...
-
 
1280
        mov     ecx, [eax + BOX.top]
-
 
1281
        add     ecx, [eax + BOX.height]
-
 
1282
        add     edx, [ebx + BOX.height]
-
 
1283
        cmp     ecx, edx
-
 
1284
        jae     @f
-
 
1285
        mov     ecx, edx
-
 
1286
    @@:
1175
        jmp     .draw_new_window_frame
1287
        mov     [draw_limits.bottom], ecx
-
 
1288
 
-
 
1289
        ; recalculate screen buffer at old position
1176
 
1290
        push    ebx
Line -... Line 1291...
-
 
1291
        mov     edx, [eax + BOX.height]
-
 
1292
        mov     ecx, [eax + BOX.width]
-
 
1293
        mov     ebx, [eax + BOX.top]
1177
  .resize_window:
1294
        mov     eax, [eax + BOX.left]
-
 
1295
        add     ecx, eax
-
 
1296
        add     edx, ebx
-
 
1297
        call    calculatescreen
-
 
1298
        pop     eax
1178
        push    eax ebx edx
1299
 
-
 
1300
        ; recalculate screen buffer at new position
-
 
1301
        mov     edx, [eax + BOX.height]
-
 
1302
        mov     ecx, [eax + BOX.width]
-
 
1303
        mov     ebx, [eax + BOX.top]
Line 1179... Line -...
1179
 
-
 
1180
        mov     edx, edi
-
 
1181
        sub     edx, window_data
1304
        mov     eax, [eax + BOX.left]
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
-
 
Line -... Line 1305...
-
 
1305
        add     ecx, eax
-
 
1306
        add     edx, ebx
-
 
1307
        call    calculatescreen
-
 
1308
 
-
 
1309
        mov     eax, edi
-
 
1310
        call    redrawscreen
-
 
1311
 
1189
        jge     @f
1312
        ; tell window to redraw itself
-
 
1313
        mov     [edi + WDATA.fl_redraw], 1
-
 
1314
 
-
 
1315
        pop     ebx eax
-
 
1316
        ret
-
 
1317
 
-
 
1318
align 4
Line 1190... Line 1319...
1190
        mov     eax, 32
1319
;------------------------------------------------------------------------------
1191
    @@: mov     [new_window_pos.width], eax
1320
window._.set_window_box: ;/////////////////////////////////////////////////////
-
 
1321
;------------------------------------------------------------------------------
-
 
1322
;? 
-
 
1323
;------------------------------------------------------------------------------
-
 
1324
;> eax = pointer to BOX struct
-
 
1325
;> bl = new window state flags
-
 
1326
;> edi = pointer to WDATA struct
-
 
1327
;------------------------------------------------------------------------------
Line 1192... Line 1328...
1192
 
1328
        push    eax ebx esi
1193
  .fix_new_vert_size:
-
 
1194
        call    window._.get_rolledup_height
-
 
1195
        mov     ebx, eax
-
 
1196
        movzx   eax, word[MOUSE_Y]
1329
 
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
1330
; don't do anything if the new box is identical to the old
Line 1202... Line -...
1202
        mov     eax, ebx
-
 
1203
    @@: mov     [new_window_pos.height], eax
-
 
1204
 
-
 
1205
  .set_reposition_flag:
1331
        cmp     bl, [edi + WDATA.fl_wstate]
1206
        mov     [reposition], 1
-
 
1207
 
-
 
1208
        pop     edx ebx eax
-
 
1209
 
-
 
1210
  .draw_new_window_frame:
1332
        jnz     @f
1211
        pop     ebx eax
-
 
1212
 
1333
        mov     esi, eax
1213
        ; draw new window moving/sizing frame
-
 
1214
        call    window._.draw_window_frames
-
 
1215
 
-
 
1216
        mov     esi, [MOUSE_X]
1334
        push    edi
Line 1217... Line 1335...
1217
        mov     [WIN_TEMP_XY], esi
1335
if WDATA.box
1218
 
1336
        add     edi, WDATA.box
Line -... Line 1337...
-
 
1337
end if
-
 
1338
        mov     ecx, 4
-
 
1339
        repz cmpsd
1219
  .check_for_new_mouse_buttons_state:
1340
        pop     edi
Line 1220... Line -...
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
1341
        jz      .exit
1225
        mov     byte[DONT_DRAW_MOUSE], 1
-
 
Line 1226... Line -...
1226
        mov     cl, 0
-
 
1227
        test    [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
1342
@@:
1228
        jnz     .check_other_actions
-
 
1229
 
-
 
1230
        mov     cl, [reposition]
-
 
1231
 
1343
 
1232
        ; draw negative frame once again to hide it
-
 
Line 1233... Line -...
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]
1344
        add     esp, -sizeof.BOX
1239
        mov     [edi + WDATA.box.top], eax
-
 
Line 1240... Line -...
1240
        mov     eax, [new_window_pos.width]
-
 
1241
        mov     [edi + WDATA.box.width], eax
-
 
1242
        mov     eax, [new_window_pos.height]
1345
 
1243
        mov     [edi + WDATA.box.height], eax
-
 
1244
        call    set_window_clientbox
1346
        mov     ebx, esp
1245
 
-
 
1246
        cmp     cl, 1
-
 
1247
        jne     .check_other_actions
1347
if WDATA.box
1248
        push    esi edi ecx
-
 
1249
        mov     esi, edi
-
 
Line 1250... Line 1348...
1250
        mov     ecx, 2
1348
        lea     esi, [edi + WDATA.box]
1251
        test    [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP or WSTATE_MAXIMIZED
1349
else
1252
        jnz     @f
1350
        mov     esi, edi ; optimization for WDATA.box = 0
1253
        add     ecx, 2
1351
end if
1254
    @@: sub     edi, window_data
1352
        xchg    eax, esi
1255
        shr     edi, 5
-
 
1256
        shl     edi, 8
1353
        mov     ecx, sizeof.BOX
1257
        add     edi, SLOT_BASE + APPDATA.saved_box
1354
        call    memmove
1258
        cld
1355
        xchg    eax, esi
1259
        rep     movsd
1356
        xchg    ebx, esi
Line 1260... Line -...
1260
        pop     ecx edi esi
-
 
1261
 
-
 
1262
  .check_other_actions:
1357
        call    memmove
1263
        mov     [reposition], cl
1358
        mov     eax, ebx
1264
 
-
 
1265
        pushad
-
 
1266
 
-
 
1267
        mov     dl, [edi + WDATA.fl_wstyle]
1359
        mov     ebx, esi
Line 1268... Line -...
1268
        and     dl, 0x0f
-
 
1269
        cmp     dl, 0x00
1360
 
1270
        je      .check_if_window_fits_screen
1361
        call    window._.check_window_position
1271
        cmp     dl, 0x01
1362
        call    window._.set_window_clientbox
1272
        je      .check_if_window_fits_screen
-
 
1273
 
1363
        call    window._.invalidate_screen
1274
        cmp     cl, 1
1364
 
1275
        je      .no_window_sizing
1365
        add     esp, sizeof.BOX
-
 
1366
 
-
 
1367
        mov     cl, [esp + 4]
1276
        mov     edx, edi
1368
        mov     ch, cl
1277
        sub     edx, window_data
1369
        xchg    cl, [edi + WDATA.fl_wstate]
1278
        shr     edx, 5
1370
 
-
 
1371
        or      cl, ch
-
 
1372
        test    cl, WSTATE_MAXIMIZED
-
 
1373
        jnz     .exit
Line 1279... Line -...
1279
        shl     edx, 8
-
 
1280
        add     edx, SLOT_BASE
1374
 
1281
 
1375
        mov     eax, edi
1282
        ; did we right-click on titlebar?
1376
        sub     eax, window_data
1283
        cmp     [do_resize], 2
1377
        shl     eax, 3
1284
        jne     .check_maximization_request
1378
        add     eax, SLOT_BASE
1285
 
1379
 
-
 
1380
        lea     ebx, [edi + WDATA.box]
-
 
1381
        xchg    esp, ebx
-
 
1382
 
-
 
1383
        pop     [eax + APPDATA.saved_box.left] \
-
 
1384
                [eax + APPDATA.saved_box.top] \
-
 
1385
                [eax + APPDATA.saved_box.width] \
-
 
1386
                edx
-
 
1387
 
-
 
1388
        xchg    esp, ebx
-
 
1389
 
-
 
1390
        test    ch, WSTATE_ROLLEDUP
-
 
1391
        jnz     .exit
-
 
1392
 
-
 
1393
        mov     [eax + APPDATA.saved_box.height], edx
-
 
1394
 
-
 
1395
  .exit:
-
 
1396
        pop     esi ebx eax
-
 
1397
        ret
-
 
1398
 
-
 
1399
align 4
-
 
1400
;------------------------------------------------------------------------------
-
 
1401
window._.set_window_clientbox: ;///////////////////////////////////////////////
-
 
1402
;------------------------------------------------------------------------------
-
 
1403
;? 
-
 
1404
;------------------------------------------------------------------------------
-
 
1405
;> edi = pointer to WDATA struct
-
 
1406
;------------------------------------------------------------------------------
-
 
1407
        push    eax ecx edi
-
 
1408
 
-
 
1409
        mov     eax, [_skinh]
-
 
1410
        mov     [window_topleft + 8 * 3 + 4], eax
-
 
1411
        mov     [window_topleft + 8 * 4 + 4], eax
-
 
1412
 
-
 
1413
        mov     ecx, edi
-
 
1414
        sub     edi, window_data
-
 
1415
        shl     edi, 3
-
 
1416
        test    [ecx + WDATA.fl_wstyle], WSTYLE_CLIENTRELATIVE
-
 
1417
        jz      .whole_window
-
 
1418
 
-
 
1419
        movzx   eax, [ecx + WDATA.fl_wstyle]
-
 
1420
        and     eax, 0x0F
-
 
1421
        mov     eax, [eax * 8 + window_topleft + 0]
-
 
1422
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax
-
 
1423
        shl     eax, 1
-
 
1424
        neg     eax
-
 
1425
        add     eax, [ecx + WDATA.box.width]
-
 
1426
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax
-
 
1427
 
-
 
1428
        movzx   eax, [ecx + WDATA.fl_wstyle]
-
 
1429
        and     eax, 0x0F
-
 
1430
        push    [eax * 8 + window_topleft + 0]
1286
        ; yes we did, toggle normal/rolled up window state
1431
        mov     eax, [eax * 8 + window_topleft + 4]
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
1432
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax
1293
        call    window._.get_rolledup_height
1433
        neg     eax
-
 
1434
        sub     eax, [esp]
-
 
1435
        add     eax, [ecx + WDATA.box.height]
1294
        jmp     .set_new_window_height
1436
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax
-
 
1437
        add     esp, 4
Line 1295... Line -...
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
1438
        jmp     .exit
1306
        mov     eax, [Screen_Max_Y]
-
 
Line 1307... Line -...
1307
        sub     eax, [edi + WDATA.box.height]
-
 
1308
        mov     [edi + WDATA.box.top], eax
1439
 
Line 1309... Line -...
1309
    @@: call    check_window_position
-
 
1310
        call    set_window_clientbox
-
 
1311
 
1440
  .whole_window:
1312
  .check_maximization_request:
-
 
1313
        ; can window change its height?
-
 
1314
        push    edx
-
 
1315
        mov     dl, [edi + WDATA.fl_wstyle]
1441
        xor     eax, eax
1316
        and     dl, 0x0f
-
 
1317
        cmp     dl, 0x04
-
 
1318
        pop     edx
-
 
Line 1319... Line 1442...
1319
        je      .check_if_window_fits_screen
1442
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax
1320
 
1443
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax
1321
        ; was it really a maximize/restore request?
-
 
1322
        cmp     [do_resize], 1
-
 
1323
        jne     .check_if_window_fits_screen
1444
        mov     eax, [ecx + WDATA.box.width]
1324
        cmp     [do_resize_from_corner], 0
-
 
1325
        jne     .check_if_window_fits_screen
-
 
1326
        cmp     [latest_window_touch_delta], 50
-
 
Line 1327... Line 1445...
1327
        jg      .check_if_window_fits_screen
1445
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax
-
 
1446
        mov     eax, [ecx + WDATA.box.height]
1328
 
1447
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax
-
 
1448
 
-
 
1449
  .exit:
Line 1329... Line -...
1329
        ; yes is was, toggle normal/maximized window state
-
 
1330
        xor     [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
-
 
1331
        mov     [reposition], 1
1450
        pop     edi ecx eax
Line -... Line 1451...
-
 
1451
        ret
1332
 
1452
 
Line -... Line 1453...
-
 
1453
align 4
-
 
1454
;------------------------------------------------------------------------------
-
 
1455
window._.sys_set_window: ;/////////////////////////////////////////////////////
-
 
1456
;------------------------------------------------------------------------------
-
 
1457
;? 
-
 
1458
;------------------------------------------------------------------------------
-
 
1459
;< edx = pointer to WDATA struct
1333
        ; calculate and set appropriate window bounds
1460
;------------------------------------------------------------------------------
-
 
1461
        mov     eax, [CURRENT_TASK]
-
 
1462
        shl     eax, 5
-
 
1463
        add     eax, window_data
-
 
1464
 
-
 
1465
        ; save window colors
Line 1334... Line -...
1334
        test    [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
-
 
1335
        jz      .restore_normal_window_size
1466
        mov     [eax + WDATA.cl_workarea], edx
1336
        mov     eax, [screen_workarea.left]
1467
        mov     [eax + WDATA.cl_titlebar], esi
1337
        mov     [edi + WDATA.box.left], eax
1468
        mov     [eax + WDATA.cl_frames], edi
1338
        sub     eax, [screen_workarea.right]
1469
 
1339
        neg     eax
1470
        mov     edi, eax
1340
        mov     [edi + WDATA.box.width], eax
1471
 
1341
        mov     eax, [screen_workarea.top]
1472
        ; was it already defined before?
Line 1342... Line -...
1342
        mov     [edi + WDATA.box.top], eax
-
 
1343
        test    [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
1473
        test    [edi + WDATA.fl_wdrawn], 1
1344
        jnz     .calculate_window_client_area
1474
        jnz     .set_client_box
1345
        sub     eax, [screen_workarea.bottom]
-
 
1346
        neg     eax
-
 
1347
        mov     [edi + WDATA.box.height], eax
-
 
1348
        jmp     .calculate_window_client_area
-
 
1349
 
-
 
Line -... Line 1475...
-
 
1475
        or      [edi + WDATA.fl_wdrawn], 1
1350
  .restore_normal_window_size:
1476
 
-
 
1477
        ; NOTE: commented out since doesn't provide necessary functionality
Line -... Line 1478...
-
 
1478
        ;       anyway, to be reworked
-
 
1479
;       mov     eax, [timer_ticks] ; [0xfdf0]
1351
        push    [edi + WDATA.box.height]
1480
;       add     eax, 100
1352
        push    edi
1481
;       mov     [new_window_starting], eax
Line -... Line 1482...
-
 
1482
 
-
 
1483
        ; no it wasn't, performing initial window definition
-
 
1484
        movzx   eax, bx
-
 
1485
        mov     [edi + WDATA.box.width], eax
1353
        lea     esi, [edx + APPDATA.saved_box]
1486
        movzx   eax, cx
-
 
1487
        mov     [edi + WDATA.box.height], eax
-
 
1488
        sar     ebx, 16
-
 
1489
        sar     ecx, 16
1354
        mov     ecx, 4
1490
        mov     [edi + WDATA.box.left], ebx
Line -... Line 1491...
-
 
1491
        mov     [edi + WDATA.box.top], ecx
1355
        cld
1492
 
1356
        rep     movsd
1493
        call    window._.check_window_position
-
 
1494
 
Line 1357... Line -...
1357
        pop     edi
-
 
1358
        pop     eax
1495
        push    ecx edi
1359
        test    [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
1496
 
1360
        jz      .calculate_window_client_area
-
 
1361
        mov     [edi + WDATA.box.height], eax
1497
        mov     cl, [edi + WDATA.fl_wstyle]
1362
 
-
 
Line 1363... Line 1498...
1363
  .calculate_window_client_area:
1498
        mov     eax, [edi + WDATA.cl_frames]
-
 
1499
 
-
 
1500
        sub     edi, window_data
-
 
1501
        shl     edi, 3
-
 
1502
        add     edi, SLOT_BASE
-
 
1503
 
-
 
1504
        and     cl, 0x0F
-
 
1505
        cmp     cl, 3
1364
        call    set_window_clientbox
1506
        je      @f
-
 
1507
        cmp     cl, 4
-
 
1508
        je      @f
-
 
1509
 
-
 
1510
        xor     eax, eax
1365
 
1511
 
1366
  .check_if_window_fits_screen:
1512
    @@:
-
 
1513
        mov     [edi + APPDATA.wnd_caption], eax
-
 
1514
 
-
 
1515
        mov     esi, [esp]
Line 1367... Line 1516...
1367
        ; does window fit into screen area?
1516
        add     edi, APPDATA.saved_box
1368
        mov     eax, [edi + WDATA.box.top]
1517
        movsd
1369
        add     eax, [edi + WDATA.box.height]
1518
        movsd
Line -... Line 1519...
-
 
1519
        movsd
-
 
1520
        movsd
1370
        cmp     eax, [Screen_Max_Y]
1521
 
-
 
1522
        pop     edi ecx
-
 
1523
 
-
 
1524
        mov     esi, [CURRENT_TASK]
-
 
1525
        movzx   esi, word[WIN_STACK + esi * 2]
-
 
1526
        lea     esi, [WIN_POS + esi * 2]
-
 
1527
        call    waredraw
-
 
1528
 
-
 
1529
        mov     eax, [edi + WDATA.box.left]
-
 
1530
        mov     ebx, [edi + WDATA.box.top]
-
 
1531
        mov     ecx, [edi + WDATA.box.width]
1371
        jbe     .no_window_sizing
1532
        mov     edx, [edi + WDATA.box.height]
-
 
1533
        add     ecx, eax
-
 
1534
        add     edx, ebx
-
 
1535
        call    calculatescreen
-
 
1536
 
1372
        mov     eax, [edi + WDATA.box.left]
1537
        mov     byte[KEY_COUNT], 0           ; empty keyboard buffer
-
 
1538
        mov     byte[BTN_COUNT], 0           ; empty button buffer
-
 
1539
 
-
 
1540
  .set_client_box:
-
 
1541
        ; update window client box coordinates
-
 
1542
        call    window._.set_window_clientbox
-
 
1543
 
-
 
1544
        ; reset window redraw flag and exit
-
 
1545
        mov     [edi + WDATA.fl_redraw], 0
-
 
1546
        mov     edx, edi
-
 
1547
        ret
-
 
1548
 
-
 
1549
align 4
Line 1373... Line 1550...
1373
        add     eax, [edi + WDATA.box.width]
1550
;------------------------------------------------------------------------------
1374
        cmp     eax, [Screen_Max_X]
1551
window._.check_window_position: ;//////////////////////////////////////////////
1375
        jbe     .no_window_sizing
1552
;------------------------------------------------------------------------------
1376
 
1553
;? Check if window is inside screen area
-
 
1554
;------------------------------------------------------------------------------
-
 
1555
;> edi = pointer to WDATA
1377
        ; no it doesn't, fix that
1556
;------------------------------------------------------------------------------
1378
        mov     eax, [Screen_Max_X]
1557
        push    eax ebx ecx edx esi
1379
        sub     eax, [edi + WDATA.box.width]
1558
 
1380
        mov     [edi + WDATA.box.left], eax
1559
        mov     eax, [edi + WDATA.box.left]
1381
        mov     eax, [Screen_Max_Y]
1560
        mov     ebx, [edi + WDATA.box.top]
1382
        sub     eax, [edi + WDATA.box.height]
1561
        mov     ecx, [edi + WDATA.box.width]
1383
        mov     [edi + WDATA.box.top], eax
1562
        mov     edx, [edi + WDATA.box.height]
1384
        call    set_window_clientbox
1563
 
-
 
1564
        mov     esi, [Screen_Max_X]
1385
 
1565
        cmp     ecx, esi
1386
  .no_window_sizing:
1566
        ja      .fix_width_high
Line 1387... Line 1567...
1387
        popad
1567
 
1388
 
1568
  .check_left:
1389
        ; did somethins actually change its place?
1569
        or      eax, eax
1390
        cmp     [reposition], 0
1570
        jl      .fix_left_low
-
 
1571
        add     eax, ecx
-
 
1572
        cmp     eax, esi
1391
        je      .reset_vars
1573
        jg      .fix_left_high
1392
 
1574
 
1393
        mov     byte[DONT_DRAW_MOUSE], 1
1575
  .check_height:
1394
 
1576
        mov     esi, [Screen_Max_Y]
1395
        push    eax ebx ecx edx
1577
        cmp     edx, esi
1396
 
1578
        ja      .fix_height_high
1397
        ; recalculate screen buffer at new position
1579
 
1398
        mov     eax, [edi + WDATA.box.left]
1580
  .check_top:
1399
        mov     ebx, [edi + WDATA.box.top]
1581
        or      ebx, ebx
-
 
1582
        jl      .fix_top_low
1400
        mov     ecx, [edi + WDATA.box.width]
1583
        add     ebx, edx
1401
        mov     edx, [edi + WDATA.box.height]
1584
        cmp     ebx, esi
1402
        add     ecx, eax
1585
        jg      .fix_top_high
1403
        add     edx, ebx
1586
 
-
 
1587
  .exit:
1404
        call    calculatescreen
1588
        pop     esi edx ecx ebx eax
1405
 
1589
        ret
Line 1406... Line 1590...
1406
        ; recalculate screen buffer at old position
1590
 
1407
        mov     eax, [old_window_pos.left]
1591
  .fix_width_high:
1408
        mov     ebx, [old_window_pos.top]
1592
        mov     ecx, esi
Line 1620... Line 1804...
1620
        test    al,al
1804
        test    al, al
1621
        jz      @f
1805
        jz      @f
1622
        mov     eax, esi
1806
        mov     eax, esi
1623
        mov     [ebp], al
1807
        mov     [ebp], al
1624
        ; -- end body --
1808
        ; -- end body --
-
 
1809
    @@:
1625
    @@: inc     ebp
1810
        inc     ebp
1626
        inc     edx
1811
        inc     edx
1627
        cmp     edx, [ff_xsz]
1812
        cmp     edx, [ff_xsz]
1628
        jb      .ff_new_x
1813
        jb      .ff_new_x
Line 1629... Line 1814...
1629
 
1814
 
Line 1662... Line 1847...
1662
;------------------------------------------------------------------------------
1847
;------------------------------------------------------------------------------
1663
        push    eax ebx
1848
        push    eax ebx
Line 1664... Line 1849...
1664
 
1849
 
1665
        ; if type of current active window is 3 or 4, it must be redrawn
1850
        ; if type of current active window is 3 or 4, it must be redrawn
-
 
1851
        mov     ebx, [TASK_COUNT]
-
 
1852
        
-
 
1853
;       DEBUGF  1, "K : TASK_COUNT (0x%x)\n", ebx
1666
        mov     ebx, [TASK_COUNT]
1854
        
1667
        movzx   ebx, word[WIN_POS + ebx * 2]
1855
        movzx   ebx, word[WIN_POS + ebx * 2]
1668
        shl     ebx, 5
1856
        shl     ebx, 5
1669
        add     eax, window_data
1857
        add     eax, window_data
1670
        mov     al, [window_data + ebx + WDATA.fl_wstyle]
1858
        mov     al, [window_data + ebx + WDATA.fl_wstyle]
Line 1688... Line 1876...
1688
 
1876
 
1689
  .next_stack_window:
1877
  .next_stack_window:
1690
        cmp     eax, [TASK_COUNT]
1878
        cmp     eax, [TASK_COUNT]
1691
        jae     .move_self_up
1879
        jae     .move_self_up
-
 
1880
        inc     eax
-
 
1881
        
-
 
1882
;       push    ebx
-
 
1883
;       xor     ebx,ebx
-
 
1884
;       mov     bx,[WIN_STACK + eax * 2]
-
 
1885
;       DEBUGF  1, "K : DEC WIN_STACK (0x%x)\n",ebx
-
 
1886
;       pop     ebx
1692
        inc     eax
1887
        
1693
        cmp     [WIN_STACK + eax * 2], bx
1888
        cmp     [WIN_STACK + eax * 2], bx
1694
        jbe     .next_stack_window
1889
        jbe     .next_stack_window
1695
        dec     word[WIN_STACK + eax * 2]
1890
        dec     word[WIN_STACK + eax * 2]
Line 1720... Line 1915...
1720
        mov     word[MOUSE_SCROLL_V], 0
1915
        mov     word[MOUSE_SCROLL_V], 0
Line 1721... Line 1916...
1721
 
1916
 
1722
        pop     ebx eax
1917
        pop     ebx eax
Line -... Line 1918...
-
 
1918
        ret
-
 
1919
 
-
 
1920
;------------------------------------------------------------------------------
-
 
1921
window._.window_deactivate: ;////////////////////////////////////////////////////
-
 
1922
;------------------------------------------------------------------------------
-
 
1923
;? Deactivate window
-
 
1924
;------------------------------------------------------------------------------
-
 
1925
;> esi = pointer to WIN_POS+ window data
-
 
1926
;------------------------------------------------------------------------------
-
 
1927
        push    eax ebx
-
 
1928
;------------------------------------------------------------------------------
-
 
1929
.move_others_up:
-
 
1930
        ; ax <- process no
-
 
1931
        movzx   ebx, word[esi]
-
 
1932
        ; ax <- position in window stack
-
 
1933
        movzx   ebx, word[WIN_STACK + ebx * 2]
-
 
1934
        ; up others
-
 
1935
        xor     eax, eax
-
 
1936
.next_stack_window:
-
 
1937
        cmp     eax, [TASK_COUNT]
-
 
1938
        jae     .move_self_down
-
 
1939
        inc     eax
-
 
1940
        cmp     [WIN_STACK + eax * 2], bx
-
 
1941
        jae     .next_stack_window
-
 
1942
        inc     word[WIN_STACK + eax * 2]
-
 
1943
        jmp     .next_stack_window
-
 
1944
;----------------------------------------------
-
 
1945
.move_self_down:
-
 
1946
        movzx   ebx, word[esi]
-
 
1947
        ; this is the last (and the low)
-
 
1948
        mov     [WIN_STACK + ebx * 2], word 1
-
 
1949
        ; update on screen - window stack
-
 
1950
        xor     eax, eax
-
 
1951
.next_window_pos:
-
 
1952
        cmp     eax, [TASK_COUNT]
-
 
1953
        jae     .reset_vars
-
 
1954
        inc     eax
-
 
1955
        movzx   ebx, word[WIN_STACK + eax * 2]
-
 
1956
        mov     [WIN_POS + ebx * 2], ax
-
 
1957
        jmp     .next_window_pos
-
 
1958
;-----------------------------------------------
-
 
1959
.reset_vars:
-
 
1960
        mov     byte[KEY_COUNT], 0
-
 
1961
        mov     byte[BTN_COUNT], 0
-
 
1962
        mov     word[MOUSE_SCROLL_H], 0
-
 
1963
        mov     word[MOUSE_SCROLL_V], 0
-
 
1964
        pop     ebx eax
1723
        ret
1965
        ret
1724
 
1966
;------------------------------------------------------------------------------ 
1725
align 4
1967
align 4
1726
;------------------------------------------------------------------------------
1968
;------------------------------------------------------------------------------
1727
window._.check_window_draw: ;//////////////////////////////////////////////////
1969
window._.check_window_draw: ;//////////////////////////////////////////////////
1728
;------------------------------------------------------------------------------
1970
;------------------------------------------------------------------------------
1729
;? Check if window is necessary to draw
1971
;? Check if window is necessary to draw
1730
;------------------------------------------------------------------------------
1972
;------------------------------------------------------------------------------
1731
;> edi = pointer to WDATA
1973
;> edi = pointer to WDATA
1732
;------------------------------------------------------------------------------
1974
;------------------------------------------------------------------------------
1733
        mov     cl, [edi + WDATA.fl_wstyle]
1975
        mov     cl, [edi + WDATA.fl_wstyle]
1734
        and     cl, 0x0f
1976
        and     cl, 0x0f
1735
        cmp     cl, 0x03
1977
        cmp     cl, 3
1736
        je      .exit.redraw      ; window type 3
1978
        je      .exit.redraw      ; window type 3
Line 1737... Line 1979...
1737
        cmp     cl, 0x04
1979
        cmp     cl, 4
Line 1738... Line 1980...
1738
        je      .exit.redraw      ; window type 4
1980
        je      .exit.redraw      ; window type 4
1739
 
1981
 
1740
        push    eax ebx edx esi
1982
        push    eax ebx edx esi
Line 1741... Line -...
1741
 
-
 
1742
        mov     eax, edi
-
 
1743
        sub     eax, window_data
1983
 
1744
        shr     eax, 5
1984
        mov     eax, edi
Line 1745... Line 1985...
1745
 
1985
        sub     eax, window_data
1746
        ; esi = process number
1986
        shr     eax, 5
Line 1796... Line 2036...
1796
        xor     ecx, ecx
2036
        xor     ecx, ecx
1797
        ret
2037
        ret
Line 1798... Line 2038...
1798
 
2038
 
1799
align 4
2039
align 4
1800
;------------------------------------------------------------------------------
2040
;------------------------------------------------------------------------------
1801
window._.draw_window_frames: ;/////////////////////////////////////////////////
-
 
1802
;------------------------------------------------------------------------------
-
 
1803
;? Draw negative window frames
2041
window._.draw_window_caption: ;////////////////////////////////////////////////
1804
;------------------------------------------------------------------------------
2042
;------------------------------------------------------------------------------
1805
;> edi = pointer to WDATA
2043
;? 
1806
;------------------------------------------------------------------------------
2044
;------------------------------------------------------------------------------
1807
        push    eax
2045
        inc     [mouse_pause]
Line -... Line 2046...
-
 
2046
        call    [_display.disable_mouse]
-
 
2047
 
1808
        cli
2048
        xor     eax, eax
-
 
2049
        mov     edx, [TASK_COUNT]
-
 
2050
        movzx   edx, word[WIN_POS + edx * 2]
1809
 
2051
        cmp     edx, [CURRENT_TASK]
-
 
2052
        jne     @f
-
 
2053
        inc     eax
-
 
2054
    @@:
1810
        test    [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
2055
        mov     edx, [CURRENT_TASK]
1811
        jnz     .exit
2056
        shl     edx, 5
-
 
2057
        add     edx, window_data
-
 
2058
        movzx   ebx, [edx + WDATA.fl_wstyle]
-
 
2059
        and     bl, 0x0F
1812
        mov     eax, [new_window_pos.left]
2060
        cmp     bl, 3
-
 
2061
        je      .draw_caption_style_3
-
 
2062
        cmp     bl, 4
-
 
2063
        je      .draw_caption_style_3
-
 
2064
 
-
 
2065
        jmp     .not_style_3
-
 
2066
 
1813
        cmp     eax, [edi + WDATA.box.left]
2067
  .draw_caption_style_3:
-
 
2068
        push    edx
-
 
2069
        call    drawwindow_IV_caption
-
 
2070
        add     esp, 4
-
 
2071
        jmp     .2
-
 
2072
 
-
 
2073
  .not_style_3:
-
 
2074
        cmp     bl, 2
1814
        jnz     .draw
2075
        jne     .not_style_2
-
 
2076
 
-
 
2077
        call    drawwindow_III_caption
-
 
2078
        jmp     .2
-
 
2079
 
1815
        mov     eax, [new_window_pos.width]
2080
  .not_style_2:
-
 
2081
        cmp     bl, 0
1816
        cmp     eax, [edi + WDATA.box.width]
2082
        jne     .2
-
 
2083
 
-
 
2084
        call    drawwindow_I_caption
1817
        jnz     .draw
2085
 
-
 
2086
  .2:
-
 
2087
        mov     edi, [CURRENT_TASK]
1818
        mov     eax, [new_window_pos.top]
2088
        shl     edi, 5
1819
        cmp     eax, [edi + WDATA.box.top]
2089
        test    [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
1820
        jnz     .draw
2090
        jz      .exit
1821
        mov     eax, [new_window_pos.height]
2091
        mov     edx, [edi * 8 + SLOT_BASE + APPDATA.wnd_caption]
-
 
2092
        or      edx, edx
1822
        cmp     eax, [edi + WDATA.box.height]
2093
        jz      .exit
-
 
2094
 
-
 
2095
        movzx   eax, [edi + window_data + WDATA.fl_wstyle]
-
 
2096
        and     al, 0x0F
-
 
2097
        cmp     al, 3
-
 
2098
        je      .skinned
1823
        jnz     .draw
2099
        cmp     al, 4
-
 
2100
        je      .skinned
-
 
2101
 
1824
        xor     [edi + WDATA.fl_wdrawn], 2
2102
        jmp     .not_skinned
-
 
2103
 
-
 
2104
  .skinned:
-
 
2105
        mov     ebp, [edi + window_data + WDATA.box.left - 2]
-
 
2106
        mov     bp, word[edi + window_data + WDATA.box.top]
-
 
2107
        movzx   eax, word[edi + window_data + WDATA.box.width]
1825
 
2108
        sub     ax, [_skinmargins.left]
-
 
2109
        sub     ax, [_skinmargins.right]
-
 
2110
        push    edx
-
 
2111
        cwde
-
 
2112
        cdq
-
 
2113
        mov     ebx, 6
-
 
2114
        idiv    ebx
-
 
2115
        pop     edx
-
 
2116
        or      eax, eax
-
 
2117
        js      .exit
1826
  .draw:
2118
 
1827
        push    ebx esi
2119
        mov     esi, eax
1828
        mov     eax, [new_window_pos.left - 2]
2120
        mov     ebx, dword[_skinmargins.left - 2]
1829
        mov     ax, word[new_window_pos.left]
2121
        mov     bx, word[_skinh]
-
 
2122
        sub     bx, [_skinmargins.bottom]
-
 
2123
        sub     bx, [_skinmargins.top]
1830
        add     ax, word[new_window_pos.width]
2124
        sar     bx, 1
-
 
2125
        adc     bx, 0
-
 
2126
        add     bx, [_skinmargins.top]
-
 
2127
        add     bx, -3
-
 
2128
        add     ebx, ebp
-
 
2129
        jmp     .dodraw
-
 
2130
 
-
 
2131
  .not_skinned:
-
 
2132
        cmp     al, 1
-
 
2133
        je      .exit
1831
        mov     ebx, [new_window_pos.top - 2]
2134
 
-
 
2135
        mov     ebp, [edi + window_data + WDATA.box.left - 2]
-
 
2136
        mov     bp, word[edi + window_data + WDATA.box.top]
-
 
2137
        movzx   eax, word[edi + window_data + WDATA.box.width]
-
 
2138
        sub     eax, 16
-
 
2139
        push    edx
-
 
2140
        cwde
-
 
2141
        cdq
-
 
2142
        mov     ebx, 6
-
 
2143
        idiv    ebx
-
 
2144
        pop     edx
-
 
2145
        or      eax, eax
-
 
2146
        js      .exit
-
 
2147
 
-
 
2148
        mov     esi, eax
-
 
2149
        mov     ebx, 0x00080007
-
 
2150
        add     ebx, ebp
-
 
2151
 
-
 
2152
  .dodraw:
-
 
2153
        mov     ecx, [common_colours + 16]
-
 
2154
        or      ecx, 0x80000000
-
 
2155
        xor     edi, edi
-
 
2156
        call    dtext_asciiz_esi
-
 
2157
 
-
 
2158
  .exit:
-
 
2159
        dec     [mouse_pause]
-
 
2160
        call    [draw_pointer]
-
 
2161
        ret
-
 
2162
 
-
 
2163
align 4
-
 
2164
;------------------------------------------------------------------------------
-
 
2165
window._.draw_negative_box: ;//////////////////////////////////////////////////
-
 
2166
;------------------------------------------------------------------------------
-
 
2167
;? Draw negative box
-
 
2168
;------------------------------------------------------------------------------
-
 
2169
;> edi = pointer to BOX struct
1832
        mov     bx, word[new_window_pos.top]
2170
;------------------------------------------------------------------------------
-
 
2171
        push    eax ebx esi
-
 
2172
        mov     esi, 0x01000000
-
 
2173
.1:
-
 
2174
        mov     eax, [edi + BOX.left - 2]
-
 
2175
        mov     ax, word[edi + BOX.left]
-
 
2176
        add     ax, word[edi + BOX.width]
-
 
2177
        mov     ebx, [edi + BOX.top - 2]
1833
        add     bx, word[new_window_pos.height]
2178
        mov     bx, word[edi + BOX.top]
1834
        mov     esi, 0x01000000
2179
        add     bx, word[edi + BOX.height]
-
 
2180
        call    draw_rectangle.forced
-
 
2181
        pop     esi ebx eax
-
 
2182
        ret
-
 
2183
;------------------------------------------------------------------------------
-
 
2184
window._.end_moving__box: ;//////////////////////////////////////////////////
-
 
2185
;------------------------------------------------------------------------------
-
 
2186
;? Draw positive box
-
 
2187
;------------------------------------------------------------------------------
-
 
2188
;> edi = pointer to BOX struct
-
 
2189
;------------------------------------------------------------------------------
-
 
2190
        push    eax ebx esi
-
 
2191
        xor     esi, esi
-
 
2192
        jmp     window._.draw_negative_box.1
-
 
2193
 
-
 
2194
 
-
 
2195
;------------------------------------------------------------------------------
-
 
2196
window._.get_rect: ;/////////////////////////////////////////////////////
-
 
2197
;------------------------------------------------------------------------------
-
 
2198
;?   void __fastcall get_window_rect(struct RECT* rc);
-
 
2199
;------------------------------------------------------------------------------
-
 
2200
;> ecx = pointer to RECT
-
 
2201
;------------------------------------------------------------------------------
-
 
2202
        mov     eax, [TASK_BASE]
-
 
2203
 
-
 
2204
        mov     edx, [eax-twdw + WDATA.box.left]
-
 
2205
        mov     [ecx+RECT.left], edx
-
 
2206
 
-
 
2207
        add     edx, [eax-twdw + WDATA.box.width]
-
 
2208
        mov     [ecx+RECT.right], edx
-
 
2209
 
-
 
2210
        mov     edx, [eax-twdw + WDATA.box.top]
-
 
2211
        mov     [ecx+RECT.top], edx
-
 
2212
 
Line 1835... Line -...
1835
        call    draw_rectangle.forced
-
 
1836
        pop     esi ebx
-
 
1837
 
-
 
1838
  .exit:
2213
        add     edx, [eax-twdw + WDATA.box.height]
Line 1839... Line -...
1839
        sti
-
 
1840
        pop     eax
-
 
1841
        ret
-
 
1842
 
-