Subversion Repositories Kolibri OS

Rev

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

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