Changeset 49177 in vbox
- Timestamp:
- Oct 18, 2013 11:48:13 AM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r49048 r49177 271 271 } 272 272 273 /** Adjusts guest screen size for each the machine-window we have. */ 274 void UIMachineLogic::maybeAdjustGuestScreenSize() 275 { 276 foreach(UIMachineWindow *pMachineWindow, machineWindows()) 277 pMachineWindow->machineView()->maybeAdjustGuestScreenSize(); 278 } 279 273 280 #ifdef Q_WS_MAC 274 281 void UIMachineLogic::updateDockIcon() … … 1120 1127 pMachineWindow->showNormal(); 1121 1128 1122 /* Normalize view'sgeometry: */1123 pMachineWindow-> machineView()->normalizeGeometry(true);1129 /* Normalize window geometry: */ 1130 pMachineWindow->normalizeGeometry(true); 1124 1131 } 1125 1132 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
r49025 r49177 79 79 bool isPreventAutoClose() const { return m_fIsPreventAutoClose; } 80 80 void setPreventAutoClose(bool fIsPreventAutoClose) { m_fIsPreventAutoClose = fIsPreventAutoClose; } 81 82 /* API: Guest screen size stuff: */ 83 void maybeAdjustGuestScreenSize(); 81 84 82 85 /* Wrapper to open Machine settings / Network page: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r49167 r49177 275 275 /* Normalize machine-window geometry: */ 276 276 if (visualStateType() == UIVisualStateType_Normal) 277 normalizeGeometry(true /* Adjust Position?*/);277 machineWindow()->normalizeGeometry(true /* adjust position */); 278 278 } 279 279 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
r47493 r49177 76 76 virtual void setGuestAutoresizeEnabled(bool /* fEnabled */) {} 77 77 78 /* Public members: */ 79 virtual void normalizeGeometry(bool /* bAdjustPosition = false */) = 0; 78 /** Adjusts guest screen size to correspond current machine-window size. 79 * @note Reimplemented in sub-classes. Base implementation does nothing. */ 80 virtual void maybeAdjustGuestScreenSize() {} 80 81 81 82 /* Framebuffer aspect ratio: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.h
r49013 r49177 61 61 CSession& session() const; 62 62 CMachine machine() const; 63 64 /** Adjusts machine-window size to correspond current guest screen size. 65 * @param fAdjustPosition determines whether is it necessary to adjust position too. 66 * @note Reimplemented in sub-classes. Base implementation does nothing. */ 67 virtual void normalizeGeometry(bool fAdjustPosition) { Q_UNUSED(fAdjustPosition); } 63 68 64 69 #ifndef VBOX_WITH_TRANSLUCENT_SEAMLESS -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r49167 r49177 206 206 } 207 207 208 void UISession::adjustGuestView()209 {210 foreach(UIMachineWindow *pMachineWindow, machineLogic()->machineWindows())211 {212 bool fAdjustPosition = false;213 UIVisualStateType visualStateType = machineLogic()->visualStateType();214 215 if (visualStateType == UIVisualStateType_Normal ||216 visualStateType == UIVisualStateType_Scale)217 fAdjustPosition = true;218 219 /* Normalize view's geometry: */220 pMachineWindow->machineView()->normalizeGeometry(fAdjustPosition);221 }222 }223 224 208 void UISession::powerUp() 225 209 { … … 276 260 { 277 261 msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_state_restore_90px.png", 0, 0); 278 /* If restoring from saved state, guest MachineView 279 should be notified about host MachineWindow geometry change */ 280 adjustGuestView(); 262 /* After restoring from 'saved' state, guest screen size should be adjusted: */ 263 machineLogic()->maybeAdjustGuestScreenSize(); 281 264 } 282 265 else -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r49121 r49177 271 271 void reinitMenuPool(); 272 272 bool preparePowerUp(); 273 void adjustGuestView();274 273 int countOfVisibleWindows(); 275 274 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.cpp
r49009 r49177 63 63 void UIMachineViewFullscreen::sltAdditionsStateChanged() 64 64 { 65 normalizeGeometry(false);65 maybeAdjustGuestScreenSize(); 66 66 } 67 67 … … 136 136 } 137 137 138 void UIMachineViewFullscreen::normalizeGeometry(bool /* fAdjustPosition */) 138 /** Adjusts guest screen size to correspond current <i>working area</i> size. */ 139 void UIMachineViewFullscreen::maybeAdjustGuestScreenSize() 139 140 { 140 141 /* Check if we should adjust guest to new size: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.h
r49009 r49177 62 62 void setGuestAutoresizeEnabled(bool bEnabled); 63 63 64 /* Private helpers: */65 void normalizeGeometry(bool fAdjustPosition);64 /* Helpers: Geometry stuff: */ 65 void maybeAdjustGuestScreenSize(); 66 66 QRect workingArea() const; 67 67 QSize calculateMaxGuestSize() const; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp
r49013 r49177 165 165 /* Resize to the appropriate size: */ 166 166 resize(workingArea.size()); 167 /* Adjust guest if necessary: */168 machineView()-> normalizeGeometry(false);167 /* Adjust guest screen size if necessary: */ 168 machineView()->maybeAdjustGuestScreenSize(); 169 169 /* Move mini-toolbar into appropriate place: */ 170 170 if (m_pMiniToolBar) -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp
r49176 r49177 49 49 , m_bIsGuestAutoresizeEnabled(gActionPool->action(UIActionIndexRuntime_Toggle_GuestAutoresize)->isChecked()) 50 50 { 51 52 /* Initialization: */ 53 sltAdditionsStateChanged(); 51 /* Resend the last resize hint if there was a fullscreen or 52 * seamless transition previously. If we were not in graphical 53 * mode initially after the transition this happens when we switch. */ 54 maybeResendResizeHint(); 54 55 } 55 56 … … 65 66 void UIMachineViewNormal::sltAdditionsStateChanged() 66 67 { 67 /* Resend the last resize hint if there was a fullscreen or 68 * seamless transition previously. If we were not in graphical 69 * mode initially after the transition this happens when we 70 * switch. */ 71 maybeResendResizeHint(); 68 maybeAdjustGuestScreenSize(); 72 69 } 73 70 … … 194 191 } 195 192 196 void UIMachineViewNormal::normalizeGeometry(bool bAdjustPosition) 197 { 198 #ifndef VBOX_GUI_WITH_CUSTOMIZATIONS1 199 QWidget *pTopLevelWidget = window(); 200 201 /* Calculate client window offsets: */ 202 QRect frameGeo = pTopLevelWidget->frameGeometry(); 203 QRect geo = pTopLevelWidget->geometry(); 204 int dl = geo.left() - frameGeo.left(); 205 int dt = geo.top() - frameGeo.top(); 206 int dr = frameGeo.right() - geo.right(); 207 int db = frameGeo.bottom() - geo.bottom(); 208 209 /* Get the best size w/o scroll bars: */ 210 QSize s = pTopLevelWidget->sizeHint(); 211 212 /* Resize the frame to fit the contents: */ 213 s -= pTopLevelWidget->size(); 214 frameGeo.setRight(frameGeo.right() + s.width()); 215 frameGeo.setBottom(frameGeo.bottom() + s.height()); 216 217 if (bAdjustPosition) 218 { 219 QRegion availableGeo; 220 QDesktopWidget *dwt = QApplication::desktop(); 221 if (dwt->isVirtualDesktop()) 222 /* Compose complex available region */ 223 for (int i = 0; i < dwt->numScreens(); ++ i) 224 availableGeo += dwt->availableGeometry(i); 225 else 226 /* Get just a simple available rectangle */ 227 availableGeo = dwt->availableGeometry(pTopLevelWidget->pos()); 228 229 frameGeo = VBoxGlobal::normalizeGeometry(frameGeo, availableGeo); 230 } 231 232 #if 0 233 /* Center the frame on the desktop: */ 234 frameGeo.moveCenter(availableGeo.center()); 235 #endif 236 237 /* Finally, set the frame geometry */ 238 pTopLevelWidget->setGeometry(frameGeo.left() + dl, frameGeo.top() + dt, frameGeo.width() - dl - dr, frameGeo.height() - dt - db); 239 240 #else /* !VBOX_GUI_WITH_CUSTOMIZATIONS1 */ 241 Q_UNUSED(bAdjustPosition); 242 #endif /* VBOX_GUI_WITH_CUSTOMIZATIONS1 */ 193 /** Adjusts guest screen size to correspond current machine-window size. */ 194 void UIMachineViewNormal::maybeAdjustGuestScreenSize() 195 { 196 /* Check if we should adjust guest to new size: */ 197 QSize centralWidgetSize = machineWindow()->centralWidget()->size(); 198 if ((int)frameBuffer()->width() != centralWidgetSize.width() || 199 (int)frameBuffer()->height() != centralWidgetSize.height()) 200 if (m_bIsGuestAutoresizeEnabled && uisession()->isGuestSupportsGraphics()) 201 sltPerformGuestResize(centralWidgetSize); 243 202 } 244 203 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.h
r49176 r49177 44 44 void sltAdditionsStateChanged(); 45 45 46 #ifdef Q_WS_X1147 /* Slot to perform synchronized geometry normalization.48 * Currently its only required under X11 as of its async nature: */49 virtual void sltNormalizeGeometry() { normalizeGeometry(true); }50 #endif /* Q_WS_X11 */51 52 46 private: 53 47 … … 72 66 /* Private helpers: */ 73 67 void maybeResendResizeHint(); 74 void normalizeGeometry(bool fAdjustPosition);68 void maybeAdjustGuestScreenSize(); 75 69 QRect workingArea() const; 76 70 QSize calculateMaxGuestSize() const; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp
r47401 r49177 457 457 m_normalGeometry = QRect(x, y, width(), height()); 458 458 setGeometry(m_normalGeometry); 459 if (machineView())460 machineView()->normalizeGeometry(false);459 /* Normalize to the optimal size: */ 460 normalizeGeometry(false); 461 461 } 462 462 /* Maximize if needed: */ … … 466 466 else 467 467 { 468 /* Normalize view early to the optimal size: */ 469 if (machineView()) 470 machineView()->normalizeGeometry(true); 468 /* Normalize to the optimal size: */ 469 normalizeGeometry(true); 471 470 /* Move newly created window to the screen center: */ 472 471 m_normalGeometry = geometry(); … … 475 474 } 476 475 477 /* Normalize view to the optimal size: */ 478 if (machineView()) 476 /* Normalize to the optimal size: */ 479 477 #ifdef Q_WS_X11 480 QTimer::singleShot(0, machineView(), SLOT(sltNormalizeGeometry()));481 #else /* Q_WS_X11 */482 machineView()->normalizeGeometry(true);483 #endif 478 QTimer::singleShot(0, this, SLOT(sltNormalizeGeometry())); 479 #else /* !Q_WS_X11 */ 480 normalizeGeometry(true); 481 #endif /* !Q_WS_X11 */ 484 482 } 485 483 … … 611 609 } 612 610 611 /** 612 * Adjusts machine-window size to correspond current guest screen size. 613 * @param fAdjustPosition determines whether is it necessary to adjust position too. 614 */ 615 void UIMachineWindowNormal::normalizeGeometry(bool fAdjustPosition) 616 { 617 #ifndef VBOX_GUI_WITH_CUSTOMIZATIONS1 618 /* Skip if maximized: */ 619 if (isMaximized()) 620 return; 621 622 /* Calculate client window offsets: */ 623 QRect frameGeo = frameGeometry(); 624 QRect geo = geometry(); 625 int dl = geo.left() - frameGeo.left(); 626 int dt = geo.top() - frameGeo.top(); 627 int dr = frameGeo.right() - geo.right(); 628 int db = frameGeo.bottom() - geo.bottom(); 629 630 /* Get the best size w/o scroll-bars: */ 631 QSize s = sizeHint(); 632 633 /* Resize the frame to fit the contents: */ 634 s -= size(); 635 frameGeo.setRight(frameGeo.right() + s.width()); 636 frameGeo.setBottom(frameGeo.bottom() + s.height()); 637 638 /* Adjust position if necessary: */ 639 if (fAdjustPosition) 640 { 641 QRegion availableGeo; 642 QDesktopWidget *dwt = QApplication::desktop(); 643 if (dwt->isVirtualDesktop()) 644 /* Compose complex available region: */ 645 for (int i = 0; i < dwt->numScreens(); ++i) 646 availableGeo += dwt->availableGeometry(i); 647 else 648 /* Get just a simple available rectangle */ 649 availableGeo = dwt->availableGeometry(pos()); 650 651 frameGeo = VBoxGlobal::normalizeGeometry(frameGeo, availableGeo); 652 } 653 654 /* Finally, set the frame geometry: */ 655 setGeometry(frameGeo.left() + dl, frameGeo.top() + dt, 656 frameGeo.width() - dl - dr, frameGeo.height() - dt - db); 657 658 #else /* !VBOX_GUI_WITH_CUSTOMIZATIONS1 */ 659 Q_UNUSED(fAdjustPosition); 660 #endif /* VBOX_GUI_WITH_CUSTOMIZATIONS1 */ 661 } 662 613 663 void UIMachineWindowNormal::updateAppearanceOf(int iElement) 614 664 { -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.h
r46686 r49177 43 43 private slots: 44 44 45 #ifdef Q_WS_X11 46 /** X11: Performs machine-window async geometry normalization. */ 47 void sltNormalizeGeometry() { normalizeGeometry(true); } 48 #endif /* Q_WS_X11 */ 49 45 50 /* Session event-handlers: */ 46 51 void sltMachineStateChanged(); … … 82 87 void showInNecessaryMode(); 83 88 89 /* Helper: Machine-window geometry stuff: */ 90 void normalizeGeometry(bool fAdjustPosition); 91 84 92 /* Update stuff: */ 85 93 void updateAppearanceOf(int aElement); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.h
r49176 r49177 65 65 /* Private helpers: */ 66 66 QSize sizeHint() const; 67 void normalizeGeometry(bool /* fAdjustPosition */) {}68 67 QRect workingArea() const; 69 68 QSize calculateMaxGuestSize() const; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.cpp
r49009 r49177 72 72 void UIMachineViewSeamless::sltAdditionsStateChanged() 73 73 { 74 normalizeGeometry(false);74 maybeAdjustGuestScreenSize(); 75 75 } 76 76 … … 154 154 } 155 155 156 void UIMachineViewSeamless::normalizeGeometry(bool /* fAdjustPosition */) 156 /** Adjusts guest screen size to correspond current <i>working area</i> size. */ 157 void UIMachineViewSeamless::maybeAdjustGuestScreenSize() 157 158 { 158 159 /* Check if we should adjust guest to new size: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.h
r49009 r49177 64 64 //void cleanupCommon() {} 65 65 66 /* Private helpers: */67 void normalizeGeometry(bool fAdjustPosition);66 /* Helpers: Geometry stuff: */ 67 void maybeAdjustGuestScreenSize(); 68 68 QRect workingArea() const; 69 69 QSize calculateMaxGuestSize() const; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineWindowSeamless.cpp
r49013 r49177 197 197 /* Resize to the appropriate size: */ 198 198 resize(workingArea.size()); 199 /* Adjust guest if necessary: */200 machineView()-> normalizeGeometry(false);199 /* Adjust guest screen size if necessary: */ 200 machineView()->maybeAdjustGuestScreenSize(); 201 201 #ifndef Q_WS_MAC 202 202 /* Move mini-toolbar into appropriate place: */
Note:
See TracChangeset
for help on using the changeset viewer.