Subversion Repositories Kolibri OS

Rev

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: 9932 $
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
9930 Doczom 81
        mov     edx, [current_slot]
82
        mov     edx, [edx + APPDATA.window]
83
        add     eax, [edx + WDATA.box.left]
84
        add     ebx, [edx + WDATA.box.top]
85
        add     eax, [edx + WDATA.clientbox.left]
86
        add     ebx, [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
 
9930 Doczom 106
        mov     eax, [current_slot]
107
        mov     eax, [eax + APPDATA.window]
108
        mov     ebp, [eax + WDATA.box.left]
109
        add     ebp, [eax + WDATA.clientbox.left]
9477 rgimad 110
        shl     ebp, 16
9930 Doczom 111
        add     ebp, [eax + WDATA.box.top]
112
        add     bp, word[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
9930 Doczom 150
        mov     esi, [current_slot]
151
        mov     esi, [esi + APPDATA.window]
152
        add     eax, [esi + WDATA.clientbox.left]
153
        add     ebx, [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:
9930 Doczom 164
        mov     edi, [current_slot]
165
        mov     edi, [edi + APPDATA.window]
166
        movzx   eax, word[edi + WDATA.box.left]
9477 rgimad 167
        mov     ebp, eax
9930 Doczom 168
        add     ebp, [edi + WDATA.clientbox.left]
169
        add     ax, word[edi + WDATA.clientbox.left]
9477 rgimad 170
        add     ebp, ebx
171
        shl     eax, 16
9930 Doczom 172
        movzx   ebx, word[edi + WDATA.box.top]
9477 rgimad 173
        add     eax, ebp
174
        mov     ebp, ebx
9930 Doczom 175
        add     ebp, [edi + WDATA.clientbox.top]
176
        add     bx, word[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:
9930 Doczom 486
        mov     edi, [current_slot]
487
        mov     edi, [edi + APPDATA.window]
488
        or      [edi + 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
@@:
9930 Doczom 497
        mov     [edi + WDATA.caption], ecx
498
        mov     [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:
9930 Doczom 504
        mov     byte [background_window + 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]
9930 Doczom 558
        shl     edi, BSF sizeof.WDATA
1362 mikedld 559
 
9930 Doczom 560
        test    byte [window_data + edi + WDATA.fl_wstate], WSTATE_USED
561
        jz      .skip_window
1362 mikedld 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?
9930 Doczom 1089
        test    byte [window_data + edi + WDATA.fl_wstate], WSTATE_USED
1090
        jz      @f
2648 mario79 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?
9930 Doczom 1096
        test    [window_data + edi + WDATA.fl_wstate], WSTATE_MINIMIZED
2648 mario79 1097
        jnz     @f
1098
; no it's not, let's do that
9930 Doczom 1099
        or      [window_data + edi + WDATA.fl_wstate], WSTATE_MINIMIZED
2648 mario79 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:
9930 Doczom 1294
        push    [edi + WDATA.saved_box.height] \
1295
                [edi + WDATA.saved_box.width] \
1296
                [edi + WDATA.saved_box.top] \
1297
                [edi + WDATA.saved_box.left]
1391 mikedld 1298
        mov     eax, esp
2436 mario79 1299
;--------------------------------------
1300
align 4
1301
.set_box:
1391 mikedld 1302
        test    bl, WSTATE_ROLLEDUP
1303
        jz      @f
1362 mikedld 1304
 
1391 mikedld 1305
        xchg    eax, ecx
1306
        call    window._.get_rolledup_height
1307
        mov     [ecx + BOX.height], eax
1308
        xchg    eax, ecx
2436 mario79 1309
;--------------------------------------
1310
align 4
1311
@@:
2288 clevermous 1312
        call    window._.set_window_box
2381 hidnplayr 1313
        add     esp, sizeof.BOX
2436 mario79 1314
;--------------------------------------
1315
align 4
1316
.exit:
2443 Serge 1317
        inc     [_display.mask_seqno]
1391 mikedld 1318
        ret
2436 mario79 1319
;------------------------------------------------------------------------------
9477 rgimad 1320
 
1321
 
1391 mikedld 1322
align 4
1323
;> esi = process slot
9477 rgimad 1324
sys_window_rollup_handler:
1391 mikedld 1325
        ; toggle normal/rolled up window state
1326
        mov     bl, [edi + WDATA.fl_wstate]
1327
        xor     bl, WSTATE_ROLLEDUP
1362 mikedld 1328
 
1391 mikedld 1329
        ; calculate and set appropriate window bounds
1330
        test    bl, WSTATE_ROLLEDUP
1331
        jz      .restore_size
1362 mikedld 1332
 
1391 mikedld 1333
        call    window._.get_rolledup_height
1334
        push    eax \
1335
                [edi + WDATA.box.width] \
1336
                [edi + WDATA.box.top] \
1337
                [edi + WDATA.box.left]
1338
        mov     eax, esp
1339
        jmp     .set_box
2436 mario79 1340
;--------------------------------------
1341
align 4
1342
.restore_size:
1391 mikedld 1343
        test    bl, WSTATE_MAXIMIZED
1344
        jnz     @f
2381 hidnplayr 1345
        add     esp, -sizeof.BOX
9930 Doczom 1346
        lea     eax, [edi + WDATA.saved_box]
1391 mikedld 1347
        jmp     .set_box
2436 mario79 1348
;--------------------------------------
1349
align 4
1350
@@:
2288 clevermous 1351
        mov     eax, [screen_workarea.top]
1391 mikedld 1352
        push    [screen_workarea.bottom] \
1353
                [edi + WDATA.box.width] \
1354
                eax \
1355
                [edi + WDATA.box.left]
1356
        sub     [esp + BOX.height], eax
1357
        mov     eax, esp
2436 mario79 1358
;--------------------------------------
1359
align 4
1360
.set_box:
1391 mikedld 1361
        call    window._.set_window_box
2381 hidnplayr 1362
        add     esp, sizeof.BOX
1391 mikedld 1363
        ret
2436 mario79 1364
;------------------------------------------------------------------------------
1391 mikedld 1365
align 4
1366
;------------------------------------------------------------------------------
9477 rgimad 1367
;sys_window_start_moving_handler:
1391 mikedld 1368
;------------------------------------------------------------------------------
1369
;? 
1370
;------------------------------------------------------------------------------
1371
;> eax = old (original) window box
1372
;> esi = process slot
1373
;------------------------------------------------------------------------------
2669 mario79 1374
;        mov     edi, eax
1375
;        call    window._.draw_negative_box
1376
;        ret
2436 mario79 1377
;------------------------------------------------------------------------------
9477 rgimad 1378
 
1379
 
1391 mikedld 1380
align 4
1381
;> eax = old (original) window box
1382
;> ebx = new (final) window box
1383
;> esi = process slot
9477 rgimad 1384
sys_window_end_moving_handler:
2669 mario79 1385
;        mov     edi, ebx
1386
;        call    window._.end_moving__box
1362 mikedld 1387
 
1391 mikedld 1388
        mov     edi, esi
9709 Doczom 1389
        shl     edi, BSF sizeof.WDATA
1391 mikedld 1390
        add     edi, window_data
1362 mikedld 1391
 
5870 GerdtR 1392
        test    [fl_moving], 1
1393
        jz      @f
1394
 
1395
        push    edi
1396
        mov     edi, ebx
1397
        call    window._.draw_negative_box
1398
        pop     edi
1399
    @@:
1400
 
1391 mikedld 1401
        mov     eax, ebx
1402
        mov     bl, [edi + WDATA.fl_wstate]
1403
        call    window._.set_window_box
1404
        ret
2436 mario79 1405
;------------------------------------------------------------------------------
9477 rgimad 1406
 
1407
 
1391 mikedld 1408
align 4
1409
;> eax = old (from previous call) window box
1410
;> ebx = new (current) window box
1411
;> esi = process_slot
9477 rgimad 1412
sys_window_moving_handler:
1391 mikedld 1413
        mov     edi, eax
1414
        call    window._.draw_negative_box
1415
        mov     edi, ebx
1416
        call    window._.draw_negative_box
1417
        ret
9477 rgimad 1418
 
1419
 
1420
 
1421
 
1391 mikedld 1422
;==============================================================================
9477 rgimad 1423
;      private functions
1391 mikedld 1424
;==============================================================================
1362 mikedld 1425
 
1391 mikedld 1426
iglobal
6800 pathoswith 1427
align 4
1428
window_topleft  dd \
1391 mikedld 1429
    1, 21, \ ;type 0
1430
    0,  0, \ ;type 1
1431
    5, 20, \ ;type 2
1432
    5,  ?, \ ;type 3 {set by skin}
1433
    5,  ?    ;type 4 {set by skin}
1434
endg
1362 mikedld 1435
 
2436 mario79 1436
;------------------------------------------------------------------------------
9477 rgimad 1437
 
1438
 
1391 mikedld 1439
align 4
1440
;> eax = old (original) window box
1441
;> ebx = new (final) window box
1442
;> edi = pointer to WDATA struct
9477 rgimad 1443
window._.invalidate_screen:
1362 mikedld 1444
        push    eax ebx
1445
 
1391 mikedld 1446
        ; TODO: do we really need `draw_limits`?
1550 diamond 1447
        ; Yes, they are used by background drawing code.
2514 mario79 1448
 
1449
; we need only to restore the background windows at the old place!
1450
        mov     ecx, [ebx + BOX.left]
2288 clevermous 1451
        mov     [draw_limits.left], ecx
2514 mario79 1452
        add     ecx, [ebx + BOX.width]
2288 clevermous 1453
        mov     [draw_limits.right], ecx
2514 mario79 1454
        mov     ecx, [ebx + BOX.top]
2288 clevermous 1455
        mov     [draw_limits.top], ecx
2514 mario79 1456
        add     ecx, [ebx + BOX.height]
2288 clevermous 1457
        mov     [draw_limits.bottom], ecx
2514 mario79 1458
; recalculate screen buffer at old position
1391 mikedld 1459
        push    ebx
1460
        mov     edx, [eax + BOX.height]
1461
        mov     ecx, [eax + BOX.width]
1462
        mov     ebx, [eax + BOX.top]
1463
        mov     eax, [eax + BOX.left]
1464
        add     ecx, eax
1465
        add     edx, ebx
1466
        call    calculatescreen
1467
        pop     eax
2514 mario79 1468
; recalculate screen buffer at new position
1391 mikedld 1469
        mov     edx, [eax + BOX.height]
1470
        mov     ecx, [eax + BOX.width]
1471
        mov     ebx, [eax + BOX.top]
1472
        mov     eax, [eax + BOX.left]
1473
        add     ecx, eax
1474
        add     edx, ebx
1475
        call    calculatescreen
1362 mikedld 1476
 
1391 mikedld 1477
        mov     eax, edi
1478
        call    redrawscreen
1362 mikedld 1479
 
1391 mikedld 1480
        ; tell window to redraw itself
1481
        mov     [edi + WDATA.fl_redraw], 1
1362 mikedld 1482
 
1391 mikedld 1483
        pop     ebx eax
1484
        ret
2436 mario79 1485
;------------------------------------------------------------------------------
9477 rgimad 1486
 
1487
 
1391 mikedld 1488
align 4
1489
;> eax = pointer to BOX struct
1490
;> bl = new window state flags
1491
;> edi = pointer to WDATA struct
9477 rgimad 1492
window._.set_window_box:
1391 mikedld 1493
        push    eax ebx esi
1362 mikedld 1494
 
1474 diamond 1495
; don't do anything if the new box is identical to the old
2288 clevermous 1496
        cmp     bl, [edi + WDATA.fl_wstate]
1497
        jnz     @f
1498
        mov     esi, eax
1499
        push    edi
1474 diamond 1500
if WDATA.box
2288 clevermous 1501
        add     edi, WDATA.box
1474 diamond 1502
end if
2288 clevermous 1503
        mov     ecx, 4
1504
        repz cmpsd
1505
        pop     edi
1506
        jz      .exit
2436 mario79 1507
;--------------------------------------
1508
align 4
1474 diamond 1509
@@:
2381 hidnplayr 1510
        add     esp, -sizeof.BOX
1391 mikedld 1511
        mov     ebx, esp
1424 diamond 1512
if WDATA.box
1391 mikedld 1513
        lea     esi, [edi + WDATA.box]
1424 diamond 1514
else
2288 clevermous 1515
        mov     esi, edi ; optimization for WDATA.box = 0
1424 diamond 1516
end if
1391 mikedld 1517
        xchg    eax, esi
2381 hidnplayr 1518
        mov     ecx, sizeof.BOX
1391 mikedld 1519
        call    memmove
1520
        xchg    eax, esi
1521
        xchg    ebx, esi
1522
        call    memmove
1424 diamond 1523
        mov     eax, ebx
1524
        mov     ebx, esi
1391 mikedld 1525
        call    window._.check_window_position
1526
        call    window._.set_window_clientbox
1527
        call    window._.invalidate_screen
1362 mikedld 1528
 
2381 hidnplayr 1529
        add     esp, sizeof.BOX
1362 mikedld 1530
 
1391 mikedld 1531
        mov     cl, [esp + 4]
1532
        mov     ch, cl
1533
        xchg    cl, [edi + WDATA.fl_wstate]
1362 mikedld 1534
 
1391 mikedld 1535
        or      cl, ch
1536
        test    cl, WSTATE_MAXIMIZED
1537
        jnz     .exit
1362 mikedld 1538
 
1391 mikedld 1539
        lea     ebx, [edi + WDATA.box]
1540
        xchg    esp, ebx
1362 mikedld 1541
 
9930 Doczom 1542
        pop     [edi + WDATA.saved_box.left] \
1543
                [edi + WDATA.saved_box.top] \
1544
                [edi + WDATA.saved_box.width] \
1391 mikedld 1545
                edx
1362 mikedld 1546
 
1391 mikedld 1547
        xchg    esp, ebx
1362 mikedld 1548
 
1391 mikedld 1549
        test    ch, WSTATE_ROLLEDUP
1550
        jnz     .exit
1362 mikedld 1551
 
9930 Doczom 1552
        mov     [edi + WDATA.saved_box.height], edx
2436 mario79 1553
;--------------------------------------
1554
align 4
1555
.exit:
1391 mikedld 1556
        pop     esi ebx eax
1557
        ret
2436 mario79 1558
;------------------------------------------------------------------------------
9477 rgimad 1559
 
1560
 
1391 mikedld 1561
align 4
1562
;> edi = pointer to WDATA struct
9477 rgimad 1563
window._.set_window_clientbox:
1391 mikedld 1564
        push    eax ecx edi
1362 mikedld 1565
 
1391 mikedld 1566
        mov     eax, [_skinh]
1567
        mov     [window_topleft + 8 * 3 + 4], eax
1568
        mov     [window_topleft + 8 * 4 + 4], eax
1362 mikedld 1569
 
1391 mikedld 1570
        mov     ecx, edi
1571
        test    [ecx + WDATA.fl_wstyle], WSTYLE_CLIENTRELATIVE
1572
        jz      .whole_window
1362 mikedld 1573
 
1391 mikedld 1574
        movzx   eax, [ecx + WDATA.fl_wstyle]
1575
        and     eax, 0x0F
1576
        mov     eax, [eax * 8 + window_topleft + 0]
9926 Doczom 1577
        mov     [ecx + WDATA.clientbox.left], eax
1391 mikedld 1578
        shl     eax, 1
1579
        neg     eax
1580
        add     eax, [ecx + WDATA.box.width]
8012 leency 1581
        inc     eax  ;Leency: as window is created width+1 so client the same
9926 Doczom 1582
        mov     [ecx + WDATA.clientbox.width], eax
1362 mikedld 1583
 
1391 mikedld 1584
        movzx   eax, [ecx + WDATA.fl_wstyle]
1585
        and     eax, 0x0F
1586
        push    [eax * 8 + window_topleft + 0]
1587
        mov     eax, [eax * 8 + window_topleft + 4]
9926 Doczom 1588
        mov     [ecx + WDATA.clientbox.top], eax
1391 mikedld 1589
        neg     eax
1590
        sub     eax, [esp]
1591
        add     eax, [ecx + WDATA.box.height]
8012 leency 1592
        inc     eax  ;Leency: as window is created height+1 so client the same
9926 Doczom 1593
        mov     [ecx + WDATA.clientbox.height], eax
1391 mikedld 1594
        add     esp, 4
1595
        jmp     .exit
2436 mario79 1596
;--------------------------------------
1597
align 4
1598
.whole_window:
1391 mikedld 1599
        xor     eax, eax
9926 Doczom 1600
        mov     [ecx + WDATA.clientbox.left], eax
1601
        mov     [ecx + WDATA.clientbox.top], eax
1391 mikedld 1602
        mov     eax, [ecx + WDATA.box.width]
9926 Doczom 1603
        mov     [ecx + WDATA.clientbox.width], eax
1391 mikedld 1604
        mov     eax, [ecx + WDATA.box.height]
9926 Doczom 1605
        mov     [ecx + WDATA.clientbox.height], eax
2436 mario79 1606
;--------------------------------------
1607
align 4
1608
.exit:
1391 mikedld 1609
        pop     edi ecx eax
1610
        ret
2436 mario79 1611
;------------------------------------------------------------------------------
9477 rgimad 1612
 
1613
 
1391 mikedld 1614
align 4
1615
;< edx = pointer to WDATA struct
9477 rgimad 1616
window._.sys_set_window:
8869 rgimad 1617
        mov     eax, [current_slot_idx]
9709 Doczom 1618
        shl     eax, BSF sizeof.WDATA
1391 mikedld 1619
        add     eax, window_data
5926 pathoswith 1620
; save window colors
1391 mikedld 1621
        mov     [eax + WDATA.cl_workarea], edx
1622
        mov     [eax + WDATA.cl_titlebar], esi
1623
        mov     [eax + WDATA.cl_frames], edi
1624
        mov     edi, eax
5926 pathoswith 1625
; Was it already defined before?
1391 mikedld 1626
        test    [edi + WDATA.fl_wdrawn], 1
1627
        jnz     .set_client_box
5926 pathoswith 1628
; No, it wasn't. After first draw_window we need redraw mouse necessarily!
1629
; Otherwise the user can see cursor specified by f.37.5 from another window.
1630
; He will be really unhappy! Usually, he will be enraged!
1563 diamond 1631
        or      [edi + WDATA.fl_wdrawn], 1
2503 mario79 1632
        mov     [redrawmouse_unconditional], 1
3534 clevermous 1633
        call    wakeup_osloop
5926 pathoswith 1634
; performing initial window definition
1391 mikedld 1635
        movzx   eax, bx
1362 mikedld 1636
        mov     [edi + WDATA.box.width], eax
1391 mikedld 1637
        movzx   eax, cx
1362 mikedld 1638
        mov     [edi + WDATA.box.height], eax
1391 mikedld 1639
        sar     ebx, 16
1640
        sar     ecx, 16
1641
        mov     [edi + WDATA.box.left], ebx
1642
        mov     [edi + WDATA.box.top], ecx
1362 mikedld 1643
 
1391 mikedld 1644
        call    window._.check_window_position
1362 mikedld 1645
 
1391 mikedld 1646
        push    ecx edi
1362 mikedld 1647
 
1391 mikedld 1648
        mov     cl, [edi + WDATA.fl_wstyle]
1649
        mov     eax, [edi + WDATA.cl_frames]
1362 mikedld 1650
 
9926 Doczom 1651
        mov     esi, [esp]
1362 mikedld 1652
 
1391 mikedld 1653
        and     cl, 0x0F
1654
        cmp     cl, 3
1655
        je      @f
1656
        cmp     cl, 4
1657
        je      @f
1362 mikedld 1658
 
1391 mikedld 1659
        xor     eax, eax
2436 mario79 1660
;--------------------------------------
1661
align 4
1662
@@:
9926 Doczom 1663
        mov     [esi + WDATA.caption], eax
1362 mikedld 1664
 
9930 Doczom 1665
        add     edi, WDATA.saved_box
1391 mikedld 1666
        movsd
1667
        movsd
1668
        movsd
1669
        movsd
1362 mikedld 1670
 
1391 mikedld 1671
        pop     edi ecx
1672
 
8869 rgimad 1673
        mov     esi, [current_slot_idx]
1391 mikedld 1674
        movzx   esi, word[WIN_STACK + esi * 2]
1675
        lea     esi, [WIN_POS + esi * 2]
1676
        call    waredraw
1677
 
1362 mikedld 1678
        mov     eax, [edi + WDATA.box.left]
1679
        mov     ebx, [edi + WDATA.box.top]
1680
        mov     ecx, [edi + WDATA.box.width]
1681
        mov     edx, [edi + WDATA.box.height]
1682
        add     ecx, eax
1683
        add     edx, ebx
1684
        call    calculatescreen
1685
 
1391 mikedld 1686
        mov     byte[KEY_COUNT], 0           ; empty keyboard buffer
1687
        mov     byte[BTN_COUNT], 0           ; empty button buffer
2436 mario79 1688
;--------------------------------------
1689
align 4
1690
.set_client_box:
1391 mikedld 1691
        ; update window client box coordinates
1692
        call    window._.set_window_clientbox
1362 mikedld 1693
 
1391 mikedld 1694
        ; reset window redraw flag and exit
1695
        mov     [edi + WDATA.fl_redraw], 0
1696
        mov     edx, edi
1697
        ret
2436 mario79 1698
;------------------------------------------------------------------------------
9477 rgimad 1699
 
1700
 
1391 mikedld 1701
align 4
1702
;? Check if window is inside screen area
1703
;> edi = pointer to WDATA
9477 rgimad 1704
window._.check_window_position:
1391 mikedld 1705
        push    eax ebx ecx edx esi
1362 mikedld 1706
 
1391 mikedld 1707
        mov     eax, [edi + WDATA.box.left]
1708
        mov     ebx, [edi + WDATA.box.top]
1709
        mov     ecx, [edi + WDATA.box.width]
1710
        mov     edx, [edi + WDATA.box.height]
1362 mikedld 1711
 
5350 serge 1712
        mov     esi, [_display.width]
1391 mikedld 1713
        cmp     ecx, esi
5350 serge 1714
        jae     .fix_width_high
2436 mario79 1715
;--------------------------------------
1716
align 4
1717
.check_left:
1391 mikedld 1718
        or      eax, eax
1719
        jl      .fix_left_low
1720
        add     eax, ecx
1721
        cmp     eax, esi
5350 serge 1722
        jge     .fix_left_high
2436 mario79 1723
;--------------------------------------
1724
align 4
1725
.check_height:
5350 serge 1726
        mov     esi, [_display.height]
1391 mikedld 1727
        cmp     edx, esi
5350 serge 1728
        jae     .fix_height_high
2436 mario79 1729
;--------------------------------------
1730
align 4
1731
.check_top:
1391 mikedld 1732
        or      ebx, ebx
1733
        jl      .fix_top_low
1734
        add     ebx, edx
1735
        cmp     ebx, esi
5350 serge 1736
        jge     .fix_top_high
2436 mario79 1737
;--------------------------------------
1738
align 4
1739
.exit:
1391 mikedld 1740
        pop     esi edx ecx ebx eax
1362 mikedld 1741
        ret
2436 mario79 1742
;--------------------------------------
1743
align 4
1744
.fix_width_high:
1391 mikedld 1745
        mov     ecx, esi
8928 dunkaist 1746
        dec     ecx
1747
        mov     [edi + WDATA.box.width], ecx
1391 mikedld 1748
        jmp     .check_left
2436 mario79 1749
;--------------------------------------
1750
align 4
1751
.fix_left_low:
1391 mikedld 1752
        xor     eax, eax
1753
        mov     [edi + WDATA.box.left], eax
1754
        jmp     .check_height
2436 mario79 1755
;--------------------------------------
1756
align 4
1757
.fix_left_high:
1391 mikedld 1758
        mov     eax, esi
1759
        sub     eax, ecx
8928 dunkaist 1760
        dec     eax
1391 mikedld 1761
        mov     [edi + WDATA.box.left], eax
1762
        jmp     .check_height
2436 mario79 1763
;--------------------------------------
1764
align 4
1765
.fix_height_high:
1391 mikedld 1766
        mov     edx, esi
8928 dunkaist 1767
        dec     edx
1768
        mov     [edi + WDATA.box.height], edx
1391 mikedld 1769
        jmp     .check_top
2436 mario79 1770
;--------------------------------------
1771
align 4
1772
.fix_top_low:
1391 mikedld 1773
        xor     ebx, ebx
1774
        mov     [edi + WDATA.box.top], ebx
1775
        jmp     .exit
2436 mario79 1776
;--------------------------------------
1777
align 4
1778
.fix_top_high:
1391 mikedld 1779
        mov     ebx, esi
1780
        sub     ebx, edx
8928 dunkaist 1781
        dec     ebx
1391 mikedld 1782
        mov     [edi + WDATA.box.top], ebx
1783
        jmp     .exit
2436 mario79 1784
;------------------------------------------------------------------------------
9477 rgimad 1785
 
1786
 
1362 mikedld 1787
align 4
1788
;> edi = pointer to WDATA
9477 rgimad 1789
window._.get_titlebar_height:
1362 mikedld 1790
        mov     al, [edi + WDATA.fl_wstyle]
1791
        and     al, 0x0f
1792
        cmp     al, 0x03
1793
        jne     @f
1794
        mov     eax, [_skinh]
1795
        ret
2436 mario79 1796
;--------------------------------------
1797
align 4
1798
@@:
2288 clevermous 1799
        mov     eax, 21
1362 mikedld 1800
        ret
2436 mario79 1801
;------------------------------------------------------------------------------
9477 rgimad 1802
 
1803
 
1362 mikedld 1804
align 4
1805
;> edi = pointer to WDATA
9477 rgimad 1806
window._.get_rolledup_height:
1362 mikedld 1807
        mov     al, [edi + WDATA.fl_wstyle]
1808
        and     al, 0x0f
1809
        cmp     al, 0x03
1810
        jb      @f
1811
        mov     eax, [_skinh]
1812
        add     eax, 3
1813
        ret
2436 mario79 1814
;--------------------------------------
1815
align 4
1816
@@:
2288 clevermous 1817
        or      al, al
1362 mikedld 1818
        jnz     @f
1819
        mov     eax, 21
1820
        ret
2436 mario79 1821
;--------------------------------------
1822
align 4
1823
@@:
2288 clevermous 1824
        mov     eax, 21 + 2
1362 mikedld 1825
        ret
2436 mario79 1826
;------------------------------------------------------------------------------
9477 rgimad 1827
 
1828
 
1362 mikedld 1829
align 4
1830
;? Reserve window area in screen buffer
1831
;> eax = left
1832
;> ebx = top
1833
;> ecx = right
1834
;> edx = bottom
1835
;> esi = process number
9477 rgimad 1836
window._.set_screen:
1362 mikedld 1837
virtual at esp
1838
  ff_x     dd ?
1839
  ff_y     dd ?
1840
  ff_width dd ?
1841
  ff_xsz   dd ?
1842
  ff_ysz   dd ?
1843
  ff_scale dd ?
1844
end virtual
1845
 
1846
        pushad
1847
 
9926 Doczom 1848
        mov     edi, esi
1849
        shl     edi, BSF sizeof.WDATA
1850
 
1362 mikedld 1851
        cmp     esi, 1
1852
        jz      .check_for_shaped_window
9926 Doczom 1853
 
1362 mikedld 1854
        cmp     [window_data + edi + WDATA.box.width], 0
1855
        jnz     .check_for_shaped_window
1856
        cmp     [window_data + edi + WDATA.box.height], 0
1857
        jz      .exit
2436 mario79 1858
;--------------------------------------
1859
align 4
1860
.check_for_shaped_window:
9926 Doczom 1861
        cmp     [window_data + edi + WDATA.shape], 0
1362 mikedld 1862
        jne     .shaped_window
1863
 
1864
        ; get x&y size
1865
        sub     ecx, eax
1866
        sub     edx, ebx
1867
        inc     ecx
1868
        inc     edx
1869
 
1870
        ; get WinMap start
1368 mikedld 1871
        push    esi
4424 Serge 1872
        mov     esi, [_display.width]
2446 mario79 1873
        mov     edi, [d_width_calc_area + ebx*4]
1874
 
1362 mikedld 1875
        add     edi, eax
5351 serge 1876
        add     edi, [_display.win_map]
1368 mikedld 1877
        pop     eax
1878
        mov     ah, al
1879
        push    ax
1880
        shl     eax, 16
1881
        pop     ax
2436 mario79 1882
;--------------------------------------
1883
align 4
1884
.next_line:
1362 mikedld 1885
        push    ecx
1368 mikedld 1886
        shr     ecx, 2
2288 clevermous 1887
        rep stosd
1368 mikedld 1888
        mov     ecx, [esp]
1889
        and     ecx, 3
2288 clevermous 1890
        rep stosb
1362 mikedld 1891
        pop     ecx
1368 mikedld 1892
        add     edi, esi
1362 mikedld 1893
        sub     edi, ecx
1894
        dec     edx
1895
        jnz     .next_line
1896
 
1897
        jmp     .exit
2436 mario79 1898
;--------------------------------------
1899
align 4
1900
.shaped_window:
1362 mikedld 1901
        ;  for (y=0; y <= x_size; y++)
1902
        ;      for (x=0; x <= x_size; x++)
1903
        ;          if (shape[coord(x,y,scale)]==1)
1904
        ;             set_pixel(x, y, process_number);
1905
 
1906
        sub     ecx, eax
1907
        sub     edx, ebx
1908
        inc     ecx
1909
        inc     edx
1910
 
9926 Doczom 1911
        push    [window_data + edi + WDATA.shape_scale]  ; push scale first -> for loop
1362 mikedld 1912
 
1913
        ; get WinMap start  -> ebp
1914
        push    eax
2446 mario79 1915
        mov     eax, [d_width_calc_area + ebx*4]
1916
 
1362 mikedld 1917
        add     eax, [esp]
5351 serge 1918
        add     eax, [_display.win_map]
1362 mikedld 1919
        mov     ebp, eax
1920
 
9926 Doczom 1921
        mov     edi, [window_data + edi + WDATA.shape]
1362 mikedld 1922
        pop     eax
1923
 
1924
        ; eax = x_start
1925
        ; ebx = y_start
1926
        ; ecx = x_size
1927
        ; edx = y_size
1928
        ; esi = process_number
1929
        ; edi = &shape
1930
        ;       [scale]
1931
        push    edx ecx ; for loop - x,y size
1932
 
1933
        mov     ecx, esi
9709 Doczom 1934
        shl     ecx, BSF sizeof.WDATA
1362 mikedld 1935
        mov     edx, [window_data + ecx + WDATA.box.top]
1936
        push    [window_data + ecx + WDATA.box.width]           ; for loop - width
1937
        mov     ecx, [window_data + ecx + WDATA.box.left]
1938
        sub     ebx, edx
1939
        sub     eax, ecx
1940
        push    ebx eax ; for loop - x,y
1941
 
1942
        add     [ff_xsz], eax
1943
        add     [ff_ysz], ebx
1944
 
1945
        mov     ebx, [ff_y]
2436 mario79 1946
;--------------------------------------
1947
align 4
1948
.ff_new_y:
1362 mikedld 1949
        mov     edx, [ff_x]
2436 mario79 1950
;--------------------------------------
1951
align 4
1952
.ff_new_x:
1362 mikedld 1953
        ; -- body --
1954
        mov     ecx, [ff_scale]
1955
        mov     eax, [ff_width]
1956
        inc     eax
1957
        shr     eax, cl
1958
        push    ebx edx
1959
        shr     ebx, cl
1960
        shr     edx, cl
1961
        imul    eax, ebx
1962
        add     eax, edx
1963
        pop     edx ebx
1964
        add     eax, edi
1965
        call    .read_byte
2288 clevermous 1966
        test    al, al
1362 mikedld 1967
        jz      @f
1968
        mov     eax, esi
1969
        mov     [ebp], al
1970
        ; -- end body --
2436 mario79 1971
;--------------------------------------
1972
align 4
1973
@@:
2288 clevermous 1974
        inc     ebp
1362 mikedld 1975
        inc     edx
1976
        cmp     edx, [ff_xsz]
1977
        jb      .ff_new_x
1978
 
1979
        sub     ebp, [ff_xsz]
1980
        add     ebp, [ff_x]
5350 serge 1981
        add     ebp, [_display.width]  ; screen.x
1362 mikedld 1982
        inc     ebx
1983
        cmp     ebx, [ff_ysz]
1984
        jb      .ff_new_y
1985
 
1986
        add     esp, 24
2436 mario79 1987
;--------------------------------------
1988
align 4
1989
.exit:
1362 mikedld 1990
        popad
2443 Serge 1991
        inc     [_display.mask_seqno]
1362 mikedld 1992
        ret
2436 mario79 1993
;--------------------------------------
1994
align 4
1995
.read_byte:
1362 mikedld 1996
        ; eax - address
1997
        ; esi - slot
1998
        push    eax ecx edx esi
1999
        xchg    eax, esi
2000
        lea     ecx, [esp + 12]
2001
        mov     edx, 1
2002
        call    read_process_memory
2003
        pop     esi edx ecx eax
2004
        ret
2436 mario79 2005
;------------------------------------------------------------------------------
9477 rgimad 2006
 
2007
 
1362 mikedld 2008
align 4
9477 rgimad 2009
; Activate window
2010
; esi = pointer to WIN_POS+ window data
2011
window._.window_activate:
1362 mikedld 2012
        push    eax ebx
2013
 
2014
        ; if type of current active window is 3 or 4, it must be redrawn
8866 rgimad 2015
        mov     ebx, [thread_count]
5350 serge 2016
 
8866 rgimad 2017
;       DEBUGF  1, "K : thread_count (0x%x)\n", ebx
5350 serge 2018
 
1368 mikedld 2019
        movzx   ebx, word[WIN_POS + ebx * 2]
9709 Doczom 2020
        shl     ebx, BSF sizeof.WDATA
1362 mikedld 2021
        add     eax, window_data
1368 mikedld 2022
        mov     al, [window_data + ebx + WDATA.fl_wstyle]
2023
        and     al, 0x0f
2024
        cmp     al, 0x03
1362 mikedld 2025
        je      .set_window_redraw_flag
1368 mikedld 2026
        cmp     al, 0x04
2027
        jne     .move_others_down
2436 mario79 2028
;--------------------------------------
2029
align 4
2030
.set_window_redraw_flag:
1368 mikedld 2031
        mov     [window_data + ebx + WDATA.fl_redraw], 1
2436 mario79 2032
;--------------------------------------
2033
align 4
2034
.move_others_down:
8115 dunkaist 2035
        ; bx <- process no
1368 mikedld 2036
        movzx   ebx, word[esi]
8115 dunkaist 2037
        ; bx <- position in window stack
1368 mikedld 2038
        movzx   ebx, word[WIN_STACK + ebx * 2]
1362 mikedld 2039
 
2040
        ; drop others
1368 mikedld 2041
        xor     eax, eax
2436 mario79 2042
;--------------------------------------
2043
align 4
2044
.next_stack_window:
8866 rgimad 2045
        cmp     eax, [thread_count]
1362 mikedld 2046
        jae     .move_self_up
1368 mikedld 2047
        inc     eax
5350 serge 2048
 
2288 clevermous 2049
;       push    ebx
2050
;       xor     ebx,ebx
2051
;       mov     bx,[WIN_STACK + eax * 2]
2052
;       DEBUGF  1, "K : DEC WIN_STACK (0x%x)\n",ebx
2053
;       pop     ebx
5350 serge 2054
 
1368 mikedld 2055
        cmp     [WIN_STACK + eax * 2], bx
1362 mikedld 2056
        jbe     .next_stack_window
1368 mikedld 2057
        dec     word[WIN_STACK + eax * 2]
1362 mikedld 2058
        jmp     .next_stack_window
2436 mario79 2059
;--------------------------------------
2060
align 4
2061
.move_self_up:
1368 mikedld 2062
        movzx   ebx, word[esi]
8866 rgimad 2063
        ; number of thread
2064
        mov     ax, word [thread_count]
1362 mikedld 2065
        ; this is the last (and the upper)
1368 mikedld 2066
        mov     [WIN_STACK + ebx * 2], ax
1362 mikedld 2067
 
2068
        ; update on screen - window stack
1368 mikedld 2069
        xor     eax, eax
2436 mario79 2070
;--------------------------------------
2071
align 4
2072
.next_window_pos:
8866 rgimad 2073
        cmp     eax, [thread_count]
1362 mikedld 2074
        jae     .reset_vars
1368 mikedld 2075
        inc     eax
2076
        movzx   ebx, word[WIN_STACK + eax * 2]
2077
        mov     [WIN_POS + ebx * 2], ax
1362 mikedld 2078
        jmp     .next_window_pos
2436 mario79 2079
;--------------------------------------
2080
align 4
2081
.reset_vars:
1362 mikedld 2082
        mov     byte[KEY_COUNT], 0
2083
        mov     byte[BTN_COUNT], 0
2084
        mov     word[MOUSE_SCROLL_H], 0
2085
        mov     word[MOUSE_SCROLL_V], 0
2086
 
2087
        pop     ebx eax
2088
        ret
2244 mario79 2089
;------------------------------------------------------------------------------
9477 rgimad 2090
 
2091
 
2092
; Deactivate window
2093
; esi = pointer to WIN_POS+ window data
2094
window._.window_deactivate:
2288 clevermous 2095
        push    eax ebx
2436 mario79 2096
;--------------------------------------
2097
align 4
2244 mario79 2098
.move_others_up:
2288 clevermous 2099
        ; ax <- process no
2100
        movzx   ebx, word[esi]
2101
        ; ax <- position in window stack
2102
        movzx   ebx, word[WIN_STACK + ebx * 2]
2103
        ; up others
2104
        xor     eax, eax
2436 mario79 2105
;--------------------------------------
2106
align 4
2244 mario79 2107
.next_stack_window:
8866 rgimad 2108
        cmp     eax, [thread_count]
2288 clevermous 2109
        jae     .move_self_down
2110
        inc     eax
2111
        cmp     [WIN_STACK + eax * 2], bx
2112
        jae     .next_stack_window
2113
        inc     word[WIN_STACK + eax * 2]
2114
        jmp     .next_stack_window
2436 mario79 2115
;--------------------------------------
2116
align 4
2244 mario79 2117
.move_self_down:
2288 clevermous 2118
        movzx   ebx, word[esi]
2119
        ; this is the last (and the low)
2120
        mov     [WIN_STACK + ebx * 2], word 1
2121
        ; update on screen - window stack
2122
        xor     eax, eax
2436 mario79 2123
;--------------------------------------
2124
align 4
2244 mario79 2125
.next_window_pos:
8866 rgimad 2126
        cmp     eax, [thread_count]
2288 clevermous 2127
        jae     .reset_vars
2128
        inc     eax
2129
        movzx   ebx, word[WIN_STACK + eax * 2]
2130
        mov     [WIN_POS + ebx * 2], ax
2131
        jmp     .next_window_pos
2436 mario79 2132
;--------------------------------------
2133
align 4
2244 mario79 2134
.reset_vars:
2288 clevermous 2135
        mov     byte[KEY_COUNT], 0
2136
        mov     byte[BTN_COUNT], 0
2137
        mov     word[MOUSE_SCROLL_H], 0
2138
        mov     word[MOUSE_SCROLL_V], 0
2139
        pop     ebx eax
2140
        ret
5350 serge 2141
;------------------------------------------------------------------------------
9477 rgimad 2142
 
2143
 
1362 mikedld 2144
align 4
9477 rgimad 2145
; Check if window is necessary to draw
2146
; edi = pointer to WDATA
2147
window._.check_window_draw:
1362 mikedld 2148
        mov     cl, [edi + WDATA.fl_wstyle]
2149
        and     cl, 0x0f
1391 mikedld 2150
        cmp     cl, 3
1362 mikedld 2151
        je      .exit.redraw      ; window type 3
1391 mikedld 2152
        cmp     cl, 4
1362 mikedld 2153
        je      .exit.redraw      ; window type 4
2154
 
2155
        push    eax ebx edx esi
2156
 
2157
        mov     eax, edi
2158
        sub     eax, window_data
9926 Doczom 2159
        shr     eax, BSF sizeof.WDATA
1362 mikedld 2160
 
2161
        movzx   eax, word[WIN_STACK + eax * 2]  ; get value of the curr process
2162
        lea     esi, [WIN_POS + eax * 2]        ; get address of this process at 0xC400
2436 mario79 2163
;--------------------------------------
2164
align 4
2165
.next_window:
1362 mikedld 2166
        add     esi, 2
2167
 
8866 rgimad 2168
        mov     eax, [thread_count]
1362 mikedld 2169
        lea     eax, word[WIN_POS + eax * 2] ; number of the upper window
2170
 
2171
        cmp     esi, eax
2172
        ja      .exit.no_redraw
2173
 
2174
        movzx   edx, word[esi]
9930 Doczom 2175
        shl     edx, BSF sizeof.WDATA
9932 Doczom 2176
        test    byte [window_data + edx + WDATA.fl_wstate], WSTATE_USED
2177
        jz      .next_window
1362 mikedld 2178
 
2179
        mov     eax, [edi + WDATA.box.top]
2180
        mov     ebx, [edi + WDATA.box.height]
2181
        add     ebx, eax
2182
 
2183
        mov     ecx, [window_data + edx + WDATA.box.top]
2184
        cmp     ecx, ebx
2185
        jge     .next_window
2186
        add     ecx, [window_data + edx + WDATA.box.height]
2187
        cmp     eax, ecx
2188
        jge     .next_window
2189
 
2190
        mov     eax, [edi + WDATA.box.left]
2191
        mov     ebx, [edi + WDATA.box.width]
2192
        add     ebx, eax
2193
 
2194
        mov     ecx, [window_data + edx + WDATA.box.left]
2195
        cmp     ecx, ebx
2196
        jge     .next_window
2197
        add     ecx, [window_data + edx + WDATA.box.width]
2198
        cmp     eax, ecx
2199
        jge     .next_window
2200
 
2201
        pop     esi edx ebx eax
2436 mario79 2202
;--------------------------------------
2203
align 4
2204
.exit.redraw:
1362 mikedld 2205
        xor     ecx, ecx
2206
        inc     ecx
2207
        ret
2436 mario79 2208
;--------------------------------------
2209
align 4
2210
.exit.no_redraw:
1362 mikedld 2211
        pop     esi edx ebx eax
2212
        xor     ecx, ecx
2213
        ret
9477 rgimad 2214
 
2215
 
2436 mario79 2216
;------------------------------------------------------------------------------
9477 rgimad 2217
 
2218
 
1362 mikedld 2219
align 4
9477 rgimad 2220
window._.draw_window_caption:
1391 mikedld 2221
        xor     eax, eax
8866 rgimad 2222
        mov     edx, [thread_count]
1391 mikedld 2223
        movzx   edx, word[WIN_POS + edx * 2]
8869 rgimad 2224
        cmp     edx, [current_slot_idx]
1391 mikedld 2225
        jne     @f
2226
        inc     eax
2436 mario79 2227
;--------------------------------------
2228
align 4
2229
@@:
8869 rgimad 2230
        mov     edx, [current_slot_idx]
9926 Doczom 2231
        shl     edx, BSF sizeof.WDATA
1391 mikedld 2232
        add     edx, window_data
2233
        movzx   ebx, [edx + WDATA.fl_wstyle]
2234
        and     bl, 0x0F
2235
        cmp     bl, 3
2236
        je      .draw_caption_style_3
2237
        cmp     bl, 4
2238
        je      .draw_caption_style_3
1362 mikedld 2239
 
1391 mikedld 2240
        jmp     .not_style_3
2436 mario79 2241
;--------------------------------------
2242
align 4
2243
.draw_caption_style_3:
1391 mikedld 2244
        push    edx
2245
        call    drawwindow_IV_caption
2246
        add     esp, 4
2247
        jmp     .2
2436 mario79 2248
;--------------------------------------
2249
align 4
2250
.not_style_3:
1391 mikedld 2251
        cmp     bl, 2
2252
        jne     .not_style_2
2253
 
2254
        call    drawwindow_III_caption
2255
        jmp     .2
2436 mario79 2256
;--------------------------------------
2257
align 4
2258
.not_style_2:
1391 mikedld 2259
        cmp     bl, 0
2260
        jne     .2
2261
 
2262
        call    drawwindow_I_caption
2436 mario79 2263
;--------------------------------------
2264
align 4
2265
.2:
8869 rgimad 2266
        mov     edi, [current_slot_idx]
9709 Doczom 2267
        shl     edi, BSF sizeof.WDATA
9926 Doczom 2268
        test    [window_data + edi + WDATA.fl_wstyle], WSTYLE_HASCAPTION
1391 mikedld 2269
        jz      .exit
9926 Doczom 2270
        mov     edx, [window_data + edi + WDATA.caption]
1391 mikedld 2271
        or      edx, edx
2272
        jz      .exit
2273
 
5926 pathoswith 2274
        mov     ebp, [edi + window_data + WDATA.box.left - 2]
2275
        mov     bp, word[edi + window_data + WDATA.box.top]
1391 mikedld 2276
        movzx   eax, [edi + window_data + WDATA.fl_wstyle]
2277
        and     al, 0x0F
2278
        cmp     al, 3
2279
        je      .skinned
2280
        cmp     al, 4
2281
        je      .skinned
2282
 
2283
        jmp     .not_skinned
2436 mario79 2284
;--------------------------------------
2285
align 4
2286
.skinned:
1391 mikedld 2287
        movzx   eax, word[edi + window_data + WDATA.box.width]
2288
        sub     ax, [_skinmargins.left]
2289
        sub     ax, [_skinmargins.right]
2290
        js      .exit
2291
        mov     ebx, dword[_skinmargins.left - 2]
2292
        mov     bx, word[_skinh]
2293
        sub     bx, [_skinmargins.bottom]
2294
        sub     bx, [_skinmargins.top]
2295
        sar     bx, 1
2296
        add     bx, [_skinmargins.top]
5926 pathoswith 2297
        sub     bx, 8
1391 mikedld 2298
        jmp     .dodraw
2436 mario79 2299
;--------------------------------------
2300
align 4
2301
.not_skinned:
1391 mikedld 2302
        cmp     al, 1
2303
        je      .exit
2304
        movzx   eax, word[edi + window_data + WDATA.box.width]
2305
        sub     eax, 16
2306
        js      .exit
5926 pathoswith 2307
        mov     ebx, 80002h
2308
.dodraw:
2309
        shr     eax, 3
1391 mikedld 2310
        mov     esi, eax
2311
        add     ebx, ebp
2312
        mov     ecx, [common_colours + 16]
9926 Doczom 2313
        mov     al, [window_data + edi + WDATA.captionEncoding]
6802 pathoswith 2314
        test    al, al
2315
        jnz     @f
5926 pathoswith 2316
        mov     al, 1
2317
        cmp     byte [edx], 4
2318
        jnc     @f
2319
        mov     al, [edx]
2320
        test    al, al
2321
        jz      .exit
2322
        inc     edx
2323
@@:
2324
        shl     eax, 28
7103 0CodErr 2325
        or      ecx, eax
1391 mikedld 2326
        xor     edi, edi
7103 0CodErr 2327
        stc
2328
        call    dtext._
2436 mario79 2329
.exit:
5926 pathoswith 2330
        jmp     __sys_draw_pointer
2436 mario79 2331
;------------------------------------------------------------------------------
9477 rgimad 2332
 
2333
 
1391 mikedld 2334
align 4
9477 rgimad 2335
; Draw negative box
2336
; edi = pointer to BOX struct
2337
window._.draw_negative_box:
1391 mikedld 2338
        push    eax ebx esi
2233 mario79 2339
        mov     esi, 0x01000000
2436 mario79 2340
;--------------------------------------
2341
align 4
2233 mario79 2342
.1:
1391 mikedld 2343
        mov     eax, [edi + BOX.left - 2]
2344
        mov     ax, word[edi + BOX.left]
2345
        add     ax, word[edi + BOX.width]
2346
        mov     ebx, [edi + BOX.top - 2]
2347
        mov     bx, word[edi + BOX.top]
2348
        add     bx, word[edi + BOX.height]
2349
        call    draw_rectangle.forced
2350
        pop     esi ebx eax
2351
        ret
2233 mario79 2352
;------------------------------------------------------------------------------
2669 mario79 2353
;align 4
2436 mario79 2354
;------------------------------------------------------------------------------
2669 mario79 2355
;window._.end_moving__box: ;//////////////////////////////////////////////////
2233 mario79 2356
;------------------------------------------------------------------------------
2357
;? Draw positive box
2358
;------------------------------------------------------------------------------
2359
;> edi = pointer to BOX struct
2360
;------------------------------------------------------------------------------
2669 mario79 2361
;        push    eax ebx esi
2362
;        xor     esi, esi
2363
;        jmp     window._.draw_negative_box.1
2341 Serge 2364
;------------------------------------------------------------------------------
9477 rgimad 2365
 
2366
 
2436 mario79 2367
align 4
9477 rgimad 2368
; void __fastcall get_window_rect(struct RECT* rc);
2369
; ecx = pointer to RECT
2370
window._.get_rect:
9709 Doczom 2371
        mov     eax, [current_slot_idx]
2372
        shl     eax, BSF sizeof.WDATA
2341 Serge 2373
 
9709 Doczom 2374
        mov     edx, [eax + window_data + WDATA.box.left]
2341 Serge 2375
        mov     [ecx+RECT.left], edx
2376
 
9709 Doczom 2377
        add     edx, [eax + window_data + WDATA.box.width]
2341 Serge 2378
        mov     [ecx+RECT.right], edx
2379
 
9709 Doczom 2380
        mov     edx, [eax +window_data + WDATA.box.top]
2341 Serge 2381
        mov     [ecx+RECT.top], edx
2382
 
9709 Doczom 2383
        add     edx, [eax + window_data + WDATA.box.height]
2341 Serge 2384
        mov     [ecx+RECT.bottom], edx
2385
        ret
2436 mario79 2386
;------------------------------------------------------------------------------
9477 rgimad 2387
 
2388
 
5836 GerdtR 2389
align 4
9477 rgimad 2390
; redraw all windows one above the window
5865 GerdtR 2391
;> eax = left
2392
;> ebx = top
2393
;> ecx = right
2394
;> edx = bottom
2395
;> esi = process number
2396
;! corrupted edi
9477 rgimad 2397
window._.redraw_top_wnd:
5865 GerdtR 2398
        push    0
2399
        jmp     window._.set_top_wnd.go
9477 rgimad 2400
;------------------------------------------------------------------------------
5865 GerdtR 2401
 
9477 rgimad 2402
 
5865 GerdtR 2403
align 4
9477 rgimad 2404
; call set_screen for all windows one above the window
5836 GerdtR 2405
;> eax = left
2406
;> ebx = top
2407
;> ecx = right
2408
;> edx = bottom
2409
;> esi = process number
2410
;! corrupted edi
9477 rgimad 2411
window._.set_top_wnd:
5865 GerdtR 2412
        push    1
2413
.go:
5836 GerdtR 2414
        push    esi
2415
        pushfd
2416
        cli
2417
 
2418
        push    ebp
8866 rgimad 2419
        mov     ebp, [thread_count]
5836 GerdtR 2420
        cmp     ebp, 1
2421
        jbe     .exit
2422
 
9709 Doczom 2423
        shl     esi, BSF sizeof.WDATA
5865 GerdtR 2424
        cmp     [esi + window_data + WDATA.z_modif], ZPOS_ALWAYS_TOP
2425
        je      .exit
2426
 
5836 GerdtR 2427
        push    eax ;for num layout
2428
        push    edx ecx ebx eax
2429
 
5865 GerdtR 2430
        movsx   eax, byte [esi + window_data + WDATA.z_modif]
5836 GerdtR 2431
        inc     eax
5865 GerdtR 2432
        mov     dword[esp+10h], eax
5836 GerdtR 2433
;--------------------------------------
2434
align 4
2435
.layout:
2436
        mov     esi, 1        ; = num in window stack
8866 rgimad 2437
        mov     ebp, [thread_count]
5836 GerdtR 2438
;--------------------------------------
2439
align 4
2440
.next_window:
2441
        movzx   edi, word[WIN_POS + esi * 2]
9930 Doczom 2442
        shl     edi, BSF sizeof.WDATA
5836 GerdtR 2443
 
9930 Doczom 2444
        test    byte [window_data + edi + WDATA.fl_wstate], WSTATE_USED
2445
        jz      .skip_window
5836 GerdtR 2446
 
2447
        add     edi, window_data
2448
        test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
2449
        jnz     .skip_window
2450
 
5865 GerdtR 2451
        mov     eax, [esp+10h]
5836 GerdtR 2452
        cmp     [edi + WDATA.z_modif], al
2453
        jne     .skip_window
2454
 
2455
        mov     eax, [edi + WDATA.box.left]
2456
        cmp     eax, [esp + RECT.right]
2457
        jg      .skip_window
2458
        mov     ebx, [edi + WDATA.box.top]
2459
        cmp     ebx, [esp + RECT.bottom]
2460
        jg      .skip_window
2461
        mov     ecx, [edi + WDATA.box.width]
2462
        add     ecx, eax
2463
        cmp     ecx, [esp + RECT.left]
2464
        jl      .skip_window
2465
        mov     edx, [edi + WDATA.box.height]
2466
        add     edx, ebx
2467
        cmp     edx, [esp + RECT.top]
2468
        jl      .skip_window
2469
 
2470
        cmp     eax, [esp + RECT.left]
2471
        jae     @f
2472
        mov     eax, [esp + RECT.left]
2473
;--------------------------------------
2474
align 4
2475
@@:
2476
        cmp     ebx, [esp + RECT.top]
2477
        jae     @f
2478
        mov     ebx, [esp + RECT.top]
2479
;--------------------------------------
2480
align 4
2481
@@:
2482
        cmp     ecx, [esp + RECT.right]
2483
        jbe     @f
2484
        mov     ecx, [esp + RECT.right]
2485
;--------------------------------------
2486
align 4
2487
@@:
2488
        cmp     edx, [esp + RECT.bottom]
2489
        jbe     @f
2490
        mov     edx, [esp + RECT.bottom]
2491
;--------------------------------------
2492
align 4
2493
@@:
5865 GerdtR 2494
        cmp     dword[esp+32], 0
2495
        je      .set_fl_redraw
2496
 
5836 GerdtR 2497
        push    esi
2498
        movzx   esi, word[WIN_POS + esi * 2]
2499
        call    window._.set_screen
2500
        pop     esi
5865 GerdtR 2501
        jmp     @f
2502
.set_fl_redraw:
5836 GerdtR 2503
        mov     [edi + WDATA.fl_redraw], 1      ;set redraw flag
5865 GerdtR 2504
     @@:
5836 GerdtR 2505
;--------------------------------------
2506
align 4
2507
.skip_window:
2508
        inc     esi
2509
        dec     ebp
2510
        jnz     .next_window
2511
;--------------------------------------
5865 GerdtR 2512
        inc     dword[esp+10h]
2513
        cmp     byte[esp+10h], ZPOS_ALWAYS_TOP
2514
        jle     .layout
5836 GerdtR 2515
;-------------------------------------
2516
 
2517
        pop     eax ebx ecx edx
2518
        pop     ebp     ;del num layout
2519
;-------------------------------------
2520
align 4
2521
.exit:
2522
 
2523
        pop     ebp
2524
        popfd
2525
        pop     esi
2526
 
5865 GerdtR 2527
        add     esp, 4   ;dword for 0/1 - set_screen/fl_redraw
5836 GerdtR 2528
        ret