~n-muench/ubuntu/precise/open-vm-tools/open-vm-tools.raring-precise.backport

« back to all changes in this revision

Viewing changes to services/plugins/unity/unitylib/unityPlatformX11Settings.cc

  • 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-2008 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
 
 * unityPlatformX11Settings.c --
21
 
 *
22
 
 *    Handles saving and restoring various system settings that are needed for Unity to
23
 
 *    work well.
24
 
 */
25
 
 
26
 
#include "unityX11.h"
27
 
 
28
 
#if !defined(VM_HAVE_X11_SS_EXT) && !defined(USING_AUTOCONF)
29
 
#error "We're not building with the X11 ScreenSaver extension."
30
 
#endif
31
 
 
32
 
 
33
 
/*
34
 
 *-----------------------------------------------------------------------------
35
 
 *
36
 
 * GetScreensaverActive --
37
 
 *
38
 
 *      Finds out whether the screensaver is currently enabled.
39
 
 *
40
 
 * Results:
41
 
 *      TRUE if successful, FALSE otherwise
42
 
 *
43
 
 * Side effects:
44
 
 *      Stores the current setting in *currentSetting
45
 
 *
46
 
 *-----------------------------------------------------------------------------
47
 
 */
48
 
 
49
 
static Bool
50
 
GetScreensaverActive(UnityPlatform *up,    // IN
51
 
                     Bool *currentSetting) // OUT
52
 
{
53
 
   int timeout;
54
 
   int dummy;
55
 
 
56
 
   ASSERT(up);
57
 
   ASSERT(currentSetting);
58
 
 
59
 
   *currentSetting = FALSE;
60
 
 
61
 
#if defined(VM_HAVE_X11_SS_EXT)
62
 
   {
63
 
      int eventBase;
64
 
      int errorBase;
65
 
      if (XScreenSaverQueryExtension(up->display, &eventBase, &errorBase)) {
66
 
         XScreenSaverInfo saverInfo;
67
 
 
68
 
         if (!XScreenSaverQueryInfo(up->display,
69
 
                                    DefaultRootWindow(up->display),
70
 
                                    &saverInfo)) {
71
 
            return FALSE;
72
 
         }
73
 
 
74
 
         *currentSetting = (saverInfo.state != ScreenSaverDisabled);
75
 
      }
76
 
   }
77
 
#endif
78
 
 
79
 
   timeout = -1;
80
 
   XGetScreenSaver(up->display, &timeout, &dummy, &dummy, &dummy);
81
 
 
82
 
   if(timeout == -1) {
83
 
      return FALSE;
84
 
   }
85
 
 
86
 
   *currentSetting = *currentSetting || (timeout ? TRUE : FALSE);
87
 
   return TRUE;
88
 
}
89
 
 
90
 
 
91
 
/*
92
 
 *-----------------------------------------------------------------------------
93
 
 *
94
 
 * SetScreensaverActive --
95
 
 *
96
 
 *      Enables/disables the screensaver.
97
 
 *
98
 
 * Results:
99
 
 *      TRUE if successful, FALSE otherwise
100
 
 *
101
 
 * Side effects:
102
 
 *      None.
103
 
 *
104
 
 *-----------------------------------------------------------------------------
105
 
 */
106
 
 
107
 
static Bool
108
 
SetScreensaverActive(UnityPlatform *up,    // IN
109
 
                     Bool currentSetting)  // IN
110
 
