Subversion Repositories Kolibri OS

Rev

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