Subversion Repositories Kolibri OS

Rev

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

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