{
111
 
   int timeout = -1; // If XGetScreenSaver fails, use the default
112
 
   int interval = 0;
113
 
   int preferBlanking = DefaultBlanking;
114
 
   int allowExposures = DefaultExposures;
115
 
   char *xdgScreensaverPath;
116
 
 
117
 
   ASSERT(up);
118
 
 
119
 
   /*
120
 
    * There are currently three ways to enable/disable the screensaver (in order of
121
 
    * current preference):
122
 
    *
123
 
    * 1. The xdg-screensaver script that knows how to talk to the screensavers of most
124
 
    * current desktops.
125
 
    * 2. XScreenSaverSuspend, via the X screensaver extension.
126
 
    * 3. XSetScreenSaver.
127
 
    *
128
 
    * Only the first one actually works on most systems, but the other two are there to
129
 
    * catch corner cases on odd systems.
130
 
    */
131
 
 
132
 
   xdgScreensaverPath = g_find_program_in_path("xdg-screensaver");
133
 
   if (up->rootWindows && xdgScreensaverPath) {
134
 
      char rootWindowID[64];
135
 
      char *argv[] = {xdgScreensaverPath,
136
 
                      (char*)(currentSetting ? "resume" : "suspend"),
137
 
                      rootWindowID,
138
 
                      NULL};
139
 
 
140
 
      g_snprintf(rootWindowID, sizeof rootWindowID, "%#lx", up->rootWindows->windows[0]);
141
 
 
142
 
      g_spawn_sync("/", argv, NULL, (GSpawnFlags)0, NULL, NULL, NULL, NULL, NULL, NULL);
143
 
   }
144
 
   g_free(xdgScreensaverPath);
145
 
 
146
 
#if defined(VM_HAVE_X11_SS_EXT)
147
 
   {
148
 
      int eventBase;
149
 
      int errorBase;
150
 
 
151
 
      if (!XScreenSaverQueryExtension(up->display, &eventBase, &errorBase)) {
152
 
         return FALSE;
153
 
      }
154
 
   /*
155
 
    * XScreenSaverSuspend is only available as of version 1.1 of the screensaver
156
 
    * extension
157
 
    */
158
 
#   if (ScreenSaverMajorVersion > 1 \
159
 
       || (ScreenSaverMajorVersion == 1 && ScreenSaverMinorVersion >= 1))
160
 
      {
161
 
         int majorVersion;
162
 
         int minorVersion;
163
 
 
164
 
         if (XScreenSaverQueryVersion(up->display, &majorVersion, &minorVersion)
165
 
             && (majorVersion > 1 || (majorVersion == 1 && minorVersion >= 1))) {
166
 
 
167
 
            XScreenSaverSuspend(up->display, !currentSetting);
168
 
            up->currentSettings[UNITY_UI_SCREENSAVER] = currentSetting;
169
 
         }
170
 
      }
171
 
#   endif
172
 
 
173
 
      /*
174
 
       * XXX TODO: On systems that don't have XScreenSaverSuspend, we could always monitor
175
 
       * ScreenSaverNotify events, and send a ForceScreenSaver request (with value of Reset)
176
 
       * whenever the screensaver comes on.
177
 
       */
178
 
   }
179
 
#endif
180
 
 
181
 
   XGetScreenSaver(up->display, &timeout, &interval, &preferBlanking, &allowExposures);
182
 
 
183
 
   if (!currentSetting) {
184
 
      up->savedScreenSaverTimeout = timeout; // Save the old timeout.
185
 
      timeout = 0; // Disables the screensaver.
186
 
   } else {
187
 
      timeout = up->savedScreenSaverTimeout;
188
 
      up->savedScreenSaverTimeout = -1;
189
 
   }
190
 
 
191
 
   XSetScreenSaver(up->display, timeout, interval, preferBlanking, allowExposures);
192
 
 
193
 
   if (!currentSetting) {
194
 
      /*
195
 
       * Disable the screen saver if it's already active.
196
 
       */
197
 
      XForceScreenSaver(up->display, ScreenSaverReset);
198
 
   }
199
 
 
200
 
   return TRUE;
201
 
}
202
 
 
203
 
 
204
 
#ifdef VM_UNIMPLEMENTED_UNITY_SETTINGS
205
 
 
206
 
 
207
 
/*
208
 
 *-----------------------------------------------------------------------------
209
 
 *
210
 
 * GetDropShadowActive --
211
 
 *
212
 
 *      Finds out whether drop shadows are currently enabled.
213
 
 *
214
 
 * Results:
215
 
 *      TRUE if successful, FALSE otherwise
216
 
 *
217
 
 * Side effects:
218
 
 *      Stores the current setting in *currentSetting
219
 
 *
220
 
 *-----------------------------------------------------------------------------
221
 
 */
222
 
 
223
 
static Bool
224
 
GetDropShadowActive(UnityPlatform *up,    // IN
225
 
                    Bool *currentSetting) // OUT
226
 
{
227
 
   ASSERT(up);
228
 
   ASSERT(currentSetting);
229
 
 
230
 
   NOT_IMPLEMENTED();
231
 
 
232
 
   return FALSE;
233
 
}
234
 
 
235
 
 
236
 
/*
237
 
 *-----------------------------------------------------------------------------
238
 
 *
239
 
 * SetDropShadowActive --
240
 
 *
241
 
 *      Enables/disables drop shadows.
242
 
 *
243
 
 * Results:
244
 
 *      TRUE if successful, FALSE otherwise
245
 
 *
246
 
 * Side effects:
247
 
 *      None.
248
 
 *
249
 
 *-----------------------------------------------------------------------------
250
 
 */
251
 
 
252
 
static Bool
253
 
SetDropShadowActive(UnityPlatform *up,    // IN
254
 
                    Bool currentSetting)  // IN
255
 
{
256
 
   ASSERT(up);
257
 
 
258
 
   up->currentSettings[UNITY_UI_DROP_SHADOW] = currentSetting;
259
 
 
260
 
   NOT_IMPLEMENTED();
261
 
 
262
 
   return FALSE;
263
 
}
264
 
 
265
 
 
266
 
/*
267
 
 *-----------------------------------------------------------------------------
268
 
 *
269
 
 * GetMenuAnimationActive --
270
 
 *
271
 
 *      Finds out whether menu animation is currently enabled.
272
 
 *
273
 
 * Results:
274
 
 *      TRUE if successful, FALSE otherwise
275
 
 *
276
 
 * Side effects:
277
 
 *      Stores the current setting in *currentSetting
278
 
 *
279
 
 *-----------------------------------------------------------------------------
280
 
 */
