VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.h@ 47478

Last change on this file since 47478 was 47478, checked in by vboxsync, 12 years ago

FE/Qt: Runtime UI: Adding extra-data flag 'GUI/RestrictedVisualStates' to restrict unwanted visual-representation states.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * UIMouseHandler class declaration
5 */
6
7/*
8 * Copyright (C) 2010-2012 Oracle Corporation
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
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.
17 */
18
19#ifndef ___UIMouseHandler_h___
20#define ___UIMouseHandler_h___
21
22/* Qt includes: */
23#include <QObject>
24#include <QPoint>
25#include <QMap>
26#include <QRect>
27
28/* GUI includes: */
29#include "UIDefs.h"
30
31/* Forward declarations: */
32class QWidget;
33class QTouchEvent;
34class UISession;
35class UIMachineLogic;
36class UIMachineWindow;
37class UIMachineView;
38#ifdef Q_WS_X11
39typedef union _XEvent XEvent;
40#endif /* Q_WS_X11 */
41class CSession;
42
43/* Delegate to control VM mouse functionality: */
44class UIMouseHandler : public QObject
45{
46 Q_OBJECT;
47
48public:
49
50 /* Factory functions to create/destroy mouse-handler: */
51 static UIMouseHandler* create(UIMachineLogic *pMachineLogic, UIVisualStateType visualStateType);
52 static void destroy(UIMouseHandler *pMouseHandler);
53
54 /* Prepare/cleanup listener for particular machine-window: */
55 void prepareListener(ulong uIndex, UIMachineWindow *pMachineWindow);
56 void cleanupListener(ulong uIndex);
57
58 /* Commands to capture/release mouse: */
59 void captureMouse(ulong uScreenId);
60 void releaseMouse();
61
62 /* Setter for mouse-integration feature: */
63 void setMouseIntegrationEnabled(bool fEnabled);
64
65 /* Current mouse state: */
66 int mouseState() const;
67
68#ifdef Q_WS_X11
69 bool x11EventFilter(XEvent *pEvent, ulong uScreenId);
70#endif /* Q_WS_X11 */
71
72signals:
73
74 /* Notifies listeners about mouse state-change: */
75 void mouseStateChanged(int iNewState);
76
77protected slots:
78
79 /* Machine state-change handler: */
80 virtual void sltMachineStateChanged();
81
82 /* Mouse capability-change handler: */
83 virtual void sltMouseCapabilityChanged();
84
85 /* Mouse pointer-shape-change handler: */
86 virtual void sltMousePointerShapeChanged();
87
88protected:
89
90 /* Mouse-handler constructor/destructor: */
91 UIMouseHandler(UIMachineLogic *pMachineLogic);
92 virtual ~UIMouseHandler();
93
94 /* Getters: */
95 UIMachineLogic* machineLogic() const;
96 UISession* uisession() const;
97 CSession& session() const;
98
99 /* Event handler for registered machine-view(s): */
100 bool eventFilter(QObject *pWatched, QEvent *pEvent);
101
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);
107
108 /* Separate function to handle incoming multi-touch events: */
109 bool multiTouchEvent(QTouchEvent *pTouchEvent, ulong uScreenId);
110
111#ifdef Q_WS_WIN
112 /* This method is actually required only because under win-host
113 * we do not really grab the mouse in case of capturing it: */
114 void updateMouseCursorClipping();
115 QRect m_mouseCursorClippingRect;
116#endif /* Q_WS_WIN */
117
118 /* Machine logic parent: */
119 UIMachineLogic *m_pMachineLogic;
120
121 /* Registered machine-windows(s): */
122 QMap<ulong, QWidget*> m_windows;
123 /* Registered machine-view(s): */
124 QMap<ulong, UIMachineView*> m_views;
125 /* Registered machine-view-viewport(s): */
126 QMap<ulong, QWidget*> m_viewports;
127
128 /* Other mouse variables: */
129 QPoint m_lastMousePos;
130 QPoint m_capturedMousePos;
131 int m_iLastMouseWheelDelta;
132 int m_iMouseCaptureViewIndex;
133};
134
135#endif // !___UIMouseHandler_h___
136
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette