[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 |
|
---|
[26637] | 22 | /* Global includes */
|
---|
[30408] | 23 | #include <QObject>
|
---|
| 24 | #include <QPoint>
|
---|
| 25 | #include <QMap>
|
---|
[382] | 26 |
|
---|
[26637] | 27 | /* Local includes */
|
---|
| 28 | #include "UIMachineDefs.h"
|
---|
[6467] | 29 |
|
---|
[30408] | 30 | /* Global forwards */
|
---|
| 31 | class QWidget;
|
---|
[26699] | 32 |
|
---|
[26754] | 33 | /* Local forwards */
|
---|
[30408] | 34 | class CSession;
|
---|
[26815] | 35 | class UISession;
|
---|
[27021] | 36 | class UIMachineLogic;
|
---|
[34471] | 37 | class UIMachineWindow;
|
---|
[30408] | 38 | class UIMachineView;
|
---|
[30637] | 39 | #ifdef Q_WS_X11
|
---|
| 40 | typedef union _XEvent XEvent;
|
---|
| 41 | #endif /* Q_WS_X11 */
|
---|
[26699] | 42 |
|
---|
[30408] | 43 | /* Delegate to control VM mouse functionality: */
|
---|
| 44 | class UIMouseHandler : public QObject
|
---|
[382] | 45 | {
|
---|
[26637] | 46 | Q_OBJECT;
|
---|
[382] | 47 |
|
---|
| 48 | public:
|
---|
| 49 |
|
---|
[30408] | 50 | /* Factory functions to create/destroy mouse-handler: */
|
---|
| 51 | static UIMouseHandler* create(UIMachineLogic *pMachineLogic, UIVisualStateType visualStateType);
|
---|
| 52 | static void destroy(UIMouseHandler *pMouseHandler);
|
---|
[26889] | 53 |
|
---|
[34471] | 54 | /* Prepare/cleanup listener for particular machine-window: */
|
---|
| 55 | void prepareListener(ulong uIndex, UIMachineWindow *pMachineWindow);
|
---|
| 56 | void cleanupListener(ulong uIndex);
|
---|
[382] | 57 |
|
---|
[30408] | 58 | /* Commands to capture/release mouse: */
|
---|
| 59 | void captureMouse(ulong uScreenId);
|
---|
| 60 | void releaseMouse();
|
---|
[26773] | 61 |
|
---|
[30408] | 62 | /* Setter for mouse-integration feature: */
|
---|
| 63 | void setMouseIntegrationEnabled(bool fEnabled);
|
---|
[382] | 64 |
|
---|
[30408] | 65 | /* Current mouse state: */
|
---|
| 66 | int mouseState() const;
|
---|
[26815] | 67 |
|
---|
[30637] | 68 | #ifdef Q_WS_X11
|
---|
| 69 | bool x11EventFilter(XEvent *pEvent, ulong uScreenId);
|
---|
| 70 | #endif /* Q_WS_X11 */
|
---|
| 71 |
|
---|
[26637] | 72 | signals:
|
---|
[382] | 73 |
|
---|
[30408] | 74 | /* Notifies listeners about mouse state-change: */
|
---|
| 75 | void mouseStateChanged(int iNewState);
|
---|
[26730] | 76 |
|
---|
[26773] | 77 | protected slots:
|
---|
| 78 |
|
---|
[30408] | 79 | /* Machine state-change handler: */
|
---|
[26815] | 80 | virtual void sltMachineStateChanged();
|
---|
[30408] | 81 |
|
---|
| 82 | /* Mouse capability-change handler: */
|
---|
[26815] | 83 | virtual void sltMouseCapabilityChanged();
|
---|
[26773] | 84 |
|
---|
[30408] | 85 | /* Mouse pointer-shape-change handler: */
|
---|
| 86 | virtual void sltMousePointerShapeChanged();
|
---|
[26967] | 87 |
|
---|
[30408] | 88 | protected:
|
---|
[28239] | 89 |
|
---|
[30408] | 90 | /* Mouse-handler constructor/destructor: */
|
---|
| 91 | UIMouseHandler(UIMachineLogic *pMachineLogic);
|
---|
| 92 | virtual ~UIMouseHandler();
|
---|
[26637] | 93 |
|
---|
[30408] | 94 | /* Getters: */
|
---|
| 95 | UIMachineLogic* machineLogic() const;
|
---|
| 96 | UISession* uisession() const;
|
---|
| 97 | CSession& session() const;
|
---|
[26754] | 98 |
|
---|
[30408] | 99 | /* Event handler for registered machine-view(s): */
|
---|
| 100 | bool eventFilter(QObject *pWatched, QEvent *pEvent);
|
---|
[382] | 101 |
|
---|
[30408] | 102 | /* Separate function to handle most of existing mouse-events: */
|
---|
| 103 | bool mouseEvent(int iEventType, ulong uScreenId,
|
---|
| 104 | const QPoint &relativePos, const QPoint &globalPos,
|
---|
| 105 | Qt::MouseButtons mouseButtons,
|
---|
| 106 | int wheelDelta, Qt::Orientation wheelDirection);
|
---|
[382] | 107 |
|
---|
[30408] | 108 | #ifdef Q_WS_WIN
|
---|
| 109 | /* This method is actually required only because under win-host
|
---|
| 110 | * we do not really grab the mouse in case of capturing it: */
|
---|
| 111 | void updateMouseCursorClipping();
|
---|
| 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 |
|
---|