Subversion Repositories Kolibri OS

Rev

Rev 8866 | Rev 8928 | 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: 8869 $
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    ;
133
        jnz     @f                               ;
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
150
        jnz     @f
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
1689
        mov     [edi + WDATA.box.width], esi
1690
        jmp     .check_left
2436 mario79 1691
;--------------------------------------
1692
align 4
1693
.fix_left_low:
1391 mikedld 1694
        xor     eax, eax
1695
        mov     [edi + WDATA.box.left], eax
1696
        jmp     .check_height
2436 mario79 1697
;--------------------------------------
1698
align 4
1699
.fix_left_high:
1391 mikedld 1700
        mov     eax, esi
1701
        sub     eax, ecx
1702
        mov     [edi + WDATA.box.left], eax
1703
        jmp     .check_height
2436 mario79 1704
;--------------------------------------
1705
align 4
1706
.fix_height_high:
1391 mikedld 1707
        mov     edx, esi
1708
        mov     [edi + WDATA.box.height], esi
1709
        jmp     .check_top
2436 mario79 1710
;--------------------------------------
1711
align 4
1712
.fix_top_low:
1391 mikedld 1713
        xor     ebx, ebx
1714
        mov     [edi + WDATA.box.top], ebx
1715
        jmp     .exit
2436 mario79 1716
;--------------------------------------
1717
align 4
1718
.fix_top_high:
1391 mikedld 1719
        mov     ebx, esi
1720
        sub     ebx, edx
1721
        mov     [edi + WDATA.box.top], ebx
1722
        jmp     .exit
2436 mario79 1723
;------------------------------------------------------------------------------
1362 mikedld 1724
align 4
1725
;------------------------------------------------------------------------------
1726
window._.get_titlebar_height: ;////////////////////////////////////////////////
1727
;------------------------------------------------------------------------------
1391 mikedld 1728
;? 
1729
;------------------------------------------------------------------------------
1362 mikedld 1730
;> edi = pointer to WDATA
1731
;------------------------------------------------------------------------------
1732
        mov     al, [edi + WDATA.fl_wstyle]
1733
        and     al, 0x0f
1734
        cmp     al, 0x03
1735
        jne     @f
1736
        mov     eax, [_skinh]
1737
        ret
2436 mario79 1738
;--------------------------------------
1739
align 4
1740
@@:
2288 clevermous 1741
        mov     eax, 21
1362 mikedld 1742
        ret
2436 mario79 1743
;------------------------------------------------------------------------------
1362 mikedld 1744
align 4
1745
;------------------------------------------------------------------------------
1746
window._.get_rolledup_height: ;////////////////////////////////////////////////
1747
;------------------------------------------------------------------------------
1391 mikedld 1748
;? 
1749
;------------------------------------------------------------------------------
1362 mikedld 1750
;> edi = pointer to WDATA
1751
;------------------------------------------------------------------------------
1752
        mov     al, [edi + WDATA.fl_wstyle]
1753
        and     al, 0x0f
1754
        cmp     al, 0x03
1755
        jb      @f
1756
        mov     eax, [_skinh]
1757
        add     eax, 3
1758
        ret
2436 mario79 1759
;--------------------------------------
1760
align 4
1761
@@:
2288 clevermous 1762
        or      al, al
1362 mikedld 1763
        jnz     @f
1764
        mov     eax, 21
1765
        ret
2436 mario79 1766
;--------------------------------------
1767
align 4
1768
@@:
2288 clevermous 1769
        mov     eax, 21 + 2
1362 mikedld 1770
        ret
2436 mario79 1771
;------------------------------------------------------------------------------
1362 mikedld 1772
align 4
1773
;------------------------------------------------------------------------------
1774
window._.set_screen: ;/////////////////////////////////////////////////////////
1775
;------------------------------------------------------------------------------
1776
;? Reserve window area in screen buffer
1777
;------------------------------------------------------------------------------
1778
;> eax = left
1779
;> ebx = top
1780
;> ecx = right
1781
;> edx = bottom
1782
;> esi = process number
1783
;------------------------------------------------------------------------------
1784
virtual at esp
1785
  ff_x     dd ?
1786
  ff_y     dd ?
1787
  ff_width dd ?
1788
  ff_xsz   dd ?
1789
  ff_ysz   dd ?
