VirtualBox

Changeset 58943 in vbox


Ignore:
Timestamp:
Dec 1, 2015 4:25:06 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: Qt5 migration (part 25): Adjusting X11 native stuff to Qt5: Now the most dangerous part, VM keyboard stuff.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/x11/XKeyboard-new.cpp

    r52730 r58943  
    1616 */
    1717
     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: */
    1824#define LOG_GROUP LOG_GROUP_GUI
    1925
    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: */
    2242#include <X11/XKBlib.h>
    23 #include <X11/Xlib.h>
    2443#include <X11/keysym.h>
    25 #include <XKeyboard.h>
    26 #include <VBox/log.h>
    27 #include <VBox/VBoxKeyboard.h>
    2844
    2945
     
    232248 * Translate an X server scancode to a PC keyboard scancode.
    233249 */
    234 unsigned handleXKeyEvent(XEvent *event)
     250unsigned handleXKeyEvent(Display *pDisplay, unsigned int iDetail)
    235251{
    236252    // call the WINE event handler
    237     unsigned key = X11DRV_KeyEvent(event->xkey.display, event->xkey.keycode);
     253    unsigned key = X11DRV_KeyEvent(pDisplay, iDetail);
    238254    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));
    240256    return key;
    241257}
     
    248264 * keycode is pressed.
    249265 */
    250 void initMappedX11Keyboard(Display *pDisplay, QString remapScancodes)
     266void initMappedX11Keyboard(Display *pDisplay, const QString &remapScancodes)
    251267{
    252268    int (*scancodes)[2] = NULL;
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/x11/XKeyboard.h

    r55401 r58943  
    1919#define __XKeyboard_h__
    2020
    21 #include <QString>
     21/* Forward declarations: */
     22class QString;
     23typedef struct _XDisplay Display;
     24
    2225
    2326// initialize the X keyboard subsystem
    24 void initMappedX11Keyboard(Display *pDisplay, QString remapScancodes);
     27void initMappedX11Keyboard(Display *pDisplay, const QString &remapScancodes);
    2528// our custom keyboard handler
    26 unsigned handleXKeyEvent(XEvent *event);
     29unsigned handleXKeyEvent(Display *pDisplay, unsigned int iDetail);
    2730// Called after release logging is started, in case initXKeyboard wishes to log
    2831// anything
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp

    r55724 r58943  
    2828/* GUI includes: */
    2929# include "VBoxGlobal.h"
     30# include "UIExtraDataManager.h"
    3031# include "UIMessageCenter.h"
    3132# include "UIPopupCenter.h"
    3233# include "UIActionPool.h"
     34# include "UISession.h"
     35# include "UIMachineLogic.h"
     36# include "UIMachineWindow.h"
     37# include "UIMachineView.h"
     38# include "UIHostComboEditor.h"
    3339# include "UIKeyboardHandlerNormal.h"
    3440# include "UIKeyboardHandlerFullscreen.h"
     
    3642# include "UIKeyboardHandlerScale.h"
    3743# 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 */
    4448
    4549/* COM includes: */
    46 # include "CConsole.h"
     50# include "CKeyboard.h"
    4751
    4852#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    4953
    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 */
    5169#ifdef Q_WS_X11
    5270# include <X11/XKBlib.h>
    5371# include <X11/keysym.h>
    5472# ifdef KeyPress
     73const int XFocusIn = FocusIn;
    5574const int XFocusOut = FocusOut;
    56 const int XFocusIn = FocusIn;
    5775const int XKeyPress = KeyPress;
    5876const int XKeyRelease = KeyRelease;
     
    6280#  undef FocusIn
    6381# endif /* KeyPress */
    64 # include "XKeyboard.h"
     82# if QT_VERSION >= 0x050000
     83#  include <xcb/xcb.h>
     84# endif /* QT_VERSION >= 0x050000 */
    6585#endif /* Q_WS_X11 */
    66 
    67 #ifdef Q_WS_MAC
    68 # 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_WIN
    75 # include "WinKeyboard.h"
    76 #endif /* Q_WS_WIN */
    7786
    7887/* Enums representing different keyboard-states: */
    7988enum { KeyExtended = 0x01, KeyPressed = 0x02, KeyPause = 0x04, KeyPrint = 0x08 };
    8089enum { IsKeyPressed = 0x01, IsExtKeyPressed = 0x02, IsKbdCaptured = 0x80 };
     90
    8191
    8292#ifdef Q_WS_WIN
     
    172182
    173183#ifdef Q_WS_X11
     184# if QT_VERSION < 0x050000
    174185struct CHECKFORX11FOCUSEVENTSDATA
    175186{
     
    203214    return data.fEventFound;
    204215}
     216# endif /* QT_VERSION < 0x050000 */
    205217#endif /* Q_WS_X11 */
    206218
     
    234246            case UIVisualStateType_Scale:
    235247            {
     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 */
    236251                XGrabKey(QX11Info::display(), AnyKey, AnyModifier, m_windows[m_iKeyboardCaptureViewIndex]->winId(), False, GrabModeAsync, GrabModeAsync);
     252# endif /* QT_VERSION < 0x050000 */
    237253                break;
    238254            }
     
    241257            case UIVisualStateType_Seamless:
    242258            {
     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 */
    243262                /* Keyboard grabbing can fail because of some keyboard shortcut is still grabbed by window manager.
    244263                 * We can't be sure this shortcut will be released at all, so we will retry to grab keyboard for 50 times,
     
    256275                           CurrentTime))
    257276                        --cTriesLeft;
     277# endif /* QT_VERSION < 0x050000 */
    258278                break;
    259279            }
     
    302322            case UIVisualStateType_Scale:
    303323            {
     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 */
    304327                XUngrabKey(QX11Info::display(), AnyKey, AnyModifier, m_windows[m_iKeyboardCaptureViewIndex]->winId());
     328# endif /* QT_VERSION < 0x050000 */
    305329                break;
    306330            }
     
    309333            case UIVisualStateType_Seamless:
    310334            {
     335# if QT_VERSION >= 0x050000
     336                xcb_ungrab_keyboard(QX11Info::connection(), CurrentTime);
     337# else /* QT_VERSION < 0x050000 */
    311338                XUngrabKeyboard(QX11Info::display(), CurrentTime);
     339# endif /* QT_VERSION < 0x050000 */
    312340                break;
    313341            }
     
    568596
    569597#elif defined(Q_WS_X11)
     598# if QT_VERSION >= 0x050000
     599
     600bool 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 */
    570695
    571696static Bool UIKeyboardHandlerCompEvent(Display*, XEvent *pEvent, XPointer pvArg)
     
    621746        {
    622747            /* Translate the keycode to a PC scan code. */
    623             unsigned scan = handleXKeyEvent(pEvent);
     748            unsigned scan = handleXKeyEvent(pEvent->xkey.display, pEvent->xkey.keycode);
    624749
    625750            /* Scancodes 0x00 (no valid translation) and 0x80 are ignored: */
     
    691816}
    692817
    693 #endif
     818# endif /* QT_VERSION < 0x050000 */
     819#endif /* Q_WS_X11 */
    694820
    695821/* Machine state-change handler: */
     
    14181544}
    14191545
    1420 void UIKeyboardHandler::keyEventReleaseHostComboKeys(CKeyboard keyboard)
    1421 {
     1546void UIKeyboardHandler::keyEventReleaseHostComboKeys(const CKeyboard &constKeyboard)
     1547{
     1548    /* Get keyboard: */
     1549    CKeyboard keyboard(constKeyboard);
    14221550    /* We have to make guest to release pressed keys from the host-combination: */
    14231551    QList<uint8_t> hostComboScans = m_pressedHostComboKeys.values();
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.h

    r55401 r58943  
    2020
    2121/* Qt includes: */
     22#include <QMap>
    2223#include <QObject>
    23 #include <QMap>
    2424
    2525/* GUI includes: */
    2626#include "UIExtraDataDefs.h"
     27
     28/* Other VBox includes: */
     29#include <VBox/com/defs.h>
     30
     31/* External includes: */
    2732#ifdef Q_WS_MAC
     33# include <Carbon/Carbon.h>
    2834# include <CoreFoundation/CFBase.h>
    29 # include <Carbon/Carbon.h>
    3035#endif /* Q_WS_MAC */
    31 
    32 /* COM includes: */
    33 #include "COMEnums.h"
    34 #include "CKeyboard.h"
    3536
    3637/* Forward declarations: */
    3738class QWidget;
     39class VBoxGlobalSettings;
     40class UIActionPool;
    3841class UISession;
    39 class UIActionPool;
    4042class UIMachineLogic;
    4143class UIMachineWindow;
    4244class UIMachineView;
    43 class VBoxGlobalSettings;
     45class CKeyboard;
    4446#if defined(Q_WS_WIN)
    4547class WinAltGrMonitor;
    4648#elif defined(Q_WS_X11)
    47 typedef union  _XEvent XEvent;
     49# if QT_VERSION < 0x050000
     50typedef union _XEvent XEvent;
     51# endif /* QT_VERSION < 0x050000 */
    4852#endif /* Q_WS_X11 */
    49 class CKeyboard;
     53
    5054
    5155/* Delegate to control VM keyboard functionality: */
     
    7175    /* Commands to capture/release keyboard: */
    7276#ifdef Q_WS_X11
     77# if QT_VERSION < 0x050000
    7378    bool checkForX11FocusEvents(unsigned long hWindow);
    74 #endif
     79# endif /* QT_VERSION < 0x050000 */
     80#endif /* Q_WS_X11 */
    7581    void captureKeyboard(ulong uScreenId);
    7682    void releaseKeyboard();
     
    99105    WinAltGrMonitor *m_pAltGrMonitor;
    100106#elif defined(Q_WS_X11)
     107# if QT_VERSION >= 0x050000
     108    bool nativeEventFilter(void *pMessage, ulong uScreenId);
     109# else /* QT_VERSION < 0x050000 */
    101110    bool x11EventFilter(XEvent *pEvent, ulong uScreenId);
    102 #endif
     111# endif /* QT_VERSION < 0x050000 */
     112#endif /* Q_WS_X11 */
    103113
    104114protected slots:
     
    144154    bool keyEventHostComboHandled(int iKey, wchar_t *pUniKey, bool isHostComboStateChanged, bool *pfResult);
    145155    void keyEventHandleHostComboRelease(ulong uScreenId);
    146     void keyEventReleaseHostComboKeys(CKeyboard keyboard);
     156    void keyEventReleaseHostComboKeys(const CKeyboard &keyboard);
    147157    /* Separate function to handle most of existing keyboard-events: */
    148158    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  
    2323# include <QDesktopWidget>
    2424# include <QMainWindow>
    25 # include <QTimer>
    2625# include <QPainter>
    2726# include <QScrollBar>
    28 # include <QMainWindow>
     27# include <QTimer>
    2928
    3029/* GUI includes: */
    3130# include "VBoxGlobal.h"
     31# include "UIExtraDataManager.h"
    3232# include "UIMessageCenter.h"
    33 # include "UIFrameBuffer.h"
    34 # include "VBoxFBOverlay.h"
    3533# include "UISession.h"
    36 # include "UIKeyboardHandler.h"
    37 # include "UIMouseHandler.h"
    3834# include "UIMachineLogic.h"
    3935# include "UIMachineWindow.h"
     
    4238# include "UIMachineViewSeamless.h"
    4339# 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 */
    4547# ifdef VBOX_WITH_DRAG_AND_DROP
    4648#  include "UIDnDHandler.h"
     
    4850
    4951/* VirtualBox interface declarations: */
    50 #ifndef VBOX_WITH_XPCOM
    51 # 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 */
    5557
    5658/* COM includes: */
    57 # include "CSession.h"
    5859# include "CConsole.h"
    5960# include "CDisplay.h"
    60 # include "CFramebuffer.h"
     61# include "CSession.h"
    6162# ifdef VBOX_WITH_DRAG_AND_DROP
    6263#  include "CDnDSource.h"
    6364#  include "CDnDTarget.h"
    6465#  include "CGuest.h"
    65 #  include "CGuestDnDSource.h"
    66 #  include "CGuestDnDTarget.h"
    6766# endif /* VBOX_WITH_DRAG_AND_DROP */
    6867
     68/* Other VBox includes: */
     69# include <iprt/asm.h>
     70
    6971#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    7072
     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
    7186/* Other VBox includes: */
    72 #include <iprt/asm.h>
    7387#include <VBox/VBoxOGL.h>
    7488#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 */
    7698#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
     104const int XFocusIn = FocusIn;
    80105const int XFocusOut = FocusOut;
    81 const int XFocusIn = FocusIn;
    82106const int XKeyPress = KeyPress;
    83107const 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 */
    89114#endif /* Q_WS_X11 */
    90 
    91 #ifdef Q_WS_MAC
    92 # 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 
    102115
    103116#ifdef DEBUG_andy
     
    109122#endif
    110123
     124
     125#ifdef Q_WS_X11
     126# if QT_VERSION >= 0x050000
     127/*********************************************************************************************************************************
     128*   Class UIViewport implementation.                                                                                             *
     129*********************************************************************************************************************************/
     130
     131UIViewport::UIViewport(UIMachineView *pParent)
     132    : QWidget(pParent)
     133    , m_pMachineView(pParent)
     134{
     135}
     136
     137bool 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*********************************************************************************************************************************/
    111168
    112169/* static */
     
    591648{
    592649    /* 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 */
    593655    AssertPtrReturnVoid(viewport());
    594656    {
     
    16951757#elif defined(Q_WS_X11)
    16961758
     1759# if QT_VERSION < 0x050000
    16971760bool UIMachineView::x11Event(XEvent *pEvent)
    16981761{
     
    17051768    switch (pEvent->type)
    17061769    {
     1770        case XFocusIn:
    17071771        case XFocusOut:
    1708         case XFocusIn:
    17091772        case XKeyPress:
    17101773        case XKeyRelease:
     
    17261789    return fResult;
    17271790}
     1791# endif /* QT_VERSION < 0x050000 */
    17281792
    17291793#endif /* Q_WS_X11 */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r58011 r58943  
    2424
    2525/* GUI includes: */
     26#include "UIExtraDataDefs.h"
     27#include "UIMachineDefs.h"
    2628#ifdef VBOX_WITH_DRAG_AND_DROP
    2729# 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: */
    3139#ifdef Q_WS_MAC
    3240# include <CoreFoundation/CFBase.h>
    3341#endif /* Q_WS_MAC */
    3442
    35 /* COM includes: */
    36 #include "COMEnums.h"
    37 
    38 /* Other VBox includes: */
    39 #include "VBox/com/ptr.h"
    40 
    4143/* Forward declarations: */
     44class UIActionPool;
    4245class UISession;
    43 class UIActionPool;
    4446class UIMachineLogic;
    4547class UIMachineWindow;
    4648class UIFrameBuffer;
    47 #ifdef VBOX_WITH_DRAG_AND_DROP
    48  class CDnDTarget;
    49 #endif
    50 class CSession;
    51 class CMachine;
    5249class CConsole;
    5350class CDisplay;
    5451class CGuest;
     52class CMachine;
     53class CSession;
     54#ifdef Q_WS_X11
     55# if QT_VERSION >= 0x050000
     56class UIMachineView;
     57# else /* QT_VERSION < 0x050000 */
     58typedef 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. */
     75class UIViewport : public QWidget
     76{
     77    Q_OBJECT;
     78
     79public:
     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
     87protected:
     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
     93private:
     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 */
    55100
    56101class UIMachineView : public QAbstractScrollArea
     
    335380    bool winEvent(MSG *pMsg, long *puResult);
    336381#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 */
    339387
    340388    /** Scales passed size forward. */
     
    400448    friend class UIFrameBufferPrivate;
    401449    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 */
    402455};
    403456
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r58866 r58943  
    2222/* Qt includes: */
    2323# include <QCloseEvent>
     24# include <QProcess>
    2425# include <QTimer>
    25 # include <QProcess>
    2626
    2727/* GUI includes: */
    2828# include "VBoxGlobal.h"
     29# include "UIConverter.h"
     30# include "UIModalWindowManager.h"
     31# include "UIExtraDataManager.h"
    2932# include "UIMessageCenter.h"
    30 # include "UIKeyboardHandler.h"
     33# include "UISession.h"
     34# include "UIMachineLogic.h"
    3135# include "UIMachineWindow.h"
    32 # include "UIMachineLogic.h"
    33 # include "UIMachineView.h"
    3436# include "UIMachineWindowNormal.h"
    3537# include "UIMachineWindowFullscreen.h"
    3638# include "UIMachineWindowSeamless.h"
    3739# include "UIMachineWindowScale.h"
     40# include "UIMachineView.h"
     41# include "UIKeyboardHandler.h"
    3842# include "UIMouseHandler.h"
    39 # include "UISession.h"
    4043# include "UIVMCloseDialog.h"
    41 # include "UIConverter.h"
    42 # include "UIModalWindowManager.h"
    43 # include "UIExtraDataManager.h"
    4444
    4545/* COM includes: */
     
    5757/* External includes: */
    5858#ifdef Q_WS_X11
    59 # include <X11/Xlib.h>
     59# if QT_VERSION < 0x050000
     60#  include <X11/Xlib.h>
     61# endif /* QT_VERSION < 0x050000 */
    6062#endif /* Q_WS_X11 */
     63
    6164
    6265/* static */
     
    259262
    260263#ifdef Q_WS_X11
     264# if QT_VERSION < 0x050000
    261265bool UIMachineWindow::x11Event(XEvent *pEvent)
    262266{
     
    279283    return false;
    280284}
     285# endif /* QT_VERSION < 0x050000 */
    281286#endif /* Q_WS_X11 */
    282287
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.h

    r58142 r58943  
    3434
    3535/* Forward declarations: */
     36class QCloseEvent;
    3637class QGridLayout;
    3738class QSpacerItem;
    38 class QCloseEvent;
    39 class CSession;
     39class UIActionPool;
    4040class UISession;
    4141class UIMachineLogic;
    4242class UIMachineView;
    43 class UIActionPool;
     43class CSession;
     44#ifdef Q_WS_X11
     45# if QT_VERSION < 0x050000
     46typedef union _XEvent XEvent;
     47# endif /* QT_VERSION < 0x050000 */
     48#endif /* Q_WS_X11 */
     49
    4450
    4551/* Machine-window interface: */
     
    117123    /* Event handlers: */
    118124#ifdef Q_WS_X11
    119     /** X11: Native event handler. */
     125# if QT_VERSION < 0x050000
     126    /** X11: Qt4: Handles all native events. */
    120127    bool x11Event(XEvent *pEvent);
     128# endif /* QT_VERSION < 0x050000 */
    121129#endif /* Q_WS_X11 */
    122130
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp

    r57592 r58943  
    2727/* GUI includes: */
    2828# include "VBoxGlobal.h"
     29# include "UIExtraDataManager.h"
    2930# include "UIMessageCenter.h"
    3031# include "UIPopupCenter.h"
    31 # include "UIKeyboardHandler.h"
    32 # include "UIMouseHandler.h"
    3332# include "UISession.h"
    3433# include "UIMachineLogic.h"
    3534# include "UIMachineWindow.h"
    3635# include "UIMachineView.h"
     36# include "UIKeyboardHandler.h"
     37# include "UIMouseHandler.h"
    3738# include "UIFrameBuffer.h"
    38 # include "UIExtraDataManager.h"
    39 
     39# ifdef Q_WS_MAC
     40#  include "VBoxUtils-darwin.h"
     41# endif /* Q_WS_MAC */
    4042# ifdef Q_WS_WIN
    4143#  include "VBoxUtils-win.h"
    4244# endif /* Q_WS_WIN */
    4345
    44 # ifdef Q_WS_MAC
    45 #  include "VBoxUtils-darwin.h"
    46 # endif /* Q_WS_MAC */
    47 
    4846/* COM includes: */
    49 # include "CConsole.h"
    5047# include "CDisplay.h"
    5148
     49/* Other VBox includes: */
    5250# include <iprt/time.h>
    5351
    5452#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    5553
     54/* Qt includes: */
    5655#include <QTouchEvent>
    5756
     57/* COM includes: */
    5858#include "CMouse.h"
    5959
    60 
     60/* External includes: */
    6161#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
    6465const 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 */
    7369#endif /* Q_WS_X11 */
    7470
     
    269265
    270266#ifdef Q_WS_X11
     267# if QT_VERSION < 0x050000
    271268bool UIMouseHandler::x11EventFilter(XEvent *pEvent, ulong /* uScreenId */)
    272269{
     
    296293    return fResult;
    297294}
     295# endif /* QT_VERSION < 0x050000 */
    298296#endif /* Q_WS_X11 */
    299297
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.h

    r55401 r58943  
    2020
    2121/* Qt includes: */
     22#include <QMap>
    2223#include <QObject>
    2324#include <QPoint>
    24 #include <QMap>
     25#include <QPointer>
    2526#include <QRect>
    26 #include <QPointer>
    2727
    2828/* GUI includes: */
     
    3030
    3131/* Forward declarations: */
     32class QTouchEvent;
    3233class QWidget;
    33 class QTouchEvent;
    3434class UISession;
    3535class UIMachineLogic;
    3636class UIMachineWindow;
    3737class UIMachineView;
    38 #ifdef Q_WS_X11
    39 typedef union  _XEvent XEvent;
    40 #endif /* Q_WS_X11 */
    4138class CDisplay;
    4239class CMouse;
     40#ifdef Q_WS_X11
     41# if QT_VERSION < 0x050000
     42typedef union _XEvent XEvent;
     43# endif /* QT_VERSION < 0x050000 */
     44#endif /* Q_WS_X11 */
     45
    4346
    4447/* Delegate to control VM mouse functionality: */
     
    7376
    7477#ifdef Q_WS_X11
     78# if QT_VERSION < 0x050000
     79    /** X11: Qt4: Handles all native events. */
    7580    bool x11EventFilter(XEvent *pEvent, ulong uScreenId);
     81# endif /* QT_VERSION < 0x050000 */
    7682#endif /* Q_WS_X11 */
    7783
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