Subversion Repositories Kolibri OS

Rev

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