~ubuntu-branches/ubuntu/quantal/open-vm-tools/quantal-201210021442

« back to all changes in this revision

Viewing changes to services/plugins/unity/unityWindowTracker/unityWindowTracker.h

  • Committer: Package Import Robot
  • Author(s): Nate Muench
  • Date: 2012-01-23 16:09:45 UTC
  • mfrom: (1.4.6) (2.4.26 sid)
  • Revision ID: package-import@ubuntu.com-20120123160945-b6s0r1vkcovucpf3
Tags: 2011.12.20-562307-0ubuntu1
* Merge latest upstream git tag. Fixes building on Precise
  (LP: #898289, LP: #905612)

* Items merged from Debian unstable:
  - debian/control:
    + open-vm-tools recommends open-vm-dkms. (LP: #598933)
    + open-vm-tools now suggests open-vm-toolbox. (LP: #604998)
  (From 2011.08.21-471295-1 release)
  - Updating maintainer and uploaders fields.
  - Removing vcs fields.
  - Removing references to Daniel's old email address.
  - Updating years in copyright file.
  - Updating to standards version 3.9.2.
  - Updating to debhelper version 8.
  - Switching to source format 3.0 (quilt).
  - Removing manual chrpath setting.
  - Removing exclusion from plugins from debhelper shlibs.
  - Rediffing kvers.patch.
  (From 2011.09.23-491607-1 release)
  - Marking binary architecture-dependend packages as linux and kfreebsd
  only.
  - Removing liburiparser-dev from build-depends as upstream dropped
  unity support.
  - Building with libproc-dev on amd64 again.
  - Dropping disabling of dnet support.
  (From 2011.09.23-491607-2 release)
  - Adding doxygen to build-depends for api documentation.
  - Adding libcunit1-dev to build-depends for test suites.
  - Minimizing rules file.
  - Adding open-vm-tools-dev package, containing only the api
    documentation for now.
  (From 2011.09.23-491607-3 release)
  - Sorting overrides in rules alphabetically.
  - Compacting copyright file.
  - Adding udev rule to set timeout for vmware scsi devices
  (From 2011.12.20-562307-1 release)
  - Adding patch to correct typo in upstreams dkms configuration

* Remaining Changes:
  - Remove Stable part of version numbering.
  - debian folder:
    + Re-added open-vm-dkms.postinst & open-vm-dkms.prerm.
      * Allows dkms modules to compile upon installation.
  - debian/control:
    + Re-add open-vm-source and make into a transitional package
      for open-vm-toolbox.
    + Return dependancies that were moved to open-vm-tools back to
      open-vm-toolbox.
  - debian/rules and debian/open-vm-toolbox.lintian-overrides:
    + Make vmware-user-suid-wrapper suid-root
  - debian/rules:
    + Added CFLAGS field with -Wno-deprecated-declarations
      * Will suppress issues with glib 2.31 or later.
    + Add line to copy vmware-xdg-detect-de into place.
    + Install vmware-user.desktop through toolbox package.
  - debian/open-vm-tools.init:
    + Re-add 'modprobe [-r] vmblock'.
    + Add 'modprobe [-r] vmxnet'.
      * Incase it's not loaded during boot.
    + Remove and re-add pcnet32 module
      * Will be done before (remove) and after (readd) vmxnet module
        is added.
      * If vmxnet doesn't exist (aka modules fail to build), pcnet32 can be
        still used for network connectivity.
      * Workaround until a better fix can be done.
  - Re-add gnome-session to debian/local/xautostart.conf
  - Manpages removed (from debian/manpages):
    + vmmemctl.9
    + vmxnet3.9
    + Remove references to manpages that have been removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*********************************************************
2
 
 * Copyright (C) 2007 VMware, Inc. All rights reserved.
3
 
 *
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.
7
 
 *
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.
12
 
 *
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.
16
 
 *
17
 
 *********************************************************/
18
 
 
19
 
/*
20
 
 * unityWindowTracker.h --
21
 
 *
22
 
 *    Used to buffer state about a window manager.
23
 
 *
24
 
 *    In general, clients will notify the window tracker of changes to the window
25
 
 *    manager state via:
26
 
 *
27
 
 *       UnityWindowTracker_AddWindow
28
 
 *       UnityWindowTracker_RemoveWindow
29
 
 *       UnityWindowTracker_MoveWindow
30
 
 *       UnityWindowTracker_ChangeWindowRegion
31
 
 *       etc. etc.
32
 
 *
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.
37
 
 *
38
 
 *    Typical use works something like:
39
 
 *
40
 
 *         UnityWindowTracker_Init(...)
41
 
 *         many times do {
42
 
 *              many times to {
43
 
 *                 UnityWindowTracker_AddWindow, UnityWindowTracker_MoveWindow, etc.
44
 
 *              }
45
 
 *              UnityWindowTracker_RequestUpdates(...)
46
 
 *         }
47
 
 *         UnityWindowTracker_Cleanup(...)
48
 
 *
49
 
 */
50
 
 
51
 
#ifndef _UNITY_WINDOW_TRACKER_H_
52
 
#define _UNITY_WINDOW_TRACKER_H_
53
 
 
54
 
#include "hashTable.h"
55
 
#include "region.h"
56
 
#include "dynbuf.h"
57
 
#include "unityCommon.h"
58
 
 
59
 
/* The maximum number of windows that this tracker can track */
60
 
#define UNITY_MAX_WINDOWS           1024
61
 
 
62
 
/*
63
 
 * UNITY_CHANGE_* track changes to windows as we're accumulating state for
64
 
 * an update.
65
 
 */
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)
78
 
 
79
 
/*
80
 
 * UNITY_UPDATE_* flags are passed to UnityWindowTracker_RequestUpdates
81
 
 */
82
 
#define UNITY_UPDATE_INCREMENTAL       (1 << 0)
83
 
#define UNITY_UPDATE_REMOVE_UNTOUCHED  (1 << 1)
84
 
 
85
 
typedef enum {
86
 
   UNITY_WINDOW_ORDER_TOP = 0,
87
 
   UNITY_WINDOW_ORDER_BOTTOM = UNITY_MAX_WINDOWS
88
 
} UnityZOrder;
89
 
 
90
 
/*
91
 
 * Unity callbacks passed to UnityWindowTracker_Init used to notify the
92
 
 * caller of changes to the window system.
93
 
 */
94
 
typedef enum {
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
107
 
} UnityUpdateType;
108
 
 
109
 
/*
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.
115
 
 */
116
 
 
117
 
typedef struct UnityUpdate {
118
 
   UnityUpdateType type;
119
 
   union {
120
 
      struct {
121
 
         UnityWindowId     id;
122
 
         DynBuf            windowPathUtf8;
123
 
         DynBuf            execPathUtf8;
124
 
      } addWindow;
125
 
 
126
 
      struct {
127
 
         UnityWindowId     id;
128
 
      } removeWindow;
129
 
 
130
 
      struct {
131
 
         UnityWindowId     id;
132
 
         BoxRec            rect;
133
 
      } moveWindow;
134
 
 
135
 
      struct {
136
 
         UnityWindowId     id;
137
 
         RegionPtr         region;
138
 
      } changeWindowRegion;
139
 
 
140
 
      struct {
141
 
         UnityWindowId     id;
142
 
         DynBuf            titleUtf8;
143
 
      } changeWindowTitle;
144
 
 
145
 
      struct {
146
 
         uint32            count;
147
 
         UnityWindowId     ids[UNITY_MAX_WINDOWS];
148
 
      } zorder;
149
 
 
150
 
      struct {
151
 
         UnityWindowId     id;
152
 
         uint32            state;
153
 
      } changeWindowState;
154
 
 
155
 
      struct {
156
 
         UnityWindowId     id;
157
 
         UnityWindowAttribute attr;
158
 
         uint32 value;
159
 
      } changeWindowAttribute;
160
 
 
161
 
      struct {
162
 
         UnityWindowId id;
163
 
         UnityWindowType winType;
164
 
      } changeWindowType;
165
 
 
166
 
      struct {
167
 
         UnityWindowId id;
168
 
         UnityIconType iconType;
169
 
      } changeWindowIcon;
170
 
 
171
 
      struct {
172
 
         UnityWindowId id;
173
 
         UnityDesktopId desktopId;
174
 
      } changeWindowDesktop;
175
 
 
176
 
      struct {
177
 
         UnityDesktopId desktopId;
178
 
      } changeActiveDesktop;
179
 
 
180
 
   } u;
181
 
} UnityUpdate;
182
 
 
183
 
typedef void (*UnityUpdateCallback)(void *param, UnityUpdate *update);
184
 
 
185
 
void UnityWindowTracker_ParseUnityUpdate(const char *result,
186
 
                                         int len,
187
 
                                         UnityUpdateCallback cb,
188
 
                                         void *param);
189
 
 
190
 
/*
191
 
 * Internal state --
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 (!!)
194
 
 *
195
 
 */
196
 
 
197
 
#define UNITY_INFO_ATTR_EXISTS  (1 << 7)
198
 
#define UNITY_INFO_ATTR_CHANGED (1 << 6)
199
 
#define UNITY_INFO_ATTR_ENABLED (1 << 0)
200
 
 
201
 
typedef struct {
202
 
   UnityWindowId     id;
203
 
   DynBuf            titleUtf8;
204
 
   RegionPtr         region;
205
 
   BoxRec            rect;
206
 
   uint32            state;
207
 
   UnityWindowType   type;
208
 
   UnityDesktopId    desktopId;
209
 
   DynBuf            windowPathUtf8;
210
 
   DynBuf            execPathUtf8;
211
 
 
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];
216
 
 
217
 
   Bool              reap;
218
 
   /*
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).
222
 
    */
223
 
   Bool              touched;
224
 
   /*
225
 
    * Used to track which properties of a window changed during the last update cycle.
226
 
    */
227
 
   int               changed;
228
 
 
229
 
   void             *data;
230
 
 
231
 
   /*
232
 
    * This points back to the tracker. It's either this, or a bigger hack in
233
 
    * lib/misc/hash.c
234
 
    */
235
 
   void             *tracker;
236
 
} UnityWindowInfo;
237
 
 
238
 
typedef struct _UnityWindowTracker UnityWindowTracker;
239
 
 
240
 
typedef void (*UnityDataFreeFunc)(UnityWindowTracker *tracker,
241
 
                                  UnityWindowInfo *windowInfo,
242
 
                                  void *data);
243
 
 
244
 
struct _UnityWindowTracker {
245
 
   HashTable      *windows;
246
 
   UnityWindowId  zorder[UNITY_MAX_WINDOWS];
247
 
   uint32         count; // in zorder array
248
 
   Bool           zorderChanged;
249
 
 
250
 
   UnityDesktopId activeDesktopId;
251
 
   Bool           activeDesktopChanged;
252
 
 
253
 
   /*
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.
257
 
    */
258
 
   Bool           addHiddenWindows;
259
 
 
260
 
   void           *cbparam;
261
 
   UnityUpdateCallback cb;
262
 
   uint32         updateFlags;
263
 
 
264
 
   UnityDataFreeFunc freeFn;
265
 
};
266
 
 
267
 
/*
268
 
 * Public Functions --
269
 
 */
270
 
 
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,
277
 
                                              UnityWindowId id,
278
 
                                              DynBuf *windowPathUtf8,
279
 
                                              DynBuf *execPathUtf8);
