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
RevLine 
[382]1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
[26691]4 * UISession 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
[26691]19#ifndef ___UIConsole_h___
20#define ___UIConsole_h___
[19817]21
[26691]22/* Global includes */
23#include <QObject>
[26815]24#include <QCursor>
[382]25
[26691]26/* Local includes */
27#include "COMDefs.h"
[27335]28#include "UIMachineDefs.h"
[382]29
[26952]30/* Global forwards */
[27141]31class QMenu;
[26952]32class QMenuBar;
[35686]33#ifdef VBOX_GUI_WITH_KEYS_RESET_HANDLER
[35695]34# ifdef Q_WS_MAC
35struct __siginfo;
36typedef struct __siginfo siginfo_t;
37# else /* Q_WS_MAC */
[35686]38struct siginfo;
39typedef struct siginfo siginfo_t;
[35695]40# endif /* !Q_WS_MAC */
[35686]41#endif /* VBOX_GUI_WITH_KEYS_RESET_HANDLER */
[26952]42
[26691]43/* Local forwards */
[26919]44class UIActionsPool;
[27768]45class UIFrameBuffer;
[27374]46class UIMachine;
[28342]47class UIMachineLogic;
[26919]48class UIMachineMenuBar;
[5132]49
[26691]50/* CConsole callback event types: */
51enum UIConsoleEventType
[382]52{
[26691]53 UIConsoleEventType_MousePointerShapeChange = QEvent::User + 1,
54 UIConsoleEventType_MouseCapabilityChange,
55 UIConsoleEventType_KeyboardLedsChange,
56 UIConsoleEventType_StateChange,
57 UIConsoleEventType_AdditionsStateChange,
58 UIConsoleEventType_NetworkAdapterChange,
[28963]59 /* Not used: UIConsoleEventType_SerialPortChange, */
60 /* Not used: UIConsoleEventType_ParallelPortChange, */
61 /* Not used: UIConsoleEventType_StorageControllerChange, */
[26691]62 UIConsoleEventType_MediumChange,
[28963]63 /* Not used: UIConsoleEventType_CPUChange, */
[33386]64 UIConsoleEventType_VRDEServerChange,
65 UIConsoleEventType_VRDEServerInfoChange,
[26691]66 UIConsoleEventType_USBControllerChange,
67 UIConsoleEventType_USBDeviceStateChange,
68 UIConsoleEventType_SharedFolderChange,
69 UIConsoleEventType_RuntimeError,
70 UIConsoleEventType_CanShowWindow,
71 UIConsoleEventType_ShowWindow,
72 UIConsoleEventType_MAX
[382]73};
74
[26691]75class UISession : public QObject
[382]76{
[26691]77 Q_OBJECT;
[382]78
79public:
80
[26890]81 /* Machine uisession constructor/destructor: */
82 UISession(UIMachine *pMachine, CSession &session);
[26691]83 virtual ~UISession();
[2700]84
[27310]85 /* Common members: */
86 void powerUp();
87
[26815]88 /* Common getters: */
[26691]89 CSession& session() { return m_session; }
[26815]90 KMachineState machineState() const { return m_machineState; }
[26919]91 UIActionsPool* actionsPool() const;
[27310]92 QWidget* mainMachineWindow() const;
[28342]93 UIMachineLogic* machineLogic() const;
[27335]94 QMenu* newMenu(UIMainMenuType fOptions = UIMainMenuType_All);
95 QMenuBar* newMenuBar(UIMainMenuType fOptions = UIMainMenuType_All);
[27141]96 QCursor cursor() const { return m_cursor; }
[26919]97
[26815]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; }
[29485]109 bool isIgnoreRuntimeMediumsChanging() const { return m_fIsIgnoreRuntimeMediumsChanging; }
[26815]110 bool isGuestResizeIgnored() const { return m_fIsGuestResizeIgnored; }
[27300]111 bool isSeamlessModeRequested() const { return m_fIsSeamlessModeRequested; }
[30348]112 bool isAutoCaptureDisabled() const { return m_fIsAutoCaptureDisabled; }
[4141]113
[26815]114 /* Guest additions state getters: */
[32086]115 bool isGuestAdditionsActive() const { return (m_ulGuestAdditionsRunLevel > AdditionsRunLevelType_None); }
[27178]116 bool isGuestSupportsGraphics() const { return isGuestAdditionsActive() && m_fIsGuestSupportsGraphics; }
117 bool isGuestSupportsSeamless() const { return isGuestSupportsGraphics() && m_fIsGuestSupportsSeamless; }
[26815]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; }
[26964]132 bool isValidPointerShapePresent() const { return m_fIsValidPointerShapePresent; }
[27227]133 bool isHidingHostPointer() const { return m_fIsHidingHostPointer; }
[26815]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; }
[27300]140 void setSeamlessModeRequested(bool fIsSeamlessModeRequested) { m_fIsSeamlessModeRequested = fIsSeamlessModeRequested; }
[30348]141 void setAutoCaptureDisabled(bool fIsAutoCaptureDisabled) { m_fIsAutoCaptureDisabled = fIsAutoCaptureDisabled; }
[26815]142
143 /* Keyboard setters: */
144 void setNumLockAdaptionCnt(uint uNumLockAdaptionCnt) { m_uNumLockAdaptionCnt = uNumLockAdaptionCnt; }
145 void setCapsLockAdaptionCnt(uint uCapsLockAdaptionCnt) { m_uCapsLockAdaptionCnt = uCapsLockAdaptionCnt; }
146
147 /* Mouse setters: */
[30408]148 void setMouseCaptured(bool fIsMouseCaptured) { m_fIsMouseCaptured = fIsMouseCaptured; }
[26815]149 void setMouseIntegrated(bool fIsMouseIntegrated) { m_fIsMouseIntegrated = fIsMouseIntegrated; }
150
[27697]151#ifdef VBOX_WITH_VIDEOHWACCEL
[27757]152 /* return a persisted framebuffer for the given screen
153 * see comment below for the m_FrameBufferVector field */
[27768]154 UIFrameBuffer* frameBuffer(ulong screenId) const;
[27757]155 /* @return VINF_SUCCESS - on success
156 * VERR_INVALID_PARAMETER - if screenId is invalid */
[27768]157 int setFrameBuffer(ulong screenId, UIFrameBuffer* pFrameBuffer);
[27697]158#endif
159
[26691]160signals:
[382]161
[26815]162 /* Console callback signals: */
163 void sigMousePointerShapeChange();
164 void sigMouseCapabilityChange();
165 void sigKeyboardLedsChange();
166 void sigMachineStateChange();
[26691]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();
[26754]173 void sigRuntimeError(bool bIsFatal, const QString &strErrorId, const QString &strMessage);
[29014]174#ifdef RT_OS_DARWIN
175 void sigShowWindows();
176#endif /* RT_OS_DARWIN */
[382]177
[26967]178 /* Session signals: */
[27310]179 void sigMachineStarted();
[26967]180
[27374]181public slots:
182
183 void sltInstallGuestAdditionsFrom(const QString &strSource);
184
[26890]185private slots:
186
187 /* Close uisession handler: */
188 void sltCloseVirtualSession();
189
[30677]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
[382]197private:
198
[26691]199 /* Private getters: */
[26815]200 UIMachine* uimachine() const { return m_pMachine; }
[4202]201
[26815]202 /* Prepare helpers: */
[27141]203 void prepareMenuPool();
[26815]204 void loadSessionSettings();
205
206 /* Cleanup helpers: */
207 void saveSessionSettings();
[27141]208 void cleanupMenuPool();
[26815]209
210 /* Common helpers: */
[26996]211 WId winId() const;
[26815]212 void setPointerShape(const uchar *pShapeData, bool fHasAlpha, uint uXHot, uint uYHot, uint uWidth, uint uHeight);
[27141]213 void reinitMenuPool();
[27310]214 void preparePowerUp();
[3045]215
[35686]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
[26691]220 /* Private variables: */
221 UIMachine *m_pMachine;
[26890]222 CSession &m_session;
[382]223
[27141]224 UIMachineMenuBar *m_pMenuPool;
[26919]225
[27697]226#ifdef VBOX_WITH_VIDEOHWACCEL
[27757]227 /* When 2D is enabled we do not re-create Framebuffers. This is done
[27768]228 * 1. to avoid 2D command loss during the time slot when no framebuffer is
229 * assigned to the display
[27757]230 * 2. to make it easier to preserve the current 2D state */
[27768]231 QVector<UIFrameBuffer*> m_FrameBufferVector;
[27697]232#endif
233
[26815]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;
[29485]243 bool m_fIsIgnoreRuntimeMediumsChanging : 1;
[26815]244 bool m_fIsGuestResizeIgnored : 1;
[27300]245 bool m_fIsSeamlessModeRequested : 1;
[30348]246 bool m_fIsAutoCaptureDisabled : 1;
[26815]247
248 /* Guest additions flags: */
[32020]249 ULONG m_ulGuestAdditionsRunLevel;
250 bool m_fIsGuestSupportsGraphics : 1;
251 bool m_fIsGuestSupportsSeamless : 1;
[26815]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;
[26964]266 bool m_fIsValidPointerShapePresent : 1;
[27227]267 bool m_fIsHidingHostPointer : 1;
[26815]268
[26691]269 /* Friend classes: */
[30677]270 friend class UIConsoleEventHandler;
[382]271};
272
[26691]273#endif // !___UIConsole_h___
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use