Subversion Repositories Kolibri OS

Rev

Rev 4429 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4429 Serge 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
4
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa      ;;
5
;; Distributed under terms of the GNU General Public License    ;;
6
;;                                                              ;;
7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8
 
9
$Revision: 4424 $
10
 
11
;==============================================================================
12
;///// public functions ///////////////////////////////////////////////////////
13
;==============================================================================
14
 
15
window.BORDER_SIZE = 5
16
 
17
macro FuncTable name, table_name, [label]
18
{
19
  common
20
    align 4
21
    \label name#.#table_name dword
22
  forward
23
    dd name#.#label
24
  common
25
    name#.sizeof.#table_name = $ - name#.#table_name
26
}
27
 
28
uglobal
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
        call    window._.sys_set_window
47
        pop     eax
48
 
49
        or      al, al
50
        jnz     @f
51
 
52
        ; type I - original style
53
        call    drawwindow_I
54
        jmp     window._.draw_window_caption.2
55
;--------------------------------------
56
align 4
57
@@:
58
        dec     al
59
        jnz     @f
60
 
61
        ; type II - only reserve area, no draw
62
;        call    sys_window_mouse
63
;        call    [draw_pointer]
64
        call    __sys_draw_pointer
65
        jmp     .exit
66
;--------------------------------------
67
align 4
68
@@:
69
        dec     al
70
        jnz     @f
71
 
72
        ; type III  - new style
73
        call    drawwindow_III
74
        jmp     window._.draw_window_caption.2
75
 
76
        ; type IV & V - skinned window (resizable & not)
77
;--------------------------------------
78
align 4
79
@@:
80
        mov     eax, [TASK_COUNT]
81
        movzx   eax, word[WIN_POS + eax * 2]
82
        cmp     eax, [CURRENT_TASK]
83
        setz    al
84
        movzx   eax, al
85
        push    eax
86
        call    drawwindow_IV
87
        jmp     window._.draw_window_caption.2
88
;--------------------------------------
89
align 4
90
.exit:
91
        ret
92
;------------------------------------------------------------------------------
93
align 4
94
;------------------------------------------------------------------------------
95
syscall_display_settings: ;///// system function 48 ///////////////////////////
96
;------------------------------------------------------------------------------
97
;; Redraw screen:
98
;< ebx = 0
99
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
100
;; Set button style:
101
;< ebx = 1
102
;< ecx = 0 (flat) or 1 (with gradient)
103
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
104
;; Set system color palette:
105
;< ebx = 2
106
;< ecx = pointer to color table
107
;< edx = size of color table
108
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
109
;; Get system color palette:
110
;< ebx = 3
111
;< ecx = pointer to color table buffer
112
;< edx = size of color table buffer
113
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
114
;; Get skinned caption height:
115
;< ebx = 4
116
;> eax = height in pixels
117
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
118
;; Get screen working area:
119
;< ebx = 5
120
;> eax = pack[16(left), 16(right)]
121
;> ebx = pack[16(top), 16(bottom)]
122
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
123
;; Set screen working area:
124
;< ebx = 6
125
;< ecx = pack[16(left), 16(right)]
126
;< edx = pack[16(top), 16(bottom)]
127
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
128
;; Get skin margins:
129
;< ebx = 7
130
;> eax = pack[16(left), 16(right)]
131
;> ebx = pack[16(top), 16(bottom)]
132
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
133
;; Set skin:
134
;< ebx = 8
135
;< ecx = pointer to FileInfoBlock struct
136
;> eax = FS error code
137
;------------------------------------------------------------------------------
138
        cmp     ebx, .sizeof.ftable / 4
139
        ja      @f
140
        jmp     [.ftable + ebx * 4]
141
;--------------------------------------
142
align 4
143
@@:
144
        ret
145
;------------------------------------------------------------------------------
146
align 4
147
syscall_display_settings.00:
148
        xor     eax, eax
149
        inc     ebx
150
        cmp     [windowtypechanged], ebx
151
        jne     .exit
152
        mov     [windowtypechanged], eax
153
 
154
        jmp     syscall_display_settings._.redraw_whole_screen
155
;--------------------------------------
156
align 4
157
.exit:
158
        ret
159
;------------------------------------------------------------------------------
160
align 4
161
syscall_display_settings.01:
162
        and     ecx, 1
163
        cmp     ecx, [buttontype]
164
        je      .exit
165
        mov     [buttontype], ecx
166
        mov     [windowtypechanged], ebx
167
;--------------------------------------
168
align 4
169
  .exit:
170
        ret
171
;------------------------------------------------------------------------------
172
align 4
173
syscall_display_settings.02:
174
        dec     ebx
175
        mov     esi, ecx
176
        and     edx, 127
177
        mov     edi, common_colours
178
        mov     ecx, edx
179
        rep movsb
180
        mov     [windowtypechanged], ebx
181
        ret
182
;------------------------------------------------------------------------------
183
align 4
184
syscall_display_settings.03:
185
        mov     edi, ecx
186
        and     edx, 127
187
        mov     esi, common_colours
188
        mov     ecx, edx
189
        rep movsb
190
        ret
191
;------------------------------------------------------------------------------
192
align 4
193
syscall_display_settings.04:
194
        mov     eax, [_skinh]
195
        mov     [esp + 32], eax
196
        ret
197
;------------------------------------------------------------------------------
198
align 4
199
syscall_display_settings.05:
200
        mov     eax, [screen_workarea.left - 2]
201
        mov     ax, word[screen_workarea.right]
202
        mov     [esp + 32], eax
203
        mov     eax, [screen_workarea.top - 2]
204
        mov     ax, word[screen_workarea.bottom]
205
        mov     [esp + 20], eax
206
        ret
207
;------------------------------------------------------------------------------
208
align 4
209
syscall_display_settings.06:
210
        xor     esi, esi
211
 
212
        mov     edi, [Screen_Max_X]
213
        mov     eax, ecx
214
        movsx   ebx, ax
215
        sar     eax, 16
216
        cmp     eax, ebx
217
        jge     .check_horizontal
218
        inc     esi
219
        or      eax, eax
220
        jge     @f
221
        xor     eax, eax
222
;--------------------------------------
223
align 4
224
@@:
225
        mov     [screen_workarea.left], eax
226
        cmp     ebx, edi
227
        jle     @f
228
        mov     ebx, edi
229
;--------------------------------------
230
align 4
231
@@:
232
        mov     [screen_workarea.right], ebx
233
;--------------------------------------
234
align 4
235
.check_horizontal:
236
        mov     edi, [Screen_Max_Y]
237
        mov     eax, edx
238
        movsx   ebx, ax
239
        sar     eax, 16
240
        cmp     eax, ebx
241
        jge     .check_if_redraw_needed
242
        inc     esi
243
        or      eax, eax
244
        jge     @f
245
        xor     eax, eax
246
;--------------------------------------
247
align 4
248
@@:
249
        mov     [screen_workarea.top], eax
250
        cmp     ebx, edi
251
        jle     @f
252
        mov     ebx, edi
253
;--------------------------------------
254
align 4
255
@@:
256
        mov     [screen_workarea.bottom], ebx
257
;--------------------------------------
258
align 4
259
.check_if_redraw_needed:
260
        or      esi, esi
261
        jz      .exit
262
 
263
        call    repos_windows
264
        jmp     syscall_display_settings._.calculate_whole_screen
265
;--------------------------------------
266
align 4
267
.exit:
268
        ret
269
;------------------------------------------------------------------------------
270
align 4
271
syscall_display_settings.07:
272
        mov     eax, [_skinmargins + 0]
273
        mov     [esp + 32], eax
274
        mov     eax, [_skinmargins + 4]
275
        mov     [esp + 20], eax
276
        ret
277
;------------------------------------------------------------------------------
278
align 4
279
syscall_display_settings.08:
280
        mov     ebx, ecx
281
        call    read_skin_file
282
        mov     [esp + 32], eax
283
        test    eax, eax
284
        jnz     .exit
285
 
286
        call    syscall_display_settings._.calculate_whole_screen
287
        jmp     syscall_display_settings._.redraw_whole_screen
288
;--------------------------------------
289
align 4
290
.exit:
291
        ret
292
;------------------------------------------------------------------------------
293
align 4
294
syscall_display_settings._.calculate_whole_screen:
295
        xor     eax, eax
296
        xor     ebx, ebx
297
        mov     ecx, [Screen_Max_X]
298
        mov     edx, [Screen_Max_Y]
299
        jmp     calculatescreen
300
;------------------------------------------------------------------------------
301
align 4
302
syscall_display_settings._.redraw_whole_screen:
303
        xor     eax, eax
304
        mov     [draw_limits.left], eax
305
        mov     [draw_limits.top], eax
306
        mov     eax, [Screen_Max_X]
307
        mov     [draw_limits.right], eax
308
        mov     eax, [Screen_Max_Y]
309
        mov     [draw_limits.bottom], eax
310
        mov     eax, window_data
311
        jmp     redrawscreen
312
;------------------------------------------------------------------------------
313
align 4
314
;------------------------------------------------------------------------------
315
syscall_set_window_shape: ;///// system function 50 ///////////////////////////
316
;------------------------------------------------------------------------------
317
;; Set window shape address:
318
;> ebx = 0
319
;> ecx = shape data address
320
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
321
;; Set window shape scale:
322
;> ebx = 1
323
;> ecx = scale power (resulting scale is 2^ebx)
324
;------------------------------------------------------------------------------
325
        mov     edi, [current_slot]
326
 
327
        test    ebx, ebx
328
        jne     .shape_scale
329
        mov     [edi + APPDATA.wnd_shape], ecx
330
;--------------------------------------
331
align 4
332
.shape_scale:
333
        dec     ebx
334
        jnz     .exit
335
        mov     [edi + APPDATA.wnd_shape_scale], ecx
336
;--------------------------------------
337
align 4
338
.exit:
339
        ret
340
;------------------------------------------------------------------------------
341
align 4
342
;------------------------------------------------------------------------------
343
syscall_move_window: ;///// system function 67 ////////////////////////////////
344
;------------------------------------------------------------------------------
345
;? 
346
;------------------------------------------------------------------------------
347
        mov     edi, [CURRENT_TASK]
348
        shl     edi, 5
349
        add     edi, window_data
350
 
351
        test    [edi + WDATA.fl_wdrawn], 1
352
        jz      .exit
353
 
