VirtualBox

Changeset 38981 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Oct 12, 2011 7:19:08 PM (13 years ago)
Author:
vboxsync
Message:

FE/Qt: refactor almost identical code for different view types into UIMachineView

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r38979 r38981  
    850850#endif /* Q_WS_MAC */
    851851
     852bool UIMachineView::guestResizeEvent(QEvent *pEvent, bool fFullscreen)
     853{
     854    /* Some situations require framebuffer resize events to be ignored at all,
     855     * leaving machine-window, machine-view and framebuffer sizes preserved: */
     856    if (uisession()->isGuestResizeIgnored())
     857        return true;
     858
     859    /* Get guest resize-event: */
     860    UIResizeEvent *pResizeEvent = static_cast<UIResizeEvent*>(pEvent);
     861
     862    /* Perform framebuffer resize: */
     863    frameBuffer()->resizeEvent(pResizeEvent);
     864
     865    /* Reapply maximum size restriction for machine-view: */
     866    setMaximumSize(sizeHint());
     867
     868    /* Perform machine-view resize: */
     869    resize(pResizeEvent->width(), pResizeEvent->height());
     870
     871    /* May be we have to restrict minimum size? */
     872    maybeRestrictMinimumSize();
     873
     874    /* Let our toplevel widget calculate its sizeHint properly: */
     875    QCoreApplication::sendPostedEvents(0, QEvent::LayoutRequest);
     876
     877#ifdef Q_WS_MAC
     878    machineLogic()->updateDockIconSize(screenId(), pResizeEvent->width(), pResizeEvent->height());
     879#endif /* Q_WS_MAC */
     880
     881    /* Update machine-view sliders: */
     882    updateSliders();
     883
     884    /* Normalize machine-window geometry: */
     885    if (!fFullscreen)
     886        normalizeGeometry(true /* Adjust Position? */);
     887
     888    /* Report to the VM thread that we finished resizing: */
     889    session().GetConsole().GetDisplay().ResizeCompleted(screenId());
     890
     891    /* We also recalculate the desktop geometry if this is determined
     892     * automatically. In fact, we only need this on the first resize,
     893     * but it is done every time to keep the code simpler. */
     894    calculateDesktopGeometry();
     895
     896    /* Emit a signal about guest was resized: */
     897    emit resizeHintDone();
     898
     899    pEvent->accept();
     900    return true;
     901}
     902
    852903bool UIMachineView::event(QEvent *pEvent)
    853904{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r38978 r38981  
    157157    CGImageRef frameBuffertoCGImageRef(UIFrameBuffer *pFrameBuffer);
    158158#endif /* Q_WS_MAC */
     159    bool guestResizeEvent(QEvent *pEvent, bool fFullscreen);
    159160
    160161    /* Cross-platforms event processors: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.cpp

    r38978 r38981  
    105105        case VBoxDefs::ResizeEventType:
    106106        {
    107             /* Some situations require framebuffer resize events to be ignored at all,
    108              * leaving machine-window, machine-view and framebuffer sizes preserved: */
    109             if (uisession()->isGuestResizeIgnored())
    110                 return true;
    111 
    112             /* Get guest resize-event: */
    113             UIResizeEvent *pResizeEvent = static_cast<UIResizeEvent*>(pEvent);
    114 
    115             /* Perform framebuffer resize: */
    116             frameBuffer()->resizeEvent(pResizeEvent);
    117 
    118             /* Reapply maximum size restriction for machine-view: */
    119             setMaximumSize(sizeHint());
    120 
    121             /* Perform machine-view resize: */
    122             resize(pResizeEvent->width(), pResizeEvent->height());
    123 
    124             /* May be we have to restrict minimum size? */
    125             maybeRestrictMinimumSize();
    126 
    127             /* Let our toplevel widget calculate its sizeHint properly: */
    128             QCoreApplication::sendPostedEvents(0, QEvent::LayoutRequest);
    129 
    130 #ifdef Q_WS_MAC
    131             machineLogic()->updateDockIconSize(screenId(), pResizeEvent->width(), pResizeEvent->height());
    132 #endif /* Q_WS_MAC */
    133 
    134             /* Update machine-view sliders: */
    135             updateSliders();
    136 
    137             /* Report to the VM thread that we finished resizing: */
    138             session().GetConsole().GetDisplay().ResizeCompleted(screenId());
    139 
    140             /* We also recalculate the desktop geometry if this is determined
    141              * automatically.  In fact, we only need this on the first resize,
    142              * but it is done every time to keep the code simpler. */
    143             calculateDesktopGeometry();
    144 
    145             /* Emit a signal about guest was resized: */
    146             emit resizeHintDone();
    147 
    148             pEvent->accept();
    149             return true;
     107            return guestResizeEvent(pEvent, true);
    150108        }
    151109
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp

    r38978 r38981  
    108108        case VBoxDefs::ResizeEventType:
    109109        {
    110             /* Some situations require framebuffer resize events to be ignored at all,
    111              * leaving machine-window, machine-view and framebuffer sizes preserved: */
    112             if (uisession()->isGuestResizeIgnored())
    113                 return true;
    114 
    115             /* Get guest resize-event: */
    116             UIResizeEvent *pResizeEvent = static_cast<UIResizeEvent*>(pEvent);
    117 
    118             /* Perform framebuffer resize: */
    119             frameBuffer()->resizeEvent(pResizeEvent);
    120 
    121             /* Reapply maximum size restriction for machine-view: */
    122             setMaximumSize(sizeHint());
    123 
    124             /* Perform machine-view resize: */
    125             resize(pResizeEvent->width(), pResizeEvent->height());
    126 
    127             /* May be we have to restrict minimum size? */
    128             maybeRestrictMinimumSize();
    129 
    130             /* Let our toplevel widget calculate its sizeHint properly: */
    131             QCoreApplication::sendPostedEvents(0, QEvent::LayoutRequest);
    132 
    133 #ifdef Q_WS_MAC
    134             machineLogic()->updateDockIconSize(screenId(), pResizeEvent->width(), pResizeEvent->height());
    135 #endif /* Q_WS_MAC */
    136 
    137             /* Update machine-view sliders: */
    138             updateSliders();
    139 
    140             /* Normalize machine-window geometry: */
    141             normalizeGeometry(true /* Adjust Position? */);
    142 
    143             /* Report to the VM thread that we finished resizing: */
    144             session().GetConsole().GetDisplay().ResizeCompleted(screenId());
    145 
    146             /* We also recalculate the desktop geometry if this is determined
    147              * automatically. In fact, we only need this on the first resize,
    148              * but it is done every time to keep the code simpler. */
    149             calculateDesktopGeometry();
    150 
    151             /* Emit a signal about guest was resized: */
    152             emit resizeHintDone();
    153 
    154             pEvent->accept();
    155             return true;
     110            return guestResizeEvent(pEvent, false);
    156111        }
    157112
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.cpp

    r38978 r38981  
    122122        case VBoxDefs::ResizeEventType:
    123123        {
    124             /* Some situations require framebuffer resize events to be ignored at all,
    125              * leaving machine-window, machine-view and framebuffer sizes preserved: */
    126             if (uisession()->isGuestResizeIgnored())
    127                 return true;
    128 
    129             /* Get guest resize-event: */
    130             UIResizeEvent *pResizeEvent = static_cast<UIResizeEvent*>(pEvent);
    131 
    132             /* Perform framebuffer resize: */
    133             frameBuffer()->resizeEvent(pResizeEvent);
    134 
    135             /* Reapply maximum size restriction for machine-view: */
    136             setMaximumSize(sizeHint());
    137 
    138             /* Perform machine-view resize: */
    139             resize(pResizeEvent->width(), pResizeEvent->height());
    140 
    141             /* Let our toplevel widget calculate its sizeHint properly: */
    142             QCoreApplication::sendPostedEvents(0, QEvent::LayoutRequest);
    143 
    144 #ifdef Q_WS_MAC
    145             machineLogic()->updateDockIconSize(screenId(), pResizeEvent->width(), pResizeEvent->height());
    146 #endif /* Q_WS_MAC */
    147 
    148             /* Update machine-view sliders: */
    149             updateSliders();
    150 
    151             /* Report to the VM thread that we finished resizing: */
    152             session().GetConsole().GetDisplay().ResizeCompleted(screenId());
    153 
    154             /* We also recalculate the desktop geometry if this is determined
    155              * automatically.  In fact, we only need this on the first resize,
    156              * but it is done every time to keep the code simpler. */
    157             calculateDesktopGeometry();
    158 
    159             /* Emit a signal about guest was resized: */
    160             emit resizeHintDone();
    161 
    162             pEvent->accept();
    163             return true;
     124            return guestResizeEvent(pEvent, true);
    164125        }
    165126
Note: See TracChangeset for help on using the changeset viewer.

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