bool UIMachineViewFullscreen::eventFilter(QObject *pWatched, QEvent *pEvent) { /* Who are we watching? */ QMainWindow *pMainDialog = machineWindowWrapper() && machineWindowWrapper()->machineWindow() ? qobject_cast<QMainWindow*>(machineWindowWrapper()->machineWindow()) : 0; if (pWatched != 0 && pWatched == pMainDialog) { switch (pEvent->type()) { case QEvent::Resize: { /* Send guest-resize hint only if top window resizing to required dimension: */ QResizeEvent *pResizeEvent = static_cast<QResizeEvent*>(pEvent); if (pResizeEvent->size() != workingArea().size()) break; /* Set the "guest needs to resize" hint. * This hint is acted upon when (and only when) the autoresize property is "true": */ m_fShouldWeDoResize = uisession()->isGuestSupportsGraphics(); if (m_bIsGuestAutoresizeEnabled && m_fShouldWeDoResize) QTimer::singleShot(0, this, SLOT(sltPerformGuestResize())); break; } default: break; } } return UIMachineView::eventFilter(pWatched, pEvent); }
bool UIMachineViewSeamless::eventFilter(QObject *pWatched, QEvent *pEvent) { if (pWatched != 0 && pWatched == machineWindow()) { switch (pEvent->type()) { case QEvent::Resize: { /* Send guest-resize hint only if top window resizing to required dimension: */ QResizeEvent *pResizeEvent = static_cast<QResizeEvent*>(pEvent); if (pResizeEvent->size() != workingArea().size()) break; /* Recalculate max guest size: */ setMaxGuestSize(); /* And resize guest to that size: */ if (uisession()->isGuestSupportsGraphics()) QTimer::singleShot(0, this, SLOT(sltPerformGuestResize())); break; } default: break; } } return UIMachineView::eventFilter(pWatched, pEvent); }
bool UIMachineViewNormal::eventFilter(QObject *pWatched, QEvent *pEvent) { if (pWatched != 0 && pWatched == machineWindow()) { switch (pEvent->type()) { case QEvent::Resize: { /* We call this on every resize as: * * Window frame geometry can change on resize. * * On X11 we set information here which becomes available * asynchronously at an unknown time after window * creation. As long as the information is not available * we make a best guess. */ setMaxGuestSize(); if (pEvent->spontaneous() && m_bIsGuestAutoresizeEnabled && uisession()->isGuestSupportsGraphics()) QTimer::singleShot(300, this, SLOT(sltPerformGuestResize())); break; } #if defined (Q_WS_WIN32) # if defined (VBOX_GUI_USE_DDRAW) case QEvent::Move: { /* Notification from our parent that it has moved. We need this in order * to possibly adjust the direct screen blitting: */ if (frameBuffer()) frameBuffer()->moveEvent(static_cast<QMoveEvent*>(pEvent)); break; } # endif /* defined (VBOX_GUI_USE_DDRAW) */ #endif /* defined (Q_WS_WIN32) */ default: break; } } #ifdef Q_WS_WIN else if (pWatched != 0 && pWatched == machineWindow()->menuBar()) { /* Due to windows host uses separate 'focus set' to let menubar to * operate while popped up (see UIMachineViewNormal::event() for details), * it also requires backward processing: */ switch (pEvent->type()) { /* If menubar gets the focus while not popped up => give it back: */ case QEvent::FocusIn: { if (!QApplication::activePopupWidget()) setFocus(); } default: break; } } #endif /* Q_WS_WIN */ return UIMachineView::eventFilter(pWatched, pEvent); }
void UIMachineViewSeamless::normalizeGeometry(bool /* fAdjustPosition */) { /* Check if we should adjust guest to new size: */ if ((int)frameBuffer()->width() != workingArea().size().width() || (int)frameBuffer()->height() != workingArea().size().height()) if (uisession()->isGuestSupportsGraphics()) sltPerformGuestResize(workingArea().size()); }
void UIMachineViewNormal::adjustGuestScreenSize() { /* Should we adjust guest-screen size? Logging paranoia is required here to reveal the truth. */ LogRel(("GUI: UIMachineViewNormal::adjustGuestScreenSize: Adjust guest-screen size if necessary.\n")); bool fAdjust = false; /* Step 1: Is the guest-screen of another size than necessary? */ if (!fAdjust) { /* Acquire frame-buffer size: */ QSize frameBufferSize(frameBuffer()->width(), frameBuffer()->height()); /* Take the scale-factor(s) into account: */ frameBufferSize = scaledForward(frameBufferSize); /* Acquire central-widget size: */ const QSize centralWidgetSize = machineWindow()->centralWidget()->size(); if (frameBufferSize != centralWidgetSize) { LogRel2(("GUI: UIMachineViewNormal::adjustGuestScreenSize: Guest-screen is of another size than necessary, adjustment is required.\n")); fAdjust = true; } } /* Step 2: Is guest-additions supports graphics? */ if (fAdjust) { if (!uisession()->isGuestSupportsGraphics()) { LogRel2(("GUI: UIMachineViewNormal::adjustGuestScreenSize: Guest-additions are not supporting graphics, adjustment is omitted.\n")); fAdjust = false; } } /* Step 3: Is guest-screen visible? */ if (fAdjust) { if (!uisession()->isScreenVisible(screenId())) { LogRel2(("GUI: UIMachineViewNormal::adjustGuestScreenSize: Guest-screen is not visible, adjustment is omitted.\n")); fAdjust = false; } } /* Step 4: Is guest-screen auto-resize enabled? */ if (fAdjust) { if (!m_bIsGuestAutoresizeEnabled) { LogRel2(("GUI: UIMachineViewNormal::adjustGuestScreenSize: Guest-screen auto-resize is disabled, adjustment is omitted.\n")); fAdjust = false; } } /* Final step: Adjust if requested/allowed. */ if (fAdjust) { sltPerformGuestResize(machineWindow()->centralWidget()->size()); } }
void UIMachineViewFullscreen::setGuestAutoresizeEnabled(bool fEnabled) { if (m_bIsGuestAutoresizeEnabled != fEnabled) { m_bIsGuestAutoresizeEnabled = fEnabled; if (m_bIsGuestAutoresizeEnabled && uisession()->isGuestSupportsGraphics()) sltPerformGuestResize(); } }
void UIMachineViewFullscreen::sltAdditionsStateChanged() { /* Check if we should restrict minimum size: */ maybeRestrictMinimumSize(); /* Check if we should resize guest to fullscreen, all the * required features will be tested in sltPerformGuestResize(...): */ if ((int)frameBuffer()->width() != workingArea().size().width() || (int)frameBuffer()->height() != workingArea().size().height()) sltPerformGuestResize(workingArea().size()); }
void UIMachineViewFullscreen::sltAdditionsStateChanged() { /* Check if we should restrict minimum size: */ maybeRestrictMinimumSize(); /* Check if we should resize guest to fullscreen */ if ((int)frameBuffer()->width() != workingArea().size().width() || (int)frameBuffer()->height() != workingArea().size().height()) if (m_bIsGuestAutoresizeEnabled && uisession()->isGuestSupportsGraphics()) sltPerformGuestResize(workingArea().size()); }
void UIMachineViewFullscreen::setGuestAutoresizeEnabled(bool fEnabled) { if (m_bIsGuestAutoresizeEnabled != fEnabled) { m_bIsGuestAutoresizeEnabled = fEnabled; maybeRestrictMinimumSize(); sltPerformGuestResize(); } }
void UIMachineViewNormal::setGuestAutoresizeEnabled(bool fEnabled) { if (m_bIsGuestAutoresizeEnabled != fEnabled) { m_bIsGuestAutoresizeEnabled = fEnabled; maybeRestrictMinimumSize(); if (m_bIsGuestAutoresizeEnabled && uisession()->isGuestSupportsGraphics()) sltPerformGuestResize(); } }
void UIMachineViewSeamless::cleanupSeamless() { /* If machine still running: */ if (uisession()->isRunning()) { /* Reset seamless feature flag of the guest: */ session().GetConsole().GetDisplay().SetSeamlessMode(false); /* Rollback seamless frame-buffer size to normal: */ machineWindowWrapper()->machineWindow()->hide(); sltPerformGuestResize(guestSizeHint()); m_pSyncBlocker->exec(); /* Delete sync-blocker: */ m_pSyncBlocker->deleteLater(); } }
void UIMachineViewSeamless::adjustGuestScreenSize() { /* Acquire working-area size: */ const QSize workingAreaSize = workingArea().size(); /* Acquire frame-buffer size: */ QSize frameBufferSize(frameBuffer()->width(), frameBuffer()->height()); /* Take the scale-factor(s) into account: */ frameBufferSize = scaledForward(frameBufferSize); /* Check if we should adjust guest-screen to new size: */ if (frameBuffer()->isAutoEnabled() || frameBufferSize != workingAreaSize) if (uisession()->isGuestSupportsGraphics() && uisession()->isScreenVisible(screenId())) { frameBuffer()->setAutoEnabled(false); sltPerformGuestResize(workingArea().size()); } }
void UIMachineViewFullscreen::cleanupFullscreen() { /* If machine still running: */ if (uisession()->isRunning()) { /* And guest supports advanced graphics management which is enabled: */ if (m_bIsGuestAutoresizeEnabled && uisession()->isGuestSupportsGraphics()) { /* Rollback seamless frame-buffer size to normal: */ machineWindowWrapper()->machineWindow()->hide(); sltPerformGuestResize(guestSizeHint()); m_pSyncBlocker->exec(); /* Request to delete sync-blocker: */ m_pSyncBlocker->deleteLater(); } } }
bool UIMachineViewNormal::eventFilter(QObject *pWatched, QEvent *pEvent) { if (pWatched != 0 && pWatched == machineWindow()) { switch (pEvent->type()) { case QEvent::Resize: { /* Recalculate max guest size: */ setMaxGuestSize(); /* And resize guest to current window size: */ if (pEvent->spontaneous() && m_bIsGuestAutoresizeEnabled && uisession()->isGuestSupportsGraphics()) QTimer::singleShot(300, this, SLOT(sltPerformGuestResize())); break; } default: break; } } return UIMachineView::eventFilter(pWatched, pEvent); }
void UIMachineViewNormal::maybeResendResizeHint() { if (m_bIsGuestAutoresizeEnabled && uisession()->isGuestSupportsGraphics()) { /* Get the current machine: */ CMachine machine = session().GetMachine(); /* We send a guest size hint if needed to reverse a transition * to fullscreen or seamless. */ QString strKey = makeExtraDataKeyPerMonitor(GUI_LastGuestSizeHintWasFullscreen); QString strHintSent = machine.GetExtraData(strKey); if (!strHintSent.isEmpty()) { QSize hint = guestSizeHint(); /* Temporarily restrict the size to prevent a brief resize to the * framebuffer dimensions (see @a UIMachineView::sizeHint()) before * the following resize() is acted upon. */ setMaximumSize(hint); m_sizeHintOverride = hint; sltPerformGuestResize(hint); } } }
bool UIMachineViewFullscreen::eventFilter(QObject *pWatched, QEvent *pEvent) { if (pWatched != 0 && pWatched == machineWindow()) { switch (pEvent->type()) { case QEvent::Resize: { /* Send guest-resize hint only if top window resizing to required dimension: */ QResizeEvent *pResizeEvent = static_cast<QResizeEvent*>(pEvent); if (pResizeEvent->size() != workingArea().size()) break; if (m_bIsGuestAutoresizeEnabled && uisession()->isGuestSupportsGraphics()) QTimer::singleShot(0, this, SLOT(sltPerformGuestResize())); break; } default: break; } } return UIMachineView::eventFilter(pWatched, pEvent); }
void UIMachineViewFullscreen::normalizeGeometry(bool /* fAdjustPosition */) { sltPerformGuestResize(workingArea().size()); }
void UIMachineViewFullscreen::adjustGuestScreenSize() { /* Should we adjust guest-screen size? Logging paranoia is required here to reveal the truth. */ LogRel(("GUI: UIMachineViewFullscreen::adjustGuestScreenSize: Adjust guest-screen size if necessary.\n")); bool fAdjust = false; /* Step 1: Was the guest-screen enabled automatically? */ if (!fAdjust) { if (frameBuffer()->isAutoEnabled()) { LogRel2(("GUI: UIMachineViewFullscreen::adjustGuestScreenSize: Guest-screen was enabled automatically, adjustment is required.\n")); fAdjust = true; } } /* Step 2: Is the guest-screen of another size than necessary? */ if (!fAdjust) { /* Acquire frame-buffer size: */ QSize frameBufferSize(frameBuffer()->width(), frameBuffer()->height()); /* Take the scale-factor(s) into account: */ frameBufferSize = scaledForward(frameBufferSize); /* Acquire working-area size: */ const QSize workingAreaSize = workingArea().size(); if (frameBufferSize != workingAreaSize) { LogRel2(("GUI: UIMachineViewFullscreen::adjustGuestScreenSize: Guest-screen is of another size than necessary, adjustment is required.\n")); fAdjust = true; } } /* Step 3: Is guest-additions supports graphics? */ if (fAdjust) { if (!uisession()->isGuestSupportsGraphics()) { LogRel2(("GUI: UIMachineViewFullscreen::adjustGuestScreenSize: Guest-additions are not supporting graphics, adjustment is omitted.\n")); fAdjust = false; } } /* Step 4: Is guest-screen visible? */ if (fAdjust) { if (!uisession()->isScreenVisible(screenId())) { LogRel2(("GUI: UIMachineViewFullscreen::adjustGuestScreenSize: Guest-screen is not visible, adjustment is omitted.\n")); fAdjust = false; } } /* Step 5: Is guest-screen auto-resize enabled? */ if (fAdjust) { if (!m_bIsGuestAutoresizeEnabled) { LogRel2(("GUI: UIMachineViewFullscreen::adjustGuestScreenSize: Guest-screen auto-resize is disabled, adjustment is omitted.\n")); fAdjust = false; } } /* Final step: Adjust if requested/allowed. */ if (fAdjust) { frameBuffer()->setAutoEnabled(false); sltPerformGuestResize(workingArea().size()); /* And remember the size to know what we are resizing out of when we exit: */ uisession()->setLastFullScreenSize(screenId(), scaledForward(scaledBackward(workingArea().size()))); } }