Subversion Repositories Kolibri OS

Rev

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

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