VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h@ 35686

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

FE/Qt4: special signal handler for reseting pressed keys

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.9 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * UISession 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 ___UIConsole_h___
20#define ___UIConsole_h___
21
22/* Global includes */
23#include <QObject>
24#include <QCursor>
25
26/* Local includes */
27#include "COMDefs.h"
28#include "UIMachineDefs.h"
29
30/* Global forwards */
31class QMenu;
32class QMenuBar;
33#ifdef VBOX_GUI_WITH_KEYS_RESET_HANDLER
34struct siginfo;
35typedef struct siginfo siginfo_t;
36#endif /* VBOX_GUI_WITH_KEYS_RESET_HANDLER */
37
38/* Local forwards */
39class UIActionsPool;
40class UIFrameBuffer;
41class UIMachine;
42class UIMachineLogic;
43class UIMachineMenuBar;
44
45/* CConsole callback event types: */
46enum UIConsoleEventType
47{
48 UIConsoleEventType_MousePointerShapeChange = QEvent::User + 1,
49 UIConsoleEventType_MouseCapabilityChange,
50 UIConsoleEventType_KeyboardLedsChange,
51 UIConsoleEventType_StateChange,
52 UIConsoleEventType_AdditionsStateChange,
53 UIConsoleEventType_NetworkAdapterChange,
54 /* Not used: UIConsoleEventType_SerialPortChange, */
55 /* Not used: UIConsoleEventType_ParallelPortChange, */
56 /* Not used: UIConsoleEventType_StorageControllerChange, */
57 UIConsoleEventType_MediumChange,
58 /* Not used: UIConsoleEventType_CPUChange, */
59 UIConsoleEventType_VRDEServerChange,
60 UIConsoleEventType_VRDEServerInfoChange,
61 UIConsoleEventType_USBControllerChange,
62 UIConsoleEventType_USBDeviceStateChange,
63 UIConsoleEventType_SharedFolderChange,
64 UIConsoleEventType_RuntimeError,
65 UIConsoleEventType_CanShowWindow,
66 UIConsoleEventType_ShowWindow,
67 UIConsoleEventType_MAX
68};
69
70class UISession : public QObject
71{
72 Q_OBJECT;
73
74public:
75
76 /* Machine uisession constructor/destructor: */
77 UISession(UIMachine *pMachine, CSession &session);
78 virtual ~UISession();
79
80 /* Common members: */
81 void powerUp();
82
83 /* Common getters: */
84 CSession& session() { return m_session; }
85 KMachineState machineState() const { return m_machineState; }
86 UIActionsPool* actionsPool() const;
87 QWidget* mainMachineWindow() const;
88 UIMachineLogic* machineLogic() const;
89 QMenu* newMenu(UIMainMenuType fOptions = UIMainMenuType_All);
90 QMenuBar* newMenuBar(UIMainMenuType fOptions = UIMainMenuType_All);
91 QCursor cursor() const { return m_cursor; }
92
93 bool isSaved() const { return machineState() == KMachineState_Saved; }
94 bool isTurnedOff() const { return machineState() == KMachineState_PoweredOff ||
95 machineState() == KMachineState_Saved ||
96 machineState() == KMachineState_Teleported ||
97 machineState() == KMachineState_Aborted; }
98 bool isPaused() const { return machineState() == KMachineState_Paused ||
99 machineState() == KMachineState_TeleportingPausedVM; }
100 bool isRunning() const { return machineState() == KMachineState_Running ||
101 machineState() == KMachineState_Teleporting ||
102 machineState() == KMachineState_LiveSnapshotting; }
103 bool isFirstTimeStarted() const { return m_fIsFirstTimeStarted; }
104 bool isIgnoreRuntimeMediumsChanging() const { return m_fIsIgnoreRuntimeMediumsChanging; }
105 bool isGuestResizeIgnored() const { return m_fIsGuestResizeIgnored; }
106 bool isSeamlessModeRequested() const { return m_fIsSeamlessModeRequested; }
107 bool isAutoCaptureDisabled() const { return m_fIsAutoCaptureDisabled; }
108
109 /* Guest additions state getters: */
110 bool isGuestAdditionsActive() const { return (m_ulGuestAdditionsRunLevel > AdditionsRunLevelType_None); }
111 bool isGuestSupportsGraphics() const { return isGuestAdditionsActive() && m_fIsGuestSupportsGraphics; }
112 bool isGuestSupportsSeamless() const { return isGuestSupportsGraphics() && m_fIsGuestSupportsSeamless; }
113
114 /* Keyboard getters: */
115 bool isNumLock() const { return m_fNumLock; }
116 bool isCapsLock() const { return m_fCapsLock; }
117 bool isScrollLock() const { return m_fScrollLock; }
118 uint numLockAdaptionCnt() const { return m_uNumLockAdaptionCnt; }
119 uint capsLockAdaptionCnt() const { return m_uCapsLockAdaptionCnt; }
120
121 /* Mouse getters: */
122 bool isMouseSupportsAbsolute() const { return m_fIsMouseSupportsAbsolute; }
123 bool isMouseSupportsRelative() const { return m_fIsMouseSupportsRelative; }
124 bool isMouseHostCursorNeeded() const { return m_fIsMouseHostCursorNeeded; }
125 bool isMouseCaptured() const { return m_fIsMouseCaptured; }
126 bool isMouseIntegrated() const { return m_fIsMouseIntegrated; }
127 bool isValidPointerShapePresent() const { return m_fIsValidPointerShapePresent; }
128 bool isHidingHostPointer() const { return m_fIsHidingHostPointer; }
129
130 /* Common setters: */
131 bool pause() { return setPause(true); }
132 bool unpause() { return setPause(false); }
133 bool setPause(bool fOn);
134 void setGuestResizeIgnored(bool fIsGuestResizeIgnored) { m_fIsGuestResizeIgnored = fIsGuestResizeIgnored; }
135 void setSeamlessModeRequested(bool fIsSeamlessModeRequested) { m_fIsSeamlessModeRequested = fIsSeamlessModeRequested; }
136 void setAutoCaptureDisabled(bool fIsAutoCaptureDisabled) { m_fIsAutoCaptureDisabled = fIsAutoCaptureDisabled; }
137
138 /* Keyboard setters: */
139 void setNumLockAdaptionCnt(uint uNumLockAdaptionCnt) { m_uNumLockAdaptionCnt = uNumLockAdaptionCnt; }
140 void setCapsLockAdaptionCnt(uint uCapsLockAdaptionCnt) { m_uCapsLockAdaptionCnt = uCapsLockAdaptionCnt; }
141
142 /* Mouse setters: */
143 void setMouseCaptured(bool fIsMouseCaptured) { m_fIsMouseCaptured = fIsMouseCaptured; }
144 void setMouseIntegrated(bool fIsMouseIntegrated) { m_fIsMouseIntegrated = fIsMouseIntegrated; }
145
146#ifdef VBOX_WITH_VIDEOHWACCEL
147 /* return a persisted framebuffer for the given screen
148 * see comment below for the m_FrameBufferVector field */
149 UIFrameBuffer* frameBuffer(ulong screenId) const;
150 /* @return VINF_SUCCESS - on success
151 * VERR_INVALID_PARAMETER - if screenId is invalid */
152 int setFrameBuffer(ulong screenId, UIFrameBuffer* pFrameBuffer);
153#endif
154
155signals:
156
157 /* Console callback signals: */
158 void sigMousePointerShapeChange();
159 void sigMouseCapabilityChange();
160 void sigKeyboardLedsChange();
161 void sigMachineStateChange();
162 void sigAdditionsStateChange();
163 void sigNetworkAdapterChange(const CNetworkAdapter &networkAdapter);
164 void sigMediumChange(const CMediumAttachment &mediumAttachment);
165 void sigUSBControllerChange();
166 void sigUSBDeviceStateChange(const CUSBDevice &device, bool bIsAttached, const CVirtualBoxErrorInfo &error);
167 void sigSharedFolderChange();
168 void sigRuntimeError(bool bIsFatal, const QString &strErrorId, const QString &strMessage);
169#ifdef RT_OS_DARWIN
170 void sigShowWindows();
171#endif /* RT_OS_DARWIN */
172
173 /* Session signals: */
174 void sigMachineStarted();
175
176public slots:
177
178 void sltInstallGuestAdditionsFrom(const QString &strSource);
179
180private slots:
181
182 /* Close uisession handler: */
183 void sltCloseVirtualSession();
184
185 /* Console events slots */
186 void sltMousePointerShapeChange(bool fVisible, bool fAlpha, QPoint hotCorner, QSize size, QVector<uint8_t> shape);
187 void sltMouseCapabilityChange(bool fSupportsAbsolute, bool fSupportsRelative, bool fNeedsHostCursor);
188 void sltKeyboardLedsChangeEvent(bool fNumLock, bool fCapsLock, bool fScrollLock);
189 void sltStateChange(KMachineState state);
190 void sltAdditionsChange();
191
192private:
193
194 /* Private getters: */
195 UIMachine* uimachine() const { return m_pMachine; }
196
197 /* Prepare helpers: */
198 void prepareMenuPool();
199 void loadSessionSettings();
200
201 /* Cleanup helpers: */
202 void saveSessionSettings();
203 void cleanupMenuPool();
204
205 /* Common helpers: */
206 WId winId() const;
207 void setPointerShape(const uchar *pShapeData, bool fHasAlpha, uint uXHot, uint uYHot, uint uWidth, uint uHeight);
208 void reinitMenuPool();
209 void preparePowerUp();
210
211#ifdef VBOX_GUI_WITH_KEYS_RESET_HANDLER
212 static void signalHandlerSIGUSR1(int sig, siginfo_t *pInfo, void *pSecret);
213#endif /* VBOX_GUI_WITH_KEYS_RESET_HANDLER */
214
215 /* Private variables: */
216 UIMachine *m_pMachine;
217 CSession &m_session;
218
219 UIMachineMenuBar *m_pMenuPool;
220
221#ifdef VBOX_WITH_VIDEOHWACCEL
222 /* When 2D is enabled we do not re-create Framebuffers. This is done
223 * 1. to avoid 2D command loss during the time slot when no framebuffer is
224 * assigned to the display
225 * 2. to make it easier to preserve the current 2D state */
226 QVector<UIFrameBuffer*> m_FrameBufferVector;
227#endif
228
229 /* Common variables: */
230 KMachineState m_machineState;
231 QCursor m_cursor;
232#if defined(Q_WS_WIN)
233 HCURSOR m_alphaCursor;
234#endif
235
236 /* Common flags: */
237 bool m_fIsFirstTimeStarted : 1;
238 bool m_fIsIgnoreRuntimeMediumsChanging : 1;
239 bool m_fIsGuestResizeIgnored : 1;
240 bool m_fIsSeamlessModeRequested : 1;
241 bool m_fIsAutoCaptureDisabled : 1;
242
243 /* Guest additions flags: */
244 ULONG m_ulGuestAdditionsRunLevel;
245 bool m_fIsGuestSupportsGraphics : 1;
246 bool m_fIsGuestSupportsSeamless : 1;
247
248 /* Keyboard flags: */
249 bool m_fNumLock : 1;
250 bool m_fCapsLock : 1;
251 bool m_fScrollLock : 1;
252 uint m_uNumLockAdaptionCnt;
253 uint m_uCapsLockAdaptionCnt;
254
255 /* Mouse flags: */
256 bool m_fIsMouseSupportsAbsolute : 1;
257 bool m_fIsMouseSupportsRelative : 1;
258 bool m_fIsMouseHostCursorNeeded : 1;
259 bool m_fIsMouseCaptured : 1;
260 bool m_fIsMouseIntegrated : 1;
261 bool m_fIsValidPointerShapePresent : 1;
262 bool m_fIsHidingHostPointer : 1;
263
264 /* Friend classes: */
265 friend class UIConsoleEventHandler;
266};
267
268#endif // !___UIConsole_h___
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use