Changeset 26773 in vbox for trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp
- Timestamp:
- Feb 25, 2010 1:53:19 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 58030
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp
r26754 r26773 73 73 } 74 74 75 void UIMachineViewNormal::normalizeGeometry(bool bAdjustPosition /* = false */) 76 { 77 /* Make no normalizeGeometry in case we are in manual resize mode or main window is maximized */ 78 if (machineWindowWrapper()->machineWindow()->isMaximized()) 79 return; 80 81 QWidget *pTopLevelWidget = window(); 82 83 /* calculate client window offsets */ 84 QRect fr = pTopLevelWidget->frameGeometry(); 85 QRect r = pTopLevelWidget->geometry(); 86 int dl = r.left() - fr.left(); 87 int dt = r.top() - fr.top(); 88 int dr = fr.right() - r.right(); 89 int db = fr.bottom() - r.bottom(); 90 91 /* get the best size w/o scroll bars */ 92 QSize s = pTopLevelWidget->sizeHint(); 93 94 /* resize the frame to fit the contents */ 95 s -= pTopLevelWidget->size(); 96 fr.setRight(fr.right() + s.width()); 97 fr.setBottom(fr.bottom() + s.height()); 98 99 if (bAdjustPosition) 100 { 101 QRegion ar; 102 QDesktopWidget *dwt = QApplication::desktop(); 103 if (dwt->isVirtualDesktop()) 104 /* Compose complex available region */ 105 for (int i = 0; i < dwt->numScreens(); ++ i) 106 ar += dwt->availableGeometry(i); 107 else 108 /* Get just a simple available rectangle */ 109 ar = dwt->availableGeometry(pTopLevelWidget->pos()); 110 111 fr = VBoxGlobal::normalizeGeometry(fr, ar, mode() != VBoxDefs::SDLMode /* canResize */); 112 } 113 114 #if 0 115 /* Center the frame on the desktop: */ 116 fr.moveCenter(ar.center()); 117 #endif 118 119 /* Finally, set the frame geometry */ 120 pTopLevelWidget->setGeometry(fr.left() + dl, fr.top() + dt, fr.width() - dl - dr, fr.height() - dt - db); 121 } 122 123 void UIMachineViewNormal::maybeRestrictMinimumSize() 124 { 125 /* Sets the minimum size restriction depending on the auto-resize feature state and the current rendering mode. 126 * Currently, the restriction is set only in SDL mode and only when the auto-resize feature is inactive. 127 * We need to do that because we cannot correctly draw in a scrolled window in SDL mode. 128 * In all other modes, or when auto-resize is in force, this function does nothing. */ 129 if (mode() == VBoxDefs::SDLMode) 130 { 131 if (!isGuestSupportsGraphics() || !m_bIsGuestAutoresizeEnabled) 132 setMinimumSize(sizeHint()); 133 else 134 setMinimumSize(0, 0); 135 } 136 } 137 138 void UIMachineViewNormal::doResizeHint(const QSize & /*toSize*/) 75 void UIMachineViewNormal::sltPerformGuestResize(const QSize & /* toSize */) 139 76 { 140 77 #if 0 // TODO: fix that logic! … … 171 108 } 172 109 173 /* If the desktop geometry is set automatically, this will update it. */ 174 void UIMachineViewNormal::doResizeDesktop(int) 175 { 176 calculateDesktopGeometry(); 177 } 178 179 void UIMachineViewNormal::sltToggleGuestAutoresize(bool bOn) 180 { 181 if (m_bIsGuestAutoresizeEnabled != bOn) 182 { 183 m_bIsGuestAutoresizeEnabled = bOn; 184 185 maybeRestrictMinimumSize(); 186 187 if (isGuestSupportsGraphics() && m_bIsGuestAutoresizeEnabled) 188 doResizeHint(); 189 } 190 } 191 192 void UIMachineViewNormal::sltAdditionsStateChanged(const QString & /* strVersion */, bool /* bIsActive */, 193 bool /* bIsSeamlessSupported */, bool bIsGraphicsSupported) 194 { 110 void UIMachineViewNormal::sltAdditionsStateChanged() 111 { 112 /* Base-class additions state-change-handler: */ 113 UIMachineView::sltAdditionsStateChanged(); 114 195 115 /* Enable/Disable guest auto-resizing depending on advanced graphics availablability: */ 196 s ltToggleGuestAutoresize(bIsGraphicsSupported&& m_bIsGuestAutoresizeEnabled);116 setGuestAutoresizeEnabled(isGuestSupportsGraphics() && m_bIsGuestAutoresizeEnabled); 197 117 } 198 118 199 119 void UIMachineViewNormal::prepareFilters() 200 120 { 201 /* P arentclass filters: */121 /* Prepare base-class filters: */ 202 122 UIMachineView::prepareFilters(); 203 123 … … 206 126 } 207 127 128 void UIMachineViewNormal::setGuestAutoresizeEnabled(bool fEnabled) 129 { 130 if (m_bIsGuestAutoresizeEnabled != fEnabled) 131 { 132 m_bIsGuestAutoresizeEnabled = fEnabled; 133 134 maybeRestrictMinimumSize(); 135 136 if (isGuestSupportsGraphics() && m_bIsGuestAutoresizeEnabled) 137 sltPerformGuestResize(); 138 } 139 } 140 141 void UIMachineViewNormal::normalizeGeometry(bool bAdjustPosition /* = false */) 142 { 143 QWidget *pTopLevelWidget = window(); 144 145 /* Make no normalizeGeometry in case we are in manual resize mode or main window is maximized: */ 146 if (pTopLevelWidget->isMaximized()) 147 return; 148 149 /* Calculate client window offsets: */ 150 QRect frameGeo = pTopLevelWidget->frameGeometry(); 151 QRect geo = pTopLevelWidget->geometry(); 152 int dl = geo.left() - frameGeo.left(); 153 int dt = geo.top() - frameGeo.top(); 154 int dr = frameGeo.right() - geo.right(); 155 int db = frameGeo.bottom() - geo.bottom(); 156 157 /* Get the best size w/o scroll bars: */ 158 QSize s = pTopLevelWidget->sizeHint(); 159 160 /* Resize the frame to fit the contents: */ 161 s -= pTopLevelWidget->size(); 162 frameGeo.setRight(frameGeo.right() + s.width()); 163 frameGeo.setBottom(frameGeo.bottom() + s.height()); 164 165 if (bAdjustPosition) 166 { 167 QRegion availableGeo; 168 QDesktopWidget *dwt = QApplication::desktop(); 169 if (dwt->isVirtualDesktop()) 170 /* Compose complex available region */ 171 for (int i = 0; i < dwt->numScreens(); ++ i) 172 availableGeo += dwt->availableGeometry(i); 173 else 174 /* Get just a simple available rectangle */ 175 availableGeo = dwt->availableGeometry(pTopLevelWidget->pos()); 176 177 frameGeo = VBoxGlobal::normalizeGeometry(frameGeo, availableGeo, mode() != VBoxDefs::SDLMode /* canResize */); 178 } 179 180 #if 0 181 /* Center the frame on the desktop: */ 182 frameGeo.moveCenter(availableGeo.center()); 183 #endif 184 185 /* Finally, set the frame geometry */ 186 pTopLevelWidget->setGeometry(frameGeo.left() + dl, frameGeo.top() + dt, frameGeo.width() - dl - dr, frameGeo.height() - dt - db); 187 } 188 189 void UIMachineViewNormal::maybeRestrictMinimumSize() 190 { 191 /* Sets the minimum size restriction depending on the auto-resize feature state and the current rendering mode. 192 * Currently, the restriction is set only in SDL mode and only when the auto-resize feature is inactive. 193 * We need to do that because we cannot correctly draw in a scrolled window in SDL mode. 194 * In all other modes, or when auto-resize is in force, this function does nothing. */ 195 if (mode() == VBoxDefs::SDLMode) 196 { 197 if (!isGuestSupportsGraphics() || !m_bIsGuestAutoresizeEnabled) 198 setMinimumSize(sizeHint()); 199 else 200 setMinimumSize(0, 0); 201 } 202 } 203
Note:
See TracChangeset
for help on using the changeset viewer.