1 | /* $Id: UIMachineWindowFullscreen.cpp 61659 2016-06-10 14:22:03Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIMachineWindowFullscreen class implementation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010-2015 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifdef VBOX_WITH_PRECOMPILED_HEADERS
|
---|
19 | # include <precomp.h>
|
---|
20 | #else /* !VBOX_WITH_PRECOMPILED_HEADERS */
|
---|
21 |
|
---|
22 | /* Qt includes: */
|
---|
23 | # include <QMenu>
|
---|
24 | # include <QTimer>
|
---|
25 | # ifdef VBOX_WS_WIN
|
---|
26 | # if QT_VERSION >= 0x050000
|
---|
27 | # include <QWindow>
|
---|
28 | # endif /* QT_VERSION >= 0x050000 */
|
---|
29 | # endif /* VBOX_WS_WIN */
|
---|
30 |
|
---|
31 | /* GUI includes: */
|
---|
32 | # include "VBoxGlobal.h"
|
---|
33 | # include "UIExtraDataManager.h"
|
---|
34 | # include "UISession.h"
|
---|
35 | # include "UIActionPoolRuntime.h"
|
---|
36 | # include "UIMachineLogicFullscreen.h"
|
---|
37 | # include "UIMachineWindowFullscreen.h"
|
---|
38 | # include "UIMachineView.h"
|
---|
39 | # if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
|
---|
40 | # include "UIMachineDefs.h"
|
---|
41 | # include "UIMiniToolBar.h"
|
---|
42 | # elif defined(VBOX_WS_MAC)
|
---|
43 | # include "UIFrameBuffer.h"
|
---|
44 | # include "VBoxUtils-darwin.h"
|
---|
45 | # include "UICocoaApplication.h"
|
---|
46 | # endif /* VBOX_WS_MAC */
|
---|
47 |
|
---|
48 | /* COM includes: */
|
---|
49 | # include "CSnapshot.h"
|
---|
50 |
|
---|
51 | #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
|
---|
52 |
|
---|
53 |
|
---|
54 | UIMachineWindowFullscreen::UIMachineWindowFullscreen(UIMachineLogic *pMachineLogic, ulong uScreenId)
|
---|
55 | : UIMachineWindow(pMachineLogic, uScreenId)
|
---|
56 | #if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
|
---|
57 | , m_pMiniToolBar(0)
|
---|
58 | #endif /* VBOX_WS_WIN || VBOX_WS_X11 */
|
---|
59 | #ifdef VBOX_WS_MAC
|
---|
60 | , m_fIsInFullscreenTransition(false)
|
---|
61 | #endif /* VBOX_WS_MAC */
|
---|
62 | , m_fWasMinimized(false)
|
---|
63 | {
|
---|
64 | }
|
---|
65 |
|
---|
66 | #ifdef VBOX_WS_MAC
|
---|
67 | void UIMachineWindowFullscreen::handleNativeNotification(const QString &strNativeNotificationName)
|
---|
68 | {
|
---|
69 | /* Make sure this method is only used for ML and next: */
|
---|
70 | AssertReturnVoid(vboxGlobal().osRelease() > MacOSXRelease_Lion);
|
---|
71 |
|
---|
72 | /* Log all arrived notifications: */
|
---|
73 | LogRel(("UIMachineWindowFullscreen::handleNativeNotification: Notification '%s' received.\n",
|
---|
74 | strNativeNotificationName.toLatin1().constData()));
|
---|
75 |
|
---|
76 | /* Handle 'NSWindowWillEnterFullScreenNotification' notification: */
|
---|
77 | if (strNativeNotificationName == "NSWindowWillEnterFullScreenNotification")
|
---|
78 | {
|
---|
79 | LogRel(("UIMachineWindowFullscreen::handleNativeNotification: "
|
---|
80 | "Native fullscreen mode about to enter, notifying listener...\n"));
|
---|
81 | emit sigNotifyAboutNativeFullscreenWillEnter();
|
---|
82 | }
|
---|
83 | /* Handle 'NSWindowDidEnterFullScreenNotification' notification: */
|
---|
84 | else if (strNativeNotificationName == "NSWindowDidEnterFullScreenNotification")
|
---|
85 | {
|
---|
86 | /* Mark window transition complete: */
|
---|
87 | m_fIsInFullscreenTransition = false;
|
---|
88 | LogRel(("UIMachineWindowFullscreen::handleNativeNotification: "
|
---|
89 | "Native fullscreen mode entered, notifying listener...\n"));
|
---|
90 | /* Update console's display viewport and 3D overlay: */
|
---|
91 | machineView()->updateViewport();
|
---|
92 | emit sigNotifyAboutNativeFullscreenDidEnter();
|
---|
93 | }
|
---|
94 | /* Handle 'NSWindowWillExitFullScreenNotification' notification: */
|
---|
95 | else if (strNativeNotificationName == "NSWindowWillExitFullScreenNotification")
|
---|
96 | {
|
---|
97 | LogRel(("UIMachineWindowFullscreen::handleNativeNotification: "
|
---|
98 | "Native fullscreen mode about to exit, notifying listener...\n"));
|
---|
99 | emit sigNotifyAboutNativeFullscreenWillExit();
|
---|
100 | }
|
---|
101 | /* Handle 'NSWindowDidExitFullScreenNotification' notification: */
|
---|
102 | else if (strNativeNotificationName == "NSWindowDidExitFullScreenNotification")
|
---|
103 | {
|
---|
104 | /* Mark window transition complete: */
|
---|
105 | m_fIsInFullscreenTransition = false;
|
---|
106 | LogRel(("UIMachineWindowFullscreen::handleNativeNotification: "
|
---|
107 | "Native fullscreen mode exited, notifying listener...\n"));
|
---|
108 | /* Update console's display viewport and 3D overlay: */
|
---|
109 | machineView()->updateViewport();
|
---|
110 | emit sigNotifyAboutNativeFullscreenDidExit();
|
---|
111 | }
|
---|
112 | /* Handle 'NSWindowDidFailToEnterFullScreenNotification' notification: */
|
---|
113 | else if (strNativeNotificationName == "NSWindowDidFailToEnterFullScreenNotification")
|
---|
114 | {
|
---|
115 | /* Mark window transition complete: */
|
---|
116 | m_fIsInFullscreenTransition = false;
|
---|
117 | LogRel(("UIMachineWindowFullscreen::handleNativeNotification: "
|
---|
118 | "Native fullscreen mode fail to enter, notifying listener...\n"));
|
---|
119 | emit sigNotifyAboutNativeFullscreenFailToEnter();
|
---|
120 | }
|
---|
121 | }
|
---|
122 | #endif /* VBOX_WS_MAC */
|
---|
123 |
|
---|
124 | #if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
|
---|
125 | void UIMachineWindowFullscreen::sltMachineStateChanged()
|
---|
126 | {
|
---|
127 | /* Call to base-class: */
|
---|
128 | UIMachineWindow::sltMachineStateChanged();
|
---|
129 |
|
---|
130 | /* Update mini-toolbar: */
|
---|
131 | updateAppearanceOf(UIVisualElement_MiniToolBar);
|
---|
132 | }
|
---|
133 |
|
---|
134 | void UIMachineWindowFullscreen::sltRevokeWindowActivation()
|
---|
135 | {
|
---|
136 | /* Make sure window is visible: */
|
---|
137 | if (!isVisible() || isMinimized())
|
---|
138 | return;
|
---|
139 |
|
---|
140 | /* Revoke stolen activation: */
|
---|
141 | #ifdef VBOX_WS_X11
|
---|
142 | raise();
|
---|
143 | #endif /* VBOX_WS_X11 */
|
---|
144 | activateWindow();
|
---|
145 | }
|
---|
146 | #endif /* VBOX_WS_WIN || VBOX_WS_X11 */
|
---|
147 |
|
---|
148 | #ifdef VBOX_WS_MAC
|
---|
149 | void UIMachineWindowFullscreen::sltEnterNativeFullscreen(UIMachineWindow *pMachineWindow)
|
---|
150 | {
|
---|
151 | /* Make sure this slot is called only under ML and next: */
|
---|
152 | AssertReturnVoid(vboxGlobal().osRelease() > MacOSXRelease_Lion);
|
---|
153 |
|
---|
154 | /* Make sure it is NULL or 'this' window passed: */
|
---|
155 | if (pMachineWindow && pMachineWindow != this)
|
---|
156 | return;
|
---|
157 |
|
---|
158 | /* Make sure this window has fullscreen logic: */
|
---|
159 | UIMachineLogicFullscreen *pFullscreenLogic = qobject_cast<UIMachineLogicFullscreen*>(machineLogic());
|
---|
160 | AssertPtrReturnVoid(pFullscreenLogic);
|
---|
161 |
|
---|
162 | /* Make sure this window should be shown and mapped to host-screen: */
|
---|
163 | if (!uisession()->isScreenVisible(m_uScreenId) ||
|
---|
164 | !pFullscreenLogic->hasHostScreenForGuestScreen(m_uScreenId))
|
---|
165 | return;
|
---|
166 |
|
---|
167 | /* Mark window 'transitioned to fullscreen': */
|
---|
168 | m_fIsInFullscreenTransition = true;
|
---|
169 |
|
---|
170 | /* Enter native fullscreen mode if necessary: */
|
---|
171 | if ( (pFullscreenLogic->screensHaveSeparateSpaces() || m_uScreenId == 0)
|
---|
172 | && !darwinIsInFullscreenMode(this))
|
---|
173 | darwinToggleFullscreenMode(this);
|
---|
174 | }
|
---|
175 |
|
---|
176 | void UIMachineWindowFullscreen::sltExitNativeFullscreen(UIMachineWindow *pMachineWindow)
|
---|
177 | {
|
---|
178 | /* Make sure this slot is called only under ML and next: */
|
---|
179 | AssertReturnVoid(vboxGlobal().osRelease() > MacOSXRelease_Lion);
|
---|
180 |
|
---|
181 | /* Make sure it is NULL or 'this' window passed: */
|
---|
182 | if (pMachineWindow && pMachineWindow != this)
|
---|
183 | return;
|
---|
184 |
|
---|
185 | /* Make sure this window has fullscreen logic: */
|
---|
186 | UIMachineLogicFullscreen *pFullscreenLogic = qobject_cast<UIMachineLogicFullscreen*>(machineLogic());
|
---|
187 | AssertPtrReturnVoid(pFullscreenLogic);
|
---|
188 |
|
---|
189 | /* Mark window 'transitioned from fullscreen': */
|
---|
190 | m_fIsInFullscreenTransition = true;
|
---|
191 |
|
---|
192 | /* Exit native fullscreen mode if necessary: */
|
---|
193 | if ( (pFullscreenLogic->screensHaveSeparateSpaces() || m_uScreenId == 0)
|
---|
194 | && darwinIsInFullscreenMode(this))
|
---|
195 | darwinToggleFullscreenMode(this);
|
---|
196 | }
|
---|
197 | #endif /* VBOX_WS_MAC */
|
---|
198 |
|
---|
199 | void UIMachineWindowFullscreen::prepareVisualState()
|
---|
200 | {
|
---|
201 | /* Call to base-class: */
|
---|
202 | UIMachineWindow::prepareVisualState();
|
---|
203 |
|
---|
204 | /* The background has to go black: */
|
---|
205 | QPalette palette(centralWidget()->palette());
|
---|
206 | palette.setColor(centralWidget()->backgroundRole(), Qt::black);
|
---|
207 | centralWidget()->setPalette(palette);
|
---|
208 | centralWidget()->setAutoFillBackground(true);
|
---|
209 | setAutoFillBackground(true);
|
---|
210 |
|
---|
211 | #if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
|
---|
212 | /* Prepare mini-toolbar: */
|
---|
213 | prepareMiniToolbar();
|
---|
214 | #endif /* VBOX_WS_WIN || VBOX_WS_X11 */
|
---|
215 |
|
---|
216 | #ifdef VBOX_WS_MAC
|
---|
217 | /* Native fullscreen stuff on ML and next: */
|
---|
218 | if (vboxGlobal().osRelease() > MacOSXRelease_Lion)
|
---|
219 | {
|
---|
220 | /* Make sure this window has fullscreen logic: */
|
---|
221 | UIMachineLogicFullscreen *pFullscreenLogic = qobject_cast<UIMachineLogicFullscreen*>(machineLogic());
|
---|
222 | AssertPtrReturnVoid(pFullscreenLogic);
|
---|
223 | /* Enable fullscreen support for every screen which requires it: */
|
---|
224 | if (pFullscreenLogic->screensHaveSeparateSpaces() || m_uScreenId == 0)
|
---|
225 | darwinEnableFullscreenSupport(this);
|
---|
226 | /* Enable transience support for other screens: */
|
---|
227 | else
|
---|
228 | darwinEnableTransienceSupport(this);
|
---|
229 | /* Register to native fullscreen notifications: */
|
---|
230 | UICocoaApplication::instance()->registerToNotificationOfWindow("NSWindowWillEnterFullScreenNotification", this,
|
---|
231 | UIMachineWindow::handleNativeNotification);
|
---|
232 | UICocoaApplication::instance()->registerToNotificationOfWindow("NSWindowDidEnterFullScreenNotification", this,
|
---|
233 | UIMachineWindow::handleNativeNotification);
|
---|
234 | UICocoaApplication::instance()->registerToNotificationOfWindow("NSWindowWillExitFullScreenNotification", this,
|
---|
235 | UIMachineWindow::handleNativeNotification);
|
---|
236 | UICocoaApplication::instance()->registerToNotificationOfWindow("NSWindowDidExitFullScreenNotification", this,
|
---|
237 | UIMachineWindow::handleNativeNotification);
|
---|
238 | UICocoaApplication::instance()->registerToNotificationOfWindow("NSWindowDidFailToEnterFullScreenNotification", this,
|
---|
239 | UIMachineWindow::handleNativeNotification);
|
---|
240 | }
|
---|
241 | #endif /* VBOX_WS_MAC */
|
---|
242 | }
|
---|
243 |
|
---|
244 | #if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
|
---|
245 | void UIMachineWindowFullscreen::prepareMiniToolbar()
|
---|
246 | {
|
---|
247 | /* Make sure mini-toolbar is not restricted: */
|
---|
248 | if (!gEDataManager->miniToolbarEnabled(vboxGlobal().managedVMUuid()))
|
---|
249 | return;
|
---|
250 |
|
---|
251 | /* Create mini-toolbar: */
|
---|
252 | m_pMiniToolBar = new UIMiniToolBar(this,
|
---|
253 | GeometryType_Full,
|
---|
254 | gEDataManager->miniToolbarAlignment(vboxGlobal().managedVMUuid()),
|
---|
255 | gEDataManager->autoHideMiniToolbar(vboxGlobal().managedVMUuid()));
|
---|
256 | AssertPtrReturnVoid(m_pMiniToolBar);
|
---|
257 | {
|
---|
258 | /* Configure mini-toolbar: */
|
---|
259 | m_pMiniToolBar->addMenus(actionPool()->menus());
|
---|
260 | connect(m_pMiniToolBar, SIGNAL(sigMinimizeAction()),
|
---|
261 | this, SLOT(showMinimized()), Qt::QueuedConnection);
|
---|
262 | connect(m_pMiniToolBar, SIGNAL(sigExitAction()),
|
---|
263 | actionPool()->action(UIActionIndexRT_M_View_T_Fullscreen), SLOT(trigger()));
|
---|
264 | connect(m_pMiniToolBar, SIGNAL(sigCloseAction()),
|
---|
265 | actionPool()->action(UIActionIndex_M_Application_S_Close), SLOT(trigger()));
|
---|
266 | connect(m_pMiniToolBar, SIGNAL(sigNotifyAboutWindowActivationStolen()),
|
---|
267 | this, SLOT(sltRevokeWindowActivation()), Qt::QueuedConnection);
|
---|
268 | # ifdef VBOX_WS_X11
|
---|
269 | // WORKAROUND:
|
---|
270 | // Due to Unity bug we want native full-screen flag to be set
|
---|
271 | // for mini-toolbar _before_ trying to show it in full-screen mode.
|
---|
272 | // That significantly improves of chances to have required geometry.
|
---|
273 | if (vboxGlobal().typeOfWindowManager() == X11WMType_Compiz)
|
---|
274 | vboxGlobal().setFullScreenFlag(m_pMiniToolBar);
|
---|
275 | # endif /* VBOX_WS_X11 */
|
---|
276 | }
|
---|
277 | }
|
---|
278 | #endif /* VBOX_WS_WIN || VBOX_WS_X11 */
|
---|
279 |
|
---|
280 | #if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
|
---|
281 | void UIMachineWindowFullscreen::cleanupMiniToolbar()
|
---|
282 | {
|
---|
283 | /* Make sure mini-toolbar was created: */
|
---|
284 | if (!m_pMiniToolBar)
|
---|
285 | return;
|
---|
286 |
|
---|
287 | /* Save mini-toolbar settings: */
|
---|
288 | gEDataManager->setAutoHideMiniToolbar(m_pMiniToolBar->autoHide(), vboxGlobal().managedVMUuid());
|
---|
289 | /* Delete mini-toolbar: */
|
---|
290 | delete m_pMiniToolBar;
|
---|
291 | m_pMiniToolBar = 0;
|
---|
292 | }
|
---|
293 | #endif /* VBOX_WS_WIN || VBOX_WS_X11 */
|
---|
294 |
|
---|
295 | void UIMachineWindowFullscreen::cleanupVisualState()
|
---|
296 | {
|
---|
297 | #ifdef VBOX_WS_MAC
|
---|
298 | /* Native fullscreen stuff on ML and next: */
|
---|
299 | if (vboxGlobal().osRelease() > MacOSXRelease_Lion)
|
---|
300 | {
|
---|
301 | /* Unregister from native fullscreen notifications: */
|
---|
302 | UICocoaApplication::instance()->unregisterFromNotificationOfWindow("NSWindowWillEnterFullScreenNotification", this);
|
---|
303 | UICocoaApplication::instance()->unregisterFromNotificationOfWindow("NSWindowDidEnterFullScreenNotification", this);
|
---|
304 | UICocoaApplication::instance()->unregisterFromNotificationOfWindow("NSWindowWillExitFullScreenNotification", this);
|
---|
305 | UICocoaApplication::instance()->unregisterFromNotificationOfWindow("NSWindowDidExitFullScreenNotification", this);
|
---|
306 | UICocoaApplication::instance()->unregisterFromNotificationOfWindow("NSWindowDidFailToEnterFullScreenNotification", this);
|
---|
307 | }
|
---|
308 | #endif /* VBOX_WS_MAC */
|
---|
309 |
|
---|
310 | #if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
|
---|
311 | /* Cleanup mini-toolbar: */
|
---|
312 | cleanupMiniToolbar();
|
---|
313 | #endif /* VBOX_WS_WIN || VBOX_WS_X11 */
|
---|
314 |
|
---|
315 | /* Call to base-class: */
|
---|
316 | UIMachineWindow::cleanupVisualState();
|
---|
317 | }
|
---|
318 |
|
---|
319 | void UIMachineWindowFullscreen::placeOnScreen()
|
---|
320 | {
|
---|
321 | /* Get corresponding host-screen: */
|
---|
322 | const int iHostScreen = qobject_cast<UIMachineLogicFullscreen*>(machineLogic())->hostScreenForGuestScreen(m_uScreenId);
|
---|
323 | /* And corresponding working area: */
|
---|
324 | const QRect workingArea = vboxGlobal().screenGeometry(iHostScreen);
|
---|
325 | Q_UNUSED(workingArea);
|
---|
326 |
|
---|
327 | #if defined(VBOX_WS_MAC)
|
---|
328 |
|
---|
329 | /* Make sure this window has fullscreen logic: */
|
---|
330 | UIMachineLogicFullscreen *pFullscreenLogic = qobject_cast<UIMachineLogicFullscreen*>(machineLogic());
|
---|
331 | AssertPtrReturnVoid(pFullscreenLogic);
|
---|
332 |
|
---|
333 | /* Move window to the appropriate position: */
|
---|
334 | move(workingArea.topLeft());
|
---|
335 |
|
---|
336 | /* Resize window to the appropriate size on Lion and previous: */
|
---|
337 | if (vboxGlobal().osRelease() <= MacOSXRelease_Lion)
|
---|
338 | resize(workingArea.size());
|
---|
339 | /* Resize window to the appropriate size on ML and next
|
---|
340 | * only if that screen has no own user-space: */
|
---|
341 | else if (!pFullscreenLogic->screensHaveSeparateSpaces() && m_uScreenId != 0)
|
---|
342 | resize(workingArea.size());
|
---|
343 | else
|
---|
344 | {
|
---|
345 | /* Load normal geometry first of all: */
|
---|
346 | QRect geo = gEDataManager->machineWindowGeometry(UIVisualStateType_Normal, m_uScreenId, vboxGlobal().managedVMUuid());
|
---|
347 | /* If normal geometry is null => use frame-buffer size: */
|
---|
348 | if (geo.isNull())
|
---|
349 | {
|
---|
350 | const UIFrameBuffer *pFrameBuffer = uisession()->frameBuffer(m_uScreenId);
|
---|
351 | geo = QRect(QPoint(0, 0), QSize(pFrameBuffer->width(), pFrameBuffer->height()).boundedTo(workingArea.size()));
|
---|
352 | }
|
---|
353 | /* If frame-buffer size is null => use default size: */
|
---|
354 | if (geo.isNull())
|
---|
355 | geo = QRect(QPoint(0, 0), QSize(800, 600).boundedTo(workingArea.size()));
|
---|
356 | /* Move window to the center of working-area: */
|
---|
357 | geo.moveCenter(workingArea.center());
|
---|
358 | setGeometry(geo);
|
---|
359 | }
|
---|
360 |
|
---|
361 | #elif defined(VBOX_WS_WIN)
|
---|
362 |
|
---|
363 | # if QT_VERSION >= 0x050000
|
---|
364 | /* Map window onto required screen: */
|
---|
365 | windowHandle()->setScreen(qApp->screens().at(iHostScreen));
|
---|
366 | # endif /* QT_VERSION >= 0x050000 */
|
---|
367 | /* Set appropriate window size: */
|
---|
368 | resize(workingArea.size());
|
---|
369 | # if QT_VERSION < 0x050000
|
---|
370 | /* Move window onto required screen: */
|
---|
371 | move(workingArea.topLeft());
|
---|
372 | # endif /* QT_VERSION < 0x050000 */
|
---|
373 |
|
---|
374 | /* If there is a mini-toolbar: */
|
---|
375 | if (m_pMiniToolBar)
|
---|
376 | {
|
---|
377 | # if QT_VERSION >= 0x050000
|
---|
378 | /* Map mini-toolbar onto required screen: */
|
---|
379 | m_pMiniToolBar->windowHandle()->setScreen(qApp->screens().at(iHostScreen));
|
---|
380 | # endif /* QT_VERSION >= 0x050000 */
|
---|
381 | /* Set appropriate mini-toolbar size: */
|
---|
382 | m_pMiniToolBar->resize(workingArea.size());
|
---|
383 | # if QT_VERSION < 0x050000
|
---|
384 | /* Move mini-toolbar onto required screen: */
|
---|
385 | m_pMiniToolBar->move(workingArea.topLeft());
|
---|
386 | # endif /* QT_VERSION < 0x050000 */
|
---|
387 | }
|
---|
388 |
|
---|
389 | #elif defined(VBOX_WS_X11)
|
---|
390 |
|
---|
391 | /* Set appropriate geometry for window: */
|
---|
392 | resize(workingArea.size());
|
---|
393 | move(workingArea.topLeft());
|
---|
394 |
|
---|
395 | /* If there is a mini-toolbar: */
|
---|
396 | if (m_pMiniToolBar)
|
---|
397 | {
|
---|
398 | /* Set appropriate geometry for mini-toolbar: */
|
---|
399 | m_pMiniToolBar->resize(workingArea.size());
|
---|
400 | m_pMiniToolBar->move(workingArea.topLeft());
|
---|
401 | }
|
---|
402 |
|
---|
403 | #else
|
---|
404 |
|
---|
405 | # warning "port me"
|
---|
406 |
|
---|
407 | #endif
|
---|
408 | }
|
---|
409 |
|
---|
410 | void UIMachineWindowFullscreen::showInNecessaryMode()
|
---|
411 | {
|
---|
412 | /* Make sure window has fullscreen logic: */
|
---|
413 | UIMachineLogicFullscreen *pFullscreenLogic = qobject_cast<UIMachineLogicFullscreen*>(machineLogic());
|
---|
414 | AssertPtrReturnVoid(pFullscreenLogic);
|
---|
415 |
|
---|
416 | /* Make sure window should be shown and mapped to some host-screen: */
|
---|
417 | if (!uisession()->isScreenVisible(m_uScreenId) ||
|
---|
418 | !pFullscreenLogic->hasHostScreenForGuestScreen(m_uScreenId))
|
---|
419 | {
|
---|
420 | /* Remember whether the window was minimized: */
|
---|
421 | if (isMinimized())
|
---|
422 | m_fWasMinimized = true;
|
---|
423 | /* Hide window and reset it's state to NONE: */
|
---|
424 | setWindowState(Qt::WindowNoState);
|
---|
425 | hide();
|
---|
426 | /* If there is mini-toolbar: */
|
---|
427 | if (m_pMiniToolBar)
|
---|
428 | {
|
---|
429 | /* Hide mini-toolbar and reset it's state to NONE: */
|
---|
430 | m_pMiniToolBar->setWindowState(Qt::WindowNoState);
|
---|
431 | m_pMiniToolBar->hide();
|
---|
432 | }
|
---|
433 | }
|
---|
434 | else
|
---|
435 | {
|
---|
436 | /* Ignore if window is minimized and visible: */
|
---|
437 | if (isMinimized() && isVisible())
|
---|
438 | return;
|
---|
439 |
|
---|
440 | #ifdef VBOX_WS_X11
|
---|
441 | /* If WM doesn't support native stuff, we need to call for placeOnScreen(): */
|
---|
442 | const bool fSupportsNativeFullScreen = VBoxGlobal::supportsFullScreenMonitorsProtocolX11() &&
|
---|
443 | !gEDataManager->legacyFullscreenModeRequested();
|
---|
444 | if (!fSupportsNativeFullScreen)
|
---|
445 | {
|
---|
446 | /* Make sure window have appropriate geometry: */
|
---|
447 | placeOnScreen();
|
---|
448 | }
|
---|
449 | #else /* !VBOX_WS_X11 */
|
---|
450 | /* Make sure window have appropriate geometry: */
|
---|
451 | placeOnScreen();
|
---|
452 | #endif /* !VBOX_WS_X11 */
|
---|
453 |
|
---|
454 | #if defined(VBOX_WS_MAC)
|
---|
455 | /* ML and next using native stuff, so we can call for simple show(),
|
---|
456 | * Lion and previous using Qt stuff, so we should call for showFullScreen(): */
|
---|
457 | const bool fSupportsNativeFullScreen = vboxGlobal().osRelease() > MacOSXRelease_Lion;
|
---|
458 | if (fSupportsNativeFullScreen)
|
---|
459 | {
|
---|
460 | /* Show window in normal mode: */
|
---|
461 | show();
|
---|
462 | }
|
---|
463 | else
|
---|
464 | {
|
---|
465 | /* Show window in fullscreen mode: */
|
---|
466 | showFullScreen();
|
---|
467 | }
|
---|
468 | #elif defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
|
---|
469 | /* If there is mini-toolbar: */
|
---|
470 | if (m_pMiniToolBar)
|
---|
471 | {
|
---|
472 | /* Show mini-toolbar: */
|
---|
473 | m_pMiniToolBar->showFullScreen();
|
---|
474 | }
|
---|
475 | /* Show window: */
|
---|
476 | showFullScreen();
|
---|
477 | /* Restore minimized state if necessary: */
|
---|
478 | if (m_fWasMinimized)
|
---|
479 | {
|
---|
480 | m_fWasMinimized = false;
|
---|
481 | showMinimized();
|
---|
482 | }
|
---|
483 | #endif /* VBOX_WS_WIN || VBOX_WS_X11 */
|
---|
484 |
|
---|
485 | #ifdef VBOX_WS_X11
|
---|
486 | /* If WM supports native stuff, we need to map window to corresponding host-screen. */
|
---|
487 | if (fSupportsNativeFullScreen)
|
---|
488 | {
|
---|
489 | /* Tell recent window managers which host-screen this window should be mapped to: */
|
---|
490 | VBoxGlobal::setFullScreenMonitorX11(this, pFullscreenLogic->hostScreenForGuestScreen(m_uScreenId));
|
---|
491 |
|
---|
492 | /* If there is a mini-toolbar: */
|
---|
493 | if (m_pMiniToolBar)
|
---|
494 | {
|
---|
495 | /* Tell recent window managers which host-screen this mini-toolbar should be mapped to: */
|
---|
496 | VBoxGlobal::setFullScreenMonitorX11(m_pMiniToolBar, pFullscreenLogic->hostScreenForGuestScreen(m_uScreenId));
|
---|
497 | }
|
---|
498 | }
|
---|
499 | #endif /* VBOX_WS_X11 */
|
---|
500 |
|
---|
501 | /* Adjust machine-view size if necessary: */
|
---|
502 | adjustMachineViewSize();
|
---|
503 |
|
---|
504 | /* Make sure machine-view have focus: */
|
---|
505 | m_pMachineView->setFocus();
|
---|
506 | }
|
---|
507 | }
|
---|
508 |
|
---|
509 | #if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
|
---|
510 | void UIMachineWindowFullscreen::updateAppearanceOf(int iElement)
|
---|
511 | {
|
---|
512 | /* Call to base-class: */
|
---|
513 | UIMachineWindow::updateAppearanceOf(iElement);
|
---|
514 |
|
---|
515 | /* Update mini-toolbar: */
|
---|
516 | if (iElement & UIVisualElement_MiniToolBar)
|
---|
517 | {
|
---|
518 | /* If there is a mini-toolbar: */
|
---|
519 | if (m_pMiniToolBar)
|
---|
520 | {
|
---|
521 | /* Get snapshot(s): */
|
---|
522 | QString strSnapshotName;
|
---|
523 | if (machine().GetSnapshotCount() > 0)
|
---|
524 | {
|
---|
525 | CSnapshot snapshot = machine().GetCurrentSnapshot();
|
---|
526 | strSnapshotName = " (" + snapshot.GetName() + ")";
|
---|
527 | }
|
---|
528 | /* Update mini-toolbar text: */
|
---|
529 | m_pMiniToolBar->setText(machineName() + strSnapshotName);
|
---|
530 | }
|
---|
531 | }
|
---|
532 | }
|
---|
533 | #endif /* VBOX_WS_WIN || VBOX_WS_X11 */
|
---|
534 |
|
---|
535 | #ifdef VBOX_WS_WIN
|
---|
536 | # if QT_VERSION >= 0x050000
|
---|
537 | void UIMachineWindowFullscreen::showEvent(QShowEvent *pEvent)
|
---|
538 | {
|
---|
539 | /* Expose workaround again,
|
---|
540 | * Qt devs will never fix that it seems.
|
---|
541 | * This time they forget to set 'Mapped'
|
---|
542 | * attribute for initially frame-less window. */
|
---|
543 | setAttribute(Qt::WA_Mapped);
|
---|
544 |
|
---|
545 | /* Call to base-class: */
|
---|
546 | UIMachineWindow::showEvent(pEvent);
|
---|
547 | }
|
---|
548 | # endif /* QT_VERSION >= 0x050000 */
|
---|
549 | #endif /* VBOX_WS_WIN */
|
---|
550 |
|
---|