280
 
UnityWindowInfo *UnityWindowTracker_AddWindowWithData(UnityWindowTracker *tracker,
281
 
                                                      UnityWindowId id,
282
 
                                                      DynBuf *windowPathUtf8,
283
 
                                                      DynBuf *execPathUtf8,
284
 
                                                      void *data);
285
 
void UnityWindowTracker_MoveWindow(UnityWindowTracker *tracker,
286
 
                                   UnityWindowId id, int x1, int y1, int x2,
287
 
                                   int y2);
288
 
void UnityWindowTracker_ChangeWindowRegion(UnityWindowTracker *tracker,
289
 
                                           UnityWindowId id, RegionPtr region);
290
 
void UnityWindowTracker_RemoveWindow(UnityWindowTracker *tracker,
291
 
                                     UnityWindowId id);
292
 
void UnityWindowTracker_SendUpdate(UnityWindowTracker *tracker,
293
 
                                   UnityUpdate *update);
294
 
void UnityWindowTracker_SetWindowTitle(UnityWindowTracker *tracker,
295
 
                                       UnityWindowId id,
296
 
                                       DynBuf *titleUtf8);
297
 
void UnityWindowTracker_RemoveAllWindows(UnityWindowTracker *tracker);
298
 
 
299
 
/*
300
 
 * Please note that calling ChangeWindowState directly is deprecated. Use
301
 
 * SetWindowAttribute and SetWindowType instead.
302
 
 */
