Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
41 mikedld 1
get_titlebar_height: ; edi = window draw_data pointer
2
        mov     al,[edi+WDATA.fl_wstyle]
3
        and     al,0x0F
4
        cmp     al,0x03
5
        jne     @f
6
        mov     eax,[_skinh]
7
        ret
8
    @@: mov     eax,21
9
        ret
10
 
11
get_rolledup_height: ; edi = window draw_data pointer
12
        mov     al,[edi+WDATA.fl_wstyle]
13
        and     al,0x0F
14
        cmp     al,0x03
15
        jne     @f
16
        mov     eax,[_skinh]
17
        add     eax,3
18
        ret
19
    @@: or      al,al
20
        jnz     @f
21
        mov     eax,21
22
        ret
23
    @@: mov     eax,21+2
24
        ret
25
 
26
 
1 ha 27
setwindowdefaults:
28
        pushad
29
 
30
        xor   eax,eax
380 serge 31
        mov   ecx,WIN_STACK
1 ha 32
       @@:
33
        inc   eax
34
        add   ecx,2
35
        mov   [ecx+0x000],ax          ; process no
36
        mov   [ecx+0x400],ax          ; positions in stack
380 serge 37
        cmp   ecx,WIN_POS-2            ; the more high, the more surface
1 ha 38
        jnz   @b
39
 
40
        popad
41
        ret
42
 
43
 
44
 
45
; eax = cx
46
; ebx = cy
47
; ecx = ex
48
; edx = ey
49
; идея: перебрать все окна, начиная с самого нижнего,
112 poddubny 50
;       и для попавших в заданную область
51
;       частей окон вызвать setscreen
1 ha 52
align 4
53
calculatescreen:
54
        pushad
102 poddubny 55
        pushfd
1 ha 56
        cli
57
 
112 poddubny 58
        push    edx ecx ebx eax
1 ha 59
 
112 poddubny 60
        mov     esi, 1
61
        call    setscreen
62
 
379 serge 63
        mov     ebp, [TASK_COUNT]        ; number of processes
112 poddubny 64
        cmp     ebp, 1
65
        jbe     .finish
1 ha 66
        align 4
67
      .new_wnd:
380 serge 68
        movzx   edi, word [WIN_POS + esi * 2]
102 poddubny 69
        shl     edi, 5
70
 
379 serge 71
        cmp     [CURRENT_TASK+edi+TASKDATA.state], byte 9
102 poddubny 72
        je      .not_wnd
73
 
74
        add     edi, window_data
112 poddubny 75
        test    [edi+WDATA.fl_wstate], WSTATE_MINIMIZED
41 mikedld 76
        jnz     .not_wnd
112 poddubny 77
 
114 mikedld 78
        mov     eax,[edi+WDATA.box.left]
112 poddubny 79
        cmp     eax, [esp+RECT.right]
80
        ja      .out_of_bounds
114 mikedld 81
        mov     ebx,[edi+WDATA.box.top]
112 poddubny 82
        cmp     ebx, [esp+RECT.bottom]
83
        ja      .out_of_bounds
114 mikedld 84
        mov     ecx,[edi+WDATA.box.width]
112 poddubny 85
        add     ecx, eax
86
        cmp     ecx, [esp+RECT.left]
87
        jb      .out_of_bounds
114 mikedld 88
        mov     edx,[edi+WDATA.box.height]
112 poddubny 89
        add     edx, ebx
90
        cmp     edx, [esp+RECT.top]
91
        jb      .out_of_bounds
92
 
117 mario79 93
    cmp     eax, [esp+RECT.left]
112 poddubny 94
        jae     @f
95
        mov     eax, [esp+RECT.left]
96
     @@:
117 mario79 97
    cmp     ebx, [esp+RECT.top]
112 poddubny 98
        jae     @f
99
        mov     ebx, [esp+RECT.top]
100
     @@:
117 mario79 101
    cmp     ecx, [esp+RECT.right]
112 poddubny 102
        jbe     @f
103
        mov     ecx, [esp+RECT.right]
104
     @@:
117 mario79 105
    cmp     edx, [esp+RECT.bottom]
112 poddubny 106
        jbe     @f
107
        mov     edx, [esp+RECT.bottom]
108
     @@:
109
 
110
        push    esi
380 serge 111
        movzx   esi, word [WIN_POS + esi * 2]
112 poddubny 112
        call    setscreen
113
        pop     esi
114
 
1 ha 115
      .not_wnd:
112 poddubny 116
      .out_of_bounds:
117
        inc     esi
118
        dec     ebp
119
        jnz     .new_wnd
1 ha 120
      .finish:
112 poddubny 121
 
117 mario79 122
    pop     eax ebx ecx edx
112 poddubny 123
 
102 poddubny 124
        popfd
1 ha 125
        popad
126
ret
127
 
128
 
129
 
130
virtual at esp
112 poddubny 131
  ff_x     dd ?
132
  ff_y     dd ?
133
  ff_width dd ?
1 ha 134
  ff_xsz   dd ?
135
  ff_ysz   dd ?
136
  ff_scale dd ?
137
end virtual
138
 
139
align 4
140
; резервирует место под окно заданного процесса
141
setscreen:
142
;  eax  x start
143
;  ebx  y start
144
;  ecx  x end
145
;  edx  y end
146
;  esi  process number
147
pushad
142 diamond 148
; \begin{diamond}[29.08.2006]
149
        cmp     esi, 1
150
        jz      @f
151
        mov     edi, esi
152
        shl     edi, 5
153
        cmp     [edi+window_data+WDATA.box.width], 0
154
        jnz     @f
155
        cmp     [edi+window_data+WDATA.box.height], 0
156
        jz      .ret
157
@@:
158
; \end{diamond}[29.08.2006]
380 serge 159
        mov edi, esi ;;;word [esi*2+WIN_POS]
1 ha 160
        shl   edi, 8
380 serge 161
        add   edi, SLOT_BASE  ; address of random shaped window area
115 poddubny 162
        cmp   [edi+APPDATA.wnd_shape], dword 0
1 ha 163
        jne   .free_form
164
 
165
        ; get x&y size
166
        sub   ecx, eax
167
        sub   edx, ebx
168
        inc   ecx
169
        inc   edx
170
 
171
        ; get WinMap start
381 serge 172
        mov   edi, [ScreenWidth] ; screen_sx
1 ha 173
        inc   edi
174
        imul  edi, ebx
175
        add   edi, eax
176
        add   edi, WinMapAddress
177
 
178
  .new_y:
179
        push  ecx ; sx
180
        push  edx
181
 
182
        mov   edx, esi
183
        align 4
184
  .new_x:
185
        mov   byte [edi], dl
186
        inc   edi
187
        dec   ecx
188
        jnz   .new_x
189
 
190
        pop   edx
191
        pop   ecx
381 serge 192
        add   edi, [ScreenWidth]
1 ha 193
        inc   edi
194
        sub   edi, ecx
195
        dec   edx
196
        jnz   .new_y
142 diamond 197
.ret:
1 ha 198
 popad
199
 ret
200
  .read_byte:
201
   ;eax - address
202
   ;esi - slot
203
        push  eax
204
        push  ebx
205
        push  ecx
206
        push  edx
207
        mov   edx,eax
208
        mov   eax,esi
209
        lea   ebx,[esp+12]
210
        mov   ecx,1
211
        call  read_process_memory
212
        pop   edx
213
        pop   ecx
214
        pop   ebx
215
        pop   eax
379 serge 216
        ret
1 ha 217
  .free_form:
218
 
219
        ;  for (y=0; y <= x_size; y++)
220
        ;      for (x=0; x <= x_size; x++)
221
        ;          if (shape[coord(x,y,scale)]==1)
222
        ;             set_pixel(x, y, process_number);
223
 
224
        sub  ecx, eax
225
        sub  edx, ebx
226
        inc  ecx
227
        inc  edx
228
 
115 poddubny 229
        push  dword [edi+APPDATA.wnd_shape_scale]  ; push scale first -> for loop
1 ha 230
 
231
        ; get WinMap start  -> ebp
232
        push  eax
381 serge 233
        mov   eax, [ScreenWidth] ; screen_sx
1 ha 234
        inc   eax
112 poddubny 235
        imul  eax, ebx
236
        add   eax, [esp]
1 ha 237
        add   eax, WinMapAddress
238
        mov   ebp, eax
239
 
115 poddubny 240
        mov   edi, [edi+APPDATA.wnd_shape]
1 ha 241
        pop   eax
242
 
243
        ; eax = x_start
244
        ; ebx = y_start
245
        ; ecx = x_size
246
        ; edx = y_size
247
        ; esi = process_number
248
        ; edi = &shape
249
        ;       [scale]
112 poddubny 250
        push edx ecx ; for loop - x,y size
251
 
252
        mov  ecx, esi
253
        shl  ecx, 5
