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
RevLine 
[382]1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
[30408]4 * UIMouseHandler class declaration
[382]5 */
6
7/*
[28800]8 * Copyright (C) 2010 Oracle Corporation
[382]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
[5999]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.
[382]17 */
18
[30408]19#ifndef ___UIMouseHandler_h___
20#define ___UIMouseHandler_h___
[382]21
[26637]22/* Global includes */
[30408]23#include <QObject>
24#include <QPoint>
25#include <QMap>
[35906]26#include <QRect>
[382]27
[26637]28/* Local includes */
29#include "UIMachineDefs.h"
[6467]30
[30408]31/* Global forwards */
32class QWidget;
[26699]33
[26754]34/* Local forwards */
[30408]35class CSession;
[26815]36class UISession;
[27021]37class UIMachineLogic;
[34471]38class UIMachineWindow;
[30408]39class UIMachineView;
[30637]40#ifdef Q_WS_X11
41typedef union _XEvent XEvent;
42#endif /* Q_WS_X11 */
[26699]43
[30408]44/* Delegate to control VM mouse functionality: */
45class UIMouseHandler : public QObject
[382]46{
[26637]47 Q_OBJECT;
[382]48
49public:
50
[30408]51 /* Factory functions to create/destroy mouse-handler: */
52 static UIMouseHandler* create(UIMachineLogic *pMachineLogic, UIVisualStateType visualStateType);
53 static void destroy(UIMouseHandler *pMouseHandler);
[26889]54
[34471]55 /* Prepare/cleanup listener for particular machine-window: */
56 void prepareListener(ulong uIndex, UIMachineWindow *pMachineWindow);
57 void cleanupListener(ulong uIndex);
[382]58
[30408]59 /* Commands to capture/release mouse: */
60 void captureMouse(ulong uScreenId);
61 void releaseMouse();
[26773]62
[30408]63 /* Setter for mouse-integration feature: */
64 void setMouseIntegrationEnabled(bool fEnabled);
[382]65
[30408]66 /* Current mouse state: */
67 int mouseState() const;
[26815]68
[30637]69#ifdef Q_WS_X11
70 bool x11EventFilter(XEvent *pEvent, ulong uScreenId);
71#endif /* Q_WS_X11 */
72
[26637]73signals:
[382]74
[30408]75 /* Notifies listeners about mouse state-change: */
76 void mouseStateChanged(int iNewState);
[26730]77
[26773]78protected slots:
79
[30408]80 /* Machine state-change handler: */
[26815]81 virtual void sltMachineStateChanged();
[30408]82
83 /* Mouse capability-change handler: */
[26815]84 virtual void sltMouseCapabilityChanged();
[26773]85
[30408]86 /* Mouse pointer-shape-change handler: */
87 virtual void sltMousePointerShapeChanged();
[26967]88
[30408]89protected:
[28239]90
[30408]91 /* Mouse-handler constructor/destructor: */
92 UIMouseHandler(UIMachineLogic *pMachineLogic);
93 virtual ~UIMouseHandler();
[26637]94
[30408]95 /* Getters: */
96 UIMachineLogic* machineLogic() const;
97 UISession* uisession() const;
98 CSession& session() const;
[26754]99
[30408]100 /* Event handler for registered machine-view(s): */
101 bool eventFilter(QObject *pWatched, QEvent *pEvent);
[382]102
[30408]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);
[382]108
[30408]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();
[35906]113 QRect m_mouseCursorClippingRect;
[30408]114#endif /* Q_WS_WIN */
[382]115
[30408]116 /* Machine logic parent: */
117 UIMachineLogic *m_pMachineLogic;
[382]118
[34471]119 /* Registered machine-windows(s): */
120 QMap<ulong, QWidget*> m_windows;
[30408]121 /* Registered machine-view(s): */
122 QMap<ulong, UIMachineView*> m_views;
123 /* Registered machine-view-viewport(s): */
124 QMap<ulong, QWidget*> m_viewports;
[27012]125
[30408]126 /* Other mouse variables: */
[26754]127 QPoint m_lastMousePos;
128 QPoint m_capturedMousePos;
[25304]129 int m_iLastMouseWheelDelta;
[30408]130 int m_iMouseCaptureViewIndex;
[382]131};
132
[30408]133#endif // !___UIMouseHandler_h___
[27124]134
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use