354
        test    [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
355
        jnz     .exit
356
 
357
        cmp     ebx, -1
358
        jne     @f
359
        mov     ebx, [edi + WDATA.box.left]
360
;--------------------------------------
361
align 4
362
@@:
363
        cmp     ecx, -1
364
        jne     @f
365
        mov     ecx, [edi + WDATA.box.top]
366
;--------------------------------------
367
align 4
368
@@:
369
        cmp     edx, -1
370
        jne     @f
371
        mov     edx, [edi + WDATA.box.width]
372
;--------------------------------------
373
align 4
374
@@:
375
        cmp     esi, -1
376
        jne     @f
377
        mov     esi, [edi + WDATA.box.height]
378
;--------------------------------------
379
align 4
380
@@:
381
        push    esi edx ecx ebx
382
        mov     eax, esp
383
        mov     bl, [edi + WDATA.fl_wstate]
384
;--------------------------------------
385
align 4
386
@@:
387
        cmp     [REDRAW_BACKGROUND], byte 0
388
        jz      @f
389
        call    change_task
390
        jmp     @b
391
;--------------------------------------
392
align 4
393
@@:
394
        call    window._.set_window_box
395
        add     esp, sizeof.BOX
396
 
397
        ; NOTE: do we really need this? to be reworked
398
;       mov     byte[DONT_DRAW_MOUSE], 0 ; mouse pointer
399
;       mov     byte[MOUSE_BACKGROUND], 0 ; no mouse under
400
;       mov     byte[MOUSE_DOWN], 0 ; react to mouse up/down
401
 
402
        ; NOTE: do we really need this? to be reworked
403
;       call    [draw_pointer]
404
;--------------------------------------
405
align 4
406
.exit:
407
        ret
408
;------------------------------------------------------------------------------
409
align 4
410
;------------------------------------------------------------------------------
411
syscall_window_settings: ;///// system function 71 /////////////////////////////
412
;------------------------------------------------------------------------------
413
;? 
414
;------------------------------------------------------------------------------
415
        dec     ebx     ; subfunction #1 - set window caption
416
        jnz     .exit_fail
417
 
418
        ; NOTE: only window owner thread can set its caption,
419
        ;       so there's no parameter for PID/TID
420
 
421
        mov     edi, [CURRENT_TASK]
422
        shl     edi, 5
423
 
424
        mov     [edi * 8 + SLOT_BASE + APPDATA.wnd_caption], ecx
425
        or      [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
426
 
427
        call    window._.draw_window_caption
428
 
429
        xor     eax, eax ; eax = 0 (success)
430
        ret
431
 
432
;  .get_window_caption:
433
;        dec     eax     ; subfunction #2 - get window caption
434
;        jnz     .exit_fail
435
 
436
        ; not implemented yet
437
;--------------------------------------
438
align 4
439
.exit_fail:
440
        xor     eax, eax
441
        inc     eax     ; eax = 1 (fail)
442
        ret
443
;------------------------------------------------------------------------------
444
align 4
445
;------------------------------------------------------------------------------
446
set_window_defaults: ;/////////////////////////////////////////////////////////
447
;------------------------------------------------------------------------------
448
;? 
449
;------------------------------------------------------------------------------
450
        mov     byte [window_data + 0x20 + WDATA.cl_titlebar + 3], 1 ; desktop is not movable
451
        push    eax ecx
452
        xor     eax, eax
453
        mov     ecx, WIN_STACK
454
;--------------------------------------
455
align 4
456
@@:
457
        inc     eax
458
        add     ecx, 2
459
        ; process no
460
        mov     [ecx + 0x000], ax
461
        ; positions in stack
462
        mov     [ecx + 0x400], ax
463
        cmp     ecx, WIN_POS - 2
464
        jne     @b
465
        pop     ecx eax
466
        ret
467
;------------------------------------------------------------------------------
468
align 4
469
;------------------------------------------------------------------------------
470
calculatescreen: ;/////////////////////////////////////////////////////////////
471
;------------------------------------------------------------------------------
472
;? Scan all windows from bottom to top, calling `setscreen` for each one
473
;? intersecting given screen area
474
;------------------------------------------------------------------------------
475
;> eax = left
476
;> ebx = top
477
;> ecx = right
478
;> edx = bottom
479
;------------------------------------------------------------------------------
480
        push    esi
481
        pushfd
482
        cli
483
 
484
        mov     esi, 1
485
        call    window._.set_screen
486
 
487
        push    ebp
488
 
489
        mov     ebp, [TASK_COUNT]
490
        cmp     ebp, 1
491
        jbe     .exit
492
 
493
        push    edx ecx ebx eax
494
;--------------------------------------
495
align 4
496
.next_window:
497
        movzx   edi, word[WIN_POS + esi * 2]
498
        shl     edi, 5
499
 
500
        cmp     [CURRENT_TASK + edi + TASKDATA.state], TSTATE_FREE
501
        je      .skip_window
502
 
503
        add     edi, window_data
504
        test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
505
        jnz     .skip_window
506
 
507
        mov     eax, [edi + WDATA.box.left]
508
        cmp     eax, [esp + RECT.right]
509
        jg      .skip_window
510
        mov     ebx, [edi + WDATA.box.top]
511
        cmp     ebx, [esp + RECT.bottom]
512
        jg      .skip_window
513
        mov     ecx, [edi + WDATA.box.width]
514
        add     ecx, eax
515
        cmp     ecx, [esp + RECT.left]
516
        jl      .skip_window
517
        mov     edx, [edi + WDATA.box.height]
518
        add     edx, ebx
519
        cmp     edx, [esp + RECT.top]
520
        jl      .skip_window
521
 
522
        cmp     eax, [esp + RECT.left]
523
        jae     @f
524
        mov     eax, [esp + RECT.left]
525
;--------------------------------------
526
align 4
527
@@:
528
        cmp     ebx, [esp + RECT.top]
529
        jae     @f
530
        mov     ebx, [esp + RECT.top]
531
;--------------------------------------
532
align 4
533
@@:
534
        cmp     ecx, [esp + RECT.right]
535
        jbe     @f
536
        mov     ecx, [esp + RECT.right]
537
;--------------------------------------
538
align 4
539
@@:
540
        cmp     edx, [esp + RECT.bottom]
541
        jbe     @f
542
        mov     edx, [esp + RECT.bottom]
543
;--------------------------------------
544
align 4
545
@@:
546
        push    esi
547
        movzx   esi, word[WIN_POS + esi * 2]
548
        call    window._.set_screen
549
        pop     esi
550
;--------------------------------------
551
align 4
552
.skip_window:
553
        inc     esi
554
        dec     ebp
555
        jnz     .next_window
556
 
557
        pop     eax ebx ecx edx
558
;--------------------------------------
559
align 4
560
.exit:
561
        pop     ebp
562
        inc     [_display.mask_seqno]
563
        popfd
564
        pop     esi
565
        ret
566
;------------------------------------------------------------------------------
567
align 4
568
;------------------------------------------------------------------------------
569
repos_windows: ;///////////////////////////////////////////////////////////////
570
;------------------------------------------------------------------------------
571
;? 
572
;------------------------------------------------------------------------------
573
        mov     ecx, [TASK_COUNT]
574
        mov     edi, window_data + sizeof.WDATA * 2
575
        call    force_redraw_background
576
        dec     ecx
577
        jle     .exit
578
;--------------------------------------
579
align 4
580
.next_window:
581
        mov     [edi + WDATA.fl_redraw], 1
582
        test    [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
583
        jnz     .fix_maximized
584
 
585
        mov     eax, [edi + WDATA.box.left]
586
        add     eax, [edi + WDATA.box.width]
587
        mov     ebx, [Screen_Max_X]
588
        cmp     eax, ebx
589
        jle     .fix_vertical
590
        mov     eax, [edi + WDATA.box.width]
591
        sub     eax, ebx
592
        jle     @f
593
        mov     [edi + WDATA.box.width], ebx
594
;--------------------------------------
595
align 4
596
@@:
597
        sub     ebx, [edi + WDATA.box.width]
598
        mov     [edi + WDATA.box.left], ebx
599
;--------------------------------------
600
align 4
601
.fix_vertical:
602
        mov     eax, [edi + WDATA.box.top]
603
        add     eax, [edi + WDATA.box.height]
604
        mov     ebx, [Screen_Max_Y]
605
        cmp     eax, ebx
606
        jle     .fix_client_box
607
        mov     eax, [edi + WDATA.box.height]
608
        sub     eax, ebx
609
        jle     @f
610
        mov     [edi + WDATA.box.height], ebx
611
;--------------------------------------
612
align 4
613
@@:
614
        sub     ebx, [edi + WDATA.box.height]
615
        mov     [edi + WDATA.box.top], ebx
616
;--------------------------------------
617
align 4
618
.fix_client_box:
619
        call    window._.set_window_clientbox
620
        add     edi, sizeof.WDATA
621
        loop    .next_window
622
;--------------------------------------
623
align 4
624
.exit:
625
        ret
626
;--------------------------------------
627
align 4
628
.fix_maximized:
629
        mov     eax, [screen_workarea.left]
630
        mov     [edi + WDATA.box.left], eax
631
        sub     eax, [screen_workarea.right]
632
        neg     eax
633
        mov     [edi + WDATA.box.width], eax
634
        mov     eax, [screen_workarea.top]
635
        mov     [edi + WDATA.box.top], eax
636
        test    [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
637
        jnz     .fix_client_box
638
        sub     eax, [screen_workarea.bottom]
639
        neg     eax
640
        mov     [edi + WDATA.box.height], eax
641
        jmp     .fix_client_box
642
;------------------------------------------------------------------------------
643
;align 4
644
;------------------------------------------------------------------------------
645
;sys_window_mouse: ;////////////////////////////////////////////////////////////
646
;------------------------------------------------------------------------------
647
;? 
648
;------------------------------------------------------------------------------
649
        ; NOTE: commented out since doesn't provide necessary functionality
650
        ;       anyway, to be reworked
651
;       push    eax
652
;
653
;       mov     eax, [timer_ticks]
654
;       cmp     [new_window_starting], eax
655
;       jb      .exit
656
;
657
;       mov     byte[MOUSE_BACKGROUND], 0
658
;       mov     byte[DONT_DRAW_MOUSE], 0
659
;
660
;       mov     [new_window_starting], eax
661
;
662
; .exit:
663
;       pop     eax
664
;        ret
665
;------------------------------------------------------------------------------
666
align 4
667
;------------------------------------------------------------------------------
668
draw_rectangle: ;//////////////////////////////////////////////////////////////
669
;------------------------------------------------------------------------------
670
;> eax = pack[16(left), 16(right)]
671
;> ebx = pack[16(top), 16(bottom)]
672
;> esi = color
673
;       ?? RR GG BB    ; 0x01000000 negation
674
;                      ; 0x02000000 used for draw_rectangle without top line
675
;                      ;           for example drawwindow_III and drawwindow_IV
676
;------------------------------------------------------------------------------
677
        push    eax ebx ecx edi
678
 
679
        xor     edi, edi
680
;--------------------------------------
681
align 4
682
.flags_set:
683
        push    ebx
684
 
685
        ; set line color
686
        mov     ecx, esi
687
        ; draw top border
688
        rol     ebx, 16
689
        push    ebx
690
        rol     ebx, 16
691
        pop     bx
692
        test    ecx, 1 shl 25
693
        jnz     @f
694
        sub     ecx, 1 shl 25
695
;        call    [draw_line]
696
        call    __sys_draw_line
697
;--------------------------------------
698
align 4
699
@@:
700
        ; draw bottom border
701
        mov     ebx, [esp - 2]
702
        pop     bx
703
;        call    [draw_line]
704
        call    __sys_draw_line
705
 
706
        pop     ebx
707
        add     ebx, 1 * 65536 - 1
708
 
709
        ; draw left border
710
        rol     eax, 16
711
        push    eax
712
        rol     eax, 16
713
        pop     ax
714
;        call    [draw_line]
715
        call    __sys_draw_line
716
 
717
        ; draw right border
718
        mov     eax, [esp - 2]
719
        pop     ax
720
;        call    [draw_line]
721
        call    __sys_draw_line
722
 
723
        pop     edi ecx ebx eax
724
        ret
725
;--------------------------------------
726
align 4
727
.forced:
728
        push    eax ebx ecx edi
729
        xor     edi, edi
730
        inc     edi
731
        jmp     .flags_set
732
;------------------------------------------------------------------------------
733
align 4
734
;------------------------------------------------------------------------------
735
drawwindow_I_caption: ;////////////////////////////////////////////////////////
736
;------------------------------------------------------------------------------
737
;? 
738
;------------------------------------------------------------------------------
739
        push    [edx + WDATA.cl_titlebar]
740
        mov     esi, edx
741
 
742
        mov     edx, [esi + WDATA.box.top]
743
        mov     eax, edx
744
        lea     ebx, [edx + 21]
745
        inc     edx
746
        add     eax, [esi + WDATA.box.height]
747
 
748
        cmp     ebx, eax
749
        jbe     @f
750
        mov     ebx, eax
751
;--------------------------------------
752
align 4
753
@@:
754
        push    ebx
755
 
756
        xor     edi, edi
757
;--------------------------------------
758
align 4
759
.next_line:
760
        mov     ebx, edx
761
        shl     ebx, 16
762
        add     ebx, edx
763
        mov     eax, [esi + WDATA.box.left]
764
        inc     eax
765
        shl     eax, 16
766
        add     eax, [esi + WDATA.box.left]
767
        add     eax, [esi + WDATA.box.width]
768
        dec     eax
769
        mov     ecx, [esi + WDATA.cl_titlebar]
770
        test    ecx, 0x80000000
771
        jz      @f
772
        sub     ecx, 0x00040404
773
        mov     [esi + WDATA.cl_titlebar], ecx
774
;--------------------------------------
775
align 4
776
@@:
777
        and     ecx, 0x00ffffff
778
;        call    [draw_line]
779
        call    __sys_draw_line
780
        inc     edx
781
        cmp     edx, [esp]
782
        jb      .next_line
783
 
784
        add     esp, 4
785
        pop     [esi + WDATA.cl_titlebar]
786
        ret
787
;------------------------------------------------------------------------------
788
align 4
789
;------------------------------------------------------------------------------
790
drawwindow_I: ;////////////////////////////////////////////////////////////////
791
;------------------------------------------------------------------------------
792
;? 
793
;------------------------------------------------------------------------------
794
        pushad
795
 
796
        ; window border
797
 
798
        mov     eax, [edx + WDATA.box.left - 2]
799
        mov     ax, word[edx + WDATA.box.left]
800
        add     ax, word[edx + WDATA.box.width]
801
        mov     ebx, [edx + WDATA.box.top - 2]
802
        mov     bx, word[edx + WDATA.box.top]
803
        add     bx, word[edx + WDATA.box.height]
804
 
805
        mov     esi, [edx + WDATA.cl_frames]
806
        call    draw_rectangle
807
 
808
        ; window caption
809
 
810
        call    drawwindow_I_caption
811
 
812
        ; window client area
813
 
814
        ; do we need to draw it?
815
        mov     edi, [esi + WDATA.cl_workarea]
816
        test    edi, 0x40000000
817
        jnz     .exit
818
 
819
        ; does client area have a positive size on screen?
4587 Serge 820
        cmp     [esi + WDATA.box.height], 21
821
        jle     .exit
4429 Serge 822
 
823
        ; okay, let's draw it
824
        mov     eax, 1
825
        mov     ebx, 21
826
        mov     ecx, [esi + WDATA.box.width]
827
        mov     edx, [esi + WDATA.box.height]
828
;        call    [drawbar]
829
        call    vesa20_drawbar
830
;--------------------------------------
831
align 4
832
.exit:
833
        popad
834
        ret
835
;------------------------------------------------------------------------------
836
align 4
837
;------------------------------------------------------------------------------
838
drawwindow_III_caption: ;/////////////////////////////////////////////////////
839
;------------------------------------------------------------------------------
840
;? 
841
;------------------------------------------------------------------------------
842
        mov     ecx, [edx + WDATA.cl_titlebar]
843
        push    ecx
844
        mov     esi, edx
845
        mov     edx, [esi + WDATA.box.top]
846
        add     edx, 4
847
        mov     ebx, [esi + WDATA.box.top]
848
        add     ebx, 20
849
        mov     eax, [esi + WDATA.box.top]
850
        add     eax, [esi + WDATA.box.height]
851
 
852
        cmp     ebx, eax
853
        jb      @f
854
        mov     ebx, eax
855
;--------------------------------------
856
align 4
857
@@:
858
        push    ebx
859
 
860
        xor     edi, edi
861
;--------------------------------------
862
align 4
863
.next_line:
864
        mov     ebx, edx
865
        shl     ebx, 16
866
        add     ebx, edx
867
        mov     eax, [esi + WDATA.box.left]
868
        shl     eax, 16
869
        add     eax, [esi + WDATA.box.left]
870
        add     eax, [esi + WDATA.box.width]
871
        add     eax, 4 * 65536 - 4
872
        mov     ecx, [esi + WDATA.cl_titlebar]
873
        test    ecx, 0x40000000
874
        jz      @f
875
        add     ecx, 0x00040404
876
;--------------------------------------
877
align 4
878
@@:
879
        test    ecx, 0x80000000
880
        jz      @f
881
        sub     ecx, 0x00040404
882
;--------------------------------------
883
align 4
884
@@:
885
        mov     [esi + WDATA.cl_titlebar], ecx
886
        and     ecx, 0x00ffffff
887
;        call    [draw_line]
888
        call    __sys_draw_line
889
        inc     edx
890
        cmp     edx, [esp]
891
        jb      .next_line
892
 
893
        add     esp, 4
894
        pop     [esi + WDATA.cl_titlebar]
895
        ret
896
;------------------------------------------------------------------------------
897
align 4
898
;------------------------------------------------------------------------------
899
drawwindow_III: ;//////////////////////////////////////////////////////////////
900
;------------------------------------------------------------------------------
901
;? 
902
;------------------------------------------------------------------------------
903
        pushad
904
 
905
        ; window border
906
 
907
        mov     eax, [edx + WDATA.box.left - 2]
908
        mov     ax, word[edx + WDATA.box.left]
909
        add     ax, word[edx + WDATA.box.width]
910
        mov     ebx, [edx + WDATA.box.top - 2]
911
        mov     bx, word[edx + WDATA.box.top]
912
        add     bx, word[edx + WDATA.box.height]
913
 
914
        mov     esi, [edx + WDATA.cl_frames]
915
        shr     esi, 1
916
        and     esi, 0x007f7f7f
917
        call    draw_rectangle
918
 
919
        push    esi
920
        mov     ecx, 3
921
        mov     esi, [edx + WDATA.cl_frames]
922
;--------------------------------------
923
align 4
924
.next_frame:
925
        add     eax, 1 * 65536 - 1
926
        add     ebx, 1 * 65536 - 1
927
        call    draw_rectangle
928
        dec     ecx
929
        jnz     .next_frame
930
 
931
        pop     esi
932
        add     eax, 1 * 65536 - 1
933
        add     ebx, 1 * 65536 - 1
934
        call    draw_rectangle
935
 
936
        ; window caption
937
 
938
        call    drawwindow_III_caption
939
 
940
        ; window client area
941
 
942
        ; do we need to draw it?
943
        mov     edi, [esi + WDATA.cl_workarea]
944
        test    edi, 0x40000000
945
        jnz     .exit
946
 
947
        ; does client area have a positive size on screen?
948
        mov     edx, [esi + WDATA.box.top]
949
        add     edx, 21 + 5
950
        mov     ebx, [esi + WDATA.box.top]
951
        add     ebx, [esi + WDATA.box.height]
952
        cmp     edx, ebx
953
        jg      .exit
954
 
955
        ; okay, let's draw it
956
        mov     eax, 5
957
        mov     ebx, 20
958
        mov     ecx, [esi + WDATA.box.width]
959
        mov     edx, [esi + WDATA.box.height]
960
        sub     ecx, 4
961
        sub     edx, 4
962
;        call    [drawbar]
963
        call    vesa20_drawbar
964
;--------------------------------------
965
align 4
966
.exit:
967
        popad
968
        ret
969
;------------------------------------------------------------------------------
970
align 4
971
;------------------------------------------------------------------------------
972
waredraw: ;////////////////////////////////////////////////////////////////////
973
;------------------------------------------------------------------------------
974
;? Activate window, redrawing if necessary
975
;------------------------------------------------------------------------------
976
        push    -1
977
        mov     eax, [TASK_COUNT]
978
        lea     eax, [WIN_POS + eax * 2]
979
        cmp     eax, esi
980
        pop     eax
981
        je      .exit
982
 
983
        ; is it overlapped by another window now?
984
        push    ecx
985
        call    window._.check_window_draw
986
        test    ecx, ecx
987
        pop     ecx
988
        jz      .do_not_draw
989
 
990
        ; yes it is, activate and update screen buffer
991
        call    window._.window_activate
992
 
993
        pushad
994
        mov     edi, [TASK_COUNT]
995
        movzx   esi, word[WIN_POS + edi * 2]
996
        shl     esi, 5
997
        add     esi, window_data
998
 
999
        mov     eax, [esi + WDATA.box.left]
1000
        mov     ebx, [esi + WDATA.box.top]
1001
        mov     ecx, [esi + WDATA.box.width]
1002
        mov     edx, [esi + WDATA.box.height]
1003
 
1004
        add     ecx, eax
1005
        add     edx, ebx
1006
 
1007
        mov     edi, [TASK_COUNT]
1008
        movzx   esi, word[WIN_POS + edi * 2]
1009
        call    window._.set_screen
1010
        inc     [_display.mask_seqno]
1011
        popad
1012
 
1013
        ; tell application to redraw itself
1014
        mov     [edi + WDATA.fl_redraw], 1
1015
        xor     eax, eax
1016
        jmp     .exit
1017
;--------------------------------------
1018
align 4
1019
.do_not_draw:
1020
        ; no it's not, just activate the window
1021
        call    window._.window_activate
1022
        xor     eax, eax
1023
        ret
1024
 
1025
;--------------------------------------
1026
align 4
1027
.exit:
1028
        inc     eax
1029
        ret
1030
;------------------------------------------------------------------------------
1031
align 4
1032
;------------------------------------------------------------------------------
1033
minimize_all_window:
1034
        push    ebx ecx edx esi edi
1035
        pushfd
1036
        cli
1037
        xor     edx, edx
1038
        mov     eax, 2  ; we do not minimize the kernel thread N1
1039
        mov     ebx, [TASK_COUNT]
1040
;--------------------------------------
1041
align 4
1042
.loop:
1043
        movzx   edi, word[WIN_POS + eax * 2]
1044
        shl     edi, 5
1045
; it is a unused slot?
1046
        cmp     dword [edi+CURRENT_TASK+TASKDATA.state], 9
1047
        je      @f
1048
; it is a hidden thread?
1049
        lea     esi, [edi*8+SLOT_BASE+APPDATA.app_name]
1050
        cmp     [esi], byte '@'
1051
        je      @f
1052
; is it already minimized?
1053
        test    [edi + window_data+WDATA.fl_wstate], WSTATE_MINIMIZED
1054
        jnz     @f
1055
; no it's not, let's do that
1056
        or      [edi + window_data+WDATA.fl_wstate], WSTATE_MINIMIZED
1057
        inc     edx
1058
;--------------------------------------
1059
align 4
1060
@@:
1061
        inc     eax
1062
        cmp     eax, ebx
1063
        jbe     .loop
1064
; If nothing has changed
1065
        test    edx, edx
1066
        jz      @f
1067
 
1068
        push    edx
1069
        call    syscall_display_settings._.calculate_whole_screen
1070
        call    syscall_display_settings._.redraw_whole_screen
1071
        pop     edx
1072
;--------------------------------------
1073
align 4
1074
@@:
1075
        mov     eax, edx
1076
        popfd
1077
        pop     edi esi edx ecx ebx
1078
        ret
1079
;------------------------------------------------------------------------------
1080
align 4
1081
;------------------------------------------------------------------------------
1082
minimize_window: ;/////////////////////////////////////////////////////////////
1083
;------------------------------------------------------------------------------
1084
;> eax = window number on screen
1085
;------------------------------------------------------------------------------
1086
;# corrupts [dl*]
1087
;------------------------------------------------------------------------------
1088
        push    edi
1089
        pushfd
1090
        cli
1091
 
1092
        ; is it already minimized?
1093
        movzx   edi, word[WIN_POS + eax * 2]
1094
        shl     edi, 5
1095
        add     edi, window_data
1096
        test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
1097
        jnz     .exit
1098
 
1099
        push    eax ebx ecx edx esi
1100
 
1101
        ; no it's not, let's do that
1102
        or      [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
1103
; If the window width is 0, then the action is not needed.
1104
        cmp     [edi + WDATA.box.width], dword 0
1105
        je      @f
1106
; If the window height is 0, then the action is not needed.
1107
        cmp     [edi + WDATA.box.height], dword 0
1108
        je      @f
1109
 
1110
        mov     eax, [edi + WDATA.box.left]
1111
        mov     [draw_limits.left], eax
1112
        mov     ecx, eax
1113
        add     ecx, [edi + WDATA.box.width]
1114
        mov     [draw_limits.right], ecx
1115
        mov     ebx, [edi + WDATA.box.top]
1116
        mov     [draw_limits.top], ebx
1117
        mov     edx, ebx
1118
        add     edx, [edi + WDATA.box.height]
1119
        mov     [draw_limits.bottom], edx
1120
 
1121
;        DEBUGF  1, "K : minimize_window\n"
1122
;        DEBUGF  1, "K : dl_left %x\n",[draw_limits.left]
1123
;        DEBUGF  1, "K : dl_right %x\n",[draw_limits.right]
1124
;        DEBUGF  1, "K : dl_top %x\n",[draw_limits.top]
1125
;        DEBUGF  1, "K : dl_bottom %x\n",[draw_limits.bottom]
1126
        call    calculatescreen
1127
;        xor     esi, esi
1128
;        xor     eax, eax
1129
        mov     eax, edi
1130
        call    redrawscreen
1131
;--------------------------------------
1132
align 4
1133
@@:
1134
        pop     esi edx ecx ebx eax
1135
;--------------------------------------
1136
align 4
1137
.exit:
1138
        popfd
1139
        pop     edi
1140
        ret
1141
;------------------------------------------------------------------------------
1142
align 4
1143
;------------------------------------------------------------------------------
1144
restore_minimized_window: ;////////////////////////////////////////////////////
1145
;------------------------------------------------------------------------------
1146
;> eax = window number on screen
1147
;------------------------------------------------------------------------------
1148
;# corrupts [dl*]
1149
;------------------------------------------------------------------------------
1150
        pushad
1151
        pushfd
1152
        cli
1153
 
1154
        ; is it already restored?
1155
        movzx   esi, word[WIN_POS + eax * 2]
1156
        mov     edi, esi
1157
        shl     edi, 5
1158
        add     edi, window_data
1159
        test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
1160
        jz      .exit
1161
 
1162
        ; no it's not, let's do that
1163
        mov     [edi + WDATA.fl_redraw], 1
1164
        and     [edi + WDATA.fl_wstate], not WSTATE_MINIMIZED
1165
        mov     ebp, window._.set_screen
1166
        cmp     eax, [TASK_COUNT]
1167
        jz      @f
1168
        mov     ebp, calculatescreen
1169
;--------------------------------------
1170
align 4
1171
@@:
1172
        mov     eax, [edi + WDATA.box.left]
1173
        mov     ebx, [edi + WDATA.box.top]
1174
        mov     ecx, [edi + WDATA.box.width]
1175
        mov     edx, [edi + WDATA.box.height]
1176
        add     ecx, eax
1177
        add     edx, ebx
1178
        call    ebp
1179
        inc     [_display.mask_seqno]
1180
;--------------------------------------
1181
align 4
1182
.exit:
1183
        popfd
1184
        popad
1185
        ret
1186
;------------------------------------------------------------------------------
1187
align 4
1188
; TODO: remove this proc
1189
;------------------------------------------------------------------------------
1190
window_check_events: ;/////////////////////////////////////////////////////////
1191
;------------------------------------------------------------------------------
1192
;? 
1193
;------------------------------------------------------------------------------
1194
        ; do we have window minimize/restore request?
1195
        cmp     [window_minimize], 0
1196
        je      .exit
1197
 
1198
        ; okay, minimize or restore top-most window and exit
1199
        mov     eax, [TASK_COUNT]
1200
        mov     bl, 0
1201
        xchg    [window_minimize], bl
1202
        dec     bl
1203
        jnz     @f
1204
        call    minimize_window
1205
        jmp     .exit
1206
;--------------------------------------
1207
align 4
1208
@@:
1209
        call    restore_minimized_window
1210
;--------------------------------------
1211
align 4
1212
.exit:
1213
        ret
1214
;------------------------------------------------------------------------------
1215
align 4
1216
;------------------------------------------------------------------------------
1217
sys_window_maximize_handler: ;/////////////////////////////////////////////////
1218
;------------------------------------------------------------------------------
1219
;? 
1220
;------------------------------------------------------------------------------
1221
;> esi = process slot
1222
;------------------------------------------------------------------------------
1223
        mov     edi, esi
1224
        shl     edi, 5
1225
        add     edi, window_data
1226
 
1227
        ; can window change its height?
1228
        ; only types 2 and 3 can be resized
1229
        mov     dl, [edi + WDATA.fl_wstyle]
1230
        test    dl, 2
1231
        jz      .exit
1232
 
1233
        ; toggle normal/maximized window state
1234
        mov     bl, [edi + WDATA.fl_wstate]
1235
        xor     bl, WSTATE_MAXIMIZED
1236
 
1237
        ; calculate and set appropriate window bounds
1238
        test    bl, WSTATE_MAXIMIZED
1239
        jz      .restore_size
1240
 
1241
        mov     eax, [screen_workarea.left]
1242
        mov     ecx, [screen_workarea.top]
1243
        push    [screen_workarea.bottom] \
1244
                [screen_workarea.right] \
1245
                ecx \
1246
                eax
1247
        sub     [esp + BOX.width], eax
1248
        sub     [esp + BOX.height], ecx
1249
        mov     eax, esp
1250
        jmp     .set_box
1251
;--------------------------------------
1252
align 4
1253
.restore_size:
1254
        mov     eax, esi
1255
        shl     eax, 8
1256
        add     eax, SLOT_BASE + APPDATA.saved_box
1257
        push    [eax + BOX.height] \
1258
                [eax + BOX.width] \
1259
                [eax + BOX.top] \
1260
                [eax + BOX.left]
1261
        mov     eax, esp
1262
;--------------------------------------
1263
align 4
1264
.set_box:
1265
        test    bl, WSTATE_ROLLEDUP
1266
        jz      @f
1267
 
1268
        xchg    eax, ecx
1269
        call    window._.get_rolledup_height
1270
        mov     [ecx + BOX.height], eax
1271
        xchg    eax, ecx
1272
;--------------------------------------
1273
align 4
1274
@@:
1275
        call    window._.set_window_box
1276
        add     esp, sizeof.BOX
1277
;--------------------------------------
1278
align 4
1279
.exit:
1280
        inc     [_display.mask_seqno]
1281
        ret
1282
;------------------------------------------------------------------------------
1283
align 4
1284
;------------------------------------------------------------------------------
1285
sys_window_rollup_handler: ;///////////////////////////////////////////////////
1286
;------------------------------------------------------------------------------
1287
;? 
1288
;------------------------------------------------------------------------------
1289
;> esi = process slot
1290
;------------------------------------------------------------------------------
1291
        mov     edx, esi
1292
        shl     edx, 8
1293
        add     edx, SLOT_BASE
1294
 
1295
        ; toggle normal/rolled up window state
1296
        mov     bl, [edi + WDATA.fl_wstate]
1297
        xor     bl, WSTATE_ROLLEDUP
1298
 
1299
        ; calculate and set appropriate window bounds
1300
        test    bl, WSTATE_ROLLEDUP
1301
        jz      .restore_size
1302
 
1303
        call    window._.get_rolledup_height
1304
        push    eax \
1305
                [edi + WDATA.box.width] \
1306
                [edi + WDATA.box.top] \
1307
                [edi + WDATA.box.left]
1308
        mov     eax, esp
1309
        jmp     .set_box
1310
;--------------------------------------
1311
align 4
1312
.restore_size:
1313
        test    bl, WSTATE_MAXIMIZED
1314
        jnz     @f
1315
        add     esp, -sizeof.BOX
1316
        lea     eax, [edx + APPDATA.saved_box]
1317
        jmp     .set_box
1318
;--------------------------------------
1319
align 4
1320
@@:
1321
        mov     eax, [screen_workarea.top]
1322
        push    [screen_workarea.bottom] \
1323
                [edi + WDATA.box.width] \
1324
                eax \
1325
                [edi + WDATA.box.left]
1326
        sub     [esp + BOX.height], eax
1327
        mov     eax, esp
1328
;--------------------------------------
1329
align 4
1330
.set_box:
1331
        call    window._.set_window_box
1332
        add     esp, sizeof.BOX
1333
        ret
1334
;------------------------------------------------------------------------------
1335
align 4
1336
;------------------------------------------------------------------------------
1337
;sys_window_start_moving_handler: ;/////////////////////////////////////////////
1338
;------------------------------------------------------------------------------
1339
;? 
1340
;------------------------------------------------------------------------------
1341
;> eax = old (original) window box
1342
;> esi = process slot
1343
;------------------------------------------------------------------------------
1344
;        mov     edi, eax
1345
;        call    window._.draw_negative_box
1346
;        ret
1347
;------------------------------------------------------------------------------
1348
align 4
1349
;------------------------------------------------------------------------------
1350
sys_window_end_moving_handler: ;///////////////////////////////////////////////
1351
;------------------------------------------------------------------------------
1352
;? 
1353
;------------------------------------------------------------------------------
1354
;> eax = old (original) window box
1355
;> ebx = new (final) window box
1356
;> esi = process slot
1357
;------------------------------------------------------------------------------
1358
;        mov     edi, ebx
1359
;        call    window._.end_moving__box
1360
 
1361
        mov     edi, esi
1362
        shl     edi, 5
1363
        add     edi, window_data
1364
 
1365
        mov     eax, ebx
1366
        mov     bl, [edi + WDATA.fl_wstate]
1367
        call    window._.set_window_box
1368
        ret
1369
;------------------------------------------------------------------------------
1370
align 4
1371
;------------------------------------------------------------------------------
1372
sys_window_moving_handler: ;///////////////////////////////////////////////////
1373
;------------------------------------------------------------------------------
1374
;? 
1375
;------------------------------------------------------------------------------
1376
;> eax = old (from previous call) window box
1377
;> ebx = new (current) window box
1378
;> esi = process_slot
1379
;------------------------------------------------------------------------------
1380
        mov     edi, eax
1381
        call    window._.draw_negative_box
1382
        mov     edi, ebx
1383
        call    window._.draw_negative_box
1384
        ret
1385
;==============================================================================
1386
;///// private functions //////////////////////////////////////////////////////
1387
;==============================================================================
1388
 
1389
iglobal
1390
  FuncTable syscall_display_settings, ftable, \
1391
    00, 01, 02, 03, 04, 05, 06, 07, 08
1392
 
1393
  align 4
1394
  window_topleft dd \
1395
    1, 21, \ ;type 0
1396
    0,  0, \ ;type 1
1397
    5, 20, \ ;type 2
1398
    5,  ?, \ ;type 3 {set by skin}
1399
    5,  ?    ;type 4 {set by skin}
1400
endg
1401
 
1402
;uglobal
1403
  ; NOTE: commented out since doesn't provide necessary functionality anyway,
1404
  ;       to be reworked
1405
; new_window_starting       dd ?
1406
;endg
1407
;------------------------------------------------------------------------------
1408
align 4
1409
;------------------------------------------------------------------------------
1410
window._.invalidate_screen: ;//////////////////////////////////////////////////
1411
;------------------------------------------------------------------------------
1412
;? 
1413
;------------------------------------------------------------------------------
1414
;> eax = old (original) window box
1415
;> ebx = new (final) window box
1416
;> edi = pointer to WDATA struct
1417
;------------------------------------------------------------------------------
1418
        push    eax ebx
1419
 
1420
        ; TODO: do we really need `draw_limits`?
1421
        ; Yes, they are used by background drawing code.
1422
 
1423
; we need only to restore the background windows at the old place!
1424
        mov     ecx, [ebx + BOX.left]
1425
        mov     [draw_limits.left], ecx
1426
        add     ecx, [ebx + BOX.width]
1427
        mov     [draw_limits.right], ecx
1428
        mov     ecx, [ebx + BOX.top]
1429
        mov     [draw_limits.top], ecx
1430
        add     ecx, [ebx + BOX.height]
1431
        mov     [draw_limits.bottom], ecx
1432
; recalculate screen buffer at old position
1433
        push    ebx
1434
        mov     edx, [eax + BOX.height]
1435
        mov     ecx, [eax + BOX.width]
1436
        mov     ebx, [eax + BOX.top]
1437
        mov     eax, [eax + BOX.left]
1438
        add     ecx, eax
1439
        add     edx, ebx
1440
        call    calculatescreen
1441
        pop     eax
1442
; recalculate screen buffer at new position
1443
        mov     edx, [eax + BOX.height]
1444
        mov     ecx, [eax + BOX.width]
1445
        mov     ebx, [eax + BOX.top]
1446
        mov     eax, [eax + BOX.left]
1447
        add     ecx, eax
1448
        add     edx, ebx
1449
        call    calculatescreen
1450
 
1451
        mov     eax, edi
1452
        call    redrawscreen
1453
 
1454
        ; tell window to redraw itself
1455
        mov     [edi + WDATA.fl_redraw], 1
1456
 
1457
        pop     ebx eax
1458
        ret
1459
;------------------------------------------------------------------------------
1460
align 4
1461
;------------------------------------------------------------------------------
1462
window._.set_window_box: ;/////////////////////////////////////////////////////
1463
;------------------------------------------------------------------------------
1464
;? 
1465
;------------------------------------------------------------------------------
1466
;> eax = pointer to BOX struct
1467
;> bl = new window state flags
1468
;> edi = pointer to WDATA struct
1469
;------------------------------------------------------------------------------
1470
        push    eax ebx esi
1471
 
1472
; don't do anything if the new box is identical to the old
1473
        cmp     bl, [edi + WDATA.fl_wstate]
1474
        jnz     @f
1475
        mov     esi, eax
1476
        push    edi
1477
if WDATA.box
1478
        add     edi, WDATA.box
1479
end if
1480
        mov     ecx, 4
1481
        repz cmpsd
1482
        pop     edi
1483
        jz      .exit
1484
;--------------------------------------
1485
align 4
1486
@@:
1487
        add     esp, -sizeof.BOX
1488
        mov     ebx, esp
1489
if WDATA.box
1490
        lea     esi, [edi + WDATA.box]
1491
else
1492
        mov     esi, edi ; optimization for WDATA.box = 0
1493
end if
1494
        xchg    eax, esi
1495
        mov     ecx, sizeof.BOX
1496
        call    memmove
1497
        xchg    eax, esi
1498
        xchg    ebx, esi
1499
        call    memmove
1500
        mov     eax, ebx
1501
        mov     ebx, esi
1502
 
1503
        call    window._.check_window_position
1504
        call    window._.set_window_clientbox
1505
        call    window._.invalidate_screen
1506
 
1507
        add     esp, sizeof.BOX
1508
 
1509
        mov     cl, [esp + 4]
1510
        mov     ch, cl
1511
        xchg    cl, [edi + WDATA.fl_wstate]
1512
 
1513
        or      cl, ch
1514
        test    cl, WSTATE_MAXIMIZED
1515
        jnz     .exit
1516
 
1517
        mov     eax, edi
1518
        sub     eax, window_data
1519
        shl     eax, 3
1520
        add     eax, SLOT_BASE
1521
 
1522
        lea     ebx, [edi + WDATA.box]
1523
        xchg    esp, ebx
1524
 
1525
        pop     [eax + APPDATA.saved_box.left] \
1526
                [eax + APPDATA.saved_box.top] \
1527
                [eax + APPDATA.saved_box.width] \
1528
                edx
1529
 
1530
        xchg    esp, ebx
1531
 
1532
        test    ch, WSTATE_ROLLEDUP
1533
        jnz     .exit
1534
 
1535
        mov     [eax + APPDATA.saved_box.height], edx
1536
;--------------------------------------
1537
align 4
1538
.exit:
1539
        pop     esi ebx eax
1540
        ret
1541
;------------------------------------------------------------------------------
1542
align 4
1543
;------------------------------------------------------------------------------
1544
window._.set_window_clientbox: ;///////////////////////////////////////////////
1545
;------------------------------------------------------------------------------
1546
;? 
1547
;------------------------------------------------------------------------------
1548
;> edi = pointer to WDATA struct
1549
;------------------------------------------------------------------------------
1550
        push    eax ecx edi
1551
 
1552
        mov     eax, [_skinh]
1553
        mov     [window_topleft + 8 * 3 + 4], eax
1554
        mov     [window_topleft + 8 * 4 + 4], eax
1555
 
1556
        mov     ecx, edi
1557
        sub     edi, window_data
1558
        shl     edi, 3
1559
        test    [ecx + WDATA.fl_wstyle], WSTYLE_CLIENTRELATIVE
1560
        jz      .whole_window
1561
 
1562
        movzx   eax, [ecx + WDATA.fl_wstyle]
1563
        and     eax, 0x0F
1564
        mov     eax, [eax * 8 + window_topleft + 0]
1565
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax
1566
        shl     eax, 1
1567
        neg     eax
1568
        add     eax, [ecx + WDATA.box.width]
1569
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax
1570
 
1571
        movzx   eax, [ecx + WDATA.fl_wstyle]
1572
        and     eax, 0x0F
1573
        push    [eax * 8 + window_topleft + 0]
1574
        mov     eax, [eax * 8 + window_topleft + 4]
1575
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax
1576
        neg     eax
1577
        sub     eax, [esp]
1578
        add     eax, [ecx + WDATA.box.height]
1579
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax
1580
        add     esp, 4
1581
        jmp     .exit
1582
;--------------------------------------
1583
align 4
1584
.whole_window:
1585
        xor     eax, eax
1586
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax
1587
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax
1588
        mov     eax, [ecx + WDATA.box.width]
1589
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax
1590
        mov     eax, [ecx + WDATA.box.height]
1591
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax
1592
;--------------------------------------
1593
align 4
1594
.exit:
1595
        pop     edi ecx eax
1596
        ret
1597
;------------------------------------------------------------------------------
1598
align 4
1599
;------------------------------------------------------------------------------
1600
window._.sys_set_window: ;/////////////////////////////////////////////////////
1601
;------------------------------------------------------------------------------
1602
;? 
1603
;------------------------------------------------------------------------------
1604
;< edx = pointer to WDATA struct
1605
;------------------------------------------------------------------------------
1606
        mov     eax, [CURRENT_TASK]
1607
        shl     eax, 5
1608
        add     eax, window_data
1609
 
1610
        ; save window colors
1611
        mov     [eax + WDATA.cl_workarea], edx
1612
        mov     [eax + WDATA.cl_titlebar], esi
1613
        mov     [eax + WDATA.cl_frames], edi
1614
 
1615
        mov     edi, eax
1616
 
1617
        ; was it already defined before?
1618
        test    [edi + WDATA.fl_wdrawn], 1
1619
        jnz     .set_client_box
1620
        or      [edi + WDATA.fl_wdrawn], 1
1621
; After first draw_window we need redraw mouse necessarily!
1622
; Otherwise the user can see cursor specified by f.37.5 from another window.
1623
; He will be really unhappy! He is terrible in rage - usually he throws stones!
1624
        mov     [redrawmouse_unconditional], 1
1625
        call    wakeup_osloop
1626
        ; NOTE: commented out since doesn't provide necessary functionality
1627
        ;       anyway, to be reworked
1628
;       mov     eax, [timer_ticks] ; [0xfdf0]
1629
;       add     eax, 100
1630
;       mov     [new_window_starting], eax
1631
 
1632
        ; no it wasn't, performing initial window definition
1633
        movzx   eax, bx
1634
        mov     [edi + WDATA.box.width], eax
1635
        movzx   eax, cx
1636
        mov     [edi + WDATA.box.height], eax
1637
        sar     ebx, 16
1638
        sar     ecx, 16
1639
        mov     [edi + WDATA.box.left], ebx
1640
        mov     [edi + WDATA.box.top], ecx
1641
 
1642
        call    window._.check_window_position
1643
 
1644
        push    ecx edi
1645
 
1646
        mov     cl, [edi + WDATA.fl_wstyle]
1647
        mov     eax, [edi + WDATA.cl_frames]
1648
 
1649
        sub     edi, window_data
1650
        shl     edi, 3
1651
        add     edi, SLOT_BASE
1652
 
1653
        and     cl, 0x0F
1654
        cmp     cl, 3
1655
        je      @f
1656
        cmp     cl, 4
1657
        je      @f
1658
 
1659
        xor     eax, eax
1660
;--------------------------------------
1661
align 4
1662
@@:
1663
        mov     [edi + APPDATA.wnd_caption], eax
1664
 
1665
        mov     esi, [esp]
1666
        add     edi, APPDATA.saved_box
1667
        movsd
1668
        movsd
1669
        movsd
1670
        movsd
1671
 
1672
        pop     edi ecx
1673
 
1674
        mov     esi, [CURRENT_TASK]
1675
        movzx   esi, word[WIN_STACK + esi * 2]
1676
        lea     esi, [WIN_POS + esi * 2]
1677
        call    waredraw
1678
 
1679
        mov     eax, [edi + WDATA.box.left]
1680
        mov     ebx, [edi + WDATA.box.top]
1681
        mov     ecx, [edi + WDATA.box.width]
1682
        mov     edx, [edi + WDATA.box.height]
1683
        add     ecx, eax
1684
        add     edx, ebx
1685
        call    calculatescreen
1686
 
1687
        mov     byte[KEY_COUNT], 0           ; empty keyboard buffer
1688
        mov     byte[BTN_COUNT], 0           ; empty button buffer
1689
;--------------------------------------
1690
align 4
1691
.set_client_box:
1692
        ; update window client box coordinates
1693
        call    window._.set_window_clientbox
1694
 
1695
        ; reset window redraw flag and exit
1696
        mov     [edi + WDATA.fl_redraw], 0
1697
        mov     edx, edi
1698
        ret
1699
;------------------------------------------------------------------------------
1700
align 4
1701
;------------------------------------------------------------------------------
1702
window._.check_window_position: ;//////////////////////////////////////////////
1703
;------------------------------------------------------------------------------
1704
;? Check if window is inside screen area
1705
;------------------------------------------------------------------------------
1706
;> edi = pointer to WDATA
1707
;------------------------------------------------------------------------------
1708
        push    eax ebx ecx edx esi
1709
 
1710
        mov     eax, [edi + WDATA.box.left]
1711
        mov     ebx, [edi + WDATA.box.top]
1712
        mov     ecx, [edi + WDATA.box.width]
1713
        mov     edx, [edi + WDATA.box.height]
1714
 
1715
        mov     esi, [Screen_Max_X]
1716
        cmp     ecx, esi
1717
        ja      .fix_width_high
1718
;--------------------------------------
1719
align 4
1720
.check_left:
1721
        or      eax, eax
1722
        jl      .fix_left_low
1723
        add     eax, ecx
1724
        cmp     eax, esi
1725
        jg      .fix_left_high
1726
;--------------------------------------
1727
align 4
1728
.check_height:
1729
        mov     esi, [Screen_Max_Y]
1730
        cmp     edx, esi
1731
        ja      .fix_height_high
1732
;--------------------------------------
1733
align 4
1734
.check_top:
1735
        or      ebx, ebx
1736
        jl      .fix_top_low
1737
        add     ebx, edx
1738
        cmp     ebx, esi
1739
        jg      .fix_top_high
1740
;--------------------------------------
1741
align 4
1742
.exit:
1743
        pop     esi edx ecx ebx eax
1744
        ret
1745
;--------------------------------------
1746
align 4
1747
.fix_width_high:
1748
        mov     ecx, esi
1749
        mov     [edi + WDATA.box.width], esi
1750
        jmp     .check_left
1751
;--------------------------------------
1752
align 4
1753
.fix_left_low:
1754
        xor     eax, eax
1755
        mov     [edi + WDATA.box.left], eax
1756
        jmp     .check_height
1757
;--------------------------------------
1758
align 4
1759
.fix_left_high:
1760
        mov     eax, esi
1761
        sub     eax, ecx
1762
        mov     [edi + WDATA.box.left], eax
1763
        jmp     .check_height
1764
;--------------------------------------
1765
align 4
1766
.fix_height_high:
1767
        mov     edx, esi
1768
        mov     [edi + WDATA.box.height], esi
1769
        jmp     .check_top
1770
;--------------------------------------
1771
align 4
1772
.fix_top_low:
1773
        xor     ebx, ebx
1774
        mov     [edi + WDATA.box.top], ebx
1775
        jmp     .exit
1776
;--------------------------------------
1777
align 4
1778
.fix_top_high:
1779
        mov     ebx, esi
1780
        sub     ebx, edx
1781
        mov     [edi + WDATA.box.top], ebx
1782
        jmp     .exit
1783
;------------------------------------------------------------------------------
1784
align 4
1785
;------------------------------------------------------------------------------
1786
window._.get_titlebar_height: ;////////////////////////////////////////////////
1787
;------------------------------------------------------------------------------
1788
;? 
1789
;------------------------------------------------------------------------------
1790
;> edi = pointer to WDATA
1791
;------------------------------------------------------------------------------
1792
        mov     al, [edi + WDATA.fl_wstyle]
1793
        and     al, 0x0f
1794
        cmp     al, 0x03
1795
        jne     @f
1796
        mov     eax, [_skinh]
1797
        ret
1798
;--------------------------------------
1799
align 4
1800
@@:
1801
        mov     eax, 21
1802
        ret
1803
;------------------------------------------------------------------------------
1804
align 4
1805
;------------------------------------------------------------------------------
1806
window._.get_rolledup_height: ;////////////////////////////////////////////////
1807
;------------------------------------------------------------------------------
1808
;? 
1809
;------------------------------------------------------------------------------
1810
;> edi = pointer to WDATA
1811
;------------------------------------------------------------------------------
1812
        mov     al, [edi + WDATA.fl_wstyle]
1813
        and     al, 0x0f
1814
        cmp     al, 0x03
1815
        jb      @f
1816
        mov     eax, [_skinh]
1817
        add     eax, 3
1818
        ret
1819
;--------------------------------------
1820
align 4
1821
@@:
1822
        or      al, al
1823
        jnz     @f
1824
        mov     eax, 21
1825
        ret
1826
;--------------------------------------
1827
align 4
1828
@@:
1829
        mov     eax, 21 + 2
1830
        ret
1831
;------------------------------------------------------------------------------
1832
align 4
1833
;------------------------------------------------------------------------------
1834
window._.set_screen: ;/////////////////////////////////////////////////////////
1835
;------------------------------------------------------------------------------
1836
;? Reserve window area in screen buffer
1837
;------------------------------------------------------------------------------
1838
;> eax = left
1839
;> ebx = top
1840
;> ecx = right
1841
;> edx = bottom
1842
;> esi = process number
1843
;------------------------------------------------------------------------------
1844
virtual at esp
1845
  ff_x     dd ?
1846
  ff_y     dd ?
1847
  ff_width dd ?
1848
  ff_xsz   dd ?
1849
  ff_ysz   dd ?
1850
  ff_scale dd ?
1851
end virtual
1852
 
1853
        pushad
1854
 
1855
        cmp     esi, 1
1856
        jz      .check_for_shaped_window
1857
        mov     edi, esi
1858
        shl     edi, 5
1859
        cmp     [window_data + edi + WDATA.box.width], 0
1860
        jnz     .check_for_shaped_window
1861
        cmp     [window_data + edi + WDATA.box.height], 0
1862
        jz      .exit
1863
;--------------------------------------
1864
align 4
1865
.check_for_shaped_window:
1866
        mov     edi, esi
1867
        shl     edi, 8
1868
        add     edi, SLOT_BASE
1869
        cmp     [edi + APPDATA.wnd_shape], 0
1870
        jne     .shaped_window
1871
 
1872
        ; get x&y size
1873
        sub     ecx, eax
1874
        sub     edx, ebx
1875
        inc     ecx
1876
        inc     edx
1877
 
1878
        ; get WinMap start
1879
        push    esi
1880
        mov     esi, [_display.width]
1881
        mov     edi, [d_width_calc_area + ebx*4]
1882
 
1883
        add     edi, eax
1884
        add     edi, [_WinMapAddress]
1885
        pop     eax
1886
        mov     ah, al
1887
        push    ax
1888
        shl     eax, 16
1889
        pop     ax
1890
;--------------------------------------
1891
align 4
1892
.next_line:
1893
        push    ecx
1894
        shr     ecx, 2
1895
        rep stosd
1896
        mov     ecx, [esp]
1897
        and     ecx, 3
1898
        rep stosb
1899
        pop     ecx
1900
        add     edi, esi
1901
        sub     edi, ecx
1902
        dec     edx
1903
        jnz     .next_line
1904
 
1905
        jmp     .exit
1906
;--------------------------------------
1907
align 4
1908
.shaped_window:
1909
        ;  for (y=0; y <= x_size; y++)
1910
        ;      for (x=0; x <= x_size; x++)
1911
        ;          if (shape[coord(x,y,scale)]==1)
1912
        ;             set_pixel(x, y, process_number);
1913
 
1914
        sub     ecx, eax
1915
        sub     edx, ebx
1916
        inc     ecx
1917
        inc     edx
1918
 
1919
        push    [edi + APPDATA.wnd_shape_scale]  ; push scale first -> for loop
1920
 
1921
        ; get WinMap start  -> ebp
1922
        push    eax
1923
        mov     eax, [d_width_calc_area + ebx*4]
1924
 
1925
        add     eax, [esp]
1926
        add     eax, [_WinMapAddress]
1927
        mov     ebp, eax
1928
 
1929
        mov     edi, [edi + APPDATA.wnd_shape]
1930
        pop     eax
1931
 
1932
        ; eax = x_start
1933
        ; ebx = y_start
1934
        ; ecx = x_size
1935
        ; edx = y_size
1936
        ; esi = process_number
1937
        ; edi = &shape
1938
        ;       [scale]
1939
        push    edx ecx ; for loop - x,y size
1940
 
1941
        mov     ecx, esi
1942
        shl     ecx, 5
1943
        mov     edx, [window_data + ecx + WDATA.box.top]
1944
        push    [window_data + ecx + WDATA.box.width]           ; for loop - width
1945
        mov     ecx, [window_data + ecx + WDATA.box.left]
1946
        sub     ebx, edx
1947
        sub     eax, ecx
1948
        push    ebx eax ; for loop - x,y
1949
 
1950
        add     [ff_xsz], eax
1951
        add     [ff_ysz], ebx
1952
 
1953
        mov     ebx, [ff_y]
1954
;--------------------------------------
1955
align 4
1956
.ff_new_y:
1957
        mov     edx, [ff_x]
1958
;--------------------------------------
1959
align 4
1960
.ff_new_x:
1961
        ; -- body --
1962
        mov     ecx, [ff_scale]
1963
        mov     eax, [ff_width]
1964
        inc     eax
1965
        shr     eax, cl
1966
        push    ebx edx
1967
        shr     ebx, cl
1968
        shr     edx, cl
1969
        imul    eax, ebx
1970
        add     eax, edx
1971
        pop     edx ebx
1972
        add     eax, edi
1973
        call    .read_byte
1974
        test    al, al
1975
        jz      @f
1976
        mov     eax, esi
1977
        mov     [ebp], al
1978
        ; -- end body --
1979
;--------------------------------------
1980
align 4
1981
@@:
1982
        inc     ebp
1983
        inc     edx
1984
        cmp     edx, [ff_xsz]
1985
        jb      .ff_new_x
1986
 
1987
        sub     ebp, [ff_xsz]
1988
        add     ebp, [ff_x]
1989
        add     ebp, [Screen_Max_X]  ; screen.x
1990
        inc     ebp
1991
        inc     ebx
1992
        cmp     ebx, [ff_ysz]
1993
        jb      .ff_new_y
1994
 
1995
        add     esp, 24
1996
;--------------------------------------
1997
align 4
1998
.exit:
1999
        popad
2000
        inc     [_display.mask_seqno]
2001
        ret
2002
;--------------------------------------
2003
align 4
2004
.read_byte:
2005
        ; eax - address
2006
        ; esi - slot
2007
        push    eax ecx edx esi
2008
        xchg    eax, esi
2009
        lea     ecx, [esp + 12]
2010
        mov     edx, 1
2011
        call    read_process_memory
2012
        pop     esi edx ecx eax
2013
        ret
2014
;------------------------------------------------------------------------------
2015
align 4
2016
;------------------------------------------------------------------------------
2017
window._.window_activate: ;////////////////////////////////////////////////////
2018
;------------------------------------------------------------------------------
2019
;? Activate window
2020
;------------------------------------------------------------------------------
2021
;> esi = pointer to WIN_POS+ window data
2022
;------------------------------------------------------------------------------
2023
        push    eax ebx
2024
 
2025
        ; if type of current active window is 3 or 4, it must be redrawn
2026
        mov     ebx, [TASK_COUNT]
2027
 
2028
;       DEBUGF  1, "K : TASK_COUNT (0x%x)\n", ebx
2029
 
2030
        movzx   ebx, word[WIN_POS + ebx * 2]
2031
        shl     ebx, 5
2032
        add     eax, window_data
2033
        mov     al, [window_data + ebx + WDATA.fl_wstyle]
2034
        and     al, 0x0f
2035
        cmp     al, 0x03
2036
        je      .set_window_redraw_flag
2037
        cmp     al, 0x04
2038
        jne     .move_others_down
2039
;--------------------------------------
2040
align 4
2041
.set_window_redraw_flag:
2042
        mov     [window_data + ebx + WDATA.fl_redraw], 1
2043
;--------------------------------------
2044
align 4
2045
.move_others_down:
2046
        ; ax <- process no
2047
        movzx   ebx, word[esi]
2048
        ; ax <- position in window stack
2049
        movzx   ebx, word[WIN_STACK + ebx * 2]
2050
 
2051
        ; drop others
2052
        xor     eax, eax
2053
;--------------------------------------
2054
align 4
2055
.next_stack_window:
2056
        cmp     eax, [TASK_COUNT]
2057
        jae     .move_self_up
2058
        inc     eax
2059
 
2060
;       push    ebx
2061
;       xor     ebx,ebx
2062
;       mov     bx,[WIN_STACK + eax * 2]
2063
;       DEBUGF  1, "K : DEC WIN_STACK (0x%x)\n",ebx
2064
;       pop     ebx
2065
 
2066
        cmp     [WIN_STACK + eax * 2], bx
2067
        jbe     .next_stack_window
2068
        dec     word[WIN_STACK + eax * 2]
2069
        jmp     .next_stack_window
2070
;--------------------------------------
2071
align 4
2072
.move_self_up:
2073
        movzx   ebx, word[esi]
2074
        ; number of processes
2075
        mov     ax, [TASK_COUNT]
2076
        ; this is the last (and the upper)
2077
        mov     [WIN_STACK + ebx * 2], ax
2078
 
2079
        ; update on screen - window stack
2080
        xor     eax, eax
2081
;--------------------------------------
2082
align 4
2083
.next_window_pos:
2084
        cmp     eax, [TASK_COUNT]
2085
        jae     .reset_vars
2086
        inc     eax
2087
        movzx   ebx, word[WIN_STACK + eax * 2]
2088
        mov     [WIN_POS + ebx * 2], ax
2089
        jmp     .next_window_pos
2090
;--------------------------------------
2091
align 4
2092
.reset_vars:
2093
        mov     byte[KEY_COUNT], 0
2094
        mov     byte[BTN_COUNT], 0
2095
        mov     word[MOUSE_SCROLL_H], 0
2096
        mov     word[MOUSE_SCROLL_V], 0
2097
 
2098
        pop     ebx eax
2099
        ret
2100
;------------------------------------------------------------------------------
2101
window._.window_deactivate: ;////////////////////////////////////////////////////
2102
;------------------------------------------------------------------------------
2103
;? Deactivate window
2104
;------------------------------------------------------------------------------
2105
;> esi = pointer to WIN_POS+ window data
2106
;------------------------------------------------------------------------------
2107
        push    eax ebx
2108
;--------------------------------------
2109
align 4
2110
.move_others_up:
2111
        ; ax <- process no
2112
        movzx   ebx, word[esi]
2113
        ; ax <- position in window stack
2114
        movzx   ebx, word[WIN_STACK + ebx * 2]
2115
        ; up others
2116
        xor     eax, eax
2117
;--------------------------------------
2118
align 4
2119
.next_stack_window:
2120
        cmp     eax, [TASK_COUNT]
2121
        jae     .move_self_down
2122
        inc     eax
2123
        cmp     [WIN_STACK + eax * 2], bx
2124
        jae     .next_stack_window
2125
        inc     word[WIN_STACK + eax * 2]
2126
        jmp     .next_stack_window
2127
;--------------------------------------
2128
align 4
2129
.move_self_down:
2130
        movzx   ebx, word[esi]
2131
        ; this is the last (and the low)
2132
        mov     [WIN_STACK + ebx * 2], word 1
2133
        ; update on screen - window stack
2134
        xor     eax, eax
2135
;--------------------------------------
2136
align 4
2137
.next_window_pos:
2138
        cmp     eax, [TASK_COUNT]
2139
        jae     .reset_vars
2140
        inc     eax
2141
        movzx   ebx, word[WIN_STACK + eax * 2]
2142
        mov     [WIN_POS + ebx * 2], ax
2143
        jmp     .next_window_pos
2144
;--------------------------------------
2145
align 4
2146
.reset_vars:
2147
        mov     byte[KEY_COUNT], 0
2148
        mov     byte[BTN_COUNT], 0
2149
        mov     word[MOUSE_SCROLL_H], 0
2150
        mov     word[MOUSE_SCROLL_V], 0
2151
        pop     ebx eax
2152
        ret
2153
;------------------------------------------------------------------------------
2154
align 4
2155
;------------------------------------------------------------------------------
2156
window._.check_window_draw: ;//////////////////////////////////////////////////
2157
;------------------------------------------------------------------------------
2158
;? Check if window is necessary to draw
2159
;------------------------------------------------------------------------------
2160
;> edi = pointer to WDATA
2161
;------------------------------------------------------------------------------
2162
        mov     cl, [edi + WDATA.fl_wstyle]
2163
        and     cl, 0x0f
2164
        cmp     cl, 3
2165
        je      .exit.redraw      ; window type 3
2166
        cmp     cl, 4
2167
        je      .exit.redraw      ; window type 4
2168
 
2169
        push    eax ebx edx esi
2170
 
2171
        mov     eax, edi
2172
        sub     eax, window_data
2173
        shr     eax, 5
2174
 
2175
        movzx   eax, word[WIN_STACK + eax * 2]  ; get value of the curr process
2176
        lea     esi, [WIN_POS + eax * 2]        ; get address of this process at 0xC400
2177
;--------------------------------------
2178
align 4
2179
.next_window:
2180
        add     esi, 2
2181
 
2182
        mov     eax, [TASK_COUNT]
2183
        lea     eax, word[WIN_POS + eax * 2] ; number of the upper window
2184
 
2185
        cmp     esi, eax
2186
        ja      .exit.no_redraw
2187
 
2188
        movzx   edx, word[esi]
2189
        shl     edx, 5
2190
        cmp     [CURRENT_TASK + edx + TASKDATA.state], TSTATE_FREE
2191
        je      .next_window
2192
 
2193
        mov     eax, [edi + WDATA.box.top]
2194
        mov     ebx, [edi + WDATA.box.height]
2195
        add     ebx, eax
2196
 
2197
        mov     ecx, [window_data + edx + WDATA.box.top]
2198
        cmp     ecx, ebx
2199
        jge     .next_window
2200
        add     ecx, [window_data + edx + WDATA.box.height]
2201
        cmp     eax, ecx
2202
        jge     .next_window
2203
 
2204
        mov     eax, [edi + WDATA.box.left]
2205
        mov     ebx, [edi + WDATA.box.width]
2206
        add     ebx, eax
2207
 
2208
        mov     ecx, [window_data + edx + WDATA.box.left]
2209
        cmp     ecx, ebx
2210
        jge     .next_window
2211
        add     ecx, [window_data + edx + WDATA.box.width]
2212
        cmp     eax, ecx
2213
        jge     .next_window
2214
 
2215
        pop     esi edx ebx eax
2216
;--------------------------------------
2217
align 4
2218
.exit.redraw:
2219
        xor     ecx, ecx
2220
        inc     ecx
2221
        ret
2222
;--------------------------------------
2223
align 4
2224
.exit.no_redraw:
2225
        pop     esi edx ebx eax
2226
        xor     ecx, ecx
2227
        ret
2228
;------------------------------------------------------------------------------
2229
align 4
2230
;------------------------------------------------------------------------------
2231
window._.draw_window_caption: ;////////////////////////////////////////////////
2232
;------------------------------------------------------------------------------
2233
;? 
2234
;------------------------------------------------------------------------------
2235
        xor     eax, eax
2236
        mov     edx, [TASK_COUNT]
2237
        movzx   edx, word[WIN_POS + edx * 2]
2238
        cmp     edx, [CURRENT_TASK]
2239
        jne     @f
2240
        inc     eax
2241
;--------------------------------------
2242
align 4
2243
@@:
2244
        mov     edx, [CURRENT_TASK]
2245
        shl     edx, 5
2246
        add     edx, window_data
2247
        movzx   ebx, [edx + WDATA.fl_wstyle]
2248
        and     bl, 0x0F
2249
        cmp     bl, 3
2250
        je      .draw_caption_style_3
2251
        cmp     bl, 4
2252
        je      .draw_caption_style_3
2253
 
2254
        jmp     .not_style_3
2255
;--------------------------------------
2256
align 4
2257
.draw_caption_style_3:
2258
        push    edx
2259
        call    drawwindow_IV_caption
2260
        add     esp, 4
2261
        jmp     .2
2262
;--------------------------------------
2263
align 4
2264
.not_style_3:
2265
        cmp     bl, 2
2266
        jne     .not_style_2
2267
 
2268
        call    drawwindow_III_caption
2269
        jmp     .2
2270
;--------------------------------------
2271
align 4
2272
.not_style_2:
2273
        cmp     bl, 0
2274
        jne     .2
2275
 
2276
        call    drawwindow_I_caption
2277
;--------------------------------------
2278
align 4
2279
.2:
2280
        mov     edi, [CURRENT_TASK]
2281
        shl     edi, 5
2282
        test    [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
2283
        jz      .exit
2284
        mov     edx, [edi * 8 + SLOT_BASE + APPDATA.wnd_caption]
2285
        or      edx, edx
2286
        jz      .exit
2287
 
2288
        movzx   eax, [edi + window_data + WDATA.fl_wstyle]
2289
        and     al, 0x0F
2290
        cmp     al, 3
2291
        je      .skinned
2292
        cmp     al, 4
2293
        je      .skinned
2294
 
2295
        jmp     .not_skinned
2296
;--------------------------------------
2297
align 4
2298
.skinned:
2299
        mov     ebp, [edi + window_data + WDATA.box.left - 2]
2300
        mov     bp, word[edi + window_data + WDATA.box.top]
2301
        movzx   eax, word[edi + window_data + WDATA.box.width]
2302
        sub     ax, [_skinmargins.left]
2303
        sub     ax, [_skinmargins.right]
2304
        push    edx
2305
        cwde
2306
        cdq
2307
        mov     ebx, 6
2308
        idiv    ebx
2309
        pop     edx
2310
        or      eax, eax
2311
        js      .exit
2312
 
2313
        mov     esi, eax
2314
        mov     ebx, dword[_skinmargins.left - 2]
2315
        mov     bx, word[_skinh]
2316
        sub     bx, [_skinmargins.bottom]
2317
        sub     bx, [_skinmargins.top]
2318
        sar     bx, 1
2319
        adc     bx, 0
2320
        add     bx, [_skinmargins.top]
2321
        add     bx, -3
2322
        add     ebx, ebp
2323
        jmp     .dodraw
2324
;--------------------------------------
2325
align 4
2326
.not_skinned:
2327
        cmp     al, 1
2328
        je      .exit
2329
 
2330
        mov     ebp, [edi + window_data + WDATA.box.left - 2]
2331
        mov     bp, word[edi + window_data + WDATA.box.top]
2332
        movzx   eax, word[edi + window_data + WDATA.box.width]
2333
        sub     eax, 16
2334
        push    edx
2335
        cwde
2336
        cdq
2337
        mov     ebx, 6
2338
        idiv    ebx
2339
        pop     edx
2340
        or      eax, eax
2341
        js      .exit
2342
 
2343
        mov     esi, eax
2344
        mov     ebx, 0x00080007
2345
        add     ebx, ebp
2346
;--------------------------------------
2347
align 4
2348
.dodraw:
2349
        mov     ecx, [common_colours + 16]
2350
        or      ecx, 0x80000000
2351
        xor     edi, edi
2352
        call    dtext_asciiz_esi
2353
;--------------------------------------
2354
align 4
2355
.exit:
2356
;        call    [draw_pointer]
2357
        call    __sys_draw_pointer
2358
        ret
2359
;------------------------------------------------------------------------------
2360
align 4
2361
;------------------------------------------------------------------------------
2362
window._.draw_negative_box: ;//////////////////////////////////////////////////
2363
;------------------------------------------------------------------------------
2364
;? Draw negative box
2365
;------------------------------------------------------------------------------
2366
;> edi = pointer to BOX struct
2367
;------------------------------------------------------------------------------
2368
        push    eax ebx esi
2369
        mov     esi, 0x01000000
2370
;--------------------------------------
2371
align 4
2372
.1:
2373
        mov     eax, [edi + BOX.left - 2]
2374
        mov     ax, word[edi + BOX.left]
2375
        add     ax, word[edi + BOX.width]
2376
        mov     ebx, [edi + BOX.top - 2]
2377
        mov     bx, word[edi + BOX.top]
2378
        add     bx, word[edi + BOX.height]
2379
        call    draw_rectangle.forced
2380
        pop     esi ebx eax
2381
        ret
2382
;------------------------------------------------------------------------------
2383
;align 4
2384
;------------------------------------------------------------------------------
2385
;window._.end_moving__box: ;//////////////////////////////////////////////////
2386
;------------------------------------------------------------------------------
2387
;? Draw positive box
2388
;------------------------------------------------------------------------------
2389
;> edi = pointer to BOX struct
2390
;------------------------------------------------------------------------------
2391
;        push    eax ebx esi
2392
;        xor     esi, esi
2393
;        jmp     window._.draw_negative_box.1
2394
;------------------------------------------------------------------------------
2395
align 4
2396
;------------------------------------------------------------------------------
2397
window._.get_rect: ;/////////////////////////////////////////////////////
2398
;------------------------------------------------------------------------------
2399
;?   void __fastcall get_window_rect(struct RECT* rc);
2400
;------------------------------------------------------------------------------
2401
;> ecx = pointer to RECT
2402
;------------------------------------------------------------------------------
2403
        mov     eax, [TASK_BASE]
2404
 
2405
        mov     edx, [eax-twdw + WDATA.box.left]
2406
        mov     [ecx+RECT.left], edx
2407
 
2408
        add     edx, [eax-twdw + WDATA.box.width]
2409
        mov     [ecx+RECT.right], edx
2410
 
2411
        mov     edx, [eax-twdw + WDATA.box.top]
2412
        mov     [ecx+RECT.top], edx
2413
 
2414
        add     edx, [eax-twdw + WDATA.box.height]
2415
        mov     [ecx+RECT.bottom], edx
2416
        ret
2417
;------------------------------------------------------------------------------