Changeset 39023 in vbox
- Timestamp:
- Oct 18, 2011 9:01:00 PM (13 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp
r39021 r39023 169 169 /** 170 170 * Returns whether we like the given video mode. 171 * @note We always like a mode smaller than the current framebuffer 172 * size. 171 173 * 172 174 * @returns COM status code … … 185 187 *pbSupported = TRUE; 186 188 QSize screen = m_pMachineView->maxGuestSize(); 187 if ((screen.width() != 0) && (uWidth > (ULONG)screen.width())) 189 if ( (screen.width() != 0) 190 && (uWidth > (ULONG)screen.width()) 191 && (uWidth > (ULONG)width())) 188 192 *pbSupported = FALSE; 189 if ((screen.height() != 0) && (uHeight > (ULONG)screen.height())) 193 if ( (screen.height() != 0) 194 && (uHeight > (ULONG)screen.height()) 195 && (uHeight > (ULONG)height())) 190 196 *pbSupported = FALSE; 191 197 LogFlowThisFunc(("screenW=%lu, screenH=%lu -> aSupported=%s\n", -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r39022 r39023 25 25 #include <QScrollBar> 26 26 #include <VBox/VBoxVideo.h> 27 #include <iprt/asm.h> 27 28 28 29 /* Local includes */ … … 160 161 AssertMsg(newSize.isValid(), ("Size should be valid!\n")); 161 162 162 /* Store the new hint */163 storeHintForGuestSizePolicy(newSize.width(), newSize.height());164 163 /* Send new size-hint to the guest: */ 165 164 session().GetConsole().GetDisplay().SetVideoModeHint(newSize.width(), newSize.height(), 0, screenId()); … … 240 239 , m_previousState(KMachineState_Null) 241 240 , m_maxGuestSizePolicy(MaxGuestSizePolicy_Invalid) 241 , m_u64MaxGuestSize(0) 242 242 #ifdef VBOX_WITH_VIDEOHWACCEL 243 243 , m_fAccelerate2DVideo(bAccelerate2DVideo) … … 485 485 QString maxGuestSize = vboxGlobal().settings().publicProperty("GUI/MaxGuestResolution"); 486 486 if ((maxGuestSize == QString::null) || (maxGuestSize == "auto")) 487 setMaxGuestSizePolicy(MaxGuestSizePolicy_Automatic, 0, 0);487 m_maxGuestSizePolicy = MaxGuestSizePolicy_Automatic; 488 488 else if (maxGuestSize == "any") 489 setMaxGuestSizePolicy(MaxGuestSizePolicy_Any, 0, 0);489 m_maxGuestSizePolicy = MaxGuestSizePolicy_Any; 490 490 else /** @todo Mea culpa, but what about error checking? */ 491 491 { 492 492 int width = maxGuestSize.section(',', 0, 0).toInt(); 493 493 int height = maxGuestSize.section(',', 1, 1).toInt(); 494 setMaxGuestSizePolicy(MaxGuestSizePolicy_Fixed, width, height); 494 m_maxGuestSizePolicy = MaxGuestSizePolicy_Fixed; 495 m_fixedMaxGuestSize = QSize(width, height); 495 496 } 496 497 } … … 597 598 } 598 599 599 QSize UIMachineView::maxGuestSize() const 600 void UIMachineView::setMaxGuestSize() 600 601 { 601 602 QSize maxSize; … … 603 604 { 604 605 case MaxGuestSizePolicy_Fixed: 606 maxSize = m_fixedMaxGuestSize; 607 break; 605 608 case MaxGuestSizePolicy_Automatic: 606 maxSize = QSize(qMax(m_fixedMaxGuestSize.width(), m_storedGuestHintSize.width()), 607 qMax(m_fixedMaxGuestSize.height(), m_storedGuestHintSize.height())); 609 maxSize = calculateMaxGuestSize(); 608 610 break; 609 611 case MaxGuestSizePolicy_Any: 612 default: 613 AssertMsg(m_maxGuestSizePolicy == MaxGuestSizePolicy_Any, 614 ("Invalid maximum guest size policy %d!\n", 615 m_maxGuestSizePolicy)); 616 /* (0, 0) means any of course. */ 610 617 maxSize = QSize(0, 0); 611 break; 612 default: 613 AssertMsgFailed(("Invalid maximum guest size policy %d!\n", 614 m_maxGuestSizePolicy)); 615 } 616 return maxSize; 618 } 619 ASMAtomicWriteU64(&m_u64MaxGuestSize, 620 RT_MAKE_U64(maxSize.width(), maxSize.height())); 621 } 622 623 QSize UIMachineView::maxGuestSize() 624 { 625 uint64_t u64Size = ASMAtomicReadU64(&m_u64MaxGuestSize); 626 return QSize(int(RT_HI_U32(u64Size)), int(RT_LO_U32(u64Size))); 617 627 } 618 628 … … 650 660 /* Return result: */ 651 661 return sizeHint; 652 }653 654 void UIMachineView::setMaxGuestSizePolicy(MaxGuestSizePolicy policy, int cwMax,655 int chMax)656 {657 switch (policy)658 {659 case MaxGuestSizePolicy_Fixed:660 m_maxGuestSizePolicy = MaxGuestSizePolicy_Fixed;661 if (cwMax != 0 && chMax != 0)662 m_fixedMaxGuestSize = QSize(cwMax, chMax);663 else664 m_fixedMaxGuestSize = QSize(0, 0);665 storeHintForGuestSizePolicy(0, 0);666 break;667 case MaxGuestSizePolicy_Automatic:668 m_maxGuestSizePolicy = MaxGuestSizePolicy_Automatic;669 m_fixedMaxGuestSize = QSize(0, 0);670 storeHintForGuestSizePolicy(0, 0);671 break;672 case MaxGuestSizePolicy_Any:673 m_maxGuestSizePolicy = MaxGuestSizePolicy_Any;674 m_fixedMaxGuestSize = QSize(0, 0);675 break;676 default:677 AssertMsgFailed(("Invalid maximum guest size policy %d\n",678 policy));679 m_maxGuestSizePolicy = MaxGuestSizePolicy_Invalid;680 }681 }682 683 void UIMachineView::storeHintForGuestSizePolicy(int cWidth, int cHeight)684 {685 if (m_maxGuestSizePolicy == MaxGuestSizePolicy_Automatic)686 m_storedGuestHintSize = QSize(cWidth, cHeight);687 662 } 688 663 … … 892 867 /* Report to the VM thread that we finished resizing: */ 893 868 session().GetConsole().GetDisplay().ResizeCompleted(screenId()); 894 895 /* We also recalculate the maximum guest size if necessary. In fact we896 * only need this on the first resize, but it is done every time to keep897 * the code simpler. */898 calculateMaxGuestSize();899 869 900 870 /* Emit a signal about guest was resized: */ … … 1009 979 { 1010 980 updateSliders(); 981 /* We call this on every resize as on X11 it sets information which becomes 982 * available asynchronously at an unknown time after window creation. As 983 * long as the information is not available we make a best guess. */ 984 setMaxGuestSize(); 1011 985 return QAbstractScrollArea::resizeEvent(pEvent); 1012 986 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
r39022 r39023 135 135 UIFrameBuffer* frameBuffer() const { return m_pFrameBuffer; } 136 136 const QPixmap& pauseShot() const { return m_pauseShot; } 137 /** Helper to retrieve the last non-fullscreen guest size hint 138 * sent. @note Currently unused. */ 139 QSize storedGuestHintSize() const { return m_storedGuestHintSize; } 140 /** What policy are we currently applying for limiting guest 141 * resolutions? */ 142 MaxGuestSizePolicy maxGuestSizePolicy() const 143 { return m_maxGuestSizePolicy; } 144 /** The maximum guest resolution which we currently wish to handle. 145 * @note This must be safely called from another thread. 146 * @todo So make it atomic. 147 */ 148 QSize maxGuestSize() const; 137 /** Atomically store the maximum guest resolution which we currently wish 138 * to handle for @a maxGuestSize() to read. */ 139 void setMaxGuestSize(); 140 /** Atomically read the maximum guest resolution which we currently wish to 141 * handle. This may safely be called from another thread (called by 142 * UIFramebuffer on EMT). */ 143 QSize maxGuestSize(); 149 144 /** Retrieve the last non-fullscreen guest size hint (from extra data). 150 145 */ … … 152 147 153 148 /* Protected setters: */ 154 void setMaxGuestSizePolicy(MaxGuestSizePolicy policy, int cwMax, 155 int chMax); 156 void storeHintForGuestSizePolicy(int cWidth, int cHeight); 149 /** Store a guest size hint value to extra data, called on switching to 150 * fullscreen. */ 157 151 void storeGuestSizeHint(const QSize &sizeHint); 158 152 … … 165 159 /** Calculate how big the guest desktop can be while still fitting on one 166 160 * host screen. */ 167 virtual void calculateMaxGuestSize()= 0;161 virtual QSize calculateMaxGuestSize() const = 0; 168 162 virtual void maybeRestrictMinimumSize() = 0; 169 163 virtual void updateSliders(); … … 204 198 KMachineState m_previousState; 205 199 206 /** The policy for calculating the maximum guest resolution w e wish to207 * support. */200 /** The policy for calculating the maximum guest resolution which we wish 201 * to handle. */ 208 202 MaxGuestSizePolicy m_maxGuestSizePolicy; 209 203 /** The maximum guest size for fixed size policy. */ 210 204 QSize m_fixedMaxGuestSize; 211 /** The last guest size hint sent out, used for calculating the maximum 212 * supported guest resolution. */ 213 QSize m_storedGuestHintSize; 205 /** Maximum guest resolution which we wish to handle. Must be accessed 206 * atomically. */ 207 /** @todo This should be private. */ 208 volatile uint64_t m_u64MaxGuestSize; 214 209 215 210 #ifdef VBOX_WITH_VIDEOHWACCEL -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.cpp
r39021 r39023 95 95 void UIMachineViewFullscreen::sltDesktopResized() 96 96 { 97 /* Recalculate the maximum guest size if necessary. */ 98 calculateMaxGuestSize(); 97 99 98 } 100 99 … … 205 204 } 206 205 207 void UIMachineViewFullscreen::calculateMaxGuestSize() 208 { 209 /* This method should not get called until we have initially set up the desktop geometry type: */ 210 Assert((maxGuestSizePolicy() != MaxGuestSizePolicy_Invalid)); 211 /* If we are not doing automatic adjustment then there is nothing to do. */ 212 if (maxGuestSizePolicy() == MaxGuestSizePolicy_Automatic) 213 m_fixedMaxGuestSize = workingArea().size(); 206 QSize UIMachineViewFullscreen::calculateMaxGuestSize() const 207 { 208 return workingArea().size(); 214 209 } 215 210 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.h
r39021 r39023 71 71 void normalizeGeometry(bool /* fAdjustPosition */) {} 72 72 QRect workingArea() const; 73 void calculateMaxGuestSize();73 QSize calculateMaxGuestSize() const; 74 74 void maybeRestrictMinimumSize(); 75 75 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp
r39022 r39023 98 98 void UIMachineViewNormal::sltDesktopResized() 99 99 { 100 /* Recalculate the maximum guest size if necessary. */ 101 calculateMaxGuestSize(); 100 102 101 } 103 102 … … 304 303 } 305 304 306 void UIMachineViewNormal::calculateMaxGuestSize() 307 { 308 /* This method should not get called until we have initially set up the 309 * maximum guest size policy. */ 310 Assert((maxGuestSizePolicy() != MaxGuestSizePolicy_Invalid)); 311 /* If we are not doing automatic adjustment then there is nothing to do. */ 312 if (maxGuestSizePolicy() == MaxGuestSizePolicy_Automatic) 313 { 314 /* The area taken up by the machine window on the desktop, 315 * including window frame, title, menu bar and status bar: */ 316 QRect windowGeo = machineWindowWrapper()->machineWindow()->frameGeometry(); 317 /* The area taken up by the machine central widget, so excluding all decorations: */ 318 QRect centralWidgetGeo = static_cast<QMainWindow*>(machineWindowWrapper()->machineWindow())->centralWidget()->geometry(); 319 /* To work out how big we can make the console window while still fitting on the desktop, 320 * we calculate workingArea() - (windowGeo - centralWidgetGeo). 321 * This works because the difference between machine window and machine central widget 322 * (or at least its width and height) is a constant. */ 323 m_fixedMaxGuestSize = QSize( workingArea().width() 324 - (windowGeo.width() 325 - centralWidgetGeo.width()), 326 workingArea().height() 327 - (windowGeo.height() 328 - centralWidgetGeo.height())); 329 } 305 QSize UIMachineViewNormal::calculateMaxGuestSize() const 306 { 307 /* The area taken up by the machine window on the desktop, 308 * including window frame, title, menu bar and status bar: */ 309 QRect windowGeo = machineWindowWrapper()->machineWindow()->frameGeometry(); 310 /* The area taken up by the machine central widget, so excluding all decorations: */ 311 QRect centralWidgetGeo = static_cast<QMainWindow*>(machineWindowWrapper()->machineWindow())->centralWidget()->geometry(); 312 /* To work out how big we can make the console window while still fitting on the desktop, 313 * we calculate workingArea() - (windowGeo - centralWidgetGeo). 314 * This works because the difference between machine window and machine central widget 315 * (or at least its width and height) is a constant. */ 316 return QSize( workingArea().width() 317 - (windowGeo.width() - centralWidgetGeo.width()), 318 workingArea().height() 319 - (windowGeo.height() - centralWidgetGeo.height())); 330 320 } 331 321 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.h
r39021 r39023 80 80 void normalizeGeometry(bool fAdjustPosition); 81 81 QRect workingArea() const; 82 void calculateMaxGuestSize();82 QSize calculateMaxGuestSize() const; 83 83 void maybeRestrictMinimumSize(); 84 84 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.cpp
r39021 r39023 154 154 void UIMachineViewScale::sltDesktopResized() 155 155 { 156 /* Recalculate the maximum guest size if necessary. */ 157 calculateMaxGuestSize(); 156 158 157 } 159 158 … … 185 184 /* Report to the VM thread that we finished resizing: */ 186 185 session().GetConsole().GetDisplay().ResizeCompleted(screenId()); 187 188 /* We also recalculate the maximum guest size if necessary. In189 * fact we only need this on the first resize, but it is done190 * every time to keep the code simpler. */191 calculateMaxGuestSize();192 186 193 187 /* Emit a signal about guest was resized: */ … … 368 362 } 369 363 370 void UIMachineViewScale::calculateMaxGuestSize() 371 { 372 /* This method should not get called until we have initially set up the 373 * maximum guest size policy. */ 374 Assert((maxGuestSizePolicy() != MaxGuestSizePolicy_Invalid)); 375 /* If we are not doing automatic adjustment then there is nothing to do. */ 376 if (maxGuestSizePolicy() == MaxGuestSizePolicy_Automatic) 377 { 378 /* The area taken up by the machine window on the desktop, 379 * including window frame, title, menu bar and status bar: */ 380 QRect windowGeo = machineWindowWrapper()->machineWindow()->frameGeometry(); 381 /* The area taken up by the machine central widget, so excluding all decorations: */ 382 QRect centralWidgetGeo = static_cast<QMainWindow*>(machineWindowWrapper()->machineWindow())->centralWidget()->geometry(); 383 /* To work out how big we can make the console window while still fitting on the desktop, 384 * we calculate workingArea() - (windowGeo - centralWidgetGeo). 385 * This works because the difference between machine window and machine central widget 386 * (or at least its width and height) is a constant. */ 387 m_fixedMaxGuestSize = QSize( workingArea().width() 388 - (windowGeo.width() 389 - centralWidgetGeo.width()), 390 workingArea().height() 391 - (windowGeo.height() 392 - centralWidgetGeo.height())); 393 } 364 QSize UIMachineViewScale::calculateMaxGuestSize() const 365 { 366 /* The area taken up by the machine window on the desktop, 367 * including window frame, title, menu bar and status bar: */ 368 QRect windowGeo = machineWindowWrapper()->machineWindow()->frameGeometry(); 369 /* The area taken up by the machine central widget, so excluding all decorations: */ 370 QRect centralWidgetGeo = static_cast<QMainWindow*>(machineWindowWrapper()->machineWindow())->centralWidget()->geometry(); 371 /* To work out how big we can make the console window while still fitting on the desktop, 372 * we calculate workingArea() - (windowGeo - centralWidgetGeo). 373 * This works because the difference between machine window and machine central widget 374 * (or at least its width and height) is a constant. */ 375 return QSize( workingArea().width() 376 - (windowGeo.width() - centralWidgetGeo.width()), 377 workingArea().height() 378 - (windowGeo.height() - centralWidgetGeo.height())); 394 379 } 395 380 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.h
r39021 r39023 72 72 void normalizeGeometry(bool /* fAdjustPosition */) {} 73 73 QRect workingArea() const; 74 void calculateMaxGuestSize();74 QSize calculateMaxGuestSize() const; 75 75 void maybeRestrictMinimumSize() {} 76 76 void updateSliders(); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.cpp
r39021 r39023 101 101 * I don't think that it is the GUI's job to check that 102 102 * the resize succeeded though. */ 103 104 /* Recalculate the maximum guest size if necessary. */105 calculateMaxGuestSize();106 103 } 107 104 … … 227 224 } 228 225 229 void UIMachineViewSeamless::calculateMaxGuestSize() 230 { 231 /* This method should not get called until we have initially set up the desktop geometry type: */ 232 Assert((maxGuestSizePolicy() != MaxGuestSizePolicy_Invalid)); 233 /* If we are not doing automatic adjustment then there is nothing to do. */ 234 if (maxGuestSizePolicy() == MaxGuestSizePolicy_Automatic) 235 m_fixedMaxGuestSize = workingArea().size(); 236 } 237 226 QSize UIMachineViewSeamless::calculateMaxGuestSize() const 227 { 228 return workingArea().size(); 229 } 230 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.h
r39021 r39023 75 75 void normalizeGeometry(bool /* fAdjustPosition */) {} 76 76 QRect workingArea() const; 77 void calculateMaxGuestSize();77 QSize calculateMaxGuestSize() const; 78 78 void maybeRestrictMinimumSize() {} 79 79
Note:
See TracChangeset
for help on using the changeset viewer.