1
/*********************************************************
2
* Copyright (C) 2007 VMware, Inc. All rights reserved.
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License as published
6
* by the Free Software Foundation version 2.1 and no later version.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10
* or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
11
* License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program; if not, write to the Free Software Foundation, Inc.,
15
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17
*********************************************************/
20
* unityWindowTracker.h --
22
* Used to buffer state about a window manager.
24
* In general, clients will notify the window tracker of changes to the window
27
* UnityWindowTracker_AddWindow
28
* UnityWindowTracker_RemoveWindow
29
* UnityWindowTracker_MoveWindow
30
* UnityWindowTracker_ChangeWindowRegion
33
* And then call UnityWindowTracker_RequestUpdates to pull a summary of the updates
34
* out. The user may call the AddWindow, RemoveWindow, etc functions as often as they
35
* like. The window tracker's job is to compress a series of notifications into the
36
* smallest delta between updates.
38
* Typical use works something like:
40
* UnityWindowTracker_Init(...)
43
* UnityWindowTracker_AddWindow, UnityWindowTracker_MoveWindow, etc.
45
* UnityWindowTracker_RequestUpdates(...)
47
* UnityWindowTracker_Cleanup(...)
51
#ifndef _UNITY_WINDOW_TRACKER_H_
52
#define _UNITY_WINDOW_TRACKER_H_
54
#include "hashTable.h"
57
#include "unityCommon.h"
59
/* The maximum number of windows that this tracker can track */
60
#define UNITY_MAX_WINDOWS 1024
63
* UNITY_CHANGE_* track changes to windows as we're accumulating state for
66
#define UNITY_CHANGED_POSITION (1 << 0)
67
#define UNITY_CHANGED_REGION (1 << 1)
68
#define UNITY_CHANGED_ADDED (1 << 2)
69
#define UNITY_CHANGED_REMOVED (1 << 3)
70
#define UNITY_CHANGED_TITLE (1 << 4)
71
#define UNITY_CHANGED_ZORDER (1 << 5)
72
#define UNITY_CHANGED_WINDOW_STATE (1 << 6)
73
#define UNITY_CHANGED_WINDOW_ATTRIBUTES (1 << 7)
74
#define UNITY_CHANGED_WINDOW_TYPE (1 << 8)
75
#define UNITY_CHANGED_WINDOW_ICONS (1 << 9)
76
#define UNITY_CHANGED_WINDOW_DESKTOP (1 << 10)
77
#define UNITY_CHANGED_ACTIVE_DESKTOP (1 << 11)
80
* UNITY_UPDATE_* flags are passed to UnityWindowTracker_RequestUpdates
82
#define UNITY_UPDATE_INCREMENTAL (1 << 0)
83
#define UNITY_UPDATE_REMOVE_UNTOUCHED (1 << 1)
86
UNITY_WINDOW_ORDER_TOP = 0,
87
UNITY_WINDOW_ORDER_BOTTOM = UNITY_MAX_WINDOWS
91
* Unity callbacks passed to UnityWindowTracker_Init used to notify the
92
* caller of changes to the window system.
95
UNITY_UPDATE_ADD_WINDOW,
96
UNITY_UPDATE_MOVE_WINDOW,
97
UNITY_UPDATE_REMOVE_WINDOW,
98
UNITY_UPDATE_CHANGE_WINDOW_REGION,
99
UNITY_UPDATE_CHANGE_WINDOW_TITLE,
100
UNITY_UPDATE_CHANGE_ZORDER,
101
UNITY_UPDATE_CHANGE_WINDOW_STATE,
102
UNITY_UPDATE_CHANGE_WINDOW_ATTRIBUTE,
103
UNITY_UPDATE_CHANGE_WINDOW_TYPE,
104
UNITY_UPDATE_CHANGE_WINDOW_ICON,
105
UNITY_UPDATE_CHANGE_WINDOW_DESKTOP,
106
UNITY_UPDATE_CHANGE_ACTIVE_DESKTOP
110
* Single UnityUpdate struct that gets passed into the UnityUpdateCallback
111
* function. Unity updates have a very long way to travel (tools ->
112
* vmx -> mks -> vnc -> (wire) -> vnc -> ui) and having a single callback
113
* function greatly reduces the amount of plumbing that has to be written
114
* for every singe command.
117
typedef struct UnityUpdate {
118
UnityUpdateType type;
122
DynBuf windowPathUtf8;
138
} changeWindowRegion;
147
UnityWindowId ids[UNITY_MAX_WINDOWS];
157
UnityWindowAttribute attr;
159
} changeWindowAttribute;
163
UnityWindowType winType;
168
UnityIconType iconType;
173
UnityDesktopId desktopId;
174
} changeWindowDesktop;
177
UnityDesktopId desktopId;
178
} changeActiveDesktop;
183
typedef void (*UnityUpdateCallback)(void *param, UnityUpdate *update);
185
void UnityWindowTracker_ParseUnityUpdate(const char *result,
187
UnityUpdateCallback cb,
192
* Do not fiddle with these bits! They are included in this header to aid in debugging.
193
* Enjoy looking at them, but consider them READ ONLY (!!)
197
#define UNITY_INFO_ATTR_EXISTS (1 << 7)
198
#define UNITY_INFO_ATTR_CHANGED (1 << 6)
199
#define UNITY_INFO_ATTR_ENABLED (1 << 0)
207
UnityWindowType type;
208
UnityDesktopId desktopId;
209
DynBuf windowPathUtf8;
212
/* Each element is an OR of the UNITY_INFO_ATTR_* values */
213
unsigned char attributes[UNITY_MAX_ATTRIBUTES];
214
/* Ditto, but only EXISTS and CHANGED apply... */
215
unsigned char icons[UNITY_MAX_ICONS];
219
* Used to track if a window was reported during the last update cycle (whether or not
220
* its properties actually changed), so that we can automatically have windows removed
221
* in Unity implementations that poll for changes (such as Win32).
225
* Used to track which properties of a window changed during the last update cycle.
232
* This points back to the tracker. It's either this, or a bigger hack in
238
typedef struct _UnityWindowTracker UnityWindowTracker;
240
typedef void (*UnityDataFreeFunc)(UnityWindowTracker *tracker,
241
UnityWindowInfo *windowInfo,
244
struct _UnityWindowTracker {
246
UnityWindowId zorder[UNITY_MAX_WINDOWS];
247
uint32 count; // in zorder array
250
UnityDesktopId activeDesktopId;
251
Bool activeDesktopChanged;
254
* True if the guest should add hidden windows to the list of tracked windows.
255
* The windows will be added to the tracker with the hidden attribute.
256
* By default the guest will not add hidden windows to the tracker.
258
Bool addHiddenWindows;
261
UnityUpdateCallback cb;
264
UnityDataFreeFunc freeFn;
268
* Public Functions --
271
void UnityWindowTracker_Init(UnityWindowTracker *tracker,
272
UnityUpdateCallback cb);
273
void UnityWindowTracker_Cleanup(UnityWindowTracker *tracker);
274
void UnityWindowTracker_SetDataFreeFunc(UnityWindowTracker *tracker,
275
UnityDataFreeFunc freeFn);
276
UnityWindowInfo *UnityWindowTracker_AddWindow(UnityWindowTracker *tracker,
278
DynBuf *windowPathUtf8,
279
DynBuf *execPathUtf8);
280
UnityWindowInfo *UnityWindowTracker_AddWindowWithData(UnityWindowTracker *tracker,
282
DynBuf *windowPathUtf8,
283
DynBuf *execPathUtf8,
285
void UnityWindowTracker_MoveWindow(UnityWindowTracker *tracker,
286
UnityWindowId id, int x1, int y1, int x2,
288
void UnityWindowTracker_ChangeWindowRegion(UnityWindowTracker *tracker,
289
UnityWindowId id, RegionPtr region);
290
void UnityWindowTracker_RemoveWindow(UnityWindowTracker *tracker,
292
void UnityWindowTracker_SendUpdate(UnityWindowTracker *tracker,
293
UnityUpdate *update);
294
void UnityWindowTracker_SetWindowTitle(UnityWindowTracker *tracker,
297
void UnityWindowTracker_RemoveAllWindows(UnityWindowTracker *tracker);
300
* Please note that calling ChangeWindowState directly is deprecated. Use
301
* SetWindowAttribute and SetWindowType instead.
303
void UnityWindowTracker_ChangeWindowState(UnityWindowTracker *tracker,
307
* Deprecated. Use GetWindowAttribute and GetWindowType instead.
309
Bool UnityWindowTracker_GetWindowState(UnityWindowTracker *tracker,
313
void UnityWindowTracker_ChangeWindowAttribute(UnityWindowTracker *tracker,
315
UnityWindowAttribute attr,
317
Bool UnityWindowTracker_GetWindowAttribute(UnityWindowTracker *tracker,
319
UnityWindowAttribute attr,
321
void UnityWindowTracker_ChangeWindowType(UnityWindowTracker *tracker,
323
UnityWindowType winType);
324
Bool UnityWindowTracker_GetWindowType(UnityWindowTracker *tracker,
326
UnityWindowType *winType);
327
void UnityWindowTracker_NotifyIconChanged(UnityWindowTracker *tracker,
329
UnityIconType iconType);
330
void UnityWindowTracker_ChangeWindowDesktop(UnityWindowTracker *tracker,
332
UnityDesktopId desktopId);
333
Bool UnityWindowTracker_GetWindowDesktop(UnityWindowTracker *tracker,
335
UnityDesktopId *desktopId);
336
void UnityWindowTracker_ChangeActiveDesktop(UnityWindowTracker *tracker,
337
UnityDesktopId desktopId);
338
UnityDesktopId UnityWindowTracker_GetActiveDesktop(UnityWindowTracker *tracker);
339
void UnityWindowTracker_SetZOrder(UnityWindowTracker *tracker, UnityWindowId zorder[],
341
void UnityWindowTracker_SetZPosition(UnityWindowTracker *tracker, UnityWindowId window,
343
void UnityWindowTracker_RequestUpdates(UnityWindowTracker *tracker,
344
uint32 flags, void *param);
345
UnityWindowInfo *UnityWindowTracker_LookupWindow(UnityWindowTracker *tracker,
350
*-----------------------------------------------------------------------------
352
* UnityWindowTracker_GetWindowData --
354
* Returns the app data pointer associated with a particular Unity window.
357
* Pointer to the app data. May be NULL if no data is set or 'info' is invalid.
362
*-----------------------------------------------------------------------------
366
UnityWindowTracker_GetWindowData(UnityWindowTracker *tracker, // IN
367
UnityWindowInfo *info) // IN
369
return info ? info->data : NULL;
374
*-----------------------------------------------------------------------------
376
* UnityWindowTracker_GetWindowDataById --
378
* Returns the app data pointer associated with a particular Unity window ID.
381
* Pointer to the app data. May be NULL if no data is set or 'info' is invalid.
386
*-----------------------------------------------------------------------------
390
UnityWindowTracker_GetWindowDataById(UnityWindowTracker *tracker, // IN
391
UnityWindowId winId) // IN
393
return UnityWindowTracker_GetWindowData(tracker,
394
UnityWindowTracker_LookupWindow(tracker,