~n-muench/ubuntu/oneiric/open-vm-tools/open-vm-tools.fix-836277

« back to all changes in this revision

Viewing changes to lib/unity/unityPlatformX11Window.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-07-30 12:56:49 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090730125649-97sfj5li8axiseoo
Tags: 2009.07.22-179896-2
* Temporarily building without dumbnet, the recently uploaded
  new dumbnet upstream version broke down (Closes: #539006).
* Using more common name to store local debian additions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
131
131
      Window *children = NULL;
132
132
      unsigned int nchildren;
133
133
 
134
 
      XQueryTree(up->display, rootWindow, &dummyroot, &dummyparent, &children,
135
 
                 &nchildren);
 
134
      if (!XQueryTree(up->display, rootWindow, &dummyroot, &dummyparent,
 
135
                      &children, &nchildren)) {
 
136
         Debug("%s: XQueryTree failed\n", __func__);
 
137
         goto out;
 
138
      }
136
139
 
137
140
      /*
138
141
       * Now, filter out all of the relevant top-level windows into a local buffer
221
224
   {
222
225
      size_t childrenSize = nWindows * sizeof *relevantUChildren;
223
226
 
224
 
      if (memcmp(relevantXChildren, relevantUChildren, childrenSize) || 
 
227
      if (memcmp(relevantXChildren, relevantUChildren, childrenSize) ||
225
228
          memcmp(relevantXChildren, trackerChildren, childrenSize)) {
226
229
         Debug("%s: mismatch!\n", callerName);
227
230
         Debug("%s: %8s %10s %10s %10s\n", callerName, "index", "X Server",
978
981
 
979
982
   upw->isRelevant = isRelevant;
980
983
   if (isRelevant) {
 
984
      DynBuf windowPath;
 
985
      DynBuf execPath;
 
986
      Bool retval;
 
987
 
 
988
      DynBuf_Init(&windowPath);
 
989
      DynBuf_Init(&execPath);
 
990
 
 
991
      retval = UnityPlatformGetWindowPath(up,
 
992
                                          upw->toplevelWindow,
 
993
                                          &windowPath,
 
994
                                          &execPath);
 
995
 
 
996
      if (!retval) {
 
997
         Debug("GetWindowPath didn't know how to identify the window...\n");
 
998
      }
 
999
 
981
1000
      Debug("Adding window %#lx to tracker\n", upw->toplevelWindow);
982
 
      UnityWindowTracker_AddWindowWithData(up->tracker, upw->toplevelWindow, upw);
 
1001
      UnityWindowTracker_AddWindowWithData(up->tracker,
 
1002
                                           upw->toplevelWindow,
 
1003
                                           &windowPath,
 
1004
                                           &execPath,
 
1005
                                           upw);
 
1006
      DynBuf_Destroy(&windowPath);
 
1007
      DynBuf_Destroy(&execPath);
 
1008
 
983
1009
      UPWindowPushFullUpdate(up, upw);
984
1010
   } else {
985
1011
      Debug("Removing window %#lx from tracker\n", upw->toplevelWindow);
1567
1593
   } else
1568
1594
#endif
1569
1595
   {
1570
 
      if (up->desktopInfo.currentDesktop == upw->desktopNumber) {
 
1596
      if (upw->desktopNumber == up->desktopInfo.currentDesktop ||
 
1597
          upw->desktopNumber == -1) {
1571
1598
         UnityRect actualRect;
1572
1599
         Window actualWindow;
1573
1600
 
1746
1773
 
1747
1774
   argv = inArgv;
1748
1775
 
1749
 
#ifdef GTK2
1750
1776
   while (argc && AppUtil_AppIsSkippable(argv[0])) {
1751
1777
      argv++;
1752
1778
      argc--;
1773
1799
         return FALSE;
1774
1800
      }
1775
1801
   }
1776
 
#endif
1777
1802
 
1778
1803
   /*
1779
1804
    * If the program in question takes any arguments, they will be appended as URI
1885
1910
   Str_Snprintf(cbuf, sizeof cbuf, "/proc/%d/cwd", pid);
1886
1911
   i = readlink(cbuf, cwdbuf, sizeof cwdbuf);
1887
1912
   if (i <= 0) {
1888
 
      return FALSE;
 
1913
      /* Lookup of cwd failed.  We'll try our best without it. */
 
1914
      i = 0;
1889
1915
   }
1890
1916
   cwdbuf[i] = '\0';
1891
1917
 
1911
1937
      }
1912
1938
      argv[argc] = NULL;
1913
1939
 
1914
 
      return UnityPlatformArgvToWindowPaths(up, upw, argv, argc, cwdbuf,
 
1940
      return UnityPlatformArgvToWindowPaths(up, upw, argv, argc,
 
1941
                                            cwdbuf[0] ? cwdbuf : NULL,
1915
1942
                                            windowUri, execUri);
1916
1943
   }
1917
1944
#endif
2047
2074
 *      Get the information needed to re-launch a window and retrieve further
2048
2075
 *      information on it.
2049
2076
 *
2050
 
 *      'buf' will hold two URI strings, one which uniquely identifies an X11
2051
 
 *      window (windowUri) and one which uniquely identifies the window's owning
 
2077
 *      windowPathUtf8 uniquely identifies an X11 window (windowUri),
 
2078
 *      execPathUtf8 uniquely identifies the window's owning
2052
2079
 *      executable (execUri).
2053
2080
 *
2054
2081
 *      windowUri is handy for getting icons and other data associated with a
2059
2086
 *      from the same application are really associated with separate
2060
2087
 *      applications.)
2061
2088
 *
2062
 
 *      I.e., <windowUri><nul><execUri><nul>
2063
 
 *
2064
 
 *      This RPC is overloaded with two URIs in order to maintain backwards
2065
 
 *      compatibility with older VMXs / host UIs expecting to pass the first
2066
 
 *      (and, to them, only known) URI to GHIGetBinaryInfo.
2067
 
 *
2068
2089
 * Results:
2069
2090
 *      TRUE if everything went ok, FALSE otherwise.
2070
2091
 *
2071
2092
 * Side effects:
2072
 
 *      None
 
2093
 *      Original buffer contents are overwritten.
2073
2094
 *
2074
2095
 *----------------------------------------------------------------------------
2075
2096
 */
2077
2098
Bool
2078
2099
UnityPlatformGetWindowPath(UnityPlatform *up,        // IN: Platform data
2079
2100
                           UnityWindowId window,     // IN: window handle
2080
 
                           DynBuf *buf)              // IN/OUT: full path to the binary
 
2101
                           DynBuf *windowPathUtf8,   // IN/OUT: full path to the window
 
2102
                           DynBuf *execPathUtf8)     // IN/OUT: full path to the binary
2081
2103
{
2082
2104
   UnityPlatformWindow *upw;
2083
2105
   Bool retval = FALSE;
2103
2125
            "   execUri = %s\n",
2104
2126
            window, windowUri, execUri);
2105
2127
 
2106
 
      DynBuf_AppendString(buf, windowUri);
2107
 
      DynBuf_AppendString(buf, execUri);
 
2128
      DynBuf_SetSize(windowPathUtf8, 0);
 
2129
      DynBuf_SetSize(execPathUtf8, 0);
 
2130
      DynBuf_AppendString(windowPathUtf8, windowUri);
 
2131
      DynBuf_AppendString(execPathUtf8, execUri);
2108
2132
 
2109
2133
      g_free(windowUri);
2110
2134
      g_free(execUri);