Subversion Repositories Kolibri OS

Rev

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