Subversion Repositories Kolibri OS

Rev

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

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