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