1790
  ff_scale dd ?
1791
end virtual
1792
 
1793
        pushad
1794
 
1795
        cmp     esi, 1
1796
        jz      .check_for_shaped_window
1797
        mov     edi, esi
1798
        shl     edi, 5
1799
        cmp     [window_data + edi + WDATA.box.width], 0
1800
        jnz     .check_for_shaped_window
1801
        cmp     [window_data + edi + WDATA.box.height], 0
1802
        jz      .exit
2436 mario79 1803
;--------------------------------------
1804
align 4
1805
.check_for_shaped_window:
1362 mikedld 1806
        mov     edi, esi
1807
        shl     edi, 8
1808
        add     edi, SLOT_BASE
1809
        cmp     [edi + APPDATA.wnd_shape], 0
1810
        jne     .shaped_window
1811
 
1812
        ; get x&y size
1813
        sub     ecx, eax
1814
        sub     edx, ebx
1815
        inc     ecx
1816
        inc     edx
1817
 
1818
        ; get WinMap start
1368 mikedld 1819
        push    esi
4424 Serge 1820
        mov     esi, [_display.width]
2446 mario79 1821
        mov     edi, [d_width_calc_area + ebx*4]
1822
 
1362 mikedld 1823
        add     edi, eax
5351 serge 1824
        add     edi, [_display.win_map]
1368 mikedld 1825
        pop     eax
1826
        mov     ah, al
1827
        push    ax
1828
        shl     eax, 16
1829
        pop     ax
2436 mario79 1830
;--------------------------------------
1831
align 4
1832
.next_line:
1362 mikedld 1833
        push    ecx
1368 mikedld 1834
        shr     ecx, 2
2288 clevermous 1835
        rep stosd
1368 mikedld 1836
        mov     ecx, [esp]
1837
        and     ecx, 3
2288 clevermous 1838
        rep stosb
1362 mikedld 1839
        pop     ecx
1368 mikedld 1840
        add     edi, esi
1362 mikedld 1841
        sub     edi, ecx
1842
        dec     edx
1843
        jnz     .next_line
1844
 
1845
        jmp     .exit
2436 mario79 1846
;--------------------------------------
1847
align 4
1848
.shaped_window:
1362 mikedld 1849
        ;  for (y=0; y <= x_size; y++)
1850
        ;      for (x=0; x <= x_size; x++)
1851
        ;          if (shape[coord(x,y,scale)]==1)
1852
        ;             set_pixel(x, y, process_number);
1853
 
1854
        sub     ecx, eax
1855
        sub     edx, ebx
1856
        inc     ecx
1857
        inc     edx
1858
 
1859
        push    [edi + APPDATA.wnd_shape_scale]  ; push scale first -> for loop
1860
 
1861
        ; get WinMap start  -> ebp
1862
        push    eax
2446 mario79 1863
        mov     eax, [d_width_calc_area + ebx*4]
1864
 
1362 mikedld 1865
        add     eax, [esp]
5351 serge 1866
        add     eax, [_display.win_map]
1362 mikedld 1867
        mov     ebp, eax
1868
 
1869
        mov     edi, [edi + APPDATA.wnd_shape]
1870
        pop     eax
1871
 
1872
        ; eax = x_start
1873
        ; ebx = y_start
1874
        ; ecx = x_size
1875
        ; edx = y_size
1876
        ; esi = process_number
1877
        ; edi = &shape
1878
        ;       [scale]
1879
        push    edx ecx ; for loop - x,y size
1880
 
1881
        mov     ecx, esi
1882
        shl     ecx, 5
1883
        mov     edx, [window_data + ecx + WDATA.box.top]
1884
        push    [window_data + ecx + WDATA.box.width]           ; for loop - width
1885
        mov     ecx, [window_data + ecx + WDATA.box.left]
1886
        sub     ebx, edx
1887
        sub     eax, ecx
1888
        push    ebx eax ; for loop - x,y
1889
 
1890
        add     [ff_xsz], eax
1891
        add     [ff_ysz], ebx
1892
 
1893
        mov     ebx, [ff_y]
2436 mario79 1894
;--------------------------------------
1895
align 4
1896
.ff_new_y:
1362 mikedld 1897
        mov     edx, [ff_x]
2436 mario79 1898
;--------------------------------------
1899
align 4
1900
.ff_new_x:
1362 mikedld 1901
        ; -- body --