281
 
 
282
 
static Bool
283
 
GetMenuAnimationActive(UnityPlatform *up,    // IN
284
 
                       Bool *currentSetting) // OUT
285
 
{
286
 
   ASSERT(up);
287
 
   ASSERT(currentSetting);
288
 
 
289
 
   NOT_IMPLEMENTED();
290
 
 
291
 
   return FALSE;
292
 
}
293
 
 
294
 
 
295
 
/*
296
 
 *-----------------------------------------------------------------------------
297
 
 *
298
 
 * SetMenuAnimationActive --
299
 
 *
300
 
 *      Enables/disables the screensaver.
301
 
 *
302
 
 * Results:
303
 
 *      TRUE if successful, FALSE otherwise
304
 
 *
305
 
 * Side effects:
306
 
 *      None.
307
 
 *
308
 
 *-----------------------------------------------------------------------------
309
 
 */
310
 
 
311
 
static Bool
312
 
SetMenuAnimationActive(UnityPlatform *up,    // IN
313
 
                       Bool currentSetting)  // IN
314
 
{
315
 
   ASSERT(up);
316
 
 
317
 
   up->currentSettings[UNITY_UI_MENU_ANIMATION] = currentSetting;
318
 
 
319
 
   NOT_IMPLEMENTED();
320
 
 
321
 
   return FALSE;
322
 
}
323
 
 
324
 
 
325
 
/*
326
 
 *-----------------------------------------------------------------------------
327
 
 *
328
 
 * GetTooltipAnimationActive --
329
 
 *
330
 
 *      Finds out whether the screensaver is currently enabled.
331
 
 *
332
 
 * Results:
333
 
 *      TRUE if successful, FALSE otherwise
334
 
 *
335
 
 * Side effects:
336
 
 *      Stores the current setting in *currentSetting
337
 
 *
338
 
 *-----------------------------------------------------------------------------
339
 
 */
340
 
 
341
 
static Bool
342
 
GetTooltipAnimationActive(UnityPlatform *up,    // IN
343
 
                          Bool *currentSetting) // OUT
344
 
{
345
 
   ASSERT(up);
346
 
   ASSERT(currentSetting);
347
 
 
348
 
   NOT_IMPLEMENTED();
349
 
 
350
 
   return FALSE;
351
 
}
352
 
 
353
 
 
354
 
/*
355
 
 *-----------------------------------------------------------------------------
356
 
 *
357
 
 * SetTooltipAnimationActive --
358
 
 *
359
 
 *      Enables/disables the screensaver.
360
 
 *
361
 
 * Results:
362
 
 *      TRUE if successful, FALSE otherwise
363
 
 *
364
 
 * Side effects:
365
 
 *      None.
366
 
 *
367
 
 *-----------------------------------------------------------------------------
368
 
 */
369
 
 
370
 
static Bool
371
 
SetTooltipAnimationActive(UnityPlatform *up,    // IN
372
 
                          Bool currentSetting)  // IN
373
 
{
374
 
   ASSERT(up);
375
 
 
376
 
   up->currentSettings[UNITY_UI_TOOLTIP_ANIMATION] = currentSetting;
377
 
 
378
 
   NOT_IMPLEMENTED();
379
 
 
380
 
   return FALSE;
381
 
}
382
 
 
383
 
 
384
 
/*
385
 
 *-----------------------------------------------------------------------------
386
 
 *
387
 
 * GetWindowAnimationActive --
388
 
 *
389
 
 *      Finds out whether the screensaver is currently enabled.
390
 
 *
391
 
 * Results:
392
 
 *      TRUE if successful, FALSE otherwise
393
 
 *
394
 
 * Side effects:
395
 
 *      Stores the current setting in *currentSetting
396
 
 *
397
 
 *-----------------------------------------------------------------------------
398
 
 */
399
 
 
400
 
static Bool
401
 
GetWindowAnimationActive(UnityPlatform *up,    // IN
402
 
                         Bool *currentSetting) // OUT
403
 
{
404
 
   ASSERT(up);
405
 
   ASSERT(currentSetting);
406
 
 
407
 
   NOT_IMPLEMENTED();
408
 
 
409
 
   return FALSE;
410
 
}
411
 
 
412
 
 
413
 
/*
414
 
 *-----------------------------------------------------------------------------
415
 
 *
416
 
 * SetWindowAnimationActive --
417
 
 *
418
 
 *      Enables/disables the screensaver.
419
 
 *
420
 
 * Results:
421
 
 *      TRUE if successful, FALSE otherwise
422
 
 *
423
 
 * Side effects:
424
 
 *      None.
425
 
 *
426
 
 *-----------------------------------------------------------------------------
427
 
 */
428
 
 
429
 
static Bool
430
 
SetWindowAnimationActive(UnityPlatform *up,    // IN
431
 
                         Bool currentSetting)  // IN
