VirtualBox

Ignore:
Timestamp:
May 28, 2013 9:13:16 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
86040
Message:

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

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r46242 r46293  
    296296        src/runtime/UIActionPoolRuntime.h \
    297297        src/runtime/UIConsoleEventHandler.h \
     298        src/runtime/UIFrameBuffer.h \
    298299        src/runtime/UIIndicatorsPool.h \
    299300        src/runtime/UIKeyboardHandler.h \
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDefs.h

    r46058 r46293  
    6969    {
    7070          ResizeEventType = QEvent::User + 101
    71         , RepaintEventType
    7271        , SetRegionEventType
    7372        , ModifierKeyChangeEventType
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp

    r46283 r46293  
    4747#endif
    4848{
     49    /* Assign mahine-view: */
    4950    AssertMsg(m_pMachineView, ("UIMachineView must not be null\n"));
    5051    m_WinId = (m_pMachineView && m_pMachineView->viewport()) ? (LONG64)m_pMachineView->viewport()->winId() : 0;
     52
     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);
     58
     59    /* Initialize critical-section: */
    5160    int rc = RTCritSectInit(&m_critSect);
    5261    AssertRC(rc);
     
    177186}
    178187
    179 /* This method is called on EMT from under this object's lock! */
    180188STDMETHODIMP UIFrameBuffer::NotifyUpdate(ULONG uX, ULONG uY, ULONG uW, ULONG uH)
    181189{
     190    /* See comment in setView(): */
     191    lock();
     192
    182193    /* QWidget::update() is NOT thread safe and seems never will be,
    183      * So we have to post an async event to perform update operation.
    184      * Later the event will be replaced by the corresponding signal stuff: */
    185     lock(); /* See comment in setView(). */
    186     if (m_pMachineView)
    187         QApplication::postEvent(m_pMachineView, new UIRepaintEvent(uX, uY, uW, uH));
    188     unlock();
    189 
     194     * So we have to notify the machine-view with the async signal to perform update operation. */
     195    if (m_pMachineView)
     196        emit sigNotifyUpdate(uX, uY, uW, uH);
     197
     198    /* Unlock thread finally: */
     199    unlock();
     200
     201    /* Confirm NotifyUpdate: */
    190202    return S_OK;
    191203}
     
    309321     * so I will do it anyway. */
    310322    lock();
     323
     324    /* Disconnect NotifyUpdate handler: */
     325    if (m_pMachineView)
     326        disconnect(this, SIGNAL(sigNotifyUpdate(int, int, int, int)),
     327                   m_pMachineView, SLOT(sltHandleNotifyUpdate(int, int, int, int)));
     328
     329    /* Reassign machine-view: */
    311330    m_pMachineView = pView;
    312331    m_WinId = (m_pMachineView && m_pMachineView->viewport()) ? (LONG64)m_pMachineView->viewport()->winId() : 0;
    313     unlock();
    314 }
     332
     333    /* Connect NotifyUpdate handler: */
     334    if (m_pMachineView)
     335        connect(this, SIGNAL(sigNotifyUpdate(int, int, int, int)),
     336                m_pMachineView, SLOT(sltHandleNotifyUpdate(int, int, int, int)),
     337                Qt::QueuedConnection);
     338
     339    /* Unlock thread finally: */
     340    unlock();
     341}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.h

    r46283 r46293  
    6767
    6868/**
    69  *  Frame buffer repaint event.
    70  */
    71 class UIRepaintEvent : public QEvent
    72 {
    73 public:
    74 
    75     UIRepaintEvent(int iX, int iY, int iW, int iH)
    76         : QEvent((QEvent::Type)RepaintEventType)
    77         , m_iX(iX), m_iY(iY), m_iW(iW), m_iH(iH) {}
    78     int x() { return m_iX; }
    79     int y() { return m_iY; }
    80     int width() { return m_iW; }
    81     int height() { return m_iH; }
    82 
    83 private:
    84 
    85     int m_iX, m_iY, m_iW, m_iH;
    86 };
    87 
    88 /**
    8969 *  Frame buffer set region event.
    9070 */
     
    124104 *  See IFramebuffer documentation for more info.
    125105 */
    126 class UIFrameBuffer : VBOX_SCRIPTABLE_IMPL(IFramebuffer)
     106class UIFrameBuffer : public QObject, VBOX_SCRIPTABLE_IMPL(IFramebuffer)
    127107{
     108    Q_OBJECT;
     109
     110signals:
     111
     112    /* Notifiers: EMT<->GUI interthread stuff: */
     113    void sigNotifyUpdate(int iX, int iY, int iW, int iH);
     114
    128115public:
    129116
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r46058 r46293  
    203203    QString strKey = makeExtraDataKeyPerMonitor(GUI_LastGuestSizeHintWasFullscreen);
    204204    machine.SetExtraData(strKey, isFullscreenOrSeamless() ? "true" : "");
     205}
     206
     207void UIMachineView::sltHandleNotifyUpdate(int iX, int iY, int iW, int iH)
     208{
     209    /* Update corresponding viewport part: */
     210    viewport()->update(iX - contentsX(), iY - contentsY(), iW, iH);
    205211}
    206212
     
    916922    switch (pEvent->type())
    917923    {
    918         case RepaintEventType:
    919         {
    920             UIRepaintEvent *pPaintEvent = static_cast<UIRepaintEvent*>(pEvent);
    921             viewport()->update(pPaintEvent->x() - contentsX(), pPaintEvent->y() - contentsY(),
    922                                 pPaintEvent->width(), pPaintEvent->height());
    923             return true;
    924         }
    925 
    926924#ifdef Q_WS_MAC
    927925        /* Event posted OnShowWindow: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r46058 r46293  
    9191    /* Slot to perform guest resize: */
    9292    void sltPerformGuestResize(const QSize &aSize = QSize());
     93
     94    /* Handler: Frame-buffer NotifyUpdate stuff: */
     95    virtual void sltHandleNotifyUpdate(int iX, int iY, int iW, int iH);
    9396
    9497    /* Watch dog for desktop resizes: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.cpp

    r46005 r46293  
    137137}
    138138
     139void UIMachineViewScale::sltHandleNotifyUpdate(int iX, int iY, int iW, int iH)
     140{
     141    /* Initialize variables for scale mode: */
     142    QSize scaledSize = frameBuffer()->scaledSize();
     143    double xRatio = (double)scaledSize.width() / frameBuffer()->width();
     144    double yRatio = (double)scaledSize.height() / frameBuffer()->height();
     145    AssertMsg(contentsX() == 0, ("This can't be, else notify Dsen!\n"));
     146    AssertMsg(contentsY() == 0, ("This can't be, else notify Dsen!\n"));
     147
     148    /* Update corresponding viewport part,
     149     * But make sure we update always a bigger rectangle than requested to
     150     * catch all rounding errors. (use 1 time the ratio factor and
     151     * round down on top/left, but round up for the width/height) */
     152    viewport()->update((int)(iX * xRatio) - ((int)xRatio) - 1,
     153                       (int)(iY * yRatio) - ((int)yRatio) - 1,
     154                       (int)(iW * xRatio) + ((int)xRatio + 2) * 2,
     155                       (int)(iH * yRatio) + ((int)yRatio + 2) * 2);
     156}
     157
    139158bool UIMachineViewScale::event(QEvent *pEvent)
    140159{
     
    172191        }
    173192
    174         case RepaintEventType:
    175         {
    176             UIRepaintEvent *pPaintEvent = static_cast<UIRepaintEvent*>(pEvent);
    177             QSize scaledSize = frameBuffer()->scaledSize();
    178             double xRatio = (double)scaledSize.width() / frameBuffer()->width();
    179             double yRatio = (double)scaledSize.height() / frameBuffer()->height();
    180             AssertMsg(contentsX() == 0, ("This can't be, else notify Dsen!\n"));
    181             AssertMsg(contentsY() == 0, ("This can't be, else notify Dsen!\n"));
    182 
    183             /* Make sure we update always a bigger rectangle than requested to
    184              * catch all rounding errors. (use 1 time the ratio factor and
    185              * round down on top/left, but round up for the width/height) */
    186             viewport()->update((int)(pPaintEvent->x() * xRatio) - ((int)xRatio) - 1,
    187                                (int)(pPaintEvent->y() * yRatio) - ((int)yRatio) - 1,
    188                                (int)(pPaintEvent->width() * xRatio) + ((int)xRatio + 2) * 2,
    189                                (int)(pPaintEvent->height() * yRatio) + ((int)yRatio + 2) * 2);
    190             pEvent->accept();
    191             return true;
    192         }
    193 
    194         default:
     193         default:
    195194            break;
    196195    }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.h

    r46020 r46293  
    4949    void sltPerformGuestScale();
    5050
     51    /* Handler: Frame-buffer NotifyUpdate stuff: */
     52    void sltHandleNotifyUpdate(int iX, int iY, int iW, int iH);
     53
    5154private:
    5255
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