1902
        mov     ecx, [ff_scale]
1903
        mov     eax, [ff_width]
1904
        inc     eax
1905
        shr     eax, cl
1906
        push    ebx edx
1907
        shr     ebx, cl
1908
        shr     edx, cl
1909
        imul    eax, ebx
1910
        add     eax, edx
1911
        pop     edx ebx
1912
        add     eax, edi
1913
        call    .read_byte
2288 clevermous 1914
        test    al, al
1362 mikedld 1915
        jz      @f
1916
        mov     eax, esi
1917
        mov     [ebp], al
1918
        ; -- end body --
2436 mario79 1919
;--------------------------------------
1920
align 4
1921
@@:
2288 clevermous 1922
        inc     ebp
1362 mikedld 1923
        inc     edx
1924
        cmp     edx, [ff_xsz]
1925
        jb      .ff_new_x
1926
 
1927
        sub     ebp, [ff_xsz]
1928
        add     ebp, [ff_x]
5350 serge 1929
        add     ebp, [_display.width]  ; screen.x
1362 mikedld 1930
        inc     ebx
1931
        cmp     ebx, [ff_ysz]
1932
        jb      .ff_new_y
1933
 
1934
        add     esp, 24
2436 mario79 1935
;--------------------------------------
1936
align 4
1937
.exit:
1362 mikedld 1938
        popad
2443 Serge 1939
        inc     [_display.mask_seqno]
1362 mikedld 1940
        ret
2436 mario79 1941
;--------------------------------------
1942
align 4
1943
.read_byte:
1362 mikedld 1944
        ; eax - address
1945
        ; esi - slot
1946
        push    eax ecx edx esi
1947
        xchg    eax, esi
1948
        lea     ecx, [esp + 12]
1949
        mov     edx, 1
1950
        call    read_process_memory
1951
        pop     esi edx ecx eax
1952
        ret
2436 mario79 1953
;------------------------------------------------------------------------------
1362 mikedld 1954
align 4
1955
;------------------------------------------------------------------------------
1956
window._.window_activate: ;////////////////////////////////////////////////////
1957
;------------------------------------------------------------------------------
1958
;? Activate window
1959
;------------------------------------------------------------------------------
1960
;> esi = pointer to WIN_POS+ window data
1961
;------------------------------------------------------------------------------
1962
        push    eax ebx
1963
 
1964
        ; if type of current active window is 3 or 4, it must be redrawn
8866 rgimad 1965
        mov     ebx, [thread_count]
5350 serge 1966
 
8866 rgimad 1967
;       DEBUGF  1, "K : thread_count (0x%x)\n", ebx
5350 serge 1968
 
1368 mikedld 1969
        movzx   ebx, word[WIN_POS + ebx * 2]
1970
        shl     ebx, 5
1362 mikedld 1971
        add     eax, window_data
1368 mikedld 1972
        mov     al, [window_data + ebx + WDATA.fl_wstyle]
1973
        and     al, 0x0f
1974
        cmp     al, 0x03
1362 mikedld 1975
        je      .set_window_redraw_flag
1368 mikedld 1976
        cmp     al, 0x04
1977
        jne     .move_others_down
2436 mario79 1978
;--------------------------------------
1979
align 4
1980
.set_window_redraw_flag:
1368 mikedld 1981
        mov     [window_data + ebx + WDATA.fl_redraw], 1
2436 mario79 1982
;--------------------------------------
1983
align 4
1984
.move_others_down:
8115 dunkaist 1985
        ; bx <- process no
1368 mikedld 1986
        movzx   ebx, word[esi]
8115 dunkaist 1987
        ; bx <- position in window stack
1368 mikedld 1988
        movzx   ebx, word[WIN_STACK + ebx * 2]
1362 mikedld 1989
 
1990
        ; drop others
1368 mikedld 1991
        xor     eax, eax
2436 mario79 1992
;--------------------------------------
1993
align 4
1994
.next_stack_window:
8866 rgimad 1995
        cmp     eax, [thread_count]
1362 mikedld 1996
        jae     .move_self_up
1368 mikedld 1997
        inc     eax
5350 serge 1998
 
