1 /**
2  * FreeRDP: A Remote Desktop Protocol Implementation
3  * Window Alternate Secondary Drawing Orders Interface API
4  *
5  * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #ifndef FREERDP_UPDATE_WINDOW_H
21 #define FREERDP_UPDATE_WINDOW_H
22 
23 #include <freerdp/types.h>
24 
25 /* Window Order Header Flags */
26 #define WINDOW_ORDER_TYPE_WINDOW 0x01000000
27 #define WINDOW_ORDER_TYPE_NOTIFY 0x02000000
28 #define WINDOW_ORDER_TYPE_DESKTOP 0x04000000
29 
30 #define WINDOW_ORDER_STATE_NEW 0x10000000
31 #define WINDOW_ORDER_STATE_DELETED 0x20000000
32 
33 /* Window Order Update */
34 #define WINDOW_ORDER_FIELD_OWNER 0x00000002
35 #define WINDOW_ORDER_FIELD_STYLE 0x00000008
36 #define WINDOW_ORDER_FIELD_SHOW 0x00000010
37 #define WINDOW_ORDER_FIELD_TITLE 0x00000004
38 #define WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET 0x00004000
39 #define WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE 0x00010000
40 #define WINDOW_ORDER_FIELD_RESIZE_MARGIN_X 0x00000080
41 #define WINDOW_ORDER_FIELD_RESIZE_MARGIN_Y 0x08000000
42 #define WINDOW_ORDER_FIELD_RP_CONTENT 0x00020000
43 #define WINDOW_ORDER_FIELD_ROOT_PARENT 0x00040000
44 #define WINDOW_ORDER_FIELD_WND_OFFSET 0x00000800
45 #define WINDOW_ORDER_FIELD_WND_CLIENT_DELTA 0x00008000
46 #define WINDOW_ORDER_FIELD_WND_SIZE 0x00000400
47 #define WINDOW_ORDER_FIELD_WND_RECTS 0x00000100
48 #define WINDOW_ORDER_FIELD_VIS_OFFSET 0x00001000
49 #define WINDOW_ORDER_FIELD_VISIBILITY 0x00000200
50 #define WINDOW_ORDER_FIELD_OVERLAY_DESCRIPTION 0x00400000
51 #define WINDOW_ORDER_FIELD_ICON_OVERLAY_NULL 0x00200000
52 #define WINDOW_ORDER_FIELD_TASKBAR_BUTTON 0x00800000
53 #define WINDOW_ORDER_FIELD_ENFORCE_SERVER_ZORDER 0x00080000
54 #define WINDOW_ORDER_FIELD_APPBAR_STATE 0x00000040
55 #define WINDOW_ORDER_FIELD_APPBAR_EDGE 0x00000001
56 
57 /* Window (chached) Icon */
58 #define WINDOW_ORDER_ICON 0x40000000
59 #define WINDOW_ORDER_CACHED_ICON 0x80000000
60 #define WINDOW_ORDER_FIELD_ICON_BIG 0x00002000
61 #define WINDOW_ORDER_FIELD_ICON_OVERLAY 0x00100000
62 
63 #define WINDOW_ORDER_FIELD_NOTIFY_VERSION 0x00000008
64 #define WINDOW_ORDER_FIELD_NOTIFY_TIP 0x00000001
65 #define WINDOW_ORDER_FIELD_NOTIFY_INFO_TIP 0x00000002
66 #define WINDOW_ORDER_FIELD_NOTIFY_STATE 0x00000004
67 #define WINDOW_ORDER_FIELD_DESKTOP_NONE 0x00000001
68 #define WINDOW_ORDER_FIELD_DESKTOP_HOOKED 0x00000002
69 #define WINDOW_ORDER_FIELD_DESKTOP_ARC_COMPLETED 0x00000004
70 #define WINDOW_ORDER_FIELD_DESKTOP_ARC_BEGAN 0x00000008
71 #define WINDOW_ORDER_FIELD_DESKTOP_ZORDER 0x00000010
72 #define WINDOW_ORDER_FIELD_DESKTOP_ACTIVE_WND 0x00000020
73 
74 /* Window Show States */
75 #define WINDOW_HIDE 0x00
76 #define WINDOW_SHOW_MINIMIZED 0x02
77 #define WINDOW_SHOW_MAXIMIZED 0x03
78 #define WINDOW_SHOW 0x05
79 
80 /* Window Styles */
81 #ifndef _WIN32
82 #define WS_BORDER 0x00800000
83 #define WS_CAPTION 0x00C00000
84 #define WS_CHILD 0x40000000
85 #define WS_CLIPCHILDREN 0x02000000
86 #define WS_CLIPSIBLINGS 0x04000000
87 #define WS_DISABLED 0x08000000
88 #define WS_DLGFRAME 0x00400000
89 #define WS_GROUP 0x00020000
90 #define WS_HSCROLL 0x00100000
91 #define WS_ICONIC 0x20000000
92 #define WS_MAXIMIZE 0x01000000
93 #define WS_MAXIMIZEBOX 0x00010000
94 #define WS_MINIMIZE 0x20000000
95 #define WS_MINIMIZEBOX 0x00020000
96 #define WS_OVERLAPPED 0x00000000
97 #define WS_OVERLAPPEDWINDOW \
98 	(WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX)
99 #define WS_POPUP 0x80000000
100 #define WS_POPUPWINDOW (WS_POPUP | WS_BORDER | WS_SYSMENU)
101 #define WS_SIZEBOX 0x00040000
102 #define WS_SYSMENU 0x00080000
103 #define WS_TABSTOP 0x00010000
104 #define WS_THICKFRAME 0x00040000
105 #define WS_VISIBLE 0x10000000
106 #define WS_VSCROLL 0x00200000
107 #endif
108 
109 /* Extended Window Styles */
110 #ifndef _WIN32
111 #define WS_EX_ACCEPTFILES 0x00000010
112 #define WS_EX_APPWINDOW 0x00040000
113 #define WS_EX_CLIENTEDGE 0x00000200
114 #define WS_EX_COMPOSITED 0x02000000
115 #define WS_EX_CONTEXTHELP 0x00000400
116 #define WS_EX_CONTROLPARENT 0x00010000
117 #define WS_EX_DLGMODALFRAME 0x00000001
118 #define WS_EX_LAYERED 0x00080000
119 #define WS_EX_LAYOUTRTL 0x00400000
120 #define WS_EX_LEFT 0x00000000
121 #define WS_EX_LEFTSCROLLBAR 0x00004000
122 #define WS_EX_LTRREADING 0x00000000
123 #define WS_EX_MDICHILD 0x00000040
124 #define WS_EX_NOACTIVATE 0x08000000
125 #define WS_EX_NOINHERITLAYOUT 0x00100000
126 #define WS_EX_NOPARENTNOTIFY 0x00000004
127 #define WS_EX_OVERLAPPEDWINDOW (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE)
128 #define WS_EX_PALETTEWINDOW (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST)
129 #define WS_EX_RIGHT 0x00001000
130 #define WS_EX_RIGHTSCROLLBAR 0x00000000
131 #define WS_EX_RTLREADING 0x00002000
132 #define WS_EX_STATICEDGE 0x00020000
133 #define WS_EX_TOOLWINDOW 0x00000080
134 #define WS_EX_TOPMOST 0x00000008
135 #define WS_EX_TRANSPARENT 0x00000020
136 #define WS_EX_WINDOWEDGE 0x00000100
137 #endif
138 
139 /**
140  * This is a custom extended window style used by XRDP
141  * instructing the client to use local window decorations
142  */
143 
144 #define WS_EX_DECORATIONS 0x40000000
145 
146 struct _WINDOW_ORDER_INFO
147 {
148 	UINT32 windowId;
149 	UINT32 fieldFlags;
150 	UINT32 notifyIconId;
151 };
152 typedef struct _WINDOW_ORDER_INFO WINDOW_ORDER_INFO;
153 
154 struct _ICON_INFO
155 {
156 	UINT32 cacheEntry;
157 	UINT32 cacheId;
158 	UINT32 bpp;
159 	UINT32 width;
160 	UINT32 height;
161 	UINT32 cbColorTable;
162 	UINT32 cbBitsMask;
163 	UINT32 cbBitsColor;
164 	BYTE* bitsMask;
165 	BYTE* colorTable;
166 	BYTE* bitsColor;
167 };
168 typedef struct _ICON_INFO ICON_INFO;
169 
170 struct _CACHED_ICON_INFO
171 {
172 	UINT32 cacheEntry;
173 	UINT32 cacheId;
174 };
175 typedef struct _CACHED_ICON_INFO CACHED_ICON_INFO;
176 
177 struct _NOTIFY_ICON_INFOTIP
178 {
179 	UINT32 timeout;
180 	UINT32 flags;
181 	RAIL_UNICODE_STRING text;
182 	RAIL_UNICODE_STRING title;
183 };
184 typedef struct _NOTIFY_ICON_INFOTIP NOTIFY_ICON_INFOTIP;
185 
186 struct _WINDOW_STATE_ORDER
187 {
188 	UINT32 ownerWindowId;
189 	UINT32 style;
190 	UINT32 extendedStyle;
191 	UINT32 showState;
192 	RAIL_UNICODE_STRING titleInfo;
193 	INT32 clientOffsetX;
194 	INT32 clientOffsetY;
195 	UINT32 clientAreaWidth;
196 	UINT32 clientAreaHeight;
197 	UINT32 RPContent;
198 	UINT32 rootParentHandle;
199 	INT32 windowOffsetX;
200 	INT32 windowOffsetY;
201 	INT32 windowClientDeltaX;
202 	INT32 windowClientDeltaY;
203 	UINT32 windowWidth;
204 	UINT32 windowHeight;
205 	UINT32 numWindowRects;
206 	RECTANGLE_16* windowRects;
207 	INT32 visibleOffsetX;
208 	INT32 visibleOffsetY;
209 	UINT32 resizeMarginLeft;
210 	UINT32 resizeMarginTop;
211 	UINT32 resizeMarginRight;
212 	UINT32 resizeMarginBottom;
213 	UINT32 numVisibilityRects;
214 	RECTANGLE_16* visibilityRects;
215 	RAIL_UNICODE_STRING OverlayDescription;
216 	BYTE TaskbarButton;
217 	UINT8 EnforceServerZOrder;
218 	UINT8 AppBarState;
219 	UINT8 AppBarEdge;
220 };
221 typedef struct _WINDOW_STATE_ORDER WINDOW_STATE_ORDER;
222 
223 struct _WINDOW_ICON_ORDER
224 {
225 	ICON_INFO* iconInfo;
226 };
227 typedef struct _WINDOW_ICON_ORDER WINDOW_ICON_ORDER;
228 
229 struct _WINDOW_CACHED_ICON_ORDER
230 {
231 	CACHED_ICON_INFO cachedIcon;
232 };
233 typedef struct _WINDOW_CACHED_ICON_ORDER WINDOW_CACHED_ICON_ORDER;
234 
235 struct _NOTIFY_ICON_STATE_ORDER
236 {
237 	UINT32 version;
238 	RAIL_UNICODE_STRING toolTip;
239 	NOTIFY_ICON_INFOTIP infoTip;
240 	UINT32 state;
241 	ICON_INFO icon;
242 	CACHED_ICON_INFO cachedIcon;
243 };
244 typedef struct _NOTIFY_ICON_STATE_ORDER NOTIFY_ICON_STATE_ORDER;
245 
246 struct _MONITORED_DESKTOP_ORDER
247 {
248 	UINT32 activeWindowId;
249 	UINT32 numWindowIds;
250 	UINT32* windowIds;
251 };
252 typedef struct _MONITORED_DESKTOP_ORDER MONITORED_DESKTOP_ORDER;
253 
254 typedef BOOL (*pWindowCreate)(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
255                               const WINDOW_STATE_ORDER* window_state);
256 typedef BOOL (*pWindowUpdate)(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
257                               const WINDOW_STATE_ORDER* window_state);
258 typedef BOOL (*pWindowIcon)(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
259                             const WINDOW_ICON_ORDER* window_icon);
260 typedef BOOL (*pWindowCachedIcon)(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
261                                   const WINDOW_CACHED_ICON_ORDER* window_cached_icon);
262 typedef BOOL (*pWindowDelete)(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo);
263 typedef BOOL (*pNotifyIconCreate)(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
264                                   const NOTIFY_ICON_STATE_ORDER* notify_icon_state);
265 typedef BOOL (*pNotifyIconUpdate)(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
266                                   const NOTIFY_ICON_STATE_ORDER* notify_icon_state);
267 typedef BOOL (*pNotifyIconDelete)(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo);
268 typedef BOOL (*pMonitoredDesktop)(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
269                                   const MONITORED_DESKTOP_ORDER* monitored_desktop);
270 typedef BOOL (*pNonMonitoredDesktop)(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo);
271 
272 struct rdp_window_update
273 {
274 	rdpContext* context;     /* 0 */
275 	UINT32 paddingA[16 - 1]; /* 1 */
276 
277 	pWindowCreate WindowCreate;               /* 16 */
278 	pWindowUpdate WindowUpdate;               /* 17 */
279 	pWindowIcon WindowIcon;                   /* 18 */
280 	pWindowCachedIcon WindowCachedIcon;       /* 19 */
281 	pWindowDelete WindowDelete;               /* 20 */
282 	pNotifyIconCreate NotifyIconCreate;       /* 21 */
283 	pNotifyIconUpdate NotifyIconUpdate;       /* 22 */
284 	pNotifyIconDelete NotifyIconDelete;       /* 23 */
285 	pMonitoredDesktop MonitoredDesktop;       /* 24 */
286 	pNonMonitoredDesktop NonMonitoredDesktop; /* 25 */
287 	UINT32 paddingB[32 - 26];                 /* 26 */
288 
289 	/* internal */
290 };
291 typedef struct rdp_window_update rdpWindowUpdate;
292 
293 #endif /* FREERDP_UPDATE_WINDOW_H */
294