VirtualBox

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

Last change on this file since 75938 was 75938, checked in by vboxsync, 6 years ago

FE/Qt: bugref:9309: Windows host: Filter out rare duplicated mouse events on the border of endless movement triggers.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1/* $Id: UIMouseHandler.h 75938 2018-12-04 08:42:19Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIMouseHandler class declaration.
4 */
5
6/*
7 * Copyright (C) 2010-2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ___UIMouseHandler_h___
19#define ___UIMouseHandler_h___
20
21/* Qt includes: */
22#include <QMap>
23#include <QObject>
24#include <QPoint>
25#include <QPointer>
26#include <QRect>
27
28/* GUI includes: */
29#include "UIExtraDataDefs.h"
30
31/* Forward declarations: */
32class QTouchEvent;
33class QWidget;
34class UISession;
35class UIMachineLogic;
36class UIMachineWindow;
37class UIMachineView;
38class CDisplay;
39class CMouse;
40
41
42/* Delegate to control VM mouse functionality: */
43class UIMouseHandler : public QObject
44{
45 Q_OBJECT;
46
47signals:
48
49 /** Notifies listeners about state-change. */
50 void sigStateChange(int iState);
51
52public:
53
54 /* Factory functions to create/destroy mouse-handler: */
55 static UIMouseHandler* create(UIMachineLogic *pMachineLogic, UIVisualStateType visualStateType);
56 static void destroy(UIMouseHandler *pMouseHandler);
57
58 /* Prepare/cleanup listener for particular machine-window: */
59 void prepareListener(ulong uIndex, UIMachineWindow *pMachineWindow);
60 void cleanupListener(ulong uIndex);
61
62 /* Commands to capture/release mouse: */
63 void captureMouse(ulong uScreenId);
64 void releaseMouse();
65
66 /* Setter for mouse-integration feature: */
67 void setMouseIntegrationEnabled(bool fEnabled);
68
69 /* Current mouse state: */
70 int state() const;
71
72 /** Qt5: Performs pre-processing of all the native events. */
73 bool nativeEventFilter(void *pMessage, ulong uScreenId);
74
75protected slots:
76
77 /* Machine state-change handler: */
78 virtual void sltMachineStateChanged();
79
80 /* Mouse capability-change handler: */
81 virtual void sltMouseCapabilityChanged();
82
83 /* Mouse pointer-shape-change handler: */
84 virtual void sltMousePointerShapeChanged();
85
86 /** Activate hovered window if any. */
87 void sltMaybeActivateHoveredWindow();
88
89protected:
90
91 /* Mouse-handler constructor/destructor: */
92 UIMouseHandler(UIMachineLogic *pMachineLogic);
93 virtual ~UIMouseHandler();
94
95 /* Getters: */
96 UIMachineLogic* machineLogic() const;
97 UISession* uisession() const;
98
99 /** Returns the console's display reference. */
100 CDisplay& display() const;
101 /** Returns the console's mouse reference. */
102 CMouse& mouse() const;
103
104 /* Event handler for registered machine-view(s): */
105 bool eventFilter(QObject *pWatched, QEvent *pEvent);
106
107 /* Separate function to handle most of existing mouse-events: */
108 bool mouseEvent(int iEventType, ulong uScreenId,
109 const QPoint &relativePos, const QPoint &globalPos,
110 Qt::MouseButtons mouseButtons,
111 int wheelDelta, Qt::Orientation wheelDirection);
112
113 /* Separate function to handle incoming multi-touch events: */
114 bool multiTouchEvent(QTouchEvent *pTouchEvent, ulong uScreenId);
115
116#ifdef VBOX_WS_WIN
117 /* This method is actually required only because under win-host
118 * we do not really grab the mouse in case of capturing it: */
119 void updateMouseCursorClipping();
120 QRect m_mouseCursorClippingRect;
121#endif /* VBOX_WS_WIN */
122
123 /* Machine logic parent: */
124 UIMachineLogic *m_pMachineLogic;
125
126 /* Registered machine-windows(s): */
127 QMap<ulong, QWidget*> m_windows;
128 /* Registered machine-view(s): */
129 QMap<ulong, UIMachineView*> m_views;
130 /* Registered machine-view-viewport(s): */
131 QMap<ulong, QWidget*> m_viewports;
132
133 /** Hovered window to be activated. */
134 QPointer<QWidget> m_pHoveredWindow;
135
136 /* Other mouse variables: */
137 QPoint m_lastMousePos;
138 QPoint m_capturedMousePos;
139 int m_iLastMouseWheelDelta;
140 int m_iMouseCaptureViewIndex;
141
142#ifdef VBOX_WS_WIN
143 /** Holds whether cursor position was just
144 * reseted to simulate infinite mouse moving. */
145 bool m_fCursorPositionReseted;
146#endif
147};
148
149#endif // !___UIMouseHandler_h___
150
Note: See TracBrowser for help on using the repository browser.

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