2288 clevermous 1999
;       push    ebx
2000
;       xor     ebx,ebx
2001
;       mov     bx,[WIN_STACK + eax * 2]
2002
;       DEBUGF  1, "K : DEC WIN_STACK (0x%x)\n",ebx
2003
;       pop     ebx
5350 serge 2004
 
1368 mikedld 2005
        cmp     [WIN_STACK + eax * 2], bx
1362 mikedld 2006
        jbe     .next_stack_window
1368 mikedld 2007
        dec     word[WIN_STACK + eax * 2]
1362 mikedld 2008
        jmp     .next_stack_window
2436 mario79 2009
;--------------------------------------
2010
align 4
2011
.move_self_up:
1368 mikedld 2012
        movzx   ebx, word[esi]
8866 rgimad 2013
        ; number of thread
2014
        mov     ax, word [thread_count]
1362 mikedld 2015
        ; this is the last (and the upper)
1368 mikedld 2016
        mov     [WIN_STACK + ebx * 2], ax
1362 mikedld 2017
 
2018
        ; update on screen - window stack
1368 mikedld 2019
        xor     eax, eax
2436 mario79 2020
;--------------------------------------
2021
align 4
2022
.next_window_pos:
8866 rgimad 2023
        cmp     eax, [thread_count]
1362 mikedld 2024
        jae     .reset_vars
1368 mikedld 2025
        inc     eax
2026
        movzx   ebx, word[WIN_STACK + eax * 2]
2027
        mov     [WIN_POS + ebx * 2], ax
1362 mikedld 2028
        jmp     .next_window_pos
2436 mario79 2029
;--------------------------------------
2030
align 4
2031
.reset_vars:
1362 mikedld 2032
        mov     byte[KEY_COUNT], 0
2033
        mov     byte[BTN_COUNT], 0
2034
        mov     word[MOUSE_SCROLL_H], 0
2035
        mov     word[MOUSE_SCROLL_V], 0
2036
 
2037
        pop     ebx eax
2038
        ret
2244 mario79 2039
;------------------------------------------------------------------------------
2040
window._.window_deactivate: ;////////////////////////////////////////////////////
2041
;------------------------------------------------------------------------------
2042
;? Deactivate window
2043
;------------------------------------------------------------------------------
2044
;> esi = pointer to WIN_POS+ window data
2045
;------------------------------------------------------------------------------
2288 clevermous 2046
        push    eax ebx
2436 mario79 2047
;--------------------------------------
2048
align 4
2244 mario79 2049
.move_others_up:
2288 clevermous 2050
        ; ax <- process no
2051
        movzx   ebx, word[esi]
2052
        ; ax <- position in window stack
2053
        movzx   ebx, word[WIN_STACK + ebx * 2]
2054
        ; up others
2055
        xor     eax, eax
2436 mario79 2056
;--------------------------------------
2057
align 4
2244 mario79 2058
.next_stack_window:
8866 rgimad 2059
        cmp     eax, [thread_count]
2288 clevermous 2060
        jae     .move_self_down
2061
        inc     eax
2062
        cmp     [WIN_STACK + eax * 2], bx
2063
        jae     .next_stack_window
2064
        inc     word[WIN_STACK + eax * 2]
2065
        jmp     .next_stack_window
2436 mario79 2066
;--------------------------------------
2067
align 4
2244 mario79 2068
.move_self_down:
2288 clevermous 2069
        movzx   ebx, word[esi]
2070
        ; this is the last (and the low)
2071
        mov     [WIN_STACK + ebx * 2], word 1
2072
        ; update on screen - window stack
2073
        xor     eax, eax
2436 mario79 2074
;--------------------------------------
2075
align 4
2244 mario79 2076
.next_window_pos:
8866 rgimad 2077
        cmp     eax, [thread_count]
2288 clevermous 2078
        jae     .reset_vars
2079
        inc     eax
2080
        movzx   ebx, word[WIN_STACK + eax * 2]
2081
        mov     [WIN_POS + ebx * 2], ax
2082
        jmp     .next_window_pos
2436 mario79 2083
;--------------------------------------
2084
align 4
2244 mario79 2085
.reset_vars:
2288 clevermous 2086
        mov     byte[KEY_COUNT], 0
2087
        mov     byte[BTN_COUNT], 0
2088
        mov     word[MOUSE_SCROLL_H], 0
2089
        mov     word[MOUSE_SCROLL_V], 0
2090
        pop     ebx eax
