Changeset 27052 in vbox for trunk/src/VBox
- Timestamp:
- Mar 4, 2010 6:44:12 PM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.cpp
r27012 r27052 25 25 #include <QApplication> 26 26 #include <QDesktopWidget> 27 #include <QTimer> 27 28 #ifdef Q_WS_MAC 28 29 #include <QMenuBar> … … 51 52 #endif 52 53 , uMonitor) 54 , m_fIsInitialResizeEventProcessed(false) 55 , m_fShouldWeDoResize(false) 53 56 { 54 57 /* Prepare frame buffer: */ 55 58 prepareFrameBuffer(); 56 59 57 /* Prepare backup inforrmation: */58 prepareBackup();59 60 60 /* Prepare common things: */ 61 61 prepareCommon(); … … 73 73 loadMachineViewSettings(); 74 74 75 /* Prepare seamless mode: */75 /* Prepare seamless view: */ 76 76 prepareSeamless(); 77 77 … … 95 95 } 96 96 97 void UIMachineViewSeamless::sltPerformGuestResize() 98 { 99 /* Get machine window: */ 100 QIMainDialog *pMainDialog = machineWindowWrapper() && machineWindowWrapper()->machineWindow() ? 101 qobject_cast<QIMainDialog*>(machineWindowWrapper()->machineWindow()) : 0; 102 103 /* Get the available size for the guest display. We assume here that the centralWidget() 104 * contains only this machine view and gives it all available space: */ 105 QSize newSize(pMainDialog ? pMainDialog->centralWidget()->size() : QSize()); 106 AssertMsg(newSize.isValid(), ("Size should be valid!\n")); 107 108 /* Do not send the same hints as we already have: */ 109 if ((newSize.width() == storedConsoleSize().width()) && (newSize.height() == storedConsoleSize().height())) 110 return; 111 112 /* If we awaiting resize: */ 113 if (m_fShouldWeDoResize) 114 { 115 /* Remember the new size: */ 116 storeConsoleSize(newSize.width(), newSize.height()); 117 118 /* Send new size-hint to the guest: */ 119 session().GetConsole().GetDisplay().SetVideoModeHint(newSize.width(), newSize.height(), 0, screenId()); 120 } 121 122 /* We had requested resize now, rejecting other accident requests: */ 123 m_fShouldWeDoResize = false; 124 } 125 97 126 void UIMachineViewSeamless::sltAdditionsStateChanged() 98 127 { … … 100 129 } 101 130 102 /* If the desktop geometry is set automatically, this will update it: */103 131 void UIMachineViewSeamless::sltDesktopResized() 104 132 { 105 133 // TODO: Try to resize framebuffer according new desktop size, exit seamless if resize is failed! 134 135 /* If the desktop geometry is set automatically, this will update it: */ 136 calculateDesktopGeometry(); 106 137 } 107 138 … … 117 148 return true; 118 149 150 /* We are starting to perform machine view resize: */ 151 bool oldIgnoreMainwndResize = isMachineWindowResizeIgnored(); 152 setMachineWindowResizeIgnored(true); 153 119 154 /* Get guest resize-event: */ 120 155 UIResizeEvent *pResizeEvent = static_cast<UIResizeEvent*>(pEvent); … … 125 160 /* Reapply maximum size restriction for machine view: */ 126 161 setMaximumSize(sizeHint()); 162 163 /* Store the new size to prevent unwanted resize hints being sent back: */ 164 storeConsoleSize(pResizeEvent->width(), pResizeEvent->height()); 127 165 128 166 /* Perform machine view resize: */ … … 143 181 //mDockIconPreview->setOriginalSize(pResizeEvent->width(), pResizeEvent->height()); 144 182 #endif /* Q_WS_MAC */ 145 146 /* Update machine view sliders: */147 updateSliders();148 183 149 184 /* Unfortunately restoreOverrideCursor() is broken in Qt 4.4.0 if WA_PaintOnScreen widgets are present. … … 165 200 session().GetConsole().GetDisplay().ResizeCompleted(screenId()); 166 201 202 /* We are finishing to perform machine view resize: */ 203 setMachineWindowResizeIgnored(oldIgnoreMainwndResize); 204 167 205 /* Make sure that all posted signals are processed: */ 168 206 qApp->processEvents(); 207 208 /* We also recalculate the desktop geometry if this is determined automatically. 209 * In fact, we only need this on the first resize, 210 * but it is done every time to keep the code simpler. */ 211 calculateDesktopGeometry(); 169 212 170 213 /* Emit a signal about guest was resized: */ … … 210 253 bool UIMachineViewSeamless::eventFilter(QObject *pWatched, QEvent *pEvent) 211 254 { 255 QIMainDialog *pMainDialog = machineWindowWrapper() && machineWindowWrapper()->machineWindow() ? 256 qobject_cast<QIMainDialog*>(machineWindowWrapper()->machineWindow()) : 0; 257 if (pWatched != 0 && pWatched == pMainDialog) 258 { 259 switch (pEvent->type()) 260 { 261 case QEvent::Resize: 262 { 263 /* Ignore initial resize event: */ 264 if (!m_fIsInitialResizeEventProcessed) 265 { 266 m_fIsInitialResizeEventProcessed = true; 267 break; 268 } 269 270 /* Set the "guest needs to resize" hint. 271 * This hint is acted upon when (and only when) the autoresize property is "true": */ 272 m_fShouldWeDoResize = uisession()->isGuestSupportsGraphics(); 273 if (!isMachineWindowResizeIgnored() && uisession()->isGuestSupportsGraphics()) 274 QTimer::singleShot(0, this, SLOT(sltPerformGuestResize())); 275 break; 276 } 277 default: 278 break; 279 } 280 } 212 281 #ifdef Q_WS_MAC // TODO: Is it really needed? 213 282 QMenuBar *pMenuBar = machineWindowWrapper() && machineWindowWrapper()->machineWindow() ? … … 242 311 } 243 312 244 void UIMachineViewSeamless::prepareBackup() 245 { 313 void UIMachineViewSeamless::prepareCommon() 314 { 315 /* Base class common settings: */ 316 UIMachineView::prepareCommon(); 317 246 318 /* Store old machine view size before bramebuffer resized: */ 247 319 m_normalSize = QSize(frameBuffer()->width(), frameBuffer()->height()); 320 321 /* Minimum size is ignored: */ 322 setMinimumSize(0, 0); 323 /* No scrollbars: */ 324 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 325 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 248 326 } 249 327 … … 254 332 255 333 #ifdef Q_WS_MAC // TODO: Is it really needed? See UIMachineViewSeamless::eventFilter(...); 256 /* Menu bar filter s: */334 /* Menu bar filter: */ 257 335 qobject_cast<QIMainDialog*>(machineWindowWrapper()->machineWindow())->menuBar()->installEventFilter(this); 258 336 #endif … … 275 353 void UIMachineViewSeamless::prepareSeamless() 276 354 { 355 /* Set seamless feature flag to the guest: */ 277 356 session().GetConsole().GetDisplay().SetSeamlessMode(true); 278 session().GetConsole().GetDisplay().SetVideoModeHint(machineWindowWrapper()->machineWindow()->width(),279 machineWindowWrapper()->machineWindow()->height(), 0, screenId());280 357 } 281 358 282 359 void UIMachineViewSeamless::cleanupSeamless() 283 360 { 284 /* Send normal size-hint tothe guest: */361 /* Reset seamless feature flag of the guest: */ 285 362 session().GetConsole().GetDisplay().SetSeamlessMode(false); 286 session().GetConsole().GetDisplay().SetVideoModeHint(m_normalSize.width(), m_normalSize.height(), 0, screenId());287 363 } 288 364 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.h
r27028 r27052 44 44 private slots: 45 45 46 /* Slot to perform guest resize: */ 47 void sltPerformGuestResize(); 48 46 49 /* Console callback handlers: */ 47 50 void sltAdditionsStateChanged(); … … 57 60 58 61 /* Prepare helpers: */ 59 void prepare Backup();62 void prepareCommon(); 60 63 void prepareFilters(); 61 64 void prepareConnections(); … … 68 71 //void prepareConnections() {} 69 72 //void cleanupFilters() {} 70 //void prepareBackup() {}73 //void cleanupCommon(); 71 74 72 75 /* Private helpers: */ … … 74 77 75 78 /* Private variables: */ 79 bool m_fIsInitialResizeEventProcessed : 1; 80 bool m_fShouldWeDoResize : 1; 76 81 QRegion m_lastVisibleRegion; 77 82 QSize m_normalSize; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineWindowSeamless.cpp
r27039 r27052 78 78 79 79 /* Show window: */ 80 show ();80 showMaximized(); 81 81 } 82 82 … … 157 157 void UIMachineWindowSeamless::prepareSeamless() 158 158 { 159 /* Move & resize seamless frameless window: */160 QRect geometry = QApplication::desktop()->availableGeometry();161 159 #ifdef Q_WS_WIN 162 m_prevRegion = geometry; 163 #endif 164 move(geometry.topLeft()); 165 resize(geometry.size()); 160 m_prevRegion = QApplication::desktop()->availableGeometry(); 161 #endif 166 162 167 163 #ifdef Q_WS_MAC … … 172 168 ::darwinSetShowsWindowTransparent(this, true); 173 169 #endif 174 175 /* Perform these events: */176 qApp->processEvents();177 170 } 178 171
Note:
See TracChangeset
for help on using the changeset viewer.