Changeset 46293 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- May 28, 2013 9:13:16 AM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 86040
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r46242 r46293 296 296 src/runtime/UIActionPoolRuntime.h \ 297 297 src/runtime/UIConsoleEventHandler.h \ 298 src/runtime/UIFrameBuffer.h \ 298 299 src/runtime/UIIndicatorsPool.h \ 299 300 src/runtime/UIKeyboardHandler.h \ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDefs.h
r46058 r46293 69 69 { 70 70 ResizeEventType = QEvent::User + 101 71 , RepaintEventType72 71 , SetRegionEventType 73 72 , ModifierKeyChangeEventType -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp
r46283 r46293 47 47 #endif 48 48 { 49 /* Assign mahine-view: */ 49 50 AssertMsg(m_pMachineView, ("UIMachineView must not be null\n")); 50 51 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: */ 51 60 int rc = RTCritSectInit(&m_critSect); 52 61 AssertRC(rc); … … 177 186 } 178 187 179 /* This method is called on EMT from under this object's lock! */180 188 STDMETHODIMP UIFrameBuffer::NotifyUpdate(ULONG uX, ULONG uY, ULONG uW, ULONG uH) 181 189 { 190 /* See comment in setView(): */ 191 lock(); 192 182 193 /* 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: */ 190 202 return S_OK; 191 203 } … … 309 321 * so I will do it anyway. */ 310 322 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: */ 311 330 m_pMachineView = pView; 312 331 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 67 67 68 68 /** 69 * Frame buffer repaint event.70 */71 class UIRepaintEvent : public QEvent72 {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 /**89 69 * Frame buffer set region event. 90 70 */ … … 124 104 * See IFramebuffer documentation for more info. 125 105 */ 126 class UIFrameBuffer : VBOX_SCRIPTABLE_IMPL(IFramebuffer)106 class UIFrameBuffer : public QObject, VBOX_SCRIPTABLE_IMPL(IFramebuffer) 127 107 { 108 Q_OBJECT; 109 110 signals: 111 112 /* Notifiers: EMT<->GUI interthread stuff: */ 113 void sigNotifyUpdate(int iX, int iY, int iW, int iH); 114 128 115 public: 129 116 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r46058 r46293 203 203 QString strKey = makeExtraDataKeyPerMonitor(GUI_LastGuestSizeHintWasFullscreen); 204 204 machine.SetExtraData(strKey, isFullscreenOrSeamless() ? "true" : ""); 205 } 206 207 void 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); 205 211 } 206 212 … … 916 922 switch (pEvent->type()) 917 923 { 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 926 924 #ifdef Q_WS_MAC 927 925 /* Event posted OnShowWindow: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
r46058 r46293 91 91 /* Slot to perform guest resize: */ 92 92 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); 93 96 94 97 /* Watch dog for desktop resizes: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.cpp
r46005 r46293 137 137 } 138 138 139 void 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 139 158 bool UIMachineViewScale::event(QEvent *pEvent) 140 159 { … … 172 191 } 173 192 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: 195 194 break; 196 195 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.h
r46020 r46293 49 49 void sltPerformGuestScale(); 50 50 51 /* Handler: Frame-buffer NotifyUpdate stuff: */ 52 void sltHandleNotifyUpdate(int iX, int iY, int iW, int iH); 53 51 54 private: 52 55
Note:
See TracChangeset
for help on using the changeset viewer.