432
 
{
433
 
   ASSERT(up);
434
 
 
435
 
   up->currentSettings[UNITY_UI_WINDOW_ANIMATION] = currentSetting;
436
 
 
437
 
   NOT_IMPLEMENTED();
438
 
 
439
 
   return FALSE;
440
 
}
441
 
 
442
 
 
443
 
/*
444
 
 *-----------------------------------------------------------------------------
445
 
 *
446
 
 * GetFullWindowDragActive --
447
 
 *
448
 
 *      Finds out whether the screensaver is currently enabled.
449
 
 *
450
 
 * Results:
451
 
 *      TRUE if successful, FALSE otherwise
452
 
 *
453
 
 * Side effects:
454
 
 *      Stores the current setting in *currentSetting
455
 
 *
456
 
 *-----------------------------------------------------------------------------
457
 
 */
458
 
 
459
 
static Bool
460
 
GetFullWindowDragActive(UnityPlatform *up,    // IN
461
 
                        Bool *currentSetting) // OUT
462
 
{
463
 
   ASSERT(up);
464
 
   ASSERT(currentSetting);
465
 
 
466
 
   NOT_IMPLEMENTED();
467
 
 
468
 
   return FALSE;
469
 
}
470
 
 
471
 
 
472
 
/*
473
 
 *-----------------------------------------------------------------------------
474
 
 *
475
 
 * SetFullWindowDragActive --
476
 
 *
477
 
 *      Enables/disables the screensaver.
478
 
 *
479
 
 * Results:
480
 
 *      TRUE if successful, FALSE otherwise
481
 
 *
482
 
 * Side effects:
483
 
 *      None.
484
 
 *
485
 
 *-----------------------------------------------------------------------------
486
 
 */
487
 
 
488
 
static Bool
489
 
SetFullWindowDragActive(UnityPlatform *up,    // IN
490
 
                        Bool currentSetting)  // IN
491
 
{
492
 
   ASSERT(up);
493
 
 
494
 
   up->currentSettings[UNITY_UI_FULL_WINDOW_DRAG] = currentSetting;
495
 
 
496
 
   NOT_IMPLEMENTED();
497
 
 
498
 
   return FALSE;
499
 
}
500
 
 
501
 
 
502
 
#endif
503
 
 
504
 
 
505
 
/*
506
 
 *-----------------------------------------------------------------------------
507
 
 *
508
 
 * GetTaskbarVisible --
509
 
 *
510
 
 *      Shows or hides the taskbar as appropriate.
511
 
 *
512
 
 * Results:
513
 
 *      TRUE if successful, FALSE otherwise.
514
 
 *
515
 
 * Side effects:
516
 
 *      None.
517
 
 *
518
 
 *-----------------------------------------------------------------------------
519
 
 */
520
 
 
521
 
static Bool
522
 
GetTaskbarVisible(UnityPlatform *up,    // IN
523
 
                  Bool *currentSetting) // OUT
524
 
{
525
 
   UnityPlatformWindow **allWindows;
526
 
   size_t i;
527
 
   size_t numWindows;
528
 
 
529
 
   ASSERT(up);
530
 
   ASSERT(currentSetting);
531
 
 
532
 
   numWindows = 0;
533
 
   HashTable_ToArray(up->allWindows,
534
 
                     (void ***)&allWindows,
535
 
                     &numWindows);
536
 
 
537
 
   if (!numWindows) {
538
 
      Debug("Couldn't find any listed windows for taskbar visibility detection.\n");
539
 
      return FALSE; // We haven't yet populated the window list for some reason
540
 
   }
541
 
 
542
 
   /*
543
 
    * Hunt through all the windows for ones that are of type DOCK.
544
 
    */
545
 
   *currentSetting = FALSE;
546
 
   for (i = 0; i < numWindows; i++) {
547
 
      if (UNITY_WINDOW_TYPE_DOCK == allWindows[i]->windowType
548
 
         && allWindows[i]->isViewable) {
549
 
         *currentSetting = TRUE;
550
 
         break;
551
 
      }
552
 
   }
553
 
 
554
 
   free(allWindows);
555
 
 
556
 
   return TRUE;
557
 
}
558
 
 
559
 
 
560
 
/*
561
 
 *-----------------------------------------------------------------------------
562
 
 *
563
 
 * UnityPlatformSetTaskbarVisible --
564
 
 *
565
 
 *      Shows or hides the taskbar as appropriate.
566
 
 *
567
 
 * Results:
568
 
 *      TRUE if successful, FALSE otherwise.
569
 
 *
570
 
 * Side effects:
571
 
 *      Shows or hides task bar.
572
 
 *
573
 
 *-----------------------------------------------------------------------------
574
 
 */
575
 
 
576
 
Bool
577
 
UnityPlatformSetTaskbarVisible(UnityPlatform *up,   // IN
578
 
                               Bool currentSetting) // IN
579
 
