VirtualBox

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

Last change on this file since 91109 was 91109, checked in by vboxsync, 3 years ago

FE/Qt: bugref:10067: Move window geometry stuff from UICommon to UIDesktopWidgetWatchdog.

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

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