2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: Visibility computations
5 * FILE: subsys/win32k/ntuser/vis.c
6 * PROGRAMMER: Ge van Geldorp (ge@gse.nl)
10 DBG_DEFAULT_CHANNEL(UserWinpos
);
13 VIS_ComputeVisibleRegion(
20 PWND PreviousWindow
, CurrentWindow
, CurrentSibling
;
22 if (!Wnd
|| !(Wnd
->style
& WS_VISIBLE
))
31 VisRgn
= IntSysCreateRectRgnIndirect(&Wnd
->rcClient
);
35 VisRgn
= IntSysCreateRectRgnIndirect(&Wnd
->rcWindow
);
39 * Walk through all parent windows and for each clip the visble region
40 * to the parent's client area and exclude all siblings that are over
45 CurrentWindow
= Wnd
->spwndParent
;
48 if ( CurrentWindow
->state2
& WNDS2_INDESTROY
||
49 CurrentWindow
->state
& WNDS_DESTROYED
)
51 ERR("ATM the Current Window or Parent is dead!\n");
52 if (VisRgn
) GreDeleteObject(VisRgn
);
56 if (!(CurrentWindow
->style
& WS_VISIBLE
))
58 if (VisRgn
) GreDeleteObject(VisRgn
);
62 ClipRgn
= IntSysCreateRectRgnIndirect(&CurrentWindow
->rcClient
);
63 NtGdiCombineRgn(VisRgn
, VisRgn
, ClipRgn
, RGN_AND
);
64 GreDeleteObject(ClipRgn
);
66 if ((PreviousWindow
->style
& WS_CLIPSIBLINGS
) ||
67 (PreviousWindow
== Wnd
&& ClipSiblings
))
69 CurrentSibling
= CurrentWindow
->spwndChild
;
70 while ( CurrentSibling
!= NULL
&&
71 CurrentSibling
!= PreviousWindow
)
73 if ((CurrentSibling
->style
& WS_VISIBLE
) &&
74 !(CurrentSibling
->ExStyle
& WS_EX_TRANSPARENT
))
76 ClipRgn
= IntSysCreateRectRgnIndirect(&CurrentSibling
->rcWindow
);
77 /* Combine it with the window region if available */
78 if (CurrentSibling
->hrgnClip
&& !(CurrentSibling
->style
& WS_MINIMIZE
))
80 NtGdiOffsetRgn(ClipRgn
, -CurrentSibling
->rcWindow
.left
, -CurrentSibling
->rcWindow
.top
);
81 NtGdiCombineRgn(ClipRgn
, ClipRgn
, CurrentSibling
->hrgnClip
, RGN_AND
);
82 NtGdiOffsetRgn(ClipRgn
, CurrentSibling
->rcWindow
.left
, CurrentSibling
->rcWindow
.top
);
84 NtGdiCombineRgn(VisRgn
, VisRgn
, ClipRgn
, RGN_DIFF
);
85 GreDeleteObject(ClipRgn
);
87 CurrentSibling
= CurrentSibling
->spwndNext
;
91 PreviousWindow
= CurrentWindow
;
92 CurrentWindow
= CurrentWindow
->spwndParent
;
97 CurrentWindow
= Wnd
->spwndChild
;
100 if ((CurrentWindow
->style
& WS_VISIBLE
) &&
101 !(CurrentWindow
->ExStyle
& WS_EX_TRANSPARENT
))
103 ClipRgn
= IntSysCreateRectRgnIndirect(&CurrentWindow
->rcWindow
);
104 /* Combine it with the window region if available */
105 if (CurrentWindow
->hrgnClip
&& !(CurrentWindow
->style
& WS_MINIMIZE
))
107 NtGdiOffsetRgn(ClipRgn
, -CurrentWindow
->rcWindow
.left
, -CurrentWindow
->rcWindow
.top
);
108 NtGdiCombineRgn(ClipRgn
, ClipRgn
, CurrentWindow
->hrgnClip
, RGN_AND
);
109 NtGdiOffsetRgn(ClipRgn
, CurrentWindow
->rcWindow
.left
, CurrentWindow
->rcWindow
.top
);
111 NtGdiCombineRgn(VisRgn
, VisRgn
, ClipRgn
, RGN_DIFF
);
112 GreDeleteObject(ClipRgn
);
114 CurrentWindow
= CurrentWindow
->spwndNext
;
118 if (Wnd
->hrgnClip
&& !(Wnd
->style
& WS_MINIMIZE
))
120 NtGdiOffsetRgn(VisRgn
, -Wnd
->rcWindow
.left
, -Wnd
->rcWindow
.top
);
121 NtGdiCombineRgn(VisRgn
, VisRgn
, Wnd
->hrgnClip
, RGN_AND
);
122 NtGdiOffsetRgn(VisRgn
, Wnd
->rcWindow
.left
, Wnd
->rcWindow
.top
);
129 co_VIS_WindowLayoutChanged(
135 USER_REFERENCE_ENTRY Ref
;
139 Parent
= Wnd
->spwndParent
;
142 Temp
= IntSysCreateRectRgn(0, 0, 0, 0);
144 NtGdiCombineRgn(Temp
, NewlyExposed
, NULL
, RGN_COPY
);
146 Wnd
->rcWindow
.left
- Parent
->rcClient
.left
,
147 Wnd
->rcWindow
.top
- Parent
->rcClient
.top
);
149 UserRefObjectCo(Parent
, &Ref
);
150 co_UserRedrawWindow(Parent
, NULL
, Temp
,
151 RDW_FRAME
| RDW_ERASE
| RDW_INVALIDATE
|
153 UserDerefObjectCo(Parent
);
155 GreDeleteObject(Temp
);