{
580
 
   UnityPlatformWindow **allWindows;
581
 
   size_t i;
582
 
   size_t numWindows;
583
 
 
584
 
   ASSERT(up);
585
 
 
586
 
   up->needTaskbarSetting = FALSE;
587
 
 
588
 
   up->currentSettings[UNITY_UI_TASKBAR_VISIBLE] = currentSetting;
589
 
 
590
 
   numWindows = 0;
591
 
   HashTable_ToArray(up->allWindows,
592
 
                     (void ***) &allWindows,
593
 
                     &numWindows);
594
 
 
595
 
   /*
596
 
    * Hunt through all the windows for ones that are of type DOCK.
597
 
    */
598
 
   for (i = 0; i < numWindows; i++) {
599
 
      if (UNITY_WINDOW_TYPE_DOCK == allWindows[i]->windowType) {
600
 
         Window dockWindow;
601
 
         UnityPlatformWindow *upw = allWindows[i];
602
 
 
603
 
         dockWindow = upw->clientWindow;
604
 
         if (!dockWindow) {
605
 
            dockWindow = upw->toplevelWindow;
606
 
         }
607
 
 
608
 
         if (currentSetting) {
609
 
            /*
610
 
             * If this flag is still set, that means that this window is being
611
 
             * remapped -before- we received a _NET_WM_DESKTOP PropertyDelete
612
 
             * notification.  (One such case may be if exiting Unity before the
613
 
             * PropertyDelete is delivered.)  In that case, we'll go ahead and
614
 
             * reset the property ourselves before remapping.
615
 
             */
616
 
            if (upw->wantSetDesktopNumberOnUnmap) {
617
 
               UPWindow_SetEWMHDesktop(up, upw, upw->onUnmapDesktopNumber);
618
 
               upw->wantSetDesktopNumberOnUnmap = FALSE;
619
 
            }
620
 
            XMapWindow(up->display, dockWindow);
621
 
         } else {
622
 
            /* Preserve _NET_WM_DESKTOP across unmap. */
623
 
            if (!upw->wantSetDesktopNumberOnUnmap) {
624
 
               upw->wantSetDesktopNumberOnUnmap = TRUE;
625
 
               upw->onUnmapDesktopNumber = upw->desktopNumber;
626
 
            }
627
 
            XWithdrawWindow(up->display, dockWindow, 0);
628
 
         }
629
 
 
630
 
         UPWindow_CheckRelevance(up, upw, NULL);
631
 
      }
632
 
   }
633
 
 
634
 
   free(allWindows);
635
 
 
636
 
   if (!numWindows) {
637
 
      /*
638
 
       * We need to repeat this call later.
639
 
       */
640
 
      up->needTaskbarSetting = TRUE;
641
 
   }
642
 
 
643
 
   return TRUE;
644
 
}
645
 
 
646
 
 
647
 
/*
648
 
 *-----------------------------------------------------------------------------
649
 
 *
650
 
 * SaveVirtualDesktopSettings --
651
 
 *
652
 
 *      Saves the current virtual desktop configuration so it can be restored later on.
653
 
 *
654
 
 * Results:
655
 
 *      None.
656
 
 *
657
 
 * Side effects:
658
 
 *      None.
659
 
 *
660
 
 *-----------------------------------------------------------------------------
661
 
 */
662
 
 
663
 
void
664
 
SaveVirtualDesktopSettings(UnityPlatform *up) // IN
665
 
{
666
 
   ASSERT(up);
667
 
 
668
 
   up->desktopInfo.savedNumDesktops = UnityPlatformGetNumVirtualDesktops(up);
669
 
   UnityPlatformGetVirtualDesktopLayout(up, up->desktopInfo.savedLayoutData);
670
 
   up->desktopInfo.savedCurrentDesktop = UnityX11GetCurrentDesktop(up);
671
 
}
672
 
 
673
 
 
674
 
/*
675
 
 *-----------------------------------------------------------------------------
676
 
 *
677
 
 * RestoreVirtualDesktopSettings --
678
 
 *
679
 
 *      Restores the saved virtual desktop configuration.
680
 
 *
681
 
 * Results:
682
 
 *      None.
683
 
 *
684
 
 * Side effects:
685
 
 *      Guest's virtual desktop config may be changed.
686
 
 *
687
 
 *-----------------------------------------------------------------------------
688
 
 */
689
 
 
690
 
void
691
 
RestoreVirtualDesktopSettings(UnityPlatform *up) // IN
692
 
{
693
 
   size_t tempDesktops;
694
 
   ASSERT(up);
695
 
 
696
 
   memcpy(up->desktopInfo.layoutData,
697
 
          up->desktopInfo.savedLayoutData,
698
 
          sizeof up->desktopInfo.layoutData);
699
 
   tempDesktops = up->desktopInfo.numDesktops;
700
 
   up->desktopInfo.numDesktops = up->desktopInfo.savedNumDesktops;
701
 
   UnityPlatformSyncDesktopConfig(up);
702
 
 
703
 
   /*
704
 
    * ...because numDesktops also refers to the size of the guestDesktopToUnity and
705
 
    * unityDesktopToGuest arrays.
706
 
    */
707
 
   up->desktopInfo.numDesktops = tempDesktops;
708
 
 
709
 
   UnityX11SetCurrentDesktop(up, up->desktopInfo.savedCurrentDesktop);
710
 
}
711
 
 
712
 
 
713
 
