Subversion Repositories Kolibri OS

Rev

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

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