VirtualBox

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

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

FE/Qt4-OSX: Prevent the mouse from leaving the window in capture mode.

  • 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
27/* Local includes */
28#include "UIMachineDefs.h"
29
30/* Global forwards */
31class QWidget;
32
33/* Local forwards */
34class CSession;
35class UISession;
36class UIMachineLogic;
37class UIMachineWindow;
38class UIMachineView;
39#ifdef Q_WS_X11
40typedef union _XEvent XEvent;
41#endif /* Q_WS_X11 */
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#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 */
113
114 /* Machine logic parent: */
115 UIMachineLogic *m_pMachineLogic;
116
117 /* Registered machine-windows(s): */
118 QMap<ulong, QWidget*> m_windows;
119 /* Registered machine-view(s): */
120 QMap<ulong, UIMachineView*> m_views;
121 /* Registered machine-view-viewport(s): */
122 QMap<ulong, QWidget*> m_viewports;
123
124 /* Other mouse variables: */
125 QPoint m_lastMousePos;
126 QPoint m_capturedMousePos;
127 int m_iLastMouseWheelDelta;
128 int m_iMouseCaptureViewIndex;
129};
130
131#endif // !___UIMouseHandler_h___
132
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use