VirtualBox

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

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

FE/Qt: Mouse-Handler: Extend mouse-handler listener to handle machine-window events. Perform mouse-cursor-clipping update for situations when machine-window was moved by desktop system (win host).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 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_MAC
69 /* Enable mouse event compression if we leave the VM view.
70 * This is necessary for having smooth resizing of the VM/other windows.
71 * Disable mouse event compression if we enter the VM view.
72 * So all mouse events are registered in the VM. */
73 void setMouseCoalescingEnabled(bool fOn);
74#endif /* Q_WS_MAC */
75
76#ifdef Q_WS_X11
77 bool x11EventFilter(XEvent *pEvent, ulong uScreenId);
78#endif /* Q_WS_X11 */
79
80signals:
81
82 /* Notifies listeners about mouse state-change: */
83 void mouseStateChanged(int iNewState);
84
85protected slots:
86
87 /* Machine state-change handler: */
88 virtual void sltMachineStateChanged();
89
90 /* Mouse capability-change handler: */
91 virtual void sltMouseCapabilityChanged();
92
93 /* Mouse pointer-shape-change handler: */
94 virtual void sltMousePointerShapeChanged();
95
96protected:
97
98 /* Mouse-handler constructor/destructor: */
99 UIMouseHandler(UIMachineLogic *pMachineLogic);
100 virtual ~UIMouseHandler();
101
102 /* Getters: */
103 UIMachineLogic* machineLogic() const;
104 UISession* uisession() const;
105 CSession& session() const;
106
107 /* Event handler for registered machine-view(s): */
108 bool eventFilter(QObject *pWatched, QEvent *pEvent);
109
110 /* Separate function to handle most of existing mouse-events: */
111 bool mouseEvent(int iEventType, ulong uScreenId,
112 const QPoint &relativePos, const QPoint &globalPos,
113 Qt::MouseButtons mouseButtons,
114 int wheelDelta, Qt::Orientation wheelDirection);
115
116#ifdef Q_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#endif /* Q_WS_WIN */
121
122 /* Machine logic parent: */
123 UIMachineLogic *m_pMachineLogic;
124
125 /* Registered machine-windows(s): */
126 QMap<ulong, QWidget*> m_windows;
127 /* Registered machine-view(s): */
128 QMap<ulong, UIMachineView*> m_views;
129 /* Registered machine-view-viewport(s): */
130 QMap<ulong, QWidget*> m_viewports;
131
132 /* Other mouse variables: */
133 QPoint m_lastMousePos;
134 QPoint m_capturedMousePos;
135 int m_iLastMouseWheelDelta;
136 int m_iMouseCaptureViewIndex;
137};
138
139#endif // !___UIMouseHandler_h___
140
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use