Subversion Repositories Kolibri OS

Rev

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

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