Subversion Repositories Kolibri OS

Rev

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

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