/*
714
 
 *-----------------------------------------------------------------------------
715
 
 *
716
 
 * UnityPlatformSaveSystemSettings --
717
 
 *
718
 
 *      Stub to make unity.c happy. This function is called at a very inconvenient time
719
 
 *      for the X11 port, so I just call its UnityX11 equivalent at the appropriate point
720
 
 *      in StartHelperThreads instead.
721
 
 *
722
 
 * Results:
723
 
 *      None.
724
 
 *
725
 
 * Side effects:
726
 
 *      None.
727
 
 *
728
 
 *-----------------------------------------------------------------------------
729
 
 */
730
 
 
731
 
void
732
 
UnityPlatformSaveSystemSettings(UnityPlatform *up) // IN
733
 
{
734
 
}
735
 
 
736
 
 
737
 
/*
738
 
 *----------------------------------------------------------------------------
739
 
 *
740
 
 * UnityX11SaveSystemSettings --
741
 
 *
742
 
 *      Save and disable certain system settings here:
743
 
 *      a. If a screen saver is enabled, disable it
744
 
 *      b. If animation for menus or tooltips is enabled, disable it
745
 
 *      c. If menu shading is enabled, disable it
746
 
 *      d. If full window drag is disabled, enable it
747
 
 *      e. If window animation is enabled, disable it
748
 
 *      f. Hide the task bar.
749
 
 *
750
 
 *      Right now on X11, only the screensaver and task bar make any sense.
751
 
 *
752
 
 *      Remember all the settings changed above in a bit mask,
753
 
 *      so we can restore them later when the user exits
754
 
 *      the Unity mode.
755
 
 *
756
 
 *      Note, that the system ui changes made here will not
757
 
 *      persist after the system reboot.
758
 
 *
759
 
 * Results:
760
 
 *      None.
761
 
 *
762
 
 * Side effects:
763
 
 *      A bunch of system ui settings might be changed.
764
 
 *
765
 
 *----------------------------------------------------------------------------
766
 
 */
767
 
 
768
 
void
769
 
UnityX11SaveSystemSettings(UnityPlatform *up) // IN
770
 
{
771
 
   ASSERT(up);
772
 
 
773
 
   /*
774
 
    * We only want to remember current settings if we do not have saved settings already.
775
 
    * One of the reasons why we might have saved settings already is because we are
776
 
    * re-entering unity without cleanly exiting it first (if the VM was suspended).  In
777
 
    * this case, theoretically, all the right settings are set already and
778
 
    * up->originalSettings contains the original user settings that we do not want to
779
 
    * overwrite.
780
 
    */
781
 
   if (!up->haveOriginalSettings) {
782
 
      Bool *originalSettings = up->originalSettings;
783
 
 
784
 
      memset(up->originalSettings, 0, sizeof up->originalSettings);
785
 
 
786
 
      if (!GetScreensaverActive(up, &originalSettings[UNITY_UI_SCREENSAVER])) {
787
 
         originalSettings[UNITY_UI_SCREENSAVER] = TRUE;
788
 
      }
789
 
 
790
 
#ifdef VM_UNIMPLEMENTED_UNITY_SETTINGS
791
 
      if (!GetDropShadowActive(up, &originalSettings[UNITY_UI_DROP_SHADOW])) {
792
 
         originalSettings[UNITY_UI_DROP_SHADOW] = TRUE;
793
 
      }
794
 
 
795
 
      if (!GetMenuAnimationActive(up, &originalSettings[UNITY_UI_MENU_ANIMATION])) {
796
 
         originalSettings[UNITY_UI_MENU_ANIMATION] = TRUE;
797
 
      }
798
 
 
799
 
      if (!GetTooltipAnimationActive(up,
800
 
                                     &originalSettings[UNITY_UI_TOOLTIP_ANIMATION])) {
801
 
         originalSettings[UNITY_UI_TOOLTIP_ANIMATION] = TRUE;
802
 
      }
803
 
 
804
 
      if (!GetWindowAnimationActive(up, &originalSettings[UNITY_UI_WINDOW_ANIMATION])) {
805
 
         originalSettings[UNITY_UI_WINDOW_ANIMATION] = TRUE;
806
 
      }
807
 
 
808
 
      if (!GetFullWindowDragActive(up, &originalSettings[UNITY_UI_FULL_WINDOW_DRAG])) {
809
 
         originalSettings[UNITY_UI_FULL_WINDOW_DRAG] = TRUE;
810
 
      }
811
 
#endif
812
 
 
813
 
      if (!GetTaskbarVisible(up, &originalSettings[UNITY_UI_TASKBAR_VISIBLE])) {
814
 
         originalSettings[UNITY_UI_TASKBAR_VISIBLE] = TRUE;
815
 
      }
816
 
 
817
 
      SaveVirtualDesktopSettings(up);
818
 
 
819
 
      up->haveOriginalSettings = TRUE;
820
 
 
821
 
      memcpy(up->currentSettings, originalSettings, sizeof up->currentSettings);
822
 
   }
823
 
 
824
 
   SetScreensaverActive(up, FALSE);
825
 
#ifdef VM_UNIMPLEMENTED_UNITY_SETTINGS
826
 
   SetDropShadowActive(up, FALSE);
827
 
   SetMenuAnimationActive(up, FALSE);
828
 
   SetTooltipAnimationActive(up, FALSE);
829
 
   SetWindowAnimationActive(up, FALSE);
830
 
   SetFullWindowDragActive(up, FALSE);
831
 
#endif
832
 
 
833
 
   {
834
 
      char *reply = NULL;
835
 
      size_t replyLen;
836
 
      Bool shouldBeVisible = FALSE;
837
 
 
838
 
      if (!RpcOut_sendOne(&reply, &replyLen, UNITY_RPC_VMX_SHOW_TASKBAR)) {
839
 
         Debug("%s: could not get the VMX show taskbar setting, assuming FALSE\n",
840
 
               __FUNCTION__);
841
 
      } else {
842
 
         uint32 value = 0;
843
 
 
844
 
         if (StrUtil_StrToUint(&value, reply)) {
845
 
            shouldBeVisible = (value == 0) ? FALSE : TRUE;
846
 
         }
847
 
      }
848
 
 
849
 
      Debug("TASKBAR SHOULD BE VISIBLE: %d\n", shouldBeVisible);
850
 
 
851
 
      UnityPlatformSetTaskbarVisible(up, shouldBeVisible);
852
 
 
853
 
      free(reply);
854
 
   }
855
 
}
856
 
 
857
 
 
858
 
