Changeset 88679 in vbox for trunk/src/VBox
- Timestamp:
- Apr 23, 2021 2:50:25 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIConsoleEventHandler.cpp
r86541 r88679 5 5 6 6 /* 7 * Copyright (C) 2010-202 0Oracle Corporation7 * Copyright (C) 2010-2021 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 17 18 18 /* GUI includes: */ 19 #include "UICommon.h" 19 20 #include "UIConsoleEventHandler.h" 21 #include "UIExtraDataManager.h" 20 22 #include "UIMainEventListener.h" 21 23 #include "UIMousePointerShapeData.h" 22 #include "UIExtraDataManager.h"23 #include "UICommon.h"24 24 #include "UISession.h" 25 25 #ifdef VBOX_WS_MAC … … 29 29 /* COM includes: */ 30 30 #include "COMEnums.h" 31 #include "CConsole.h" 31 32 #include "CEventListener.h" 32 33 #include "CEventSource.h" 33 #include "CConsole.h"34 34 35 35 … … 93 93 UIConsoleEventHandlerProxy(QObject *pParent, UISession *pSession); 94 94 /** Destructs event proxy object. */ 95 ~UIConsoleEventHandlerProxy(); 96 97 protected: 98 99 /** @name Prepare/Cleanup cascade. 100 * @{ */ 101 /** Prepares all. */ 102 void prepare(); 103 /** Prepares listener. */ 104 void prepareListener(); 105 /** Prepares connections. */ 106 void prepareConnections(); 107 108 /** Cleanups connections. */ 109 void cleanupConnections(); 110 /** Cleanups listener. */ 111 void cleanupListener(); 112 /** Cleanups all. */ 113 void cleanup(); 114 /** @} */ 95 virtual ~UIConsoleEventHandlerProxy() /* override */; 115 96 116 97 private slots: 117 98 118 /** @name Slots for waitable signals. 119 * @{ */ 120 /** Returns whether VM window can be shown. */ 121 void sltCanShowWindow(bool &fVeto, QString &strReason); 122 /** Shows VM window if possible. */ 123 void sltShowWindow(qint64 &winId); 124 /** @} */ 99 /** Returns whether VM window can be shown. */ 100 void sltCanShowWindow(bool &fVeto, QString &strReason); 101 /** Shows VM window if possible. */ 102 void sltShowWindow(qint64 &winId); 125 103 126 104 private: 105 106 /** Prepares all. */ 107 void prepare(); 108 /** Prepares listener. */ 109 void prepareListener(); 110 /** Prepares connections. */ 111 void prepareConnections(); 112 113 /** Cleanups connections. */ 114 void cleanupConnections(); 115 /** Cleanups listener. */ 116 void cleanupListener(); 117 /** Cleanups all. */ 118 void cleanup(); 127 119 128 120 /** Holds the UI session reference. */ … … 144 136 , m_pSession(pSession) 145 137 { 146 /* Prepare: */147 138 prepare(); 148 139 } … … 150 141 UIConsoleEventHandlerProxy::~UIConsoleEventHandlerProxy() 151 142 { 152 /* Cleanup: */153 143 cleanup(); 154 144 } 155 145 146 void UIConsoleEventHandlerProxy::sltCanShowWindow(bool & /* fVeto */, QString & /* strReason */) 147 { 148 /* Nothing for now. */ 149 } 150 151 void UIConsoleEventHandlerProxy::sltShowWindow(qint64 &winId) 152 { 153 #ifdef VBOX_WS_MAC 154 /* First of all, just ask the GUI thread to show the machine-window: */ 155 winId = 0; 156 if (::darwinSetFrontMostProcess()) 157 emit sigShowWindow(); 158 else 159 { 160 /* If it's failed for some reason, send the other process our PSN so it can try: */ 161 winId = ::darwinGetCurrentProcessId(); 162 } 163 #else /* !VBOX_WS_MAC */ 164 /* Return the ID of the top-level machine-window. */ 165 winId = (ULONG64)m_pSession->mainMachineWindowId(); 166 #endif /* !VBOX_WS_MAC */ 167 } 168 156 169 void UIConsoleEventHandlerProxy::prepare() 157 170 { 158 /* Prepare: */159 171 prepareListener(); 160 172 prepareConnections(); … … 203 215 << KVBoxEventType_OnAudioAdapterChanged 204 216 << KVBoxEventType_OnClipboardModeChanged 205 << KVBoxEventType_OnDnDModeChanged; 217 << KVBoxEventType_OnDnDModeChanged 218 ; 206 219 207 220 /* Register event listener for console event source: */ … … 311 324 void UIConsoleEventHandlerProxy::cleanup() 312 325 { 313 /* Cleanup: */314 326 cleanupConnections(); 315 327 cleanupListener(); 316 }317 318 void UIConsoleEventHandlerProxy::sltCanShowWindow(bool & /* fVeto */, QString & /* strReason */)319 {320 /* Nothing for now. */321 }322 323 void UIConsoleEventHandlerProxy::sltShowWindow(qint64 &winId)324 {325 #ifdef VBOX_WS_MAC326 /* First of all, just ask the GUI thread to show the machine-window: */327 winId = 0;328 if (::darwinSetFrontMostProcess())329 emit sigShowWindow();330 else331 {332 /* If it's failed for some reason, send the other process our PSN so it can try: */333 winId = ::darwinGetCurrentProcessId();334 }335 #else /* !VBOX_WS_MAC */336 /* Return the ID of the top-level machine-window. */337 winId = (ULONG64)m_pSession->mainMachineWindowId();338 #endif /* !VBOX_WS_MAC */339 328 } 340 329 … … 345 334 346 335 /* static */ 347 UIConsoleEventHandler *UIConsoleEventHandler:: m_spInstance = 0;336 UIConsoleEventHandler *UIConsoleEventHandler::s_pInstance = 0; 348 337 349 338 /* static */ 350 339 void UIConsoleEventHandler::create(UISession *pSession) 351 340 { 352 if (! m_spInstance)353 m_spInstance = new UIConsoleEventHandler(pSession);341 if (!s_pInstance) 342 s_pInstance = new UIConsoleEventHandler(pSession); 354 343 } 355 344 … … 357 346 void UIConsoleEventHandler::destroy() 358 347 { 359 if ( m_spInstance)348 if (s_pInstance) 360 349 { 361 delete m_spInstance;362 m_spInstance = 0;350 delete s_pInstance; 351 s_pInstance = 0; 363 352 } 364 353 } … … 367 356 : m_pProxy(new UIConsoleEventHandlerProxy(this, pSession)) 368 357 { 369 /* Prepare: */370 358 prepare(); 371 359 } … … 373 361 void UIConsoleEventHandler::prepare() 374 362 { 375 /* Prepare: */376 363 prepareConnections(); 377 364 } … … 393 380 Qt::QueuedConnection); 394 381 connect(m_pProxy, &UIConsoleEventHandlerProxy::sigStateChange, 395 this, &UIConsoleEventHandler::sigStateChange,382 this, &UIConsoleEventHandler::sigStateChange, 396 383 Qt::QueuedConnection); 397 384 connect(m_pProxy, &UIConsoleEventHandlerProxy::sigAdditionsChange, … … 402 389 Qt::QueuedConnection); 403 390 connect(m_pProxy, &UIConsoleEventHandlerProxy::sigStorageDeviceChange, 404 this, &UIConsoleEventHandler::sigStorageDeviceChange,391 this, &UIConsoleEventHandler::sigStorageDeviceChange, 405 392 Qt::QueuedConnection); 406 393 connect(m_pProxy, &UIConsoleEventHandlerProxy::sigMediumChange, -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIConsoleEventHandler.h
r82968 r88679 5 5 6 6 /* 7 * Copyright (C) 2010-202 0Oracle Corporation7 * Copyright (C) 2010-2021 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 28 28 /* COM includes: */ 29 29 #include "COMEnums.h" 30 #include "CVirtualBoxErrorInfo.h"31 30 #include "CMediumAttachment.h" 32 31 #include "CNetworkAdapter.h" 33 32 #include "CUSBDevice.h" 33 #include "CVirtualBoxErrorInfo.h" 34 34 35 35 /* Forward declarations: */ … … 96 96 97 97 /** Returns singleton instance created by the factory. */ 98 static UIConsoleEventHandler * instance() { return m_spInstance; }98 static UIConsoleEventHandler *instance() { return s_pInstance; } 99 99 /** Creates singleton instance created by the factory. */ 100 100 static void create(UISession *pSession); … … 107 107 UIConsoleEventHandler(UISession *pSession); 108 108 109 /** @name Prepare cascade. 110 * @{ */ 111 /** Prepares all. */ 112 void prepare(); 113 /** Prepares connections. */ 114 void prepareConnections(); 115 /** @} */ 109 /** Prepares all. */ 110 void prepare(); 111 /** Prepares connections. */ 112 void prepareConnections(); 116 113 117 114 private: 118 115 119 116 /** Holds the singleton static console event handler instance. */ 120 static UIConsoleEventHandler * m_spInstance;117 static UIConsoleEventHandler *s_pInstance; 121 118 122 119 /** Holds the console event proxy instance. */
Note:
See TracChangeset
for help on using the changeset viewer.