1 | /* $Id: UIMachine.cpp 103771 2024-03-11 15:16:04Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIMachine class implementation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | /* Qt includes: */
|
---|
29 | #ifdef VBOX_WS_WIN
|
---|
30 | # include <QBitmap>
|
---|
31 | #endif
|
---|
32 | #ifdef VBOX_WS_MAC
|
---|
33 | # include <QMenuBar>
|
---|
34 | # include <QTimer>
|
---|
35 | #endif
|
---|
36 |
|
---|
37 | /* GUI includes: */
|
---|
38 | #include "UICommon.h"
|
---|
39 | #include "UIDesktopWidgetWatchdog.h"
|
---|
40 | #include "UIExtraDataManager.h"
|
---|
41 | #include "UIGlobalSession.h"
|
---|
42 | #include "UIIconPool.h"
|
---|
43 | #include "UIMachine.h"
|
---|
44 | #include "UISession.h"
|
---|
45 | #include "UIActionPoolRuntime.h"
|
---|
46 | #include "UILoggingDefs.h"
|
---|
47 | #include "UIMachineLogic.h"
|
---|
48 | #include "UIMachineWindow.h"
|
---|
49 | #include "UIMessageCenter.h"
|
---|
50 | #include "UINotificationCenter.h"
|
---|
51 | #ifdef VBOX_WS_MAC
|
---|
52 | # include "UICocoaApplication.h"
|
---|
53 | # include "VBoxUtils-darwin.h"
|
---|
54 | #endif
|
---|
55 |
|
---|
56 | /* COM includes: */
|
---|
57 | #include "CAudioAdapter.h"
|
---|
58 | #include "CAudioSettings.h"
|
---|
59 | #include "CConsole.h"
|
---|
60 | #include "CGraphicsAdapter.h"
|
---|
61 | #include "CHostVideoInputDevice.h"
|
---|
62 | #include "CMachine.h"
|
---|
63 | #include "CMediumAttachment.h"
|
---|
64 | #include "CNetworkAdapter.h"
|
---|
65 | #include "CProgress.h"
|
---|
66 | #include "CRecordingSettings.h"
|
---|
67 | #include "CSession.h"
|
---|
68 | #include "CSnapshot.h"
|
---|
69 | #include "CSystemProperties.h"
|
---|
70 | #include "CUSBController.h"
|
---|
71 | #include "CUSBDeviceFilters.h"
|
---|
72 | #include "CVRDEServer.h"
|
---|
73 |
|
---|
74 |
|
---|
75 | #ifdef VBOX_WS_MAC
|
---|
76 | /**
|
---|
77 | * MacOS X: Application Services: Core Graphics: Display reconfiguration callback.
|
---|
78 | *
|
---|
79 | * Notifies UIMachine about @a display configuration change.
|
---|
80 | * Corresponding change described by Core Graphics @a flags.
|
---|
81 | * Uses UIMachine @a pHandler to process this change.
|
---|
82 | *
|
---|
83 | * @note Last argument (@a pHandler) must always be valid pointer to UIMachine object.
|
---|
84 | * @note Calls for UIMachine::sltHandleHostDisplayAboutToChange() slot if display configuration changed.
|
---|
85 | */
|
---|
86 | void cgDisplayReconfigurationCallback(CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags, void *pHandler)
|
---|
87 | {
|
---|
88 | /* Which flags we are handling? */
|
---|
89 | int iHandledFlags = kCGDisplayAddFlag /* display added */
|
---|
90 | | kCGDisplayRemoveFlag /* display removed */
|
---|
91 | | kCGDisplaySetModeFlag /* display mode changed */;
|
---|
92 |
|
---|
93 | /* Handle 'display-add' case: */
|
---|
94 | if (flags & kCGDisplayAddFlag)
|
---|
95 | LogRelFlow(("GUI: UIMachine::cgDisplayReconfigurationCallback: Display added.\n"));
|
---|
96 | /* Handle 'display-remove' case: */
|
---|
97 | else if (flags & kCGDisplayRemoveFlag)
|
---|
98 | LogRelFlow(("GUI: UIMachine::cgDisplayReconfigurationCallback: Display removed.\n"));
|
---|
99 | /* Handle 'mode-set' case: */
|
---|
100 | else if (flags & kCGDisplaySetModeFlag)
|
---|
101 | LogRelFlow(("GUI: UIMachine::cgDisplayReconfigurationCallback: Display mode changed.\n"));
|
---|
102 |
|
---|
103 | /* Ask handler to process our callback: */
|
---|
104 | if (flags & iHandledFlags)
|
---|
105 | QTimer::singleShot(0, static_cast<UIMachine*>(pHandler),
|
---|
106 | SLOT(sltHandleHostDisplayAboutToChange()));
|
---|
107 |
|
---|
108 | Q_UNUSED(display);
|
---|
109 | }
|
---|
110 | #endif /* VBOX_WS_MAC */
|
---|
111 |
|
---|
112 |
|
---|
113 | /* static */
|
---|
114 | UIMachine *UIMachine::s_pInstance = 0;
|
---|
115 |
|
---|
116 | /* static */
|
---|
117 | bool UIMachine::startMachine()
|
---|
118 | {
|
---|
119 | /* Make sure machine is not created: */
|
---|
120 | AssertReturn(!s_pInstance, false);
|
---|
121 |
|
---|
122 | /* Restore current snapshot if requested: */
|
---|
123 | if (uiCommon().shouldRestoreCurrentSnapshot())
|
---|
124 | {
|
---|
125 | /* Create temporary session: */
|
---|
126 | CSession comSession = uiCommon().openSession(KLockType_VM);
|
---|
127 | if (comSession.isNull())
|
---|
128 | return false;
|
---|
129 |
|
---|
130 | /* Which VM we operate on? */
|
---|
131 | CMachine comMachine = comSession.GetMachine();
|
---|
132 | /* Which snapshot we are restoring? */
|
---|
133 | CSnapshot comSnapshot = comMachine.GetCurrentSnapshot();
|
---|
134 |
|
---|
135 | /* Prepare restore-snapshot progress: */
|
---|
136 | CProgress comProgress = comMachine.RestoreSnapshot(comSnapshot);
|
---|
137 | if (!comMachine.isOk())
|
---|
138 | return msgCenter().cannotRestoreSnapshot(comMachine, comSnapshot.GetName(), comMachine.GetName());
|
---|
139 |
|
---|
140 | /* Show the snapshot-discarding progress: */
|
---|
141 | msgCenter().showModalProgressDialog(comProgress, comMachine.GetName(), ":/progress_snapshot_discard_90px.png");
|
---|
142 | if (comProgress.GetResultCode() != 0)
|
---|
143 | return msgCenter().cannotRestoreSnapshot(comProgress, comSnapshot.GetName(), comMachine.GetName());
|
---|
144 |
|
---|
145 | /* Unlock session finally: */
|
---|
146 | comSession.UnlockMachine();
|
---|
147 |
|
---|
148 | /* Clear snapshot-restoring request: */
|
---|
149 | uiCommon().setShouldRestoreCurrentSnapshot(false);
|
---|
150 | }
|
---|
151 |
|
---|
152 | /* For separate process we should launch VM before UI: */
|
---|
153 | if (uiCommon().isSeparateProcess())
|
---|
154 | {
|
---|
155 | /* Get corresponding machine: */
|
---|
156 | CMachine machine = gpGlobalSession->virtualBox().FindMachine(uiCommon().managedVMUuid().toString());
|
---|
157 | AssertMsgReturn(!machine.isNull(), ("UICommon::managedVMUuid() should have filter that case before!\n"), false);
|
---|
158 |
|
---|
159 | /* Try to launch corresponding machine: */
|
---|
160 | if (!UICommon::launchMachine(machine, UILaunchMode_Separate))
|
---|
161 | return false;
|
---|
162 | }
|
---|
163 |
|
---|
164 | /* Try to create machine UI: */
|
---|
165 | return create();
|
---|
166 | }
|
---|
167 |
|
---|
168 | /* static */
|
---|
169 | bool UIMachine::create()
|
---|
170 | {
|
---|
171 | /* Make sure machine is not created: */
|
---|
172 | AssertReturn(!s_pInstance, false);
|
---|
173 |
|
---|
174 | /* Create machine UI: */
|
---|
175 | new UIMachine;
|
---|
176 |
|
---|
177 | /* Make sure it's prepared: */
|
---|
178 | if (!s_pInstance->prepare())
|
---|
179 | {
|
---|
180 | /* Destroy machine UI otherwise: */
|
---|
181 | destroy();
|
---|
182 | /* False in that case: */
|
---|
183 | return false;
|
---|
184 | }
|
---|
185 |
|
---|
186 | /* True by default: */
|
---|
187 | return true;
|
---|
188 | }
|
---|
189 |
|
---|
190 | /* static */
|
---|
191 | void UIMachine::destroy()
|
---|
192 | {
|
---|
193 | /* Make sure machine is created: */
|
---|
194 | if (!s_pInstance)
|
---|
195 | return;
|
---|
196 |
|
---|
197 | /* Protect versus recursive call: */
|
---|
198 | UIMachine *pInstance = s_pInstance;
|
---|
199 | s_pInstance = 0;
|
---|
200 | /* Cleanup machine UI: */
|
---|
201 | pInstance->cleanup();
|
---|
202 | /* Destroy machine UI: */
|
---|
203 | delete pInstance;
|
---|
204 | }
|
---|
205 |
|
---|
206 | UIFrameBuffer *UIMachine::frameBuffer(ulong uScreenId)
|
---|
207 | {
|
---|
208 | return uisession()->frameBuffer(uScreenId);
|
---|
209 | }
|
---|
210 |
|
---|
211 | QWidget* UIMachine::activeWindow() const
|
---|
212 | {
|
---|
213 | return machineLogic() && machineLogic()->activeMachineWindow()
|
---|
214 | ? machineLogic()->activeMachineWindow()
|
---|
215 | : 0;
|
---|
216 | }
|
---|
217 |
|
---|
218 | bool UIMachine::isSessionValid() const
|
---|
219 | {
|
---|
220 | return uisession() ? uisession()->isValid() : false;
|
---|
221 | }
|
---|
222 |
|
---|
223 | void UIMachine::asyncChangeVisualState(UIVisualStateType visualState)
|
---|
224 | {
|
---|
225 | emit sigRequestAsyncVisualStateChange(visualState);
|
---|
226 | }
|
---|
227 |
|
---|
228 | void UIMachine::setRequestedVisualState(UIVisualStateType visualStateType)
|
---|
229 | {
|
---|
230 | /* Remember requested visual state: */
|
---|
231 | m_enmRequestedVisualState = visualStateType;
|
---|
232 |
|
---|
233 | /* Save only if it's different from Invalid and from current one: */
|
---|
234 | if ( m_enmRequestedVisualState != UIVisualStateType_Invalid
|
---|
235 | && gEDataManager->requestedVisualState(uiCommon().managedVMUuid()) != m_enmRequestedVisualState)
|
---|
236 | gEDataManager->setRequestedVisualState(m_enmRequestedVisualState, uiCommon().managedVMUuid());
|
---|
237 | }
|
---|
238 |
|
---|
239 | UIVisualStateType UIMachine::requestedVisualState() const
|
---|
240 | {
|
---|
241 | return m_enmRequestedVisualState;
|
---|
242 | }
|
---|
243 |
|
---|
244 | QString UIMachine::machineName() const
|
---|
245 | {
|
---|
246 | return uisession()->machineName();
|
---|
247 | }
|
---|
248 |
|
---|
249 | QString UIMachine::osTypeId() const
|
---|
250 | {
|
---|
251 | return uisession()->osTypeId();
|
---|
252 | }
|
---|
253 |
|
---|
254 | void UIMachine::acquireMachinePixmap(const QSize &size, QPixmap &pixmap)
|
---|
255 | {
|
---|
256 | return uisession()->acquireMachinePixmap(size, pixmap);
|
---|
257 | }
|
---|
258 |
|
---|
259 | void UIMachine::acquireUserMachineIcon(QIcon &icon)
|
---|
260 | {
|
---|
261 | return uisession()->acquireUserMachineIcon(icon);
|
---|
262 | }
|
---|
263 |
|
---|
264 | bool UIMachine::acquireArchitectureType(KPlatformArchitecture &enmType)
|
---|
265 | {
|
---|
266 | return uisession()->acquireArchitectureType(enmType);
|
---|
267 | }
|
---|
268 |
|
---|
269 | bool UIMachine::acquireChipsetType(KChipsetType &enmType)
|
---|
270 | {
|
---|
271 | return uisession()->acquireChipsetType(enmType);
|
---|
272 | }
|
---|
273 |
|
---|
274 | void UIMachine::updateStateAdditionsActions()
|
---|
275 | {
|
---|
276 | /* Make sure action-pool knows whether GA supports graphics: */
|
---|
277 | actionPool()->toRuntime()->setGuestSupportsGraphics(isGuestSupportsGraphics());
|
---|
278 | /* Enable/Disable Upgrade Additions action depending on feature status: */
|
---|
279 | actionPool()->action(UIActionIndexRT_M_Devices_S_UpgradeGuestAdditions)->setEnabled(uisession()->guestAdditionsUpgradable());
|
---|
280 | }
|
---|
281 |
|
---|
282 | void UIMachine::updateStateAudioActions()
|
---|
283 | {
|
---|
284 | /* Make sure Audio adapter is present: */
|
---|
285 | bool fAdapterPresent = false;
|
---|
286 | acquireWhetherAudioAdapterPresent(fAdapterPresent);
|
---|
287 | if (fAdapterPresent)
|
---|
288 | {
|
---|
289 | /* Check/Uncheck Audio adapter output/input actions depending on features status: */
|
---|
290 | bool fAudioOutputEnabled = false;
|
---|
291 | bool fAudioInputEnabled = false;
|
---|
292 | acquireWhetherAudioAdapterOutputEnabled(fAudioOutputEnabled);
|
---|
293 | acquireWhetherAudioAdapterInputEnabled(fAudioInputEnabled);
|
---|
294 | actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Output)->blockSignals(true);
|
---|
295 | actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Output)->setChecked(fAudioOutputEnabled);
|
---|
296 | actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Output)->blockSignals(false);
|
---|
297 | actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Input)->blockSignals(true);
|
---|
298 | actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Input)->setChecked(fAudioInputEnabled);
|
---|
299 | actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Input)->blockSignals(false);
|
---|
300 | }
|
---|
301 | }
|
---|
302 |
|
---|
303 | void UIMachine::updateStateRecordingAction()
|
---|
304 | {
|
---|
305 | /* Make sure Recording settings present: */
|
---|
306 | bool fSettingsPresent = false;
|
---|
307 | acquireWhetherRecordingSettingsPresent(fSettingsPresent);
|
---|
308 | AssertMsgReturnVoid(fSettingsPresent,
|
---|
309 | ("Recording settings can't be null!\n"));
|
---|
310 |
|
---|
311 | /* Check/Uncheck Recording action depending on feature status: */
|
---|
312 | bool fSettingsEnabled = false;
|
---|
313 | acquireWhetherRecordingSettingsEnabled(fSettingsEnabled);
|
---|
314 | actionPool()->action(UIActionIndexRT_M_View_M_Recording_T_Start)->blockSignals(true);
|
---|
315 | actionPool()->action(UIActionIndexRT_M_View_M_Recording_T_Start)->setChecked(fSettingsEnabled);
|
---|
316 | actionPool()->action(UIActionIndexRT_M_View_M_Recording_T_Start)->blockSignals(false);
|
---|
317 | }
|
---|
318 |
|
---|
319 | void UIMachine::updateStateVRDEServerAction()
|
---|
320 | {
|
---|
321 | /* Make sure VRDE server present: */
|
---|
322 | bool fServerPresent = false;
|
---|
323 | acquireWhetherVRDEServerPresent(fServerPresent);
|
---|
324 | AssertMsgReturnVoid(fServerPresent,
|
---|
325 | ("VRDE server can't be null!\n"));
|
---|
326 |
|
---|
327 | /* Check/Uncheck VRDE Server action depending on feature status: */
|
---|
328 | bool fServerEnabled = false;
|
---|
329 | acquireWhetherVRDEServerEnabled(fServerEnabled);
|
---|
330 | actionPool()->action(UIActionIndexRT_M_View_T_VRDEServer)->blockSignals(true);
|
---|
331 | actionPool()->action(UIActionIndexRT_M_View_T_VRDEServer)->setChecked(fServerEnabled);
|
---|
332 | actionPool()->action(UIActionIndexRT_M_View_T_VRDEServer)->blockSignals(false);
|
---|
333 | }
|
---|
334 |
|
---|
335 | KMachineState UIMachine::machineStatePrevious() const
|
---|
336 | {
|
---|
337 | return uisession()->machineStatePrevious();
|
---|
338 | }
|
---|
339 |
|
---|
340 | KMachineState UIMachine::machineState() const
|
---|
341 | {
|
---|
342 | return uisession()->machineState();
|
---|
343 | }
|
---|
344 |
|
---|
345 | void UIMachine::forgetPreviousMachineState()
|
---|
346 | {
|
---|
347 | uisession()->forgetPreviousMachineState();
|
---|
348 | }
|
---|
349 |
|
---|
350 | bool UIMachine::acquireLiveMachineState(KMachineState &enmState)
|
---|
351 | {
|
---|
352 | return uisession()->acquireLiveMachineState(enmState);
|
---|
353 | }
|
---|
354 |
|
---|
355 | bool UIMachine::isTurnedOff() const
|
---|
356 | {
|
---|
357 | return uisession()->isTurnedOff();
|
---|
358 | }
|
---|
359 |
|
---|
360 | bool UIMachine::isPaused() const
|
---|
361 | {
|
---|
362 | return uisession()->isPaused();
|
---|
363 | }
|
---|
364 |
|
---|
365 | bool UIMachine::wasPaused() const
|
---|
366 | {
|
---|
367 | return uisession()->wasPaused();
|
---|
368 | }
|
---|
369 |
|
---|
370 | bool UIMachine::isRunning() const
|
---|
371 | {
|
---|
372 | return uisession()->isRunning();
|
---|
373 | }
|
---|
374 |
|
---|
375 | bool UIMachine::isStuck() const
|
---|
376 | {
|
---|
377 | return uisession()->isStuck();
|
---|
378 | }
|
---|
379 |
|
---|
380 | bool UIMachine::isGuestScreenUnDrawable() const
|
---|
381 | {
|
---|
382 | return uisession()->isGuestScreenUnDrawable();
|
---|
383 | }
|
---|
384 |
|
---|
385 | bool UIMachine::reset()
|
---|
386 | {
|
---|
387 | return uisession()->reset();
|
---|
388 | }
|
---|
389 |
|
---|
390 | bool UIMachine::pause()
|
---|
391 | {
|
---|
392 | return uisession()->pause();
|
---|
393 | }
|
---|
394 |
|
---|
395 | bool UIMachine::unpause()
|
---|
396 | {
|
---|
397 | return uisession()->unpause();
|
---|
398 | }
|
---|
399 |
|
---|
400 | bool UIMachine::setPause(bool fPause)
|
---|
401 | {
|
---|
402 | return uisession()->setPause(fPause);
|
---|
403 | }
|
---|
404 |
|
---|
405 | bool UIMachine::acquireSettingsFilePath(QString &strPath)
|
---|
406 | {
|
---|
407 | return uisession()->acquireSettingsFilePath(strPath);
|
---|
408 | }
|
---|
409 |
|
---|
410 | bool UIMachine::saveSettings()
|
---|
411 | {
|
---|
412 | return uisession()->saveSettings();
|
---|
413 | }
|
---|
414 |
|
---|
415 | bool UIMachine::acquireSnapshotCount(ulong &uCount)
|
---|
416 | {
|
---|
417 | return uisession()->acquireSnapshotCount(uCount);
|
---|
418 | }
|
---|
419 |
|
---|
420 | bool UIMachine::acquireCurrentSnapshotName(QString &strName)
|
---|
421 | {
|
---|
422 | return uisession()->acquireCurrentSnapshotName(strName);
|
---|
423 | }
|
---|
424 |
|
---|
425 | bool UIMachine::acquireMaxSnapshotIndex(const QString &strNameTemplate, ulong &uIndex)
|
---|
426 | {
|
---|
427 | return uisession()->acquireMaxSnapshotIndex(strNameTemplate, uIndex);
|
---|
428 | }
|
---|
429 |
|
---|
430 | void UIMachine::takeSnapshot(const QString &strName, const QString &strDescription)
|
---|
431 | {
|
---|
432 | return uisession()->takeSnapshot(strName, strDescription);
|
---|
433 | }
|
---|
434 |
|
---|
435 | bool UIMachine::acquireWhetherAudioAdapterPresent(bool &fPresent)
|
---|
436 | {
|
---|
437 | return uisession()->acquireWhetherAudioAdapterPresent(fPresent);
|
---|
438 | }
|
---|
439 |
|
---|
440 | bool UIMachine::acquireWhetherAudioAdapterEnabled(bool &fEnabled)
|
---|
441 | {
|
---|
442 | return uisession()->acquireWhetherAudioAdapterEnabled(fEnabled);
|
---|
443 | }
|
---|
444 |
|
---|
445 | bool UIMachine::acquireWhetherAudioAdapterOutputEnabled(bool &fEnabled)
|
---|
446 | {
|
---|
447 | return uisession()->acquireWhetherAudioAdapterOutputEnabled(fEnabled);
|
---|
448 | }
|
---|
449 |
|
---|
450 | bool UIMachine::acquireWhetherAudioAdapterInputEnabled(bool &fEnabled)
|
---|
451 | {
|
---|
452 | return uisession()->acquireWhetherAudioAdapterInputEnabled(fEnabled);
|
---|
453 | }
|
---|
454 |
|
---|
455 | bool UIMachine::setAudioAdapterOutputEnabled(bool fEnabled)
|
---|
456 | {
|
---|
457 | return uisession()->setAudioAdapterOutputEnabled(fEnabled);
|
---|
458 | }
|
---|
459 |
|
---|
460 | bool UIMachine::setAudioAdapterInputEnabled(bool fEnabled)
|
---|
461 | {
|
---|
462 | return uisession()->setAudioAdapterInputEnabled(fEnabled);
|
---|
463 | }
|
---|
464 |
|
---|
465 | bool UIMachine::isScreenVisibleHostDesires(ulong uScreenId) const
|
---|
466 | {
|
---|
467 | /* Make sure index feats the bounds: */
|
---|
468 | AssertReturn(uScreenId < (ulong)m_guestScreenVisibilityVectorHostDesires.size(), false);
|
---|
469 |
|
---|
470 | /* Return 'actual' (host-desire) visibility status: */
|
---|
471 | return m_guestScreenVisibilityVectorHostDesires.value((int)uScreenId);
|
---|
472 | }
|
---|
473 |
|
---|
474 | void UIMachine::setScreenVisibleHostDesires(ulong uScreenId, bool fIsMonitorVisible)
|
---|
475 | {
|
---|
476 | /* Make sure index feats the bounds: */
|
---|
477 | AssertReturnVoid(uScreenId < (ulong)m_guestScreenVisibilityVectorHostDesires.size());
|
---|
478 |
|
---|
479 | /* Remember 'actual' (host-desire) visibility status: */
|
---|
480 | m_guestScreenVisibilityVectorHostDesires[(int)uScreenId] = fIsMonitorVisible;
|
---|
481 |
|
---|
482 | /* And remember the request in extra data for guests with VMSVGA: */
|
---|
483 | /* This should be done before the actual hint is sent in case the guest overrides it. */
|
---|
484 | gEDataManager->setLastGuestScreenVisibilityStatus(uScreenId, fIsMonitorVisible, uiCommon().managedVMUuid());
|
---|
485 | }
|
---|
486 |
|
---|
487 | bool UIMachine::isScreenVisible(ulong uScreenId) const
|
---|
488 | {
|
---|
489 | /* Make sure index feats the bounds: */
|
---|
490 | AssertReturn(uScreenId < (ulong)m_guestScreenVisibilityVector.size(), false);
|
---|
491 |
|
---|
492 | /* Return 'actual' visibility status: */
|
---|
493 | return m_guestScreenVisibilityVector.value((int)uScreenId);
|
---|
494 | }
|
---|
495 |
|
---|
496 | void UIMachine::setScreenVisible(ulong uScreenId, bool fIsMonitorVisible)
|
---|
497 | {
|
---|
498 | /* Make sure index feats the bounds: */
|
---|
499 | AssertReturnVoid(uScreenId < (ulong)m_guestScreenVisibilityVector.size());
|
---|
500 |
|
---|
501 | /* Remember 'actual' visibility status: */
|
---|
502 | m_guestScreenVisibilityVector[(int)uScreenId] = fIsMonitorVisible;
|
---|
503 | /* Remember 'desired' visibility status: */
|
---|
504 | // See note in UIMachineView::sltHandleNotifyChange() regarding the graphics controller check. */
|
---|
505 | KGraphicsControllerType enmType = KGraphicsControllerType_Null;
|
---|
506 | acquireGraphicsControllerType(enmType);
|
---|
507 | if (enmType != KGraphicsControllerType_VMSVGA)
|
---|
508 | gEDataManager->setLastGuestScreenVisibilityStatus(uScreenId, fIsMonitorVisible, uiCommon().managedVMUuid());
|
---|
509 |
|
---|
510 | /* Make sure action-pool knows guest-screen visibility status: */
|
---|
511 | actionPool()->toRuntime()->setGuestScreenVisible(uScreenId, fIsMonitorVisible);
|
---|
512 | }
|
---|
513 |
|
---|
514 | int UIMachine::countOfVisibleWindows()
|
---|
515 | {
|
---|
516 | int cCountOfVisibleWindows = 0;
|
---|
517 | for (int i = 0; i < m_guestScreenVisibilityVector.size(); ++i)
|
---|
518 | if (m_guestScreenVisibilityVector[i])
|
---|
519 | ++cCountOfVisibleWindows;
|
---|
520 | return cCountOfVisibleWindows;
|
---|
521 | }
|
---|
522 |
|
---|
523 | QList<int> UIMachine::listOfVisibleWindows() const
|
---|
524 | {
|
---|
525 | QList<int> visibleWindows;
|
---|
526 | for (int i = 0; i < m_guestScreenVisibilityVector.size(); ++i)
|
---|
527 | if (m_guestScreenVisibilityVector.at(i))
|
---|
528 | visibleWindows.push_back(i);
|
---|
529 | return visibleWindows;
|
---|
530 | }
|
---|
531 |
|
---|
532 | QSize UIMachine::guestScreenSize(ulong uScreenId) const
|
---|
533 | {
|
---|
534 | return uisession()->frameBufferSize(uScreenId);
|
---|
535 | }
|
---|
536 |
|
---|
537 | QSize UIMachine::lastFullScreenSize(ulong uScreenId) const
|
---|
538 | {
|
---|
539 | /* Make sure index fits the bounds: */
|
---|
540 | AssertReturn(uScreenId < (ulong)m_monitorLastFullScreenSizeVector.size(), QSize(-1, -1));
|
---|
541 |
|
---|
542 | /* Return last full-screen size: */
|
---|
543 | return m_monitorLastFullScreenSizeVector.value((int)uScreenId);
|
---|
544 | }
|
---|
545 |
|
---|
546 | void UIMachine::setLastFullScreenSize(ulong uScreenId, QSize size)
|
---|
547 | {
|
---|
548 | /* Make sure index fits the bounds: */
|
---|
549 | AssertReturnVoid(uScreenId < (ulong)m_monitorLastFullScreenSizeVector.size());
|
---|
550 |
|
---|
551 | /* Remember last full-screen size: */
|
---|
552 | m_monitorLastFullScreenSizeVector[(int)uScreenId] = size;
|
---|
553 | }
|
---|
554 |
|
---|
555 | bool UIMachine::acquireGraphicsControllerType(KGraphicsControllerType &enmType)
|
---|
556 | {
|
---|
557 | return uisession()->acquireGraphicsControllerType(enmType);
|
---|
558 | }
|
---|
559 |
|
---|
560 | bool UIMachine::acquireVRAMSize(ulong &uSize)
|
---|
561 | {
|
---|
562 | return uisession()->acquireVRAMSize(uSize);
|
---|
563 | }
|
---|
564 |
|
---|
565 | bool UIMachine::acquireWhetherAccelerate3DEnabled(bool &fEnabled)
|
---|
566 | {
|
---|
567 | return uisession()->acquireWhetherAccelerate3DEnabled(fEnabled);
|
---|
568 | }
|
---|
569 |
|
---|
570 | bool UIMachine::acquireMonitorCount(ulong &uCount)
|
---|
571 | {
|
---|
572 | return uisession()->acquireMonitorCount(uCount);
|
---|
573 | }
|
---|
574 |
|
---|
575 | bool UIMachine::acquireGuestScreenParameters(ulong uScreenId,
|
---|
576 | ulong &uWidth, ulong &uHeight, ulong &uBitsPerPixel,
|
---|
577 | long &xOrigin, long &yOrigin, KGuestMonitorStatus &enmMonitorStatus)
|
---|
578 | {
|
---|
579 | return uisession()->acquireGuestScreenParameters(uScreenId,
|
---|
580 | uWidth, uHeight, uBitsPerPixel,
|
---|
581 | xOrigin, yOrigin, enmMonitorStatus);
|
---|
582 | }
|
---|
583 |
|
---|
584 | bool UIMachine::acquireSavedGuestScreenInfo(ulong uScreenId,
|
---|
585 | long &xOrigin, long &yOrigin,
|
---|
586 | ulong &uWidth, ulong &uHeight, bool &fEnabled)
|
---|
587 | {
|
---|
588 | return uisession()->acquireSavedGuestScreenInfo(uScreenId,
|
---|
589 | xOrigin, yOrigin,
|
---|
590 | uWidth, uHeight, fEnabled);
|
---|
591 | }
|
---|
592 |
|
---|
593 | bool UIMachine::setVideoModeHint(ulong uScreenId, bool fEnabled, bool fChangeOrigin,
|
---|
594 | long xOrigin, long yOrigin, ulong uWidth, ulong uHeight,
|
---|
595 | ulong uBitsPerPixel, bool fNotify)
|
---|
596 | {
|
---|
597 | return uisession()->setVideoModeHint(uScreenId, fEnabled, fChangeOrigin,
|
---|
598 | xOrigin, yOrigin, uWidth, uHeight,
|
---|
599 | uBitsPerPixel, fNotify);
|
---|
600 | }
|
---|
601 |
|
---|
602 | bool UIMachine::acquireVideoModeHint(ulong uScreenId, bool &fEnabled, bool &fChangeOrigin,
|
---|
603 | long &xOrigin, long &yOrigin, ulong &uWidth, ulong &uHeight,
|
---|
604 | ulong &uBitsPerPixel)
|
---|
605 | {
|
---|
606 | return uisession()->acquireVideoModeHint(uScreenId, fEnabled, fChangeOrigin,
|
---|
607 | xOrigin, yOrigin, uWidth, uHeight,
|
---|
608 | uBitsPerPixel);
|
---|
609 | }
|
---|
610 |
|
---|
611 | bool UIMachine::acquireScreenShot(ulong uScreenId, ulong uWidth, ulong uHeight, KBitmapFormat enmFormat, uchar *pBits)
|
---|
612 | {
|
---|
613 | return uisession()->acquireScreenShot(uScreenId, uWidth, uHeight, enmFormat, pBits);
|
---|
614 | }
|
---|
615 |
|
---|
616 | bool UIMachine::acquireSavedScreenshotInfo(ulong uScreenId, ulong &uWidth, ulong &uHeight, QVector<KBitmapFormat> &formats)
|
---|
617 | {
|
---|
618 | return uisession()->acquireSavedScreenshotInfo(uScreenId, uWidth, uHeight, formats);
|
---|
619 | }
|
---|
620 |
|
---|
621 | bool UIMachine::acquireSavedScreenshot(ulong uScreenId, KBitmapFormat enmFormat,
|
---|
622 | ulong &uWidth, ulong &uHeight, QVector<BYTE> &screenshot)
|
---|
623 | {
|
---|
624 | return uisession()->acquireSavedScreenshot(uScreenId, enmFormat,
|
---|
625 | uWidth, uHeight, screenshot);
|
---|
626 | }
|
---|
627 |
|
---|
628 | bool UIMachine::notifyScaleFactorChange(ulong uScreenId, ulong uScaleFactorWMultiplied, ulong uScaleFactorHMultiplied)
|
---|
629 | {
|
---|
630 | return uisession()->notifyScaleFactorChange(uScreenId, uScaleFactorWMultiplied, uScaleFactorHMultiplied);
|
---|
631 | }
|
---|
632 |
|
---|
633 | bool UIMachine::notifyHiDPIOutputPolicyChange(bool fUnscaledHiDPI)
|
---|
634 | {
|
---|
635 | return uisession()->notifyHiDPIOutputPolicyChange(fUnscaledHiDPI);
|
---|
636 | }
|
---|
637 |
|
---|
638 | bool UIMachine::setSeamlessMode(bool fEnabled)
|
---|
639 | {
|
---|
640 | return uisession()->setSeamlessMode(fEnabled);
|
---|
641 | }
|
---|
642 |
|
---|
643 | bool UIMachine::viewportChanged(ulong uScreenId, ulong xOrigin, ulong yOrigin, ulong uWidth, ulong uHeight)
|
---|
644 | {
|
---|
645 | return uisession()->viewportChanged(uScreenId, xOrigin, yOrigin, uWidth, uHeight);
|
---|
646 | }
|
---|
647 |
|
---|
648 | bool UIMachine::invalidateAndUpdate()
|
---|
649 | {
|
---|
650 | return uisession()->invalidateAndUpdate();
|
---|
651 | }
|
---|
652 |
|
---|
653 | bool UIMachine::invalidateAndUpdateScreen(ulong uScreenId)
|
---|
654 | {
|
---|
655 | return uisession()->invalidateAndUpdateScreen(uScreenId);
|
---|
656 | }
|
---|
657 |
|
---|
658 | bool UIMachine::acquireWhetherVRDEServerPresent(bool &fPresent)
|
---|
659 | {
|
---|
660 | return uisession()->acquireWhetherVRDEServerPresent(fPresent);
|
---|
661 | }
|
---|
662 |
|
---|
663 | bool UIMachine::acquireWhetherVRDEServerEnabled(bool &fEnabled)
|
---|
664 | {
|
---|
665 | return uisession()->acquireWhetherVRDEServerEnabled(fEnabled);
|
---|
666 | }
|
---|
667 |
|
---|
668 | bool UIMachine::setVRDEServerEnabled(bool fEnabled)
|
---|
669 | {
|
---|
670 | return uisession()->setVRDEServerEnabled(fEnabled);
|
---|
671 | }
|
---|
672 |
|
---|
673 | bool UIMachine::acquireVRDEServerPort(long &iPort)
|
---|
674 | {
|
---|
675 | return uisession()->acquireVRDEServerPort(iPort);
|
---|
676 | }
|
---|
677 |
|
---|
678 | bool UIMachine::acquireWhetherRecordingSettingsPresent(bool &fPresent)
|
---|
679 | {
|
---|
680 | return uisession()->acquireWhetherRecordingSettingsPresent(fPresent);
|
---|
681 | }
|
---|
682 |
|
---|
683 | bool UIMachine::acquireWhetherRecordingSettingsEnabled(bool &fEnabled)
|
---|
684 | {
|
---|
685 | return uisession()->acquireWhetherRecordingSettingsEnabled(fEnabled);
|
---|
686 | }
|
---|
687 |
|
---|
688 | bool UIMachine::setRecordingSettingsEnabled(bool fEnabled)
|
---|
689 | {
|
---|
690 | return uisession()->setRecordingSettingsEnabled(fEnabled);
|
---|
691 | }
|
---|
692 |
|
---|
693 | bool UIMachine::isGuestAdditionsActive() const
|
---|
694 | {
|
---|
695 | return uisession()->isGuestAdditionsActive();
|
---|
696 | }
|
---|
697 |
|
---|
698 | bool UIMachine::isGuestSupportsGraphics() const
|
---|
699 | {
|
---|
700 | return uisession()->isGuestSupportsGraphics();
|
---|
701 | }
|
---|
702 |
|
---|
703 | bool UIMachine::isGuestSupportsSeamless() const
|
---|
704 | {
|
---|
705 | return uisession()->isGuestSupportsSeamless();
|
---|
706 | }
|
---|
707 |
|
---|
708 | bool UIMachine::acquireGuestAdditionsVersion(QString &strVersion)
|
---|
709 | {
|
---|
710 | return uisession()->acquireGuestAdditionsVersion(strVersion);
|
---|
711 | }
|
---|
712 |
|
---|
713 | bool UIMachine::acquireGuestAdditionsRevision(ulong &uRevision)
|
---|
714 | {
|
---|
715 | return uisession()->acquireGuestAdditionsRevision(uRevision);
|
---|
716 | }
|
---|
717 |
|
---|
718 | bool UIMachine::notifyGuiFocusChange(bool fInfocus)
|
---|
719 | {
|
---|
720 | return uisession()->notifyGuiFocusChange(fInfocus);
|
---|
721 | }
|
---|
722 |
|
---|
723 | bool UIMachine::putScancode(LONG iCode)
|
---|
724 | {
|
---|
725 | return uisession()->putScancode(iCode);
|
---|
726 | }
|
---|
727 |
|
---|
728 | bool UIMachine::putScancodes(const QVector<LONG> &codes)
|
---|
729 | {
|
---|
730 | return uisession()->putScancodes(codes);
|
---|
731 | }
|
---|
732 |
|
---|
733 | bool UIMachine::putCAD()
|
---|
734 | {
|
---|
735 | return uisession()->putCAD();
|
---|
736 | }
|
---|
737 |
|
---|
738 | bool UIMachine::releaseKeys()
|
---|
739 | {
|
---|
740 | return uisession()->releaseKeys();
|
---|
741 | }
|
---|
742 |
|
---|
743 | bool UIMachine::putUsageCode(LONG iUsageCode, LONG iUsagePage, bool fKeyRelease)
|
---|
744 | {
|
---|
745 | return uisession()->putUsageCode(iUsageCode, iUsagePage, fKeyRelease);
|
---|
746 | }
|
---|
747 |
|
---|
748 | bool UIMachine::putMouseEvent(long iDx, long iDy, long iDz, long iDw, long iButtonState)
|
---|
749 | {
|
---|
750 | return uisession()->putMouseEvent(iDx, iDy, iDz, iDw, iButtonState);
|
---|
751 | }
|
---|
752 |
|
---|
753 | bool UIMachine::putMouseEventAbsolute(long iX, long iY, long iDz, long iDw, long iButtonState)
|
---|
754 | {
|
---|
755 | return uisession()->putMouseEventAbsolute(iX, iY, iDz, iDw, iButtonState);
|
---|
756 | }
|
---|
757 |
|
---|
758 | bool UIMachine::putEventMultiTouch(long iCount, const QVector<LONG64> &contacts, bool fIsTouchScreen, ulong uScanTime)
|
---|
759 | {
|
---|
760 | return uisession()->putEventMultiTouch(iCount, contacts, fIsTouchScreen, uScanTime);
|
---|
761 | }
|
---|
762 |
|
---|
763 | bool UIMachine::acquireClipboardMode(KClipboardMode &enmMode)
|
---|
764 | {
|
---|
765 | return uisession()->acquireClipboardMode(enmMode);
|
---|
766 | }
|
---|
767 |
|
---|
768 | bool UIMachine::setClipboardMode(KClipboardMode enmMode)
|
---|
769 | {
|
---|
770 | return uisession()->setClipboardMode(enmMode);
|
---|
771 | }
|
---|
772 |
|
---|
773 | bool UIMachine::toggleClipboardFileTransfer(bool fEnabled)
|
---|
774 | {
|
---|
775 | return uisession()->toggleClipboardFileTransfer(fEnabled);
|
---|
776 | }
|
---|
777 |
|
---|
778 | bool UIMachine::isClipboardFileTransferEnabled()
|
---|
779 | {
|
---|
780 | return uisession()->isClipboardFileTransferEnabled();
|
---|
781 | }
|
---|
782 |
|
---|
783 | bool UIMachine::acquireDnDMode(KDnDMode &enmMode)
|
---|
784 | {
|
---|
785 | return uisession()->acquireDnDMode(enmMode);
|
---|
786 | }
|
---|
787 |
|
---|
788 | bool UIMachine::setDnDMode(KDnDMode enmMode)
|
---|
789 | {
|
---|
790 | return uisession()->setDnDMode(enmMode);
|
---|
791 | }
|
---|
792 |
|
---|
793 | bool UIMachine::acquireAmountOfStorageDevices(ulong &cHardDisks, ulong &cOpticalDrives, ulong &cFloppyDrives)
|
---|
794 | {
|
---|
795 | return uisession()->acquireAmountOfStorageDevices(cHardDisks, cOpticalDrives, cFloppyDrives);
|
---|
796 | }
|
---|
797 |
|
---|
798 | bool UIMachine::storageDevices(KDeviceType enmDeviceType, QList<StorageDeviceInfo> &guiStorageDevices)
|
---|
799 | {
|
---|
800 | return uisession()->storageDevices(enmDeviceType, guiStorageDevices);
|
---|
801 | }
|
---|
802 |
|
---|
803 | bool UIMachine::acquireEncryptedMedia(EncryptedMediumMap &media)
|
---|
804 | {
|
---|
805 | return uisession()->acquireEncryptedMedia(media);
|
---|
806 | }
|
---|
807 |
|
---|
808 | bool UIMachine::addEncryptionPassword(const QString &strId, const QString &strPassword, bool fClearOnSuspend)
|
---|
809 | {
|
---|
810 | return uisession()->addEncryptionPassword(strId, strPassword, fClearOnSuspend);
|
---|
811 | }
|
---|
812 |
|
---|
813 | bool UIMachine::acquireAmountOfImmutableImages(ulong &cAmount)
|
---|
814 | {
|
---|
815 | return uisession()->acquireAmountOfImmutableImages(cAmount);
|
---|
816 | }
|
---|
817 |
|
---|
818 | bool UIMachine::mountBootMedium(const QUuid &uMediumId)
|
---|
819 | {
|
---|
820 | return uisession()->mountBootMedium(uMediumId);
|
---|
821 | }
|
---|
822 |
|
---|
823 | void UIMachine::prepareStorageMenu(QMenu *pMenu,
|
---|
824 | QObject *pListener, const char *pszSlotName,
|
---|
825 | const QString &strControllerName, const StorageSlot &storageSlot)
|
---|
826 | {
|
---|
827 | return uisession()->prepareStorageMenu(pMenu,
|
---|
828 | pListener, pszSlotName,
|
---|
829 | strControllerName, storageSlot);
|
---|
830 | }
|
---|
831 |
|
---|
832 | void UIMachine::updateMachineStorage(const UIMediumTarget &target, UIActionPool *pActionPool)
|
---|
833 | {
|
---|
834 | return uisession()->updateMachineStorage(target, pActionPool);
|
---|
835 | }
|
---|
836 |
|
---|
837 | void UIMachine::acquireWhetherUSBControllerEnabled(bool &fEnabled)
|
---|
838 | {
|
---|
839 | return uisession()->acquireWhetherUSBControllerEnabled(fEnabled);
|
---|
840 | }
|
---|
841 |
|
---|
842 | void UIMachine::acquireWhetherVideoInputDevicesEnabled(bool &fEnabled)
|
---|
843 | {
|
---|
844 | return uisession()->acquireWhetherVideoInputDevicesEnabled(fEnabled);
|
---|
845 | }
|
---|
846 |
|
---|
847 | bool UIMachine::usbDevices(QList<USBDeviceInfo> &guiUSBDevices)
|
---|
848 | {
|
---|
849 | return uisession()->usbDevices(guiUSBDevices);
|
---|
850 | }
|
---|
851 |
|
---|
852 | bool UIMachine::attachUSBDevice(const QUuid &uId)
|
---|
853 | {
|
---|
854 | return uisession()->attachUSBDevice(uId);
|
---|
855 | }
|
---|
856 |
|
---|
857 | bool UIMachine::detachUSBDevice(const QUuid &uId)
|
---|
858 | {
|
---|
859 | return uisession()->detachUSBDevice(uId);
|
---|
860 | }
|
---|
861 |
|
---|
862 | bool UIMachine::webcamDevices(QList<WebcamDeviceInfo> &guiWebcamDevices)
|
---|
863 | {
|
---|
864 | return uisession()->webcamDevices(guiWebcamDevices);
|
---|
865 | }
|
---|
866 |
|
---|
867 | bool UIMachine::webcamAttach(const QString &strPath, const QString &strName)
|
---|
868 | {
|
---|
869 | return uisession()->webcamAttach(strPath, strName);
|
---|
870 | }
|
---|
871 |
|
---|
872 | bool UIMachine::webcamDetach(const QString &strPath, const QString &strName)
|
---|
873 | {
|
---|
874 | return uisession()->webcamDetach(strPath, strName);
|
---|
875 | }
|
---|
876 |
|
---|
877 | bool UIMachine::acquireWhetherNetworkAdapterEnabled(ulong uSlot, bool &fEnabled)
|
---|
878 | {
|
---|
879 | return uisession()->acquireWhetherNetworkAdapterEnabled(uSlot, fEnabled);
|
---|
880 | }
|
---|
881 |
|
---|
882 | bool UIMachine::acquireWhetherAtLeastOneNetworkAdapterEnabled(bool &fEnabled)
|
---|
883 | {
|
---|
884 | return uisession()->acquireWhetherAtLeastOneNetworkAdapterEnabled(fEnabled);
|
---|
885 | }
|
---|
886 |
|
---|
887 | bool UIMachine::acquireWhetherNetworkCableConnected(ulong uSlot, bool &fConnected)
|
---|
888 | {
|
---|
889 | return uisession()->acquireWhetherNetworkCableConnected(uSlot, fConnected);
|
---|
890 | }
|
---|
891 |
|
---|
892 | bool UIMachine::setNetworkCableConnected(ulong uSlot, bool fConnected)
|
---|
893 | {
|
---|
894 | return uisession()->setNetworkCableConnected(uSlot, fConnected);
|
---|
895 | }
|
---|
896 |
|
---|
897 | bool UIMachine::acquireDeviceActivity(const QVector<KDeviceType> &deviceTypes, QVector<KDeviceActivity> &states)
|
---|
898 | {
|
---|
899 | return uisession()->acquireDeviceActivity(deviceTypes, states);
|
---|
900 | }
|
---|
901 |
|
---|
902 | void UIMachine::acquireHardDiskStatusInfo(QString &strInfo, bool &fAttachmentsPresent)
|
---|
903 | {
|
---|
904 | uisession()->acquireHardDiskStatusInfo(strInfo, fAttachmentsPresent);
|
---|
905 | }
|
---|
906 |
|
---|
907 | void UIMachine::acquireOpticalDiskStatusInfo(QString &strInfo, bool &fAttachmentsPresent, bool &fAttachmentsMounted)
|
---|
908 | {
|
---|
909 | uisession()->acquireOpticalDiskStatusInfo(strInfo, fAttachmentsPresent, fAttachmentsMounted);
|
---|
910 | }
|
---|
911 |
|
---|
912 | void UIMachine::acquireFloppyDiskStatusInfo(QString &strInfo, bool &fAttachmentsPresent, bool &fAttachmentsMounted)
|
---|
913 | {
|
---|
914 | uisession()->acquireFloppyDiskStatusInfo(strInfo, fAttachmentsPresent, fAttachmentsMounted);
|
---|
915 | }
|
---|
916 |
|
---|
917 | void UIMachine::acquireAudioStatusInfo(QString &strInfo, bool &fAudioEnabled, bool &fEnabledOutput, bool &fEnabledInput)
|
---|
918 | {
|
---|
919 | uisession()->acquireAudioStatusInfo(strInfo, fAudioEnabled, fEnabledOutput, fEnabledInput);
|
---|
920 | }
|
---|
921 |
|
---|
922 | void UIMachine::acquireNetworkStatusInfo(QString &strInfo, bool &fAdaptersPresent, bool &fCablesDisconnected)
|
---|
923 | {
|
---|
924 | uisession()->acquireNetworkStatusInfo(strInfo, fAdaptersPresent, fCablesDisconnected);
|
---|
925 | }
|
---|
926 |
|
---|
927 | void UIMachine::acquireUsbStatusInfo(QString &strInfo, bool &fUsbEnableds)
|
---|
928 | {
|
---|
929 | uisession()->acquireUsbStatusInfo(strInfo, fUsbEnableds);
|
---|
930 | }
|
---|
931 |
|
---|
932 | void UIMachine::acquireSharedFoldersStatusInfo(QString &strInfo, bool &fFoldersPresent)
|
---|
933 | {
|
---|
934 | uisession()->acquireSharedFoldersStatusInfo(strInfo, fFoldersPresent);
|
---|
935 | }
|
---|
936 |
|
---|
937 | void UIMachine::acquireDisplayStatusInfo(QString &strInfo, bool &fAcceleration3D)
|
---|
938 | {
|
---|
939 | uisession()->acquireDisplayStatusInfo(strInfo, fAcceleration3D);
|
---|
940 | }
|
---|
941 |
|
---|
942 | void UIMachine::acquireRecordingStatusInfo(QString &strInfo, bool &fRecordingEnabled, bool &fMachinePaused)
|
---|
943 | {
|
---|
944 | uisession()->acquireRecordingStatusInfo(strInfo, fRecordingEnabled, fMachinePaused);
|
---|
945 | }
|
---|
946 |
|
---|
947 | void UIMachine::acquireFeaturesStatusInfo(QString &strInfo, KVMExecutionEngine &enmEngine)
|
---|
948 | {
|
---|
949 | enmEngine = vmExecutionEngine();
|
---|
950 | uisession()->acquireFeaturesStatusInfo(strInfo, enmEngine,
|
---|
951 | isHWVirtExNestedPagingEnabled(),
|
---|
952 | isHWVirtExUXEnabled(),
|
---|
953 | paravirtProvider());
|
---|
954 | }
|
---|
955 |
|
---|
956 | void UIMachine::generateMachineInformationGeneral(const UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral &fOptions,
|
---|
957 | UITextTable &returnTable)
|
---|
958 | {
|
---|
959 | uisession()->generateMachineInformationGeneral(fOptions, returnTable);
|
---|
960 | }
|
---|
961 |
|
---|
962 | void UIMachine::generateMachineInformationSystem(const UIExtraDataMetaDefs::DetailsElementOptionTypeSystem &fOptions,
|
---|
963 | UITextTable &returnTable)
|
---|
964 | {
|
---|
965 | uisession()->generateMachineInformationSystem(fOptions, returnTable);
|
---|
966 | }
|
---|
967 |
|
---|
968 | void UIMachine::generateMachineInformationDisplay(const UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay &fOptions,
|
---|
969 | UITextTable &returnTable)
|
---|
970 | {
|
---|
971 | uisession()->generateMachineInformationDisplay(fOptions, returnTable);
|
---|
972 | }
|
---|
973 |
|
---|
974 | void UIMachine::generateMachineInformationStorage(const UIExtraDataMetaDefs::DetailsElementOptionTypeStorage &fOptions,
|
---|
975 | UITextTable &returnTable)
|
---|
976 | {
|
---|
977 | uisession()->generateMachineInformationStorage(fOptions, returnTable);
|
---|
978 | }
|
---|
979 |
|
---|
980 | void UIMachine::generateMachineInformationAudio(const UIExtraDataMetaDefs::DetailsElementOptionTypeAudio &fOptions,
|
---|
981 | UITextTable &returnTable)
|
---|
982 | {
|
---|
983 | uisession()->generateMachineInformationAudio(fOptions, returnTable);
|
---|
984 | }
|
---|
985 |
|
---|
986 | void UIMachine::generateMachineInformationNetwork(const UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork &fOptions,
|
---|
987 | UITextTable &returnTable)
|
---|
988 | {
|
---|
989 | uisession()->generateMachineInformationNetwork(fOptions, returnTable);
|
---|
990 | }
|
---|
991 |
|
---|
992 | void UIMachine::generateMachineInformationSerial(const UIExtraDataMetaDefs::DetailsElementOptionTypeSerial &fOptions,
|
---|
993 | UITextTable &returnTable)
|
---|
994 | {
|
---|
995 | uisession()->generateMachineInformationSerial(fOptions, returnTable);
|
---|
996 | }
|
---|
997 |
|
---|
998 | void UIMachine::generateMachineInformationUSB(const UIExtraDataMetaDefs::DetailsElementOptionTypeUsb &fOptions,
|
---|
999 | UITextTable &returnTable)
|
---|
1000 | {
|
---|
1001 | uisession()->generateMachineInformationUSB(fOptions, returnTable);
|
---|
1002 | }
|
---|
1003 |
|
---|
1004 | void UIMachine::generateMachineInformationSharedFolders(const UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders &fOptions,
|
---|
1005 | UITextTable &returnTable)
|
---|
1006 | {
|
---|
1007 | uisession()->generateMachineInformationSharedFolders(fOptions, returnTable);
|
---|
1008 | }
|
---|
1009 |
|
---|
1010 | bool UIMachine::setLogEnabled(bool fEnabled)
|
---|
1011 | {
|
---|
1012 | return uisession()->setLogEnabled(fEnabled);
|
---|
1013 | }
|
---|
1014 |
|
---|
1015 | bool UIMachine::acquireWhetherLogEnabled(bool &fEnabled)
|
---|
1016 | {
|
---|
1017 | return uisession()->acquireWhetherLogEnabled(fEnabled);
|
---|
1018 | }
|
---|
1019 |
|
---|
1020 | bool UIMachine::acquireLogFolder(QString &strFolder)
|
---|
1021 | {
|
---|
1022 | return uisession()->acquireLogFolder(strFolder);
|
---|
1023 | }
|
---|
1024 |
|
---|
1025 | bool UIMachine::acquireEffectiveCPULoad(ulong &uLoad)
|
---|
1026 | {
|
---|
1027 | return uisession()->acquireEffectiveCPULoad(uLoad);
|
---|
1028 | }
|
---|
1029 |
|
---|
1030 | bool UIMachine::acquireUptime(LONG64 &iUpTime)
|
---|
1031 | {
|
---|
1032 | return uisession()->acquireUptime(iUpTime);
|
---|
1033 | }
|
---|
1034 |
|
---|
1035 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
1036 | bool UIMachine::dbgCreated(void *pActionDebug)
|
---|
1037 | {
|
---|
1038 | return uisession()->dbgCreated(pActionDebug);
|
---|
1039 | }
|
---|
1040 |
|
---|
1041 | void UIMachine::dbgDestroy()
|
---|
1042 | {
|
---|
1043 | return uisession()->dbgDestroy();
|
---|
1044 | }
|
---|
1045 |
|
---|
1046 | void UIMachine::dbgShowStatistics()
|
---|
1047 | {
|
---|
1048 | return uisession()->dbgShowStatistics();
|
---|
1049 | }
|
---|
1050 |
|
---|
1051 | void UIMachine::dbgShowCommandLine()
|
---|
1052 | {
|
---|
1053 | return uisession()->dbgShowCommandLine();
|
---|
1054 | }
|
---|
1055 |
|
---|
1056 | void UIMachine::dbgAdjustRelativePos()
|
---|
1057 | {
|
---|
1058 | return uisession()->dbgAdjustRelativePos();
|
---|
1059 | }
|
---|
1060 | #endif /* VBOX_WITH_DEBUGGER_GUI */
|
---|
1061 |
|
---|
1062 | bool UIMachine::acquireWhetherGuestEnteredACPIMode(bool &fEntered)
|
---|
1063 | {
|
---|
1064 | return uisession()->acquireWhetherGuestEnteredACPIMode(fEntered);
|
---|
1065 | }
|
---|
1066 |
|
---|
1067 | void UIMachine::detachUi()
|
---|
1068 | {
|
---|
1069 | /* Manually close Runtime UI: */
|
---|
1070 | LogRel(("GUI: Detaching UI..\n"));
|
---|
1071 | closeRuntimeUI();
|
---|
1072 | }
|
---|
1073 |
|
---|
1074 | void UIMachine::saveState()
|
---|
1075 | {
|
---|
1076 | uisession()->saveState();
|
---|
1077 | }
|
---|
1078 |
|
---|
1079 | void UIMachine::shutdown()
|
---|
1080 | {
|
---|
1081 | uisession()->shutdown();
|
---|
1082 | }
|
---|
1083 |
|
---|
1084 | void UIMachine::powerOff(bool fIncludingDiscard)
|
---|
1085 | {
|
---|
1086 | uisession()->powerOff(fIncludingDiscard);
|
---|
1087 | }
|
---|
1088 |
|
---|
1089 | void UIMachine::sltInstallGuestAdditionsFrom(const QString &strSource)
|
---|
1090 | {
|
---|
1091 | uisession()->sltInstallGuestAdditionsFrom(strSource);
|
---|
1092 | }
|
---|
1093 |
|
---|
1094 | void UIMachine::sltMountDVDAdHoc(const QString &strSource)
|
---|
1095 | {
|
---|
1096 | uisession()->sltMountDVDAdHoc(strSource);
|
---|
1097 | }
|
---|
1098 |
|
---|
1099 | void UIMachine::sltClipboardError(QString strId, QString strMsg, long rcError)
|
---|
1100 | {
|
---|
1101 | UINotificationMessage::showClipboardError(strId, strMsg, rcError);
|
---|
1102 | }
|
---|
1103 |
|
---|
1104 | void UIMachine::closeRuntimeUI()
|
---|
1105 | {
|
---|
1106 | /* First, we have to hide any opened modal/popup widgets.
|
---|
1107 | * They then should unlock their event-loops asynchronously.
|
---|
1108 | * If all such loops are unlocked, we can close Runtime UI. */
|
---|
1109 | QWidget *pWidget = QApplication::activeModalWidget()
|
---|
1110 | ? QApplication::activeModalWidget()
|
---|
1111 | : QApplication::activePopupWidget()
|
---|
1112 | ? QApplication::activePopupWidget()
|
---|
1113 | : 0;
|
---|
1114 | if (pWidget)
|
---|
1115 | {
|
---|
1116 | /* First we should try to close this widget: */
|
---|
1117 | pWidget->close();
|
---|
1118 | /* If widget rejected the 'close-event' we can
|
---|
1119 | * still hide it and hope it will behave correctly
|
---|
1120 | * and unlock his event-loop if any: */
|
---|
1121 | if (!pWidget->isHidden())
|
---|
1122 | pWidget->hide();
|
---|
1123 | /* Asynchronously restart this slot: */
|
---|
1124 | QMetaObject::invokeMethod(this, "closeRuntimeUI", Qt::QueuedConnection);
|
---|
1125 | return;
|
---|
1126 | }
|
---|
1127 |
|
---|
1128 | /* Asynchronously ask QApplication to quit: */
|
---|
1129 | LogRel(("GUI: Request for async QApp quit.\n"));
|
---|
1130 | m_fQuitRequested = true;
|
---|
1131 | QMetaObject::invokeMethod(qApp, "quit", Qt::QueuedConnection);
|
---|
1132 | }
|
---|
1133 |
|
---|
1134 | void UIMachine::sltChangeVisualState(UIVisualStateType visualState)
|
---|
1135 | {
|
---|
1136 | /* Create new machine-logic: */
|
---|
1137 | UIMachineLogic *pMachineLogic = UIMachineLogic::create(this, visualState);
|
---|
1138 |
|
---|
1139 | /* First we have to check if the selected machine-logic is available at all.
|
---|
1140 | * Only then we delete the old machine-logic and switch to the new one. */
|
---|
1141 | if (pMachineLogic->checkAvailability())
|
---|
1142 | {
|
---|
1143 | /* Delete previous machine-logic if any: */
|
---|
1144 | UIMachineLogic::destroy(m_pMachineLogic);
|
---|
1145 |
|
---|
1146 | /* Set the new machine-logic as current one: */
|
---|
1147 | m_pMachineLogic = pMachineLogic;
|
---|
1148 | m_pMachineLogic->prepare();
|
---|
1149 |
|
---|
1150 | /* Remember new visual state: */
|
---|
1151 | m_enmVisualState = visualState;
|
---|
1152 |
|
---|
1153 | /* Save requested visual state: */
|
---|
1154 | gEDataManager->setRequestedVisualState(m_enmVisualState, uiCommon().managedVMUuid());
|
---|
1155 | }
|
---|
1156 | else
|
---|
1157 | {
|
---|
1158 | /* Delete temporary created machine-logic: */
|
---|
1159 | UIMachineLogic::destroy(pMachineLogic);
|
---|
1160 | }
|
---|
1161 |
|
---|
1162 | /* Make sure machine-logic exists: */
|
---|
1163 | if (!m_pMachineLogic)
|
---|
1164 | {
|
---|
1165 | /* Reset initial visual state to normal: */
|
---|
1166 | m_enmInitialVisualState = UIVisualStateType_Normal;
|
---|
1167 | /* Enter initial visual state again: */
|
---|
1168 | enterInitialVisualState();
|
---|
1169 | }
|
---|
1170 | }
|
---|
1171 |
|
---|
1172 | void UIMachine::sltHandleAdditionsActualChange()
|
---|
1173 | {
|
---|
1174 | updateStateAdditionsActions();
|
---|
1175 | emit sigAdditionsStateChange();
|
---|
1176 | }
|
---|
1177 |
|
---|
1178 | void UIMachine::sltHandleAudioAdapterChange()
|
---|
1179 | {
|
---|
1180 | updateStateAudioActions();
|
---|
1181 | emit sigAudioAdapterChange();
|
---|
1182 | }
|
---|
1183 |
|
---|
1184 | void UIMachine::sltHandleRecordingChange()
|
---|
1185 | {
|
---|
1186 | updateStateRecordingAction();
|
---|
1187 | emit sigRecordingChange();
|
---|
1188 | }
|
---|
1189 |
|
---|
1190 | void UIMachine::sltHandleStorageDeviceChange(const CMediumAttachment &comAttachment, bool fRemoved, bool fSilent)
|
---|
1191 | {
|
---|
1192 | updateActionRestrictions();
|
---|
1193 | emit sigStorageDeviceChange(comAttachment, fRemoved, fSilent);
|
---|
1194 | }
|
---|
1195 |
|
---|
1196 | void UIMachine::sltHandleVRDEChange()
|
---|
1197 | {
|
---|
1198 | updateStateVRDEServerAction();
|
---|
1199 | emit sigVRDEChange();
|
---|
1200 | }
|
---|
1201 |
|
---|
1202 | #ifdef VBOX_WS_MAC
|
---|
1203 | void UIMachine::sltHandleMenuBarConfigurationChange(const QUuid &uMachineID)
|
---|
1204 | {
|
---|
1205 | /* Skip unrelated machine IDs: */
|
---|
1206 | if (uiCommon().managedVMUuid() != uMachineID)
|
---|
1207 | return;
|
---|
1208 |
|
---|
1209 | /* Update Mac OS X menu-bar: */
|
---|
1210 | updateMenu();
|
---|
1211 | }
|
---|
1212 | #endif /* VBOX_WS_MAC */
|
---|
1213 |
|
---|
1214 | void UIMachine::sltHandleHostScreenCountChange()
|
---|
1215 | {
|
---|
1216 | LogRelFlow(("GUI: UIMachine: Host-screen count changed.\n"));
|
---|
1217 |
|
---|
1218 | /* Recache display data: */
|
---|
1219 | updateHostScreenData();
|
---|
1220 |
|
---|
1221 | /* Notify current machine-logic: */
|
---|
1222 | emit sigHostScreenCountChange();
|
---|
1223 | }
|
---|
1224 |
|
---|
1225 | void UIMachine::sltHandleHostScreenGeometryChange()
|
---|
1226 | {
|
---|
1227 | LogRelFlow(("GUI: UIMachine: Host-screen geometry changed.\n"));
|
---|
1228 |
|
---|
1229 | /* Recache display data: */
|
---|
1230 | updateHostScreenData();
|
---|
1231 |
|
---|
1232 | /* Notify current machine-logic: */
|
---|
1233 | emit sigHostScreenGeometryChange();
|
---|
1234 | }
|
---|
1235 |
|
---|
1236 | void UIMachine::sltHandleHostScreenAvailableAreaChange()
|
---|
1237 | {
|
---|
1238 | LogRelFlow(("GUI: UIMachine: Host-screen available-area changed.\n"));
|
---|
1239 |
|
---|
1240 | /* Notify current machine-logic: */
|
---|
1241 | emit sigHostScreenAvailableAreaChange();
|
---|
1242 | }
|
---|
1243 |
|
---|
1244 | #ifdef VBOX_WS_MAC
|
---|
1245 | void UIMachine::sltHandleHostDisplayAboutToChange()
|
---|
1246 | {
|
---|
1247 | LogRelFlow(("GUI: UIMachine::sltHandleHostDisplayAboutToChange()\n"));
|
---|
1248 |
|
---|
1249 | if (m_pWatchdogDisplayChange->isActive())
|
---|
1250 | m_pWatchdogDisplayChange->stop();
|
---|
1251 | m_pWatchdogDisplayChange->setProperty("tryNumber", 1);
|
---|
1252 | m_pWatchdogDisplayChange->start();
|
---|
1253 | }
|
---|
1254 |
|
---|
1255 | void UIMachine::sltCheckIfHostDisplayChanged()
|
---|
1256 | {
|
---|
1257 | LogRelFlow(("GUI: UIMachine::sltCheckIfHostDisplayChanged()\n"));
|
---|
1258 |
|
---|
1259 | /* Check if display count changed: */
|
---|
1260 | if (UIDesktopWidgetWatchdog::screenCount() != m_hostScreens.size())
|
---|
1261 | {
|
---|
1262 | /* Reset watchdog: */
|
---|
1263 | m_pWatchdogDisplayChange->setProperty("tryNumber", 0);
|
---|
1264 | /* Notify listeners about screen-count changed: */
|
---|
1265 | return sltHandleHostScreenCountChange();
|
---|
1266 | }
|
---|
1267 | else
|
---|
1268 | {
|
---|
1269 | /* Check if at least one display geometry changed: */
|
---|
1270 | for (int iScreenIndex = 0; iScreenIndex < UIDesktopWidgetWatchdog::screenCount(); ++iScreenIndex)
|
---|
1271 | {
|
---|
1272 | if (gpDesktop->screenGeometry(iScreenIndex) != m_hostScreens.at(iScreenIndex))
|
---|
1273 | {
|
---|
1274 | /* Reset watchdog: */
|
---|
1275 | m_pWatchdogDisplayChange->setProperty("tryNumber", 0);
|
---|
1276 | /* Notify listeners about screen-geometry changed: */
|
---|
1277 | return sltHandleHostScreenGeometryChange();
|
---|
1278 | }
|
---|
1279 | }
|
---|
1280 | }
|
---|
1281 |
|
---|
1282 | /* Check if watchdog expired, restart if not: */
|
---|
1283 | int cTryNumber = m_pWatchdogDisplayChange->property("tryNumber").toInt();
|
---|
1284 | if (cTryNumber > 0 && cTryNumber < 40)
|
---|
1285 | {
|
---|
1286 | /* Restart watchdog again: */
|
---|
1287 | m_pWatchdogDisplayChange->setProperty("tryNumber", ++cTryNumber);
|
---|
1288 | m_pWatchdogDisplayChange->start();
|
---|
1289 | }
|
---|
1290 | else
|
---|
1291 | {
|
---|
1292 | /* Reset watchdog: */
|
---|
1293 | m_pWatchdogDisplayChange->setProperty("tryNumber", 0);
|
---|
1294 | }
|
---|
1295 | }
|
---|
1296 | #endif /* VBOX_WS_MAC */
|
---|
1297 |
|
---|
1298 | void UIMachine::sltHandleGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo)
|
---|
1299 | {
|
---|
1300 | /* Ignore KGuestMonitorChangedEventType_NewOrigin change event: */
|
---|
1301 | if (changeType == KGuestMonitorChangedEventType_NewOrigin)
|
---|
1302 | return;
|
---|
1303 | /* Ignore KGuestMonitorChangedEventType_Disabled event for primary screen: */
|
---|
1304 | AssertMsg(countOfVisibleWindows() > 0, ("All machine windows are hidden!"));
|
---|
1305 | if (changeType == KGuestMonitorChangedEventType_Disabled && uScreenId == 0)
|
---|
1306 | return;
|
---|
1307 |
|
---|
1308 | /* Process KGuestMonitorChangedEventType_Enabled change event: */
|
---|
1309 | if ( !isScreenVisible(uScreenId)
|
---|
1310 | && changeType == KGuestMonitorChangedEventType_Enabled)
|
---|
1311 | setScreenVisible(uScreenId, true);
|
---|
1312 | /* Process KGuestMonitorChangedEventType_Disabled change event: */
|
---|
1313 | else if ( isScreenVisible(uScreenId)
|
---|
1314 | && changeType == KGuestMonitorChangedEventType_Disabled)
|
---|
1315 | setScreenVisible(uScreenId, false);
|
---|
1316 |
|
---|
1317 | /* Notify listeners about the change: */
|
---|
1318 | emit sigGuestMonitorChange(changeType, uScreenId, screenGeo);
|
---|
1319 | }
|
---|
1320 |
|
---|
1321 | void UIMachine::sltHandleKeyboardLedsChange(bool fNumLock, bool fCapsLock, bool fScrollLock)
|
---|
1322 | {
|
---|
1323 | /* Check if something had changed: */
|
---|
1324 | if ( m_fNumLock != fNumLock
|
---|
1325 | || m_fCapsLock != fCapsLock
|
---|
1326 | || m_fScrollLock != fScrollLock)
|
---|
1327 | {
|
---|
1328 | /* Store new num lock data: */
|
---|
1329 | if (m_fNumLock != fNumLock)
|
---|
1330 | {
|
---|
1331 | m_fNumLock = fNumLock;
|
---|
1332 | m_uNumLockAdaptionCnt = 2;
|
---|
1333 | }
|
---|
1334 |
|
---|
1335 | /* Store new caps lock data: */
|
---|
1336 | if (m_fCapsLock != fCapsLock)
|
---|
1337 | {
|
---|
1338 | m_fCapsLock = fCapsLock;
|
---|
1339 | m_uCapsLockAdaptionCnt = 2;
|
---|
1340 | }
|
---|
1341 |
|
---|
1342 | /* Store new scroll lock data: */
|
---|
1343 | if (m_fScrollLock != fScrollLock)
|
---|
1344 | {
|
---|
1345 | m_fScrollLock = fScrollLock;
|
---|
1346 | }
|
---|
1347 |
|
---|
1348 | /* Notify listeners: */
|
---|
1349 | emit sigKeyboardLedsChange();
|
---|
1350 | }
|
---|
1351 | }
|
---|
1352 |
|
---|
1353 | void UIMachine::sltMousePointerShapeChange(const UIMousePointerShapeData &shapeData)
|
---|
1354 | {
|
---|
1355 | LogRelFlow(("GUI: UIMachine::sltMousePointerShapeChange: "
|
---|
1356 | "Is visible: %s, Has alpha: %s, "
|
---|
1357 | "Hot spot: %dx%d, Shape size: %dx%d, "
|
---|
1358 | "Shape data: %s\n",
|
---|
1359 | shapeData.isVisible() ? "TRUE" : "FALSE",
|
---|
1360 | shapeData.hasAlpha() ? "TRUE" : "FALSE",
|
---|
1361 | shapeData.hotSpot().x(), shapeData.hotSpot().y(),
|
---|
1362 | shapeData.shapeSize().width(), shapeData.shapeSize().height(),
|
---|
1363 | shapeData.shape().isEmpty() ? "EMPTY" : "PRESENT"));
|
---|
1364 |
|
---|
1365 | /* In case if shape itself is present: */
|
---|
1366 | if (shapeData.shape().size() > 0)
|
---|
1367 | {
|
---|
1368 | /* We are ignoring visibility flag: */
|
---|
1369 | m_fIsHidingHostPointer = false;
|
---|
1370 |
|
---|
1371 | /* And updating current shape data: */
|
---|
1372 | m_shapeData = shapeData;
|
---|
1373 | updateMousePointerShape();
|
---|
1374 | }
|
---|
1375 | /* In case if shape itself is NOT present: */
|
---|
1376 | else
|
---|
1377 | {
|
---|
1378 | /* Remember if we should hide the cursor: */
|
---|
1379 | m_fIsHidingHostPointer = !shapeData.isVisible();
|
---|
1380 | }
|
---|
1381 |
|
---|
1382 | /* Notify listeners: */
|
---|
1383 | emit sigMousePointerShapeChange();
|
---|
1384 | }
|
---|
1385 |
|
---|
1386 | void UIMachine::sltMouseCapabilityChange(bool fSupportsAbsolute, bool fSupportsRelative,
|
---|
1387 | bool fSupportsTouchScreen, bool fSupportsTouchPad,
|
---|
1388 | bool fNeedsHostCursor)
|
---|
1389 | {
|
---|
1390 | LogRelFlow(("GUI: UIMachine::sltMouseCapabilityChange: "
|
---|
1391 | "Supports absolute: %s, Supports relative: %s, "
|
---|
1392 | "Supports touchscreen: %s, Supports touchpad: %s, "
|
---|
1393 | "Needs host cursor: %s\n",
|
---|
1394 | fSupportsAbsolute ? "TRUE" : "FALSE", fSupportsRelative ? "TRUE" : "FALSE",
|
---|
1395 | fSupportsTouchScreen ? "TRUE" : "FALSE", fSupportsTouchPad ? "TRUE" : "FALSE",
|
---|
1396 | fNeedsHostCursor ? "TRUE" : "FALSE"));
|
---|
1397 |
|
---|
1398 | /* Check if something had changed: */
|
---|
1399 | if ( m_fIsMouseSupportsAbsolute != fSupportsAbsolute
|
---|
1400 | || m_fIsMouseSupportsRelative != fSupportsRelative
|
---|
1401 | || m_fIsMouseSupportsTouchScreen != fSupportsTouchScreen
|
---|
1402 | || m_fIsMouseSupportsTouchPad != fSupportsTouchPad
|
---|
1403 | || m_fIsMouseHostCursorNeeded != fNeedsHostCursor)
|
---|
1404 | {
|
---|
1405 | /* Store new data: */
|
---|
1406 | m_fIsMouseSupportsAbsolute = fSupportsAbsolute;
|
---|
1407 | m_fIsMouseSupportsRelative = fSupportsRelative;
|
---|
1408 | m_fIsMouseSupportsTouchScreen = fSupportsTouchScreen;
|
---|
1409 | m_fIsMouseSupportsTouchPad = fSupportsTouchPad;
|
---|
1410 | m_fIsMouseHostCursorNeeded = fNeedsHostCursor;
|
---|
1411 |
|
---|
1412 | /* Notify listeners: */
|
---|
1413 | emit sigMouseCapabilityChange();
|
---|
1414 | }
|
---|
1415 | }
|
---|
1416 |
|
---|
1417 | void UIMachine::sltCursorPositionChange(bool fContainsData, unsigned long uX, unsigned long uY)
|
---|
1418 | {
|
---|
1419 | LogRelFlow(("GUI: UIMachine::sltCursorPositionChange: "
|
---|
1420 | "Cursor position valid: %d, Cursor position: %dx%d\n",
|
---|
1421 | fContainsData ? "TRUE" : "FALSE", uX, uY));
|
---|
1422 |
|
---|
1423 | /* Check if something had changed: */
|
---|
1424 | if ( m_fIsValidCursorPositionPresent != fContainsData
|
---|
1425 | || m_cursorPosition.x() != (int)uX
|
---|
1426 | || m_cursorPosition.y() != (int)uY)
|
---|
1427 | {
|
---|
1428 | /* Store new data: */
|
---|
1429 | m_fIsValidCursorPositionPresent = fContainsData;
|
---|
1430 | m_cursorPosition = QPoint(uX, uY);
|
---|
1431 |
|
---|
1432 | /* Notify listeners: */
|
---|
1433 | emit sigCursorPositionChange();
|
---|
1434 | }
|
---|
1435 | }
|
---|
1436 |
|
---|
1437 | UIMachine::UIMachine()
|
---|
1438 | : QObject(0)
|
---|
1439 | , m_fInitialized(false)
|
---|
1440 | , m_pSession(0)
|
---|
1441 | , m_enmAllowedVisualStates(UIVisualStateType_Invalid)
|
---|
1442 | , m_enmInitialVisualState(UIVisualStateType_Normal)
|
---|
1443 | , m_enmVisualState(UIVisualStateType_Invalid)
|
---|
1444 | , m_enmRequestedVisualState(UIVisualStateType_Invalid)
|
---|
1445 | , m_pMachineLogic(0)
|
---|
1446 | , m_pMachineWindowIcon(0)
|
---|
1447 | , m_pActionPool(0)
|
---|
1448 | #ifdef VBOX_WS_MAC
|
---|
1449 | , m_pMenuBar(0)
|
---|
1450 | #endif
|
---|
1451 | #ifdef VBOX_WS_MAC
|
---|
1452 | , m_pWatchdogDisplayChange(0)
|
---|
1453 | #endif
|
---|
1454 | , m_fIsGuestResizeIgnored(false)
|
---|
1455 | , m_fNumLock(false)
|
---|
1456 | , m_fCapsLock(false)
|
---|
1457 | , m_fScrollLock(false)
|
---|
1458 | , m_uNumLockAdaptionCnt(2)
|
---|
1459 | , m_uCapsLockAdaptionCnt(2)
|
---|
1460 | , m_fIsHidLedsSyncEnabled(false)
|
---|
1461 | , m_fIsAutoCaptureDisabled(false)
|
---|
1462 | , m_iKeyboardState(0)
|
---|
1463 | , m_fIsHidingHostPointer(true)
|
---|
1464 | , m_fIsValidPointerShapePresent(false)
|
---|
1465 | , m_fIsValidCursorPositionPresent(false)
|
---|
1466 | , m_fIsMouseSupportsAbsolute(false)
|
---|
1467 | , m_fIsMouseSupportsRelative(false)
|
---|
1468 | , m_fIsMouseSupportsTouchScreen(false)
|
---|
1469 | , m_fIsMouseSupportsTouchPad(false)
|
---|
1470 | , m_fIsMouseHostCursorNeeded(false)
|
---|
1471 | , m_fIsMouseCaptured(false)
|
---|
1472 | , m_fIsMouseIntegrated(true)
|
---|
1473 | , m_iMouseState(0)
|
---|
1474 | , m_enmVMExecutionEngine(KVMExecutionEngine_NotSet)
|
---|
1475 | , m_fIsHWVirtExNestedPagingEnabled(false)
|
---|
1476 | , m_fIsHWVirtExUXEnabled(false)
|
---|
1477 | , m_enmParavirtProvider(KParavirtProvider_None)
|
---|
1478 | , m_fIsManualOverride(false)
|
---|
1479 | , m_defaultCloseAction(MachineCloseAction_Invalid)
|
---|
1480 | , m_restrictedCloseActions(MachineCloseAction_Invalid)
|
---|
1481 | , m_fQuitRequested(false)
|
---|
1482 | {
|
---|
1483 | s_pInstance = this;
|
---|
1484 | }
|
---|
1485 |
|
---|
1486 | UIMachine::~UIMachine()
|
---|
1487 | {
|
---|
1488 | s_pInstance = 0;
|
---|
1489 | }
|
---|
1490 |
|
---|
1491 | bool UIMachine::prepare()
|
---|
1492 | {
|
---|
1493 | /* Prepare stuff unrelated to VM: */
|
---|
1494 | prepareNotificationCenter();
|
---|
1495 |
|
---|
1496 | /* Prepare VM session: */
|
---|
1497 | if (!prepareSession())
|
---|
1498 | return false;
|
---|
1499 |
|
---|
1500 | /* Prepare VM related stuff: */
|
---|
1501 | prepareActions();
|
---|
1502 | prepareHostScreenData();
|
---|
1503 | prepareKeyboard();
|
---|
1504 | prepareClose();
|
---|
1505 | prepareVisualState();
|
---|
1506 |
|
---|
1507 | /* Update VM related stuff: */
|
---|
1508 | updateBranding();
|
---|
1509 | updateGuestScreenData();
|
---|
1510 | enterInitialVisualState();
|
---|
1511 |
|
---|
1512 | /* Try to initialize VM session: */
|
---|
1513 | if (!uisession()->initialize())
|
---|
1514 | return false;
|
---|
1515 |
|
---|
1516 | /* Update stuff which doesn't send events on init: */
|
---|
1517 | updateVirtualizationState();
|
---|
1518 | updateStateAudioActions();
|
---|
1519 | updateMouseState();
|
---|
1520 |
|
---|
1521 | /* Warn listeners about we are initialized: */
|
---|
1522 | m_fInitialized = true;
|
---|
1523 | emit sigInitialized();
|
---|
1524 |
|
---|
1525 | /* True by default: */
|
---|
1526 | return true;
|
---|
1527 | }
|
---|
1528 |
|
---|
1529 | void UIMachine::prepareNotificationCenter()
|
---|
1530 | {
|
---|
1531 | UINotificationCenter::create();
|
---|
1532 | }
|
---|
1533 |
|
---|
1534 | bool UIMachine::prepareSession()
|
---|
1535 | {
|
---|
1536 | /* Create session UI: */
|
---|
1537 | m_pSession = new UISession(this);
|
---|
1538 | AssertPtrReturn(uisession(), false);
|
---|
1539 |
|
---|
1540 | /* Console events stuff: */
|
---|
1541 | connect(uisession(), &UISession::sigAudioAdapterChange,
|
---|
1542 | this, &UIMachine::sltHandleAudioAdapterChange);
|
---|
1543 | connect(uisession(), &UISession::sigAdditionsStateChange,
|
---|
1544 | this, &UIMachine::sigAdditionsStateChange);
|
---|
1545 | connect(uisession(), &UISession::sigAdditionsStateActualChange,
|
---|
1546 | this, &UIMachine::sltHandleAdditionsActualChange);
|
---|
1547 | connect(uisession(), &UISession::sigClipboardModeChange,
|
---|
1548 | this, &UIMachine::sigClipboardModeChange);
|
---|
1549 | connect(uisession(), &UISession::sigClipboardError,
|
---|
1550 | this, &UIMachine::sltClipboardError);
|
---|
1551 | connect(uisession(), &UISession::sigCPUExecutionCapChange,
|
---|
1552 | this, &UIMachine::sigCPUExecutionCapChange);
|
---|
1553 | connect(uisession(), &UISession::sigDnDModeChange,
|
---|
1554 | this, &UIMachine::sigDnDModeChange);
|
---|
1555 | connect(uisession(), &UISession::sigGuestMonitorChange,
|
---|
1556 | this, &UIMachine::sltHandleGuestMonitorChange);
|
---|
1557 | connect(uisession(), &UISession::sigMachineStateChange,
|
---|
1558 | this, &UIMachine::sigMachineStateChange);
|
---|
1559 | connect(uisession(), &UISession::sigMediumChange,
|
---|
1560 | this, &UIMachine::sigMediumChange);
|
---|
1561 | connect(uisession(), &UISession::sigNetworkAdapterChange,
|
---|
1562 | this, &UIMachine::sigNetworkAdapterChange);
|
---|
1563 | connect(uisession(), &UISession::sigRecordingChange,
|
---|
1564 | this, &UIMachine::sltHandleRecordingChange);
|
---|
1565 | connect(uisession(), &UISession::sigSharedFolderChange,
|
---|
1566 | this, &UIMachine::sigSharedFolderChange);
|
---|
1567 | connect(uisession(), &UISession::sigStorageDeviceChange,
|
---|
1568 | this, &UIMachine::sltHandleStorageDeviceChange);
|
---|
1569 | connect(uisession(), &UISession::sigUSBControllerChange,
|
---|
1570 | this, &UIMachine::sigUSBControllerChange);
|
---|
1571 | connect(uisession(), &UISession::sigUSBDeviceStateChange,
|
---|
1572 | this, &UIMachine::sigUSBDeviceStateChange);
|
---|
1573 | connect(uisession(), &UISession::sigVRDEChange,
|
---|
1574 | this, &UIMachine::sltHandleVRDEChange);
|
---|
1575 | connect(uisession(), &UISession::sigRuntimeError,
|
---|
1576 | this, &UIMachine::sigRuntimeError);
|
---|
1577 | #ifdef VBOX_WS_MAC
|
---|
1578 | connect(uisession(), &UISession::sigShowWindows,
|
---|
1579 | this, &UIMachine::sigShowWindows);
|
---|
1580 | #endif
|
---|
1581 |
|
---|
1582 | /* Keyboard stuff: */
|
---|
1583 | connect(uisession(), &UISession::sigKeyboardLedsChange,
|
---|
1584 | this, &UIMachine::sltHandleKeyboardLedsChange);
|
---|
1585 |
|
---|
1586 | /* Mouse stuff: */
|
---|
1587 | connect(uisession(), &UISession::sigMousePointerShapeChange,
|
---|
1588 | this, &UIMachine::sltMousePointerShapeChange);
|
---|
1589 | connect(uisession(), &UISession::sigMouseCapabilityChange,
|
---|
1590 | this, &UIMachine::sltMouseCapabilityChange);
|
---|
1591 | connect(uisession(), &UISession::sigCursorPositionChange,
|
---|
1592 | this, &UIMachine::sltCursorPositionChange);
|
---|
1593 |
|
---|
1594 | /* Make sure session prepared: */
|
---|
1595 | return uisession()->prepare();
|
---|
1596 | }
|
---|
1597 |
|
---|
1598 | void UIMachine::prepareActions()
|
---|
1599 | {
|
---|
1600 | /* Create action-pool: */
|
---|
1601 | m_pActionPool = UIActionPool::create(UIType_RuntimeUI);
|
---|
1602 | if (actionPool())
|
---|
1603 | {
|
---|
1604 | /* Make sure action-pool knows guest-screen count: */
|
---|
1605 | actionPool()->toRuntime()->setGuestScreenCount(uisession()->frameBuffers().size());
|
---|
1606 | /* Update action restrictions: */
|
---|
1607 | updateActionRestrictions();
|
---|
1608 |
|
---|
1609 | #ifdef VBOX_WS_MAC
|
---|
1610 | /* Create Mac OS X menu-bar: */
|
---|
1611 | m_pMenuBar = new QMenuBar;
|
---|
1612 | if (m_pMenuBar)
|
---|
1613 | {
|
---|
1614 | /* Configure Mac OS X menu-bar: */
|
---|
1615 | connect(gEDataManager, &UIExtraDataManager::sigMenuBarConfigurationChange,
|
---|
1616 | this, &UIMachine::sltHandleMenuBarConfigurationChange);
|
---|
1617 | /* Update Mac OS X menu-bar: */
|
---|
1618 | updateMenu();
|
---|
1619 | }
|
---|
1620 | #endif /* VBOX_WS_MAC */
|
---|
1621 |
|
---|
1622 | /* Get machine ID: */
|
---|
1623 | const QUuid uMachineID = uiCommon().managedVMUuid();
|
---|
1624 | Q_UNUSED(uMachineID);
|
---|
1625 |
|
---|
1626 | #ifdef VBOX_WS_MAC
|
---|
1627 | /* User-element (Menu-bar and Dock) options: */
|
---|
1628 | {
|
---|
1629 | const bool fDisabled = gEDataManager->guiFeatureEnabled(GUIFeatureType_NoUserElements);
|
---|
1630 | if (fDisabled)
|
---|
1631 | UICocoaApplication::instance()->hideUserElements();
|
---|
1632 | }
|
---|
1633 | #else /* !VBOX_WS_MAC */
|
---|
1634 | /* Menu-bar options: */
|
---|
1635 | {
|
---|
1636 | const bool fEnabledGlobally = !gEDataManager->guiFeatureEnabled(GUIFeatureType_NoMenuBar);
|
---|
1637 | const bool fEnabledForMachine = gEDataManager->menuBarEnabled(uMachineID);
|
---|
1638 | const bool fEnabled = fEnabledGlobally && fEnabledForMachine;
|
---|
1639 | actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_S_Settings)->setEnabled(fEnabled);
|
---|
1640 | actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_T_Visibility)->blockSignals(true);
|
---|
1641 | actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_T_Visibility)->setChecked(fEnabled);
|
---|
1642 | actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_T_Visibility)->blockSignals(false);
|
---|
1643 | }
|
---|
1644 | #endif /* !VBOX_WS_MAC */
|
---|
1645 |
|
---|
1646 | /* View options: */
|
---|
1647 | const bool fGuestScreenAutoresize = gEDataManager->guestScreenAutoResizeEnabled(uMachineID);
|
---|
1648 | actionPool()->action(UIActionIndexRT_M_View_T_GuestAutoresize)->blockSignals(true);
|
---|
1649 | actionPool()->action(UIActionIndexRT_M_View_T_GuestAutoresize)->setChecked(fGuestScreenAutoresize);
|
---|
1650 | actionPool()->action(UIActionIndexRT_M_View_T_GuestAutoresize)->blockSignals(false);
|
---|
1651 |
|
---|
1652 | /* Input options: */
|
---|
1653 | const bool fMouseIntegrated = isMouseIntegrated(); // no e-data for now ..
|
---|
1654 | actionPool()->action(UIActionIndexRT_M_Input_M_Mouse_T_Integration)->blockSignals(true);
|
---|
1655 | actionPool()->action(UIActionIndexRT_M_Input_M_Mouse_T_Integration)->setChecked(fMouseIntegrated);
|
---|
1656 | actionPool()->action(UIActionIndexRT_M_Input_M_Mouse_T_Integration)->blockSignals(false);
|
---|
1657 |
|
---|
1658 | /* Device options: */
|
---|
1659 | actionPool()->action(UIActionIndexRT_M_Devices_S_UpgradeGuestAdditions)->setEnabled(false);
|
---|
1660 |
|
---|
1661 | /* Status-bar options: */
|
---|
1662 | {
|
---|
1663 | const bool fEnabledGlobally = !gEDataManager->guiFeatureEnabled(GUIFeatureType_NoStatusBar);
|
---|
1664 | const bool fEnabledForMachine = gEDataManager->statusBarEnabled(uMachineID);
|
---|
1665 | const bool fEnabled = fEnabledGlobally && fEnabledForMachine;
|
---|
1666 | actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_S_Settings)->setEnabled(fEnabled);
|
---|
1667 | actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_T_Visibility)->blockSignals(true);
|
---|
1668 | actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_T_Visibility)->setChecked(fEnabled);
|
---|
1669 | actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_T_Visibility)->blockSignals(false);
|
---|
1670 | }
|
---|
1671 | }
|
---|
1672 | }
|
---|
1673 |
|
---|
1674 | void UIMachine::prepareHostScreenData()
|
---|
1675 | {
|
---|
1676 | /* Recache display data: */
|
---|
1677 | updateHostScreenData();
|
---|
1678 |
|
---|
1679 | #ifdef VBOX_WS_MAC
|
---|
1680 | /* Prepare display-change watchdog: */
|
---|
1681 | m_pWatchdogDisplayChange = new QTimer(this);
|
---|
1682 | {
|
---|
1683 | m_pWatchdogDisplayChange->setInterval(500);
|
---|
1684 | m_pWatchdogDisplayChange->setSingleShot(true);
|
---|
1685 | connect(m_pWatchdogDisplayChange, &QTimer::timeout,
|
---|
1686 | this, &UIMachine::sltCheckIfHostDisplayChanged);
|
---|
1687 | }
|
---|
1688 | /* Install native display reconfiguration callback: */
|
---|
1689 | CGDisplayRegisterReconfigurationCallback(cgDisplayReconfigurationCallback, this);
|
---|
1690 | #else /* !VBOX_WS_MAC */
|
---|
1691 | /* Install Qt display reconfiguration callbacks: */
|
---|
1692 | connect(gpDesktop, &UIDesktopWidgetWatchdog::sigHostScreenCountChanged,
|
---|
1693 | this, &UIMachine::sltHandleHostScreenCountChange);
|
---|
1694 | connect(gpDesktop, &UIDesktopWidgetWatchdog::sigHostScreenResized,
|
---|
1695 | this, &UIMachine::sltHandleHostScreenGeometryChange);
|
---|
1696 | # if defined(VBOX_WS_NIX) && !defined(VBOX_GUI_WITH_CUSTOMIZATIONS1)
|
---|
1697 | connect(gpDesktop, &UIDesktopWidgetWatchdog::sigHostScreenWorkAreaRecalculated,
|
---|
1698 | this, &UIMachine::sltHandleHostScreenAvailableAreaChange);
|
---|
1699 | # else /* !VBOX_WS_NIX || VBOX_GUI_WITH_CUSTOMIZATIONS1 */
|
---|
1700 | connect(gpDesktop, &UIDesktopWidgetWatchdog::sigHostScreenWorkAreaResized,
|
---|
1701 | this, &UIMachine::sltHandleHostScreenAvailableAreaChange);
|
---|
1702 | # endif /* !VBOX_WS_NIX || VBOX_GUI_WITH_CUSTOMIZATIONS1 */
|
---|
1703 | #endif /* !VBOX_WS_MAC */
|
---|
1704 | }
|
---|
1705 |
|
---|
1706 | void UIMachine::prepareKeyboard()
|
---|
1707 | {
|
---|
1708 | #if defined(VBOX_WS_MAC) || defined(VBOX_WS_WIN)
|
---|
1709 | /* Load extra-data value: */
|
---|
1710 | m_fIsHidLedsSyncEnabled = gEDataManager->hidLedsSyncState(uiCommon().managedVMUuid());
|
---|
1711 | /* Connect to extra-data changes to be able to enable/disable feature dynamically: */
|
---|
1712 | connect(gEDataManager, &UIExtraDataManager::sigHidLedsSyncStateChange,
|
---|
1713 | this, &UIMachine::sltHidLedsSyncStateChanged);
|
---|
1714 | #endif /* VBOX_WS_MAC || VBOX_WS_WIN */
|
---|
1715 | }
|
---|
1716 |
|
---|
1717 | void UIMachine::prepareClose()
|
---|
1718 | {
|
---|
1719 | /* What is the default close action and the restricted are? */
|
---|
1720 | const QUuid uMachineID = uiCommon().managedVMUuid();
|
---|
1721 | m_defaultCloseAction = gEDataManager->defaultMachineCloseAction(uMachineID);
|
---|
1722 | m_restrictedCloseActions = gEDataManager->restrictedMachineCloseActions(uMachineID);
|
---|
1723 | }
|
---|
1724 |
|
---|
1725 | void UIMachine::prepareVisualState()
|
---|
1726 | {
|
---|
1727 | /* Prepare async visual state type change handler: */
|
---|
1728 | qRegisterMetaType<UIVisualStateType>();
|
---|
1729 | connect(this, &UIMachine::sigRequestAsyncVisualStateChange,
|
---|
1730 | this, &UIMachine::sltChangeVisualState,
|
---|
1731 | Qt::QueuedConnection);
|
---|
1732 |
|
---|
1733 | /* Load restricted visual states: */
|
---|
1734 | UIVisualStateType enmRestrictedVisualStates = gEDataManager->restrictedVisualStates(uiCommon().managedVMUuid());
|
---|
1735 | /* Acquire allowed visual states: */
|
---|
1736 | m_enmAllowedVisualStates = static_cast<UIVisualStateType>(UIVisualStateType_All ^ enmRestrictedVisualStates);
|
---|
1737 |
|
---|
1738 | /* Load requested visual state, it can override initial one: */
|
---|
1739 | m_enmRequestedVisualState = gEDataManager->requestedVisualState(uiCommon().managedVMUuid());
|
---|
1740 | /* Check if requested visual state is allowed: */
|
---|
1741 | if (isVisualStateAllowed(m_enmRequestedVisualState))
|
---|
1742 | {
|
---|
1743 | switch (m_enmRequestedVisualState)
|
---|
1744 | {
|
---|
1745 | /* Direct transition allowed to scale/fullscreen modes only: */
|
---|
1746 | case UIVisualStateType_Scale:
|
---|
1747 | case UIVisualStateType_Fullscreen:
|
---|
1748 | m_enmInitialVisualState = m_enmRequestedVisualState;
|
---|
1749 | break;
|
---|
1750 | default:
|
---|
1751 | break;
|
---|
1752 | }
|
---|
1753 | }
|
---|
1754 | }
|
---|
1755 |
|
---|
1756 | void UIMachine::updateBranding()
|
---|
1757 | {
|
---|
1758 | /* Create the icon dynamically: */
|
---|
1759 | delete m_pMachineWindowIcon;
|
---|
1760 | m_pMachineWindowIcon = new QIcon;
|
---|
1761 | acquireUserMachineIcon(*m_pMachineWindowIcon);
|
---|
1762 |
|
---|
1763 | #ifndef VBOX_WS_MAC
|
---|
1764 | /* Load user's machine-window name postfix: */
|
---|
1765 | const QUuid uMachineID = uiCommon().managedVMUuid();
|
---|
1766 | m_strMachineWindowNamePostfix = gEDataManager->machineWindowNamePostfix(uMachineID);
|
---|
1767 | #endif /* !VBOX_WS_MAC */
|
---|
1768 | }
|
---|
1769 |
|
---|
1770 | void UIMachine::updateGuestScreenData()
|
---|
1771 | {
|
---|
1772 | /* Accquire guest-screen count: */
|
---|
1773 | ulong cMonitorCount = 0;
|
---|
1774 | acquireMonitorCount(cMonitorCount);
|
---|
1775 |
|
---|
1776 | /* Prepare initial screen visibility status: */
|
---|
1777 | m_guestScreenVisibilityVector.fill(false, cMonitorCount);
|
---|
1778 | m_guestScreenVisibilityVector[0] = true;
|
---|
1779 |
|
---|
1780 | /* Prepare empty last full-screen size vector: */
|
---|
1781 | m_monitorLastFullScreenSizeVector.fill(QSize(-1, -1), cMonitorCount);
|
---|
1782 |
|
---|
1783 | /* If machine is in 'saved' state: */
|
---|
1784 | if (uisession()->isSaved())
|
---|
1785 | {
|
---|
1786 | /* Update screen visibility status from saved-state: */
|
---|
1787 | for (int iScreenIndex = 0; iScreenIndex < m_guestScreenVisibilityVector.size(); ++iScreenIndex)
|
---|
1788 | {
|
---|
1789 | long iDummy = 0;
|
---|
1790 | ulong uDummy = 0;
|
---|
1791 | bool fEnabled = true;
|
---|
1792 | acquireSavedGuestScreenInfo(iScreenIndex, iDummy, iDummy, uDummy, uDummy, fEnabled);
|
---|
1793 | m_guestScreenVisibilityVector[iScreenIndex] = fEnabled;
|
---|
1794 | }
|
---|
1795 | /* And make sure at least one of them is visible (primary if others are hidden): */
|
---|
1796 | if (countOfVisibleWindows() < 1)
|
---|
1797 | m_guestScreenVisibilityVector[0] = true;
|
---|
1798 | }
|
---|
1799 | else if (uiCommon().isSeparateProcess())
|
---|
1800 | {
|
---|
1801 | /* Update screen visibility status from display directly: */
|
---|
1802 | for (int iScreenIndex = 0; iScreenIndex < m_guestScreenVisibilityVector.size(); ++iScreenIndex)
|
---|
1803 | {
|
---|
1804 | ulong uDummy = 0;
|
---|
1805 | long iDummy = 0;
|
---|
1806 | KGuestMonitorStatus enmMonitorStatus = KGuestMonitorStatus_Disabled;
|
---|
1807 | acquireGuestScreenParameters(iScreenIndex, uDummy, uDummy, uDummy, iDummy, iDummy, enmMonitorStatus);
|
---|
1808 | m_guestScreenVisibilityVector[iScreenIndex] = ( enmMonitorStatus == KGuestMonitorStatus_Enabled
|
---|
1809 | || enmMonitorStatus == KGuestMonitorStatus_Blank);
|
---|
1810 | }
|
---|
1811 | /* And make sure at least one of them is visible (primary if others are hidden): */
|
---|
1812 | if (countOfVisibleWindows() < 1)
|
---|
1813 | m_guestScreenVisibilityVector[0] = true;
|
---|
1814 | }
|
---|
1815 |
|
---|
1816 | /* Prepare initial screen visibility status of host-desires (same as facts): */
|
---|
1817 | m_guestScreenVisibilityVectorHostDesires.resize(cMonitorCount);
|
---|
1818 | for (int iScreenIndex = 0; iScreenIndex < m_guestScreenVisibilityVector.size(); ++iScreenIndex)
|
---|
1819 | m_guestScreenVisibilityVectorHostDesires[iScreenIndex] = m_guestScreenVisibilityVector[iScreenIndex];
|
---|
1820 |
|
---|
1821 | /* Make sure action-pool knows guest-screen visibility status: */
|
---|
1822 | for (int iScreenIndex = 0; iScreenIndex < m_guestScreenVisibilityVector.size(); ++iScreenIndex)
|
---|
1823 | actionPool()->toRuntime()->setGuestScreenVisible(iScreenIndex, m_guestScreenVisibilityVector.at(iScreenIndex));
|
---|
1824 | }
|
---|
1825 |
|
---|
1826 | void UIMachine::enterInitialVisualState()
|
---|
1827 | {
|
---|
1828 | sltChangeVisualState(m_enmInitialVisualState);
|
---|
1829 | }
|
---|
1830 |
|
---|
1831 | void UIMachine::cleanupMachineLogic()
|
---|
1832 | {
|
---|
1833 | /* Delete machine-logic if any: */
|
---|
1834 | UIMachineLogic::destroy(m_pMachineLogic);
|
---|
1835 | }
|
---|
1836 |
|
---|
1837 | void UIMachine::cleanupBranding()
|
---|
1838 | {
|
---|
1839 | /* Cleanup machine-window icon: */
|
---|
1840 | delete m_pMachineWindowIcon;
|
---|
1841 | m_pMachineWindowIcon = 0;
|
---|
1842 | }
|
---|
1843 |
|
---|
1844 | void UIMachine::cleanupHostScreenData()
|
---|
1845 | {
|
---|
1846 | #ifdef VBOX_WS_MAC
|
---|
1847 | /* Remove display reconfiguration callback: */
|
---|
1848 | CGDisplayRemoveReconfigurationCallback(cgDisplayReconfigurationCallback, this);
|
---|
1849 | #endif /* VBOX_WS_MAC */
|
---|
1850 | }
|
---|
1851 |
|
---|
1852 | void UIMachine::cleanupActions()
|
---|
1853 | {
|
---|
1854 | #ifdef VBOX_WS_MAC
|
---|
1855 | /* Destroy Mac OS X menu-bar: */
|
---|
1856 | delete m_pMenuBar;
|
---|
1857 | m_pMenuBar = 0;
|
---|
1858 | #endif /* VBOX_WS_MAC */
|
---|
1859 |
|
---|
1860 | /* Destroy action-pool if necessary: */
|
---|
1861 | if (actionPool())
|
---|
1862 | UIActionPool::destroy(actionPool());
|
---|
1863 | }
|
---|
1864 |
|
---|
1865 | void UIMachine::cleanupSession()
|
---|
1866 | {
|
---|
1867 | /* Destroy session UI if exists: */
|
---|
1868 | delete m_pSession;
|
---|
1869 | m_pSession = 0;
|
---|
1870 | }
|
---|
1871 |
|
---|
1872 | void UIMachine::cleanupNotificationCenter()
|
---|
1873 | {
|
---|
1874 | UINotificationCenter::destroy();
|
---|
1875 | }
|
---|
1876 |
|
---|
1877 | void UIMachine::cleanup()
|
---|
1878 | {
|
---|
1879 | /* Preprocess all the meta-events: */
|
---|
1880 | QApplication::sendPostedEvents(0, QEvent::MetaCall);
|
---|
1881 |
|
---|
1882 | /* Cleanup stuff: */
|
---|
1883 | cleanupMachineLogic();
|
---|
1884 | cleanupBranding();
|
---|
1885 | cleanupHostScreenData();
|
---|
1886 | cleanupActions();
|
---|
1887 | cleanupSession();
|
---|
1888 | cleanupNotificationCenter();
|
---|
1889 | }
|
---|
1890 |
|
---|
1891 | void UIMachine::updateActionRestrictions()
|
---|
1892 | {
|
---|
1893 | /* Get host and prepare restrictions: */
|
---|
1894 | UIExtraDataMetaDefs::RuntimeMenuMachineActionType restrictionForMachine =
|
---|
1895 | UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Invalid;
|
---|
1896 | UIExtraDataMetaDefs::RuntimeMenuViewActionType restrictionForView =
|
---|
1897 | UIExtraDataMetaDefs::RuntimeMenuViewActionType_Invalid;
|
---|
1898 | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType restrictionForDevices =
|
---|
1899 | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Invalid;
|
---|
1900 |
|
---|
1901 | /* Separate process stuff: */
|
---|
1902 | {
|
---|
1903 | /* Initialize 'Machine' menu: */
|
---|
1904 | if (!uiCommon().isSeparateProcess())
|
---|
1905 | restrictionForMachine = (UIExtraDataMetaDefs::RuntimeMenuMachineActionType)
|
---|
1906 | (restrictionForMachine | UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Detach);
|
---|
1907 | }
|
---|
1908 |
|
---|
1909 | /* VRDE server stuff: */
|
---|
1910 | {
|
---|
1911 | /* Initialize 'View' menu: */
|
---|
1912 | bool fServerPresent = false;
|
---|
1913 | acquireWhetherVRDEServerPresent(fServerPresent);
|
---|
1914 | if (!fServerPresent)
|
---|
1915 | restrictionForView = (UIExtraDataMetaDefs::RuntimeMenuViewActionType)
|
---|
1916 | (restrictionForView | UIExtraDataMetaDefs::RuntimeMenuViewActionType_VRDEServer);
|
---|
1917 | }
|
---|
1918 |
|
---|
1919 | /* Storage stuff: */
|
---|
1920 | {
|
---|
1921 | /* Initialize CD/FD menus: */
|
---|
1922 | ulong cHardDisks = 0;
|
---|
1923 | ulong iOpticalDevices = 0;
|
---|
1924 | ulong cFloppyDevices = 0;
|
---|
1925 | acquireAmountOfStorageDevices(cHardDisks, iOpticalDevices, cFloppyDevices);
|
---|
1926 | QAction *pOpticalDevicesMenu = actionPool()->action(UIActionIndexRT_M_Devices_M_OpticalDevices);
|
---|
1927 | QAction *pFloppyDevicesMenu = actionPool()->action(UIActionIndexRT_M_Devices_M_FloppyDevices);
|
---|
1928 | pOpticalDevicesMenu->setData((int)iOpticalDevices);
|
---|
1929 | pFloppyDevicesMenu->setData((int)cFloppyDevices);
|
---|
1930 | if (!iOpticalDevices)
|
---|
1931 | restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)
|
---|
1932 | (restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_OpticalDevices);
|
---|
1933 | if (!cFloppyDevices)
|
---|
1934 | restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)
|
---|
1935 | (restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_FloppyDevices);
|
---|
1936 | }
|
---|
1937 |
|
---|
1938 | /* Audio stuff: */
|
---|
1939 | {
|
---|
1940 | /* Do we need to restrict something? */
|
---|
1941 | bool fRestricted = false;
|
---|
1942 | /* Check whether audio adapter is present: */
|
---|
1943 | bool fAdapterPresent = false;
|
---|
1944 | acquireWhetherAudioAdapterPresent(fAdapterPresent);
|
---|
1945 | if (!fAdapterPresent)
|
---|
1946 | fRestricted = true;
|
---|
1947 | else
|
---|
1948 | {
|
---|
1949 | /* Check whether audio adapter is enabled: */
|
---|
1950 | bool fAdapterEnabled = false;
|
---|
1951 | acquireWhetherAudioAdapterEnabled(fAdapterEnabled);
|
---|
1952 | if (!fAdapterEnabled)
|
---|
1953 | fRestricted = true;
|
---|
1954 | }
|
---|
1955 | /* Apply restrictions: */
|
---|
1956 | if (fRestricted)
|
---|
1957 | restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)
|
---|
1958 | (restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Audio);
|
---|
1959 | }
|
---|
1960 |
|
---|
1961 | /* Network stuff: */
|
---|
1962 | {
|
---|
1963 | /* Initialize Network menu: */
|
---|
1964 | bool fAtLeastOneAdapterEnabled = false;
|
---|
1965 | acquireWhetherAtLeastOneNetworkAdapterEnabled(fAtLeastOneAdapterEnabled);
|
---|
1966 | if (!fAtLeastOneAdapterEnabled)
|
---|
1967 | restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)
|
---|
1968 | (restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Network);
|
---|
1969 | }
|
---|
1970 |
|
---|
1971 | /* USB stuff: */
|
---|
1972 | {
|
---|
1973 | /* Check whether there is at least one USB controller with an available proxy. */
|
---|
1974 | bool fUSBEnabled = false;
|
---|
1975 | acquireWhetherUSBControllerEnabled(fUSBEnabled);
|
---|
1976 | if (!fUSBEnabled)
|
---|
1977 | restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)
|
---|
1978 | (restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_USBDevices);
|
---|
1979 | }
|
---|
1980 |
|
---|
1981 | /* WebCams stuff: */
|
---|
1982 | {
|
---|
1983 | /* Check whether there is an accessible video input devices pool: */
|
---|
1984 | bool fWebCamsEnabled = false;
|
---|
1985 | acquireWhetherVideoInputDevicesEnabled(fWebCamsEnabled);
|
---|
1986 | if (!fWebCamsEnabled)
|
---|
1987 | restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)
|
---|
1988 | (restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_WebCams);
|
---|
1989 | }
|
---|
1990 |
|
---|
1991 | /* Apply cumulative restriction for 'Machine' menu: */
|
---|
1992 | actionPool()->toRuntime()->setRestrictionForMenuMachine(UIActionRestrictionLevel_Session, restrictionForMachine);
|
---|
1993 | /* Apply cumulative restriction for 'View' menu: */
|
---|
1994 | actionPool()->toRuntime()->setRestrictionForMenuView(UIActionRestrictionLevel_Session, restrictionForView);
|
---|
1995 | /* Apply cumulative restriction for 'Devices' menu: */
|
---|
1996 | actionPool()->toRuntime()->setRestrictionForMenuDevices(UIActionRestrictionLevel_Session, restrictionForDevices);
|
---|
1997 | }
|
---|
1998 |
|
---|
1999 | #ifdef VBOX_WS_MAC
|
---|
2000 | void UIMachine::updateMenu()
|
---|
2001 | {
|
---|
2002 | /* Rebuild Mac OS X menu-bar: */
|
---|
2003 | m_pMenuBar->clear();
|
---|
2004 | foreach (QMenu *pMenu, actionPool()->menus())
|
---|
2005 | {
|
---|
2006 | UIMenu *pMenuUI = qobject_cast<UIMenu*>(pMenu);
|
---|
2007 | if (!pMenuUI->isConsumable() || !pMenuUI->isConsumed())
|
---|
2008 | m_pMenuBar->addMenu(pMenuUI);
|
---|
2009 | if (pMenuUI->isConsumable() && !pMenuUI->isConsumed())
|
---|
2010 | pMenuUI->setConsumed(true);
|
---|
2011 | }
|
---|
2012 | /* Update the dock menu as well: */
|
---|
2013 | if (machineLogic())
|
---|
2014 | machineLogic()->updateDock();
|
---|
2015 | }
|
---|
2016 | #endif /* VBOX_WS_MAC */
|
---|
2017 |
|
---|
2018 | void UIMachine::updateHostScreenData()
|
---|
2019 | {
|
---|
2020 | /* Rebuild host-screen data vector: */
|
---|
2021 | m_hostScreens.clear();
|
---|
2022 | for (int iScreenIndex = 0; iScreenIndex < UIDesktopWidgetWatchdog::screenCount(); ++iScreenIndex)
|
---|
2023 | m_hostScreens << gpDesktop->screenGeometry(iScreenIndex);
|
---|
2024 |
|
---|
2025 | /* Make sure action-pool knows host-screen count: */
|
---|
2026 | actionPool()->toRuntime()->setHostScreenCount(m_hostScreens.size());
|
---|
2027 | }
|
---|
2028 |
|
---|
2029 | void UIMachine::updateMousePointerShape()
|
---|
2030 | {
|
---|
2031 | /* Fetch incoming shape data: */
|
---|
2032 | const bool fHasAlpha = m_shapeData.hasAlpha();
|
---|
2033 | const uint uWidth = m_shapeData.shapeSize().width();
|
---|
2034 | const uint uHeight = m_shapeData.shapeSize().height();
|
---|
2035 | const uchar *pShapeData = m_shapeData.shape().constData();
|
---|
2036 | AssertMsgReturnVoid(pShapeData, ("Shape data must not be NULL!\n"));
|
---|
2037 |
|
---|
2038 | /* Invalidate mouse pointer shape initially: */
|
---|
2039 | m_fIsValidPointerShapePresent = false;
|
---|
2040 | m_cursorShapePixmap = QPixmap();
|
---|
2041 | m_cursorMaskPixmap = QPixmap();
|
---|
2042 |
|
---|
2043 | /* Parse incoming shape data: */
|
---|
2044 | const uchar *pSrcAndMaskPtr = pShapeData;
|
---|
2045 | const uint uAndMaskSize = (uWidth + 7) / 8 * uHeight;
|
---|
2046 | const uchar *pSrcShapePtr = pShapeData + ((uAndMaskSize + 3) & ~3);
|
---|
2047 |
|
---|
2048 | #if defined (VBOX_WS_WIN)
|
---|
2049 |
|
---|
2050 | /* Create an ARGB image out of the shape data: */
|
---|
2051 |
|
---|
2052 | // WORKAROUND:
|
---|
2053 | // Qt5 QCursor recommends 32 x 32 cursor, therefore the original data is copied to
|
---|
2054 | // a larger QImage if necessary. Cursors like 10x16 did not work correctly (Solaris 10 guest).
|
---|
2055 | // Align the cursor dimensions to 32 bit pixels, because for example a 56x56 monochrome cursor
|
---|
2056 | // did not work correctly on Windows host.
|
---|
2057 | const uint uCursorWidth = RT_ALIGN_32(uWidth, 32);
|
---|
2058 | const uint uCursorHeight = RT_ALIGN_32(uHeight, 32);
|
---|
2059 |
|
---|
2060 | if (fHasAlpha)
|
---|
2061 | {
|
---|
2062 | QImage image(uCursorWidth, uCursorHeight, QImage::Format_ARGB32);
|
---|
2063 | memset(image.bits(), 0, image.sizeInBytes());
|
---|
2064 |
|
---|
2065 | const uint32_t *pu32SrcShapeScanline = (uint32_t *)pSrcShapePtr;
|
---|
2066 | for (uint y = 0; y < uHeight; ++y, pu32SrcShapeScanline += uWidth)
|
---|
2067 | memcpy(image.scanLine(y), pu32SrcShapeScanline, uWidth * sizeof(uint32_t));
|
---|
2068 |
|
---|
2069 | m_cursorShapePixmap = QPixmap::fromImage(image);
|
---|
2070 | }
|
---|
2071 | else
|
---|
2072 | {
|
---|
2073 | if (isPointer1bpp(pSrcShapePtr, uWidth, uHeight))
|
---|
2074 | {
|
---|
2075 | // Incoming data consist of 32 bit BGR XOR mask and 1 bit AND mask.
|
---|
2076 | // XOR pixels contain either 0x00000000 or 0x00FFFFFF.
|
---|
2077 | //
|
---|
2078 | // Originally intended result (F denotes 0x00FFFFFF):
|
---|
2079 | // XOR AND
|
---|
2080 | // 0 0 black
|
---|
2081 | // F 0 white
|
---|
2082 | // 0 1 transparent
|
---|
2083 | // F 1 xor'd
|
---|
2084 | //
|
---|
2085 | // Actual Qt5 result for color table 0:0xFF000000, 1:0xFFFFFFFF
|
---|
2086 | // (tested on Windows 7 and 10 64 bit hosts):
|
---|
2087 | // Bitmap Mask
|
---|
2088 | // 0 0 black
|
---|
2089 | // 1 0 white
|
---|
2090 | // 0 1 xor
|
---|
2091 | // 1 1 transparent
|
---|
2092 |
|
---|
2093 | QVector<QRgb> colors(2);
|
---|
2094 | colors[0] = UINT32_C(0xFF000000);
|
---|
2095 | colors[1] = UINT32_C(0xFFFFFFFF);
|
---|
2096 |
|
---|
2097 | QImage bitmap(uCursorWidth, uCursorHeight, QImage::Format_Mono);
|
---|
2098 | bitmap.setColorTable(colors);
|
---|
2099 | memset(bitmap.bits(), 0xFF, bitmap.sizeInBytes());
|
---|
2100 |
|
---|
2101 | QImage mask(uCursorWidth, uCursorHeight, QImage::Format_Mono);
|
---|
2102 | mask.setColorTable(colors);
|
---|
2103 | memset(mask.bits(), 0xFF, mask.sizeInBytes());
|
---|
2104 |
|
---|
2105 | const uint8_t *pu8SrcAndScanline = pSrcAndMaskPtr;
|
---|
2106 | const uint32_t *pu32SrcShapeScanline = (uint32_t *)pSrcShapePtr;
|
---|
2107 | for (uint y = 0; y < uHeight; ++y)
|
---|
2108 | {
|
---|
2109 | for (uint x = 0; x < uWidth; ++x)
|
---|
2110 | {
|
---|
2111 | const uint8_t u8Bit = (uint8_t)(1 << (7 - x % 8));
|
---|
2112 |
|
---|
2113 | const uint8_t u8SrcMaskByte = pu8SrcAndScanline[x / 8];
|
---|
2114 | const uint8_t u8SrcMaskBit = u8SrcMaskByte & u8Bit;
|
---|
2115 | const uint32_t u32SrcPixel = pu32SrcShapeScanline[x] & UINT32_C(0xFFFFFF);
|
---|
2116 |
|
---|
2117 | uint8_t *pu8DstMaskByte = &mask.scanLine(y)[x / 8];
|
---|
2118 | uint8_t *pu8DstBitmapByte = &bitmap.scanLine(y)[x / 8];
|
---|
2119 |
|
---|
2120 | if (u8SrcMaskBit == 0)
|
---|
2121 | {
|
---|
2122 | if (u32SrcPixel == 0)
|
---|
2123 | {
|
---|
2124 | /* Black: Qt Bitmap = 0, Mask = 0 */
|
---|
2125 | *pu8DstMaskByte &= ~u8Bit;
|
---|
2126 | *pu8DstBitmapByte &= ~u8Bit;
|
---|
2127 | }
|
---|
2128 | else
|
---|
2129 | {
|
---|
2130 | /* White: Qt Bitmap = 1, Mask = 0 */
|
---|
2131 | *pu8DstMaskByte &= ~u8Bit;
|
---|
2132 | *pu8DstBitmapByte |= u8Bit;
|
---|
2133 | }
|
---|
2134 | }
|
---|
2135 | else
|
---|
2136 | {
|
---|
2137 | if (u32SrcPixel == 0)
|
---|
2138 | {
|
---|
2139 | /* Transparent: Qt Bitmap = 1, Mask = 1 */
|
---|
2140 | *pu8DstMaskByte |= u8Bit;
|
---|
2141 | *pu8DstBitmapByte |= u8Bit;
|
---|
2142 | }
|
---|
2143 | else
|
---|
2144 | {
|
---|
2145 | /* Xor'ed: Qt Bitmap = 0, Mask = 1 */
|
---|
2146 | *pu8DstMaskByte |= u8Bit;
|
---|
2147 | *pu8DstBitmapByte &= ~u8Bit;
|
---|
2148 | }
|
---|
2149 | }
|
---|
2150 | }
|
---|
2151 |
|
---|
2152 | pu8SrcAndScanline += (uWidth + 7) / 8;
|
---|
2153 | pu32SrcShapeScanline += uWidth;
|
---|
2154 | }
|
---|
2155 |
|
---|
2156 | m_cursorShapePixmap = QBitmap::fromImage(bitmap);
|
---|
2157 | m_cursorMaskPixmap = QBitmap::fromImage(mask);
|
---|
2158 | }
|
---|
2159 | else
|
---|
2160 | {
|
---|
2161 | /* Assign alpha channel values according to the AND mask: 1 -> 0x00, 0 -> 0xFF: */
|
---|
2162 | QImage image(uCursorWidth, uCursorHeight, QImage::Format_ARGB32);
|
---|
2163 | memset(image.bits(), 0, image.sizeInBytes());
|
---|
2164 |
|
---|
2165 | const uint8_t *pu8SrcAndScanline = pSrcAndMaskPtr;
|
---|
2166 | const uint32_t *pu32SrcShapeScanline = (uint32_t *)pSrcShapePtr;
|
---|
2167 |
|
---|
2168 | for (uint y = 0; y < uHeight; ++y)
|
---|
2169 | {
|
---|
2170 | uint32_t *pu32DstPixel = (uint32_t *)image.scanLine(y);
|
---|
2171 |
|
---|
2172 | for (uint x = 0; x < uWidth; ++x)
|
---|
2173 | {
|
---|
2174 | const uint8_t u8Bit = (uint8_t)(1 << (7 - x % 8));
|
---|
2175 | const uint8_t u8SrcMaskByte = pu8SrcAndScanline[x / 8];
|
---|
2176 |
|
---|
2177 | if (u8SrcMaskByte & u8Bit)
|
---|
2178 | *pu32DstPixel++ = pu32SrcShapeScanline[x] & UINT32_C(0x00FFFFFF);
|
---|
2179 | else
|
---|
2180 | *pu32DstPixel++ = pu32SrcShapeScanline[x] | UINT32_C(0xFF000000);
|
---|
2181 | }
|
---|
2182 |
|
---|
2183 | pu32SrcShapeScanline += uWidth;
|
---|
2184 | pu8SrcAndScanline += (uWidth + 7) / 8;
|
---|
2185 | }
|
---|
2186 |
|
---|
2187 | m_cursorShapePixmap = QPixmap::fromImage(image);
|
---|
2188 | }
|
---|
2189 | }
|
---|
2190 |
|
---|
2191 | /* Mark mouse pointer shape valid: */
|
---|
2192 | m_fIsValidPointerShapePresent = true;
|
---|
2193 |
|
---|
2194 | #elif defined(VBOX_WS_NIX) || defined(VBOX_WS_MAC)
|
---|
2195 |
|
---|
2196 | /* Create an ARGB image out of the shape data: */
|
---|
2197 | QImage image(uWidth, uHeight, QImage::Format_ARGB32);
|
---|
2198 |
|
---|
2199 | if (fHasAlpha)
|
---|
2200 | {
|
---|
2201 | memcpy(image.bits(), pSrcShapePtr, uHeight * uWidth * 4);
|
---|
2202 | }
|
---|
2203 | else
|
---|
2204 | {
|
---|
2205 | renderCursorPixels((uint32_t *)pSrcShapePtr, pSrcAndMaskPtr,
|
---|
2206 | uWidth, uHeight,
|
---|
2207 | (uint32_t *)image.bits(), uHeight * uWidth * 4);
|
---|
2208 | }
|
---|
2209 |
|
---|
2210 | /* Create cursor-pixmap from the image: */
|
---|
2211 | m_cursorShapePixmap = QPixmap::fromImage(image);
|
---|
2212 |
|
---|
2213 | /* Mark mouse pointer shape valid: */
|
---|
2214 | m_fIsValidPointerShapePresent = true;
|
---|
2215 |
|
---|
2216 | #else
|
---|
2217 |
|
---|
2218 | # warning "port me"
|
---|
2219 |
|
---|
2220 | #endif
|
---|
2221 |
|
---|
2222 | /* Cache cursor pixmap size and hotspot: */
|
---|
2223 | m_cursorSize = m_cursorShapePixmap.size();
|
---|
2224 | m_cursorHotspot = m_shapeData.hotSpot();
|
---|
2225 | }
|
---|
2226 |
|
---|
2227 | void UIMachine::updateMouseState()
|
---|
2228 | {
|
---|
2229 | uisession()->acquireWhetherAbsoluteSupported(m_fIsMouseSupportsAbsolute);
|
---|
2230 | uisession()->acquireWhetherRelativeSupported(m_fIsMouseSupportsRelative);
|
---|
2231 | uisession()->acquireWhetherTouchScreenSupported(m_fIsMouseSupportsTouchScreen);
|
---|
2232 | uisession()->acquireWhetherTouchPadSupported(m_fIsMouseSupportsTouchPad);
|
---|
2233 | uisession()->acquireWhetherNeedsHostCursor(m_fIsMouseHostCursorNeeded);
|
---|
2234 | }
|
---|
2235 |
|
---|
2236 | #if defined(VBOX_WS_NIX) || defined(VBOX_WS_MAC)
|
---|
2237 | /* static */
|
---|
2238 | void UIMachine::renderCursorPixels(const uint32_t *pu32XOR, const uint8_t *pu8AND,
|
---|
2239 | uint32_t u32Width, uint32_t u32Height,
|
---|
2240 | uint32_t *pu32Pixels, uint32_t cbPixels)
|
---|
2241 | {
|
---|
2242 | /* Output pixels set to 0 which allow to not write transparent pixels anymore. */
|
---|
2243 | memset(pu32Pixels, 0, cbPixels);
|
---|
2244 |
|
---|
2245 | const uint32_t *pu32XORSrc = pu32XOR; /* Iterator for source XOR pixels. */
|
---|
2246 | const uint8_t *pu8ANDSrcLine = pu8AND; /* The current AND mask scanline. */
|
---|
2247 | uint32_t *pu32Dst = pu32Pixels; /* Iterator for all destination BGRA pixels. */
|
---|
2248 |
|
---|
2249 | /* Some useful constants. */
|
---|
2250 | const int cbANDLine = ((int)u32Width + 7) / 8;
|
---|
2251 |
|
---|
2252 | int y;
|
---|
2253 | for (y = 0; y < (int)u32Height; ++y)
|
---|
2254 | {
|
---|
2255 | int x;
|
---|
2256 | for (x = 0; x < (int)u32Width; ++x)
|
---|
2257 | {
|
---|
2258 | const uint32_t u32Pixel = *pu32XORSrc; /* Current pixel at (x,y) */
|
---|
2259 | const uint8_t *pu8ANDSrc = pu8ANDSrcLine + x / 8; /* Byte which containt current AND bit. */
|
---|
2260 |
|
---|
2261 | if ((*pu8ANDSrc << (x % 8)) & 0x80)
|
---|
2262 | {
|
---|
2263 | if (u32Pixel)
|
---|
2264 | {
|
---|
2265 | const uint32_t u32PixelInverted = ~u32Pixel;
|
---|
2266 |
|
---|
2267 | /* Scan neighbor pixels and assign them if they are transparent. */
|
---|
2268 | int dy;
|
---|
2269 | for (dy = -1; dy <= 1; ++dy)
|
---|
2270 | {
|
---|
2271 | const int yn = y + dy;
|
---|
2272 | if (yn < 0 || yn >= (int)u32Height)
|
---|
2273 | continue; /* Do not cross the bounds. */
|
---|
2274 |
|
---|
2275 | int dx;
|
---|
2276 | for (dx = -1; dx <= 1; ++dx)
|
---|
2277 | {
|
---|
2278 | const int xn = x + dx;
|
---|
2279 | if (xn < 0 || xn >= (int)u32Width)
|
---|
2280 | continue; /* Do not cross the bounds. */
|
---|
2281 |
|
---|
2282 | if (dx != 0 || dy != 0)
|
---|
2283 | {
|
---|
2284 | /* Check if the neighbor pixel is transparent. */
|
---|
2285 | const uint32_t *pu32XORNeighborSrc = &pu32XORSrc[dy * (int)u32Width + dx];
|
---|
2286 | const uint8_t *pu8ANDNeighborSrc = pu8ANDSrcLine + dy * cbANDLine + xn / 8;
|
---|
2287 | if ( *pu32XORNeighborSrc == 0
|
---|
2288 | && ((*pu8ANDNeighborSrc << (xn % 8)) & 0x80) != 0)
|
---|
2289 | {
|
---|
2290 | /* Transparent neighbor pixels are replaced with the source pixel value. */
|
---|
2291 | uint32_t *pu32PixelNeighborDst = &pu32Dst[dy * (int)u32Width + dx];
|
---|
2292 | *pu32PixelNeighborDst = u32Pixel | 0xFF000000;
|
---|
2293 | }
|
---|
2294 | }
|
---|
2295 | else
|
---|
2296 | {
|
---|
2297 | /* The pixel itself is replaced with inverted value. */
|
---|
2298 | *pu32Dst = u32PixelInverted | 0xFF000000;
|
---|
2299 | }
|
---|
2300 | }
|
---|
2301 | }
|
---|
2302 | }
|
---|
2303 | else
|
---|
2304 | {
|
---|
2305 | /* The pixel does not affect the screen.
|
---|
2306 | * Do nothing. Do not touch destination which can already contain generated pixels.
|
---|
2307 | */
|
---|
2308 | }
|
---|
2309 | }
|
---|
2310 | else
|
---|
2311 | {
|
---|
2312 | /* AND bit is 0, the pixel will be just drawn. */
|
---|
2313 | *pu32Dst = u32Pixel | 0xFF000000;
|
---|
2314 | }
|
---|
2315 |
|
---|
2316 | ++pu32XORSrc; /* Next source pixel. */
|
---|
2317 | ++pu32Dst; /* Next destination pixel. */
|
---|
2318 | }
|
---|
2319 |
|
---|
2320 | /* Next AND scanline. */
|
---|
2321 | pu8ANDSrcLine += cbANDLine;
|
---|
2322 | }
|
---|
2323 | }
|
---|
2324 | #endif /* VBOX_WS_NIX || VBOX_WS_MAC */
|
---|
2325 |
|
---|
2326 | #ifdef VBOX_WS_WIN
|
---|
2327 | /* static */
|
---|
2328 | bool UIMachine::isPointer1bpp(const uint8_t *pu8XorMask,
|
---|
2329 | uint uWidth,
|
---|
2330 | uint uHeight)
|
---|
2331 | {
|
---|
2332 | /* Check if the pointer has only 0 and 0xFFFFFF pixels, ignoring the alpha channel. */
|
---|
2333 | const uint32_t *pu32Src = (uint32_t *)pu8XorMask;
|
---|
2334 |
|
---|
2335 | uint y;
|
---|
2336 | for (y = 0; y < uHeight ; ++y)
|
---|
2337 | {
|
---|
2338 | uint x;
|
---|
2339 | for (x = 0; x < uWidth; ++x)
|
---|
2340 | {
|
---|
2341 | const uint32_t u32Pixel = pu32Src[x] & UINT32_C(0xFFFFFF);
|
---|
2342 | if (u32Pixel != 0 && u32Pixel != UINT32_C(0xFFFFFF))
|
---|
2343 | return false;
|
---|
2344 | }
|
---|
2345 |
|
---|
2346 | pu32Src += uWidth;
|
---|
2347 | }
|
---|
2348 |
|
---|
2349 | return true;
|
---|
2350 | }
|
---|
2351 | #endif /* VBOX_WS_WIN */
|
---|
2352 |
|
---|
2353 | void UIMachine::updateVirtualizationState()
|
---|
2354 | {
|
---|
2355 | uisession()->acquireExecutionEngineType(m_enmVMExecutionEngine);
|
---|
2356 | uisession()->acquireWhetherHwVirtExNestedPagingEnabled(m_fIsHWVirtExNestedPagingEnabled);
|
---|
2357 | uisession()->acquireWhetherHwVirtExUXEnabled(m_fIsHWVirtExUXEnabled);
|
---|
2358 | uisession()->acquireEffectiveParavirtProvider(m_enmParavirtProvider);
|
---|
2359 | }
|
---|