VirtualBox

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

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

FE/Qt: 6227: Decrease GUI build time: Rework COM wrappers generator to create one header per each COM interface. Update all GUI files to use newly generated headers.

  • 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/* Qt includes: */
23#include <QObject>
24#include <QPoint>
25#include <QMap>
26#include <QRect>
27
28/* GUI includes: */
29#include "UIMachineDefs.h"
30
31/* Forward declarations: */
32class QWidget;
33class UISession;
34class UIMachineLogic;
35class UIMachineWindow;
36class UIMachineView;
37#ifdef Q_WS_X11
38typedef union _XEvent XEvent;
39#endif /* Q_WS_X11 */
40class CSession;
41
42/* Delegate to control VM mouse functionality: */
43class UIMouseHandler : public QObject
44{
45 Q_OBJECT;
46
47public:
48
49 /* Factory functions to create/destroy mouse-handler: */
50 static UIMouseHandler* create(UIMachineLogic *pMachineLogic, UIVisualStateType visualStateType);
51 static void destroy(UIMouseHandler *pMouseHandler);
52
53 /* Prepare/cleanup listener for particular machine-window: */
54 void prepareListener(ulong uIndex, UIMachineWindow *pMachineWindow);
55 void cleanupListener(ulong uIndex);
56
57 /* Commands to capture/release mouse: */
58 void captureMouse(ulong uScreenId);
59 void releaseMouse();
60
61 /* Setter for mouse-integration feature: */
62 void setMouseIntegrationEnabled(bool fEnabled);
63
64 /* Current mouse state: */
65 int mouseState() const;
66
67#ifdef Q_WS_X11
68 bool x11EventFilter(XEvent *pEvent, ulong uScreenId);
69#endif /* Q_WS_X11 */
70
71signals:
72
73 /* Notifies listeners about mouse state-change: */
74 void mouseStateChanged(int iNewState);
75
76protected slots:
77
78 /* Machine state-change handler: */
79 virtual void sltMachineStateChanged();
80
81 /* Mouse capability-change handler: */
82 virtual void sltMouseCapabilityChanged();
83
84 /* Mouse pointer-shape-change handler: */
85 virtual void sltMousePointerShapeChanged();
86
87protected:
88
89 /* Mouse-handler constructor/destructor: */
90 UIMouseHandler(UIMachineLogic *pMachineLogic);
91 virtual ~UIMouseHandler();
92
93 /* Getters: */
94 UIMachineLogic* machineLogic() const;
95 UISession* uisession() const;
96 CSession& session() const;
97
98 /* Event handler for registered machine-view(s): */
99 bool eventFilter(QObject *pWatched, QEvent *pEvent);
100
101 /* Separate function to handle most of existing mouse-events: */
102 bool mouseEvent(int iEventType, ulong uScreenId,
103 const QPoint &relativePos, const QPoint &globalPos,
104 Qt::MouseButtons mouseButtons,
105 int wheelDelta, Qt::Orientation wheelDirection);
106
107#ifdef Q_WS_WIN
108 /* This method is actually required only because under win-host
109 * we do not really grab the mouse in case of capturing it: */
110 void updateMouseCursorClipping();
111 QRect m_mouseCursorClippingRect;
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