VirtualBox

Changeset 91079 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Sep 1, 2021 7:26:19 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
146729
Message:

FE/Qt: bugref:10067: Moving Windows stuff from UICommon to VBoxUtils-win.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp

    r91070 r91079  
    3939#include <QTranslator>
    4040#ifdef VBOX_WS_WIN
    41 # include <QEventLoop>
    4241# include <QStyleFactory>
    4342#endif
     
    8079# include "VBoxUtils-darwin.h"
    8180#endif
     81#ifdef VBOX_WS_WIN
     82# include "VBoxUtils-win.h"
     83#endif
    8284#ifdef VBOX_WS_X11
    8385# include "UIHostComboEditor.h"
     
    128130#include <VBox/vd.h>
    129131#include <VBox/com/Guid.h>
    130 #ifdef VBOX_WS_WIN
    131 # include <iprt/win/shlobj.h>
    132 #endif
    133132
    134133/* VirtualBox interface declarations: */
     
    15651564bool UICommon::activateWindow(WId wId, bool fSwitchDesktop /* = true */)
    15661565{
    1567     RT_NOREF(fSwitchDesktop);
     1566    Q_UNUSED(fSwitchDesktop);
    15681567    bool fResult = true;
    15691568
    15701569#if defined(VBOX_WS_WIN)
    15711570
    1572     HWND handle = (HWND)wId;
    1573 
    1574     if (IsIconic(handle))
    1575         fResult &= !!ShowWindow(handle, SW_RESTORE);
    1576     else if (!IsWindowVisible(handle))
    1577         fResult &= !!ShowWindow(handle, SW_SHOW);
    1578 
    1579     fResult &= !!SetForegroundWindow(handle);
     1571    fResult &= NativeWindowSubsystem::WinActivateWindow(wId, fSwitchDesktop);
    15801572
    15811573#elif defined(VBOX_WS_X11)
    15821574
    1583     return NativeWindowSubsystem::X11ActivateWindow(wId, fSwitchDesktop);
     1575    fResult &= NativeWindowSubsystem::X11ActivateWindow(wId, fSwitchDesktop);
    15841576
    15851577#else
     
    33953387                // In theory that's Qt5 who should allow us to provide canceling reason as well, but that functionality
    33963388                // seems to be missed in Windows platform plugin, so we are making that ourselves.
    3397                 ShutdownBlockReasonCreateAPI((HWND)windowManager().mainWindowShown()->winId(), L"VM is still running.");
     3389                NativeWindowSubsystem::ShutdownBlockReasonCreateAPI((HWND)windowManager().mainWindowShown()->winId(), L"VM is still running.");
    33983390#endif
    33993391            }
     
    34673459    emit sigVBoxSVCAvailabilityChange();
    34683460}
    3469 
    3470 #ifdef VBOX_WS_WIN
    3471 /* static */
    3472 BOOL UICommon::ShutdownBlockReasonCreateAPI(HWND hWnd, LPCWSTR pwszReason)
    3473 {
    3474     BOOL fResult = FALSE;
    3475     typedef BOOL(WINAPI *PFNSHUTDOWNBLOCKREASONCREATE)(HWND hWnd, LPCWSTR pwszReason);
    3476 
    3477     PFNSHUTDOWNBLOCKREASONCREATE pfn = (PFNSHUTDOWNBLOCKREASONCREATE)GetProcAddress(
    3478         GetModuleHandle(L"User32.dll"), "ShutdownBlockReasonCreate");
    3479     _ASSERTE(pfn);
    3480     if (pfn)
    3481         fResult = pfn(hWnd, pwszReason);
    3482     return fResult;
    3483 }
    3484 #endif
    34853461
    34863462#ifdef VBOX_WITH_DEBUGGER_GUI
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h

    r91066 r91079  
    683683                                const QString &strMachineName = QString(),
    684684                                const QString &strMachineGuestOSTypeId = QString());
    685     /** @} */
    686 
    687     /** @name Common stuff.
    688      * @{ */
    689 #ifdef VBOX_WS_WIN
    690         /** Wraps WinAPI ShutdownBlockReasonCreate function. */
    691         static BOOL ShutdownBlockReasonCreateAPI(HWND hWnd, LPCWSTR pwszReason);
    692 #endif
    693685    /** @} */
    694686
     
    886878    /** @} */
    887879
    888 #if defined(VBOX_WS_WIN)
     880#ifdef VBOX_WS_WIN
    889881    /** @name ATL stuff.
    890882     * @{ */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r91076 r91079  
    24852485        && comMachine.CanShowConsoleWindow())
    24862486    {
    2487         uiCommon().switchToMachine(comMachine);
     2487        UICommon::switchToMachine(comMachine);
    24882488        return;
    24892489    }
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItemLocal.cpp

    r84189 r91079  
    168168}
    169169
    170 bool UIVirtualMachineItemLocal::switchTo()
    171 {
    172 #ifdef VBOX_WS_MAC
    173     ULONG64 id = m_comMachine.ShowConsoleWindow();
    174 #else
    175     WId id = (WId) m_comMachine.ShowConsoleWindow();
    176 #endif
    177     AssertWrapperOk(m_comMachine);
    178     if (!m_comMachine.isOk())
    179         return false;
    180 
    181     /* winId = 0 it means the console window has already done everything
    182      * necessary to implement the "show window" semantics. */
    183     if (id == 0)
    184         return true;
    185 
    186 #if defined (VBOX_WS_WIN) || defined (VBOX_WS_X11)
    187 
    188     return uiCommon().activateWindow(id, true);
    189 
    190 #elif defined (VBOX_WS_MAC)
    191 
    192     // WORKAROUND:
    193     // This is just for the case were the other process cannot steal
    194     // the focus from us. It will send us a PSN so we can try.
    195     ProcessSerialNumber psn;
    196     psn.highLongOfPSN = id >> 32;
    197     psn.lowLongOfPSN = (UInt32)id;
    198     OSErr rc = ::SetFrontProcess(&psn);
    199     if (!rc)
    200         Log(("GUI: %#RX64 couldn't do SetFrontProcess on itself, the selector (we) had to do it...\n", id));
    201     else
    202         Log(("GUI: Failed to bring %#RX64 to front. rc=%#x\n", id, rc));
    203     return !rc;
    204 
    205 #else
    206 
    207     return false;
    208 
    209 #endif
    210 }
    211 
    212170bool UIVirtualMachineItemLocal::isItemEditable() const
    213171{
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItemLocal.h

    r84189 r91079  
    7373        /** Returns cached session state name. */
    7474        QString sessionStateName() const { return m_strSessionStateName; }
    75     /** @} */
    76 
    77     /** @name Console attributes.
    78       * @{ */
    79         /** Tries to switch to the main window of the VM process.
    80           * @return true if switched successfully. */
    81         bool switchTo();
    8275    /** @} */
    8376
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/win/VBoxUtils-win.cpp

    r89740 r91079  
    9191}
    9292
     93BOOL NativeWindowSubsystem::ShutdownBlockReasonCreateAPI(HWND hWnd, LPCWSTR pwszReason)
     94{
     95    BOOL fResult = FALSE;
     96    typedef BOOL(WINAPI *PFNSHUTDOWNBLOCKREASONCREATE)(HWND hWnd, LPCWSTR pwszReason);
     97
     98    PFNSHUTDOWNBLOCKREASONCREATE pfn = (PFNSHUTDOWNBLOCKREASONCREATE)GetProcAddress(
     99        GetModuleHandle(L"User32.dll"), "ShutdownBlockReasonCreate");
     100    _ASSERTE(pfn);
     101    if (pfn)
     102        fResult = pfn(hWnd, pwszReason);
     103    return fResult;
     104}
     105
     106bool NativeWindowSubsystem::WinActivateWindow(WId wId, bool)
     107{
     108    bool fResult = true;
     109    HWND handle = (HWND)wId;
     110
     111    if (IsIconic(handle))
     112        fResult &= !!ShowWindow(handle, SW_RESTORE);
     113    else if (!IsWindowVisible(handle))
     114        fResult &= !!ShowWindow(handle, SW_SHOW);
     115
     116    fResult &= !!SetForegroundWindow(handle);
     117    return fResult;
     118}
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/win/VBoxUtils-win.h

    r89740 r91079  
    3737    SHARED_LIBRARY_STUFF const QRegion areaCoveredByTopMostWindows();
    3838    SHARED_LIBRARY_STUFF const void setScreenSaverActive(BOOL fDisableScreenSaver);
     39
     40    /** Wraps WinAPI ShutdownBlockReasonCreate function. */
     41    SHARED_LIBRARY_STUFF BOOL ShutdownBlockReasonCreateAPI(HWND hWnd, LPCWSTR pwszReason);
     42
     43    /** Activates window with certain @a wId, @a fSwitchDesktop if requested. */
     44    bool WinActivateWindow(WId wId, bool fSwitchDesktop);
    3945}
    4046
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