VirtualBox

Changeset 59344 in vbox


Ignore:
Timestamp:
Jan 14, 2016 12:25:30 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: Qt5 migration (part 51): Too early for personal x11 stuff for keyboard handling, no common decision yet.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r59079 r59344  
    9797#endif /* Q_WS_MAC */
    9898#ifdef Q_WS_X11
    99 # if QT_VERSION >= 0x050000
    100 #  include <xcb/xcb.h>
    101 # else /* QT_VERSION < 0x050000 */
     99# if QT_VERSION < 0x050000
    102100#  include <X11/XKBlib.h>
    103101#  ifdef KeyPress
     
    111109#   undef FocusIn
    112110#  endif /* KeyPress */
    113 # endif /* QT_VERSION < 0x050000 */
     111# else /* QT_VERSION >= 0x050000 */
     112#  include <xcb/xcb.h>
     113# endif /* QT_VERSION >= 0x050000 */
    114114#endif /* Q_WS_X11 */
    115115
     
    122122#endif
    123123
    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 *********************************************************************************************************************************/
    168124
    169125/* static */
     
    668624{
    669625    /* Prepare viewport: */
    670 #ifdef Q_WS_X11
    671 # if QT_VERSION >= 0x050000
    672     setViewport(new UIViewport(this));
    673 # endif /* QT_VERSION >= 0x050000 */
    674 #endif /* Q_WS_X11 */
    675626    AssertPtrReturnVoid(viewport());
    676627    {
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r59342 r59344  
    5858class CSession;
    5959#ifdef Q_WS_X11
    60 # if QT_VERSION >= 0x050000
    61 class UIMachineView;
    62 # else /* QT_VERSION < 0x050000 */
     60# if QT_VERSION < 0x050000
    6361typedef union _XEvent XEvent;
    6462# endif /* QT_VERSION < 0x050000 */
     
    6866#endif /* VBOX_WITH_DRAG_AND_DROP */
    6967
    70 
    71 #ifdef Q_WS_X11
    72 # if QT_VERSION >= 0x050000
    73 /** X11: Qt5: QWidget extension used as UIMachineView's viewport.
    74   * This class is currently required because of Qt5 policy change about
    75   * native keyboard events now being delivered directly to a focus-holder
    76   * (UIMachineView's viewport) instead of delivering it to top-most widget
    77   * (UIMachineWindow) and then propagating down to the focus-holder, which
    78   * with Qt4 allowed us to handle such events in focus-holder's focus-proxy
    79   * (UIMachineView) instead of focus-holder itself. */
    80 class UIViewport : public QWidget
    81 {
    82     Q_OBJECT;
    83 
    84 public:
    85 
    86     /** Constructor which brings the @a pParent machine-view. */
    87     UIViewport(UIMachineView *pParent);
    88 
    89     /** Returns the reference to the parent machine-view. */
    90     const UIMachineView* machineView() { return m_pMachineView; }
    91 
    92 protected:
    93 
    94     /** Qt5: Handles any native @a pMessage of the predefined @a eventType,
    95       * allowing to set the @a pResult to be returned to the issuer. */
    96     virtual bool nativeEvent(const QByteArray &eventType, void *pMessage, long *pResult);
    97 
    98 private:
    99 
    100     /** Holds the reference to the parent machine-view. */
    101     const UIMachineView *m_pMachineView;
    102 };
    103 # endif /* QT_VERSION >= 0x050000 */
    104 #endif /* Q_WS_X11 */
    10568
    10669class UIMachineView : public QAbstractScrollArea
     
    453416    friend class UIFrameBufferPrivate;
    454417    friend class VBoxOverlayFrameBuffer;
    455 #ifdef Q_WS_X11
    456 # if QT_VERSION >= 0x050000
    457     friend class UIViewport;
    458 # endif /* QT_VERSION >= 0x050000 */
    459 #endif /* Q_WS_X11 */
    460418};
    461419
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