VirtualBox

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

Last change on this file was 103988, checked in by vboxsync, 6 weeks ago

FE/Qt. bugref:10624. Adding missing override keywords gcc has found.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use