Changeset 39021 in vbox for trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
- Timestamp:
- Oct 18, 2011 3:10:13 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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: */
Note:
See TracChangeset
for help on using the changeset viewer.