Changeset 39021 in vbox
- Timestamp:
- Oct 18, 2011 3:10:13 PM (13 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp
r38311 r39021 184 184 return E_POINTER; 185 185 *pbSupported = TRUE; 186 QSize screen = m_pMachineView-> desktopGeometry();186 QSize screen = m_pMachineView->maxGuestSize(); 187 187 if ((screen.width() != 0) && (uWidth > (ULONG)screen.width())) 188 188 *pbSupported = FALSE; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r38992 r39021 160 160 AssertMsg(newSize.isValid(), ("Size should be valid!\n")); 161 161 162 /* Store the new size*/163 store ConsoleSize(newSize.width(), newSize.height());162 /* Store the new hint */ 163 storeHintForGuestSizePolicy(newSize.width(), newSize.height()); 164 164 /* Send new size-hint to the guest: */ 165 165 session().GetConsole().GetDisplay().SetVideoModeHint(newSize.width(), newSize.height(), 0, screenId()); … … 238 238 , m_pFrameBuffer(0) 239 239 , m_previousState(KMachineState_Null) 240 , m_ desktopGeometryType(DesktopGeo_Invalid)240 , m_maxGuestSizePolicy(MaxGuestSizePolicy_Invalid) 241 241 #ifdef VBOX_WITH_VIDEOHWACCEL 242 242 , m_fAccelerate2DVideo(bAccelerate2DVideo) … … 480 480 /* Global settings: */ 481 481 { 482 /* Remember the desktop geometry and register for geometry483 * change events for telling the guest aboutvideo modes we like: */484 QString desktopGeometry= vboxGlobal().settings().publicProperty("GUI/MaxGuestResolution");485 if (( desktopGeometry == QString::null) || (desktopGeometry== "auto"))486 set DesktopGeometry(DesktopGeo_Automatic, 0, 0);487 else if ( desktopGeometry== "any")488 set DesktopGeometry(DesktopGeo_Any, 0, 0);489 else 490 { 491 int width = desktopGeometry.section(',', 0, 0).toInt();492 int height = desktopGeometry.section(',', 1, 1).toInt();493 set DesktopGeometry(DesktopGeo_Fixed, width, height);482 /* Remember the maximum guest size policy for telling the guest about 483 * video modes we like: */ 484 QString maxGuestSize = vboxGlobal().settings().publicProperty("GUI/MaxGuestResolution"); 485 if ((maxGuestSize == QString::null) || (maxGuestSize == "auto")) 486 setMaxGuestSizePolicy(MaxGuestSizePolicy_Automatic, 0, 0); 487 else if (maxGuestSize == "any") 488 setMaxGuestSizePolicy(MaxGuestSizePolicy_Any, 0, 0); 489 else /** @todo Mea culpa, but what about error checking? */ 490 { 491 int width = maxGuestSize.section(',', 0, 0).toInt(); 492 int height = maxGuestSize.section(',', 1, 1).toInt(); 493 setMaxGuestSizePolicy(MaxGuestSizePolicy_Fixed, width, height); 494 494 } 495 495 } … … 596 596 } 597 597 598 QSize UIMachineView:: desktopGeometry() const599 { 600 QSize geometry;601 switch (m_ desktopGeometryType)602 { 603 case DesktopGeo_Fixed:604 case DesktopGeo_Automatic:605 geometry = QSize(qMax(m_desktopGeometry.width(), m_storedConsoleSize.width()),606 qMax(m_ desktopGeometry.height(), m_storedConsoleSize.height()));607 break; 608 case DesktopGeo_Any:609 geometry= QSize(0, 0);598 QSize UIMachineView::maxGuestSize() const 599 { 600 QSize maxSize; 601 switch (m_maxGuestSizePolicy) 602 { 603 case MaxGuestSizePolicy_Fixed: 604 case MaxGuestSizePolicy_Automatic: 605 maxSize = QSize(qMax(m_fixedMaxGuestSize.width(), m_storedGuestHintSize.width()), 606 qMax(m_fixedMaxGuestSize.height(), m_storedGuestHintSize.height())); 607 break; 608 case MaxGuestSizePolicy_Any: 609 maxSize = QSize(0, 0); 610 610 break; 611 611 default: 612 AssertMsgFailed(("Bad geometry type %d!\n", m_desktopGeometryType)); 613 } 614 return geometry; 612 AssertMsgFailed(("Invalid maximum guest size policy %d!\n", 613 m_maxGuestSizePolicy)); 614 } 615 return maxSize; 615 616 } 616 617 … … 650 651 } 651 652 652 void UIMachineView::setDesktopGeometry(DesktopGeo geometry, int aWidth, int aHeight) 653 { 654 switch (geometry) 655 { 656 case DesktopGeo_Fixed: 657 m_desktopGeometryType = DesktopGeo_Fixed; 658 if (aWidth != 0 && aHeight != 0) 659 m_desktopGeometry = QSize(aWidth, aHeight); 653 void UIMachineView::setMaxGuestSizePolicy(MaxGuestSizePolicy policy, int cwMax, 654 int chMax) 655 { 656 switch (policy) 657 { 658 case MaxGuestSizePolicy_Fixed: 659 m_maxGuestSizePolicy = MaxGuestSizePolicy_Fixed; 660 if (cwMax != 0 && chMax != 0) 661 m_fixedMaxGuestSize = QSize(cwMax, chMax); 660 662 else 661 m_ desktopGeometry= QSize(0, 0);662 store ConsoleSize(0, 0);663 break; 664 case DesktopGeo_Automatic:665 m_ desktopGeometryType = DesktopGeo_Automatic;666 m_ desktopGeometry= QSize(0, 0);667 store ConsoleSize(0, 0);668 break; 669 case DesktopGeo_Any:670 m_ desktopGeometryType = DesktopGeo_Any;671 m_ desktopGeometry= QSize(0, 0);663 m_fixedMaxGuestSize = QSize(0, 0); 664 storeHintForGuestSizePolicy(0, 0); 665 break; 666 case MaxGuestSizePolicy_Automatic: 667 m_maxGuestSizePolicy = MaxGuestSizePolicy_Automatic; 668 m_fixedMaxGuestSize = QSize(0, 0); 669 storeHintForGuestSizePolicy(0, 0); 670 break; 671 case MaxGuestSizePolicy_Any: 672 m_maxGuestSizePolicy = MaxGuestSizePolicy_Any; 673 m_fixedMaxGuestSize = QSize(0, 0); 672 674 break; 673 675 default: 674 AssertMsgFailed(("Invalid desktop geometry type %d\n", geometry)); 675 m_desktopGeometryType = DesktopGeo_Invalid; 676 } 677 } 678 679 void UIMachineView::storeConsoleSize(int iWidth, int iHeight) 680 { 681 if (m_desktopGeometryType == DesktopGeo_Automatic) 682 m_storedConsoleSize = QSize(iWidth, iHeight); 676 AssertMsgFailed(("Invalid maximum guest size policy %d\n", 677 policy)); 678 m_maxGuestSizePolicy = MaxGuestSizePolicy_Invalid; 679 } 680 } 681 682 void UIMachineView::storeHintForGuestSizePolicy(int cWidth, int cHeight) 683 { 684 if (m_maxGuestSizePolicy == MaxGuestSizePolicy_Automatic) 685 m_storedGuestHintSize = QSize(cWidth, cHeight); 683 686 } 684 687 … … 889 892 session().GetConsole().GetDisplay().ResizeCompleted(screenId()); 890 893 891 /* We also recalculate the desktop geometry if this is determined892 * automatically. In fact, we only need this on the first resize,893 * but it is done every time to keepthe code simpler. */894 calculate DesktopGeometry();894 /* We also recalculate the maximum guest size if necessary. In fact we 895 * only need this on the first resize, but it is done every time to keep 896 * the code simpler. */ 897 calculateMaxGuestSize(); 895 898 896 899 /* Emit a signal about guest was resized: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
r38987 r39021 44 44 public: 45 45 46 /* Desktop geometry types: */ 47 enum DesktopGeo { DesktopGeo_Invalid = 0, DesktopGeo_Fixed, DesktopGeo_Automatic, DesktopGeo_Any }; 46 /** Policy for determining which guest resolutions we wish to 47 * handle. We also accept anything smaller than the current 48 * resolution. */ 49 enum MaxGuestSizePolicy 50 { 51 /** Policy not set correctly. */ 52 MaxGuestSizePolicy_Invalid = 0, 53 /** Anything up to a fixed size. */ 54 MaxGuestSizePolicy_Fixed, 55 /** Anything up to available space on the host desktop. */ 56 MaxGuestSizePolicy_Automatic, 57 /** We accept anything. */ 58 MaxGuestSizePolicy_Any 59 }; 48 60 49 61 /* Factory function to create machine-view: */ … … 123 135 UIFrameBuffer* frameBuffer() const { return m_pFrameBuffer; } 124 136 const QPixmap& pauseShot() const { return m_pauseShot; } 125 QSize storedConsoleSize() const { return m_storedConsoleSize; } 126 DesktopGeo desktopGeometryType() const { return m_desktopGeometryType; } 127 QSize desktopGeometry() const; 137 /** Helper to retrieve the last non-fullscreen guest size hint 138 * sent. @note Currently unused. */ 139 QSize storedGuestHintSize() const { return m_storedGuestHintSize; } 140 /** What policy are we currently applying for limiting guest 141 * resolutions? */ 142 MaxGuestSizePolicy maxGuestSizePolicy() const 143 { return m_maxGuestSizePolicy; } 144 /** The maximum guest resolution which we currently wish to handle. 145 * @note This must be safely called from another thread. 146 * @todo So make it atomic. 147 */ 148 QSize maxGuestSize() const; 149 /** Retrieve the last non-fullscreen guest size hint (from extra data). 150 */ 128 151 QSize guestSizeHint(); 129 152 130 153 /* Protected setters: */ 131 void setDesktopGeometry(DesktopGeo geometry, int iWidth, int iHeight); 132 void storeConsoleSize(int iWidth, int iHeight); 154 void setMaxGuestSizePolicy(MaxGuestSizePolicy policy, int cwMax, 155 int chMax); 156 void storeHintForGuestSizePolicy(int cWidth, int cHeight); 133 157 void storeGuestSizeHint(const QSize &sizeHint); 134 158 … … 137 161 virtual void takePauseShotSnapshot(); 138 162 virtual void resetPauseShot() { m_pauseShot = QPixmap(); } 139 virtual QRect workingArea() = 0; 140 virtual void calculateDesktopGeometry() = 0; 163 /** The available area on the current screen for application windows. */ 164 virtual QRect workingArea() const = 0; 165 /** Calculate how big the guest desktop can be while still fitting on one 166 * host screen. */ 167 virtual void calculateMaxGuestSize() = 0; 141 168 virtual void maybeRestrictMinimumSize() = 0; 142 169 virtual void updateSliders(); … … 176 203 KMachineState m_previousState; 177 204 178 DesktopGeo m_desktopGeometryType; 179 QSize m_desktopGeometry; 180 QSize m_storedConsoleSize; 205 /** The policy for calculating the maximum guest resolution we wish to 206 * support. */ 207 MaxGuestSizePolicy m_maxGuestSizePolicy; 208 /** The maximum guest size for fixed size policy. */ 209 QSize m_fixedMaxGuestSize; 210 /** The last guest size hint sent out, used for calculating the maximum 211 * supported guest resolution. */ 212 QSize m_storedGuestHintSize; 181 213 182 214 #ifdef VBOX_WITH_VIDEOHWACCEL -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.cpp
r38992 r39021 95 95 void UIMachineViewFullscreen::sltDesktopResized() 96 96 { 97 /* If the desktop geometry is set automatically, this will update it:*/98 calculate DesktopGeometry();97 /* Recalculate the maximum guest size if necessary. */ 98 calculateMaxGuestSize(); 99 99 } 100 100 … … 197 197 } 198 198 199 QRect UIMachineViewFullscreen::workingArea() 199 QRect UIMachineViewFullscreen::workingArea() const 200 200 { 201 201 /* Get corresponding screen: */ … … 205 205 } 206 206 207 void UIMachineViewFullscreen::calculate DesktopGeometry()207 void UIMachineViewFullscreen::calculateMaxGuestSize() 208 208 { 209 209 /* This method should not get called until we have initially set up the desktop geometry type: */ 210 Assert(( desktopGeometryType() != DesktopGeo_Invalid));211 /* If we are not doing automatic geometry calculation then there is nothing to do:*/212 if ( desktopGeometryType() == DesktopGeo_Automatic)213 m_ desktopGeometry= workingArea().size();210 Assert((maxGuestSizePolicy() != MaxGuestSizePolicy_Invalid)); 211 /* If we are not doing automatic adjustment then there is nothing to do. */ 212 if (maxGuestSizePolicy() == MaxGuestSizePolicy_Automatic) 213 m_fixedMaxGuestSize = workingArea().size(); 214 214 } 215 215 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.h
r38978 r39021 70 70 /* Private helpers: */ 71 71 void normalizeGeometry(bool /* fAdjustPosition */) {} 72 QRect workingArea() ;73 void calculate DesktopGeometry();72 QRect workingArea() const; 73 void calculateMaxGuestSize(); 74 74 void maybeRestrictMinimumSize(); 75 75 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp
r38993 r39021 98 98 void UIMachineViewNormal::sltDesktopResized() 99 99 { 100 /* If the desktop geometry is set automatically, this will update it:*/101 calculate DesktopGeometry();100 /* Recalculate the maximum guest size if necessary. */ 101 calculateMaxGuestSize(); 102 102 } 103 103 … … 297 297 } 298 298 299 QRect UIMachineViewNormal::workingArea() 299 QRect UIMachineViewNormal::workingArea() const 300 300 { 301 301 return QApplication::desktop()->availableGeometry(this); 302 302 } 303 303 304 void UIMachineViewNormal::calculateDesktopGeometry() 305 { 306 /* This method should not get called until we have initially set up the desktop geometry type: */ 307 Assert((desktopGeometryType() != DesktopGeo_Invalid)); 308 /* If we are not doing automatic geometry calculation then there is nothing to do: */ 309 if (desktopGeometryType() == DesktopGeo_Automatic) 304 void UIMachineViewNormal::calculateMaxGuestSize() 305 { 306 /* This method should not get called until we have initially set up the 307 * maximum guest size policy. */ 308 Assert((maxGuestSizePolicy() != MaxGuestSizePolicy_Invalid)); 309 /* If we are not doing automatic adjustment then there is nothing to do. */ 310 if (maxGuestSizePolicy() == MaxGuestSizePolicy_Automatic) 310 311 { 311 312 /* The area taken up by the machine window on the desktop, … … 318 319 * This works because the difference between machine window and machine central widget 319 320 * (or at least its width and height) is a constant. */ 320 m_desktopGeometry = QSize(workingArea().width() - (windowGeo.width() - centralWidgetGeo.width()), 321 workingArea().height() - (windowGeo.height() - centralWidgetGeo.height())); 321 m_fixedMaxGuestSize = QSize( workingArea().width() 322 - (windowGeo.width() 323 - centralWidgetGeo.width()), 324 workingArea().height() 325 - (windowGeo.height() 326 - centralWidgetGeo.height())); 322 327 } 323 328 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.h
r38978 r39021 79 79 /* Private helpers: */ 80 80 void normalizeGeometry(bool fAdjustPosition); 81 QRect workingArea() ;82 void calculate DesktopGeometry();81 QRect workingArea() const; 82 void calculateMaxGuestSize(); 83 83 void maybeRestrictMinimumSize(); 84 84 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.cpp
r38992 r39021 154 154 void UIMachineViewScale::sltDesktopResized() 155 155 { 156 /* If the desktop geometry is set automatically, this will update it:*/157 calculate DesktopGeometry();156 /* Recalculate the maximum guest size if necessary. */ 157 calculateMaxGuestSize(); 158 158 } 159 159 … … 186 186 session().GetConsole().GetDisplay().ResizeCompleted(screenId()); 187 187 188 /* We also recalculate the desktop geometry if this is determined189 * automatically. In fact, we only need this on the first resize,190 * but it is doneevery time to keep the code simpler. */191 calculate DesktopGeometry();188 /* We also recalculate the maximum guest size if necessary. In 189 * fact we only need this on the first resize, but it is done 190 * every time to keep the code simpler. */ 191 calculateMaxGuestSize(); 192 192 193 193 /* Emit a signal about guest was resized: */ … … 363 363 } 364 364 365 QRect UIMachineViewScale::workingArea() 365 QRect UIMachineViewScale::workingArea() const 366 366 { 367 367 return QApplication::desktop()->availableGeometry(this); 368 368 } 369 369 370 void UIMachineViewScale::calculateDesktopGeometry() 371 { 372 /* This method should not get called until we have initially set up the desktop geometry type: */ 373 Assert((desktopGeometryType() != DesktopGeo_Invalid)); 374 /* If we are not doing automatic geometry calculation then there is nothing to do: */ 375 if (desktopGeometryType() == DesktopGeo_Automatic) 370 void UIMachineViewScale::calculateMaxGuestSize() 371 { 372 /* This method should not get called until we have initially set up the 373 * maximum guest size policy. */ 374 Assert((maxGuestSizePolicy() != MaxGuestSizePolicy_Invalid)); 375 /* If we are not doing automatic adjustment then there is nothing to do. */ 376 if (maxGuestSizePolicy() == MaxGuestSizePolicy_Automatic) 376 377 { 377 378 /* The area taken up by the machine window on the desktop, … … 384 385 * This works because the difference between machine window and machine central widget 385 386 * (or at least its width and height) is a constant. */ 386 m_desktopGeometry = QSize(workingArea().width() - (windowGeo.width() - centralWidgetGeo.width()), 387 workingArea().height() - (windowGeo.height() - centralWidgetGeo.height())); 387 m_fixedMaxGuestSize = QSize( workingArea().width() 388 - (windowGeo.width() 389 - centralWidgetGeo.width()), 390 workingArea().height() 391 - (windowGeo.height() 392 - centralWidgetGeo.height())); 388 393 } 389 394 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.h
r38962 r39021 71 71 QSize sizeHint() const; 72 72 void normalizeGeometry(bool /* fAdjustPosition */) {} 73 QRect workingArea() ;74 void calculate DesktopGeometry();73 QRect workingArea() const; 74 void calculateMaxGuestSize(); 75 75 void maybeRestrictMinimumSize() {} 76 76 void updateSliders(); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.cpp
r38992 r39021 96 96 void UIMachineViewSeamless::sltDesktopResized() 97 97 { 98 // TODO: Try to resize framebuffer according new desktop size, exit seamless if resize is failed! 99 100 /* If the desktop geometry is set automatically, this will update it: */ 101 calculateDesktopGeometry(); 98 /** @todo Try to resize framebuffer according new desktop size, 99 * exit seamless if resize is failed! */ 100 /** @todo Check whether this isn't already fixed elsewhere. 101 * I don't think that it is the GUI's job to check that 102 * the resize succeeded though. */ 103 104 /* Recalculate the maximum guest size if necessary. */ 105 calculateMaxGuestSize(); 102 106 } 103 107 … … 215 219 } 216 220 217 QRect UIMachineViewSeamless::workingArea() 221 QRect UIMachineViewSeamless::workingArea() const 218 222 { 219 223 /* Get corresponding screen: */ … … 223 227 } 224 228 225 void UIMachineViewSeamless::calculate DesktopGeometry()229 void UIMachineViewSeamless::calculateMaxGuestSize() 226 230 { 227 231 /* This method should not get called until we have initially set up the desktop geometry type: */ 228 Assert(( desktopGeometryType() != DesktopGeo_Invalid));229 /* If we are not doing automatic geometry calculation then there is nothing to do:*/230 if ( desktopGeometryType() == DesktopGeo_Automatic)231 m_ desktopGeometry= workingArea().size();232 } 233 232 Assert((maxGuestSizePolicy() != MaxGuestSizePolicy_Invalid)); 233 /* If we are not doing automatic adjustment then there is nothing to do. */ 234 if (maxGuestSizePolicy() == MaxGuestSizePolicy_Automatic) 235 m_fixedMaxGuestSize = workingArea().size(); 236 } 237 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.h
r38978 r39021 74 74 /* Private helpers: */ 75 75 void normalizeGeometry(bool /* fAdjustPosition */) {} 76 QRect workingArea() ;77 void calculate DesktopGeometry();76 QRect workingArea() const; 77 void calculateMaxGuestSize(); 78 78 void maybeRestrictMinimumSize() {} 79 79
Note:
See TracChangeset
for help on using the changeset viewer.