Fix race condition when one thread changes the update region of a window
[reactos.git] / reactos / subsys / win32k / include / window.h
1 #ifndef _WIN32K_WINDOW_H
2 #define _WIN32K_WINDOW_H
3
4 struct _PROPERTY;
5 struct _WINDOW_OBJECT;
6 typedef struct _WINDOW_OBJECT *PWINDOW_OBJECT;
7
8 #include <windows.h>
9 #include <ddk/ntddk.h>
10 #include <include/class.h>
11 #include <include/msgqueue.h>
12 #include <include/winsta.h>
13 #include <include/dce.h>
14 #include <include/prop.h>
15
16
17 VOID FASTCALL
18 WinPosSetupInternalPos(VOID);
19
20 typedef struct _INTERNALPOS
21 {
22 RECT NormalRect;
23 POINT IconPos;
24 POINT MaxPos;
25 } INTERNALPOS, *PINTERNALPOS;
26
27 typedef struct _WINDOW_OBJECT
28 {
29 /* Pointer to the window class. */
30 PWNDCLASS_OBJECT Class;
31 /* Extended style. */
32 DWORD ExStyle;
33 /* Window name. */
34 UNICODE_STRING WindowName;
35 /* Style. */
36 DWORD Style;
37 /* Context help id */
38 DWORD ContextHelpId;
39 /* system menu handle. */
40 HMENU SystemMenu;
41 /* Handle of the module that created the window. */
42 HINSTANCE Instance;
43 /* Entry in the thread's list of windows. */
44 LIST_ENTRY ListEntry;
45 /* Pointer to the extra data associated with the window. */
46 PCHAR ExtraData;
47 /* Size of the extra data associated with the window. */
48 ULONG ExtraDataSize;
49 /* Position of the window. */
50 RECT WindowRect;
51 /* Position of the window's client area. */
52 RECT ClientRect;
53 /* Handle for the window. */
54 HANDLE Self;
55 /* Window flags. */
56 ULONG Flags;
57 /* Window menu handle or window id */
58 UINT IDMenu;
59 /* Handle of region of the window to be updated. */
60 HANDLE UpdateRegion;
61 HANDLE NCUpdateRegion;
62 /* Lock to be held when manipulating (NC)UpdateRegion */
63 FAST_MUTEX UpdateLock;
64 /* Pointer to the owning thread's message queue. */
65 PUSER_MESSAGE_QUEUE MessageQueue;
66 struct _WINDOW_OBJECT* FirstChild;
67 struct _WINDOW_OBJECT* LastChild;
68 /* Lock for the list of child windows. */
69 FAST_MUTEX ChildrenListLock;
70 struct _WINDOW_OBJECT* NextSibling;
71 struct _WINDOW_OBJECT* PrevSibling;
72 /* Entry in the list of thread windows. */
73 LIST_ENTRY ThreadListEntry;
74 /* Pointer to the parent window. */
75 struct _WINDOW_OBJECT* Parent;
76 /* Pointer to the owner window. */
77 struct _WINDOW_OBJECT* Owner;
78 /* DC Entries (DCE) */
79 PDCE Dce;
80 /* Property list head.*/
81 LIST_ENTRY PropListHead;
82 FAST_MUTEX PropListLock;
83 ULONG PropListItems;
84 /* Scrollbar info */
85 PSCROLLBARINFO pHScroll;
86 PSCROLLBARINFO pVScroll;
87 PSCROLLBARINFO wExtra;
88 LONG UserData;
89 BOOL Unicode;
90 WNDPROC WndProcA;
91 WNDPROC WndProcW;
92 PETHREAD OwnerThread;
93 HWND hWndLastPopup; /* handle to last active popup window (wine doesn't use pointer, for unk. reason)*/
94 PINTERNALPOS InternalPos;
95 } WINDOW_OBJECT; /* PWINDOW_OBJECT already declared at top of file */
96
97 /* Window flags. */
98 #define WINDOWOBJECT_NEED_SIZE (0x00000001)
99 #define WINDOWOBJECT_NEED_ERASEBKGND (0x00000002)
100 #define WINDOWOBJECT_NEED_NCPAINT (0x00000004)
101 #define WINDOWOBJECT_NEED_INTERNALPAINT (0x00000008)
102 #define WINDOWOBJECT_RESTOREMAX (0x00000020)
103
104 inline BOOL IntIsDesktopWindow(PWINDOW_OBJECT WindowObject);
105
106 inline BOOL IntIsBroadcastHwnd(HWND hwnd);
107
108 BOOL FASTCALL
109 IntIsWindow(HWND hWnd);
110
111 HWND* FASTCALL
112 IntWinListChildren(PWINDOW_OBJECT Window);
113
114 BOOLEAN FASTCALL
115 IntWndBelongsToThread(PWINDOW_OBJECT Window, PW32THREAD ThreadData);
116
117 NTSTATUS FASTCALL
118 InitWindowImpl (VOID);
119
120 NTSTATUS FASTCALL
121 CleanupWindowImpl (VOID);
122
123 VOID FASTCALL
124 IntGetClientRect (PWINDOW_OBJECT WindowObject, PRECT Rect);
125
126 PWINDOW_OBJECT FASTCALL
127 IntGetWindowObject (HWND hWnd);
128
129 VOID FASTCALL
130 IntReleaseWindowObject (PWINDOW_OBJECT Window);
131
132 HWND FASTCALL
133 IntGetActiveWindow (VOID);
134
135 BOOL FASTCALL
136 IntIsWindowVisible (HWND Wnd);
137
138 BOOL FASTCALL
139 IntIsChildWindow (HWND Parent, HWND Child);
140
141 BOOL FASTCALL
142 IntSetProp(PWINDOW_OBJECT Wnd, ATOM Atom, HANDLE Data);
143
144 PPROPERTY FASTCALL
145 IntGetProp(PWINDOW_OBJECT WindowObject, ATOM Atom);
146
147 DWORD FASTCALL
148 IntGetWindowThreadProcessId(PWINDOW_OBJECT Wnd, PDWORD pid);
149
150 VOID FASTCALL
151 IntUnlinkWindow(PWINDOW_OBJECT Wnd);
152
153 VOID FASTCALL
154 IntLinkWindow(PWINDOW_OBJECT Wnd, PWINDOW_OBJECT WndParent, PWINDOW_OBJECT WndPrevSibling);
155
156 PWINDOW_OBJECT FASTCALL
157 IntGetAncestor(PWINDOW_OBJECT Wnd, UINT Type);
158
159 PWINDOW_OBJECT FASTCALL
160 IntGetParent(PWINDOW_OBJECT Wnd);
161
162 typedef enum _WINLOCK_TYPE
163 {
164 None,
165 Any,
166 Shared,
167 Exclusive
168 } WINLOCK_TYPE;
169
170 #define ASSERT_WINLOCK(a) assert(IntVerifyWinLock(a))
171
172 inline VOID IntAcquireWinLockShared();
173 inline VOID IntAcquireWinLockExclusive();
174 inline VOID IntReleaseWinLock();
175 BOOL FASTCALL IntVerifyWinLock(WINLOCK_TYPE Type);
176 WINLOCK_TYPE FASTCALL IntSuspendWinLock();
177 VOID FASTCALL IntRestoreWinLock(WINLOCK_TYPE Type);
178 inline BOOL IntInitializeWinLock();
179 inline VOID IntDeleteWinLock();
180 DWORD IntRemoveWndProcHandle(WNDPROC Handle);
181 DWORD IntRemoveProcessWndProcHandles(HANDLE ProcessID);
182 DWORD IntAddWndProcHandle(WNDPROC WindowProc, BOOL IsUnicode);
183
184 #endif /* _WIN32K_WINDOW_H */
185
186 /* EOF */