VirtualBox

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

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

FE/Qt4-OSX: make it compile on OSX

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

© 2023 Oracle
ContactPrivacy policyTerms of Use