Changeset 4514 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Sep 4, 2007 11:56:36 AM (17 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h
r4202 r4514 91 91 void fixModifierState (LONG *codes, uint *count); 92 92 93 void toggleFSMode (const QSize &aFeatSize); 94 95 void setIgnoreMainwndResize (bool aYes) { mIgnoreMainwndResize = aYes; } 96 93 97 signals: 94 98 … … 101 105 void usbStateChange(); 102 106 void sharedFoldersChanged(); 107 void resizeHintDone(); 103 108 104 109 protected: … … 176 181 private slots: 177 182 178 void exitFullScreen(); 179 180 void doResizeHint(); 181 void normalizeGeo() { normalizeGeometry (true); } 183 void doResizeHint (const QSize &aSize = QSize()); 182 184 183 185 private: … … 222 224 223 225 QTimer *resize_hint_timer; 226 QTimer *mToggleFSModeTimer; 224 227 225 228 VBoxDefs::RenderMode mode; -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h
r4297 r4514 69 69 bool isTrueSeamless() const { return mIsSeamless; } 70 70 71 bool isManualResize() const { return mManualResize; } 72 71 73 void setMouseIntegrationLocked (bool aDisabled); 72 74 … … 85 87 // events 86 88 bool event (QEvent *e); 89 void resizeEvent (QResizeEvent *e); 87 90 void closeEvent (QCloseEvent *e); 88 91 #if defined(Q_WS_X11) … … 180 183 void dbgShowCommandLine(); 181 184 185 void onEnterFullscreen(); 186 void onExitFullscreen(); 187 182 188 private: 183 189 … … 286 292 QSize normal_size; 287 293 QSize prev_min_size; 294 QSize mPrevSize; 295 QSize mAwaitingSize; 288 296 289 297 #ifdef Q_WS_WIN32 … … 292 300 293 301 // variables for dealing with true fullscreen 302 bool mDoMaximize : 1; 303 bool mManualResize : 1; 304 bool mAllowOneResize : 1; 294 305 bool mIsFullscreen : 1; 295 306 bool mIsSeamless : 1; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r4297 r4514 650 650 this, SLOT (doResizeHint())); 651 651 652 mToggleFSModeTimer = new QTimer (this); 653 connect (mToggleFSModeTimer, SIGNAL (timeout()), 654 this, SIGNAL (resizeHintDone())); 655 652 656 /* setup rendering */ 653 657 … … 834 838 void VBoxConsoleView::normalizeGeometry (bool adjustPosition /* = false */) 835 839 { 840 /* Make no normalizeGeometry in case we are in manual resize 841 * mode or main window is maximized */ 842 if (mainwnd->isManualResize() || mainwnd->isMaximized()) 843 return; 844 836 845 QWidget *tlw = topLevelWidget(); 837 846 … … 995 1004 re->width(), re->height(), re->bitsPerPixel())); 996 1005 1006 if (mToggleFSModeTimer->isActive()) 1007 mToggleFSModeTimer->stop(); 1008 997 1009 /* do frame buffer dependent resize */ 998 1010 mFrameBuf->resizeEvent (re); … … 1019 1031 QApplication::sendPostedEvents (0, QEvent::LayoutHint); 1020 1032 1021 /* automatically normalize geometry unless maximized or 1022 * full screen */ 1023 if (!mainwnd->isTrueFullscreen() && 1024 !mainwnd->isTrueSeamless() && 1025 !topLevelWidget()->isMaximized()) 1026 normalizeGeometry (true /* adjustPosition */); 1033 normalizeGeometry (true /* adjustPosition */); 1027 1034 1028 1035 /* report to the VM thread that we finished resizing */ … … 1030 1037 1031 1038 mIgnoreMainwndResize = oldIgnoreMainwndResize; 1039 1040 /* emit a signal about guest was resized */ 1041 emit resizeHintDone(); 1032 1042 1033 1043 return true; … … 1387 1397 case QEvent::Resize: 1388 1398 { 1389 if (!mIgnoreMainwndResize) 1390 { 1391 if (mIsAdditionsActive && mAutoresizeGuest) 1392 resize_hint_timer->start (300, TRUE); 1393 /// @todo disabled for the time being since seems to be not 1394 // necessary anymore 1395 #if 0 1396 /* During window maximization WindowStateChange event is 1397 * processed before Resize event, so the mIgnoreMainwndResize 1398 * variable should be set to true here in case of mainwnd is 1399 * maximized or in fullscreen state. */ 1400 /* Not sure if it is really required */ 1401 if (mainwnd->isMaximized() || mainwnd->isTrueFullscreen() 1402 || mainwnd->isTrueSeamless()) 1403 mIgnoreMainwndResize = true; 1404 #endif 1405 } 1399 if (!mIgnoreMainwndResize && 1400 mIsAdditionsActive && mAutoresizeGuest) 1401 resize_hint_timer->start (300, TRUE); 1406 1402 break; 1407 }1408 case QEvent::WindowStateChange:1409 {1410 /* The guest screen size (and therefore the contents size)1411 * could have been changed while we were maximized or minimized,1412 * so posting event for auto-resize and normalization. */1413 if (!mainwnd->isMinimized() &&1414 !mainwnd->isMaximized() &&1415 !mainwnd->isTrueFullscreen() &&1416 !mainwnd->isTrueSeamless())1417 QTimer::singleShot (0, this, SLOT (exitFullScreen()));1418 1403 } 1419 1404 … … 1966 1951 1967 1952 /** 1968 * Called on e xit from fullscreen or from maximizedmode.1953 * Called on enter/exit seamless/fullscreen mode. 1969 1954 */ 1970 void VBoxConsoleView:: exitFullScreen()1955 void VBoxConsoleView::toggleFSMode (const QSize &aResizeTo) 1971 1956 { 1972 1957 if (mIsAdditionsActive && mAutoresizeGuest) 1973 { 1974 doResizeHint(); 1975 /* Fire a normalize event with some delay to let the guest process the 1976 * resize hint and send resize properly, instead of normalizing to the 1977 * current guest size right now. */ 1978 QTimer::singleShot (200, this, SLOT (normalizeGeo())); 1979 } 1980 else 1981 { 1982 normalizeGeo(); 1983 } 1984 1985 mIgnoreMainwndResize = false; 1958 doResizeHint (aResizeTo); 1959 mToggleFSModeTimer->start (400, true); 1986 1960 } 1987 1961 … … 2770 2744 // effect :), but at least it works with NT and W2k guests. 2771 2745 2772 // @TODO Sending 0xFE is responsible for the warning 2746 // @TODO Sending 0xFE is responsible for the warning 2773 2747 // 2774 2748 // ``atkbd.c: Spurious NAK on isa0060/serio0. Some program might … … 3162 3136 } 3163 3137 3164 void VBoxConsoleView::doResizeHint ()3138 void VBoxConsoleView::doResizeHint (const QSize &aToSize) 3165 3139 { 3166 3140 if (mIsAdditionsActive && mAutoresizeGuest) 3167 3141 { 3168 /* Get the available size for the guest display. 3142 /* If this slot is invoked directly then use the passed size 3143 * otherwise get the available size for the guest display. 3169 3144 * We assume here that the centralWidget() contains this view only 3170 3145 * and gives it all available space. */ 3171 QSize sz ( mainwnd->centralWidget()->size());3146 QSize sz (aToSize.isValid() ? aToSize : mainwnd->centralWidget()->size()); 3172 3147 sz -= QSize (frameWidth() * 2, frameWidth() * 2); 3173 3148 LogFlowFunc (("Will suggest %d x %d\n", sz.width(), sz.height())); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r4450 r4514 107 107 , machine_state (CEnums::InvalidMachineState) 108 108 , no_auto_close (false) 109 , mDoMaximize (false) 110 , mManualResize (false) 111 , mAllowOneResize (false) 109 112 , mIsFullscreen (false) 110 113 , mIsSeamless (false) … … 975 978 } 976 979 980 /** 981 * This slot is called just after entering the fullscreen/seamless mode, 982 * when the console was resized to required size. 983 */ 984 void VBoxConsoleWnd::onEnterFullscreen() 985 { 986 disconnect (console, SIGNAL (resizeHintDone()), 0, 0); 987 988 vmSeamlessAction->setEnabled (mIsSeamless); 989 vmFullscreenAction->setEnabled (mIsFullscreen); 990 991 mAwaitingSize = mPrevSize; 992 } 993 994 /** 995 * This slot is called just after leaving the fullscreen/seamless mode, 996 * when the console was resized to previous size. 997 */ 998 void VBoxConsoleWnd::onExitFullscreen() 999 { 1000 disconnect (console, SIGNAL (resizeHintDone()), 0, 0); 1001 1002 vmSeamlessAction->setEnabled (mIsSeamlessSupported); 1003 vmFullscreenAction->setEnabled (true); 1004 1005 mManualResize = false; 1006 console->setIgnoreMainwndResize (false); 1007 console->normalizeGeometry (true /* adjustPosition */); 1008 } 1009 977 1010 void VBoxConsoleWnd::setMouseIntegrationLocked (bool aDisabled) 978 1011 { … … 1024 1057 { 1025 1058 QResizeEvent *re = (QResizeEvent *) e; 1026 if (!mIsFullscreen && !mIsSeamless && 1059 1060 /* do not process event if the resize events are blocked 1061 * and the proposed size is not the awaited one */ 1062 if (mManualResize && !mAllowOneResize && 1063 re->size() != mAwaitingSize) 1064 return false; 1065 1066 if (!mManualResize && 1027 1067 (windowState() & (WindowMaximized | WindowMinimized | 1028 1068 WindowFullScreen)) == 0) … … 1033 1073 #endif 1034 1074 } 1075 if (mManualResize && mAllowOneResize) 1076 mAllowOneResize = false; 1077 1035 1078 break; 1036 1079 } 1037 1080 case QEvent::Move: 1038 1081 { 1039 if (!m IsFullscreen && !mIsSeamless&&1082 if (!mManualResize && 1040 1083 (windowState() & (WindowMaximized | WindowMinimized | 1041 1084 WindowFullScreen)) == 0) … … 1054 1097 break; 1055 1098 } 1099 case QEvent::WindowStateChange: 1100 { 1101 if (mDoMaximize) 1102 { 1103 /* this workaround is necessary due to KDE seems to be 1104 * thinks the seamless mode is maximized state */ 1105 mDoMaximize = false; 1106 setWindowState (windowState() | WindowMaximized); 1107 } 1108 } 1056 1109 default: 1057 1110 break; … … 1059 1112 1060 1113 return QMainWindow::event (e); 1114 } 1115 1116 void VBoxConsoleWnd::resizeEvent (QResizeEvent *aEvent) 1117 { 1118 if (aEvent->size() == mAwaitingSize) 1119 { 1120 /* this resize was done to awaited size, so 1121 * let the guest to be resized to this size too */ 1122 mAwaitingSize = QSize(); 1123 console->toggleFSMode (centralWidget()->size()); 1124 } 1125 1126 QMainWindow::resizeEvent (aEvent); 1061 1127 } 1062 1128 … … 1818 1884 void VBoxConsoleWnd::toggleFullscreenMode (bool aOn, bool aSeamless) 1819 1885 { 1820 if (aSeamless && 1821 (aOn && !mIsSeamlessSupported || 1822 aOn && mIsFullscreen || 1823 !aOn && !mIsSeamless)) 1824 return; 1825 1826 /* Check if the Guest Video RAM enough for the seamless mode */ 1827 QRect screen = QApplication::desktop()->screenGeometry (this); 1828 ULONG vRamSize = csession.GetMachine().GetVRAMSize(); 1829 if (aSeamless && aOn && 1830 (ULONG64) vRamSize * _1M * 8 < 1831 (ULONG64) screen.width() * screen.height() * QColor::numBitPlanes()) 1832 { 1833 vboxProblem().cannotEnterSeamlessMode (screen.width(), 1834 screen.height(), QColor::numBitPlanes()); 1835 vmSeamlessAction->setOn (false); 1836 return; 1886 if (aSeamless) 1887 { 1888 /* Check if it is necessary to enter/leave seamless mode */ 1889 if (aOn && !mIsSeamlessSupported || aOn && mIsFullscreen || 1890 !aOn && !mIsSeamless) 1891 return; 1892 1893 /* Check if the Guest Video RAM enough for the seamless mode */ 1894 QRect screen = QApplication::desktop()->screenGeometry (this); 1895 ULONG vRamSize = csession.GetMachine().GetVRAMSize(); 1896 if (aOn && 1897 (ULONG64) vRamSize * _1M * 8 < 1898 (ULONG64) screen.width() * screen.height() * QColor::numBitPlanes()) 1899 { 1900 vboxProblem().cannotEnterSeamlessMode (screen.width(), 1901 screen.height(), QColor::numBitPlanes()); 1902 vmSeamlessAction->setOn (false); 1903 return; 1904 } 1837 1905 } 1838 1906 … … 1874 1942 vmDisableMouseIntegrAction->setEnabled (!aOn); 1875 1943 1876 console->console().GetDisplay().SetSeamlessMode(aOn); 1944 console->console().GetDisplay().SetSeamlessMode (aOn); 1945 mIsSeamless = aOn; 1877 1946 } 1878 1947 else … … 1887 1956 if (aOn) 1888 1957 { 1889 if (aSeamless) 1890 mIsSeamless = true; 1958 /* Block any disallowed resize events: */ 1959 mManualResize = true; 1960 console->setIgnoreMainwndResize (true); 1961 1962 /* temporarily disable the mode-related action to make sure 1963 * user can not leave the mode before he enter it */ 1964 aSeamless ? vmSeamlessAction->setEnabled (false) : 1965 vmFullscreenAction->setEnabled (false); 1966 1967 connect (console, SIGNAL (resizeHintDone()), this, SLOT (onEnterFullscreen())); 1891 1968 1892 1969 /* Save the previous scroll-view minimum size before entering … … 1900 1977 was_max = isMaximized(); 1901 1978 1979 /* memorize previous size before entering the f/s mode */ 1980 mPrevSize = size(); 1981 1902 1982 /* set the correct flags to disable unnecessary frame controls */ 1903 1983 int flags = WType_TopLevel | WStyle_Customize | WStyle_NoBorder; … … 1909 1989 QApplication::desktop()->availableGeometry (this) : 1910 1990 QApplication::desktop()->screenGeometry (this); 1991 1992 /* let the required resize event pass */ 1993 mAwaitingSize = scrGeo.size(); 1911 1994 1912 1995 #ifdef Q_WS_WIN32 … … 1949 2032 /* go fullscreen */ 1950 2033 resize (scrGeo.size()); 1951 setMinimumSize (s ize());1952 setMaximumSize (s ize());2034 setMinimumSize (scrGeo.size()); 2035 setMaximumSize (scrGeo.size()); 1953 2036 1954 2037 #ifdef Q_WS_MAC … … 1965 2048 else 1966 2049 { 2050 /* temporarily disable the mode-related action to make sure 2051 * user can not enter the mode before he leave it */ 2052 aSeamless ? vmSeamlessAction->setEnabled (false) : 2053 vmFullscreenAction->setEnabled (false); 2054 2055 connect (console, SIGNAL (resizeHintDone()), this, SLOT (onExitFullscreen())); 2056 1967 2057 /* Restore the previous scroll-view minimum size before the exiting 1968 2058 * fullscreen. Required for correct scroll-view and guest display … … 1981 2071 1982 2072 /* reparent to restore normal flags */ 1983 reparent (parentWidget(), normal_wflags, QPoint (0, 0), false);2073 reparent (parentWidget(), normal_wflags, normal_pos, false); 1984 2074 /* reattaching application icon after window reparenting */ 1985 2075 setIcon (QPixmap::fromMimeSource ("ico40x01.png")); … … 2002 2092 setMaximumSize (QSize (QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); 2003 2093 2004 if (aSeamless) 2005 { 2006 if (was_max) 2007 { 2008 /* restore the maximized state */ 2094 /* restore previous position and size */ 2095 bool is_max = isMaximized(); 2096 move (normal_pos); 2097 if (was_max) 2098 mAllowOneResize = true; 2099 resize (normal_size); 2100 qApp->processEvents(); 2101 2102 if (was_max) 2103 { 2104 if (aSeamless && is_max) 2105 mDoMaximize = true; 2106 else 2009 2107 setWindowState (windowState() | WindowMaximized); 2010 } 2011 else 2012 { 2013 move (normal_pos); 2014 resize (normal_size); 2015 QTimer::singleShot (200, console, SLOT (exitFullScreen())); 2016 } 2017 } 2018 else 2019 { 2020 move (normal_pos); 2021 resize (normal_size); 2022 /* restore the maximized state */ 2023 if (was_max) 2024 setWindowState (windowState() | WindowMaximized); 2025 else 2026 QTimer::singleShot (0, console, SLOT (exitFullScreen())); 2027 } 2028 2029 /* let our toplevel widget calculate its sizeHint properly */ 2030 QApplication::sendPostedEvents (0, QEvent::LayoutHint); 2031 2032 if (aSeamless) 2033 mIsSeamless = false; 2108 qApp->processEvents(); 2109 } 2034 2110 } 2035 2111
Note:
See TracChangeset
for help on using the changeset viewer.