2091
        ret
5350 serge 2092
;------------------------------------------------------------------------------
1362 mikedld 2093
align 4
2094
;------------------------------------------------------------------------------
2095
window._.check_window_draw: ;//////////////////////////////////////////////////
2096
;------------------------------------------------------------------------------
2097
;? Check if window is necessary to draw
2098
;------------------------------------------------------------------------------
2099
;> edi = pointer to WDATA
2100
;------------------------------------------------------------------------------
2101
        mov     cl, [edi + WDATA.fl_wstyle]
2102
        and     cl, 0x0f
1391 mikedld 2103
        cmp     cl, 3
1362 mikedld 2104
        je      .exit.redraw      ; window type 3
1391 mikedld 2105
        cmp     cl, 4
1362 mikedld 2106
        je      .exit.redraw      ; window type 4
2107
 
2108
        push    eax ebx edx esi
2109
 
2110
        mov     eax, edi
2111
        sub     eax, window_data
2112
        shr     eax, 5
2113
 
2114
        movzx   eax, word[WIN_STACK + eax * 2]  ; get value of the curr process
2115
        lea     esi, [WIN_POS + eax * 2]        ; get address of this process at 0xC400
2436 mario79 2116
;--------------------------------------
2117
align 4
2118
.next_window:
1362 mikedld 2119
        add     esi, 2
2120
 
8866 rgimad 2121
        mov     eax, [thread_count]
1362 mikedld 2122
        lea     eax, word[WIN_POS + eax * 2] ; number of the upper window
2123
 
2124
        cmp     esi, eax
2125
        ja      .exit.no_redraw
2126
 
2127
        movzx   edx, word[esi]
8869 rgimad 2128
        shl     edx, 5 ; size of TASKDATA and WDATA is 32 bytes
2129
        cmp     byte [TASK_TABLE + edx + TASKDATA.state], TSTATE_FREE
1362 mikedld 2130
        je      .next_window
2131
 
2132
        mov     eax, [edi + WDATA.box.top]
2133
        mov     ebx, [edi + WDATA.box.height]
2134
        add     ebx, eax
2135
 
2136
        mov     ecx, [window_data + edx + WDATA.box.top]
2137
        cmp     ecx, ebx
2138
        jge     .next_window
2139
        add     ecx, [window_data + edx + WDATA.box.height]
2140
        cmp     eax, ecx
2141
        jge     .next_window
2142
 
2143
        mov     eax, [edi + WDATA.box.left]
2144
        mov     ebx, [edi + WDATA.box.width]
2145
        add     ebx, eax
2146
 
2147
        mov     ecx, [window_data + edx + WDATA.box.left]
2148
        cmp     ecx, ebx
2149
        jge     .next_window
2150
        add     ecx, [window_data + edx + WDATA.box.width]
2151
        cmp     eax, ecx
2152
        jge     .next_window
2153
 
2154
        pop     esi edx ebx eax
2436 mario79 2155
;--------------------------------------
2156
align 4
2157
.exit.redraw:
1362 mikedld 2158
        xor     ecx, ecx
2159
        inc     ecx
2160
        ret
2436 mario79 2161
;--------------------------------------
2162
align 4
2163
.exit.no_redraw:
1362 mikedld 2164
        pop     esi edx ebx eax
2165
        xor     ecx, ecx
2166
        ret
2436 mario79 2167
;------------------------------------------------------------------------------
1362 mikedld 2168
align 4
2169
;------------------------------------------------------------------------------
1391 mikedld 2170
window._.draw_window_caption: ;////////////////////////////////////////////////
1362 mikedld 2171
;------------------------------------------------------------------------------
1391 mikedld 2172
;? 
1362 mikedld 2173
;------------------------------------------------------------------------------
1391 mikedld 2174
        xor     eax, eax
8866 rgimad 2175
        mov     edx, [thread_count]
1391 mikedld 2176
        movzx   edx, word[WIN_POS + edx * 2]
8869 rgimad 2177
        cmp     edx, [current_slot_idx]
1391 mikedld 2178
        jne     @f
2179
        inc     eax
2436 mario79 2180
;--------------------------------------
2181
align 4
2182
@@:
8869 rgimad 2183
        mov     edx, [current_slot_idx]
1391 mikedld 2184
        shl     edx, 5
