Changeset 5544 in vbox
- Timestamp:
- Oct 29, 2007 9:50:13 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
r5132 r5544 91 91 void fixModifierState (LONG *codes, uint *count); 92 92 93 void toggleFSMode (const QSize &aFeatSize);93 void toggleFSMode(); 94 94 95 95 void setIgnoreMainwndResize (bool aYes) { mIgnoreMainwndResize = aYes; } … … 232 232 233 233 QRegion mLastVisibleRegion; 234 QSize mNormalSize; 234 235 235 236 #if defined(Q_WS_WIN) -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h
r5260 r5544 42 42 class QHBox; 43 43 class QLabel; 44 class QSpacerItem; 44 45 45 46 class VBoxConsoleView; … … 69 70 bool isTrueSeamless() const { return mIsSeamless; } 70 71 71 bool isManualResize() const { return mManualResize; }72 73 72 void setMouseIntegrationLocked (bool aDisabled); 74 73 … … 77 76 void installGuestAdditionsFrom (const QString &aSource); 78 77 79 #ifdef Q_WS_WIN80 78 void setMask (const QRegion &aRegion); 81 #endif82 79 83 80 public slots: … … 87 84 // events 88 85 bool event (QEvent *e); 89 void resizeEvent (QResizeEvent *e);90 86 void closeEvent (QCloseEvent *e); 91 87 #if defined(Q_WS_X11) … … 252 248 bool statusBarChangedInside; 253 249 250 QSpacerItem *mShiftingSpacer; 251 254 252 #ifdef VBOX_WITH_DEBUGGER_GUI 255 253 // Debugger popup menu … … 294 292 QSize normal_size; 295 293 QSize prev_min_size; 296 QSize mPrevSize;297 QSize mAwaitingSize;298 294 299 295 #ifdef Q_WS_WIN32 … … 302 298 303 299 // variables for dealing with true fullscreen 304 bool mDoMaximize : 1; 305 bool mManualResize : 1; 306 bool mAllowOneResize : 1; 300 QRegion mStrictedRegion; 307 301 bool mIsFullscreen : 1; 308 302 bool mIsSeamless : 1; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r5329 r5544 846 846 /* Make no normalizeGeometry in case we are in manual resize 847 847 * mode or main window is maximized */ 848 if (mainwnd->isMa nualResize() || mainwnd->isMaximized())848 if (mainwnd->isMaximized()) 849 849 return; 850 850 … … 1651 1651 { 1652 1652 flags |= KeyExtended; 1653 scan = ch >> 8; 1653 scan = ch >> 8; 1654 1654 } 1655 1655 else if (scan == 0x5C && (ch & 0xFF) == '/') … … 2054 2054 * Called on enter/exit seamless/fullscreen mode. 2055 2055 */ 2056 void VBoxConsoleView::toggleFSMode (const QSize &aResizeTo)2056 void VBoxConsoleView::toggleFSMode() 2057 2057 { 2058 2058 if (mIsAdditionsActive && mAutoresizeGuest) 2059 doResizeHint (aResizeTo); 2059 { 2060 QSize newSize = QSize(); 2061 if (mainwnd->isTrueFullscreen() || mainwnd->isTrueSeamless()) 2062 { 2063 mNormalSize = frameSize(); 2064 newSize = maximumSize(); 2065 } 2066 else 2067 newSize = mNormalSize; 2068 doResizeHint (newSize); 2069 } 2060 2070 mToggleFSModeTimer->start (400, true); 2061 2071 } … … 3267 3277 * and gives it all available space. */ 3268 3278 QSize sz (aToSize.isValid() ? aToSize : mainwnd->centralWidget()->size()); 3269 sz -= QSize (frameWidth() * 2, frameWidth() * 2); 3279 if (!aToSize.isValid()) 3280 sz -= QSize (frameWidth() * 2, frameWidth() * 2); 3270 3281 LogFlowFunc (("Will suggest %d x %d\n", sz.width(), sz.height())); 3271 3282 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r5512 r5544 108 108 , machine_state (CEnums::InvalidMachineState) 109 109 , no_auto_close (false) 110 , mDoMaximize (false)111 , mManualResize (false)112 , mAllowOneResize (false)113 110 , mIsFullscreen (false) 114 111 , mIsSeamless (false) … … 634 631 { 635 632 setCentralWidget (new QWidget (this, "centralWidget")); 636 new QBoxLayout (centralWidget(), QBoxLayout:: LeftToRight);633 new QBoxLayout (centralWidget(), QBoxLayout::Down); 637 634 } 638 635 … … 651 648 ((QBoxLayout*) centralWidget()->layout())->addWidget ( 652 649 console, 0, AlignVCenter | AlignHCenter); 650 651 mShiftingSpacer = new QSpacerItem (0, 0, QSizePolicy::Expanding, 652 QSizePolicy::Fixed); 653 ((QBoxLayout*) centralWidget()->layout())->addItem (mShiftingSpacer); 653 654 654 655 CMachine cmachine = csession.GetMachine(); … … 1008 1009 vmSeamlessAction->setEnabled (mIsSeamless); 1009 1010 vmFullscreenAction->setEnabled (mIsFullscreen); 1010 1011 mAwaitingSize = mPrevSize;1012 1011 } 1013 1012 … … 1023 1022 vmFullscreenAction->setEnabled (true); 1024 1023 1025 mManualResize = false;1026 1024 console->setIgnoreMainwndResize (false); 1027 1025 console->normalizeGeometry (true /* adjustPosition */); … … 1078 1076 QResizeEvent *re = (QResizeEvent *) e; 1079 1077 1080 /* do not process event if the resize events are blocked 1081 * and the proposed size is not the awaited one */ 1082 if (mManualResize && !mAllowOneResize && 1083 re->size() != mAwaitingSize) 1084 return false; 1085 1086 if (!mManualResize && 1087 (windowState() & WindowMaximized) == 0) 1078 if ((windowState() & WindowMaximized) == 0) 1088 1079 { 1089 1080 normal_size = re->size(); … … 1092 1083 #endif 1093 1084 } 1094 if (mManualResize && mAllowOneResize)1095 mAllowOneResize = false;1096 1097 1085 break; 1098 1086 } 1099 1087 case QEvent::Move: 1100 1088 { 1101 if (!mManualResize && 1102 (windowState() & (WindowMaximized | WindowMinimized | 1089 if ((windowState() & (WindowMaximized | WindowMinimized | 1103 1090 WindowFullScreen)) == 0) 1104 1091 { … … 1116 1103 break; 1117 1104 } 1118 case QEvent::WindowStateChange:1119 {1120 if (mDoMaximize)1121 {1122 /* this workaround is necessary due to KDE seems to be1123 * thinks the seamless mode is maximized state */1124 mDoMaximize = false;1125 setWindowState (windowState() | WindowMaximized);1126 }1127 }1128 1105 default: 1129 1106 break; … … 1131 1108 1132 1109 return QMainWindow::event (e); 1133 }1134 1135 void VBoxConsoleWnd::resizeEvent (QResizeEvent *aEvent)1136 {1137 if (aEvent->size() == mAwaitingSize)1138 {1139 /* this resize was done to awaited size, so1140 * let the guest to be resized to this size too */1141 mAwaitingSize = QSize();1142 console->toggleFSMode (centralWidget()->size());1143 }1144 1145 QMainWindow::resizeEvent (aEvent);1146 1110 } 1147 1111 … … 1940 1904 if (aSeamless) 1941 1905 { 1942 /* Check if it is necessary to enter/leave seamless mode */1943 if (aOn && !mIsSeamlessSupported || aOn && mIsFullscreen||1906 /* Check if it is necessary to enter/leave seamless mode. */ 1907 if (aOn && (!mIsSeamlessSupported || mIsFullscreen) || 1944 1908 !aOn && !mIsSeamless) 1945 1909 return; 1946 1910 1947 /* Check if the Guest Video RAM enough for the seamless mode */1911 /* Check if the Guest Video RAM enough for the seamless mode. */ 1948 1912 QRect screen = QApplication::desktop()->screenGeometry (this); 1949 1913 ULONG64 availBits = (csession.GetMachine().GetVRAMSize() /* vram */ … … 1956 1920 * screen.height() /* display height */ 1957 1921 * QColor::numBitPlanes(); /* bit per pixel */ 1958 1959 1922 if (aOn && (availBits < usedBits)) 1960 1923 { … … 1975 1938 if (aOn) 1976 1939 { 1977 /* take the toggle hot key from the menu item*/1940 /* Take the toggle hot key from the menu item. */ 1978 1941 QString hotKey = aSeamless ? vmSeamlessAction->menuText() : 1979 1942 vmFullscreenAction->menuText(); 1980 1943 hotKey = QStringList::split ('\t', hotKey) [1]; 1981 1944 Assert (!hotKey.isEmpty()); 1982 /* get the host key name*/1945 /* Get the host key name. */ 1983 1946 QString hostKey = QIHotKeyEdit::keyName (vboxGlobal().settings() 1984 1947 .hostKey()); 1985 /* show the info message*/1948 /* Show the info message. */ 1986 1949 aSeamless ? vboxProblem().remindAboutGoingSeamless (hotKey, hostKey) : 1987 1950 vboxProblem().remindAboutGoingFullscreen (hotKey, hostKey); … … 1990 1953 if (aSeamless) 1991 1954 { 1992 /* activate the auto-resize feature required for the seamless mode*/1955 /* Activate the auto-resize feature required for the seamless mode. */ 1993 1956 if (!vmAutoresizeGuestAction->isOn()) 1994 1957 vmAutoresizeGuestAction->setOn (true); 1995 1958 1996 /* activate the mouse integration feature for the seamless mode*/1959 /* Activate the mouse integration feature for the seamless mode. */ 1997 1960 if (vmDisableMouseIntegrAction->isOn()) 1998 1961 vmDisableMouseIntegrAction->setOn (false); … … 2017 1980 if (aOn) 2018 1981 { 2019 /* Block any disallowed resize events: */ 2020 mManualResize = true; 2021 console->setIgnoreMainwndResize (true); 2022 2023 /* temporarily disable the mode-related action to make sure 2024 * user can not leave the mode before he enter it */ 1982 /* Temporarily disable the mode-related action to make sure 1983 * user can not leave the mode before he enter it. */ 2025 1984 aSeamless ? vmSeamlessAction->setEnabled (false) : 2026 1985 vmFullscreenAction->setEnabled (false); 2027 2028 connect (console, SIGNAL (resizeHintDone()), this, SLOT (onEnterFullscreen())); 1986 /* Toggle console to manual resize mode. */ 1987 console->setIgnoreMainwndResize (true); 1988 connect (console, SIGNAL (resizeHintDone()), 1989 this, SLOT (onEnterFullscreen())); 1990 1991 /* Memorize the maximized state. */ 1992 was_max = isMaximized(); 2029 1993 2030 1994 /* Save the previous scroll-view minimum size before entering … … 2035 1999 console->setMinimumSize (0, 0); 2036 2000 2037 /* memorize the maximized state */2038 was_max = isMaximized();2039 2040 /* memorize previous size before entering the f/s mode */2041 mPrevSize = size();2042 2043 /* set the correct flags to disable unnecessary frame controls */2044 int flags = WType_TopLevel | WStyle_Customize | WStyle_NoBorder;2045 if (!aSeamless)2046 flags |= WStyle_StaysOnTop;2047 2048 2001 /* let the widget take the whole available desktop space */ 2049 2002 QRect scrGeo = aSeamless ? … … 2051 2004 QApplication::desktop()->screenGeometry (this); 2052 2005 2053 /* let the required resize event pass */ 2054 mAwaitingSize = scrGeo.size(); 2006 /* Calculate the difference region between current mode 2007 * (fullscreen or seamless) and the screen geometry. */ 2008 mStrictedRegion = 2009 QRegion (QApplication::desktop()->screenGeometry (this)) - scrGeo; 2010 2011 /* Setup the shifting spacer to make the console to be aligned on top 2012 * in the seamless mode. */ 2013 mShiftingSpacer->changeSize (0, mStrictedRegion.boundingRect().height(), 2014 QSizePolicy::Preferred, QSizePolicy::Fixed); 2055 2015 2056 2016 #ifdef Q_WS_WIN32 … … 2058 2018 #endif 2059 2019 2060 /* hide early to avoid extra flicker */ 2061 hide(); 2062 /* hide all but the central widget containing the console view */ 2020 /* Hide all but the central widget containing the console view. */ 2063 2021 QObjectList *list = queryList (NULL, NULL, false, false); 2064 2022 for (QObject *obj = list->first(); obj != NULL; obj = list->next()) … … 2076 2034 delete list; 2077 2035 2078 /* reparent to apply new flags and place to the top left corner of the 2079 * current desktop */ 2080 reparent (parentWidget(), flags, QPoint (scrGeo.x(), scrGeo.y()), false); 2081 /* reattaching application icon after window reparenting */ 2082 setIcon (QPixmap::fromMimeSource ("ico40x01.png")); 2083 2084 /* adjust colors and appearance */ 2036 /* Adjust colors and appearance. */ 2085 2037 erase_color = centralWidget()->eraseColor(); 2086 2038 centralWidget()->setEraseColor (black); 2087 2039 console_style = console->frameStyle(); 2088 2040 console->setFrameStyle (QFrame::NoFrame); 2089 console->setMaximumSize ( console->sizeHint());2041 console->setMaximumSize (scrGeo.size()); 2090 2042 console->setVScrollBarMode (QScrollView::AlwaysOff); 2091 2043 console->setHScrollBarMode (QScrollView::AlwaysOff); 2092 2044 2093 /* go fullscreen */ 2094 resize (scrGeo.size()); 2095 setMinimumSize (scrGeo.size()); 2096 setMaximumSize (scrGeo.size()); 2045 /* Going fullscreen: 2046 * "normal -> fullscreen" for normal window, 2047 * "maximized -> normal -> fullscreen" for maximized window. 2048 * Going "maximized -> fullscreen" wrong on KDE in both directions. 2049 * Here it does not resize the child window correctly. */ 2050 if (was_max) 2051 showNormal(); 2052 showFullScreen(); 2097 2053 2098 2054 #ifdef Q_WS_MAC 2099 2055 if (!aSeamless) 2100 2056 { 2101 /* make the apple menu bar go away. */2057 /* Make the apple menu bar go away. */ 2102 2058 OSStatus orc = SetSystemUIMode (kUIModeAllHidden, 2103 2059 kUIOptionDisableAppleMenu); … … 2106 2062 } 2107 2063 #endif 2064 2065 qApp->processEvents(); 2066 console->toggleFSMode(); 2108 2067 } 2109 2068 else 2110 2069 { 2111 /* temporarily disable the mode-related action to make sure2112 * user can not enter the mode before he leave it */2070 /* Temporarily disable the mode-related action to make sure 2071 * user can not enter the mode before he leave it. */ 2113 2072 aSeamless ? vmSeamlessAction->setEnabled (false) : 2114 2073 vmFullscreenAction->setEnabled (false); 2115 2074 /* Toggle console to manual resize mode. */ 2116 2075 connect (console, SIGNAL (resizeHintDone()), this, SLOT (onExitFullscreen())); 2076 2077 /* Reset the shifting spacer. */ 2078 mShiftingSpacer->changeSize (0, 0, QSizePolicy::Preferred, 2079 QSizePolicy::Fixed); 2117 2080 2118 2081 /* Restore the previous scroll-view minimum size before the exiting … … 2128 2091 #endif 2129 2092 2130 /* hide early to avoid extra flicker */ 2131 hide(); 2132 2133 /* reparent to restore normal flags */ 2134 reparent (parentWidget(), normal_wflags, normal_pos, false); 2135 /* reattaching application icon after window reparenting */ 2136 setIcon (QPixmap::fromMimeSource ("ico40x01.png")); 2137 2138 /* adjust colors and appearance */ 2093 /* Adjust colors and appearance. */ 2094 clearMask(); 2139 2095 centralWidget()->setEraseColor (erase_color); 2140 2096 console->setFrameStyle (console_style); … … 2143 2099 console->setHScrollBarMode (QScrollView::Auto); 2144 2100 2145 /* show everything hidden when going fullscreen*/2101 /* Show everything hidden when going fullscreen. */ 2146 2102 for (QObject *obj = hidden_children.first(); obj != NULL; 2147 2103 obj = hidden_children.next()) … … 2149 2105 hidden_children.clear(); 2150 2106 2151 /* restore normal values */ 2152 setMinimumSize (QSize(0, 0)); 2153 setMaximumSize (QSize (QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); 2154 2155 /* check if we are maximized: seamless on some wm == maximized */ 2156 bool is_max = isMaximized(); 2157 2158 /* restore previous position */ 2159 move (normal_pos); 2160 2107 /* Going normal || maximized: 2108 * "fullscreen -> normal" if was normal window, 2109 * "fullscreen -> normal -> maximized" if was maximized window. 2110 * Going "fullscreen -> maximized" wrong on KDE in both directions. 2111 * Here it looses the window frame totally. */ 2112 showNormal(); 2161 2113 if (was_max) 2162 /* let pass one resize event with previous size */ 2163 mAllowOneResize = true; 2164 else 2165 /* ensure we are waiting for the previous size */ 2166 mAwaitingSize = normal_size; 2167 2168 /* restore previous size */ 2169 resize (normal_size); 2114 showMaximized(); 2115 2170 2116 qApp->processEvents(); 2171 2172 if (was_max) 2173 { 2174 if (aSeamless && is_max) 2175 /* if seamless == maximized do delayed maximization */ 2176 mDoMaximize = true; 2177 else 2178 /* restore maximized mode now */ 2179 setWindowState (windowState() | WindowMaximized); 2180 qApp->processEvents(); 2181 } 2182 } 2183 2184 /* VBoxConsoleView loses focus for some reason after reparenting, 2185 * restore it */ 2186 console->setFocus(); 2187 2188 if (!wasHidden) 2189 show(); 2117 console->toggleFSMode(); 2118 } 2119 if (wasHidden) 2120 hide(); 2190 2121 } 2191 2122 … … 2564 2495 } 2565 2496 2497 void VBoxConsoleWnd::setMask (const QRegion &aRegion) 2498 { 2499 QRegion region = aRegion - mStrictedRegion; 2500 2566 2501 #ifdef Q_WS_WIN 2567 void VBoxConsoleWnd::setMask (const QRegion &aRegion) 2568 { 2569 QRegion difference = mPrevRegion.subtract (aRegion); 2502 QRegion difference = mPrevRegion.subtract (region); 2570 2503 2571 2504 /* Region offset calculation */ … … 2579 2512 /* Visible region calculation */ 2580 2513 HRGN newReg = CreateRectRgn (0, 0, 0, 0); 2581 CombineRgn (newReg, aRegion.handle(), 0, RGN_COPY);2514 CombineRgn (newReg, region.handle(), 0, RGN_COPY); 2582 2515 OffsetRgn (newReg, fleft, ftop); 2583 2516 … … 2592 2525 RedrawWindow (console->viewport()->winId(), NULL, NULL, RDW_INVALIDATE); 2593 2526 2594 mPrevRegion = aRegion; 2595 } 2596 #endif 2527 mPrevRegion = region; 2528 #else 2529 QMainWindow::setMask (region); 2530 #endif 2531 } 2597 2532 2598 2533 /**
Note:
See TracChangeset
for help on using the changeset viewer.