114 mikedld 254
        mov  edx, [window_data+ecx+WDATA.box.top]
255
        push [window_data+ecx+WDATA.box.width]      ; for loop - width
256
        mov  ecx, [window_data+ecx+WDATA.box.left]
112 poddubny 257
        sub  ebx, edx
258
        sub  eax, ecx
259
        push ebx eax ; for loop - x,y
260
 
261
        add  [ff_xsz], eax
262
        add  [ff_ysz], ebx
263
 
264
        mov  ebx, [ff_y]
265
 
1 ha 266
      .ff_new_y:
112 poddubny 267
        mov  edx, [ff_x]
268
 
1 ha 269
      .ff_new_x:
270
        ; -- body --
271
        mov  ecx, [ff_scale]
112 poddubny 272
        mov  eax, [ff_width]
273
        inc  eax
1 ha 274
        shr  eax, cl
275
        push ebx edx
276
        shr  ebx, cl
277
        shr  edx, cl
278
        imul eax, ebx
279
        add  eax, edx
280
        pop  edx ebx
112 poddubny 281
        add  eax, edi
1 ha 282
        call .read_byte
283
        test al,al
284
        jz   @f
112 poddubny 285
        mov  eax, esi
1 ha 286
        mov  [ebp], al
287
       @@:
288
        ; -- end body --
289
        inc  ebp
290
        inc  edx
291
        cmp  edx, [ff_xsz]
292
        jb   .ff_new_x
293
        sub  ebp, [ff_xsz]
112 poddubny 294
        add  ebp, [ff_x]
381 serge 295
        add  ebp, [ScreenWidth]  ; screen.x
1 ha 296
        inc  ebp
297
        inc  ebx
298
        cmp  ebx, [ff_ysz]
299
        jb   .ff_new_y
300
 
112 poddubny 301
        add  esp, 24
1 ha 302
popad
303
ret
304
 
305
 
306
display_settings:
307
 
308
;    eax = 0         ; DISPLAY redraw
309
;          ebx = 0   ; all
310
;
311
;    eax = 1         ; BUTTON type
312
;          ebx = 0   ; flat
313
;          ebx = 1   ; 3D
314
;    eax = 2         ; set WINDOW colours
315
;          ebx = pointer to table
316
;          ecx = number of bytes define
317
;    eax = 3         ; get WINDOW colours
318
;          ebx = pointer to table
319
;          ecx = number of bytes wanted
320
;    eax = 4         ; get skin height
321
;          input  : nothing
322
;          output : eax = skin height in pixel
41 mikedld 323
;    eax = 5         ; get screen workarea
324
;          input  : nothing
325
;          output : eax = [left]*65536+[right]
326
;                   ebx = [top]*65536+[bottom]
327
;    eax = 6         ; set screen workarea
328
;          input  : ecx = [left]*65536+[right]
329
;                   edx = [top]*65536+[bottom]
330
;          output : nothing
52 mikedld 331
;    eax = 7         ; get skin margins
332
;          input  : nothing
333
;          output : eax = [left]*65536+[right]
334
;                   ebx = [top]*65536+[bottom]
335
;    eax = 8         ; set window skin
336
;          input  : ecx = pointer to file info block
337
;          output : eax = FS error code
1 ha 338
 
339
 
340
     pushad
341
 
342
     test eax, eax      ; redraw display
343
     jnz  dspl0
344
     test ebx, ebx
345
     jnz  dspl0
346
     cmp  [windowtypechanged],dword 1
347
     jne  dspl00
348
     mov  [windowtypechanged],dword 0
41 mikedld 349
  redraw_screen_direct:
1 ha 350
     mov  [dlx],dword 0
351
     mov  [dly],dword 0
381 serge 352
     mov  eax,[ScreenWidth]
1 ha 353
     mov  [dlxe],eax
381 serge 354
     mov  eax,[ScreenHeight]
1 ha 355
     mov  [dlye],eax
356
     mov  eax,window_data
357
     call redrawscreen
358
   dspl00:
359
     popad
360
     ret
361
   dspl0:
362
 
363
     cmp  eax,1       ; button type
364
     jne  dspl1
365
     and  ebx,1
366
     cmp  ebx,[buttontype]
367
     je   dspl9
368
     mov  [buttontype],ebx
369
     mov  [windowtypechanged],dword 1
370
    dspl9:
371
     popad
372
     ret
373
   dspl1:
374
 
375
     cmp  eax,2       ; set common window colours
376
     jne  no_com_colours
377
     mov  [windowtypechanged],dword 1
379 serge 378
     mov  esi,[TASK_BASE]
115 poddubny 379
     add  esi,TASKDATA.mem_start
54 mikedld 380
     add  ebx,[esi]
381
     mov  esi,ebx
1 ha 382
     mov  edi,common_colours
383
     and  ecx,127
384
     cld
385
     rep  movsb
386
     popad
387
     ret
388
   no_com_colours:
389
 
390
     cmp  eax,3       ; get common window colours
391
     jne  no_get_com
379 serge 392
     mov  esi,[TASK_BASE]
115 poddubny 393
     add  esi,TASKDATA.mem_start
1 ha 394
     add  ebx,[esi]
395
     mov  edi,ebx
396
     mov  esi,common_colours
397
     and  ecx,127
398
     cld
399
     rep  movsb
400
     popad
401
     ret
402
   no_get_com:
403
 
404
     cmp  eax,4       ; get skin height
405
     jne  no_skin_height
406
     popad
407
     mov  eax,[_skinh]
408
     mov  [esp+36],eax
409
     ret
410
   no_skin_height:
411
 
41 mikedld 412
        cmp     eax,5       ; get screen workarea
413
        jne     no_get_workarea
414
        popad
415
        mov     eax,[screen_workarea.left-2]
416
        mov     ax,word[screen_workarea.right]
417
        mov     [esp+36],eax
418
        mov     eax,[screen_workarea.top-2]
419
        mov     ax,word[screen_workarea.bottom]
420
        mov     [esp+24],eax
421
        ret
422
   no_get_workarea:
423
 
424
        cmp     eax,6       ; set screen workarea
425
        jne     no_set_workarea
49 mikedld 426
        movsx   eax,word[esp+16+2]
427
        movsx   ebx,word[esp+16]
41 mikedld 428
        cmp     eax,ebx
49 mikedld 429
        jge     .lp1
381 serge 430
        or      eax,eax;[ScreenWidth]
49 mikedld 431
        jl      @f
41 mikedld 432
        mov     [screen_workarea.left],eax
381 serge 433
    @@: cmp     ebx,[ScreenWidth]
49 mikedld 434
        jg      .lp1
41 mikedld 435
        mov     [screen_workarea.right],ebx
49 mikedld 436
  .lp1: movsx   eax,word[esp+24+2]
437
        movsx   ebx,word[esp+24]
41 mikedld 438
        cmp     eax,ebx
49 mikedld 439
        jge     .lp2
440
        or      eax,eax;[0xFE04]
441
        jl      @f
41 mikedld 442
        mov     [screen_workarea.top],eax
381 serge 443
    @@: cmp     ebx,[ScreenHeight]
49 mikedld 444
        jg      .lp2
41 mikedld 445
        mov     [screen_workarea.bottom],ebx
117 mario79 446
  .lp2: call    repos_windows
112 poddubny 447
        mov     eax, 0
448
        mov     ebx, 0
381 serge 449
        mov     ecx, [ScreenWidth]
450
        mov     edx, [ScreenHeight]
117 mario79 451
    call    calculatescreen
452
;    jmp    redraw_screen_direct
49 mikedld 453
    .exit:
454
        popad
455
        ret
456
   no_set_workarea:
41 mikedld 457
 
52 mikedld 458
        cmp     eax,7       ; get skin margins
459
        jne     no_get_skinmargins
460
        popad
461
        mov     eax,dword[_skinmargins+0]
462
        mov     [esp+36],eax
463
        mov     eax,dword[_skinmargins+4]
464
        mov     [esp+24],eax
465
        ret
466
   no_get_skinmargins:
467
 
468
        cmp     eax,8       ; set window skin
469
        jne     no_set_skin
470
        mov     eax,ebx
379 serge 471
        mov     edi,[TASK_BASE]
115 poddubny 472
        add     ebx,[edi+TASKDATA.mem_start]        ; abs start of info block
52 mikedld 473
        pushd   [ebx+0] [ebx+4] [ebx+8] [ebx+12]
474
        mov     dword[ebx+0],0        ; read
475
        mov     dword[ebx+4],0        ; from the beginning
476
        mov     dword[ebx+8],64       ; 32 KBytes maximum
477
        mov     ecx,skin_data+64*512
478
        sub     ecx,[edi+0x10]
479
        mov     dword[ebx+12],ecx     ; destination
117 mario79 480
        push    eax
52 mikedld 481
        pushad
482
        call    file_system
483
        popad
