Changeset 59658 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Feb 12, 2016 2:20:29 PM (9 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp
r59657 r59658 58 58 59 59 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 60 61 /* Qt includes: */ 62 #if QT_VERSION >= 0x050000 63 # include <QAbstractNativeEventFilter> 64 #endif /* QT_VERSION >= 0x050000 */ 60 65 61 66 /* GUI includes: */ … … 95 100 enum { KeyExtended = 0x01, KeyPressed = 0x02, KeyPause = 0x04, KeyPrint = 0x08 }; 96 101 enum { IsKeyPressed = 0x01, IsExtKeyPressed = 0x02, IsKbdCaptured = 0x80 }; 102 103 104 #if QT_VERSION >= 0x050000 105 /** QAbstractNativeEventFilter extension 106 * allowing to pre-process native platform events. */ 107 class PrivateEventFilter : public QAbstractNativeEventFilter 108 { 109 public: 110 111 /** Constructor which takes the passed @a pParent to redirect events to. */ 112 PrivateEventFilter(UIKeyboardHandler *pParent) 113 : m_pParent(pParent) 114 {} 115 116 /** Handles all native events. */ 117 bool nativeEventFilter(const QByteArray &eventType, void *pMessage, long *pResult) 118 { 119 /* Redirect event to parent: */ 120 Q_UNUSED(pResult); 121 return m_pParent->nativeEventPreprocessor(eventType, pMessage); 122 } 123 124 private: 125 126 /** Holds the passed parent reference. */ 127 UIKeyboardHandler *m_pParent; 128 }; 129 #endif /* QT_VERSION >= 0x050000 */ 97 130 98 131 … … 944 977 #else /* QT_VERSION >= 0x050000 */ 945 978 979 bool UIKeyboardHandler::nativeEventPreprocessor(const QByteArray &eventType, void *pMessage) 980 { 981 /* Redirect event to machine-view: */ 982 return m_views.value(m_iKeyboardHookViewIndex)->nativeEvent(eventType, pMessage); 983 } 984 946 985 bool UIKeyboardHandler::nativeEventPostprocessor(void *pMessage, ulong uScreenId) 947 986 { … … 1419 1458 , m_pAltGrMonitor(0) 1420 1459 #endif /* Q_WS_WIN */ 1460 #if QT_VERSION >= 0x050000 1461 , m_pPrivateEventFilter(0) 1462 #endif /* QT_VERSION >= 0x050000 */ 1421 1463 , m_cMonitors(1) 1422 1464 { … … 1497 1539 1498 1540 #endif /* Q_WS_WIN */ 1541 1542 #if QT_VERSION >= 0x050000 1543 /* If private event-filter is installed: */ 1544 if (m_pPrivateEventFilter) 1545 { 1546 /* Uninstall existing private event-filter: */ 1547 qApp->removeNativeEventFilter(m_pPrivateEventFilter); 1548 delete m_pPrivateEventFilter; 1549 m_pPrivateEventFilter = 0; 1550 } 1551 #endif /* QT_VERSION >= 0x050000 */ 1499 1552 1500 1553 /* Update keyboard hook view index: */ … … 1585 1638 #endif /* Q_WS_WIN */ 1586 1639 1640 #if QT_VERSION >= 0x050000 1641 # if defined(Q_WS_WIN) || defined(Q_WS_X11) 1642 /* If private event-filter is NOT installed; 1643 * Or installed but NOT for that view: */ 1644 if (!m_pPrivateEventFilter || (int)uScreenId != m_iKeyboardHookViewIndex) 1645 { 1646 /* If private event-filter is installed: */ 1647 if (m_pPrivateEventFilter) 1648 { 1649 /* Uninstall existing private event-filter: */ 1650 qApp->removeNativeEventFilter(m_pPrivateEventFilter); 1651 delete m_pPrivateEventFilter; 1652 m_pPrivateEventFilter = 0; 1653 } 1654 /* Install new private event-filter: */ 1655 m_pPrivateEventFilter = new PrivateEventFilter(this); 1656 qApp->installNativeEventFilter(m_pPrivateEventFilter); 1657 } 1658 # endif /* Q_WS_WIN || Q_WS_X11 */ 1659 #endif /* QT_VERSION >= 0x050000 */ 1660 1587 1661 /* Update keyboard hook view index: */ 1588 1662 m_iKeyboardHookViewIndex = uScreenId; … … 1629 1703 1630 1704 #endif /* Q_WS_WIN */ 1705 1706 #if QT_VERSION >= 0x050000 1707 # if defined(Q_WS_WIN) || defined(Q_WS_X11) 1708 /* If private event-filter is installed: */ 1709 if (m_pPrivateEventFilter) 1710 { 1711 /* Uninstall existing private event-filter: */ 1712 qApp->removeNativeEventFilter(m_pPrivateEventFilter); 1713 delete m_pPrivateEventFilter; 1714 m_pPrivateEventFilter = 0; 1715 } 1716 # endif /* Q_WS_WIN || Q_WS_X11 */ 1717 #endif /* QT_VERSION >= 0x050000 */ 1631 1718 1632 1719 /* Update keyboard hook view index: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.h
r59657 r59658 52 52 # endif /* QT_VERSION < 0x050000 */ 53 53 #endif /* Q_WS_X11 */ 54 #if QT_VERSION >= 0x050000 55 class PrivateEventFilter; 56 #endif /* QT_VERSION >= 0x050000 */ 54 57 55 58 … … 118 121 # endif /* Q_WS_X11 */ 119 122 #else /* QT_VERSION >= 0x050000 */ 123 /** Qt5: Performs pre-processing of all the native events. */ 124 bool nativeEventPreprocessor(const QByteArray &eventType, void *pMessage); 120 125 /** Qt5: Performs post-processing of all the native events. */ 121 126 bool nativeEventPostprocessor(void *pMessage, ulong uScreenId); … … 231 236 #endif /* Q_WS_WIN */ 232 237 238 #if QT_VERSION >= 0x050000 239 /** Win: Holds the native event filter instance. */ 240 PrivateEventFilter *m_pPrivateEventFilter; 241 /** Win: Allows the native event filter to 242 * redirect events directly to nativeEvent handler. */ 243 friend class PrivateEventFilter; 244 #endif /* QT_VERSION >= 0x050000 */ 245 233 246 ULONG m_cMonitors; 234 247 }; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r59656 r59658 70 70 71 71 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 72 73 /* Qt includes: */74 #if defined(Q_WS_WIN) || defined(Q_WS_X11)75 # if QT_VERSION >= 0x05000076 # include <QAbstractNativeEventFilter>77 # endif /* QT_VERSION >= 0x050000 */78 #endif /* Q_WS_WIN || Q_WS_X11 */79 72 80 73 /* GUI includes: */ … … 130 123 131 124 132 #if defined(Q_WS_WIN) || defined(Q_WS_X11)133 # if QT_VERSION >= 0x050000134 /** QAbstractNativeEventFilter extension135 * allowing to pre-process native platform events. */136 class PrivateEventFilter : public QAbstractNativeEventFilter137 {138 public:139 140 /** Constructor which takes the passed @a pParent to redirect events to. */141 PrivateEventFilter(UIMachineView *pParent)142 : m_pParent(pParent)143 {}144 145 /** Handles all native events. */146 bool nativeEventFilter(const QByteArray &eventType, void *pMessage, long *pResult)147 {148 /* Redirect event to parent: */149 Q_UNUSED(pResult);150 return m_pParent->nativeEvent(eventType, pMessage);151 }152 153 private:154 155 /** Holds the passed parent reference. */156 UIMachineView *m_pParent;157 };158 # endif /* QT_VERSION >= 0x050000 */159 #endif /* Q_WS_WIN || Q_WS_X11 */160 161 162 125 /* static */ 163 126 UIMachineView* UIMachineView::create( UIMachineWindow *pMachineWindow … … 251 214 if (!pMachineView) 252 215 return; 253 254 /* Cleanup event-filters: */255 pMachineView->cleanupFilters();256 216 257 217 /* Cleanup frame-buffer: */ … … 662 622 , m_fIsDraggingFromGuest(false) 663 623 #endif 664 #if defined(Q_WS_WIN) || defined(Q_WS_X11)665 # if QT_VERSION >= 0x050000666 , m_pPrivateEventFilter(0)667 # endif /* QT_VERSION >= 0x050000 */668 #endif /* Q_WS_WIN || Q_WS_X11 */669 624 { 670 625 } … … 843 798 /* We want to be notified on some parent's events: */ 844 799 machineWindow()->installEventFilter(this); 845 846 #if defined(Q_WS_WIN) || defined(Q_WS_X11)847 # if QT_VERSION >= 0x050000848 /* Prepare private event-filter: */849 m_pPrivateEventFilter = new PrivateEventFilter(this);850 qApp->installNativeEventFilter(m_pPrivateEventFilter);851 # endif /* QT_VERSION >= 0x050000 */852 #endif /* Q_WS_WIN || Q_WS_X11 */853 800 } 854 801 … … 876 823 /* Machine state-change updater: */ 877 824 connect(uisession(), SIGNAL(sigMachineStateChange()), this, SLOT(sltMachineStateChanged())); 878 }879 880 void UIMachineView::cleanupFilters()881 {882 #if defined(Q_WS_WIN) || defined(Q_WS_X11)883 # if QT_VERSION >= 0x050000884 /* Cleanup private event-filter: */885 qApp->removeNativeEventFilter(m_pPrivateEventFilter);886 delete m_pPrivateEventFilter;887 m_pPrivateEventFilter = 0;888 # endif /* QT_VERSION >= 0x050000 */889 #endif /* Q_WS_WIN || Q_WS_X11 */890 825 } 891 826 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
r59413 r59658 62 62 # endif /* QT_VERSION < 0x050000 */ 63 63 #endif /* Q_WS_X11 */ 64 #if defined(Q_WS_WIN) || defined(Q_WS_X11)65 # if QT_VERSION >= 0x05000066 class PrivateEventFilter;67 # endif /* QT_VERSION >= 0x050000 */68 #endif /* Q_WS_WIN || Q_WS_X11 */69 64 #ifdef VBOX_WITH_DRAG_AND_DROP 70 65 class CDnDTarget; … … 189 184 //virtual void cleanupConsoleConnections() {} 190 185 //virtual void cleanupConnections() {} 191 virtual void cleanupFilters();186 //virtual void cleanupFilters() {} 192 187 //virtual void cleanupCommon() {} 193 188 virtual void cleanupFrameBuffer(); … … 433 428 #endif 434 429 435 #if defined(Q_WS_WIN) || defined(Q_WS_X11)436 # if QT_VERSION >= 0x050000437 /** X11: Holds the native event filter instance. */438 PrivateEventFilter *m_pPrivateEventFilter;439 /** X11: Allows the native event filter to440 * redirect events directly to nativeEvent handler. */441 friend class PrivateEventFilter;442 # endif /* QT_VERSION >= 0x050000 */443 #endif /* Q_WS_WIN || Q_WS_X11 */444 445 430 /* Friend classes: */ 446 431 friend class UIKeyboardHandler;
Note:
See TracChangeset
for help on using the changeset viewer.