[382] | 1 | /** @file
|
---|
| 2 | *
|
---|
| 3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
[30408] | 4 | * UIMouseHandler class declaration
|
---|
[382] | 5 | */
|
---|
| 6 |
|
---|
| 7 | /*
|
---|
[28800] | 8 | * Copyright (C) 2010 Oracle Corporation
|
---|
[382] | 9 | *
|
---|
| 10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
| 11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
| 12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
[5999] | 13 | * General Public License (GPL) as published by the Free Software
|
---|
| 14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
| 15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
| 16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
[382] | 17 | */
|
---|
| 18 |
|
---|
[30408] | 19 | #ifndef ___UIMouseHandler_h___
|
---|
| 20 | #define ___UIMouseHandler_h___
|
---|
[382] | 21 |
|
---|
[41587] | 22 | /* Qt includes: */
|
---|
[30408] | 23 | #include <QObject>
|
---|
| 24 | #include <QPoint>
|
---|
| 25 | #include <QMap>
|
---|
[35906] | 26 | #include <QRect>
|
---|
[382] | 27 |
|
---|
[41587] | 28 | /* GUI includes: */
|
---|
[26637] | 29 | #include "UIMachineDefs.h"
|
---|
[6467] | 30 |
|
---|
[41587] | 31 | /* Forward declarations: */
|
---|
[30408] | 32 | class QWidget;
|
---|
[26815] | 33 | class UISession;
|
---|
[27021] | 34 | class UIMachineLogic;
|
---|
[34471] | 35 | class UIMachineWindow;
|
---|
[30408] | 36 | class UIMachineView;
|
---|
[30637] | 37 | #ifdef Q_WS_X11
|
---|
| 38 | typedef union _XEvent XEvent;
|
---|
| 39 | #endif /* Q_WS_X11 */
|
---|
[41587] | 40 | class CSession;
|
---|
[26699] | 41 |
|
---|
[30408] | 42 | /* Delegate to control VM mouse functionality: */
|
---|
| 43 | class UIMouseHandler : public QObject
|
---|
[382] | 44 | {
|
---|
[26637] | 45 | Q_OBJECT;
|
---|
[382] | 46 |
|
---|
| 47 | public:
|
---|
| 48 |
|
---|
[30408] | 49 | /* Factory functions to create/destroy mouse-handler: */
|
---|
| 50 | static UIMouseHandler* create(UIMachineLogic *pMachineLogic, UIVisualStateType visualStateType);
|
---|
| 51 | static void destroy(UIMouseHandler *pMouseHandler);
|
---|
[26889] | 52 |
|
---|
[34471] | 53 | /* Prepare/cleanup listener for particular machine-window: */
|
---|
| 54 | void prepareListener(ulong uIndex, UIMachineWindow *pMachineWindow);
|
---|
| 55 | void cleanupListener(ulong uIndex);
|
---|
[382] | 56 |
|
---|
[30408] | 57 | /* Commands to capture/release mouse: */
|
---|
| 58 | void captureMouse(ulong uScreenId);
|
---|
| 59 | void releaseMouse();
|
---|
[26773] | 60 |
|
---|
[30408] | 61 | /* Setter for mouse-integration feature: */
|
---|
| 62 | void setMouseIntegrationEnabled(bool fEnabled);
|
---|
[382] | 63 |
|
---|
[30408] | 64 | /* Current mouse state: */
|
---|
| 65 | int mouseState() const;
|
---|
[26815] | 66 |
|
---|
[30637] | 67 | #ifdef Q_WS_X11
|
---|
| 68 | bool x11EventFilter(XEvent *pEvent, ulong uScreenId);
|
---|
| 69 | #endif /* Q_WS_X11 */
|
---|
| 70 |
|
---|
[26637] | 71 | signals:
|
---|
[382] | 72 |
|
---|
[30408] | 73 | /* Notifies listeners about mouse state-change: */
|
---|
| 74 | void mouseStateChanged(int iNewState);
|
---|
[26730] | 75 |
|
---|
[26773] | 76 | protected slots:
|
---|
| 77 |
|
---|
[30408] | 78 | /* Machine state-change handler: */
|
---|
[26815] | 79 | virtual void sltMachineStateChanged();
|
---|
[30408] | 80 |
|
---|
| 81 | /* Mouse capability-change handler: */
|
---|
[26815] | 82 | virtual void sltMouseCapabilityChanged();
|
---|
[26773] | 83 |
|
---|
[30408] | 84 | /* Mouse pointer-shape-change handler: */
|
---|
| 85 | virtual void sltMousePointerShapeChanged();
|
---|
[26967] | 86 |
|
---|
[30408] | 87 | protected:
|
---|
[28239] | 88 |
|
---|
[30408] | 89 | /* Mouse-handler constructor/destructor: */
|
---|
| 90 | UIMouseHandler(UIMachineLogic *pMachineLogic);
|
---|
| 91 | virtual ~UIMouseHandler();
|
---|
[26637] | 92 |
|
---|
[30408] | 93 | /* Getters: */
|
---|
| 94 | UIMachineLogic* machineLogic() const;
|
---|
| 95 | UISession* uisession() const;
|
---|
| 96 | CSession& session() const;
|
---|
[26754] | 97 |
|
---|
[30408] | 98 | /* Event handler for registered machine-view(s): */
|
---|
| 99 | bool eventFilter(QObject *pWatched, QEvent *pEvent);
|
---|
[382] | 100 |
|
---|
[30408] | 101 | /* Separate function to handle most of existing mouse-events: */
|
---|
| 102 | bool mouseEvent(int iEventType, ulong uScreenId,
|
---|
| 103 | const QPoint &relativePos, const QPoint &globalPos,
|
---|
| 104 | Qt::MouseButtons mouseButtons,
|
---|
| 105 | int wheelDelta, Qt::Orientation wheelDirection);
|
---|
[382] | 106 |
|
---|
[30408] | 107 | #ifdef Q_WS_WIN
|
---|
| 108 | /* This method is actually required only because under win-host
|
---|
| 109 | * we do not really grab the mouse in case of capturing it: */
|
---|
| 110 | void updateMouseCursorClipping();
|
---|
[35906] | 111 | QRect m_mouseCursorClippingRect;
|
---|
[30408] | 112 | #endif /* Q_WS_WIN */
|
---|
[382] | 113 |
|
---|
[30408] | 114 | /* Machine logic parent: */
|
---|
| 115 | UIMachineLogic *m_pMachineLogic;
|
---|
[382] | 116 |
|
---|
[34471] | 117 | /* Registered machine-windows(s): */
|
---|
| 118 | QMap<ulong, QWidget*> m_windows;
|
---|
[30408] | 119 | /* Registered machine-view(s): */
|
---|
| 120 | QMap<ulong, UIMachineView*> m_views;
|
---|
| 121 | /* Registered machine-view-viewport(s): */
|
---|
| 122 | QMap<ulong, QWidget*> m_viewports;
|
---|
[27012] | 123 |
|
---|
[30408] | 124 | /* Other mouse variables: */
|
---|
[26754] | 125 | QPoint m_lastMousePos;
|
---|
| 126 | QPoint m_capturedMousePos;
|
---|
[25304] | 127 | int m_iLastMouseWheelDelta;
|
---|
[30408] | 128 | int m_iMouseCaptureViewIndex;
|
---|
[382] | 129 | };
|
---|
| 130 |
|
---|
[30408] | 131 | #endif // !___UIMouseHandler_h___
|
---|
[27124] | 132 |
|
---|