Subversion Repositories Kolibri OS

Rev

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

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