Subversion Repositories Kolibri OS

Rev

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

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