Subversion Repositories Kolibri OS

Rev

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