Changeset 9072 in vbox for trunk/src/VBox
- Timestamp:
- May 23, 2008 12:02:58 PM (17 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxConsoleView.h
r9067 r9072 95 95 void fixModifierState (LONG *codes, uint *count); 96 96 97 void toggleFSMode ();97 void toggleFSMode (const QSize &aSize = QSize()); 98 98 99 99 void setIgnoreMainwndResize (bool aYes) { mIgnoreMainwndResize = aYes; } … … 273 273 long muCapsLockAdaptionCnt; 274 274 275 QTimer *mToggleFSModeTimer;276 275 277 276 VBoxDefs::RenderMode mode; -
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxConsoleWnd.h
r9056 r9072 190 190 void dbgShowCommandLine(); 191 191 192 void onEnterFullscreen();193 192 void onExitFullscreen(); 194 void exitFullscreen(); 195 void exitSeamless(); 193 void unlockActionsSwitch(); 196 194 197 195 void switchToFullscreen (bool aOn, bool aSeamless); … … 317 315 bool mIsSeamlessSupported : 1; 318 316 bool mIsGraphicsSupported : 1; 317 bool mIsWaitingModeResize : 1; 319 318 bool was_max : 1; 320 319 QObjectList hidden_children; -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxConsoleView.cpp
r9070 r9072 705 705 ::memset (mPressedKeys, 0, SIZEOF_ARRAY (mPressedKeys)); 706 706 707 /* This timer is used as 'last resort' which toggles f/s mode708 in case of guest additions are not responding. */709 mToggleFSModeTimer = new QTimer (this);710 mToggleFSModeTimer->setSingleShot (true);711 connect (mToggleFSModeTimer, SIGNAL (timeout()),712 this, SIGNAL (resizeHintDone()));713 714 707 /* setup rendering */ 715 708 … … 813 806 setDesktopGeometry (DesktopGeo_Fixed, width, height); 814 807 } 815 connect (QApplication::desktop(), SIGNAL ( workAreaResized (int)),808 connect (QApplication::desktop(), SIGNAL (resized (int)), 816 809 this, SLOT (doResizeDesktop (int))); 817 810 … … 1101 1094 LogFlow (("VBoxDefs::ResizeEventType: %d x %d x %d bpp\n", 1102 1095 re->width(), re->height(), re->bitsPerPixel())); 1103 1104 if (mToggleFSModeTimer->isActive())1105 mToggleFSModeTimer->stop();1106 1096 1107 1097 /* do frame buffer dependent resize */ … … 2285 2275 * Called on enter/exit seamless/fullscreen mode. 2286 2276 */ 2287 void VBoxConsoleView::toggleFSMode ()2277 void VBoxConsoleView::toggleFSMode (const QSize &aSize) 2288 2278 { 2289 2279 if (mAutoresizeGuest || mMainWnd->isTrueFullscreen()) 2290 2280 { 2291 QSize newSize = QSize();2292 if ( mMainWnd->isTrueFullscreen() || mMainWnd->isTrueSeamless())2293 { 2294 mNormalSize = frameSize();2281 QSize newSize; 2282 if (aSize.isValid()) 2283 { 2284 mNormalSize = aSize; 2295 2285 newSize = maximumSize(); 2296 2286 } … … 2299 2289 doResizeHint (newSize); 2300 2290 } 2301 /* Currently there is a 2000 msec pause before timer transfers2302 * console into desired mode if the auto-resize feature is enabled2303 * and a 100 msec pause before it transfers console into this mode2304 * if it is not enabled. 100 msec pause required for resizing2305 * before normalizing geometry. */2306 mToggleFSModeTimer->start (mAutoresizeGuest ? 2000 : 100);2307 2308 /// @todo (r=dsen) perform roll-back after 'entering' mode in case2309 // we got no resizing response from the guest.2310 2291 } 2311 2292 -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxConsoleWnd.cpp
r9056 r9072 126 126 , mIsSeamlessSupported (false) 127 127 , mIsGraphicsSupported (false) 128 , mIsWaitingModeResize (false) 128 129 , was_max (false) 129 130 , console_style (0) … … 1031 1032 1032 1033 /** 1033 * This slot is called just after entering the fullscreen/seamless mode,1034 * when the console was resized to required size.1035 */1036 void VBoxConsoleWnd::onEnterFullscreen()1037 {1038 disconnect (console, SIGNAL (resizeHintDone()), 0, 0);1039 /* It isn't guaranteed that the guest os set the video mode that1040 * we requested. So after all the resizing stuff set the clipping1041 * mask and the spacing shifter to the corresponding values. */1042 setViewInSeamlessMode (QRect (console->mapToGlobal (QPoint (0, 0)), console->size()));1043 #ifdef Q_WS_MAC1044 if (!mIsSeamless)1045 {1046 /* Fade back to the normal gamma */1047 CGDisplayFade (mFadeToken, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, false);1048 CGReleaseDisplayFadeReservation (mFadeToken);1049 }1050 #endif1051 1052 vmSeamlessAction->setEnabled (mIsSeamless);1053 vmFullscreenAction->setEnabled (mIsFullscreen);1054 if (mIsSeamless)1055 connect (console, SIGNAL (resizeHintDone()),1056 this, SLOT (exitSeamless()));1057 /* disabled for now */1058 //else if (mIsFullscreen)1059 // connect (console, SIGNAL (resizeHintDone()),1060 // this, SLOT (exitFullscreen()));1061 }1062 1063 /**1064 1034 * This slot is called just after leaving the fullscreen/seamless mode, 1065 1035 * when the console was resized to previous size. … … 1067 1037 void VBoxConsoleWnd::onExitFullscreen() 1068 1038 { 1069 disconnect (console, SIGNAL (resizeHintDone()), 0, 0); 1039 console->setIgnoreMainwndResize (false); 1040 } 1041 1042 void VBoxConsoleWnd::unlockActionsSwitch() 1043 { 1044 if (mIsSeamless) 1045 vmSeamlessAction->setEnabled (true); 1046 else if (mIsFullscreen) 1047 vmFullscreenAction->setEnabled (true); 1048 else 1049 { 1050 vmSeamlessAction->setEnabled (mIsSeamlessSupported && mIsGraphicsSupported); 1051 vmFullscreenAction->setEnabled (true); 1052 } 1053 1070 1054 #ifdef Q_WS_MAC 1071 1055 if (!mIsSeamless) … … 1076 1060 } 1077 1061 #endif 1078 1079 vmSeamlessAction->setEnabled (mIsSeamlessSupported && mIsGraphicsSupported);1080 vmFullscreenAction->setEnabled (true);1081 1082 console->setIgnoreMainwndResize (false);1083 console->normalizeGeometry (true /* adjustPosition */);1084 }1085 1086 /**1087 * This slot is called if the guest changes resolution while in fullscreen1088 * mode.1089 */1090 void VBoxConsoleWnd::exitFullscreen()1091 {1092 Assert (0); /* disabled for now */1093 if (mIsFullscreen && vmFullscreenAction->isEnabled())1094 vmFullscreenAction->toggle();1095 }1096 1097 /**1098 * This slot is called if the guest changes resolution while in seamless1099 * mode.1100 */1101 void VBoxConsoleWnd::exitSeamless()1102 {1103 if (mIsSeamless && vmSeamlessAction->isEnabled())1104 vmSeamlessAction->toggle();1105 1062 } 1106 1063 … … 1155 1112 QResizeEvent *re = (QResizeEvent *) e; 1156 1113 1157 if (!isMaximized() && !isTrueFullscreen() && !isTrueSeamless()) 1114 if (!mIsWaitingModeResize && !isMaximized() && 1115 !isTrueFullscreen() && !isTrueSeamless()) 1158 1116 { 1159 1117 normal_size = re->size(); … … 1161 1119 dbgAdjustRelativePos(); 1162 1120 #endif 1121 } 1122 1123 if (mIsWaitingModeResize) 1124 { 1125 if (!mIsFullscreen && !mIsSeamless) 1126 { 1127 mIsWaitingModeResize = false; 1128 QTimer::singleShot (0, this, SLOT (onExitFullscreen())); 1129 } 1163 1130 } 1164 1131 break; … … 1978 1945 bool VBoxConsoleWnd::toggleFullscreenMode (bool aOn, bool aSeamless) 1979 1946 { 1980 disconnect (console, SIGNAL (resizeHintDone()), 0, 0); 1981 /* Check if the Guest Video RAM enough for the fullscreen/seamless mode. */ 1947 /* Please note: For some platforms like the Mac, the calling order of the 1948 * functions in this methods is vital. So please be carefull on changing 1949 * this. */ 1950 1951 QSize initialSize = size(); 1982 1952 if (aSeamless || console->isAutoresizeGuestActive()) 1983 1953 { … … 2075 2045 bool wasHidden = isHidden(); 2076 2046 2047 /* Temporarily disable the mode-related action to make sure 2048 * user can not leave the mode before he enter it and inside out. */ 2049 aSeamless ? vmSeamlessAction->setEnabled (false) : 2050 vmFullscreenAction->setEnabled (false); 2051 2052 /* Calculate initial console size */ 2053 QSize consoleSize; 2054 2077 2055 if (aOn) 2078 2056 { 2079 /* Temporarily disable the mode-related action to make sure 2080 * user can not leave the mode before he enter it. */ 2081 aSeamless ? vmSeamlessAction->setEnabled (false) : 2082 vmFullscreenAction->setEnabled (false); 2057 consoleSize = console->frameSize(); 2058 consoleSize -= QSize (console->frameWidth() * 2, console->frameWidth() * 2); 2059 2083 2060 /* Toggle console to manual resize mode. */ 2084 2061 console->setIgnoreMainwndResize (true); 2085 connect (console, SIGNAL (resizeHintDone()),2086 this, SLOT (onEnterFullscreen()));2087 2062 2088 2063 /* Memorize the maximized state. */ … … 2106 2081 * we requested. So after all the resizing stuff set the clipping 2107 2082 * mask and the spacing shifter to the corresponding values. */ 2108 setViewInSeamlessMode (dtw->availableGeometry (this)); 2083 if (aSeamless) 2084 setViewInSeamlessMode (scrGeo); 2109 2085 2110 2086 #ifdef Q_WS_WIN32 … … 2141 2117 console->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff); 2142 2118 console->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff); 2143 2144 /* Going fullscreen */2145 switchToFullscreen (aOn, aSeamless);2146 #ifdef Q_WS_MAC /* setMask seems to not include the far border pixels. */2147 // QRect maskRect = dtw->screenGeometry (this);2148 // maskRect.setRight (maskRect.right() + 1);2149 // maskRect.setBottom (maskRect.bottom() + 1);2150 // setMask (maskRect);2151 if (aSeamless)2152 {2153 OSStatus status;2154 HIViewRef viewRef = ::darwinToHIViewRef (console->viewport());2155 Assert (VALID_PTR (viewRef));2156 WindowRef windowRef = ::darwinToWindowRef (viewRef);2157 Assert (VALID_PTR (windowRef));2158 /* @todo=poetzsch: Currently this isn't necessary. I should2159 * investigate if we can/should use this. */2160 /*2161 EventTypeSpec wCompositingEvent = { kEventClassWindow, kEventWindowGetRegion };2162 status = InstallWindowEventHandler ((WindowPtr)winId(), DarwinRegionHandler, GetEventTypeCount (wCompositingEvent), &wCompositingEvent, &mCurrRegion, &mDarwinRegionEventHandlerRef);2163 AssertCarbonOSStatus (status);2164 HIViewRef contentView = 0;2165 status = HIViewFindByID(HIViewGetRoot(windowRef), kHIViewWindowContentID, &contentView);2166 AssertCarbonOSStatus (status);2167 EventTypeSpec drawEvent = { kEventClassControl, kEventControlDraw };2168 status = InstallControlEventHandler (contentView, DarwinRegionHandler, GetEventTypeCount (drawEvent), &drawEvent, &contentView, NULL);2169 AssertCarbonOSStatus (status);2170 */2171 UInt32 features;2172 status = GetWindowFeatures (windowRef, &features);2173 AssertCarbonOSStatus (status);2174 if (( features & kWindowIsOpaque ) != 0)2175 {2176 status = HIWindowChangeFeatures (windowRef, 0, kWindowIsOpaque);2177 AssertCarbonOSStatus (status);2178 }2179 status = HIViewReshapeStructure (viewRef);2180 AssertCarbonOSStatus (status);2181 status = SetWindowAlpha(windowRef, 0.999);2182 AssertCarbonOSStatus (status);2183 /* For now disable the shadow of the window. This feature cause errors2184 * if a window in vbox looses focus, is reselected and than moved. */2185 /** @todo Search for an option to enable this again. A shadow on every2186 * window has a big coolness factor. */2187 status = ChangeWindowAttributes (windowRef, kWindowNoShadowAttribute, 0);2188 AssertCarbonOSStatus (status);2189 }2190 #else2191 // setMask (dtw->screenGeometry (this));2192 #endif2193 2194 qApp->processEvents();2195 console->toggleFSMode();2196 2119 } 2197 2120 else 2198 2121 { 2199 /* Temporarily disable the mode-related action to make sure 2200 * user can not enter the mode before he leave it. */ 2201 aSeamless ? vmSeamlessAction->setEnabled (false) : 2202 vmFullscreenAction->setEnabled (false); 2203 /* Toggle console to manual resize mode. */ 2204 connect (console, SIGNAL (resizeHintDone()), this, SLOT (onExitFullscreen())); 2205 2206 /* Reset the shifting spacer. */ 2122 /* Reset the shifting spacers. */ 2207 2123 mShiftingSpacerLeft->changeSize (0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed); 2208 2124 mShiftingSpacerTop->changeSize (0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed); … … 2218 2134 if (aSeamless) 2219 2135 { 2136 /* Please note: All the stuff below has to be done before the 2137 * window switch back to normal size. Qt changes the winId on the 2138 * fullscreen switch and make this stuff useless with the old 2139 * winId. So please be carefull on rearrangement of the method 2140 * calls. */ 2220 2141 /* Undo all mac specific installations */ 2221 2142 OSStatus status; … … 2246 2167 ((QWidget *) obj)->show(); 2247 2168 hidden_children.clear(); 2248 2249 /* Going normal || maximized */ 2250 switchToFullscreen (aOn, aSeamless); 2251 2252 qApp->processEvents(); 2253 console->toggleFSMode(); 2254 } 2169 } 2170 2171 /* Set flag for waiting host resize if it awaited during mode entering */ 2172 if ((mIsFullscreen || mIsSeamless) && (consoleSize != initialSize)) 2173 mIsWaitingModeResize = true; 2174 2175 /* Toggle qt full-screen mode */ 2176 switchToFullscreen (aOn, aSeamless); 2177 2178 #ifdef Q_WS_MAC 2179 if (aOn && aSeamless) 2180 { 2181 /* Please note: All the stuff below has to be done after the window has 2182 * switched to fullscreen. Qt changes the winId on the fullscreen 2183 * switch and make this stuff useless with the old winId. So please be 2184 * carefull on rearrangement of the method calls. */ 2185 OSStatus status; 2186 HIViewRef viewRef = ::darwinToHIViewRef (console->viewport()); 2187 Assert (VALID_PTR (viewRef)); 2188 WindowRef windowRef = ::darwinToWindowRef (viewRef); 2189 Assert (VALID_PTR (windowRef)); 2190 /* @todo=poetzsch: Currently this isn't necessary. I should 2191 * investigate if we can/should use this. */ 2192 /* 2193 EventTypeSpec wCompositingEvent = { kEventClassWindow, kEventWindowGetRegion }; 2194 status = InstallWindowEventHandler ((WindowPtr)winId(), DarwinRegionHandler, GetEventTypeCount (wCompositingEvent), &wCompositingEvent, &mCurrRegion, &mDarwinRegionEventHandlerRef); 2195 AssertCarbonOSStatus (status); 2196 HIViewRef contentView = 0; 2197 status = HIViewFindByID(HIViewGetRoot(windowRef), kHIViewWindowContentID, &contentView); 2198 AssertCarbonOSStatus (status); 2199 EventTypeSpec drawEvent = { kEventClassControl, kEventControlDraw }; 2200 status = InstallControlEventHandler (contentView, DarwinRegionHandler, GetEventTypeCount (drawEvent), &drawEvent, &contentView, NULL); 2201 AssertCarbonOSStatus (status); 2202 */ 2203 UInt32 features; 2204 status = GetWindowFeatures (windowRef, &features); 2205 AssertCarbonOSStatus (status); 2206 if (( features & kWindowIsOpaque ) != 0) 2207 { 2208 status = HIWindowChangeFeatures (windowRef, 0, kWindowIsOpaque); 2209 AssertCarbonOSStatus (status); 2210 } 2211 status = HIViewReshapeStructure (viewRef); 2212 AssertCarbonOSStatus (status); 2213 status = SetWindowAlpha(windowRef, 0.999); 2214 AssertCarbonOSStatus (status); 2215 /* For now disable the shadow of the window. This feature cause errors 2216 * if a window in vbox looses focus, is reselected and than moved. */ 2217 /** @todo Search for an option to enable this again. A shadow on every 2218 * window has a big coolness factor. */ 2219 status = ChangeWindowAttributes (windowRef, kWindowNoShadowAttribute, 0); 2220 AssertCarbonOSStatus (status); 2221 } 2222 #endif 2223 2224 /* Process all console attributes changes and sub-widget hidings */ 2225 qApp->processEvents(); 2226 2227 /* Send guest size hint */ 2228 console->toggleFSMode (consoleSize); 2229 2230 if (!mIsWaitingModeResize) 2231 onExitFullscreen(); 2232 2233 /* Unlock FS actions locked during modes toggling */ 2234 QTimer::singleShot (300, this, SLOT (unlockActionsSwitch())); 2255 2235 2256 2236 #ifdef Q_WS_MAC /* wasHidden is wrong on the mac it seems. */ … … 2317 2297 { 2318 2298 #ifndef Q_WS_MAC 2319 if (mIsSeamless) 2320 { 2321 /* It isn't guaranteed that the guest os set the video mode that 2322 * we requested. So after all the resizing stuff set the clipping 2323 * mask and the spacing shifter to the corresponding values. */ 2324 QDesktopWidget *dtw = QApplication::desktop(); 2325 QRect sRect = dtw->screenGeometry (this); 2326 QRect aRect (aTargetRect); 2327 mMaskShift.scale (aTargetRect.left(), aTargetRect.top(), Qt::IgnoreAspectRatio); 2328 /* Set the clipping mask */ 2329 mStrictedRegion = aRect; 2330 /* Set the shifting spacer */ 2331 mShiftingSpacerLeft->changeSize (RT_ABS (sRect.left() - aRect.left()), 0, 2332 QSizePolicy::Fixed, QSizePolicy::Preferred); 2333 mShiftingSpacerTop->changeSize (0, RT_ABS (sRect.top() - aRect.top()), 2334 QSizePolicy::Preferred, QSizePolicy::Fixed); 2335 mShiftingSpacerRight->changeSize (RT_ABS (sRect.right() - aRect.right()), 0, 2336 QSizePolicy::Fixed, QSizePolicy::Preferred); 2337 mShiftingSpacerBottom->changeSize (0, RT_ABS (sRect.bottom() - aRect.bottom()), 2299 /* It isn't guaranteed that the guest os set the video mode that 2300 * we requested. So after all the resizing stuff set the clipping 2301 * mask and the spacing shifter to the corresponding values. */ 2302 QDesktopWidget *dtw = QApplication::desktop(); 2303 QRect sRect = dtw->screenGeometry (this); 2304 QRect aRect (aTargetRect); 2305 mMaskShift.scale (aTargetRect.left(), aTargetRect.top(), Qt::IgnoreAspectRatio); 2306 /* Set the clipping mask */ 2307 mStrictedRegion = aRect; 2308 /* Set the shifting spacer */ 2309 mShiftingSpacerLeft->changeSize (RT_ABS (sRect.left() - aRect.left()), 0, 2310 QSizePolicy::Fixed, QSizePolicy::Preferred); 2311 mShiftingSpacerTop->changeSize (0, RT_ABS (sRect.top() - aRect.top()), 2312 QSizePolicy::Preferred, QSizePolicy::Fixed); 2313 mShiftingSpacerRight->changeSize (RT_ABS (sRect.right() - aRect.right()), 0, 2314 QSizePolicy::Fixed, QSizePolicy::Preferred); 2315 mShiftingSpacerBottom->changeSize (0, RT_ABS (sRect.bottom() - aRect.bottom()), 2338 2316 QSizePolicy::Preferred, QSizePolicy::Fixed); 2339 }2340 2317 #else // !Q_WS_MAC 2341 2318 NOREF (aTargetRect);
Note:
See TracChangeset
for help on using the changeset viewer.