Changeset 58943 in vbox
- Timestamp:
- Dec 1, 2015 4:25:06 PM (9 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 10 edited
-
platform/x11/XKeyboard-new.cpp (modified) (3 diffs)
-
platform/x11/XKeyboard.h (modified) (1 diff)
-
runtime/UIKeyboardHandler.cpp (modified) (14 diffs)
-
runtime/UIKeyboardHandler.h (modified) (4 diffs)
-
runtime/UIMachineView.cpp (modified) (8 diffs)
-
runtime/UIMachineView.h (modified) (3 diffs)
-
runtime/UIMachineWindow.cpp (modified) (4 diffs)
-
runtime/UIMachineWindow.h (modified) (2 diffs)
-
runtime/UIMouseHandler.cpp (modified) (3 diffs)
-
runtime/UIMouseHandler.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/platform/x11/XKeyboard-new.cpp
r52730 r58943 16 16 */ 17 17 18 #ifdef VBOX_WITH_PRECOMPILED_HEADERS 19 # include <precomp.h> 20 #else /* !VBOX_WITH_PRECOMPILED_HEADERS */ 21 22 /* Define GUI log group. 23 * This define should go *before* VBox/log.h include: */ 18 24 #define LOG_GROUP LOG_GROUP_GUI 19 25 20 #include <QString> 21 #include <QStringList> 26 /* Qt includes: */ 27 # include <QString> 28 # include <QStringList> 29 30 /* Other VBox includes: */ 31 # include <VBox/log.h> 32 33 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 34 35 /* GUI includes: */ 36 #include <XKeyboard.h> 37 38 /* Other VBox includes: */ 39 #include <VBox/VBoxKeyboard.h> 40 41 /* External includes: */ 22 42 #include <X11/XKBlib.h> 23 #include <X11/Xlib.h>24 43 #include <X11/keysym.h> 25 #include <XKeyboard.h>26 #include <VBox/log.h>27 #include <VBox/VBoxKeyboard.h>28 44 29 45 … … 232 248 * Translate an X server scancode to a PC keyboard scancode. 233 249 */ 234 unsigned handleXKeyEvent( XEvent *event)250 unsigned handleXKeyEvent(Display *pDisplay, unsigned int iDetail) 235 251 { 236 252 // call the WINE event handler 237 unsigned key = X11DRV_KeyEvent( event->xkey.display, event->xkey.keycode);253 unsigned key = X11DRV_KeyEvent(pDisplay, iDetail); 238 254 LogRel3(("VBoxKeyboard: converting keycode %d to scancode %s0x%x\n", 239 event->xkey.keycode, key > 0x100 ? "0xe0 " : "", key & 0xff));255 iDetail, key > 0x100 ? "0xe0 " : "", key & 0xff)); 240 256 return key; 241 257 } … … 248 264 * keycode is pressed. 249 265 */ 250 void initMappedX11Keyboard(Display *pDisplay, QStringremapScancodes)266 void initMappedX11Keyboard(Display *pDisplay, const QString &remapScancodes) 251 267 { 252 268 int (*scancodes)[2] = NULL; -
trunk/src/VBox/Frontends/VirtualBox/src/platform/x11/XKeyboard.h
r55401 r58943 19 19 #define __XKeyboard_h__ 20 20 21 #include <QString> 21 /* Forward declarations: */ 22 class QString; 23 typedef struct _XDisplay Display; 24 22 25 23 26 // initialize the X keyboard subsystem 24 void initMappedX11Keyboard(Display *pDisplay, QStringremapScancodes);27 void initMappedX11Keyboard(Display *pDisplay, const QString &remapScancodes); 25 28 // our custom keyboard handler 26 unsigned handleXKeyEvent( XEvent *event);29 unsigned handleXKeyEvent(Display *pDisplay, unsigned int iDetail); 27 30 // Called after release logging is started, in case initXKeyboard wishes to log 28 31 // anything -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp
r55724 r58943 28 28 /* GUI includes: */ 29 29 # include "VBoxGlobal.h" 30 # include "UIExtraDataManager.h" 30 31 # include "UIMessageCenter.h" 31 32 # include "UIPopupCenter.h" 32 33 # include "UIActionPool.h" 34 # include "UISession.h" 35 # include "UIMachineLogic.h" 36 # include "UIMachineWindow.h" 37 # include "UIMachineView.h" 38 # include "UIHostComboEditor.h" 33 39 # include "UIKeyboardHandlerNormal.h" 34 40 # include "UIKeyboardHandlerFullscreen.h" … … 36 42 # include "UIKeyboardHandlerScale.h" 37 43 # include "UIMouseHandler.h" 38 # include "UISession.h" 39 # include "UIMachineLogic.h" 40 # include "UIMachineWindow.h" 41 # include "UIMachineView.h" 42 # include "UIHostComboEditor.h" 43 # include "UIExtraDataManager.h" 44 # ifdef Q_WS_MAC 45 # include "UICocoaApplication.h" 46 # include "VBoxUtils-darwin.h" 47 # endif /* Q_WS_MAC */ 44 48 45 49 /* COM includes: */ 46 # include "C Console.h"50 # include "CKeyboard.h" 47 51 48 52 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 49 53 50 /* Other VBox includes: */ 54 /* GUI includes: */ 55 #ifdef Q_WS_MAC 56 # include "DarwinKeyboard.h" 57 #endif /* Q_WS_MAC */ 58 #ifdef Q_WS_WIN 59 # include "WinKeyboard.h" 60 #endif /* Q_WS_WIN */ 61 #ifdef Q_WS_X11 62 # include "XKeyboard.h" 63 #endif /* Q_WS_X11 */ 64 65 /* External includes: */ 66 #ifdef Q_WS_MAC 67 # include <Carbon/Carbon.h> 68 #endif /* Q_WS_MAC */ 51 69 #ifdef Q_WS_X11 52 70 # include <X11/XKBlib.h> 53 71 # include <X11/keysym.h> 54 72 # ifdef KeyPress 73 const int XFocusIn = FocusIn; 55 74 const int XFocusOut = FocusOut; 56 const int XFocusIn = FocusIn;57 75 const int XKeyPress = KeyPress; 58 76 const int XKeyRelease = KeyRelease; … … 62 80 # undef FocusIn 63 81 # endif /* KeyPress */ 64 # include "XKeyboard.h" 82 # if QT_VERSION >= 0x050000 83 # include <xcb/xcb.h> 84 # endif /* QT_VERSION >= 0x050000 */ 65 85 #endif /* Q_WS_X11 */ 66 67 #ifdef Q_WS_MAC68 # include "VBoxUtils-darwin.h"69 # include "DarwinKeyboard.h"70 # include "UICocoaApplication.h"71 # include <Carbon/Carbon.h>72 #endif /* Q_WS_MAC */73 74 #ifdef Q_WS_WIN75 # include "WinKeyboard.h"76 #endif /* Q_WS_WIN */77 86 78 87 /* Enums representing different keyboard-states: */ 79 88 enum { KeyExtended = 0x01, KeyPressed = 0x02, KeyPause = 0x04, KeyPrint = 0x08 }; 80 89 enum { IsKeyPressed = 0x01, IsExtKeyPressed = 0x02, IsKbdCaptured = 0x80 }; 90 81 91 82 92 #ifdef Q_WS_WIN … … 172 182 173 183 #ifdef Q_WS_X11 184 # if QT_VERSION < 0x050000 174 185 struct CHECKFORX11FOCUSEVENTSDATA 175 186 { … … 203 214 return data.fEventFound; 204 215 } 216 # endif /* QT_VERSION < 0x050000 */ 205 217 #endif /* Q_WS_X11 */ 206 218 … … 234 246 case UIVisualStateType_Scale: 235 247 { 248 # if QT_VERSION >= 0x050000 249 xcb_grab_key_checked(QX11Info::connection(), 0, m_views.value(m_iKeyboardCaptureViewIndex)->viewport()->winId(), XCB_MOD_MASK_ANY, XCB_GRAB_ANY, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC); 250 # else /* QT_VERSION < 0x050000 */ 236 251 XGrabKey(QX11Info::display(), AnyKey, AnyModifier, m_windows[m_iKeyboardCaptureViewIndex]->winId(), False, GrabModeAsync, GrabModeAsync); 252 # endif /* QT_VERSION < 0x050000 */ 237 253 break; 238 254 } … … 241 257 case UIVisualStateType_Seamless: 242 258 { 259 # if QT_VERSION >= 0x050000 260 xcb_grab_keyboard(QX11Info::connection(), 0, m_views.value(m_iKeyboardCaptureViewIndex)->viewport()->winId(), XCB_CURRENT_TIME, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC); 261 # else /* QT_VERSION < 0x050000 */ 243 262 /* Keyboard grabbing can fail because of some keyboard shortcut is still grabbed by window manager. 244 263 * We can't be sure this shortcut will be released at all, so we will retry to grab keyboard for 50 times, … … 256 275 CurrentTime)) 257 276 --cTriesLeft; 277 # endif /* QT_VERSION < 0x050000 */ 258 278 break; 259 279 } … … 302 322 case UIVisualStateType_Scale: 303 323 { 324 # if QT_VERSION >= 0x050000 325 xcb_ungrab_key(QX11Info::connection(), XCB_GRAB_ANY, m_views.value(m_iKeyboardCaptureViewIndex)->viewport()->winId(), XCB_MOD_MASK_ANY); 326 # else /* QT_VERSION < 0x050000 */ 304 327 XUngrabKey(QX11Info::display(), AnyKey, AnyModifier, m_windows[m_iKeyboardCaptureViewIndex]->winId()); 328 # endif /* QT_VERSION < 0x050000 */ 305 329 break; 306 330 } … … 309 333 case UIVisualStateType_Seamless: 310 334 { 335 # if QT_VERSION >= 0x050000 336 xcb_ungrab_keyboard(QX11Info::connection(), CurrentTime); 337 # else /* QT_VERSION < 0x050000 */ 311 338 XUngrabKeyboard(QX11Info::display(), CurrentTime); 339 # endif /* QT_VERSION < 0x050000 */ 312 340 break; 313 341 } … … 568 596 569 597 #elif defined(Q_WS_X11) 598 # if QT_VERSION >= 0x050000 599 600 bool UIKeyboardHandler::nativeEventFilter(void *pMessage, ulong uScreenId) 601 { 602 /* Cast to XCB event: */ 603 xcb_generic_event_t *pEvent = static_cast<xcb_generic_event_t*>(pMessage); 604 605 /* Check if some system event should be filtered out. 606 * Returning @c true means filtering-out, 607 * Returning @c false means passing event to Qt. */ 608 bool fResult = false; /* Pass to Qt by default. */ 609 switch (pEvent->response_type & ~0x80) 610 { 611 /* Watch for keyboard behavior: */ 612 case XCB_KEY_PRESS: 613 case XCB_KEY_RELEASE: 614 { 615 /* Cast to XCB key-event: */ 616 xcb_key_press_event_t *pKeyEvent = static_cast<xcb_key_press_event_t*>(pMessage); 617 618 /* Translate the keycode to a PC scancode: */ 619 unsigned scan = handleXKeyEvent(QX11Info::display(), pKeyEvent->detail); 620 621 /* Scancodes 0x00 (no valid translation) and 0x80 (extended flag) are ignored: */ 622 if (!(scan & 0x7F)) 623 { 624 fResult = true; 625 break; 626 } 627 628 // /* Fix for http://www.virtualbox.org/ticket/1296: 629 // * when X11 sends events for repeated keys, it always inserts an XKeyRelease before the XKeyPress. */ 630 // XEvent returnEvent; 631 // if ((pEvent->type == XKeyRelease) && (XCheckIfEvent(pEvent->xkey.display, &returnEvent, 632 // UIKeyboardHandlerCompEvent, (XPointer)pEvent) == True)) 633 // { 634 // XPutBackEvent(pEvent->xkey.display, &returnEvent); 635 // fResult = true; 636 // break; 637 // } 638 639 /* Detect common scancode flags: */ 640 int flags = 0; 641 if (scan >> 8) 642 flags |= KeyExtended; 643 if ((pEvent->response_type & ~0x80) == XCB_KEY_PRESS) 644 flags |= KeyPressed; 645 646 /* Remove the extended flag: */ 647 scan &= 0x7F; 648 649 /* Special Korean keys must send scancode 0xF1/0xF2 650 * when pressed and nothing when released. */ 651 if (scan == 0x71 || scan == 0x72) 652 { 653 if ((pEvent->response_type & ~0x80) == XCB_KEY_RELEASE) 654 { 655 fResult = true; 656 break; 657 } 658 /* Re-create the bizarre scancode: */ 659 scan |= 0x80; 660 } 661 662 /* Translate the keycode to a keysym: */ 663 KeySym ks = ::wrapXkbKeycodeToKeysym(QX11Info::display(), pKeyEvent->detail, 0, 0); 664 665 /* Detect particular scancode flags: */ 666 switch (ks) 667 { 668 case XK_Print: 669 flags |= KeyPrint; 670 break; 671 case XK_Pause: 672 if (pKeyEvent->state & ControlMask) 673 { 674 ks = XK_Break; 675 flags |= KeyExtended; 676 scan = 0x46; 677 } 678 else 679 flags |= KeyPause; 680 break; 681 } 682 683 /* Handle key-event: */ 684 fResult = keyEvent(ks, scan, flags, uScreenId); 685 break; 686 } 687 default: 688 break; 689 } 690 /* Return result: */ 691 return fResult; 692 } 693 694 # else /* QT_VERSION < 0x050000 */ 570 695 571 696 static Bool UIKeyboardHandlerCompEvent(Display*, XEvent *pEvent, XPointer pvArg) … … 621 746 { 622 747 /* Translate the keycode to a PC scan code. */ 623 unsigned scan = handleXKeyEvent(pEvent );748 unsigned scan = handleXKeyEvent(pEvent->xkey.display, pEvent->xkey.keycode); 624 749 625 750 /* Scancodes 0x00 (no valid translation) and 0x80 are ignored: */ … … 691 816 } 692 817 693 #endif 818 # endif /* QT_VERSION < 0x050000 */ 819 #endif /* Q_WS_X11 */ 694 820 695 821 /* Machine state-change handler: */ … … 1418 1544 } 1419 1545 1420 void UIKeyboardHandler::keyEventReleaseHostComboKeys(CKeyboard keyboard) 1421 { 1546 void UIKeyboardHandler::keyEventReleaseHostComboKeys(const CKeyboard &constKeyboard) 1547 { 1548 /* Get keyboard: */ 1549 CKeyboard keyboard(constKeyboard); 1422 1550 /* We have to make guest to release pressed keys from the host-combination: */ 1423 1551 QList<uint8_t> hostComboScans = m_pressedHostComboKeys.values(); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.h
r55401 r58943 20 20 21 21 /* Qt includes: */ 22 #include <QMap> 22 23 #include <QObject> 23 #include <QMap>24 24 25 25 /* GUI includes: */ 26 26 #include "UIExtraDataDefs.h" 27 28 /* Other VBox includes: */ 29 #include <VBox/com/defs.h> 30 31 /* External includes: */ 27 32 #ifdef Q_WS_MAC 33 # include <Carbon/Carbon.h> 28 34 # include <CoreFoundation/CFBase.h> 29 # include <Carbon/Carbon.h>30 35 #endif /* Q_WS_MAC */ 31 32 /* COM includes: */33 #include "COMEnums.h"34 #include "CKeyboard.h"35 36 36 37 /* Forward declarations: */ 37 38 class QWidget; 39 class VBoxGlobalSettings; 40 class UIActionPool; 38 41 class UISession; 39 class UIActionPool;40 42 class UIMachineLogic; 41 43 class UIMachineWindow; 42 44 class UIMachineView; 43 class VBoxGlobalSettings;45 class CKeyboard; 44 46 #if defined(Q_WS_WIN) 45 47 class WinAltGrMonitor; 46 48 #elif defined(Q_WS_X11) 47 typedef union _XEvent XEvent; 49 # if QT_VERSION < 0x050000 50 typedef union _XEvent XEvent; 51 # endif /* QT_VERSION < 0x050000 */ 48 52 #endif /* Q_WS_X11 */ 49 class CKeyboard; 53 50 54 51 55 /* Delegate to control VM keyboard functionality: */ … … 71 75 /* Commands to capture/release keyboard: */ 72 76 #ifdef Q_WS_X11 77 # if QT_VERSION < 0x050000 73 78 bool checkForX11FocusEvents(unsigned long hWindow); 74 #endif 79 # endif /* QT_VERSION < 0x050000 */ 80 #endif /* Q_WS_X11 */ 75 81 void captureKeyboard(ulong uScreenId); 76 82 void releaseKeyboard(); … … 99 105 WinAltGrMonitor *m_pAltGrMonitor; 100 106 #elif defined(Q_WS_X11) 107 # if QT_VERSION >= 0x050000 108 bool nativeEventFilter(void *pMessage, ulong uScreenId); 109 # else /* QT_VERSION < 0x050000 */ 101 110 bool x11EventFilter(XEvent *pEvent, ulong uScreenId); 102 #endif 111 # endif /* QT_VERSION < 0x050000 */ 112 #endif /* Q_WS_X11 */ 103 113 104 114 protected slots: … … 144 154 bool keyEventHostComboHandled(int iKey, wchar_t *pUniKey, bool isHostComboStateChanged, bool *pfResult); 145 155 void keyEventHandleHostComboRelease(ulong uScreenId); 146 void keyEventReleaseHostComboKeys( CKeyboardkeyboard);156 void keyEventReleaseHostComboKeys(const CKeyboard &keyboard); 147 157 /* Separate function to handle most of existing keyboard-events: */ 148 158 bool keyEvent(int iKey, uint8_t uScan, int fFlags, ulong uScreenId, wchar_t *pUniKey = 0); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r58894 r58943 23 23 # include <QDesktopWidget> 24 24 # include <QMainWindow> 25 # include <QTimer>26 25 # include <QPainter> 27 26 # include <QScrollBar> 28 # include <Q MainWindow>27 # include <QTimer> 29 28 30 29 /* GUI includes: */ 31 30 # include "VBoxGlobal.h" 31 # include "UIExtraDataManager.h" 32 32 # include "UIMessageCenter.h" 33 # include "UIFrameBuffer.h"34 # include "VBoxFBOverlay.h"35 33 # include "UISession.h" 36 # include "UIKeyboardHandler.h"37 # include "UIMouseHandler.h"38 34 # include "UIMachineLogic.h" 39 35 # include "UIMachineWindow.h" … … 42 38 # include "UIMachineViewSeamless.h" 43 39 # include "UIMachineViewScale.h" 44 # include "UIExtraDataManager.h" 40 # include "UIKeyboardHandler.h" 41 # include "UIMouseHandler.h" 42 # include "UIFrameBuffer.h" 43 # include "VBoxFBOverlay.h" 44 # ifdef Q_WS_MAC 45 # include "UICocoaApplication.h" 46 # endif /* Q_WS_MAC */ 45 47 # ifdef VBOX_WITH_DRAG_AND_DROP 46 48 # include "UIDnDHandler.h" … … 48 50 49 51 /* VirtualBox interface declarations: */ 50 # ifndef VBOX_WITH_XPCOM51 # include "VirtualBox.h"52 # else /* !VBOX_WITH_XPCOM */53 # include "VirtualBox_XPCOM.h"54 # endif /* VBOX_WITH_XPCOM */52 # ifndef VBOX_WITH_XPCOM 53 # include "VirtualBox.h" 54 # else /* VBOX_WITH_XPCOM */ 55 # include "VirtualBox_XPCOM.h" 56 # endif /* VBOX_WITH_XPCOM */ 55 57 56 58 /* COM includes: */ 57 # include "CSession.h"58 59 # include "CConsole.h" 59 60 # include "CDisplay.h" 60 # include "C Framebuffer.h"61 # include "CSession.h" 61 62 # ifdef VBOX_WITH_DRAG_AND_DROP 62 63 # include "CDnDSource.h" 63 64 # include "CDnDTarget.h" 64 65 # include "CGuest.h" 65 # include "CGuestDnDSource.h"66 # include "CGuestDnDTarget.h"67 66 # endif /* VBOX_WITH_DRAG_AND_DROP */ 68 67 68 /* Other VBox includes: */ 69 # include <iprt/asm.h> 70 69 71 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 70 72 73 /* GUI includes: */ 74 #ifdef Q_WS_MAC 75 # include "DarwinKeyboard.h" 76 # include "DockIconPreview.h" 77 #endif /* Q_WS_MAC */ 78 79 /* COM includes: */ 80 #include "CFramebuffer.h" 81 #ifdef VBOX_WITH_DRAG_AND_DROP 82 # include "CGuestDnDSource.h" 83 # include "CGuestDnDTarget.h" 84 #endif /* VBOX_WITH_DRAG_AND_DROP */ 85 71 86 /* Other VBox includes: */ 72 #include <iprt/asm.h>73 87 #include <VBox/VBoxOGL.h> 74 88 #include <VBox/VBoxVideo.h> 75 89 #ifdef Q_WS_MAC 90 # include <VBox/err.h> 91 #endif /* Q_WS_MAC */ 92 93 /* External includes: */ 94 #include <math.h> 95 #ifdef Q_WS_MAC 96 # include <Carbon/Carbon.h> 97 #endif /* Q_WS_MAC */ 76 98 #ifdef Q_WS_X11 77 # include <X11/XKBlib.h> 78 # include <QX11Info> 79 # ifdef KeyPress 99 # if QT_VERSION >= 0x050000 100 # include <xcb/xcb.h> 101 # else /* QT_VERSION < 0x050000 */ 102 # include <X11/XKBlib.h> 103 # ifdef KeyPress 104 const int XFocusIn = FocusIn; 80 105 const int XFocusOut = FocusOut; 81 const int XFocusIn = FocusIn;82 106 const int XKeyPress = KeyPress; 83 107 const int XKeyRelease = KeyRelease; 84 # undef KeyRelease 85 # undef KeyPress 86 # undef FocusOut 87 # undef FocusIn 88 # endif 108 # undef KeyRelease 109 # undef KeyPress 110 # undef FocusOut 111 # undef FocusIn 112 # endif /* KeyPress */ 113 # endif /* QT_VERSION < 0x050000 */ 89 114 #endif /* Q_WS_X11 */ 90 91 #ifdef Q_WS_MAC92 # include "DockIconPreview.h"93 # include "DarwinKeyboard.h"94 # include "UICocoaApplication.h"95 # include <VBox/err.h>96 # include <Carbon/Carbon.h>97 #endif /* Q_WS_MAC */98 99 /* Other includes: */100 #include <math.h>101 102 115 103 116 #ifdef DEBUG_andy … … 109 122 #endif 110 123 124 125 #ifdef Q_WS_X11 126 # if QT_VERSION >= 0x050000 127 /********************************************************************************************************************************* 128 * Class UIViewport implementation. * 129 *********************************************************************************************************************************/ 130 131 UIViewport::UIViewport(UIMachineView *pParent) 132 : QWidget(pParent) 133 , m_pMachineView(pParent) 134 { 135 } 136 137 bool UIViewport::nativeEvent(const QByteArray &eventType, void *pMessage, long *pResult) 138 { 139 /* Make sure it's XCB event: */ 140 AssertReturn(eventType == "xcb_generic_event_t", QWidget::nativeEvent(eventType, pMessage, pResult)); 141 xcb_generic_event_t *pEvent = static_cast<xcb_generic_event_t*>(pMessage); 142 143 /* Check if some XCB event should be filtered out. 144 * Returning @c true means filtering-out, 145 * Returning @c false means passing event to Qt. */ 146 switch (pEvent->response_type & ~0x80) 147 { 148 /* Watch for key-events: */ 149 case XCB_KEY_PRESS: 150 case XCB_KEY_RELEASE: 151 { 152 /* Delegate key-event handling to the keyboard-handler: */ 153 return machineView()->machineLogic()->keyboardHandler()->nativeEventFilter(pMessage, machineView()->screenId()); 154 } 155 default: 156 break; 157 } 158 159 /* Call to base-class: */ 160 return QWidget::nativeEvent(eventType, pMessage, pResult); 161 } 162 # endif /* QT_VERSION >= 0x050000 */ 163 #endif /* Q_WS_X11 */ 164 165 /********************************************************************************************************************************* 166 * Class UIMachineView implementation. * 167 *********************************************************************************************************************************/ 111 168 112 169 /* static */ … … 591 648 { 592 649 /* Prepare viewport: */ 650 #ifdef Q_WS_X11 651 # if QT_VERSION >= 0x050000 652 setViewport(new UIViewport(this)); 653 # endif /* QT_VERSION >= 0x050000 */ 654 #endif /* Q_WS_X11 */ 593 655 AssertPtrReturnVoid(viewport()); 594 656 { … … 1695 1757 #elif defined(Q_WS_X11) 1696 1758 1759 # if QT_VERSION < 0x050000 1697 1760 bool UIMachineView::x11Event(XEvent *pEvent) 1698 1761 { … … 1705 1768 switch (pEvent->type) 1706 1769 { 1770 case XFocusIn: 1707 1771 case XFocusOut: 1708 case XFocusIn:1709 1772 case XKeyPress: 1710 1773 case XKeyRelease: … … 1726 1789 return fResult; 1727 1790 } 1791 # endif /* QT_VERSION < 0x050000 */ 1728 1792 1729 1793 #endif /* Q_WS_X11 */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
r58011 r58943 24 24 25 25 /* GUI includes: */ 26 #include "UIExtraDataDefs.h" 27 #include "UIMachineDefs.h" 26 28 #ifdef VBOX_WITH_DRAG_AND_DROP 27 29 # include "UIDnDHandler.h" 28 #endif 29 #include "UIExtraDataDefs.h" 30 #include "UIMachineDefs.h" 30 #endif /* VBOX_WITH_DRAG_AND_DROP */ 31 32 /* COM includes: */ 33 #include "COMEnums.h" 34 35 /* Other VBox includes: */ 36 #include "VBox/com/ptr.h" 37 38 /* External includes: */ 31 39 #ifdef Q_WS_MAC 32 40 # include <CoreFoundation/CFBase.h> 33 41 #endif /* Q_WS_MAC */ 34 42 35 /* COM includes: */36 #include "COMEnums.h"37 38 /* Other VBox includes: */39 #include "VBox/com/ptr.h"40 41 43 /* Forward declarations: */ 44 class UIActionPool; 42 45 class UISession; 43 class UIActionPool;44 46 class UIMachineLogic; 45 47 class UIMachineWindow; 46 48 class UIFrameBuffer; 47 #ifdef VBOX_WITH_DRAG_AND_DROP48 class CDnDTarget;49 #endif50 class CSession;51 class CMachine;52 49 class CConsole; 53 50 class CDisplay; 54 51 class CGuest; 52 class CMachine; 53 class CSession; 54 #ifdef Q_WS_X11 55 # if QT_VERSION >= 0x050000 56 class UIMachineView; 57 # else /* QT_VERSION < 0x050000 */ 58 typedef union _XEvent XEvent; 59 # endif /* QT_VERSION < 0x050000 */ 60 #endif /* Q_WS_X11 */ 61 #ifdef VBOX_WITH_DRAG_AND_DROP 62 class CDnDTarget; 63 #endif /* VBOX_WITH_DRAG_AND_DROP */ 64 65 66 #ifdef Q_WS_X11 67 # if QT_VERSION >= 0x050000 68 /** X11: Qt5: QWidget extension used as UIMachineView's viewport. 69 * This class is currently required because of Qt5 policy change about 70 * native keyboard events now being delivered directly to a focus-holder 71 * (UIMachineView's viewport) instead of delivering it to top-most widget 72 * (UIMachineWindow) and then propagating down to the focus-holder, which 73 * with Qt4 allowed us to handle such events in focus-holder's focus-proxy 74 * (UIMachineView) instead of focus-holder itself. */ 75 class UIViewport : public QWidget 76 { 77 Q_OBJECT; 78 79 public: 80 81 /** Constructor which brings the @a pParent machine-view. */ 82 UIViewport(UIMachineView *pParent); 83 84 /** Returns the reference to the parent machine-view. */ 85 const UIMachineView* machineView() { return m_pMachineView; } 86 87 protected: 88 89 /** Qt5: Handles any native @a pMessage of the predefined @a eventType, 90 * allowing to set the @a pResult to be returned to the issuer. */ 91 virtual bool nativeEvent(const QByteArray &eventType, void *pMessage, long *pResult); 92 93 private: 94 95 /** Holds the reference to the parent machine-view. */ 96 const UIMachineView *m_pMachineView; 97 }; 98 # endif /* QT_VERSION >= 0x050000 */ 99 #endif /* Q_WS_X11 */ 55 100 56 101 class UIMachineView : public QAbstractScrollArea … … 335 380 bool winEvent(MSG *pMsg, long *puResult); 336 381 #elif defined(Q_WS_X11) 337 bool x11Event(XEvent *event); 338 #endif 382 # if QT_VERSION < 0x050000 383 /** X11: Qt4: Handles all native events. */ 384 bool x11Event(XEvent *pEvent); 385 # endif /* QT_VERSION < 0x050000 */ 386 #endif /* Q_WS_X11 */ 339 387 340 388 /** Scales passed size forward. */ … … 400 448 friend class UIFrameBufferPrivate; 401 449 friend class VBoxOverlayFrameBuffer; 450 #ifdef Q_WS_X11 451 # if QT_VERSION >= 0x050000 452 friend class UIViewport; 453 # endif /* QT_VERSION >= 0x050000 */ 454 #endif /* Q_WS_X11 */ 402 455 }; 403 456 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp
r58866 r58943 22 22 /* Qt includes: */ 23 23 # include <QCloseEvent> 24 # include <QProcess> 24 25 # include <QTimer> 25 # include <QProcess>26 26 27 27 /* GUI includes: */ 28 28 # include "VBoxGlobal.h" 29 # include "UIConverter.h" 30 # include "UIModalWindowManager.h" 31 # include "UIExtraDataManager.h" 29 32 # include "UIMessageCenter.h" 30 # include "UIKeyboardHandler.h" 33 # include "UISession.h" 34 # include "UIMachineLogic.h" 31 35 # include "UIMachineWindow.h" 32 # include "UIMachineLogic.h"33 # include "UIMachineView.h"34 36 # include "UIMachineWindowNormal.h" 35 37 # include "UIMachineWindowFullscreen.h" 36 38 # include "UIMachineWindowSeamless.h" 37 39 # include "UIMachineWindowScale.h" 40 # include "UIMachineView.h" 41 # include "UIKeyboardHandler.h" 38 42 # include "UIMouseHandler.h" 39 # include "UISession.h"40 43 # include "UIVMCloseDialog.h" 41 # include "UIConverter.h"42 # include "UIModalWindowManager.h"43 # include "UIExtraDataManager.h"44 44 45 45 /* COM includes: */ … … 57 57 /* External includes: */ 58 58 #ifdef Q_WS_X11 59 # include <X11/Xlib.h> 59 # if QT_VERSION < 0x050000 60 # include <X11/Xlib.h> 61 # endif /* QT_VERSION < 0x050000 */ 60 62 #endif /* Q_WS_X11 */ 63 61 64 62 65 /* static */ … … 259 262 260 263 #ifdef Q_WS_X11 264 # if QT_VERSION < 0x050000 261 265 bool UIMachineWindow::x11Event(XEvent *pEvent) 262 266 { … … 279 283 return false; 280 284 } 285 # endif /* QT_VERSION < 0x050000 */ 281 286 #endif /* Q_WS_X11 */ 282 287 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.h
r58142 r58943 34 34 35 35 /* Forward declarations: */ 36 class QCloseEvent; 36 37 class QGridLayout; 37 38 class QSpacerItem; 38 class QCloseEvent; 39 class CSession; 39 class UIActionPool; 40 40 class UISession; 41 41 class UIMachineLogic; 42 42 class UIMachineView; 43 class UIActionPool; 43 class CSession; 44 #ifdef Q_WS_X11 45 # if QT_VERSION < 0x050000 46 typedef union _XEvent XEvent; 47 # endif /* QT_VERSION < 0x050000 */ 48 #endif /* Q_WS_X11 */ 49 44 50 45 51 /* Machine-window interface: */ … … 117 123 /* Event handlers: */ 118 124 #ifdef Q_WS_X11 119 /** X11: Native event handler. */ 125 # if QT_VERSION < 0x050000 126 /** X11: Qt4: Handles all native events. */ 120 127 bool x11Event(XEvent *pEvent); 128 # endif /* QT_VERSION < 0x050000 */ 121 129 #endif /* Q_WS_X11 */ 122 130 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp
r57592 r58943 27 27 /* GUI includes: */ 28 28 # include "VBoxGlobal.h" 29 # include "UIExtraDataManager.h" 29 30 # include "UIMessageCenter.h" 30 31 # include "UIPopupCenter.h" 31 # include "UIKeyboardHandler.h"32 # include "UIMouseHandler.h"33 32 # include "UISession.h" 34 33 # include "UIMachineLogic.h" 35 34 # include "UIMachineWindow.h" 36 35 # include "UIMachineView.h" 36 # include "UIKeyboardHandler.h" 37 # include "UIMouseHandler.h" 37 38 # include "UIFrameBuffer.h" 38 # include "UIExtraDataManager.h" 39 39 # ifdef Q_WS_MAC 40 # include "VBoxUtils-darwin.h" 41 # endif /* Q_WS_MAC */ 40 42 # ifdef Q_WS_WIN 41 43 # include "VBoxUtils-win.h" 42 44 # endif /* Q_WS_WIN */ 43 45 44 # ifdef Q_WS_MAC45 # include "VBoxUtils-darwin.h"46 # endif /* Q_WS_MAC */47 48 46 /* COM includes: */ 49 # include "CConsole.h"50 47 # include "CDisplay.h" 51 48 49 /* Other VBox includes: */ 52 50 # include <iprt/time.h> 53 51 54 52 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 55 53 54 /* Qt includes: */ 56 55 #include <QTouchEvent> 57 56 57 /* COM includes: */ 58 58 #include "CMouse.h" 59 59 60 60 /* External includes: */ 61 61 #ifdef Q_WS_X11 62 # include <X11/XKBlib.h> 63 # ifdef KeyPress 62 # if QT_VERSION < 0x050000 63 # include <X11/Xlib.h> 64 # ifdef FocusOut 64 65 const int XFocusOut = FocusOut; 65 const int XFocusIn = FocusIn; 66 const int XKeyPress = KeyPress; 67 const int XKeyRelease = KeyRelease; 68 # undef KeyRelease 69 # undef KeyPress 70 # undef FocusOut 71 # undef FocusIn 72 # endif /* KeyPress */ 66 # undef FocusOut 67 # endif /* FocusOut */ 68 # endif /* QT_VERSION < 0x050000 */ 73 69 #endif /* Q_WS_X11 */ 74 70 … … 269 265 270 266 #ifdef Q_WS_X11 267 # if QT_VERSION < 0x050000 271 268 bool UIMouseHandler::x11EventFilter(XEvent *pEvent, ulong /* uScreenId */) 272 269 { … … 296 293 return fResult; 297 294 } 295 # endif /* QT_VERSION < 0x050000 */ 298 296 #endif /* Q_WS_X11 */ 299 297 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.h
r55401 r58943 20 20 21 21 /* Qt includes: */ 22 #include <QMap> 22 23 #include <QObject> 23 24 #include <QPoint> 24 #include <Q Map>25 #include <QPointer> 25 26 #include <QRect> 26 #include <QPointer>27 27 28 28 /* GUI includes: */ … … 30 30 31 31 /* Forward declarations: */ 32 class QTouchEvent; 32 33 class QWidget; 33 class QTouchEvent;34 34 class UISession; 35 35 class UIMachineLogic; 36 36 class UIMachineWindow; 37 37 class UIMachineView; 38 #ifdef Q_WS_X1139 typedef union _XEvent XEvent;40 #endif /* Q_WS_X11 */41 38 class CDisplay; 42 39 class CMouse; 40 #ifdef Q_WS_X11 41 # if QT_VERSION < 0x050000 42 typedef union _XEvent XEvent; 43 # endif /* QT_VERSION < 0x050000 */ 44 #endif /* Q_WS_X11 */ 45 43 46 44 47 /* Delegate to control VM mouse functionality: */ … … 73 76 74 77 #ifdef Q_WS_X11 78 # if QT_VERSION < 0x050000 79 /** X11: Qt4: Handles all native events. */ 75 80 bool x11EventFilter(XEvent *pEvent, ulong uScreenId); 81 # endif /* QT_VERSION < 0x050000 */ 76 82 #endif /* Q_WS_X11 */ 77 83
Note:
See TracChangeset
for help on using the changeset viewer.