303
 
void UnityWindowTracker_ChangeWindowState(UnityWindowTracker *tracker,
304
 
                                          UnityWindowId id,
305
 
                                          uint32 state);
306
 
/*
307
 
 * Deprecated. Use GetWindowAttribute and GetWindowType instead.
308
 
 */
309
 
Bool UnityWindowTracker_GetWindowState(UnityWindowTracker *tracker,
310
 
                                       UnityWindowId id,
311
 
                                       uint32 *state);
312
 
 
313
 
void UnityWindowTracker_ChangeWindowAttribute(UnityWindowTracker *tracker,
314
 
                                              UnityWindowId id,
315
 
                                              UnityWindowAttribute attr,
316
 
                                              Bool enabled);
317
 
Bool UnityWindowTracker_GetWindowAttribute(UnityWindowTracker *tracker,
318
 
                                           UnityWindowId id,
319
 
                                           UnityWindowAttribute attr,
320
 
                                           Bool *enabled);
321
 
void UnityWindowTracker_ChangeWindowType(UnityWindowTracker *tracker,
322
 
                                         UnityWindowId id,
323
 
                                         UnityWindowType winType);
324
 
Bool UnityWindowTracker_GetWindowType(UnityWindowTracker *tracker,
325
 
                                      UnityWindowId id,
326
 
                                      UnityWindowType *winType);
