- Timestamp:
- Mar 9, 2010 10:48:51 PM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r27233 r27236 423 423 #endif 424 424 425 void UIMachineView::updateSliders()426 {427 QSize p = viewport()->size();428 QSize m = maximumViewportSize();429 430 QSize v = QSize(m_pFrameBuffer->width(), m_pFrameBuffer->height());431 /* No scroll bars needed: */432 if (m.expandedTo(v) == m)433 p = m;434 435 horizontalScrollBar()->setRange(0, v.width() - p.width());436 verticalScrollBar()->setRange(0, v.height() - p.height());437 horizontalScrollBar()->setPageStep(p.width());438 verticalScrollBar()->setPageStep(p.height());439 }440 441 425 void UIMachineView::prepareFrameBuffer() 442 426 { … … 688 672 } 689 673 break; 674 } 675 676 case VBoxDefs::ResizeEventType: 677 { 678 /* Some situations require framebuffer resize events to be ignored, 679 * leaving machine window & machine view & framebuffer sizes preserved: */ 680 if (uisession()->isGuestResizeIgnored()) 681 return true; 682 683 /* We are starting to perform machine view resize: */ 684 bool oldIgnoreMainwndResize = isMachineWindowResizeIgnored(); 685 setMachineWindowResizeIgnored(true); 686 687 /* Get guest resize-event: */ 688 UIResizeEvent *pResizeEvent = static_cast<UIResizeEvent*>(pEvent); 689 690 /* Perform framebuffer resize: */ 691 frameBuffer()->resizeEvent(pResizeEvent); 692 693 /* Reapply maximum size restriction for machine view: */ 694 setMaximumSize(sizeHint()); 695 696 /* Store the new size to prevent unwanted resize hints being sent back: */ 697 storeConsoleSize(pResizeEvent->width(), pResizeEvent->height()); 698 699 /* Perform machine-view resize: */ 700 resize(pResizeEvent->width(), pResizeEvent->height()); 701 702 /* Let our toplevel widget calculate its sizeHint properly. */ 703 #ifdef Q_WS_X11 704 /* We use processEvents rather than sendPostedEvents & set the time out value to max cause on X11 otherwise 705 * the layout isn't calculated correctly. Dosn't find the bug in Qt, but this could be triggered through 706 * the async nature of the X11 window event system. */ 707 QCoreApplication::processEvents(QEventLoop::AllEvents, INT_MAX); 708 #else /* Q_WS_X11 */ 709 QCoreApplication::sendPostedEvents(0, QEvent::LayoutRequest); 710 #endif /* Q_WS_X11 */ 711 712 #ifdef Q_WS_MAC 713 // TODO_NEW_CORE 714 // mDockIconPreview->setOriginalSize(pResizeEvent->width(), pResizeEvent->height()); 715 #endif /* Q_WS_MAC */ 716 717 /* Update mouse cursor shape: */ 718 updateMouseCursorShape(); 719 #ifdef Q_WS_WIN32 720 updateMouseCursorClipping(); 721 #endif 722 723 /* May be we have to restrict minimum size? */ 724 maybeRestrictMinimumSize(); 725 726 /* Update machine-view sliders: */ 727 updateSliders(); 728 729 /* Normalize geometry: */ 730 normalizeGeometry(true /* adjustPosition */); 731 732 /* Report to the VM thread that we finished resizing */ 733 session().GetConsole().GetDisplay().ResizeCompleted(screenId()); 734 735 /* We are finishing to perform machine-view resize: */ 736 setMachineWindowResizeIgnored(oldIgnoreMainwndResize); 737 738 /* Make sure that all posted signals are processed: */ 739 qApp->processEvents(); 740 741 /* We also recalculate the desktop geometry if this is determined 742 * automatically. In fact, we only need this on the first resize, 743 * but it is done every time to keep the code simpler. */ 744 calculateDesktopGeometry(); 745 746 /* Emit a signal about guest was resized: */ 747 emit resizeHintDone(); 748 749 return true; 690 750 } 691 751 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
r27227 r27236 71 71 72 72 /* Public members: */ 73 virtual void normalizeGeometry(bool /* bAdjustPosition = false */) {}73 virtual void normalizeGeometry(bool /* bAdjustPosition = false */) = 0; 74 74 75 75 signals: … … 125 125 void updateMouseCursorClipping(); 126 126 #endif 127 void updateSliders(); 127 virtual QRect availableGeometry() = 0; 128 virtual void maybeRestrictMinimumSize() = 0; 129 virtual void updateSliders() = 0; 128 130 129 131 #ifdef Q_WS_MAC … … 208 210 void releaseAllPressedKeys(bool aReleaseHostKey = true); 209 211 void sendChangedKeyStates(); 210 211 virtual QRect availableGeometry() = 0;212 212 213 213 static void dimImage(QImage &img); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.cpp
r27235 r27236 148 148 switch (pEvent->type()) 149 149 { 150 case VBoxDefs::ResizeEventType:151 {152 /* Some situations require framebuffer resize events to be ignored,153 * leaving machine window & machine view & framebuffer sizes preserved: */154 if (uisession()->isGuestResizeIgnored())155 return true;156 157 /* We are starting to perform machine view resize: */158 bool oldIgnoreMainwndResize = isMachineWindowResizeIgnored();159 setMachineWindowResizeIgnored(true);160 161 /* Get guest resize-event: */162 UIResizeEvent *pResizeEvent = static_cast<UIResizeEvent*>(pEvent);163 164 /* Perform framebuffer resize: */165 frameBuffer()->resizeEvent(pResizeEvent);166 167 /* Reapply maximum size restriction for machine view: */168 setMaximumSize(sizeHint());169 170 /* Store the new size to prevent unwanted resize hints being sent back: */171 storeConsoleSize(pResizeEvent->width(), pResizeEvent->height());172 173 /* Perform machine view resize: */174 resize(pResizeEvent->width(), pResizeEvent->height());175 176 /* Let our toplevel widget calculate its sizeHint properly. */177 #ifdef Q_WS_X11178 /* We use processEvents rather than sendPostedEvents & set the time out value to max cause on X11 otherwise179 * the layout isn't calculated correctly. Dosn't find the bug in Qt, but this could be triggered through180 * the async nature of the X11 window event system. */181 QCoreApplication::processEvents(QEventLoop::AllEvents, INT_MAX);182 #else /* Q_WS_X11 */183 QCoreApplication::sendPostedEvents(0, QEvent::LayoutRequest);184 #endif /* Q_WS_X11 */185 186 #ifdef Q_WS_MAC187 // TODO_NEW_CORE188 // mDockIconPreview->setOriginalSize(pResizeEvent->width(), pResizeEvent->height());189 #endif /* Q_WS_MAC */190 191 /* Update mouse cursor shape: */192 updateMouseCursorShape();193 #ifdef Q_WS_WIN32194 updateMouseCursorClipping();195 #endif196 197 /* May be we have to restrict minimum size? */198 maybeRestrictMinimumSize();199 200 /* Report to the VM thread that we finished resizing */201 session().GetConsole().GetDisplay().ResizeCompleted(screenId());202 203 /* We are finishing to perform machine view resize: */204 setMachineWindowResizeIgnored(oldIgnoreMainwndResize);205 206 /* Make sure that all posted signals are processed: */207 qApp->processEvents();208 209 /* We also recalculate the desktop geometry if this is determined automatically.210 * In fact, we only need this on the first resize,211 * but it is done every time to keep the code simpler. */212 calculateDesktopGeometry();213 214 /* Emit a signal about guest was resized: */215 emit resizeHintDone();216 217 return true;218 }219 220 150 case QEvent::KeyPress: 221 151 case QEvent::KeyRelease: 222 152 { 153 /* Get key-event: */ 223 154 QKeyEvent *pKeyEvent = static_cast<QKeyEvent*>(pEvent); 224 155 156 /* Process Host+Home for menu popup: */ 225 157 if (isHostKeyPressed() && pEvent->type() == QEvent::KeyPress) 226 158 { -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.h
r27124 r27236 77 77 78 78 /* Private helpers: */ 79 void normalizeGeometry(bool /* fAdjustPosition */) {} 79 80 QRect availableGeometry(); 80 81 void maybeRestrictMinimumSize(); 82 void updateSliders() {} 81 83 82 84 /* Private members: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp
r27235 r27236 26 26 #include <QDesktopWidget> 27 27 #include <QMenuBar> 28 #include <QScrollBar> 28 29 #include <QTimer> 29 30 … … 90 91 } 91 92 92 void UIMachineViewNormal::sltAdditionsStateChanged()93 {94 /* Check if we should restrict minimum size: */95 maybeRestrictMinimumSize();96 }97 98 93 void UIMachineViewNormal::sltPerformGuestResize(const QSize &toSize) 99 94 { … … 132 127 } 133 128 134 /* If the desktop geometry is set automatically, this will update it: */ 129 void UIMachineViewNormal::sltAdditionsStateChanged() 130 { 131 /* Check if we should restrict minimum size: */ 132 maybeRestrictMinimumSize(); 133 } 134 135 135 void UIMachineViewNormal::sltDesktopResized() 136 136 { 137 /* If the desktop geometry is set automatically, this will update it: */ 137 138 calculateDesktopGeometry(); 138 139 } … … 142 143 switch (pEvent->type()) 143 144 { 144 case VBoxDefs::ResizeEventType:145 {146 /* Some situations require framebuffer resize events to be ignored,147 * leaving machine window & machine view & framebuffer sizes preserved: */148 if (uisession()->isGuestResizeIgnored())149 return true;150 151 /* We are starting to perform machine view resize: */152 bool oldIgnoreMainwndResize = isMachineWindowResizeIgnored();153 setMachineWindowResizeIgnored(true);154 155 /* Get guest resize-event: */156 UIResizeEvent *pResizeEvent = static_cast<UIResizeEvent*>(pEvent);157 158 /* Perform framebuffer resize: */159 frameBuffer()->resizeEvent(pResizeEvent);160 161 /* Reapply maximum size restriction for machine view: */162 setMaximumSize(sizeHint());163 164 /* Store the new size to prevent unwanted resize hints being sent back. */165 storeConsoleSize(pResizeEvent->width(), pResizeEvent->height());166 167 /* Resize the guest canvas: */168 resize(pResizeEvent->width(), pResizeEvent->height());169 170 /* Let our toplevel widget calculate its sizeHint properly. */171 #ifdef Q_WS_X11172 /* We use processEvents rather than sendPostedEvents & set the time out value to max cause on X11 otherwise173 * the layout isn't calculated correctly. Dosn't find the bug in Qt, but this could be triggered through174 * the async nature of the X11 window event system. */175 QCoreApplication::processEvents(QEventLoop::AllEvents, INT_MAX);176 #else /* Q_WS_X11 */177 QCoreApplication::sendPostedEvents(0, QEvent::LayoutRequest);178 #endif /* Q_WS_X11 */179 180 #ifdef Q_WS_MAC181 // TODO_NEW_CORE182 // mDockIconPreview->setOriginalSize(pResizeEvent->width(), pResizeEvent->height());183 #endif /* Q_WS_MAC */184 185 /* Update mouse cursor shape: */186 updateMouseCursorShape();187 #ifdef Q_WS_WIN32188 updateMouseCursorClipping();189 #endif190 191 /* May be we have to restrict minimum size? */192 maybeRestrictMinimumSize();193 194 /* Update machine view sliders: */195 updateSliders();196 197 /* Normalize geometry: */198 normalizeGeometry(true /* adjustPosition */);199 200 /* Report to the VM thread that we finished resizing */201 session().GetConsole().GetDisplay().ResizeCompleted(screenId());202 203 /* We are finishing to perform machine view resize: */204 setMachineWindowResizeIgnored(oldIgnoreMainwndResize);205 206 /* Make sure that all posted signals are processed: */207 qApp->processEvents();208 209 /* We also recalculate the desktop geometry if this is determined210 * automatically. In fact, we only need this on the first resize,211 * but it is done every time to keep the code simpler. */212 calculateDesktopGeometry();213 214 /* Emit a signal about guest was resized: */215 emit resizeHintDone();216 217 return true;218 }219 220 145 case QEvent::KeyPress: 221 146 case QEvent::KeyRelease: 222 147 { 148 /* Get key-event: */ 223 149 QKeyEvent *pKeyEvent = static_cast<QKeyEvent*>(pEvent); 224 150 151 /* Process Host+Home as menu-bar activator: */ 225 152 if (isHostKeyPressed() && pEvent->type() == QEvent::KeyPress) 226 153 { 227 /* Process Host+Home as menu-bar activator: */228 154 if (pKeyEvent->key() == Qt::Key_Home) 229 155 { … … 411 337 } 412 338 339 void UIMachineViewNormal::updateSliders() 340 { 341 QSize p = viewport()->size(); 342 QSize m = maximumViewportSize(); 343 344 QSize v = QSize(frameBuffer()->width(), frameBuffer()->height()); 345 /* No scroll bars needed: */ 346 if (m.expandedTo(v) == m) 347 p = m; 348 349 horizontalScrollBar()->setRange(0, v.width() - p.width()); 350 verticalScrollBar()->setRange(0, v.height() - p.height()); 351 horizontalScrollBar()->setPageStep(p.width()); 352 verticalScrollBar()->setPageStep(p.height()); 353 } 354 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.h
r27124 r27236 78 78 QRect availableGeometry(); 79 79 void maybeRestrictMinimumSize(); 80 void updateSliders(); 80 81 81 82 /* Private members: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.cpp
r27235 r27236 147 147 switch (pEvent->type()) 148 148 { 149 case VBoxDefs::ResizeEventType:150 {151 /* Some situations require framebuffer resize events to be ignored,152 * leaving machine window & machine view & framebuffer sizes preserved: */153 if (uisession()->isGuestResizeIgnored())154 return true;155 156 /* We are starting to perform machine view resize: */157 bool oldIgnoreMainwndResize = isMachineWindowResizeIgnored();158 setMachineWindowResizeIgnored(true);159 160 /* Get guest resize-event: */161 UIResizeEvent *pResizeEvent = static_cast<UIResizeEvent*>(pEvent);162 163 /* Perform framebuffer resize: */164 frameBuffer()->resizeEvent(pResizeEvent);165 166 /* Reapply maximum size restriction for machine view: */167 setMaximumSize(sizeHint());168 169 /* Store the new size to prevent unwanted resize hints being sent back: */170 storeConsoleSize(pResizeEvent->width(), pResizeEvent->height());171 172 /* Perform machine view resize: */173 resize(pResizeEvent->width(), pResizeEvent->height());174 175 /* Let our toplevel widget calculate its sizeHint properly. */176 #ifdef Q_WS_X11177 /* We use processEvents rather than sendPostedEvents & set the time out value to max cause on X11 otherwise178 * the layout isn't calculated correctly. Dosn't find the bug in Qt, but this could be triggered through179 * the async nature of the X11 window event system. */180 QCoreApplication::processEvents(QEventLoop::AllEvents, INT_MAX);181 #else /* Q_WS_X11 */182 QCoreApplication::sendPostedEvents(0, QEvent::LayoutRequest);183 #endif /* Q_WS_X11 */184 185 #ifdef Q_WS_MAC186 // TODO_NEW_CORE187 //mDockIconPreview->setOriginalSize(pResizeEvent->width(), pResizeEvent->height());188 #endif /* Q_WS_MAC */189 190 /* Update mouse cursor shape: */191 updateMouseCursorShape();192 #ifdef Q_WS_WIN32193 updateMouseCursorClipping();194 #endif195 196 /* Report to the VM thread that we finished resizing: */197 session().GetConsole().GetDisplay().ResizeCompleted(screenId());198 199 /* We are finishing to perform machine view resize: */200 setMachineWindowResizeIgnored(oldIgnoreMainwndResize);201 202 /* Make sure that all posted signals are processed: */203 qApp->processEvents();204 205 /* We also recalculate the desktop geometry if this is determined automatically.206 * In fact, we only need this on the first resize,207 * but it is done every time to keep the code simpler. */208 calculateDesktopGeometry();209 210 /* Emit a signal about guest was resized: */211 emit resizeHintDone();212 213 return true;214 }215 216 149 case VBoxDefs::SetRegionEventType: 217 150 { 151 /* Get region-update event: */ 218 152 UISetRegionEvent *pSetRegionEvent = static_cast<UISetRegionEvent*>(pEvent); 153 154 /* Apply new region: */ 219 155 if (pSetRegionEvent->region() != m_lastVisibleRegion) 220 156 { … … 228 164 case QEvent::KeyRelease: 229 165 { 166 /* Get key-event: */ 230 167 QKeyEvent *pKeyEvent = static_cast<QKeyEvent*>(pEvent); 231 168 169 /* Process Host+Home for menu popup: */ 232 170 if (isHostKeyPressed() && pEvent->type() == QEvent::KeyPress) 233 171 { -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.h
r27124 r27236 74 74 75 75 /* Private helpers: */ 76 void normalizeGeometry(bool /* fAdjustPosition */) {} 76 77 QRect availableGeometry(); 78 void maybeRestrictMinimumSize() {} 79 void updateSliders() {} 77 80 78 81 /* Private variables: */
Note:
See TracChangeset
for help on using the changeset viewer.