Changeset 10395 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jul 9, 2008 8:57:15 AM (17 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h
r9067 r10395 202 202 { 203 203 DesktopGeo_Invalid = 0, DesktopGeo_Fixed, 204 DesktopGeo_Automatic, DesktopGeo_Any , DesktopGeo_Unchanged204 DesktopGeo_Automatic, DesktopGeo_Any 205 205 }; 206 206 207 207 void setDesktopGeometry (DesktopGeo aGeo, int aWidth, int aHeight); 208 208 void setDesktopGeoHint (int aWidth, int aHeight); 209 void calculateDesktopGeometry(); 209 210 void maybeRestrictMinimumSize(); 210 211 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r9076 r10395 3570 3570 LogFlowFunc (("Will suggest %d x %d\n", sz.width(), sz.height())); 3571 3571 3572 /* Increase the maximum allowed size to the new size if needed */ 3572 /* Increase the maximum allowed size to the new size if needed. 3573 * We also recalculate the desktop geometry if this is determined 3574 * automatically. In fact, we only need this on the first resize, 3575 * but it is done every time to keep the code simpler. */ 3573 3576 setDesktopGeoHint (sz.width(), sz.height()); 3577 calculateDesktopGeometry(); 3574 3578 3575 3579 mConsole.GetDisplay().SetVideoModeHint (sz.width(), sz.height(), 0, 0); … … 3578 3582 } 3579 3583 3584 3585 /* If the desktop geometry is set automatically, this will update it. */ 3580 3586 void VBoxConsoleView::doResizeDesktop (int) 3581 3587 { 3582 /* If the desktop geometry is set automatically, this will update it. */ 3583 setDesktopGeometry (DesktopGeo_Unchanged, 0, 0); 3588 calculateDesktopGeometry(); 3584 3589 } 3585 3590 3586 3591 /** 3587 * Set the maximum size allowed for the guest desktop. This can either be 3588 * a fixed maximum size, or a lower bound on the maximum. In the second case, 3589 * the maximum will be set to the available desktop area minus 100 pixels each 3590 * way, or to the specified lower bound, whichever is greater. 3592 * Remember a geometry hint sent by the console window. This is used to 3593 * determine the maximum supported guest resolution in the @a desktopGeometry 3594 * method. A hint will always override other restrictions. 3591 3595 * 3592 * @param aWidth The maximum width for the guest screen (fixed geometry) or a 3593 * lower bound for the maximum 3594 * @param aHeight The maximum height for the guest screen (fixed geometry) 3595 * or a lower bound for the maximum 3596 * @param aWidth width of the resolution hint 3597 * @param aHeight height of the resolution hint 3596 3598 */ 3597 3599 void VBoxConsoleView::setDesktopGeoHint (int aWidth, int aHeight) … … 3601 3603 } 3602 3604 3605 3603 3606 /** 3604 * Set initial desktop geometry restrictions on the guest framebuffer. These 3605 * determine the maximum size the guest framebuffer can take on. Note that 3606 * a hint from the host will always override these restrictions. 3607 * Do initial setup of desktop geometry restrictions on the guest framebuffer. 3608 * These determine the maximum size the guest framebuffer can take on. 3607 3609 * 3608 * @param aGeo Values: fixed - the guest has a fixed maximum framebuffer 3609 * size automatic - we recalculate the maximum size 3610 * ourselves any - any size is allowed 3610 * @note a hint from the host will always override these restrictions. 3611 * 3612 * @param aGeo Fixed - the guest has a fixed maximum framebuffer size 3613 * Automatic - we calculate the maximum size ourselves. The 3614 * calculations will not actually be done until 3615 * @a calculateDesktopGeometry is called, since 3616 * we don't initially have the information needed. 3617 * Any - any size is allowed 3611 3618 * @param aWidth The maximum width for the guest screen or zero for no change 3612 3619 * (only used for fixed geometry) … … 3619 3626 (aGeo == DesktopGeo_Fixed ? "Fixed" : 3620 3627 aGeo == DesktopGeo_Automatic ? "Automatic" : 3621 aGeo == DesktopGeo_Any ? "Any" : 3622 aGeo == DesktopGeo_Unchanged ? "Unchanged" : "Invalid"), 3628 aGeo == DesktopGeo_Any ? "Any" : "Invalid"), 3623 3629 aWidth, aHeight)); 3624 Assert ((aGeo != DesktopGeo_Unchanged) || (mDesktopGeo != DesktopGeo_Invalid));3625 if (DesktopGeo_Unchanged == aGeo)3626 aGeo = mDesktopGeo;3627 3630 switch (aGeo) 3628 3631 { … … 3631 3634 if (aWidth != 0 && aHeight != 0) 3632 3635 mDesktopGeometry = QRect (0, 0, aWidth, aHeight); 3636 else 3637 mDesktopGeometry = QRect (0, 0, 0, 0); 3633 3638 setDesktopGeoHint (0, 0); 3634 3639 break; 3635 3640 case DesktopGeo_Automatic: 3636 {3637 3641 mDesktopGeo = DesktopGeo_Automatic; 3638 QRect desktop = QApplication::desktop()->screenGeometry (this); 3639 mDesktopGeometry = QRect (0, 0, desktop.width() - 100, desktop.height() - 100); 3640 LogFlowThisFunc (("Setting %d, %d\n", desktop.width() - 100, desktop.height() - 100)); 3642 mDesktopGeometry = QRect (0, 0, 0, 0); 3641 3643 setDesktopGeoHint (0, 0); 3642 3644 break; 3643 }3644 3645 case DesktopGeo_Any: 3645 3646 mDesktopGeo = DesktopGeo_Any; … … 3649 3650 AssertMsgFailed(("Invalid desktop geometry type %d\n", aGeo)); 3650 3651 mDesktopGeo = DesktopGeo_Invalid; 3652 } 3653 } 3654 3655 3656 /** 3657 * If we are in automatic mode, the geometry restrictions will be recalculated. 3658 * This is needed in particular on the first widget resize, as we can't 3659 * calculate them correctly before that. 3660 * 3661 * @note a hint from the host will always override these restrictions. 3662 * @note we can't do calculations on the fly when they are needed, because 3663 * they require querying the X server on X11 hosts and this must be done 3664 * from within the GUI thread, due to the single threadedness of Xlib. 3665 */ 3666 void VBoxConsoleView::calculateDesktopGeometry() 3667 { 3668 LogFlowThisFunc (("Entering\n")); 3669 /* This method should not get called until we have initially set up the */ 3670 Assert ((mDesktopGeo != DesktopGeo_Invalid)); 3671 /* If we are not doing automatic geometry calculation then there is 3672 * nothing to do. */ 3673 if (DesktopGeo_Automatic == mDesktopGeo) 3674 { 3675 /* Available geometry of the desktop. If the desktop is a single 3676 * screen, this will exclude space taken up by desktop taskbars 3677 * and things, but this is unfortunately not true for the more 3678 * complex case of a desktop spanning multiple screens. */ 3679 QRect desktop = QApplication::desktop()->availableGeometry (this); 3680 /* The area taken up by the console window on the desktop, 3681 * including window frame, title and menu bar and whatnot. */ 3682 QRect frame = mMainWnd->frameGeometry(); 3683 /* The area taken up by the console window, minus all 3684 * decorations. */ 3685 QRect window = mMainWnd->centralWidget()->geometry(); 3686 /* To work out how big we can make the console window while still 3687 * fitting on the desktop, we calculate desktop - frame + window. 3688 * This works because the difference between frame and window 3689 * (or at least its width and height) is a constant. */ 3690 mDesktopGeometry = 3691 QRect (0, 0, desktop.width() - frame.width() + window.width(), 3692 desktop.height() - frame.height() + window.height()); 3693 LogFlowThisFunc (("Setting %d, %d\n", mDesktopGeometry.width(), 3694 mDesktopGeometry.height())); 3651 3695 } 3652 3696 }
Note:
See TracChangeset
for help on using the changeset viewer.