327
 
void UnityWindowTracker_NotifyIconChanged(UnityWindowTracker *tracker,
328
 
                                          UnityWindowId id,
329
 
                                          UnityIconType iconType);
330
 
void UnityWindowTracker_ChangeWindowDesktop(UnityWindowTracker *tracker,
331
 
                                            UnityWindowId id,
332
 
                                            UnityDesktopId desktopId);
333
 
Bool UnityWindowTracker_GetWindowDesktop(UnityWindowTracker *tracker,
334
 
                                         UnityWindowId id,
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[],
340
 
                                  int count);
341
 
void UnityWindowTracker_SetZPosition(UnityWindowTracker *tracker, UnityWindowId window,
342
 
                                  uint32 zorder);
343
 
void UnityWindowTracker_RequestUpdates(UnityWindowTracker *tracker,
344
 
                                       uint32 flags, void *param);
345
 
UnityWindowInfo *UnityWindowTracker_LookupWindow(UnityWindowTracker *tracker,
346
 
                                                 UnityWindowId id);
347
 
 
348
 
 
349
 
/*
350
 
 *-----------------------------------------------------------------------------
351
 
 *
352
 
 * UnityWindowTracker_GetWindowData --
353
 
 *
354
 
 *      Returns the app data pointer associated with a particular Unity window.
355
 
 *
356
 
 * Results:
357
 
 *      Pointer to the app data. May be NULL if no data is set or 'info' is invalid.
358
 
 *
359
 
 * Side effects:
360
 
 *      None.
361
 
 *
362
 
 *-----------------------------------------------------------------------------
363
 
 */
364
 
 
365
 
static INLINE void *
366
 
UnityWindowTracker_GetWindowData(UnityWindowTracker *tracker, // IN
367
 
                                 UnityWindowInfo *info)       // IN
368
 
{
369
 
   return info ? info->data : NULL;
370
 
}
371
 
 
372
 
 
373
 
/*
374
 
 *-----------------------------------------------------------------------------
375
 
 *
376
 
 * UnityWindowTracker_GetWindowDataById --
377
 
 *
378
 
 *      Returns the app data pointer associated with a particular Unity window ID.
379
 
 *
380
 
 * Results:
381
 
 *      Pointer to the app data. May be NULL if no data is set or 'info' is invalid.
382
 
 *
383
 
 * Side effects:
384
 
 *      None.
385
 
 *
386
 
 *-----------------------------------------------------------------------------
387
 
 */
388
 
 
389
 
static INLINE void *
390
 
UnityWindowTracker_GetWindowDataById(UnityWindowTracker *tracker, // IN
391
 
                                     UnityWindowId winId)         // IN
392
 
{
393
 
   return UnityWindowTracker_GetWindowData(tracker,
394
 
                                           UnityWindowTracker_LookupWindow(tracker,
395
 
                                                                           winId));
396
 
}
397
 
#endif