Changeset 8888 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- May 16, 2008 12:15:58 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 30923
- Location:
- trunk/src/VBox/Frontends
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h
r8440 r8888 197 197 private: 198 198 199 void setDesktopGeometry(int minWidth, int minHeight); 199 enum meDesktopGeo { 200 invalid = 0, fixed, automatic, any, unchanged 201 }; 202 void setDesktopGeometry(meDesktopGeo type, int width, int height); 203 void setDesktopGeoHint(int width, int height); 200 204 void maybeRestrictMinimumSize(); 201 205 … … 284 288 CGImageRef mVirtualBoxLogo; 285 289 #endif 290 meDesktopGeo mDesktopGeoType; 286 291 QRect mDesktopGeometry; 292 QRect mLastSizeHint; 287 293 }; 288 294 -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobalSettings.h
r8155 r8888 45 45 QString guiFeatures; 46 46 QString languageId; 47 QString maxGuestRes; 47 48 48 49 friend class VBoxGlobalSettings; … … 58 59 Q_PROPERTY (QString guiFeatures READ guiFeatures WRITE setGuiFeatures) 59 60 Q_PROPERTY (QString languageId READ languageId WRITE setLanguageId) 61 Q_PROPERTY (QString maxGuestRes READ maxGuestRes WRITE setMaxGuestRes) 60 62 61 63 public: … … 92 94 { 93 95 mData()->languageId = aLanguageId; 96 } 97 98 QString maxGuestRes() const { return data()->maxGuestRes; } 99 void setMaxGuestRes (const QString &aMaxGuestRes) 100 { 101 mData()->maxGuestRes = aMaxGuestRes; 94 102 } 95 103 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r8779 r8888 646 646 , mVirtualBoxLogo (NULL) 647 647 #endif 648 , mDesktopGeoType(invalid) 648 649 { 649 650 Assert (!mConsole.isNull() && … … 769 770 events for telling the guest about video modes we like. */ 770 771 771 doResizeDesktop(0); 772 QString desktopGeometry = vboxGlobal().settings() 773 .publicProperty("GUI/MaxGuestResolution"); 774 if ( (QString::null == desktopGeometry) 775 || ("auto" == desktopGeometry) 776 ) 777 setDesktopGeometry(automatic, 0, 0); 778 else if ("any" == desktopGeometry) 779 setDesktopGeometry(any, 0, 0); 780 else 781 { 782 int width = desktopGeometry.section(',', 0, 0).toInt(); 783 int height = desktopGeometry.section(',', 1, 1).toInt(); 784 setDesktopGeometry(fixed, width, height); 785 } 772 786 connect (QApplication::desktop(), SIGNAL(workAreaResized(int)), 773 787 this, SLOT(doResizeDesktop(int))); … … 2267 2281 2268 2282 /** 2269 * Get the current desktop geometry for the console view widget2283 * Get the current available desktop geometry for the console/framebuffer 2270 2284 * 2271 * @returns the geometry 2285 * @returns the geometry. An empty rectangle means unrestricted. 2272 2286 */ 2273 2287 QRect VBoxConsoleView::getDesktopGeometry() 2274 2288 { 2275 return mDesktopGeometry; 2289 QRect rc; 2290 switch (mDesktopGeoType) 2291 { 2292 case fixed: 2293 case automatic: 2294 rc = QRect (0, 0, RT_MAX(mDesktopGeometry.width(), mLastSizeHint.width()), 2295 RT_MAX(mDesktopGeometry.height(), mLastSizeHint.height())); 2296 break; 2297 case any: 2298 rc = QRect (0, 0, 0, 0); 2299 break; 2300 default: 2301 AssertMsgFailed (("Bad geometry type %d\n", mDesktopGeoType)); 2302 } 2303 return rc; 2276 2304 } 2277 2305 … … 3531 3559 3532 3560 /* Increase the desktop geometry if needed */ 3533 setDesktopGeo metry(sz.width(), sz.height());3561 setDesktopGeoHint(sz.width(), sz.height()); 3534 3562 3535 3563 if (mAutoresizeGuest) … … 3540 3568 void VBoxConsoleView::doResizeDesktop (int) 3541 3569 { 3542 setDesktopGeometry(0, 0); 3570 /* If the desktop geometry is set automatically, this will update it. */ 3571 setDesktopGeometry(unchanged, 0, 0); 3543 3572 } 3544 3573 3545 3574 /** 3546 * Set the maximum size allowed for the guest desktop to the available area 3547 * minus 100 pixels each way, or to the specified minimum width and height, 3548 * whichever is greater. 3575 * Set the maximum size allowed for the guest desktop. This can either be 3576 * a fixed maximum size, or a lower bound on the maximum. In the second case, 3577 * the maximum will be set to the available desktop area minus 100 pixels each 3578 * way, or to the specified lower bound, whichever is greater. 3549 3579 * 3550 * @param minWidth The width that the guest screen should at least be 3551 * allowed to increase to 3552 * @param minHeight The height that the guest screen should at least be 3553 * allowed to increase to 3580 * @param fixed Are the parameters a fixed geometry size or a lower bound? 3581 * @param width The maximum width for the guest screen (fixed geometry) 3582 * or a lower bound for the maximum 3583 * @param height The maximum height for the guest screen (fixed geometry) 3584 * or a lower bound for the maximum 3554 3585 */ 3555 void VBoxConsoleView::setDesktopGeometry(int minWidth, int minHeight) 3556 { 3557 LogFlowThisFunc(("minWidth=%d, minHeight=%d\n", minWidth, minHeight)); 3558 QRect desktopGeometry = QApplication::desktop()->screenGeometry (this); 3559 int width = desktopGeometry.width(); 3560 if (width - 100 < minWidth) 3561 width = minWidth; 3562 else 3563 width = width - 100; 3564 int height = desktopGeometry.height(); 3565 if (height - 100 < minHeight) 3566 height = minHeight; 3567 else 3568 height = height - 100; 3569 LogFlowThisFunc(("Setting %d, %d\n", width, height)); 3570 mDesktopGeometry = QRect(0, 0, width, height); 3571 } 3572 3586 void VBoxConsoleView::setDesktopGeoHint(int width, int height) 3587 { 3588 LogFlowThisFunc(("width=%d, height=%d\n", width, height)); 3589 mLastSizeHint = QRect (0, 0, width, height); 3590 } 3591 3592 /** 3593 * Set initial desktop geometry restrictions on the guest framebuffer. These 3594 * determine the maximum size the guest framebuffer can take on. Note that 3595 * a hint from the host will always override these restrictions. 3596 * 3597 * @param type Values: fixed - the guest has a fixed maximum framebuffer size 3598 * automatic - we recalculate the maximum size ourselves 3599 * any - any size is allowed 3600 * @param width The maximum width for the guest screen or zero for no change 3601 * (only used for fixed geometry) 3602 * @param height The maximum height for the guest screen or zero for no change 3603 * (only used for fixed geometry) 3604 */ 3605 void VBoxConsoleView::setDesktopGeometry(meDesktopGeo type, int width, int height) 3606 { 3607 LogFlowThisFunc (("type = %s, width=%d, height=%d\n", 3608 (fixed == type ? "fixed" 3609 : (automatic == type ? "automatic" 3610 : (any == type ? "any" 3611 : (unchanged == type ? "unchanged" : "invalid") 3612 ) 3613 ) 3614 ), width, height 3615 )); 3616 Assert((type != unchanged) || (mDesktopGeoType != invalid)); 3617 if (unchanged == type) 3618 type = mDesktopGeoType; 3619 switch (type) 3620 { 3621 case fixed: 3622 mDesktopGeoType = fixed; 3623 if ((0 != width ) && (0 != height)) 3624 mDesktopGeometry = QRect (0, 0, width, height); 3625 setDesktopGeoHint (0, 0); 3626 break; 3627 case automatic: 3628 { 3629 mDesktopGeoType = automatic; 3630 QRect desktop = QApplication::desktop()->screenGeometry (this); 3631 mDesktopGeometry = QRect(0, 0, desktop.width() - 100, desktop.height() - 100); 3632 LogFlowThisFunc(("Setting %d, %d\n", desktop.width() - 100, desktop.height() - 100)); 3633 setDesktopGeoHint (0, 0); 3634 break; 3635 } 3636 case any: 3637 mDesktopGeoType = any; 3638 mDesktopGeometry = QRect (0, 0, 0, 0); 3639 break; 3640 default: 3641 AssertMsgFailed(("Invalid desktop geometry type %d\n", type)); 3642 mDesktopGeoType = invalid; 3643 } 3644 } 3573 3645 3574 3646 /** -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFrameBuffer.cpp
r8155 r8888 206 206 *aSupported = TRUE; 207 207 QRect screen = mView->getDesktopGeometry(); 208 if (aWidth > (ULONG) screen.width()) 208 if ( (screen.width() != 0) 209 && (aWidth > (ULONG) screen.width()) 210 ) 209 211 *aSupported = FALSE; 210 if (aHeight > (ULONG) screen.height()) 212 if ( (screen.height() != 0) 213 && (aHeight > (ULONG) screen.height()) 214 ) 211 215 *aSupported = FALSE; 212 216 LogFlowThisFunc(("returning aSupported=%d\n", *aSupported)); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobalSettings.cpp
r8155 r8888 60 60 guiFeatures = QString::null; 61 61 languageId = QString::null; 62 maxGuestRes = "auto"; 62 63 } 63 64 … … 68 69 guiFeatures = that.guiFeatures; 69 70 languageId = that.languageId; 71 maxGuestRes = that.maxGuestRes; 70 72 } 71 73 … … 80 82 autoCapture == that.autoCapture && 81 83 guiFeatures == that.guiFeatures && 82 languageId == that.languageId); 84 languageId == that.languageId && 85 maxGuestRes == that.maxGuestRes); 83 86 } 84 87 … … 105 108 { "GUI/Customizations", "guiFeatures", "\\S+", true }, 106 109 { "GUI/LanguageID", "languageId", gVBoxLangIDRegExp, true }, 110 { "GUI/MaxGuestResolution", "maxGuestRes", "\\d*[1-9]\\d*,\\d*[1-9]\\d*|any|auto", true } 107 111 }; 108 112 -
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxConsoleView.h
r8440 r8888 215 215 private: 216 216 217 void setDesktopGeometry(int minWidth, int minHeight); 217 enum meDesktopGeo { 218 invalid = 0, fixed, automatic, any, unchanged 219 }; 220 void setDesktopGeometry(meDesktopGeo type, int width, int height); 221 void setDesktopGeoHint(int width, int height); 218 222 void maybeRestrictMinimumSize(); 219 223 … … 301 305 CGImageRef mVirtualBoxLogo; 302 306 #endif 307 meDesktopGeo mDesktopGeoType; 303 308 QRect mDesktopGeometry; 309 QRect mLastSizeHint; 304 310 }; 305 311 -
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxGlobalSettings.h
r8155 r8888 46 46 QString guiFeatures; 47 47 QString languageId; 48 QString maxGuestRes; 48 49 49 50 friend class VBoxGlobalSettings; … … 59 60 Q_PROPERTY (QString guiFeatures READ guiFeatures WRITE setGuiFeatures) 60 61 Q_PROPERTY (QString languageId READ languageId WRITE setLanguageId) 62 Q_PROPERTY (QString maxGuestRes READ maxGuestRes WRITE setMaxGuestRes) 61 63 62 64 public: … … 93 95 { 94 96 mData()->languageId = aLanguageId; 97 } 98 99 QString maxGuestRes() const { return data()->maxGuestRes; } 100 void setMaxGuestRes (const QString &aMaxGuestRes) 101 { 102 mData()->maxGuestRes = aMaxGuestRes; 95 103 } 96 104 -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxConsoleView.cpp
r8866 r8888 667 667 , mVirtualBoxLogo (NULL) 668 668 #endif 669 , mDesktopGeoType(invalid) 669 670 { 670 671 Assert (!mConsole.isNull() && … … 798 799 events for telling the guest about video modes we like. */ 799 800 800 doResizeDesktop(0); 801 QString desktopGeometry = vboxGlobal().settings() 802 .publicProperty("GUI/MaxGuestResolution"); 803 if ( (QString::null == desktopGeometry) 804 || ("auto" == desktopGeometry) 805 ) 806 setDesktopGeometry(automatic, 0, 0); 807 else if ("any" == desktopGeometry) 808 setDesktopGeometry(any, 0, 0); 809 else 810 { 811 int width = desktopGeometry.section(',', 0, 0).toInt(); 812 int height = desktopGeometry.section(',', 1, 1).toInt(); 813 setDesktopGeometry(fixed, width, height); 814 } 801 815 connect (QApplication::desktop(), SIGNAL(workAreaResized(int)), 802 816 this, SLOT(doResizeDesktop(int))); … … 2289 2303 2290 2304 /** 2291 * Get the current desktop geometry for the console view widget2305 * Get the current available desktop geometry for the console/framebuffer 2292 2306 * 2293 * @returns the geometry 2307 * @returns the geometry. An empty rectangle means unrestricted. 2294 2308 */ 2295 2309 QRect VBoxConsoleView::getDesktopGeometry() 2296 2310 { 2297 return mDesktopGeometry; 2311 QRect rc; 2312 switch (mDesktopGeoType) 2313 { 2314 case fixed: 2315 case automatic: 2316 rc = QRect (0, 0, RT_MAX(mDesktopGeometry.width(), mLastSizeHint.width()), 2317 RT_MAX(mDesktopGeometry.height(), mLastSizeHint.height())); 2318 break; 2319 case any: 2320 rc = QRect (0, 0, 0, 0); 2321 break; 2322 default: 2323 AssertMsgFailed (("Bad geometry type %d\n", mDesktopGeoType)); 2324 } 2325 return rc; 2298 2326 } 2299 2327 … … 3545 3573 3546 3574 /* Increase the desktop geometry if needed */ 3547 setDesktopGeo metry(sz.width(), sz.height());3575 setDesktopGeoHint(sz.width(), sz.height()); 3548 3576 3549 3577 if (mAutoresizeGuest) … … 3554 3582 void VBoxConsoleView::doResizeDesktop (int) 3555 3583 { 3556 setDesktopGeometry(0, 0); 3584 /* If the desktop geometry is set automatically, this will update it. */ 3585 setDesktopGeometry(unchanged, 0, 0); 3557 3586 } 3558 3587 3559 3588 /** 3560 * Set the maximum size allowed for the guest desktop to the available area 3561 * minus 100 pixels each way, or to the specified minimum width and height, 3562 * whichever is greater. 3589 * Set the maximum size allowed for the guest desktop. This can either be 3590 * a fixed maximum size, or a lower bound on the maximum. In the second case, 3591 * the maximum will be set to the available desktop area minus 100 pixels each 3592 * way, or to the specified lower bound, whichever is greater. 3563 3593 * 3564 * @param minWidth The width that the guest screen should at least be 3565 * allowed to increase to 3566 * @param minHeight The height that the guest screen should at least be 3567 * allowed to increase to 3594 * @param fixed Are the parameters a fixed geometry size or a lower bound? 3595 * @param width The maximum width for the guest screen (fixed geometry) 3596 * or a lower bound for the maximum 3597 * @param height The maximum height for the guest screen (fixed geometry) 3598 * or a lower bound for the maximum 3568 3599 */ 3569 void VBoxConsoleView::setDesktopGeometry(int minWidth, int minHeight) 3570 { 3571 LogFlowThisFunc(("minWidth=%d, minHeight=%d\n", minWidth, minHeight)); 3572 QRect desktopGeometry = QApplication::desktop()->screenGeometry (this); 3573 int width = desktopGeometry.width(); 3574 if (width - 100 < minWidth) 3575 width = minWidth; 3576 else 3577 width = width - 100; 3578 int height = desktopGeometry.height(); 3579 if (height - 100 < minHeight) 3580 height = minHeight; 3581 else 3582 height = height - 100; 3583 LogFlowThisFunc(("Setting %d, %d\n", width, height)); 3584 mDesktopGeometry = QRect(0, 0, width, height); 3585 } 3586 3600 void VBoxConsoleView::setDesktopGeoHint(int width, int height) 3601 { 3602 LogFlowThisFunc(("width=%d, height=%d\n", width, height)); 3603 mLastSizeHint = QRect (0, 0, width, height); 3604 } 3605 3606 /** 3607 * Set initial desktop geometry restrictions on the guest framebuffer. These 3608 * determine the maximum size the guest framebuffer can take on. Note that 3609 * a hint from the host will always override these restrictions. 3610 * 3611 * @param type Values: fixed - the guest has a fixed maximum framebuffer size 3612 * automatic - we recalculate the maximum size ourselves 3613 * any - any size is allowed 3614 * @param width The maximum width for the guest screen or zero for no change 3615 * (only used for fixed geometry) 3616 * @param height The maximum height for the guest screen or zero for no change 3617 * (only used for fixed geometry) 3618 */ 3619 void VBoxConsoleView::setDesktopGeometry(meDesktopGeo type, int width, int height) 3620 { 3621 LogFlowThisFunc (("type = %s, width=%d, height=%d\n", 3622 (fixed == type ? "fixed" 3623 : (automatic == type ? "automatic" 3624 : (any == type ? "any" 3625 : (unchanged == type ? "unchanged" : "invalid") 3626 ) 3627 ) 3628 ), width, height 3629 )); 3630 Assert((type != unchanged) || (mDesktopGeoType != invalid)); 3631 if (unchanged == type) 3632 type = mDesktopGeoType; 3633 switch (type) 3634 { 3635 case fixed: 3636 mDesktopGeoType = fixed; 3637 if ((0 != width ) && (0 != height)) 3638 mDesktopGeometry = QRect (0, 0, width, height); 3639 setDesktopGeoHint (0, 0); 3640 break; 3641 case automatic: 3642 { 3643 mDesktopGeoType = automatic; 3644 QRect desktop = QApplication::desktop()->screenGeometry (this); 3645 mDesktopGeometry = QRect(0, 0, desktop.width() - 100, desktop.height() - 100); 3646 LogFlowThisFunc(("Setting %d, %d\n", desktop.width() - 100, desktop.height() - 100)); 3647 setDesktopGeoHint (0, 0); 3648 break; 3649 } 3650 case any: 3651 mDesktopGeoType = any; 3652 mDesktopGeometry = QRect (0, 0, 0, 0); 3653 break; 3654 default: 3655 AssertMsgFailed(("Invalid desktop geometry type %d\n", type)); 3656 mDesktopGeoType = invalid; 3657 } 3658 } 3587 3659 3588 3660 /** -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxFrameBuffer.cpp
r8155 r8888 207 207 *aSupported = TRUE; 208 208 QRect screen = mView->getDesktopGeometry(); 209 if (aWidth > (ULONG) screen.width()) 209 if ( (screen.width() != 0) 210 && (aWidth > (ULONG) screen.width()) 211 ) 210 212 *aSupported = FALSE; 211 if (aHeight > (ULONG) screen.height()) 213 if ( (screen.height() != 0) 214 && (aHeight > (ULONG) screen.height()) 215 ) 212 216 *aSupported = FALSE; 213 217 LogFlowThisFunc(("returning aSupported=%d\n", *aSupported)); -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxGlobalSettings.cpp
r8155 r8888 59 59 guiFeatures = QString::null; 60 60 languageId = QString::null; 61 maxGuestRes = "auto"; 61 62 } 62 63 … … 67 68 guiFeatures = that.guiFeatures; 68 69 languageId = that.languageId; 70 maxGuestRes = that.maxGuestRes; 69 71 } 70 72 … … 79 81 autoCapture == that.autoCapture && 80 82 guiFeatures == that.guiFeatures && 81 languageId == that.languageId); 83 languageId == that.languageId && 84 maxGuestRes == that.maxGuestRes); 82 85 } 83 86 … … 104 107 { "GUI/Customizations", "guiFeatures", "\\S+", true }, 105 108 { "GUI/LanguageID", "languageId", gVBoxLangIDRegExp, true }, 109 { "GUI/MaxGuestResolution", "maxGuestRes", "\\d*[1-9]\\d*,\\d*[1-9]\\d*|any|auto", true } 106 110 }; 107 111
Note:
See TracChangeset
for help on using the changeset viewer.