117 mario79 484
        pop    eax
52 mikedld 485
        popd    [ebx+12] [ebx+8] [ebx+4] [ebx+0]
486
        cmp     eax,ERROR_SUCCESS
487
        je      @f
488
        cmp     eax,ERROR_END_OF_FILE
489
        jne     .exit
490
    @@: cmp     [skin_data+64*512+SKIN_HEADER.ident],'SKIN'
491
        mov     eax,ERROR_UNKNOWN_FS
492
        jne     .exit
493
        mov     esi,skin_data+64*512
494
        mov     edi,skin_data
495
        mov     ecx,(64*512)/4
496
        rep     movsd
497
        call    parse_skin_data
117 mario79 498
    pushad
112 poddubny 499
        mov     eax, 0
500
        mov     ebx, 0
381 serge 501
        mov     ecx, [ScreenWidth]
502
        mov     edx, [ScreenHeight]
52 mikedld 503
        call    calculatescreen
117 mario79 504
    popad
52 mikedld 505
        mov     dword[esp+32+36],0
506
        jmp     redraw_screen_direct
507
  .exit:
508
        mov     [esp+32+36],eax
509
        popad
510
        ret
511
   no_set_skin:
512
 
49 mikedld 513
     popad
514
     ret
515
 
516
 
517
repos_windows:
379 serge 518
        mov     ecx,[TASK_COUNT]
389 serge 519
        mov     edi, OS_BASE+0x20*2
381 serge 520
    mov    byte[REDRAW_BACKGROUND],1
41 mikedld 521
        dec     ecx
117 mario79 522
        jge    @f
49 mikedld 523
        ret
150 diamond 524
    @@: mov     [edi+WDATA.fl_redraw],1