2185
        add     edx, window_data
2186
        movzx   ebx, [edx + WDATA.fl_wstyle]
2187
        and     bl, 0x0F
2188
        cmp     bl, 3
2189
        je      .draw_caption_style_3
2190
        cmp     bl, 4
2191
        je      .draw_caption_style_3
1362 mikedld 2192
 
1391 mikedld 2193
        jmp     .not_style_3
2436 mario79 2194
;--------------------------------------
2195
align 4
2196
.draw_caption_style_3:
1391 mikedld 2197
        push    edx
2198
        call    drawwindow_IV_caption
2199
        add     esp, 4
2200
        jmp     .2
2436 mario79 2201
;--------------------------------------
2202
align 4
2203
.not_style_3:
1391 mikedld 2204
        cmp     bl, 2
2205
        jne     .not_style_2
2206
 
2207
        call    drawwindow_III_caption
2208
        jmp     .2
2436 mario79 2209
;--------------------------------------
2210
align 4
2211
.not_style_2:
1391 mikedld 2212
        cmp     bl, 0
2213
        jne     .2
2214
 
2215
        call    drawwindow_I_caption
2436 mario79 2216
;--------------------------------------
2217
align 4
2218
.2:
8869 rgimad 2219
        mov     edi, [current_slot_idx]
1391 mikedld 2220
        shl     edi, 5
