Changeset 74311 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Sep 17, 2018 2:39:14 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItem.cpp
r73424 r74311 40 40 41 41 42 // Helpers43 ////////////////////////////////////////////////////////////////////////////////44 45 /// @todo Remove. See @c todo in #switchTo() below.46 #if 047 48 #if defined (VBOX_WS_WIN)49 50 struct EnumWindowsProcData51 {52 ULONG pid;53 WId wid;54 };55 56 BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)57 {58 EnumWindowsProcData *d = (EnumWindowsProcData *) lParam;59 60 DWORD pid = 0;61 GetWindowThreadProcessId(hwnd, &pid);62 63 if (d->pid == pid)64 {65 WINDOWINFO info;66 if (!GetWindowInfo(hwnd, &info))67 return TRUE;68 69 #if 070 LogFlowFunc(("pid=%d, wid=%08X\n", pid, hwnd));71 LogFlowFunc((" parent=%08X\n", GetParent(hwnd)));72 LogFlowFunc((" owner=%08X\n", GetWindow(hwnd, GW_OWNER)));73 TCHAR buf [256];74 LogFlowFunc((" rcWindow=%d,%d;%d,%d\n",75 info.rcWindow.left, info.rcWindow.top,76 info.rcWindow.right, info.rcWindow.bottom));77 LogFlowFunc((" dwStyle=%08X\n", info.dwStyle));78 LogFlowFunc((" dwExStyle=%08X\n", info.dwExStyle));79 GetClassName(hwnd, buf, 256);80 LogFlowFunc((" class=%ls\n", buf));81 GetWindowText(hwnd, buf, 256);82 LogFlowFunc((" text=%ls\n", buf));83 #endif84 85 /* we are interested in unowned top-level windows only */86 if (!(info.dwStyle & (WS_CHILD | WS_POPUP)) &&87 info.rcWindow.left < info.rcWindow.right &&88 info.rcWindow.top < info.rcWindow.bottom &&89 GetParent(hwnd) == NULL &&90 GetWindow(hwnd, GW_OWNER) == NULL)91 {92 d->wid = hwnd;93 /* if visible, stop the search immediately */94 if (info.dwStyle & WS_VISIBLE)95 return FALSE;96 /* otherwise, give other top-level windows a chance97 * (the last one wins) */98 }99 }100 101 return TRUE;102 }103 104 #endif105 106 /**107 * Searches for a main window of the given process.108 *109 * @param aPid process ID to search for110 *111 * @return window ID on success or <tt>(WId) ~0</tt> otherwise.112 */113 static WId FindWindowIdFromPid(ULONG aPid)114 {115 #if defined (VBOX_WS_WIN)116 117 EnumWindowsProcData d = { aPid, (WId) ~0 };118 EnumWindows(EnumWindowsProc, (LPARAM) &d);119 LogFlowFunc(("SELECTED wid=%08X\n", d.wid));120 return d.wid;121 122 #elif defined (VBOX_WS_X11)123 124 NOREF(aPid);125 return (WId) ~0;126 127 #elif defined (VBOX_WS_MAC)128 129 /** @todo Figure out how to get access to another windows of another process...130 * Or at least check that it's not a VBoxVRDP process. */131 NOREF (aPid);132 return (WId) 0;133 134 #else135 136 return (WId) ~0;137 138 #endif139 }140 141 #endif142 143 42 UIVirtualMachineItem::UIVirtualMachineItem(const CMachine &aMachine) 144 43 : m_machine(aMachine) … … 150 49 { 151 50 } 152 153 // public members154 ////////////////////////////////////////////////////////////////////////////////155 51 156 52 QPixmap UIVirtualMachineItem::osPixmap(QSize *pLogicalSize /* = 0 */) const … … 252 148 { 253 149 m_pid = (ULONG) ~0; 254 /// @todo Remove. See @c todo in #switchTo() below.255 #if 0256 mWinId = (WId) ~0;257 #endif258 150 } 259 151 else 260 152 { 261 153 m_pid = m_machine.GetSessionPID(); 262 /// @todo Remove. See @c todo in #switchTo() below.263 #if 0264 mWinId = FindWindowIdFromPid(m_pid);265 #endif266 154 } 267 155 … … 295 183 m_groups.clear(); 296 184 m_pid = (ULONG) ~0; 297 /// @todo Remove. See @c todo in #switchTo() below.298 #if 0299 mWinId = (WId) ~0;300 #endif301 185 302 186 /* Set configuration access level to NULL: */ … … 339 223 { 340 224 return const_cast <CMachine &>(m_machine).CanShowConsoleWindow(); 341 342 /// @todo Remove. See @c todo in #switchTo() below.343 #if 0344 return mWinId != (WId) ~0;345 #endif346 225 } 347 226 … … 389 268 return false; 390 269 #endif 391 392 /// @todo Below is the old method of switching to the console window393 // based on the process ID of the console process. It should go away394 // after the new (callback-based) method is fully tested.395 #if 0396 397 if (!canSwitchTo())398 return false;399 400 #if defined (VBOX_WS_WIN)401 402 HWND hwnd = mWinId;403 404 /* if there are blockers (modal and modeless dialogs, etc), find the405 * topmost one */406 HWND hwndAbove = NULL;407 do408 {409 hwndAbove = GetNextWindow(hwnd, GW_HWNDPREV);410 HWND hwndOwner;411 if (hwndAbove != NULL &&412 ((hwndOwner = GetWindow(hwndAbove, GW_OWNER)) == hwnd ||413 hwndOwner == hwndAbove))414 hwnd = hwndAbove;415 else416 break;417 }418 while (1);419 420 /* first, check that the primary window is visible */421 if (IsIconic(mWinId))422 ShowWindow(mWinId, SW_RESTORE);423 else if (!IsWindowVisible(mWinId))424 ShowWindow(mWinId, SW_SHOW);425 426 #if 0427 LogFlowFunc(("mWinId=%08X hwnd=%08X\n", mWinId, hwnd));428 #endif429 430 /* then, activate the topmost in the group */431 AllowSetForegroundWindow(m_pid);432 SetForegroundWindow(hwnd);433 434 return true;435 436 #elif defined (VBOX_WS_X11)437 438 return false;439 440 #elif defined (VBOX_WS_MAC)441 442 ProcessSerialNumber psn;443 OSStatus rc = ::GetProcessForPID(m_pid, &psn);444 if (!rc)445 {446 rc = ::SetFrontProcess(&psn);447 448 if (!rc)449 {450 ShowHideProcess(&psn, true);451 return true;452 }453 }454 return false;455 456 #else457 458 return false;459 460 #endif461 462 #endif463 270 } 464 271
Note:
See TracChangeset
for help on using the changeset viewer.