Subversion Repositories Kolibri OS

Rev

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

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