2221
        test    [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
2222
        jz      .exit
2223
        mov     edx, [edi * 8 + SLOT_BASE + APPDATA.wnd_caption]
2224
        or      edx, edx
2225
        jz      .exit
2226
 
5926 pathoswith 2227
        mov     ebp, [edi + window_data + WDATA.box.left - 2]
2228
        mov     bp, word[edi + window_data + WDATA.box.top]
1391 mikedld 2229
        movzx   eax, [edi + window_data + WDATA.fl_wstyle]
2230
        and     al, 0x0F
2231
        cmp     al, 3
2232
        je      .skinned
2233
        cmp     al, 4
2234
        je      .skinned
2235
 
2236
        jmp     .not_skinned
2436 mario79 2237
;--------------------------------------
2238
align 4
2239
.skinned:
1391 mikedld 2240
        movzx   eax, word[edi + window_data + WDATA.box.width]
2241
        sub     ax, [_skinmargins.left]
2242
        sub     ax, [_skinmargins.right]
2243
        js      .exit
2244
        mov     ebx, dword[_skinmargins.left - 2]
2245
        mov     bx, word[_skinh]
2246
        sub     bx, [_skinmargins.bottom]
2247
        sub     bx, [_skinmargins.top]
2248
        sar     bx, 1
2249
        add     bx, [_skinmargins.top]
5926 pathoswith 2250
        sub     bx, 8
1391 mikedld 2251
        jmp     .dodraw
2436 mario79 2252
;--------------------------------------
2253
align 4
2254
.not_skinned:
1391 mikedld 2255
        cmp     al, 1
2256
        je      .exit
2257
        movzx   eax, word[edi + window_data + WDATA.box.width]
2258
        sub     eax, 16
2259
        js      .exit
5926 pathoswith 2260
        mov     ebx, 80002h
2261
.dodraw:
2262
        shr     eax, 3
1391 mikedld 2263
        mov     esi, eax
2264
        add     ebx, ebp
2265
        mov     ecx, [common_colours + 16]
6802 pathoswith 2266
        mov     al, [edi*8 + SLOT_BASE + APPDATA.captionEncoding]
2267
        test    al, al
2268
        jnz     @f
5926 pathoswith 2269
        mov     al, 1
2270
        cmp     byte [edx], 4
2271
        jnc     @f
2272
        mov     al, [edx]
2273
        test    al, al
2274
        jz      .exit
2275
        inc     edx
2276
@@:
2277
        shl     eax, 28
7103 0CodErr 2278
        or      ecx, eax
1391 mikedld 2279
        xor     edi, edi
7103 0CodErr 2280
        stc
2281
        call    dtext._
2436 mario79 2282
.exit:
5926 pathoswith 2283
        jmp     __sys_draw_pointer
2436 mario79 2284
;------------------------------------------------------------------------------
1391 mikedld 2285
align 4
2286
;------------------------------------------------------------------------------
2287
window._.draw_negative_box: ;//////////////////////////////////////////////////
2288
;------------------------------------------------------------------------------
2289
;? Draw negative box
2290
;------------------------------------------------------------------------------
2291
;> edi = pointer to BOX struct
2292
;------------------------------------------------------------------------------
2293
        push    eax ebx esi
2233 mario79 2294
        mov     esi, 0x01000000
2436 mario79 2295
;--------------------------------------
2296
align 4
2233 mario79 2297
.1:
1391 mikedld 2298
        mov     eax, [edi + BOX.left - 2]
2299
        mov     ax, word[edi + BOX.left]
2300
        add     ax, word[edi + BOX.width]
2301
        mov     ebx, [edi + BOX.top - 2]
2302
        mov     bx, word[edi + BOX.top]
2303
        add     bx, word[edi + BOX.height]
2304
        call    draw_rectangle.forced
2305
        pop     esi ebx eax
2306
        ret
2233 mario79 2307
;------------------------------------------------------------------------------
2669 mario79 2308
;align 4
2436 mario79 2309
;------------------------------------------------------------------------------
2669 mario79 2310
;window._.end_moving__box: ;//////////////////////////////////////////////////
2233 mario79 2311
;------------------------------------------------------------------------------
2312
;? Draw positive box
2313
;------------------------------------------------------------------------------
2314
;> edi = pointer to BOX struct
2315
;------------------------------------------------------------------------------
2669 mario79 2316
;        push    eax ebx esi
2317
;        xor     esi, esi
2318
;        jmp     window._.draw_negative_box.1
2341 Serge 2319
;------------------------------------------------------------------------------
2436 mario79 2320
align 4
2321
;------------------------------------------------------------------------------
2341 Serge 2322
window._.get_rect: ;/////////////////////////////////////////////////////
2323
;------------------------------------------------------------------------------
2324
;?   void __fastcall get_window_rect(struct RECT* rc);
2325
;------------------------------------------------------------------------------
2326
;> ecx = pointer to RECT
2327
;------------------------------------------------------------------------------
2328
        mov     eax, [TASK_BASE]
2329
 
2330
        mov     edx, [eax-twdw + WDATA.box.left]
2331
        mov     [ecx+RECT.left], edx
2332
 
2333
        add     edx, [eax-twdw + WDATA.box.width]
2334
        mov     [ecx+RECT.right], edx
2335
 
2336
        mov     edx, [eax-twdw + WDATA.box.top]
2337
        mov     [ecx+RECT.top], edx
2338
 
2339
        add     edx, [eax-twdw + WDATA.box.height]
2340
        mov     [ecx+RECT.bottom], edx
2341
        ret
2436 mario79 2342
;------------------------------------------------------------------------------
5836 GerdtR 2343
align 4
2344
;------------------------------------------------------------------------------
5865 GerdtR 2345
window._.redraw_top_wnd: ;////////////////////////////////////////////////////////
2346
;------------------------------------------------------------------------------
2347
;? redraw all windows one above the window
2348
;------------------------------------------------------------------------------
2349
;> eax = left
2350
;> ebx = top
2351
;> ecx = right
2352
;> edx = bottom
2353
;> esi = process number
2354
;! corrupted edi
2355
;------------------------------------------------------------------------------
2356
        push    0
2357
        jmp     window._.set_top_wnd.go
2358
 
2359
align 4
2360
;------------------------------------------------------------------------------
5836 GerdtR 2361
window._.set_top_wnd: ;////////////////////////////////////////////////////////
2362
;------------------------------------------------------------------------------
5865 GerdtR 2363
;? call set_screen for all windows one above the window
5836 GerdtR 2364
;------------------------------------------------------------------------------
2365
;> eax = left
2366
;> ebx = top
2367
;> ecx = right
2368
;> edx = bottom
2369
;> esi = process number
2370
;! corrupted edi
2371
;------------------------------------------------------------------------------
2372
 
5865 GerdtR 2373
        push    1
2374
.go:
5836 GerdtR 2375
        push    esi
2376
        pushfd
2377
        cli
2378
 
2379
        push    ebp
8866 rgimad 2380
        mov     ebp, [thread_count]
5836 GerdtR 2381
        cmp     ebp, 1
2382
        jbe     .exit
2383
 
5865 GerdtR 2384
        shl     esi, 5
2385
        cmp     [esi + window_data + WDATA.z_modif], ZPOS_ALWAYS_TOP
2386
        je      .exit
2387
 
5836 GerdtR 2388
        push    eax ;for num layout
2389
        push    edx ecx ebx eax
2390
 
5865 GerdtR 2391
        movsx   eax, byte [esi + window_data + WDATA.z_modif]
5836 GerdtR 2392
        inc     eax
5865 GerdtR 2393
        mov     dword[esp+10h], eax
5836 GerdtR 2394
;--------------------------------------
2395
align 4
2396
.layout:
2397
        mov     esi, 1        ; = num in window stack
8866 rgimad 2398
        mov     ebp, [thread_count]
5836 GerdtR 2399
;--------------------------------------
2400
align 4
2401
.next_window:
2402
        movzx   edi, word[WIN_POS + esi * 2]
2403
        shl     edi, 5                  ;size of TASKDATA and WDATA = 32 bytes
2404
 
8869 rgimad 2405
        cmp     byte [TASK_TABLE + edi + TASKDATA.state], TSTATE_FREE
5836 GerdtR 2406
        je      .skip_window
2407
 
2408
        add     edi, window_data
2409
        test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
2410
        jnz     .skip_window
2411
 
5865 GerdtR 2412
        mov     eax, [esp+10h]
5836 GerdtR 2413
        cmp     [edi + WDATA.z_modif], al
2414
        jne     .skip_window
2415
 
2416
        mov     eax, [edi + WDATA.box.left]
2417
        cmp     eax, [esp + RECT.right]
2418
        jg      .skip_window
2419
        mov     ebx, [edi + WDATA.box.top]
2420
        cmp     ebx, [esp + RECT.bottom]
2421
        jg      .skip_window
2422
        mov     ecx, [edi + WDATA.box.width]
2423
        add     ecx, eax
2424
        cmp     ecx, [esp + RECT.left]
2425
        jl      .skip_window
2426
        mov     edx, [edi + WDATA.box.height]
2427
        add     edx, ebx
2428
        cmp     edx, [esp + RECT.top]
2429
        jl      .skip_window
2430
 
2431
        cmp     eax, [esp + RECT.left]
2432
        jae     @f
2433
        mov     eax, [esp + RECT.left]
2434
;--------------------------------------
2435
align 4
2436
@@:
2437
        cmp     ebx, [esp + RECT.top]
2438
        jae     @f
2439
        mov     ebx, [esp + RECT.top]
2440
;--------------------------------------
2441
align 4
2442
@@:
2443
        cmp     ecx, [esp + RECT.right]
2444
        jbe     @f
2445
        mov     ecx, [esp + RECT.right]
2446
;--------------------------------------
2447
align 4
2448
@@:
2449
        cmp     edx, [esp + RECT.bottom]
2450
        jbe     @f
2451
        mov     edx, [esp + RECT.bottom]
2452
;--------------------------------------
2453
align 4
2454
@@:
5865 GerdtR 2455
        cmp     dword[esp+32], 0
2456
        je      .set_fl_redraw
2457
 
5836 GerdtR 2458
        push    esi
2459
        movzx   esi, word[WIN_POS + esi * 2]
2460
        call    window._.set_screen
2461
        pop     esi
5865 GerdtR 2462
        jmp     @f
2463
.set_fl_redraw:
5836 GerdtR 2464
        mov     [edi + WDATA.fl_redraw], 1      ;set redraw flag
5865 GerdtR 2465
     @@:
5836 GerdtR 2466
;--------------------------------------
2467
align 4
2468
.skip_window:
2469
        inc     esi
2470
        dec     ebp
2471
        jnz     .next_window
2472
;--------------------------------------
5865 GerdtR 2473
        inc     dword[esp+10h]
2474
        cmp     byte[esp+10h], ZPOS_ALWAYS_TOP
2475
        jle     .layout
5836 GerdtR 2476
;-------------------------------------
2477
 
2478
        pop     eax ebx ecx edx
2479
        pop     ebp     ;del num layout
2480
;-------------------------------------
2481
align 4
2482
.exit:
2483
 
2484
        pop     ebp
2485
        popfd
2486
        pop     esi
2487
 
5865 GerdtR 2488
        add     esp, 4   ;dword for 0/1 - set_screen/fl_redraw
5836 GerdtR 2489
        ret
2490