VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp@ 98103

Last change on this file since 98103 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 23.3 KB
Line 
1/* $Id: UIMachineWindowFullscreen.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIMachineWindowFullscreen 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#include <QMenu>
30#include <QTimer>
31#ifdef VBOX_WS_WIN
32# include <QWindow>
33#endif
34
35/* GUI includes: */
36#include "UICommon.h"
37#include "UIDesktopWidgetWatchdog.h"
38#include "UIExtraDataManager.h"
39#include "UISession.h"
40#include "UIActionPoolRuntime.h"
41#include "UIMachineLogicFullscreen.h"
42#include "UIMachineWindowFullscreen.h"
43#include "UIMachineView.h"
44#include "UINotificationCenter.h"
45#if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
46# include "UIMachineDefs.h"
47# include "UIMiniToolBar.h"
48#elif defined(VBOX_WS_MAC)
49# include "UIFrameBuffer.h"
50# include "VBoxUtils-darwin.h"
51# include "UICocoaApplication.h"
52#endif /* VBOX_WS_MAC */
53
54/* COM includes: */
55#include "CSnapshot.h"
56
57
58UIMachineWindowFullscreen::UIMachineWindowFullscreen(UIMachineLogic *pMachineLogic, ulong uScreenId)
59 : UIMachineWindow(pMachineLogic, uScreenId)
60#if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
61 , m_pMiniToolBar(0)
62#endif /* VBOX_WS_WIN || VBOX_WS_X11 */
63#ifdef VBOX_WS_MAC
64 , m_fIsInFullscreenTransition(false)
65#endif /* VBOX_WS_MAC */
66 , m_fWasMinimized(false)
67#ifdef VBOX_WS_X11
68 , m_fIsMinimizationRequested(false)
69 , m_fIsMinimized(false)
70#endif
71{
72}
73
74#ifdef VBOX_WS_MAC
75void UIMachineWindowFullscreen::handleNativeNotification(const QString &strNativeNotificationName)
76{
77 /* Make sure this method is only used for ML and next: */
78 AssertReturnVoid(uiCommon().osRelease() > MacOSXRelease_Lion);
79
80 /* Log all arrived notifications: */
81 LogRel(("UIMachineWindowFullscreen::handleNativeNotification: Notification '%s' received.\n",
82 strNativeNotificationName.toLatin1().constData()));
83
84 /* Handle 'NSWindowWillEnterFullScreenNotification' notification: */
85 if (strNativeNotificationName == "NSWindowWillEnterFullScreenNotification")
86 {
87 LogRel(("UIMachineWindowFullscreen::handleNativeNotification: "
88 "Native fullscreen mode about to enter, notifying listener...\n"));
89 emit sigNotifyAboutNativeFullscreenWillEnter();
90 }
91 /* Handle 'NSWindowDidEnterFullScreenNotification' notification: */
92 else if (strNativeNotificationName == "NSWindowDidEnterFullScreenNotification")
93 {
94 /* Mark window transition complete: */
95 m_fIsInFullscreenTransition = false;
96 LogRel(("UIMachineWindowFullscreen::handleNativeNotification: "
97 "Native fullscreen mode entered, notifying listener...\n"));
98 /* Update console's display viewport and 3D overlay: */
99 machineView()->updateViewport();
100 emit sigNotifyAboutNativeFullscreenDidEnter();
101 }
102 /* Handle 'NSWindowWillExitFullScreenNotification' notification: */
103 else if (strNativeNotificationName == "NSWindowWillExitFullScreenNotification")
104 {
105 LogRel(("UIMachineWindowFullscreen::handleNativeNotification: "
106 "Native fullscreen mode about to exit, notifying listener...\n"));
107 emit sigNotifyAboutNativeFullscreenWillExit();
108 }
109 /* Handle 'NSWindowDidExitFullScreenNotification' notification: */
110 else if (strNativeNotificationName == "NSWindowDidExitFullScreenNotification")
111 {
112 /* Mark window transition complete: */
113 m_fIsInFullscreenTransition = false;
114 LogRel(("UIMachineWindowFullscreen::handleNativeNotification: "
115 "Native fullscreen mode exited, notifying listener...\n"));
116 /* Update console's display viewport and 3D overlay: */
117 machineView()->updateViewport();
118 emit sigNotifyAboutNativeFullscreenDidExit();
119 }
120 /* Handle 'NSWindowDidFailToEnterFullScreenNotification' notification: */
121 else if (strNativeNotificationName == "NSWindowDidFailToEnterFullScreenNotification")
122 {
123 /* Mark window transition complete: */
124 m_fIsInFullscreenTransition = false;
125 LogRel(("UIMachineWindowFullscreen::handleNativeNotification: "
126 "Native fullscreen mode fail to enter, notifying listener...\n"));
127 emit sigNotifyAboutNativeFullscreenFailToEnter();
128 }
129}
130#endif /* VBOX_WS_MAC */
131
132#if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
133void UIMachineWindowFullscreen::sltMachineStateChanged()
134{
135 /* Call to base-class: */
136 UIMachineWindow::sltMachineStateChanged();
137
138 /* Update mini-toolbar: */
139 updateAppearanceOf(UIVisualElement_MiniToolBar);
140}
141
142void UIMachineWindowFullscreen::sltRevokeWindowActivation()
143{
144#ifdef VBOX_WS_X11
145 // WORKAROUND:
146 // We could be asked to minimize already, but just
147 // not yet executed that order to current moment.
148 if (m_fIsMinimizationRequested)
149 return;
150#endif
151
152 /* Make sure window is visible: */
153 if (!isVisible() || isMinimized())
154 return;
155
156 /* Revoke stolen activation: */
157#ifdef VBOX_WS_X11
158 raise();
159#endif /* VBOX_WS_X11 */
160 activateWindow();
161}
162
163void UIMachineWindowFullscreen::sltHandleMiniToolBarAutoHideToggled(bool fEnabled)
164{
165 /* Save mini-toolbar settings: */
166 gEDataManager->setAutoHideMiniToolbar(fEnabled, uiCommon().managedVMUuid());
167}
168#endif /* VBOX_WS_WIN || VBOX_WS_X11 */
169
170#ifdef VBOX_WS_MAC
171void UIMachineWindowFullscreen::sltEnterNativeFullscreen(UIMachineWindow *pMachineWindow)
172{
173 /* Make sure this slot is called only under ML and next: */
174 AssertReturnVoid(uiCommon().osRelease() > MacOSXRelease_Lion);
175
176 /* Make sure it is NULL or 'this' window passed: */
177 if (pMachineWindow && pMachineWindow != this)
178 return;
179
180 /* Make sure this window has fullscreen logic: */
181 UIMachineLogicFullscreen *pFullscreenLogic = qobject_cast<UIMachineLogicFullscreen*>(machineLogic());
182 AssertPtrReturnVoid(pFullscreenLogic);
183
184 /* Make sure this window should be shown and mapped to host-screen: */
185 if (!uisession()->isScreenVisible(m_uScreenId) ||
186 !pFullscreenLogic->hasHostScreenForGuestScreen(m_uScreenId))
187 return;
188
189 /* Mark window 'transitioned to fullscreen': */
190 m_fIsInFullscreenTransition = true;
191
192 /* Enter native fullscreen mode if necessary: */
193 if ( (pFullscreenLogic->screensHaveSeparateSpaces() || m_uScreenId == 0)
194 && !darwinIsInFullscreenMode(this))
195 darwinToggleFullscreenMode(this);
196}
197
198void UIMachineWindowFullscreen::sltExitNativeFullscreen(UIMachineWindow *pMachineWindow)
199{
200 /* Make sure this slot is called only under ML and next: */
201 AssertReturnVoid(uiCommon().osRelease() > MacOSXRelease_Lion);
202
203 /* Make sure it is NULL or 'this' window passed: */
204 if (pMachineWindow && pMachineWindow != this)
205 return;
206
207 /* Make sure this window has fullscreen logic: */
208 UIMachineLogicFullscreen *pFullscreenLogic = qobject_cast<UIMachineLogicFullscreen*>(machineLogic());
209 AssertPtrReturnVoid(pFullscreenLogic);
210
211 /* Mark window 'transitioned from fullscreen': */
212 m_fIsInFullscreenTransition = true;
213
214 /* Exit native fullscreen mode if necessary: */
215 if ( (pFullscreenLogic->screensHaveSeparateSpaces() || m_uScreenId == 0)
216 && darwinIsInFullscreenMode(this))
217 darwinToggleFullscreenMode(this);
218}
219#endif /* VBOX_WS_MAC */
220
221void UIMachineWindowFullscreen::sltShowMinimized()
222{
223#ifdef VBOX_WS_X11
224 /* Remember that we are asked to minimize: */
225 m_fIsMinimizationRequested = true;
226#endif
227
228 showMinimized();
229}
230
231void UIMachineWindowFullscreen::prepareNotificationCenter()
232{
233 if (gpNotificationCenter && (m_uScreenId == 0))
234 gpNotificationCenter->setParent(centralWidget());
235}
236
237void UIMachineWindowFullscreen::prepareVisualState()
238{
239 /* Call to base-class: */
240 UIMachineWindow::prepareVisualState();
241
242 /* The background has to go black: */
243 QPalette palette(centralWidget()->palette());
244 palette.setColor(centralWidget()->backgroundRole(), Qt::black);
245 centralWidget()->setPalette(palette);
246 centralWidget()->setAutoFillBackground(true);
247 setAutoFillBackground(true);
248
249#if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
250 /* Prepare mini-toolbar: */
251 prepareMiniToolbar();
252#endif /* VBOX_WS_WIN || VBOX_WS_X11 */
253
254#ifdef VBOX_WS_MAC
255 /* Native fullscreen stuff on ML and next: */
256 if (uiCommon().osRelease() > MacOSXRelease_Lion)
257 {
258 /* Make sure this window has fullscreen logic: */
259 UIMachineLogicFullscreen *pFullscreenLogic = qobject_cast<UIMachineLogicFullscreen*>(machineLogic());
260 AssertPtrReturnVoid(pFullscreenLogic);
261 /* Enable fullscreen support for every screen which requires it: */
262 if (pFullscreenLogic->screensHaveSeparateSpaces() || m_uScreenId == 0)
263 darwinEnableFullscreenSupport(this);
264 /* Enable transience support for other screens: */
265 else
266 darwinEnableTransienceSupport(this);
267 /* Register to native fullscreen notifications: */
268 UICocoaApplication::instance()->registerToNotificationOfWindow("NSWindowWillEnterFullScreenNotification", this,
269 UIMachineWindow::handleNativeNotification);
270 UICocoaApplication::instance()->registerToNotificationOfWindow("NSWindowDidEnterFullScreenNotification", this,
271 UIMachineWindow::handleNativeNotification);
272 UICocoaApplication::instance()->registerToNotificationOfWindow("NSWindowWillExitFullScreenNotification", this,
273 UIMachineWindow::handleNativeNotification);
274 UICocoaApplication::instance()->registerToNotificationOfWindow("NSWindowDidExitFullScreenNotification", this,
275 UIMachineWindow::handleNativeNotification);
276 UICocoaApplication::instance()->registerToNotificationOfWindow("NSWindowDidFailToEnterFullScreenNotification", this,
277 UIMachineWindow::handleNativeNotification);
278}
279#endif /* VBOX_WS_MAC */
280}
281
282#if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
283void UIMachineWindowFullscreen::prepareMiniToolbar()
284{
285 /* Make sure mini-toolbar is not restricted: */
286 if (!gEDataManager->miniToolbarEnabled(uiCommon().managedVMUuid()))
287 return;
288
289 /* Create mini-toolbar: */
290 m_pMiniToolBar = new UIMiniToolBar(this,
291 GeometryType_Full,
292 gEDataManager->miniToolbarAlignment(uiCommon().managedVMUuid()),
293 gEDataManager->autoHideMiniToolbar(uiCommon().managedVMUuid()),
294 screenId());
295 AssertPtrReturnVoid(m_pMiniToolBar);
296 {
297 /* Configure mini-toolbar: */
298 m_pMiniToolBar->addMenus(actionPool()->menus());
299 connect(m_pMiniToolBar, &UIMiniToolBar::sigMinimizeAction,
300 this, &UIMachineWindowFullscreen::sltShowMinimized, Qt::QueuedConnection);
301 connect(m_pMiniToolBar, &UIMiniToolBar::sigExitAction,
302 actionPool()->action(UIActionIndexRT_M_View_T_Fullscreen), &UIAction::trigger);
303 connect(m_pMiniToolBar, &UIMiniToolBar::sigCloseAction,
304 actionPool()->action(UIActionIndex_M_Application_S_Close), &UIAction::trigger);
305 connect(m_pMiniToolBar, &UIMiniToolBar::sigNotifyAboutWindowActivationStolen,
306 this, &UIMachineWindowFullscreen::sltRevokeWindowActivation, Qt::QueuedConnection);
307 connect(m_pMiniToolBar, &UIMiniToolBar::sigAutoHideToggled,
308 this, &UIMachineWindowFullscreen::sltHandleMiniToolBarAutoHideToggled);
309 }
310}
311#endif /* VBOX_WS_WIN || VBOX_WS_X11 */
312
313#if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
314void UIMachineWindowFullscreen::cleanupMiniToolbar()
315{
316 /* Delete mini-toolbar: */
317 delete m_pMiniToolBar;
318 m_pMiniToolBar = 0;
319}
320#endif /* VBOX_WS_WIN || VBOX_WS_X11 */
321
322void UIMachineWindowFullscreen::cleanupVisualState()
323{
324#ifdef VBOX_WS_MAC
325 /* Native fullscreen stuff on ML and next: */
326 if (uiCommon().osRelease() > MacOSXRelease_Lion)
327 {
328 /* Unregister from native fullscreen notifications: */
329 UICocoaApplication::instance()->unregisterFromNotificationOfWindow("NSWindowWillEnterFullScreenNotification", this);
330 UICocoaApplication::instance()->unregisterFromNotificationOfWindow("NSWindowDidEnterFullScreenNotification", this);
331 UICocoaApplication::instance()->unregisterFromNotificationOfWindow("NSWindowWillExitFullScreenNotification", this);
332 UICocoaApplication::instance()->unregisterFromNotificationOfWindow("NSWindowDidExitFullScreenNotification", this);
333 UICocoaApplication::instance()->unregisterFromNotificationOfWindow("NSWindowDidFailToEnterFullScreenNotification", this);
334 }
335#endif /* VBOX_WS_MAC */
336
337#if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
338 /* Cleanup mini-toolbar: */
339 cleanupMiniToolbar();
340#endif /* VBOX_WS_WIN || VBOX_WS_X11 */
341
342 /* Call to base-class: */
343 UIMachineWindow::cleanupVisualState();
344}
345
346void UIMachineWindowFullscreen::cleanupNotificationCenter()
347{
348 if (gpNotificationCenter && (gpNotificationCenter->parent() == centralWidget()))
349 gpNotificationCenter->setParent(0);
350}
351
352void UIMachineWindowFullscreen::placeOnScreen()
353{
354 /* Make sure this window has fullscreen logic: */
355 UIMachineLogicFullscreen *pFullscreenLogic = qobject_cast<UIMachineLogicFullscreen*>(machineLogic());
356 AssertPtrReturnVoid(pFullscreenLogic);
357
358 /* Get corresponding host-screen: */
359 const int iHostScreen = pFullscreenLogic->hostScreenForGuestScreen(m_uScreenId);
360 /* And corresponding working area: */
361 const QRect workingArea = gpDesktop->screenGeometry(iHostScreen);
362 Q_UNUSED(workingArea);
363
364#if defined(VBOX_WS_MAC)
365
366 /* Move window to the appropriate position: */
367 move(workingArea.topLeft());
368
369 /* Resize window to the appropriate size on Lion and previous: */
370 if (uiCommon().osRelease() <= MacOSXRelease_Lion)
371 resize(workingArea.size());
372 /* Resize window to the appropriate size on ML and next if it's screen has no own user-space: */
373 else if (!pFullscreenLogic->screensHaveSeparateSpaces() && m_uScreenId != 0)
374 resize(workingArea.size());
375 /* Resize the window if we are already in the full screen mode. This covers cases like host-resolution changes while in full screen mode: */
376 else if(darwinIsInFullscreenMode(this))
377 resize(workingArea.size());
378 else
379 {
380 /* Load normal geometry first of all: */
381 QRect geo = gEDataManager->machineWindowGeometry(UIVisualStateType_Normal, m_uScreenId, uiCommon().managedVMUuid());
382 /* If normal geometry is null => use frame-buffer size: */
383 if (geo.isNull())
384 {
385 const UIFrameBuffer *pFrameBuffer = uisession()->frameBuffer(m_uScreenId);
386 geo = QRect(QPoint(0, 0), QSize(pFrameBuffer->width(), pFrameBuffer->height()).boundedTo(workingArea.size()));
387 }
388 /* If normal geometry still null => use default size: */
389 if (geo.isNull())
390 geo = QRect(QPoint(0, 0), QSize(800, 600).boundedTo(workingArea.size()));
391 /* Move window to the center of working-area: */
392 geo.moveCenter(workingArea.center());
393 UIDesktopWidgetWatchdog::setTopLevelGeometry(this, geo);
394 }
395
396#elif defined(VBOX_WS_WIN)
397
398 /* Map window onto required screen: */
399 windowHandle()->setScreen(qApp->screens().at(iHostScreen));
400 /* Set appropriate window size: */
401 resize(workingArea.size());
402
403#elif defined(VBOX_WS_X11)
404
405 /* Determine whether we should use the native full-screen mode: */
406 const bool fUseNativeFullScreen = NativeWindowSubsystem::X11SupportsFullScreenMonitorsProtocol()
407 && !gEDataManager->legacyFullscreenModeRequested();
408 if (fUseNativeFullScreen)
409 {
410 /* Tell recent window managers which host-screen this window should be mapped to: */
411 NativeWindowSubsystem::X11SetFullScreenMonitor(this, pFullscreenLogic->hostScreenForGuestScreen(m_uScreenId));
412 }
413
414 /* Set appropriate window geometry: */
415 resize(workingArea.size());
416 move(workingArea.topLeft());
417
418#else
419
420# warning "port me"
421
422#endif
423}
424
425void UIMachineWindowFullscreen::showInNecessaryMode()
426{
427 /* Make sure window has fullscreen logic: */
428 UIMachineLogicFullscreen *pFullscreenLogic = qobject_cast<UIMachineLogicFullscreen*>(machineLogic());
429 AssertPtrReturnVoid(pFullscreenLogic);
430
431#if defined(VBOX_WS_MAC)
432
433 /* If window shouldn't be shown or mapped to some host-screen: */
434 if (!uisession()->isScreenVisible(m_uScreenId) ||
435 !pFullscreenLogic->hasHostScreenForGuestScreen(m_uScreenId))
436 {
437 /* Hide window: */
438 hide();
439 }
440 /* If window should be shown and mapped to some host-screen: */
441 else
442 {
443 /* Make sure window have appropriate geometry: */
444 placeOnScreen();
445
446 /* Simple show() for ML and next, showFullScreen() otherwise: */
447 if (uiCommon().osRelease() > MacOSXRelease_Lion)
448 show();
449 else
450 showFullScreen();
451
452 /* Adjust machine-view size if necessary: */
453 adjustMachineViewSize();
454
455 /* Make sure machine-view have focus: */
456 m_pMachineView->setFocus();
457 }
458
459#elif defined(VBOX_WS_WIN)
460
461 /* If window shouldn't be shown or mapped to some host-screen: */
462 if (!uisession()->isScreenVisible(m_uScreenId) ||
463 !pFullscreenLogic->hasHostScreenForGuestScreen(m_uScreenId))
464 {
465 /* Remember whether the window was minimized: */
466 if (isMinimized())
467 m_fWasMinimized = true;
468
469 /* Hide window and reset it's state to NONE: */
470 setWindowState(Qt::WindowNoState);
471 hide();
472 }
473 /* If window should be shown and mapped to some host-screen: */
474 else
475 {
476 /* Check whether window was minimized: */
477 const bool fWasMinimized = isMinimized() && isVisible();
478 /* And reset it's state in such case before exposing: */
479 if (fWasMinimized)
480 setWindowState(Qt::WindowNoState);
481
482 /* Make sure window have appropriate geometry: */
483 placeOnScreen();
484
485 /* Show window: */
486 showFullScreen();
487
488 /* Restore minimized state if necessary: */
489 if (m_fWasMinimized || fWasMinimized)
490 {
491 m_fWasMinimized = false;
492 QMetaObject::invokeMethod(this, "showMinimized", Qt::QueuedConnection);
493 }
494
495 /* Adjust machine-view size if necessary: */
496 adjustMachineViewSize();
497
498 /* Make sure machine-view have focus: */
499 m_pMachineView->setFocus();
500 }
501
502#elif defined(VBOX_WS_X11)
503
504 /* If window shouldn't be shown or mapped to some host-screen: */
505 if (!uisession()->isScreenVisible(m_uScreenId) ||
506 !pFullscreenLogic->hasHostScreenForGuestScreen(m_uScreenId))
507 {
508 /* Remember whether the window was minimized: */
509 if (isMinimized())
510 m_fWasMinimized = true;
511
512 /* Hide window and reset it's state to NONE: */
513 setWindowState(Qt::WindowNoState);
514 hide();
515 }
516 /* If window should be shown and mapped to some host-screen: */
517 else
518 {
519 /* Check whether window was minimized: */
520 const bool fWasMinimized = isMinimized() && isVisible();
521 /* And reset it's state in such case before exposing: */
522 if (fWasMinimized)
523 setWindowState(Qt::WindowNoState);
524
525 /* Show window: */
526 showFullScreen();
527
528 /* Make sure window have appropriate geometry: */
529 placeOnScreen();
530
531 /* Restore full-screen state after placeOnScreen() call: */
532 setWindowState(Qt::WindowFullScreen);
533
534 /* Restore minimized state if necessary: */
535 if (m_fWasMinimized || fWasMinimized)
536 {
537 m_fWasMinimized = false;
538 QMetaObject::invokeMethod(this, "showMinimized", Qt::QueuedConnection);
539 }
540
541 /* Adjust machine-view size if necessary: */
542 adjustMachineViewSize();
543
544 /* Make sure machine-view have focus: */
545 m_pMachineView->setFocus();
546 }
547
548#else
549
550# warning "port me"
551
552#endif
553}
554
555#if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
556void UIMachineWindowFullscreen::updateAppearanceOf(int iElement)
557{
558 /* Call to base-class: */
559 UIMachineWindow::updateAppearanceOf(iElement);
560
561 /* Update mini-toolbar: */
562 if (iElement & UIVisualElement_MiniToolBar)
563 {
564 /* If there is a mini-toolbar: */
565 if (m_pMiniToolBar)
566 {
567 /* Get snapshot(s): */
568 QString strSnapshotName;
569 if (machine().GetSnapshotCount() > 0)
570 {
571 CSnapshot snapshot = machine().GetCurrentSnapshot();
572 strSnapshotName = " (" + snapshot.GetName() + ")";
573 }
574 /* Update mini-toolbar text: */
575 m_pMiniToolBar->setText(machineName() + strSnapshotName);
576 }
577 }
578}
579#endif /* VBOX_WS_WIN || VBOX_WS_X11 */
580
581#ifdef VBOX_WS_X11
582void UIMachineWindowFullscreen::changeEvent(QEvent *pEvent)
583{
584 switch (pEvent->type())
585 {
586 case QEvent::WindowStateChange:
587 {
588 /* Watch for window state changes: */
589 QWindowStateChangeEvent *pChangeEvent = static_cast<QWindowStateChangeEvent*>(pEvent);
590 LogRel2(("GUI: UIMachineWindowFullscreen::changeEvent: Window state changed from %d to %d\n",
591 (int)pChangeEvent->oldState(), (int)windowState()));
592 if ( windowState() == Qt::WindowMinimized
593 && pChangeEvent->oldState() == Qt::WindowNoState
594 && !m_fIsMinimized)
595 {
596 /* Mark window minimized, isMinimized() is not enough due to Qt5vsX11 fight: */
597 LogRel2(("GUI: UIMachineWindowFullscreen::changeEvent: Window minimized\n"));
598 m_fIsMinimized = true;
599 }
600 else
601 if ( windowState() == Qt::WindowNoState
602 && pChangeEvent->oldState() == Qt::WindowMinimized
603 && m_fIsMinimized)
604 {
605 /* Mark window restored, and do manual restoring with showInNecessaryMode(): */
606 LogRel2(("GUI: UIMachineWindowFullscreen::changeEvent: Window restored\n"));
607 m_fIsMinimized = false;
608 /* Remember that we no more asked to minimize: */
609 m_fIsMinimizationRequested = false;
610 showInNecessaryMode();
611 }
612 break;
613 }
614 default:
615 break;
616 }
617
618 /* Call to base-class: */
619 UIMachineWindow::changeEvent(pEvent);
620}
621#endif /* VBOX_WS_X11 */
622
623#ifdef VBOX_WS_WIN
624void UIMachineWindowFullscreen::showEvent(QShowEvent *pEvent)
625{
626 /* Expose workaround again,
627 * Qt devs will never fix that it seems.
628 * This time they forget to set 'Mapped'
629 * attribute for initially frame-less window. */
630 setAttribute(Qt::WA_Mapped);
631
632 /* Call to base-class: */
633 UIMachineWindow::showEvent(pEvent);
634}
635#endif /* VBOX_WS_WIN */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette