Changeset 91079 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Sep 1, 2021 7:26:19 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 146729
- 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 39 39 #include <QTranslator> 40 40 #ifdef VBOX_WS_WIN 41 # include <QEventLoop>42 41 # include <QStyleFactory> 43 42 #endif … … 80 79 # include "VBoxUtils-darwin.h" 81 80 #endif 81 #ifdef VBOX_WS_WIN 82 # include "VBoxUtils-win.h" 83 #endif 82 84 #ifdef VBOX_WS_X11 83 85 # include "UIHostComboEditor.h" … … 128 130 #include <VBox/vd.h> 129 131 #include <VBox/com/Guid.h> 130 #ifdef VBOX_WS_WIN131 # include <iprt/win/shlobj.h>132 #endif133 132 134 133 /* VirtualBox interface declarations: */ … … 1565 1564 bool UICommon::activateWindow(WId wId, bool fSwitchDesktop /* = true */) 1566 1565 { 1567 RT_NOREF(fSwitchDesktop);1566 Q_UNUSED(fSwitchDesktop); 1568 1567 bool fResult = true; 1569 1568 1570 1569 #if defined(VBOX_WS_WIN) 1571 1570 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); 1580 1572 1581 1573 #elif defined(VBOX_WS_X11) 1582 1574 1583 returnNativeWindowSubsystem::X11ActivateWindow(wId, fSwitchDesktop);1575 fResult &= NativeWindowSubsystem::X11ActivateWindow(wId, fSwitchDesktop); 1584 1576 1585 1577 #else … … 3395 3387 // In theory that's Qt5 who should allow us to provide canceling reason as well, but that functionality 3396 3388 // 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."); 3398 3390 #endif 3399 3391 } … … 3467 3459 emit sigVBoxSVCAvailabilityChange(); 3468 3460 } 3469 3470 #ifdef VBOX_WS_WIN3471 /* 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 #endif3485 3461 3486 3462 #ifdef VBOX_WITH_DEBUGGER_GUI -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h
r91066 r91079 683 683 const QString &strMachineName = QString(), 684 684 const QString &strMachineGuestOSTypeId = QString()); 685 /** @} */686 687 /** @name Common stuff.688 * @{ */689 #ifdef VBOX_WS_WIN690 /** Wraps WinAPI ShutdownBlockReasonCreate function. */691 static BOOL ShutdownBlockReasonCreateAPI(HWND hWnd, LPCWSTR pwszReason);692 #endif693 685 /** @} */ 694 686 … … 886 878 /** @} */ 887 879 888 #if defined(VBOX_WS_WIN)880 #ifdef VBOX_WS_WIN 889 881 /** @name ATL stuff. 890 882 * @{ */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp
r91076 r91079 2485 2485 && comMachine.CanShowConsoleWindow()) 2486 2486 { 2487 uiCommon().switchToMachine(comMachine);2487 UICommon::switchToMachine(comMachine); 2488 2488 return; 2489 2489 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItemLocal.cpp
r84189 r91079 168 168 } 169 169 170 bool UIVirtualMachineItemLocal::switchTo()171 {172 #ifdef VBOX_WS_MAC173 ULONG64 id = m_comMachine.ShowConsoleWindow();174 #else175 WId id = (WId) m_comMachine.ShowConsoleWindow();176 #endif177 AssertWrapperOk(m_comMachine);178 if (!m_comMachine.isOk())179 return false;180 181 /* winId = 0 it means the console window has already done everything182 * 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 steal194 // 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 else202 Log(("GUI: Failed to bring %#RX64 to front. rc=%#x\n", id, rc));203 return !rc;204 205 #else206 207 return false;208 209 #endif210 }211 212 170 bool UIVirtualMachineItemLocal::isItemEditable() const 213 171 { -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItemLocal.h
r84189 r91079 73 73 /** Returns cached session state name. */ 74 74 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();82 75 /** @} */ 83 76 -
trunk/src/VBox/Frontends/VirtualBox/src/platform/win/VBoxUtils-win.cpp
r89740 r91079 91 91 } 92 92 93 BOOL 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 106 bool 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 37 37 SHARED_LIBRARY_STUFF const QRegion areaCoveredByTopMostWindows(); 38 38 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); 39 45 } 40 46
Note:
See TracChangeset
for help on using the changeset viewer.