Subversion Repositories Kolibri OS

Rev

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