VirtualBox

Changeset 46361 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jun 3, 2013 1:34:22 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
86177
Message:

FE/Qt: 6749: Runtime UI: Frame-buffer interface: Using signal instead of event for RequestResize stuff.

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

Legend:

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

    r46359 r46361  
    5151    m_WinId = (m_pMachineView && m_pMachineView->viewport()) ? (LONG64)m_pMachineView->viewport()->winId() : 0;
    5252
    53     /* Connect NotifyUpdate handler: */
    54     if (m_pMachineView)
    55         connect(this, SIGNAL(sigNotifyUpdate(int, int, int, int)),
    56                 m_pMachineView, SLOT(sltHandleNotifyUpdate(int, int, int, int)),
    57                 Qt::QueuedConnection);
     53    /* Connect handlers: */
     54    if (m_pMachineView)
     55        prepareConnections();
    5856
    5957    /* Initialize critical-section: */
     
    6765    RTCritSectDelete(&m_critSect);
    6866
    69     /* Disconnect NotifyUpdate handler: */
    70     if (m_pMachineView)
    71         disconnect(this, SIGNAL(sigNotifyUpdate(int, int, int, int)),
    72                    m_pMachineView, SLOT(sltHandleNotifyUpdate(int, int, int, int)));
     67    /* Disconnect handlers: */
     68    if (m_pMachineView)
     69        cleanupConnections();
    7370}
    7471
     
    186183
    187184    /* Widget resize is NOT thread safe and never will be,
    188      * We have to notify the machine-view with the async event to perform resize operation,
    189      * later it will be replaced with signal stuff. */
    190     if (m_pMachineView)
    191         QApplication::postEvent(m_pMachineView,
    192                                 new UIResizeEvent(uPixelFormat, pVRAM,
    193                                                   uBitsPerPixel, uBytesPerLine,
    194                                                   uWidth, uHeight));
     185     * We have to notify the machine-view with the async signal to perform resize operation. */
     186    if (m_pMachineView)
     187        emit sigRequestResize(uPixelFormat, pVRAM, uBitsPerPixel, uBytesPerLine, uWidth, uHeight);
    195188    else
    196189        /* Mark request as finished.
     
    352345    lock();
    353346
    354     /* Disconnect NotifyUpdate handler: */
    355     if (m_pMachineView)
    356         disconnect(this, SIGNAL(sigNotifyUpdate(int, int, int, int)),
    357                    m_pMachineView, SLOT(sltHandleNotifyUpdate(int, int, int, int)));
     347    /* Disconnect handlers: */
     348    if (m_pMachineView)
     349        cleanupConnections();
    358350
    359351    /* Reassign machine-view: */
     
    361353    m_WinId = (m_pMachineView && m_pMachineView->viewport()) ? (LONG64)m_pMachineView->viewport()->winId() : 0;
    362354
    363     /* Connect NotifyUpdate handler: */
    364     if (m_pMachineView)
    365         connect(this, SIGNAL(sigNotifyUpdate(int, int, int, int)),
    366                 m_pMachineView, SLOT(sltHandleNotifyUpdate(int, int, int, int)),
    367                 Qt::QueuedConnection);
     355    /* Connect handlers: */
     356    if (m_pMachineView)
     357        prepareConnections();
    368358
    369359    /* Unlock thread finally: */
     
    371361}
    372362
     363void UIFrameBuffer::prepareConnections()
     364{
     365    connect(this, SIGNAL(sigRequestResize(int, uchar*, int, int, int, int)),
     366            m_pMachineView, SLOT(sltHandleRequestResize(int, uchar*, int, int, int, int)),
     367            Qt::QueuedConnection);
     368    connect(this, SIGNAL(sigNotifyUpdate(int, int, int, int)),
     369            m_pMachineView, SLOT(sltHandleNotifyUpdate(int, int, int, int)),
     370            Qt::QueuedConnection);
     371}
     372
     373void UIFrameBuffer::cleanupConnections()
     374{
     375    disconnect(this, SIGNAL(sigRequestResize(int, uchar*, int, int, int, int)),
     376               m_pMachineView, SLOT(sltHandleRequestResize(int, uchar*, int, int, int, int)));
     377    disconnect(this, SIGNAL(sigNotifyUpdate(int, int, int, int)),
     378               m_pMachineView, SLOT(sltHandleNotifyUpdate(int, int, int, int)));
     379}
     380
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.h

    r46359 r46361  
    111111
    112112    /* Notifiers: EMT<->GUI interthread stuff: */
    113     void sigNotifyUpdate(int iX, int iY, int iW, int iH);
     113    void sigRequestResize(int iPixelFormat, uchar *pVRAM,
     114                          int iBitsPerPixel, int iBytesPerLine,
     115                          int iWidth, int iHeight);
     116    void sigNotifyUpdate(int iX, int iY, int iWidth, int iHeight);
    114117
    115118public:
     
    243246private:
    244247
     248    /* Helpers: Prepare/cleanup stuff: */
     249    void prepareConnections();
     250    void cleanupConnections();
     251
    245252#ifdef Q_OS_WIN
    246253    long m_iRefCnt;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r46360 r46361  
    205205}
    206206
    207 bool UIMachineView::guestResizeEvent(QEvent *pEvent,
    208                                      bool fFullscreenOrSeamless)
    209 {
    210     /* Some situations require framebuffer resize events to be ignored at all,
    211      * leaving machine-window, machine-view and framebuffer sizes preserved: */
     207void UIMachineView::sltHandleRequestResize(int iPixelFormat, uchar *pVRAM,
     208                                           int iBitsPerPixel, int iBytesPerLine,
     209                                           int iWidth, int iHeight)
     210{
     211    /* Some situations require frame-buffer resize-events to be ignored at all,
     212     * leaving machine-window, machine-view and frame-buffer sizes preserved: */
    212213    if (uisession()->isGuestResizeIgnored())
    213         return true;
    214 
    215     /* Get guest resize-event: */
    216     UIResizeEvent *pResizeEvent = static_cast<UIResizeEvent*>(pEvent);
    217 
    218     /** If only the pitch has changed (or nothing at all!) we only update the
    219      * framebuffer and don't touch the window.  This prevents unwanted resizes
     214        return;
     215
     216    /* If only the pitch has changed (or nothing at all!) we only update the
     217     * frame-buffer and don't touch the window.  This prevents unwanted resizes
    220218     * when entering or exiting fullscreen on X.Org guests and when
    221      * re-attaching the framebuffer on a view switch. */
    222     bool fResize =    pResizeEvent->width() != frameBuffer()->width()
    223                    || pResizeEvent->height() != frameBuffer()->height();
    224 
    225     /* Perform framebuffer resize if parent window is visible: */
     219     * re-attaching the frame-buffer on a view switch. */
     220    bool fResize =    iWidth != frameBuffer()->width()
     221                   || iHeight != frameBuffer()->height();
     222
     223    /* If machine-window is visible: */
    226224    if (uisession()->isScreenVisible(m_uScreenId))
    227         frameBuffer()->resizeEvent(pResizeEvent);
    228 
     225    {
     226        /* Apply current window size to frame-buffer: */
     227        if (visualStateType() == UIVisualStateType_Scale)
     228            frameBuffer()->setScaledSize(size());
     229
     230        /* Compose guest resize-event: */
     231        UIResizeEvent resizeEvent(iPixelFormat, pVRAM,
     232                                  iBitsPerPixel, iBytesPerLine,
     233                                  iWidth, iHeight);
     234
     235        /* Perform frame-buffer resize if parent window is visible: */
     236        frameBuffer()->resizeEvent(&resizeEvent);
     237    }
     238
     239    /* If resize actually happens and machine-window is visible: */
    229240    if (fResize && uisession()->isScreenVisible(m_uScreenId))
    230241    {
    231         /* Reapply maximum size restriction for machine-view: */
    232         setMaximumSize(sizeHint());
    233 
    234         /* Disable the resize hint override hack: */
    235         m_sizeHintOverride = QSize(-1, -1);
    236 
    237         /* Perform machine-view resize: */
    238         resize(pResizeEvent->width(), pResizeEvent->height());
     242        /* Scale-mode doesn't need this: */
     243        if (visualStateType() != UIVisualStateType_Scale)
     244        {
     245            /* Reapply maximum size restriction for machine-view: */
     246            setMaximumSize(sizeHint());
     247
     248            /* Disable the resize hint override hack: */
     249            m_sizeHintOverride = QSize(-1, -1);
     250
     251            /* Perform machine-view resize: */
     252            resize(iWidth, iHeight);
     253        }
    239254
    240255        /* Let our toplevel widget calculate its sizeHint properly: */
     
    242257
    243258#ifdef Q_WS_MAC
    244         machineLogic()->updateDockIconSize(screenId(), pResizeEvent->width(), pResizeEvent->height());
     259        machineLogic()->updateDockIconSize(screenId(), iWidth, iHeight);
    245260#endif /* Q_WS_MAC */
    246261
    247         /* Update machine-view sliders: */
    248         updateSliders();
    249 
    250         /* Normalize machine-window geometry: */
    251         if (!fFullscreenOrSeamless)
    252             normalizeGeometry(true /* Adjust Position? */);
     262        /* Scale-mode doesn't need this: */
     263        if (visualStateType() != UIVisualStateType_Scale)
     264        {
     265            /* Update machine-view sliders: */
     266            updateSliders();
     267
     268            /* Normalize machine-window geometry: */
     269            if (visualStateType() == UIVisualStateType_Normal)
     270                normalizeGeometry(true /* Adjust Position? */);
     271        }
    253272    }
    254273
     
    258277    /* Emit a signal about guest was resized: */
    259278    emit resizeHintDone();
    260 
    261     pEvent->accept();
    262     return true;
    263279}
    264280
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r46360 r46361  
    9191    /* Slot to perform guest resize: */
    9292    void sltPerformGuestResize(const QSize &aSize = QSize());
     93
     94    /* Handler: Frame-buffer RequestResize stuff: */
     95    void sltHandleRequestResize(int iPixelFormat, uchar *pVRAM,
     96                                int iBitsPerPixel, int iBytesPerLine,
     97                                int iWidth, int iHeight);
    9398
    9499    /* Handler: Frame-buffer NotifyUpdate stuff: */
     
    183188    CGImageRef frameBuffertoCGImageRef(UIFrameBuffer *pFrameBuffer);
    184189#endif /* Q_WS_MAC */
    185     bool guestResizeEvent(QEvent *pEvent, bool fFullscreen);
    186190    /** What view mode (normal, fullscreen etc.) are we in? */
    187191    UIVisualStateType visualStateType() const;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.cpp

    r46020 r46361  
    6868        if (m_bIsGuestAutoresizeEnabled && uisession()->isGuestSupportsGraphics())
    6969            sltPerformGuestResize(workingArea().size());
    70 }
    71 
    72 bool UIMachineViewFullscreen::event(QEvent *pEvent)
    73 {
    74     switch (pEvent->type())
    75     {
    76         case ResizeEventType:
    77         {
    78             return guestResizeEvent(pEvent, true);
    79         }
    80 
    81         default:
    82             break;
    83     }
    84     return UIMachineView::event(pEvent);
    8570}
    8671
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.h

    r46020 r46361  
    4747
    4848    /* Event handlers: */
    49     bool event(QEvent *pEvent);
    5049    bool eventFilter(QObject *pWatched, QEvent *pEvent);
    5150
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp

    r46020 r46361  
    7070     * switch. */
    7171    maybeResendResizeHint();
    72 }
    73 
    74 bool UIMachineViewNormal::event(QEvent *pEvent)
    75 {
    76     switch (pEvent->type())
    77     {
    78         case ResizeEventType:
    79         {
    80             return guestResizeEvent(pEvent, false);
    81         }
    82 
    83         default:
    84             break;
    85     }
    86     return UIMachineView::event(pEvent);
    8772}
    8873
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.h

    r46020 r46361  
    5353
    5454    /* Event handlers: */
    55     bool event(QEvent *pEvent);
    5655    bool eventFilter(QObject *pWatched, QEvent *pEvent);
    5756
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.cpp

    r46293 r46361  
    156156}
    157157
    158 bool UIMachineViewScale::event(QEvent *pEvent)
    159 {
    160     switch (pEvent->type())
    161     {
    162         case ResizeEventType:
    163         {
    164             /* Some situations require framebuffer resize events to be ignored at all,
    165              * leaving machine-window, machine-view and framebuffer sizes preserved: */
    166             if (uisession()->isGuestResizeIgnored())
    167                 return true;
    168 
    169             /* Get guest resize-event: */
    170             UIResizeEvent *pResizeEvent = static_cast<UIResizeEvent*>(pEvent);
    171 
    172             /* Perform framebuffer resize: */
    173             frameBuffer()->setScaledSize(size());
    174             frameBuffer()->resizeEvent(pResizeEvent);
    175 
    176             /* Let our toplevel widget calculate its sizeHint properly: */
    177             QCoreApplication::sendPostedEvents(0, QEvent::LayoutRequest);
    178 
    179 #ifdef Q_WS_MAC
    180             machineLogic()->updateDockIconSize(screenId(), pResizeEvent->width(), pResizeEvent->height());
    181 #endif /* Q_WS_MAC */
    182 
    183             /* Report to the VM thread that we finished resizing: */
    184             session().GetConsole().GetDisplay().ResizeCompleted(screenId());
    185 
    186             /* Emit a signal about guest was resized: */
    187             emit resizeHintDone();
    188 
    189             pEvent->accept();
    190             return true;
    191         }
    192 
    193          default:
    194             break;
    195     }
    196     return UIMachineView::event(pEvent);
    197 }
    198 
    199158bool UIMachineViewScale::eventFilter(QObject *pWatched, QEvent *pEvent)
    200159{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.h

    r46293 r46361  
    5555
    5656    /* Event handlers: */
    57     bool event(QEvent *pEvent);
    5857    bool eventFilter(QObject *pWatched, QEvent *pEvent);
    5958
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.cpp

    r46255 r46361  
    8787            m_pFrameBuffer->applyVisibleRegionEvent(static_cast<UISetRegionEvent*>(pEvent));
    8888            return true;
    89         }
    90 
    91         case ResizeEventType:
    92         {
    93             return guestResizeEvent(pEvent, true);
    9489        }
    9590
Note: See TracChangeset for help on using the changeset viewer.

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