525
        test    [edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
49 mikedld 526
        jz      .lp2
41 mikedld 527
        mov     eax,[screen_workarea.left]
150 diamond 528
        mov     [edi+WDATA.box.left],eax
41 mikedld 529
        sub     eax,[screen_workarea.right]
530
        neg     eax
150 diamond 531
        mov     [edi+WDATA.box.width],eax
41 mikedld 532
        mov     eax,[screen_workarea.top]
150 diamond 533
        mov     [edi+WDATA.box.top],eax
534
        test    [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
41 mikedld 535
        jnz     .lp1
536
        sub     eax,[screen_workarea.bottom]
537
        neg     eax
150 diamond 538
        mov     [edi+WDATA.box.height],eax
539
  .lp1:
389 serge 540
 
150 diamond 541
        call    set_window_clientbox
542
        add     edi,0x20
41 mikedld 543
        loop    @b
544
        ret
150 diamond 545
  .lp2: mov     eax,[edi+WDATA.box.left]
546
        add     eax,[edi+WDATA.box.width]
381 serge 547
    mov    ebx,[ScreenWidth]
117 mario79 548
;    inc    ebx
549
    cmp    eax,ebx
550
    jle    .lp4
150 diamond 551
        mov     eax,[edi+WDATA.box.width]
117 mario79 552
    sub    eax,ebx
553
    jle    .lp3
150 diamond 554
        mov     [edi+WDATA.box.width],ebx
555
  .lp3: sub     ebx,[edi+WDATA.box.width]
322 diamond 556
        mov     [edi+WDATA.box.left],ebx
150 diamond 557
  .lp4: mov     eax,[edi+WDATA.box.top]
558
        add     eax,[edi+WDATA.box.height]
381 serge 559
    mov    ebx,[ScreenHeight]
117 mario79 560
;    inc    ebx
561
    cmp    eax,ebx
562
    jle    .lp6
150 diamond 563
        mov     eax,[edi+WDATA.box.height]
117 mario79 564
    sub    eax,ebx
565
    jle    .lp5
150 diamond 566
        mov     [edi+WDATA.box.height],ebx
567
  .lp5: sub     ebx,[edi+WDATA.box.height]
568
        mov     [edi+WDATA.box.top],ebx
569
  .lp6: jmp     .lp1
41 mikedld 570
 
1 ha 571
uglobal
572
  common_colours:
573
     times 128 db 0x0
574
endg
575
 
576
 
577
 
578
 
579
check_window_position:
580
 
581
    pushad                           ; window inside screen ?
582
 
115 poddubny 583
    movzx eax,word [edi+WDATA.box.left]
584
    movzx ebx,word [edi+WDATA.box.top]
585
    movzx ecx,word [edi+WDATA.box.width]
586
    movzx edx,word [edi+WDATA.box.height]
1 ha 587
 
588
    mov   esi,ecx             ; check x pos
589
    add   esi,eax
381 serge 590
    cmp   esi,[ScreenWidth]
1 ha 591
    jbe   x_pos_ok
115 poddubny 592
    mov   [edi+WDATA.box.left],dword 0
1 ha 593
    xor   eax, eax
594
  x_pos_ok:
595
 
596
    mov   esi,edx             ; check y pos
597
    add   esi,ebx
381 serge 598
    cmp   esi,[ScreenHeight]
1 ha 599
    jbe   y_pos_ok
115 poddubny 600
    mov   [edi+WDATA.box.top],dword 0
1 ha 601
    mov   ebx,0
602
  y_pos_ok:
603
 
604
    mov   esi,ecx             ; check x size
605
    add   esi,eax
381 serge 606
    cmp   esi,[ScreenWidth]
1 ha 607
    jbe   x_size_ok
381 serge 608
    mov   ecx,[ScreenWidth]
115 poddubny 609
    mov   [edi+WDATA.box.width],ecx
1 ha 610
  x_size_ok:
611
 
612
    mov   esi,edx             ; check y size
613
    add   esi,ebx
381 serge 614
    cmp   esi,[ScreenHeight]
1 ha 615
    jbe   y_size_ok
381 serge 616
    mov   edx,[ScreenHeight]
115 poddubny 617
    mov   [edi+WDATA.box.height],edx
1 ha 618
  y_size_ok:
619
 
620
    popad
621
 
622
    ret
623
 
624
 
625
uglobal
626
  new_window_starting dd 0
627
endg
628
 
629
 
630
sys_window_mouse:
631
 
632
    push  eax
633
 
115 poddubny 634
    mov   eax,[timer_ticks]
1 ha 635
    cmp   [new_window_starting],eax
636
    jb    swml1
637
 
381 serge 638
    mov   [MOUSE_BACKGROUND],byte 0  ; no mouse background
639
    mov   [DONT_DRAW_MOUSE],byte 0  ; draw mouse
1 ha 640
 
641
    mov   [new_window_starting],eax
642
 
643
  swml1:
644
 
645
    pop   eax
646
 
647
    ret
648
 
649
 
650
 
651
 
114 mikedld 652
drawwindow_I_caption:
653
 
115 poddubny 654
        mov   ecx,[edx+WDATA.cl_titlebar]   ; grab bar
1 ha 655
        push  ecx
656
        mov   esi,edx
115 poddubny 657
        mov   edx,[esi+WDATA.box.top]
1 ha 658
        add   edx,1
115 poddubny 659
        mov   ebx,[esi+WDATA.box.top]
114 mikedld 660
        add   ebx,21
115 poddubny 661
        mov   eax,[esi+WDATA.box.top]
662
        add   eax,[esi+WDATA.box.height]
1 ha 663
        cmp   ebx,eax
114 mikedld 664
        jb    .wdsizeok
1 ha 665
        mov   ebx,eax
114 mikedld 666
  .wdsizeok:
1 ha 667
        push  ebx
114 mikedld 668
  .drwi:
1 ha 669
        mov   ebx,edx
670
        shl   ebx,16
671
        add   ebx,edx
115 poddubny 672
        mov   eax,[esi+WDATA.box.left]
1 ha 673
        inc   eax
674
        shl   eax,16
115 poddubny 675
        add   eax,[esi+WDATA.box.left]
676
        add   eax,[esi+WDATA.box.width]
1 ha 677
        sub   eax,1
678
        push  edx
679
        mov   edx,0x80000000
115 poddubny 680
        mov   ecx,[esi+WDATA.cl_titlebar]
1 ha 681
        and   ecx,edx
682
        cmp   ecx,edx
114 mikedld 683
        jnz   .nofa
115 poddubny 684
        mov   ecx,[esi+WDATA.cl_titlebar]
1 ha 685
        sub   ecx,0x00040404
115 poddubny 686
        mov   [esi+WDATA.cl_titlebar],ecx
1 ha 687
        and   ecx,0x00ffffff
114 mikedld 688
        jmp   .faj
689
  .nofa:
115 poddubny 690
        mov   ecx,[esi+WDATA.cl_titlebar]
1 ha 691
        and   ecx,0x00ffffff
114 mikedld 692
  .faj:
1 ha 693
        pop   edx
694
        mov   edi,0
695
        call  [draw_line]
696
        inc   edx
697
        cmp   edx,[esp]
114 mikedld 698
        jb    .drwi
1 ha 699
        add   esp,4
700
        pop   ecx
115 poddubny 701
        mov   [esi+WDATA.cl_titlebar],ecx
1 ha 702
 
114 mikedld 703
        ret
704
 
705
 
706
drawwindow_I:
707
 
708
        pushad
186 diamond 709
        or      [edx+WDATA.fl_wdrawn], 4
114 mikedld 710
 
115 poddubny 711
        mov   esi,[edx+WDATA.cl_frames]   ; rectangle
712
        mov   eax,[edx+WDATA.box.left]
114 mikedld 713
        shl   eax,16
115 poddubny 714
        add   eax,[edx+WDATA.box.left]
715
        add   eax,[edx+WDATA.box.width]
716
        mov   ebx,[edx+WDATA.box.top]
114 mikedld 717
        shl   ebx,16
115 poddubny 718
        add   ebx,[edx+WDATA.box.top]
719
        add   ebx,[edx+WDATA.box.height]
114 mikedld 720
        call  draw_rectangle
721
 
186 diamond 722
        and     [edx+WDATA.fl_wdrawn], not 4
723
        test    [edx+WDATA.fl_wdrawn], 2
724
        jz      @f
725
        call    drawwindowframes2
726
@@:
727
 
114 mikedld 728
        call    drawwindow_I_caption
729
 
115 poddubny 730
        mov   edx,[esi+WDATA.box.top]      ; inside work area
1 ha 731
        add   edx,21+5
115 poddubny 732
        mov   ebx,[esi+WDATA.box.top]
733
        add   ebx,[esi+WDATA.box.height]
1 ha 734
        cmp   edx,ebx
735
        jg    noinside
736
        mov   eax,1
737
        mov   ebx,21
115 poddubny 738
        mov   ecx,[esi+WDATA.box.width]
739
        mov   edx,[esi+WDATA.box.height]
740
        mov   edi,[esi+WDATA.cl_workarea]
303 mikedld 741
	test  edi,0x40000000
742
	jnz   noinside
1 ha 743
        call  [drawbar]
744
      noinside:
745
 
746
        popad
747
 
748
        ret
749
 
750
 
751
draw_rectangle:
752
 
753
r_eax equ [esp+28]   ; x start
754
r_ax  equ [esp+30]   ; x end
755
r_ebx equ [esp+16]   ; y start
756
r_bx  equ [esp+18]   ; y end
757
;esi                 ; color
758
 
759
        pushad
760
 
761
        mov   ecx,esi          ; yb,xb -> yb,xe
762
        mov   eax, r_eax
763
        rol   eax, 16
764
        mov   ebx,r_ebx
765
        shl   ebx,16
766
        mov   bx,r_ebx
767
        xor   edi, edi
768
        call  [draw_line]
769
 
770
        mov   ebx,r_bx         ; ye,xb -> ye,xe
771
        shl   ebx,16
772
        mov   bx,r_bx
773
        call  [draw_line]
774
 
775
        mov   ecx,esi          ; ya,xa -> ye,xa
776
        mov   eax,r_eax
777
        shl   eax,16
778
        mov   ax,r_eax
779
        mov   ebx,r_ebx
780
        shl   ebx,16
781
        mov   bx,r_bx
782
        mov   edi,0
783
        call  [draw_line]
784
 
785
        mov   eax,r_ax       ; ya,xe -> ye,xe
786
        shl   eax,16
787
        mov   ax,r_ax
788
        call  [draw_line]
789
 
790
        popad
791
        ret
792
 
793
 
114 mikedld 794
drawwindow_III_caption:
1 ha 795
 
115 poddubny 796
        mov   ecx,[edx+WDATA.cl_titlebar]                       ; GRAB BAR
1 ha 797
        push  ecx
798
        mov   esi,edx
115 poddubny 799
        mov   edx,[esi+WDATA.box.top]
1 ha 800
        add   edx,4
115 poddubny 801
        mov   ebx,[esi+WDATA.box.top]
1 ha 802
        add   ebx,20
115 poddubny 803
        mov   eax,[esi+WDATA.box.top]
804
        add   eax,[esi+WDATA.box.height]
1 ha 805
        cmp   ebx,eax
114 mikedld 806
        jb    .wdsizeok
1 ha 807
        mov   ebx,eax
114 mikedld 808
  .wdsizeok:
1 ha 809
        push  ebx
114 mikedld 810
  .drwi:
1 ha 811
        mov   ebx,edx
812
        shl   ebx,16
813
        add   ebx,edx
115 poddubny 814
        mov   eax,[esi+WDATA.box.left]
1 ha 815
        shl   eax,16
115 poddubny 816
        add   eax,[esi+WDATA.box.left]
817
        add   eax,[esi+WDATA.box.width]
1 ha 818
        add   eax,4*65536-4
115 poddubny 819
        mov   ecx,[esi+WDATA.cl_titlebar]
1 ha 820
        test  ecx,0x40000000
114 mikedld 821
        jz    .nofa
1 ha 822
        add   ecx,0x040404
114 mikedld 823
  .nofa:
1 ha 824
        test  ecx,0x80000000
114 mikedld 825
        jz    .nofa2
1 ha 826
        sub   ecx,0x040404
114 mikedld 827
  .nofa2:
115 poddubny 828
        mov   [esi+WDATA.cl_titlebar],ecx
1 ha 829
        and   ecx,0xffffff
830
        xor   edi, edi
831
        call  [draw_line]
832
        inc   edx
833
        cmp   edx,[esp]
114 mikedld 834
        jb    .drwi
1 ha 835
        add   esp,4
836
        pop   ecx
115 poddubny 837
        mov   [esi+WDATA.cl_titlebar],ecx
1 ha 838
 
114 mikedld 839
        ret
840
 
841
 
842
drawwindow_III:
843
 
844
        pushad
845
 
846
        mov   edi,edx                              ; RECTANGLE
115 poddubny 847
        mov   eax,[edi+WDATA.box.left]
114 mikedld 848
        shl   eax,16
117 mario79 849
    mov   ax, word [edi+WDATA.box.left]
850
    add   ax, word [edi+WDATA.box.width]
115 poddubny 851
        mov   ebx,[edi+WDATA.box.top]
114 mikedld 852
        shl   ebx,16
117 mario79 853
    mov   bx, word [edi+WDATA.box.top]
854
    add   bx, word [edi+WDATA.box.height]
115 poddubny 855
        mov   esi,[edi+WDATA.cl_frames]
114 mikedld 856
        shr   esi,1
857
        and   esi,0x007f7f7f
858
        push  esi
186 diamond 859
        or      [edi+WDATA.fl_wdrawn], 4
114 mikedld 860
        call  draw_rectangle
186 diamond 861
        and     [edi+WDATA.fl_wdrawn], not 4
862
        test    [edi+WDATA.fl_wdrawn], 2
863
        jz      @f
864
        call    drawwindowframes2
865
@@:
114 mikedld 866
        mov   ecx,3
867
      dw3l:
868
        add   eax,1*65536-1
869
        add   ebx,1*65536-1
115 poddubny 870
        mov   esi,[edi+WDATA.cl_frames]
114 mikedld 871
        call  draw_rectangle
872
        dec   ecx
873
        jnz   dw3l
874
        pop   esi
875
        add   eax,1*65536-1
876
        add   ebx,1*65536-1
877
        call  draw_rectangle
878
 
879
        call    drawwindow_III_caption
880
 
115 poddubny 881
        mov   edx,[esi+WDATA.box.top]                       ; WORK AREA
1 ha 882
        add   edx,21+5
115 poddubny 883
        mov   ebx,[esi+WDATA.box.top]
884
        add   ebx,[esi+WDATA.box.height]
1 ha 885
        cmp   edx,ebx
886
        jg    noinside2
887
        mov   eax,5
888
        mov   ebx,20
115 poddubny 889
        mov   ecx,[esi+WDATA.box.width]
890
        mov   edx,[esi+WDATA.box.height]
1 ha 891
        sub   ecx,4
892
        sub   edx,4
115 poddubny 893
        mov   edi,[esi+WDATA.cl_workarea]
303 mikedld 894
	test  edi,0x40000000
895
	jnz   noinside2
1 ha 896
        call  [drawbar]
897
      noinside2:
898
 
899
        popad
900
 
901
        ret
902
 
903
 
904
 
905
; activate window
906
align 4
907
windowactivate:
908
 
909
        ; esi = abs mem position in stack 0xC400+
910
 
911
        pushad
102 poddubny 912
 
913
     ; if type of current active window is 3,
914
     ; it must be redrawn
379 serge 915
        mov   eax, [TASK_COUNT]
380 serge 916
        movzx eax, word [WIN_POS + eax*2]
102 poddubny 917
        shl   eax, 5
918
        add   eax, window_data
919
        mov   ebx, [eax + WDATA.cl_workarea]
920
        and   ebx, 0x0f000000
921
        cmp   ebx, 0x03000000
922
        jne   @f
923
        mov   [eax + WDATA.fl_redraw], byte 1
924
     @@:
925
 
33 mario79 926
        push   esi
1 ha 927
      movzx   eax, word [esi] ; ax <- process no
380 serge 928
      movzx   eax, word [WIN_STACK+eax*2] ; ax <- position in window stack
1 ha 929
 
930
        xor   esi, esi        ; drop others
931
      waloop:
379 serge 932
        cmp   esi, dword [TASK_COUNT]
1 ha 933
        jae   wacont
934
        inc   esi
380 serge 935
        lea   edi, [WIN_STACK + esi*2]
1 ha 936
        mov   bx, [edi] ; position of the current process
937
        cmp   bx, ax
938
        jbe   @f
939
        dec   bx       ; upper? => drop!
940
        mov   [edi], bx
941
      @@:
942
        jmp   waloop
943
      wacont:
944
                            ; set to no 1
945
        pop   esi           ;   esi = pointer at 0xC400
946
 
947
      movzx   eax, word [esi]
379 serge 948
        mov   bx, [TASK_COUNT]  ; number of processes
380 serge 949
        mov   [WIN_STACK+eax*2], bx     ; this is the last (and the upper)
1 ha 950
 
951
        ; update on screen -window stack
952
        xor   esi, esi
953
      waloop2:
379 serge 954
        mov   edi, [TASK_COUNT]
1 ha 955
        cmp   esi, edi
956
        jae   wacont2
957
        inc   esi
380 serge 958
        movzx ebx, word [esi*2 + WIN_STACK]
959
        mov   [ebx*2 + WIN_POS], si
1 ha 960
        jmp   waloop2
961
      wacont2:
381 serge 962
        mov   [KEY_COUNT], byte 0           ; empty keyboard buffer
963
        mov   [BTN_COUNT], byte 0           ; empty button buffer
1 ha 964
        popad
965
        ret
966
 
967
 
968
; check if window is necessary to draw
969
 
970
checkwindowdraw:
971
 
972
        ; edi = position in window_data+
973
 
102 poddubny 974
        mov   eax, [edi + WDATA.cl_workarea]
975
        and   eax, 0x0f000000
976
        cmp   eax, 0x03000000
977
        je    .return_yes      ; window type 3
978
 
1 ha 979
        mov   esi, edi
980
        sub   esi, window_data
981
        shr   esi, 5
982
 
983
        ; esi = process number
984
 
380 serge 985
        movzx eax, word [WIN_STACK + esi * 2] ; get value of the curr process
986
        lea   esi, [WIN_POS + eax * 2]      ; get address of this process at 0xC400
1 ha 987
 
988
        push  esi
989
 
990
      .new_check:
991
 
992
        pop   esi
993
        add   esi, 2
994
        push  esi
995
 
379 serge 996
        mov   eax, [TASK_COUNT]
380 serge 997
        lea   eax, word [WIN_POS + eax * 2] ; number of the upper window
1 ha 998
 
999
        cmp   esi, eax
1000
        ja    .all_wnds_to_top
1001
 
1002
        movzx eax, word [esi]
1003
        shl   eax, 5
379 serge 1004
        cmp   [CURRENT_TASK + eax + TASKDATA.state], byte 9
102 poddubny 1005
        je    .new_check                    ; skip dead windows
1 ha 1006
 
102 poddubny 1007
        lea   esi, [eax+window_data]
1008
 
115 poddubny 1009
        mov   ebx, [edi+WDATA.box.top]  ; y0
1010
        mov   edx, [edi+WDATA.box.height]
102 poddubny 1011
        add   edx, ebx      ; y0e
1 ha 1012
 
115 poddubny 1013
        mov   ecx, [esi+WDATA.box.top]  ; y  ; y check
379 serge 1014
        cmp   ecx, edx
102 poddubny 1015
        jae   .new_check     ; y < y0e
115 poddubny 1016
        mov   eax, [esi+WDATA.box.height]
102 poddubny 1017
        add   ecx, eax       ; ye
1018
        cmp   ebx, ecx       ; y0 >= ye
1 ha 1019
        ja    .new_check
1020
 
115 poddubny 1021
        mov   eax, [edi+WDATA.box.left]   ; x0
1022
        mov   ecx, [edi+WDATA.box.width]
102 poddubny 1023
        add   ecx, eax       ; x0e
1 ha 1024
 
115 poddubny 1025
        mov   edx, [esi+WDATA.box.left]   ; x ; x check
1 ha 1026
        cmp   edx, ecx
102 poddubny 1027
        jae   .new_check     ; x < x0e
115 poddubny 1028
        mov   ecx, [esi+WDATA.box.width]
1 ha 1029
        add   edx, ecx
1030
        cmp   eax, edx
1031
        ja    .new_check
1032
 
1033
        pop   esi
102 poddubny 1034
  .return_yes:
1 ha 1035
        mov   ecx,1   ; overlap some window
1036
        ret
1037
 
1038
  .all_wnds_to_top:
1039
 
1040
        pop   esi
1041
 
1042
        xor   ecx, ecx       ; passed all windows to top
1043
        ret
1044
 
1045
 
1046
 
1047
 
1048
waredraw:     ; if redraw necessary at activate
1049
 
1050
        pushad
1051
 
1052
        call  checkwindowdraw      ; draw window on activation ?
1053
        test  ecx, ecx
1054
        jz    .do_not_draw
1055
 
1056
        popad
381 serge 1057
        mov   [MOUSE_DOWN], byte 1     ; do draw mouse
1 ha 1058
        call  windowactivate
1059
 
1060
        ; update screen info
1061
        pushad
379 serge 1062
        mov   edi, [TASK_COUNT] ; the last process (number)
380 serge 1063
        movzx esi, word [WIN_POS + edi * 2]
1 ha 1064
        shl   esi, 5
1065
        add   esi, window_data
1066
 
1067
        ; coordinates of the upper window
117 mario79 1068
    mov   eax, [esi + WDATA.box.left]   ; cx
1069
    mov   ebx, [esi + WDATA.box.top]    ; cy
1070
    mov   ecx, [esi + WDATA.box.width]  ; sx
1071
    mov   edx, [esi + WDATA.box.height] ; sy
1 ha 1072
 
1073
        add   ecx, eax       ; ecx = x_end
1074
        add   edx, ebx       ; edx = y_end
1075
 
379 serge 1076
        mov   edi, [TASK_COUNT]
380 serge 1077
        movzx esi, word [WIN_POS + edi * 2]
102 poddubny 1078
        call  setscreen
1 ha 1079
        popad
1080
 
117 mario79 1081
    mov   [edi + WDATA.fl_redraw], 1  ; redraw flag for app
381 serge 1082
    mov   [MOUSE_DOWN],byte 0             ; mouse down checks
1 ha 1083
 
1084
        ret
1085
 
1086
     .do_not_draw:
1087
 
1088
        popad
1089
 
1090
        call  windowactivate
381 serge 1091
        mov   [MOUSE_DOWN],byte 0  ; mouse down checks
1092
        mov   [MOUSE_BACKGROUND],byte 0  ; no mouse background
1093
        mov   [DONT_DRAW_MOUSE],byte 0  ; draw mouse
1 ha 1094
        ret
1095
 
1096
 
105 poddubny 1097
; eax = window number on screen
1098
; corrupts registers and [dl*]
1099
minimize_window:
380 serge 1100
        movzx eax, word [WIN_POS+eax*2]
105 poddubny 1101
        shl   eax, 5
1102
        add   eax, window_data
1103
        test  [eax+WDATA.fl_wstate], WSTATE_MINIMIZED
1104
        jnz   .skip_redrawings
1105
        pushfd
1106
        cli
1107
        or    [eax+WDATA.fl_wstate], WSTATE_MINIMIZED
1108
        mov   edi, eax
112 poddubny 1109
        ;call  calculatescreen
114 mikedld 1110
        mov   eax, [edi+WDATA.box.left]
105 poddubny 1111
        mov   [dlx], eax
112 poddubny 1112
        mov   ecx, eax
114 mikedld 1113
        add   ecx, [edi+WDATA.box.width]
112 poddubny 1114
        mov   [dlxe], ecx
114 mikedld 1115
        mov   ebx, [edi+WDATA.box.top]
112 poddubny 1116
        mov   [dly], ebx
1117
        mov   edx, ebx
114 mikedld 1118
        add   edx, [edi+WDATA.box.height]
112 poddubny 1119
        mov   [dlye], edx
1120
        call  calculatescreen
105 poddubny 1121
        xor   esi, esi
1122
        xor   eax, eax
1123
        call  redrawscreen
1124
        popfd
1125
.skip_redrawings:
1126
        ret
1127
 
1128
; eax = window number on screen
1129
; corrupts registers and [dl*]
1130
restore_minimized_window:
1131
        pushfd
1132
        cli
380 serge 1133
        movzx esi, word [WIN_POS+eax*2]
105 poddubny 1134
        mov   edi, esi
1135
        shl   edi, 5
1136
        add   edi, window_data
1137
        test  [edi+WDATA.fl_wstate], WSTATE_MINIMIZED
1138
        jz    .skip_redrawings
1139
        mov   [edi+WDATA.fl_redraw], 1
1140
        and   [edi+WDATA.fl_wstate], not WSTATE_MINIMIZED
379 serge 1141
        cmp   eax, [TASK_COUNT] ; the uppermost window
105 poddubny 1142
        jnz   .no_uppermost
114 mikedld 1143
        mov   eax, [edi+WDATA.box.left]
1144
        mov   ebx, [edi+WDATA.box.top]
105 poddubny 1145
        mov   ecx, eax
1146
        mov   edx, ebx
114 mikedld 1147
        add   ecx, [edi+WDATA.box.width]
1148
        add   edx, [edi+WDATA.box.height]
105 poddubny 1149
        call  setscreen
1150
        jmp   .done
1151
.no_uppermost:
114 mikedld 1152
        mov   eax, [edi+WDATA.box.left]
1153
        mov   ebx, [edi+WDATA.box.top]
112 poddubny 1154
        mov   ecx, eax
1155
        mov   edx, ebx
114 mikedld 1156
        add   ecx, [edi+WDATA.box.width]
1157
        add   edx, [edi+WDATA.box.height]
105 poddubny 1158
        call  calculatescreen
1159
.done:
381 serge 1160
        mov   [MOUSE_BACKGROUND],byte 0 ; no mouse under
105 poddubny 1161
.skip_redrawings:
1162
        popfd
1163
        ret
1164
 
1165
 
1 ha 1166
iglobal
1167
  window_moving   db 'K : Window - move/resize',13,10,0
1168
  window_moved    db 'K : Window - done',13,10,0
1169
endg
1170
 
1171
; check window touch
1172
align 4
1173
checkwindows:
1174
        pushad
1175
 
105 poddubny 1176
        cmp   [window_minimize], 0
1177
        je    .no_minimizing
379 serge 1178
        mov   eax, [TASK_COUNT]       ; the uppermost window
105 poddubny 1179
        mov   bl, 0
1180
        xchg  [window_minimize], bl
1181
        cmp   bl, 1
1182
        jne   .restore
1183
        call  minimize_window
1184
        jmp   .continue
1185
  .restore:
1186
        call  restore_minimized_window
1187
  .continue:
1188
  .no_minimizing:
1 ha 1189
 
381 serge 1190
        cmp   [BTN_DOWN],byte 0    ; mouse buttons pressed ?
1 ha 1191
        jne   .mouse_buttons_pressed
1192
        popad
1193
        ret
1194
    .mouse_buttons_pressed:
1195
 
379 serge 1196
        mov   esi,[TASK_COUNT]
1 ha 1197
        inc   esi
1198
 
1199
      cwloop:
1200
        cmp   esi,2
1201
        jb   .exit
105 poddubny 1202
 
1 ha 1203
        dec   esi
380 serge 1204
        movzx edi, word [WIN_POS + esi * 2] ; ebx
1 ha 1205
        shl   edi, 5
1206
        add   edi, window_data
1207
;        mov   edi, ebx
117 mario79 1208
    mov   ecx, [edi + WDATA.box.left]
1209
    mov   edx, [edi + WDATA.box.top]
1 ha 1210
 
1211
        mov   eax,ecx
1212
        mov   ebx,edx
41 mikedld 1213
        test    [edi+WDATA.fl_wstate],WSTATE_MINIMIZED
1214
        jnz     cwloop
1 ha 1215
 
381 serge 1216
       movzx  eax, word [MOUSE_X]
1217
       movzx  ebx, word [MOUSE_Y]
379 serge 1218
 
1 ha 1219
        cmp   ecx, eax
1220
        jae   cwloop
1221
        cmp   edx, ebx
1222
        jae   cwloop
117 mario79 1223
    add   ecx, [edi + WDATA.box.width]
1224
    add   edx, [edi + WDATA.box.height]
1 ha 1225
        cmp   eax, ecx
1226
        jae   cwloop
1227
        cmp   ebx, edx
1228
        jae   cwloop
1229
 
1230
        pushad
1231
        mov   eax, esi
379 serge 1232
        mov   ebx, [TASK_COUNT]
1 ha 1233
        cmp   eax, ebx      ; is this window active?
1234
        jz    .move_resize_window
1235
 
1236
        ; eax = position in windowing stack
1237
        ; redraw must ?
380 serge 1238
        lea   esi, [WIN_POS + esi * 2]
1 ha 1239
        call  waredraw
1240
        add   esp, 32
1241
 
1242
      .exit:
1243
        popad
1244
        ret
1245
 
1246
   .move_resize_window:    ; MOVE OR RESIZE WINDOW
1247
        popad
1248
 
1249
        ; Check for user enabled fixed window
117 mario79 1250
    mov   edx, [edi + WDATA.cl_titlebar]
1 ha 1251
        and   edx, 0x0f000000
1252
        cmp   edx, 0x01000000
1253
        jne   .window_move_enabled_for_user
1254
        popad
1255
        ret
1256
      .window_move_enabled_for_user:
1257
 
117 mario79 1258
    test    [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
41 mikedld 1259
        jnz     .no_resize_2
1260
 
1 ha 1261
        mov   [do_resize_from_corner],byte 0   ; resize for skinned window
117 mario79 1262
    mov   edx, [edi + WDATA.cl_workarea]
1 ha 1263
        and   edx, 0x0f000000
1264
        cmp   edx, 0x02000000
1265
        jb    .no_resize_2 ; not type 2 wnd
1266
 
117 mario79 1267
    mov   edx, [edi + WDATA.box.top]
1268
    add   edx, [edi + WDATA.box.height]
1 ha 1269
        sub   edx, 6       ; edx = y_end - 6
1270
        cmp   ebx, edx     ; ebx = mouse_y
1271
        jb    .no_resize_2
1272
        mov   [do_resize_from_corner],byte 1
1273
        jmp   .continue
1274
      .no_resize_2:
1275
 
41 mikedld 1276
        push    eax
1277
        call    get_titlebar_height
117 mario79 1278
    add     eax,[edi + WDATA.box.top]
41 mikedld 1279
        cmp     ebx,eax
1280
        pop     eax
1281
        jae     .exit
1 ha 1282
 
1283
     .continue:
1284
 
1285
        push  esi
1286
        mov   esi, window_moving
1287
        call  sys_msg_board_str
1288
        pop   esi
1289
 
105 poddubny 1290
        mov   ecx, [timer_ticks]     ; double-click ?
1 ha 1291
        mov   edx, ecx
1292
        sub   edx, [latest_window_touch]
1293
        mov   [latest_window_touch], ecx
1294
        mov   [latest_window_touch_delta], edx
1295
 
381 serge 1296
        mov   cl, [BTN_DOWN]     ; save for shade check
1 ha 1297
        mov   [do_resize], cl
1298
     no_emulation_righ_button:
117 mario79 1299
    mov   ecx, [edi + WDATA.box.left]
1300
    mov   edx, [edi + WDATA.box.top]
1 ha 1301
 
1302
        push  eax ecx edx
1303
        mov   [dlx], ecx      ; save for drawlimits
1304
        mov   [dly], edx
117 mario79 1305
    mov   eax, [edi + WDATA.box.width]
1 ha 1306
        add   ecx, eax
117 mario79 1307
    mov   eax, [edi + WDATA.box.height]
1 ha 1308
        add   edx, eax
1309
        mov   [dlxe], ecx
1310
        mov   [dlye], edx
1311
        pop   edx ecx eax
1312
 
1313
        sub   eax, ecx
1314
        sub   ebx, edx
1315
 
381 serge 1316
        mov   esi, [MOUSE_X]
1317
        mov   [WIN_TEMP_XY], esi
1 ha 1318
 
1319
        pushad           ; wait for putimages to finish
1320
;        mov   eax,5
1321
;        call  delay_hs
117 mario79 1322
    mov   eax,[edi + WDATA.box.left]
1 ha 1323
        mov   [npx],eax
117 mario79 1324
    mov   eax,[edi + WDATA.box.top]
1 ha 1325
        mov   [npy],eax
1326
        popad
1327
 
1328
        push eax                  ; save old coordinates
117 mario79 1329
    mov   ax, word [edi + WDATA.box.left]
115 poddubny 1330
        mov   word [oldc+BOX.left],ax
117 mario79 1331
    mov   ax, word [edi + WDATA.box.top]
115 poddubny 1332
        mov   word [oldc+BOX.top],ax
117 mario79 1333
    mov   ax, word [edi + WDATA.box.width]
115 poddubny 1334
        mov   word [oldc+BOX.width],ax
1 ha 1335
        mov   word [npxe],ax
117 mario79 1336
    mov   ax, word [edi + WDATA.box.height]
115 poddubny 1337
        mov   word [oldc+BOX.height],ax
1 ha 1338
        mov   word [npye],ax
1339
        pop eax
1340
 
1341
        call  drawwindowframes
1342
 
1343
        mov   [reposition],0
381 serge 1344
        mov   [MOUSE_DOWN],byte 1   ; no reaction to mouse up/down
1 ha 1345
 
1346
        ; move window
1347
 
1348
      newchm:
1349
 
381 serge 1350
        mov   [DONT_DRAW_MOUSE],byte 1
1 ha 1351
 
1352
        call  checkidle
1353
 
117 mario79 1354
        call  checkVga_N13
1 ha 1355
 
381 serge 1356
        mov   [MOUSE_BACKGROUND],byte 0
1 ha 1357
 
1358
        call  [draw_pointer]
1359
 
1360
        pushad
1361
        call   stack_handler
1362
        popad
1363
 
381 serge 1364
        mov   esi,[WIN_TEMP_XY]
1365
        cmp   esi,[MOUSE_X]
1 ha 1366
        je    cwb
1367
 
381 serge 1368
        mov   cx,[MOUSE_X]
1369
        mov   dx,[MOUSE_Y]
1 ha 1370
        sub   cx,ax
1371
        sub   dx,bx
1372
 
1373
        push  ax
1374
        push  bx
1375
 
1376
        call  drawwindowframes
1377
 
381 serge 1378
        mov   ax,[ScreenWidth]
1379
        mov   bx,[ScreenHeight]
1 ha 1380
 
1381
        cmp   [do_resize_from_corner],1
1382
        je    no_new_position
1383
 
1384
        mov   word [npx],word 0     ; x repos ?
1385
        cmp   ax,cx
1386
        jb    noreposx
1387
        mov   [reposition],1
1388
        sub   ax,word [npxe]
1389
        mov   word [npx],ax
1390
        cmp   ax,cx
1391
        jb    noreposx
1392
        mov   word [npx],cx
1393
      noreposx:
1394
 
1395
        mov   word [npy],word 0     ; y repos ?
1396
        cmp   bx,dx
1397
        jb    noreposy
1398
        mov   [reposition],1
1399
        sub   bx,word [npye]
1400
        mov   word [npy],bx
1401
        cmp   bx,dx
1402
        jb    noreposy
1403
        mov   word [npy],dx
1404
      noreposy:
1405
 
1406
      no_new_position:
1407
 
1408
        cmp   [do_resize_from_corner],0    ; resize from right corner
1409
        je    norepos_size
1410
        pushad
1411
 
1412
        mov   edx,edi
1413
        sub   edx,window_data
115 poddubny 1414
        ;shr   edx,5
1415
        ;shl   edx,8
1416
        ;add   edx,0x80000                 ; process base at 0x80000+
380 serge 1417
    lea   edx, [SLOT_BASE + edx*8]
1 ha 1418
 
381 serge 1419
        movzx eax,word [MOUSE_X]
117 mario79 1420
    cmp   eax,[edi + WDATA.box.left]
1 ha 1421
        jb    nnepx
117 mario79 1422
    sub   eax,[edi + WDATA.box.left]
57 mikedld 1423
        cmp   eax,32 ; [edx+0x90+8]
1 ha 1424
        jge   nnepx2
57 mikedld 1425
        mov   eax,32 ; [edx+0x90+8]
1 ha 1426
      nnepx2:
1427
        mov   [npxe],eax
1428
      nnepx:
1429
 
57 mikedld 1430
        call    get_rolledup_height
41 mikedld 1431
        mov     ebx,eax
381 serge 1432
        movzx eax,word [MOUSE_Y]
117 mario79 1433
    cmp   eax,[edi + WDATA.box.top]
1 ha 1434
        jb    nnepy
117 mario79 1435
    sub   eax,[edi + WDATA.box.top]
41 mikedld 1436
        cmp     eax,ebx ; [edx+0x90+12]
1437
        jge     nnepy2
1438
        mov     eax,ebx ; [edx+0x90+12]
1 ha 1439
      nnepy2:
1440
        mov   [npye],eax
1441
      nnepy:
1442
 
1443
        mov   [reposition],1
1444
 
1445
        popad
1446
      norepos_size:
1447
 
1448
        pop   bx
1449
        pop   ax
1450
        call  drawwindowframes
1451
 
381 serge 1452
        mov   esi,[MOUSE_X]
1453
        mov   [WIN_TEMP_XY],esi
1 ha 1454
 
1455
      cwb:
381 serge 1456
        cmp   [BTN_DOWN],byte 0
379 serge 1457
        jne   newchm
1 ha 1458
                                     ; new position done
381 serge 1459
        mov     [DONT_DRAW_MOUSE],byte 1
41 mikedld 1460
        mov     cl,0
1461
        test    [edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
1462
        jnz     @f
1463
        mov     cl,[reposition]
1464
        call    drawwindowframes
1 ha 1465
 
1466
        mov   eax,[npx]
117 mario79 1467
    mov   [edi + WDATA.box.left],eax
1 ha 1468
        mov   eax,[npy]
117 mario79 1469
    mov   [edi + WDATA.box.top],eax
1 ha 1470
        mov   eax,[npxe]
117 mario79 1471
    mov   [edi + WDATA.box.width],eax
1 ha 1472
        mov   eax,[npye]
117 mario79 1473
    mov   [edi + WDATA.box.height],eax
150 diamond 1474
        call    set_window_clientbox
1 ha 1475
 
41 mikedld 1476
    @@: mov     [reposition],cl
1477
 
52 mikedld 1478
        cmp   [reposition],1         ; save new position and size
1479
        jne   no_bounds_save
1 ha 1480
        push  esi edi ecx
1481
        mov   esi,edi
57 mikedld 1482
        mov   ecx,2
1483
        test  [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP or WSTATE_MAXIMIZED
1484
        jnz   @f
1485
        add   ecx,2
1486
    @@: sub   edi,window_data
1 ha 1487
        shr   edi,5
1488
        shl   edi,8
380 serge 1489
        add   edi,SLOT_BASE+APPDATA.saved_box
1 ha 1490
        cld
1491
        rep   movsd
1492
        pop   ecx edi esi
52 mikedld 1493
      no_bounds_save:
1 ha 1494
 
1495
        pushad                             ; WINDOW SHADE/FULLSCREEN
1496
 
1497
        cmp   [reposition],1
1498
        je    no_window_sizing
1499
        mov   edx,edi
1500
        sub   edx,window_data
1501
        shr   edx,5
1502
        shl   edx,8
380 serge 1503
        add   edx,SLOT_BASE                 ; process base at 0x80000+
1 ha 1504
 
1505
        cmp   [do_resize],2               ; window shade ?
41 mikedld 1506
        jne   no_window_shade
1 ha 1507
        mov   [reposition],1
1508
 
41 mikedld 1509
        test    [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
1510
        jnz     wnd_rolldown
1511
  wnd_rollup:
1512
        or      [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
1513
        call    get_rolledup_height
1514
        jmp     @f
1515
  wnd_rolldown:
1516
        and     [edi+WDATA.fl_wstate],not WSTATE_ROLLEDUP
117 mario79 1517
    mov     eax,[edx + APPDATA.saved_box.height] ; 0x90+BOX.height
41 mikedld 1518
        test    [edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
1519
        jz      @f
1520
        mov     eax,[screen_workarea.bottom]
1521
        sub     eax,[screen_workarea.top]
114 mikedld 1522
    @@: mov     [edi+WDATA.box.height],eax
150 diamond 1523
        call    set_window_clientbox
1 ha 1524
 
1525
      no_window_shade:
1526
 
1527
        cmp   [do_resize],1               ; fullscreen/restore ?
1528
        jne   no_fullscreen_restore
1529
        cmp   [latest_window_touch_delta],dword 50
1530
        jg    no_fullscreen_restore
1531
        mov   [reposition],1
41 mikedld 1532
        test    [edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
1533
        jnz     restore_from_fullscreen
1534
        or      [edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
1535
        mov     eax,[screen_workarea.left]
114 mikedld 1536
        mov     [edi+WDATA.box.left],eax
41 mikedld 1537
        sub     eax,[screen_workarea.right]
1538
        neg     eax
114 mikedld 1539
        mov     [edi+WDATA.box.width],eax
41 mikedld 1540
        mov     eax,[screen_workarea.top]
114 mikedld 1541
        mov     [edi+WDATA.box.top],eax
41 mikedld 1542
        test    [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
1543
        jnz     @f
1544
        sub     eax,[screen_workarea.bottom]
1545
        neg     eax
114 mikedld 1546
        mov     [edi+WDATA.box.height],eax
41 mikedld 1547
    @@:
150 diamond 1548
        jmp     restore_from_fullscreen.clientbox
1 ha 1549
      restore_from_fullscreen:
41 mikedld 1550
        and     [edi+WDATA.fl_wstate],not WSTATE_MAXIMIZED
114 mikedld 1551
        push    [edi+WDATA.box.height]
1 ha 1552
        push  edi                         ; restore
115 poddubny 1553
        lea   esi, [edx + APPDATA.saved_box]
1 ha 1554
        mov   ecx,4
1555
        cld
1556
        rep   movsd
1557
        pop   edi
41 mikedld 1558
        pop     eax
1559
        test    [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
1560
        jz      @f
114 mikedld 1561
        mov     [edi+WDATA.box.height],eax
41 mikedld 1562
    @@:
150 diamond 1563
    .clientbox:
1564
        call    set_window_clientbox
1 ha 1565
 
1566
      no_fullscreen_restore:
1567
 
115 poddubny 1568
        mov   eax,[edi+WDATA.box.top]                 ; check Y inside screen
1569
        add   eax,[edi+WDATA.box.height]
381 serge 1570
        cmp   eax,[ScreenHeight]
1 ha 1571
        jbe   no_window_sizing
115 poddubny 1572
        mov   eax,[edi+WDATA.box.left]                 ; check X inside screen
1573
        add   eax,[edi+WDATA.box.width]
381 serge 1574
        cmp   eax,[ScreenWidth]
1 ha 1575
        jbe   no_window_sizing
381 serge 1576
        mov   eax,[ScreenWidth]
115 poddubny 1577
        sub   eax,[edi+WDATA.box.width]
1578
        mov   [edi+WDATA.box.left],eax
381 serge 1579
        mov   eax,[ScreenHeight]
115 poddubny 1580
        sub   eax,[edi+WDATA.box.height]
1581
        mov   [edi+WDATA.box.top],eax
150 diamond 1582
        call  set_window_clientbox
1 ha 1583
      no_window_sizing:
1584
 
1585
        popad
1586
 
1587
        cmp   [reposition],0
1588
        je    retwm
1589
 
381 serge 1590
        mov   [DONT_DRAW_MOUSE],byte 1 ; no mouse
1 ha 1591
 
112 poddubny 1592
 
1 ha 1593
        push  eax ebx ecx edx
115 poddubny 1594
        mov   eax,[edi+WDATA.box.left]
1595
        mov   ebx,[edi+WDATA.box.top]
1596
        mov   ecx,[edi+WDATA.box.width]
1597
        mov   edx,[edi+WDATA.box.height]
112 poddubny 1598
        add   ecx,eax
1599
        add   edx,ebx
1600
        call  calculatescreen
1601
 
115 poddubny 1602
        mov   eax,[oldc+BOX.left]
1603
        mov   ebx,[oldc+BOX.top]
1604
        mov   ecx,[oldc+BOX.width]
1605
        mov   edx,[oldc+BOX.height]
1 ha 1606
        add   ecx,eax
1607
        add   edx,ebx
1608
        call  calculatescreen
1609
        pop   edx ecx ebx eax
1610
 
1611
        mov   eax,edi
1612
        call  redrawscreen
1613
 
112 poddubny 1614
 
1615
        mov     [edi+WDATA.fl_redraw],1
1616
 
1 ha 1617
        mov   ecx,100         ; wait to avoid mouse residuals
1618
      waitre2:
381 serge 1619
        mov   [DONT_DRAW_MOUSE],byte 1
1 ha 1620
        call  checkidle
41 mikedld 1621
        cmp     [edi+WDATA.fl_redraw],0
1 ha 1622
        jz    retwm
1623
        loop  waitre2
1624
 
1625
      retwm:
1626
 
381 serge 1627
        mov   [DONT_DRAW_MOUSE],byte 0 ; mouse pointer
1628
        mov   [MOUSE_BACKGROUND],byte 0 ; no mouse under
1629
        mov   [MOUSE_DOWN],byte 0 ; react to mouse up/down
1 ha 1630
 
1631
        mov    esi,window_moved
1632
        call   sys_msg_board_str
1633
 
1634
        popad
1635
 
1636
        ret
1637
 
1638
 
1639
uglobal
1640
  add_window_data            dd  0
1641
  do_resize_from_corner      db  0x0
1642
  reposition                 db  0x0
1643
  latest_window_touch        dd  0x0
1644
  latest_window_touch_delta  dd  0x0
1645
 
1646
  do_resize db 0x0
1647
 
1648
  oldc    dd 0x0,0x0,0x0,0x0
1649
 
1650
  dlx     dd 0x0
1651
  dly     dd 0x0
1652
  dlxe    dd 0x0
1653
  dlye    dd 0x0
1654
 
1655
  npx     dd 0x0
1656
  npy     dd 0x0
1657
  npxe    dd 0x0
1658
  npye    dd 0x0
1659
 
1660
  mpx     dd 0x0
1661
  mpy     dd 0x0
1662
endg
1663
 
1664
 
1665
; draw negative window frames
186 diamond 1666
drawwindowframes2:
1667
        pushad
1668
        cli
1669
        jmp     drawwindowframes.do
1 ha 1670
drawwindowframes:
186 diamond 1671
        pushad
1672
        cli
1 ha 1673
 
163 diamond 1674
        test    [edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
1675
        jnz     .ret
186 diamond 1676
        mov     eax, [npx]
1677
        cmp     eax, [edi+WDATA.box.left]
1678
        jnz     .nowndframe
1679
        mov     eax, [npxe]
1680
        cmp     eax, [edi+WDATA.box.width]
1681
        jnz     .nowndframe
1682
        mov     eax, [npy]
1683
        cmp     eax, [edi+WDATA.box.top]
1684
        jnz     .nowndframe
1685
        mov     eax, [npye]
1686
        cmp     eax, [edi+WDATA.box.height]
1687
        jnz     .nowndframe
1688
        xor     [edi+WDATA.fl_wdrawn], 2
1689
        test    [edi+WDATA.fl_wdrawn], 4
1690
        jnz     .ret
163 diamond 1691
 
186 diamond 1692
.nowndframe:
1693
.do:
1694
        mov     edi, 1
1695
        mov     ecx, 0x01000000
1 ha 1696
        mov   eax,[npx]
1697
        shl   eax,16
1698
        add   eax,[npx]
1699
        add   eax,[npxe]
1700
        add   eax,65536*1-1
1701
        mov   ebx,[npy]
1702
        shl   ebx,16
1703
        add   ebx,[npy]
1704
        call  [draw_line]
1705
 
1706
        mov   eax,[npx]
1707
        shl   eax,16
1708
        add   eax,[npx]
1709
        add   eax,[npxe]
1710
        add   eax,65536*1-1
1711
        mov   ebx,[npy]
1712
        add   ebx,[npye]
1713
        shl   ebx,16
1714
        add   ebx,[npy]
1715
        add   ebx,[npye]
1716
        call  [draw_line]
1717
 
1718
        mov   eax,[npx]
1719
        shl   eax,16
1720
        add   eax,[npx]
1721
        mov   ebx,[npy]
1722
        shl   ebx,16
1723
        add   ebx,[npy]
1724
        add   ebx,[npye]
1725
        call  [draw_line]
1726
 
1727
        mov   eax,[npx]
1728
        add   eax,[npxe]
1729
        shl   eax,16
1730
        add   eax,[npx]
1731
        add   eax,[npxe]
1732
        mov   ebx,[npy]
1733
        shl   ebx,16
1734
        add   ebx,[npy]
1735
        add   ebx,[npye]
1736
        call  [draw_line]
1737
 
186 diamond 1738
.ret:
1739
        sti
1 ha 1740
        popad
1741
        ret
1742
 
1743
 
1744
 
1745
random_shaped_window:
1746
 
1747
;
1748
;  eax = 0    giving address of data area
1749
;      ebx    address
115 poddubny 1750
;  eax = 1    shape area scale
1 ha 1751
;      ebx    2^ebx scale
1752
 
1753
     test eax, eax
1754
     jne  rsw_no_address
379 serge 1755
     mov  eax,[CURRENT_TASK]
1 ha 1756
     shl  eax,8
1757
 
380 serge 1758
     mov  [eax+SLOT_BASE+APPDATA.wnd_shape],ebx
1 ha 1759
   rsw_no_address:
1760
 
1761
     cmp  eax,1
1762
     jne  rsw_no_scale
379 serge 1763
     mov  eax,[CURRENT_TASK]
1 ha 1764
     shl  eax,8
380 serge 1765
     mov  byte [eax+SLOT_BASE+APPDATA.wnd_shape_scale], bl
1 ha 1766
   rsw_no_scale:
1767
 
1768
     ret
1769