/*
859
 
 *-----------------------------------------------------------------------------
860
 
 *
861
 
 * UnityPlatformRestoreSystemSettings --
862
 
 *
863
 
 *      Stub to make unity.c happy. This function is called at a very inconvenient time
864
 
 *      for the X11 port, so I just call its UnityX11 equivalent at the appropriate point
865
 
 *      in KillHelperThreads instead.
866
 
 *
867
 
 * Results:
868
 
 *      None.
869
 
 *
870
 
 * Side effects:
871
 
 *      None.
872
 
 *
873
 
 *-----------------------------------------------------------------------------
874
 
 */
875
 
 
876
 
void
877
 
UnityPlatformRestoreSystemSettings(UnityPlatform *up) // IN
878
 
{
879
 
}
880
 
 
881
 
 
882
 
/*
883
 
 *----------------------------------------------------------------------------
884
 
 *
885
 
 * UnityX11RestoreSystemSettings --
886
 
 *
887
 
 *      Restore system ui settings to what they used to be
888
 
 *      before we entered unity mode.
889
 
 *
890
 
 *      This includes:
891
 
 *      a. Enable screen saver if it was disabled
892
 
 *      b. Enable menu and tool tip animation if it was disabled
893
 
 *      c. Enable menu shading is enabled if it was disabled
894
 
 *      d. Disable full window drag is disabled if it was enabled
895
 
 *      e. Enable window animation if it was disabled
896
 
 *      f. Show the task bar if it was hidden
897
 
 *
898
 
 * Results:
899
 
 *      None.
900
 
 *
901
 
 * Side effects:
902
 
 *      A bunch of system ui settings might be changed.
903
 
 *
904
 
 *----------------------------------------------------------------------------
905
 
 */
906
 
 
907
 
void
908
 
UnityX11RestoreSystemSettings(UnityPlatform *up) // IN
909
 
