VirtualBox

Ignore:
Timestamp:
Sep 17, 2018 2:39:14 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: VirtualBox Manager todo fix: Wipe out old show running VM windows code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItem.cpp

    r73424 r74311  
    4040
    4141
    42 // Helpers
    43 ////////////////////////////////////////////////////////////////////////////////
    44 
    45 /// @todo Remove. See @c todo in #switchTo() below.
    46 #if 0
    47 
    48 #if defined (VBOX_WS_WIN)
    49 
    50 struct EnumWindowsProcData
    51 {
    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 0
    70         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 #endif
    84 
    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 chance
    97              * (the last one wins) */
    98         }
    99     }
    100 
    101     return TRUE;
    102 }
    103 
    104 #endif
    105 
    106 /**
    107  * Searches for a main window of the given process.
    108  *
    109  * @param aPid process ID to search for
    110  *
    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 #else
    135 
    136     return (WId) ~0;
    137 
    138 #endif
    139 }
    140 
    141 #endif
    142 
    14342UIVirtualMachineItem::UIVirtualMachineItem(const CMachine &aMachine)
    14443    : m_machine(aMachine)
     
    15049{
    15150}
    152 
    153 // public members
    154 ////////////////////////////////////////////////////////////////////////////////
    15551
    15652QPixmap UIVirtualMachineItem::osPixmap(QSize *pLogicalSize /* = 0 */) const
     
    252148        {
    253149            m_pid = (ULONG) ~0;
    254     /// @todo Remove. See @c todo in #switchTo() below.
    255 #if 0
    256             mWinId = (WId) ~0;
    257 #endif
    258150        }
    259151        else
    260152        {
    261153            m_pid = m_machine.GetSessionPID();
    262     /// @todo Remove. See @c todo in #switchTo() below.
    263 #if 0
    264             mWinId = FindWindowIdFromPid(m_pid);
    265 #endif
    266154        }
    267155
     
    295183        m_groups.clear();
    296184        m_pid = (ULONG) ~0;
    297     /// @todo Remove. See @c todo in #switchTo() below.
    298 #if 0
    299         mWinId = (WId) ~0;
    300 #endif
    301185
    302186        /* Set configuration access level to NULL: */
     
    339223{
    340224    return const_cast <CMachine &>(m_machine).CanShowConsoleWindow();
    341 
    342     /// @todo Remove. See @c todo in #switchTo() below.
    343 #if 0
    344     return mWinId != (WId) ~0;
    345 #endif
    346225}
    347226
     
    389268    return false;
    390269#endif
    391 
    392     /// @todo Below is the old method of switching to the console window
    393     //  based on the process ID of the console process. It should go away
    394     //  after the new (callback-based) method is fully tested.
    395 #if 0
    396 
    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 the
    405      * topmost one */
    406     HWND hwndAbove = NULL;
    407     do
    408     {
    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         else
    416             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 0
    427     LogFlowFunc(("mWinId=%08X hwnd=%08X\n", mWinId, hwnd));
    428 #endif
    429 
    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 #else
    457 
    458     return false;
    459 
    460 #endif
    461 
    462 #endif
    463270}
    464271
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette