Changeset 46361 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jun 3, 2013 1:34:22 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 86177
- 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 51 51 m_WinId = (m_pMachineView && m_pMachineView->viewport()) ? (LONG64)m_pMachineView->viewport()->winId() : 0; 52 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); 53 /* Connect handlers: */ 54 if (m_pMachineView) 55 prepareConnections(); 58 56 59 57 /* Initialize critical-section: */ … … 67 65 RTCritSectDelete(&m_critSect); 68 66 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(); 73 70 } 74 71 … … 186 183 187 184 /* 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); 195 188 else 196 189 /* Mark request as finished. … … 352 345 lock(); 353 346 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(); 358 350 359 351 /* Reassign machine-view: */ … … 361 353 m_WinId = (m_pMachineView && m_pMachineView->viewport()) ? (LONG64)m_pMachineView->viewport()->winId() : 0; 362 354 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(); 368 358 369 359 /* Unlock thread finally: */ … … 371 361 } 372 362 363 void 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 373 void 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 111 111 112 112 /* 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); 114 117 115 118 public: … … 243 246 private: 244 247 248 /* Helpers: Prepare/cleanup stuff: */ 249 void prepareConnections(); 250 void cleanupConnections(); 251 245 252 #ifdef Q_OS_WIN 246 253 long m_iRefCnt; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r46360 r46361 205 205 } 206 206 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: */ 207 void 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: */ 212 213 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 220 218 * when entering or exiting fullscreen on X.Org guests and when 221 * re-attaching the frame buffer on a view switch. */222 bool fResize = pResizeEvent->width()!= frameBuffer()->width()223 || pResizeEvent->height()!= frameBuffer()->height();224 225 /* Perform framebuffer resize if parentwindow 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: */ 226 224 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: */ 229 240 if (fResize && uisession()->isScreenVisible(m_uScreenId)) 230 241 { 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 } 239 254 240 255 /* Let our toplevel widget calculate its sizeHint properly: */ … … 242 257 243 258 #ifdef Q_WS_MAC 244 machineLogic()->updateDockIconSize(screenId(), pResizeEvent->width(), pResizeEvent->height());259 machineLogic()->updateDockIconSize(screenId(), iWidth, iHeight); 245 260 #endif /* Q_WS_MAC */ 246 261 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 } 253 272 } 254 273 … … 258 277 /* Emit a signal about guest was resized: */ 259 278 emit resizeHintDone(); 260 261 pEvent->accept();262 return true;263 279 } 264 280 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
r46360 r46361 91 91 /* Slot to perform guest resize: */ 92 92 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); 93 98 94 99 /* Handler: Frame-buffer NotifyUpdate stuff: */ … … 183 188 CGImageRef frameBuffertoCGImageRef(UIFrameBuffer *pFrameBuffer); 184 189 #endif /* Q_WS_MAC */ 185 bool guestResizeEvent(QEvent *pEvent, bool fFullscreen);186 190 /** What view mode (normal, fullscreen etc.) are we in? */ 187 191 UIVisualStateType visualStateType() const; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.cpp
r46020 r46361 68 68 if (m_bIsGuestAutoresizeEnabled && uisession()->isGuestSupportsGraphics()) 69 69 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);85 70 } 86 71 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.h
r46020 r46361 47 47 48 48 /* Event handlers: */ 49 bool event(QEvent *pEvent);50 49 bool eventFilter(QObject *pWatched, QEvent *pEvent); 51 50 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp
r46020 r46361 70 70 * switch. */ 71 71 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);87 72 } 88 73 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.h
r46020 r46361 53 53 54 54 /* Event handlers: */ 55 bool event(QEvent *pEvent);56 55 bool eventFilter(QObject *pWatched, QEvent *pEvent); 57 56 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.cpp
r46293 r46361 156 156 } 157 157 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_MAC180 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 199 158 bool UIMachineViewScale::eventFilter(QObject *pWatched, QEvent *pEvent) 200 159 { -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.h
r46293 r46361 55 55 56 56 /* Event handlers: */ 57 bool event(QEvent *pEvent);58 57 bool eventFilter(QObject *pWatched, QEvent *pEvent); 59 58 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.cpp
r46255 r46361 87 87 m_pFrameBuffer->applyVisibleRegionEvent(static_cast<UISetRegionEvent*>(pEvent)); 88 88 return true; 89 }90 91 case ResizeEventType:92 {93 return guestResizeEvent(pEvent, true);94 89 } 95 90
Note:
See TracChangeset
for help on using the changeset viewer.