{
910
 
   ASSERT(up);
911
 
 
912
 
   Debug("UnityPlatformRestoreSystemSettings\n");
913
 
   if (up->currentSettings[UNITY_UI_SCREENSAVER]
914
 
       != up->originalSettings[UNITY_UI_SCREENSAVER]) {
915
 
      SetScreensaverActive(up, up->originalSettings[UNITY_UI_SCREENSAVER]);
916
 
      Debug("%s: Restored screen saver\n", __FUNCTION__);
917
 
   }
918
 
 
919
 
#ifdef VM_UNIMPLEMENTED_UNITY_SETTINGS
920
 
   if (up->currentSettings[UNITY_UI_DROP_SHADOW]
921
 
       != up->originalSettings[UNITY_UI_DROP_SHADOW]) {
922
 
      SetDropShadowActive(up, up->originalSettings[UNITY_UI_DROP_SHADOW]);
923
 
      Debug("%s: Restored drop shadows\n", __FUNCTION__);
924
 
   }
925
 
 
926
 
   if (up->currentSettings[UNITY_UI_MENU_ANIMATION]
927
 
       != up->originalSettings[UNITY_UI_MENU_ANIMATION]) {
928
 
      SetMenuAnimationActive(up, up->originalSettings[UNITY_UI_MENU_ANIMATION]);
929
 
      Debug("%s: Restored menu animation\n", __FUNCTION__);
930
 
   }
931
 
 
932
 
   if (up->currentSettings[UNITY_UI_TOOLTIP_ANIMATION]
933
 
       != up->originalSettings[UNITY_UI_TOOLTIP_ANIMATION]) {
934
 
      SetTooltipAnimationActive(up, up->originalSettings[UNITY_UI_TOOLTIP_ANIMATION]);
935
 
      Debug("%s: Restored tool tip animation\n", __FUNCTION__);
936
 
   }
937
 
 
938
 
   if (up->currentSettings[UNITY_UI_WINDOW_ANIMATION]
939
 
       != up->originalSettings[UNITY_UI_WINDOW_ANIMATION]) {
940
 
      SetWindowAnimationActive(up, up->originalSettings[UNITY_UI_WINDOW_ANIMATION]);
941
 
      Debug("%s: Restored window animation\n", __FUNCTION__);
942
 
   }
943
 
 
944
 
   if (up->currentSettings[UNITY_UI_FULL_WINDOW_DRAG]
945
 
       != up->originalSettings[UNITY_UI_FULL_WINDOW_DRAG]) {
946
 
      SetFullWindowDragActive(up, up->originalSettings[UNITY_UI_FULL_WINDOW_DRAG]);
947
 
      Debug("%s: Restored outline drag.\n", __FUNCTION__);
948
 
   }
949
 
#endif
950
 
 
951
 
   if (up->currentSettings[UNITY_UI_TASKBAR_VISIBLE]
952
 
       != up->originalSettings[UNITY_UI_TASKBAR_VISIBLE]) {
953
 
      UnityPlatformSetTaskbarVisible(up, up->originalSettings[UNITY_UI_TASKBAR_VISIBLE]);
954
 
      Debug("%s: Restored taskbar visibility.\n", __FUNCTION__);
955
 
   }
956
 
 
957
 
   RestoreVirtualDesktopSettings(up);
958
 
 
959
 
   /*
960
 
    * The user's settings have been restored, which means the originalSettings info will
961
 
    * not be relevant next time we go into SaveSystemSettings().
962
 
    */
963
 
   up->haveOriginalSettings = FALSE;
964
 
}
965
 
 
966
 
 
967
 
/*
968
 
 *----------------------------------------------------------------------------
969
 
 *
970
 
 * UnityPlatformShowTaskbar  --
971
 
 *
972
 
 *      Show/hide the taskbar while in Unity mode.
973
 
 *
974
 
 * Results:
975
 
 *      None.
976
 
 *
977
 
 * Side effects:
978
 
 *      None.
979
 
 *
980
 
 *----------------------------------------------------------------------------
981
 
 */
982
 
 
983
 
void
984
 
UnityPlatformShowTaskbar(UnityPlatform *up,   // IN
985
 
                         Bool showTaskbar)    // IN
986
 
{
987
 
   ASSERT(up);
988
 
 
989
 
   /*
990
 
    * If we are in Unity mode, we need to hide/show the taskbar.
991
 
    * If the user asked to show the taskbar and the taskbar was previously hidden,
992
 
    * we need to show the taskbar and readjust the work area.
993
 
    * Other cases (when the taskbar is already shown and user wants to show it,
994
 
    * for example), should theoretically never happen, but if they do, we just
995
 
    * ignore them because there's not much we can do.
996
 
    */
997
 
 
998
 
   if (UnityPlatformIsUnityRunning(up)) {
999
 
      Debug("Host asked us to show the taskbar %d\n", showTaskbar);
1000
 
      UnityPlatformSetTaskbarVisible(up, showTaskbar);
1001
 
   } else {
1002
 
      Debug("%s: We are not in Unity mode, ignore the show taskbar command\n",
1003
 
            __FUNCTION__);
1004
 
   }
1005
 
 
1006
 
   UnityPlatformDoUpdate(up, TRUE);
1007
 
}
1008
 
 
1009
 
 
1010
 
/*
1011
 
 *-----------------------------------------------------------------------------
1012
 
 *
1013
 
 * UnityPlatformShowDesktop --
1014
 
 *
1015
 
 *      Show/hide the entire VM desktop while in Unity mode.
1016
 
 *
1017
 
 * Results:
1018
 
 *      None
1019
 
 *
1020
 
 * Side effects:
1021
 
 *      None
1022
 
 *
1023
 
 *-----------------------------------------------------------------------------
1024
 
 */
1025
 
 
1026
 
void
1027
 
UnityPlatformShowDesktop(UnityPlatform *up, // IN
1028
 
                         Bool showDesktop)  // IN
1029
 
{
1030
 
   ASSERT(up);
1031
 
   NOT_IMPLEMENTED();
1032
 
}