VirtualBox

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

Last change on this file since 35906 was 35906, checked in by vboxsync, 13 years ago

FE/Qt: 4718: Mouse cursor issues with disabled mouse integration: Fixed bug with mouse-cursor clipping failure (win host) in case of VM window overlapped by always-on-top window(s).

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

© 2023 Oracle
ContactPrivacy policyTerms of Use