Subversion Repositories Kolibri OS

Rev

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