ReactOS 0.4.15-dev-7788-g1ad9096
vis.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: Visibility computations
5 * FILE: win32ss/user/ntuser/vis.c
6 * PROGRAMMER: Ge van Geldorp (ge@gse.nl)
7 */
8
9#include <win32k.h>
11
14 PWND Wnd,
15 BOOLEAN ClientArea,
16 BOOLEAN ClipChildren,
17 BOOLEAN ClipSiblings)
18{
19 PREGION VisRgn, ClipRgn;
20 PWND PreviousWindow, CurrentWindow, CurrentSibling;
21
22 if (!Wnd || !(Wnd->style & WS_VISIBLE))
23 {
24 return NULL;
25 }
26
27 VisRgn = NULL;
28
29 if (ClientArea)
30 {
32 }
33 else
34 {
36 }
37
38 /*
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
41 * our window.
42 */
43
44 PreviousWindow = Wnd;
45 CurrentWindow = Wnd->spwndParent;
46 while (CurrentWindow)
47 {
48 if (!VerifyWnd(CurrentWindow))
49 {
50 ERR("ATM the Current Window or Parent is dead! %p\n",CurrentWindow);
51 if (VisRgn)
52 REGION_Delete(VisRgn);
53 return NULL;
54 }
55
56 if (!(CurrentWindow->style & WS_VISIBLE))
57 {
58 if (VisRgn)
59 REGION_Delete(VisRgn);
60 return NULL;
61 }
62
63 ClipRgn = IntSysCreateRectpRgnIndirect(&CurrentWindow->rcClient);
64 IntGdiCombineRgn(VisRgn, VisRgn, ClipRgn, RGN_AND);
65 REGION_Delete(ClipRgn);
66
67 if ((PreviousWindow->style & WS_CLIPSIBLINGS) ||
68 (PreviousWindow == Wnd && ClipSiblings))
69 {
70 CurrentSibling = CurrentWindow->spwndChild;
71 while ( CurrentSibling != NULL &&
72 CurrentSibling != PreviousWindow )
73 {
74 if ((CurrentSibling->style & WS_VISIBLE) &&
75 !(CurrentSibling->ExStyle & WS_EX_TRANSPARENT))
76 {
77 ClipRgn = IntSysCreateRectpRgnIndirect(&CurrentSibling->rcWindow);
78 /* Combine it with the window region if available */
79 if (CurrentSibling->hrgnClip && !(CurrentSibling->style & WS_MINIMIZE))
80 {
81 PREGION SiblingClipRgn = REGION_LockRgn(CurrentSibling->hrgnClip);
82 if (SiblingClipRgn)
83 {
84 REGION_bOffsetRgn(ClipRgn, -CurrentSibling->rcWindow.left, -CurrentSibling->rcWindow.top);
85 IntGdiCombineRgn(ClipRgn, ClipRgn, SiblingClipRgn, RGN_AND);
86 REGION_bOffsetRgn(ClipRgn, CurrentSibling->rcWindow.left, CurrentSibling->rcWindow.top);
87 REGION_UnlockRgn(SiblingClipRgn);
88 }
89 }
90 IntGdiCombineRgn(VisRgn, VisRgn, ClipRgn, RGN_DIFF);
91 REGION_Delete(ClipRgn);
92 }
93 CurrentSibling = CurrentSibling->spwndNext;
94 }
95 }
96
97 PreviousWindow = CurrentWindow;
98 CurrentWindow = CurrentWindow->spwndParent;
99 }
100
101 if (ClipChildren)
102 {
103 CurrentWindow = Wnd->spwndChild;
104 while (CurrentWindow)
105 {
106 if ((CurrentWindow->style & WS_VISIBLE) &&
107 !(CurrentWindow->ExStyle & WS_EX_TRANSPARENT))
108 {
109 ClipRgn = IntSysCreateRectpRgnIndirect(&CurrentWindow->rcWindow);
110 /* Combine it with the window region if available */
111 if (CurrentWindow->hrgnClip && !(CurrentWindow->style & WS_MINIMIZE))
112 {
113 PREGION CurrentRgnClip = REGION_LockRgn(CurrentWindow->hrgnClip);
114 if (CurrentRgnClip)
115 {
116 REGION_bOffsetRgn(ClipRgn, -CurrentWindow->rcWindow.left, -CurrentWindow->rcWindow.top);
117 IntGdiCombineRgn(ClipRgn, ClipRgn, CurrentRgnClip, RGN_AND);
118 REGION_bOffsetRgn(ClipRgn, CurrentWindow->rcWindow.left, CurrentWindow->rcWindow.top);
119 REGION_UnlockRgn(CurrentRgnClip);
120 }
121 }
122 IntGdiCombineRgn(VisRgn, VisRgn, ClipRgn, RGN_DIFF);
123 REGION_Delete(ClipRgn);
124 }
125 CurrentWindow = CurrentWindow->spwndNext;
126 }
127 }
128
129 if (Wnd->hrgnClip && !(Wnd->style & WS_MINIMIZE))
130 {
131 PREGION WndRgnClip = REGION_LockRgn(Wnd->hrgnClip);
132 if (WndRgnClip)
133 {
134 REGION_bOffsetRgn(VisRgn, -Wnd->rcWindow.left, -Wnd->rcWindow.top);
135 IntGdiCombineRgn(VisRgn, VisRgn, WndRgnClip, RGN_AND);
136 REGION_bOffsetRgn(VisRgn, Wnd->rcWindow.left, Wnd->rcWindow.top);
137 REGION_UnlockRgn(WndRgnClip);
138 }
139 }
140
141 return VisRgn;
142}
143
146 PWND Wnd,
147 PREGION NewlyExposed)
148{
149 PWND Parent;
151
152 ASSERT_REFS_CO(Wnd);
153
154 Parent = Wnd->spwndParent;
155 if(Parent)
156 {
157 PREGION TempRgn = IntSysCreateRectpRgn(0, 0, 0, 0);
158
159 if (!TempRgn)
160 return;
161
162 IntGdiCombineRgn(TempRgn, NewlyExposed, NULL, RGN_COPY);
163 REGION_bOffsetRgn(TempRgn,
164 Wnd->rcWindow.left - Parent->rcClient.left,
165 Wnd->rcWindow.top - Parent->rcClient.top);
166
167 UserRefObjectCo(Parent, &Ref);
172
173 REGION_Delete(TempRgn);
174 }
175}
176
177/* EOF */
unsigned char BOOLEAN
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:732
#define ERR(fmt,...)
Definition: debug.h:110
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:103
#define NULL
Definition: types.h:112
#define FASTCALL
Definition: nt_native.h:50
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:40
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:27
#define WS_MINIMIZE
Definition: pedump.c:622
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_EX_TRANSPARENT
Definition: pedump.c:649
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define IntSysCreateRectpRgnIndirect(prc)
Definition: region.h:93
Definition: region.h:8
Definition: object.h:4
Definition: ntuser.h:694
DWORD ExStyle
Definition: ntuser.h:704
HRGN hrgnClip
Definition: ntuser.h:733
DWORD style
Definition: ntuser.h:706
struct _WND * spwndChild
Definition: ntuser.h:714
RECT rcClient
Definition: ntuser.h:717
struct _WND * spwndNext
Definition: ntuser.h:711
RECT rcWindow
Definition: ntuser.h:716
struct _WND * spwndParent
Definition: ntuser.h:713
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
BOOL FASTCALL co_UserRedrawWindow(PWND Window, const RECTL *UpdateRect, PREGION UpdateRgn, ULONG Flags)
Definition: painting.c:888
#define ASSERT_REFS_CO(_obj_)
Definition: userfuncs.h:14
PREGION FASTCALL VIS_ComputeVisibleRegion(PWND Wnd, BOOLEAN ClientArea, BOOLEAN ClipChildren, BOOLEAN ClipSiblings)
Definition: vis.c:13
VOID FASTCALL co_VIS_WindowLayoutChanged(PWND Wnd, PREGION NewlyExposed)
Definition: vis.c:145
VOID FASTCALL REGION_Delete(PREGION pRgn)
Definition: region.c:2449
PREGION FASTCALL REGION_LockRgn(_In_ HRGN hrgn)
Definition: region.c:2358
VOID FASTCALL REGION_UnlockRgn(_In_ PREGION prgn)
Definition: region.c:2373
PREGION FASTCALL IntSysCreateRectpRgn(INT LeftRect, INT TopRect, INT RightRect, INT BottomRect)
Definition: region.c:2407
BOOL FASTCALL REGION_bOffsetRgn(_Inout_ PREGION prgn, _In_ INT cx, _In_ INT cy)
Definition: region.c:2707
INT FASTCALL IntGdiCombineRgn(PREGION prgnDest, PREGION prgnSrc1, PREGION prgnSrc2, INT iCombineMode)
Definition: region.c:2487
PWND FASTCALL VerifyWnd(PWND pWnd)
Definition: window.c:86
#define RGN_DIFF
Definition: wingdi.h:358
#define RGN_COPY
Definition: wingdi.h:357
#define RGN_AND
Definition: wingdi.h:356
#define RDW_ERASE
Definition: winuser.h:1211
#define RDW_ALLCHILDREN
Definition: winuser.h:1221
#define RDW_FRAME
Definition: winuser.h:1212
#define RDW_INVALIDATE
Definition: winuser.h:1214