ReactOS 0.4.16-dev-91-g764881a
engwindow.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: GDI WNDOBJ Functions
5 * FILE: win32ss/gdi/eng/engwindow.c
6 * PROGRAMER: Gregor Anich
7 */
8
9#include <win32k.h>
10#include <debug.h>
12
14
15/*
16 * Calls the WNDOBJCHANGEPROC of the given WNDOBJ
17 */
18VOID
21 _In_ EWNDOBJ *Clip,
22 _In_ FLONG flChanged)
23{
24 if (Clip->ChangeProc == NULL)
25 {
26 return;
27 }
28
29 /* check flags of the WNDOBJ */
30 flChanged &= Clip->Flags;
31 if (flChanged == 0)
32 {
33 return;
34 }
35
36 TRACE("Calling WNDOBJCHANGEPROC (0x%p), Changed = 0x%x\n",
37 Clip->ChangeProc, flChanged);
38
39 /* Call the WNDOBJCHANGEPROC */
40 if (flChanged == WOC_CHANGED)
41 Clip->ChangeProc(NULL, flChanged);
42 else
43 Clip->ChangeProc((WNDOBJ *)Clip, flChanged);
44}
45
46/*
47 * Fills the CLIPOBJ and client rect of the WNDOBJ with the data from the given WND
48 */
52 EWNDOBJ* Clip,
54{
55 PREGION visRgn;
56
57 TRACE("IntEngWndUpdateClipObj\n");
58
60 if (visRgn != NULL)
61 {
62 if (visRgn->rdh.nCount > 0)
63 {
64 IntEngUpdateClipRegion((XCLIPOBJ*)Clip, visRgn->rdh.nCount, visRgn->Buffer, &visRgn->rdh.rcBound);
65 TRACE("Created visible region with %lu rects\n", visRgn->rdh.nCount);
66 TRACE(" BoundingRect: %d, %d %d, %d\n",
67 visRgn->rdh.rcBound.left, visRgn->rdh.rcBound.top,
68 visRgn->rdh.rcBound.right, visRgn->rdh.rcBound.bottom);
69 {
70 ULONG i;
71 for (i = 0; i < visRgn->rdh.nCount; i++)
72 {
73 TRACE(" Rect #%lu: %ld,%ld %ld,%ld\n", i+1,
74 visRgn->Buffer[i].left, visRgn->Buffer[i].top,
75 visRgn->Buffer[i].right, visRgn->Buffer[i].bottom);
76 }
77 }
78 }
79 REGION_Delete(visRgn);
80 }
81 else
82 {
83 /* Fall back to client rect */
84 IntEngUpdateClipRegion((XCLIPOBJ*)Clip, 1, &Window->rcClient, &Window->rcClient);
85 }
86
87 /* Update the WNDOBJ */
88 Clip->rclClient = Window->rcClient;
89 Clip->iUniq++;
90
91 return TRUE;
92}
93
94/*
95 * Updates all WNDOBJs of the given WND and calls the change-procs.
96 */
97VOID
101 _In_ FLONG flChanged)
102{
103 EWNDOBJ *Clip;
104
106
108 if (!Clip)
109 {
110 return;
111 }
112
113 ASSERT(Clip->Hwnd == Window->head.h);
114 // if (Clip->pvConsumer != NULL)
115 {
116 /* Update the WNDOBJ */
117 switch (flChanged)
118 {
119 case WOC_RGN_CLIENT:
120 /* Update the clipobj and client rect of the WNDOBJ */
122 break;
123
124 case WOC_DELETE:
125 /* FIXME: Should the WNDOBJs be deleted by win32k or by the driver? */
126 break;
127 }
128
129 /* Call the change proc */
130 IntEngWndCallChangeProc(Clip, flChanged);
131
132 /* HACK: Send WOC_CHANGED after WOC_RGN_CLIENT */
133 if (flChanged == WOC_RGN_CLIENT)
134 {
136 }
137 }
138}
139
140/*
141 * @implemented
142 */
143WNDOBJ*
146 SURFOBJ *pso,
147 HWND hWnd,
148 WNDOBJCHANGEPROC pfn,
149 FLONG fl,
150 int iPixelFormat)
151{
152 EWNDOBJ *Clip = NULL;
153 WNDOBJ *WndObjUser = NULL;
154 PWND Window;
155
156 TRACE("EngCreateWnd: pso = 0x%p, hwnd = 0x%p, pfn = 0x%p, fl = 0x%lx, pixfmt = %d\n",
157 pso, hWnd, pfn, fl, iPixelFormat);
158
160
162 {
163 FIXME("Unsupported flags: 0x%lx\n", fl & ~(WO_RGN_CLIENT_DELTA | WO_RGN_CLIENT | WO_RGN_SURFACE_DELTA | WO_RGN_SURFACE));
164 }
165
166 /* Get window object */
168 if (Window == NULL)
169 {
170 goto Exit;
171 }
172
173 /* Create WNDOBJ */
175 if (Clip == NULL)
176 {
177 ERR("Failed to allocate memory for a WND structure!\n");
178 goto Exit;
179 }
181
182 /* Fill the clipobj */
183 if (!IntEngWndUpdateClipObj(Clip, Window))
184 {
185 EngFreeMem(Clip);
186 goto Exit;
187 }
188
189 /* Fill user object */
190 WndObjUser = (WNDOBJ *)Clip;
191 WndObjUser->psoOwner = pso;
192 WndObjUser->pvConsumer = NULL;
193
194 /* Fill internal object */
195 Clip->Hwnd = hWnd;
196 Clip->ChangeProc = pfn;
197 /* Keep track of relevant flags */
199 if (fl & WO_SPRITE_NOTIFY)
201 /* Those should always be sent */
202 Clip->Flags |= WOC_CHANGED | WOC_DELETE;
204
205 /* associate object with window */
206 UserSetProp(Window, AtomWndObj, Clip, TRUE);
207 ++gcountPWO;
208
209 TRACE("EngCreateWnd: SUCCESS: %p!\n", WndObjUser);
210
211Exit:
212 UserLeave();
213 return WndObjUser;
214}
215
216
217/*
218 * @implemented
219 */
220VOID
223 IN WNDOBJ *pwo)
224{
225 EWNDOBJ* Clip = (EWNDOBJ *)pwo;//CONTAINING_RECORD(pwo, XCLIPOBJ, WndObj);
226 PWND Window;
227
228 TRACE("EngDeleteWnd: pwo = 0x%p\n", pwo);
229
231
232 /* Get window object */
234 if (Window == NULL)
235 {
236 ERR("Couldnt get window object for WndObjInt->Hwnd!!!\n");
237 }
238 else
239 {
240 /* Remove object from window */
242 }
243 --gcountPWO;
244
245 UserLeave();
246
247 /* Free resources */
249 EngFreeMem(Clip);
250}
251
252
253/*
254 * @implemented
255 */
256BOOL
259 IN WNDOBJ *pwo,
260 IN ULONG cj,
261 OUT ULONG *pul)
262{
263 /* Relay */
264 return CLIPOBJ_bEnum(&pwo->coClient, cj, pul);
265}
266
267
268/*
269 * @implemented
270 */
271ULONG
274 IN WNDOBJ *pwo,
275 IN ULONG iType,
276 IN ULONG iDirection,
277 IN ULONG cLimit)
278{
279 /* Relay */
280 // FIXME: Should we enumerate all rectangles or not?
281 return CLIPOBJ_cEnumStart(&pwo->coClient, FALSE, iType, iDirection, cLimit);
282}
283
284
285/*
286 * @implemented
287 */
288VOID
291 IN WNDOBJ *pwo,
292 IN PVOID pvConsumer)
293{
294 EWNDOBJ* Clip = (EWNDOBJ *)pwo;//CONTAINING_RECORD(pwo, XCLIPOBJ, WndObj);
295 BOOL Hack;
296
297 TRACE("WNDOBJ_vSetConsumer: pwo = 0x%p, pvConsumer = 0x%p\n", pwo, pvConsumer);
298
299 Hack = (pwo->pvConsumer == NULL);
300 pwo->pvConsumer = pvConsumer;
301
302 /* HACKHACKHACK
303 *
304 * MSDN says that the WNDOBJCHANGEPROC will be called with the most recent state
305 * when a WNDOBJ is created - we do it here because most drivers will need pvConsumer
306 * in the callback to identify the WNDOBJ I think.
307 *
308 * - blight
309 */
310 if (Hack)
311 {
312 FIXME("Is this hack really needed?\n");
316 }
317}
318
319/* EOF */
320
unsigned char BOOLEAN
HWND hWnd
Definition: settings.c:17
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERR(fmt,...)
Definition: precomp.h:57
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:106
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define APIENTRY
Definition: api.h:79
VOID APIENTRY WNDOBJ_vSetConsumer(IN WNDOBJ *pwo, IN PVOID pvConsumer)
Definition: engwindow.c:290
VOID FASTCALL IntEngWndCallChangeProc(_In_ EWNDOBJ *Clip, _In_ FLONG flChanged)
Definition: engwindow.c:20
INT gcountPWO
Definition: engwindow.c:13
WNDOBJ *APIENTRY EngCreateWnd(SURFOBJ *pso, HWND hWnd, WNDOBJCHANGEPROC pfn, FLONG fl, int iPixelFormat)
Definition: engwindow.c:145
VOID FASTCALL IntEngWindowChanged(_In_ PWND Window, _In_ FLONG flChanged)
Definition: engwindow.c:99
BOOLEAN FASTCALL IntEngWndUpdateClipObj(EWNDOBJ *Clip, PWND Window)
Definition: engwindow.c:51
VOID APIENTRY EngDeleteWnd(IN WNDOBJ *pwo)
Definition: engwindow.c:222
ULONG APIENTRY WNDOBJ_cEnumStart(IN WNDOBJ *pwo, IN ULONG iType, IN ULONG iDirection, IN ULONG cLimit)
Definition: engwindow.c:273
BOOL APIENTRY WNDOBJ_bEnum(IN WNDOBJ *pwo, IN ULONG cj, OUT ULONG *pul)
Definition: engwindow.c:258
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ASSERT(a)
Definition: mode.c:44
#define _In_
Definition: ms_sal.h:308
#define FASTCALL
Definition: nt_native.h:50
unsigned long FLONG
Definition: ntbasedef.h:366
ATOM AtomWndObj
Definition: ntuser.c:20
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
#define EngFreeMem
Definition: polytest.cpp:56
#define FL_ZERO_MEMORY
Definition: polytest.cpp:58
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
HANDLE FASTCALL UserRemoveProp(_In_ PWND Window, _In_ ATOM Atom, _In_ BOOLEAN SystemProp)
#define ASSERT_IRQL_LESS_OR_EQUAL(x)
Definition: debug.h:251
static void Exit(void)
Definition: sock.c:1330
#define TRACE(s)
Definition: solgame.cpp:4
long bottom
Definition: polytest.cpp:53
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
Definition: window.c:28
WNDOBJCHANGEPROC ChangeProc
Definition: engobjects.h:102
int PixelFormat
Definition: engobjects.h:104
HWND Hwnd
Definition: engobjects.h:101
FLONG Flags
Definition: engobjects.h:103
Definition: region.h:8
RECTL * Buffer
Definition: region.h:16
RGNDATAHEADER rdh
Definition: region.h:15
PVOID pvConsumer
Definition: winddi.h:1228
SURFOBJ * psoOwner
Definition: winddi.h:1230
Definition: ntuser.h:694
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
int32_t INT
Definition: typedefs.h:58
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:124
PREGION FASTCALL VIS_ComputeVisibleRegion(PWND Wnd, BOOLEAN ClientArea, BOOLEAN ClipChildren, BOOLEAN ClipSiblings)
Definition: vis.c:13
VOID FASTCALL IntEngUpdateClipRegion(XCLIPOBJ *Clip, ULONG count, const RECTL *pRect, const RECTL *rcBounds)
Definition: clip.c:173
VOID FASTCALL IntEngFreeClipResources(XCLIPOBJ *Clip)
Definition: clip.c:164
VOID FASTCALL IntEngInitClipObj(XCLIPOBJ *Clip)
Definition: clip.c:158
VOID FASTCALL REGION_Delete(PREGION pRgn)
Definition: region.c:2449
HANDLE FASTCALL UserGetProp(_In_ PWND Window, _In_ ATOM Atom, _In_ BOOLEAN SystemProp)
Definition: prop.c:46
#define GDITAG_WNDOBJ
Definition: tags.h:180
#define WOC_SPRITE_OVERLAP
Definition: winddi.h:1271
_In_ WNDOBJ * pwo
Definition: winddi.h:4147
_In_ HANDLE _In_ SURFOBJ * pso
Definition: winddi.h:3665
_In_ FLONG fl
Definition: winddi.h:1279
ENGAPI BOOL APIENTRY CLIPOBJ_bEnum(_In_ CLIPOBJ *pco, _In_ ULONG cj, _Out_bytecap_(cj) ULONG *pul)
Definition: clip.c:319
#define WOC_DRAWN
Definition: winddi.h:1270
#define WO_DRAW_NOTIFY
Definition: winddi.h:1599
_In_ ULONG cj
Definition: winddi.h:3540
_In_ LONG iPixelFormat
Definition: winddi.h:3488
#define WO_RGN_WINDOW
Definition: winddi.h:1598
ENGAPI ULONG APIENTRY CLIPOBJ_cEnumStart(_Inout_ CLIPOBJ *pco, _In_ BOOL bAll, _In_ ULONG iType, _In_ ULONG iDirection, _In_ ULONG cLimit)
Definition: clip.c:255
#define WO_RGN_DESKTOP_COORD
Definition: winddi.h:1601
#define WOC_SPRITE_NO_OVERLAP
Definition: winddi.h:1272
#define WO_RGN_SURFACE_DELTA
Definition: winddi.h:1595
#define WO_RGN_CLIENT
Definition: winddi.h:1594
#define WOC_CHANGED
Definition: winddi.h:1268
#define WOC_DELETE
Definition: winddi.h:1269
_In_ ULONG iType
Definition: winddi.h:3748
#define WO_SPRITE_NOTIFY
Definition: winddi.h:1600
#define WO_RGN_UPDATE_ALL
Definition: winddi.h:1597
#define WO_RGN_SURFACE
Definition: winddi.h:1596
#define WO_RGN_CLIENT_DELTA
Definition: winddi.h:1593
#define WOC_RGN_CLIENT
Definition: winddi.h:1265