Subversion Repositories Kolibri OS

Rev

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