Changeset 52891 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Sep 29, 2014 4:52:38 PM (10 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r52794 r52891 3354 3354 1 /* Source indication (1 = normal application) */); 3355 3355 } 3356 3357 /* static */ 3358 void VBoxGlobal::setTransientFor(QWidget *pWidget, QWidget *pPropWidget) 3359 { 3360 XSetTransientForHint(pWidget->x11Info().display(), 3361 pWidget->window()->winId(), 3362 pPropWidget->window()->winId()); 3363 } 3356 3364 #endif /* Q_WS_X11 */ 3357 3365 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r52794 r52891 323 323 /** X11: Performs mapping of the passed @a pWidget to host-screen with passed @a uScreenId. */ 324 324 static bool setFullScreenMonitorX11(QWidget *pWidget, ulong uScreenId); 325 /** X11: Ensures @a pPropWidget become transient for the @a pWidget. */ 326 static void setTransientFor(QWidget *pWidget, QWidget *pPropWidget); 325 327 #endif /* Q_WS_X11 */ 326 328 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp
r52873 r52891 188 188 /* Revoke stolen focus: */ 189 189 m_pMachineView->setFocus(); 190 #elif defined(Q_WS_MAC) 190 #elif defined(Q_WS_MAC) || defined(Q_WS_X11) 191 191 /* Revoke stolen activation: */ 192 192 activateWindow(); 193 #endif /* Q_WS_MAC */193 #endif /* Q_WS_MAC || Q_WS_X11 */ 194 194 } 195 195 … … 364 364 !pFullscreenLogic->hasHostScreenForGuestScreen(m_uScreenId)) 365 365 { 366 /* Hide mini-toolbar: */ 367 if ( m_pMiniToolBar 368 #ifdef Q_WS_MAC 369 && !fSupportsNativeFullScreen 370 #endif /* Q_WS_MAC */ 371 ) 366 /* If there is mini-toolbar: */ 367 if (m_pMiniToolBar) 368 { 369 #if defined(Q_WS_WIN) || defined(Q_WS_X11) 370 /* Just hide mini-toolbar: */ 372 371 m_pMiniToolBar->hide(); 372 #elif defined(Q_WS_MAC) 373 /* If no native full-screen used: */ 374 if (!fSupportsNativeFullScreen) 375 { 376 /* Just hide mini-toolbar: */ 377 m_pMiniToolBar->hide(); 378 } 379 #endif /* Q_WS_MAC */ 380 } 373 381 /* Hide window: */ 374 382 hide(); … … 425 433 adjustMachineViewSize(); 426 434 427 /* Show mini-toolbar: */ 428 if ( m_pMiniToolBar 429 #ifdef Q_WS_MAC 430 && !fSupportsNativeFullScreen 431 #endif /* Q_WS_MAC */ 432 ) 435 /* If there is mini-toolbar: */ 436 if (m_pMiniToolBar) 437 { 438 #if defined(Q_WS_WIN) 439 /* Just show mini-toolbar: */ 433 440 m_pMiniToolBar->show(); 441 #elif defined(Q_WS_MAC) 442 /* If no native full-screen used: */ 443 if (!fSupportsNativeFullScreen) 444 { 445 /* Just show mini-toolbar: */ 446 m_pMiniToolBar->show(); 447 } 448 #elif defined(Q_WS_X11) 449 /* Allow mini-toolbar to be located on full-screen area: */ 450 m_pMiniToolBar->showFullScreen(); 451 /* On modern window managers: */ 452 if (fSupportsNativeFullScreen) 453 { 454 /* We also can map mini-toolbar directly on corresponding machine-window: */ 455 VBoxGlobal::setFullScreenMonitorX11(m_pMiniToolBar, pFullscreenLogic->hostScreenForGuestScreen(m_uScreenId)); 456 } 457 /* Make sure mini-toolbar is always on top of machine-window: */ 458 VBoxGlobal::setTransientFor(m_pMiniToolBar, this); 459 #endif /* Q_WS_X11 */ 460 } 434 461 435 462 /* Make sure machine-view have focus: */ … … 452 479 const int iHostScreen = pFullscreenLogic->hostScreenForGuestScreen(m_uScreenId); 453 480 481 #ifndef Q_WS_X11 454 482 /* Move mini-toolbar into appropriate place: */ 455 483 m_pMiniToolBar->adjustGeometry(iHostScreen); 484 #else /* Q_WS_X11 */ 485 /* On modern WMs we are mapping mini-toolbar to corresponding host-screen directly. */ 486 const bool fSupportsNativeFullScreen = VBoxGlobal::supportsFullScreenMonitorsProtocolX11() && 487 !gEDataManager->legacyFullscreenModeRequested(); 488 /* Adjust mini-toolbar and move into appropriate place if necessary: */ 489 m_pMiniToolBar->adjustGeometry(fSupportsNativeFullScreen ? -1 : iHostScreen); 490 #endif /* Q_WS_X11 */ 456 491 } 457 492 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineWindowSeamless.cpp
r52873 r52891 74 74 /* Revoke stolen focus: */ 75 75 m_pMachineView->setFocus(); 76 #elif defined(Q_WS_MAC) 76 #elif defined(Q_WS_MAC) || defined(Q_WS_X11) 77 77 /* Revoke stolen activation: */ 78 78 activateWindow(); 79 #endif /* Q_WS_MAC */ 80 } 81 82 #ifdef VBOX_WITH_MASKED_SEAMLESS 83 # ifdef Q_WS_X11 84 void UIMachineWindowSeamless::sltUpdateMiniToolbarMask(const QRect &geo) 85 { 86 /* Make sure mini-toolbar exists: */ 87 AssertPtrReturnVoid(m_pMiniToolBar); 88 89 /* Remember mini-toolbar mask: */ 90 m_maskMiniToolbar = geo; 91 92 /* Re-assign guest mask. */ 93 setMask(m_maskGuest); 94 } 95 # endif /* Q_WS_X11 */ 96 #endif /* VBOX_WITH_MASKED_SEAMLESS */ 79 #endif /* Q_WS_MAC || Q_WS_X11 */ 80 } 97 81 98 82 void UIMachineWindowSeamless::prepareVisualState() … … 153 137 actionPool()->action(UIActionIndexRT_M_Machine_S_Close), SLOT(trigger())); 154 138 connect(m_pMiniToolBar, SIGNAL(sigNotifyAboutFocusStolen()), this, SLOT(sltRevokeFocus())); 155 #ifdef VBOX_WITH_MASKED_SEAMLESS156 # ifdef Q_WS_X11157 connect(m_pMiniToolBar, SIGNAL(sigNotifyAboutGeometryChange(const QRect&)),158 this, SLOT(sltUpdateMiniToolbarMask(const QRect&)));159 # endif /* Q_WS_X11 */160 #endif /* VBOX_WITH_MASKED_SEAMLESS */161 139 } 162 140 #endif /* !Q_WS_MAC */ … … 213 191 { 214 192 #ifndef Q_WS_MAC 215 /* Hidemini-toolbar: */193 /* If there is mini-toolbar: */ 216 194 if (m_pMiniToolBar) 195 { 196 /* Just hide mini-toolbar: */ 217 197 m_pMiniToolBar->hide(); 198 } 218 199 #endif /* !Q_WS_MAC */ 219 200 /* Hide window: */ … … 236 217 237 218 #ifndef Q_WS_MAC 238 /* Showmini-toolbar: */219 /* If there is mini-toolbar: */ 239 220 if (m_pMiniToolBar) 221 { 222 # if defined(Q_WS_WIN) 223 /* Just show mini-toolbar: */ 240 224 m_pMiniToolBar->show(); 225 # elif defined(Q_WS_X11) 226 /* Allow mini-toolbar to be located on full-screen area: */ 227 m_pMiniToolBar->showMaximized(); 228 /* Make sure mini-toolbar is always on top of machine-window: */ 229 VBoxGlobal::setTransientFor(m_pMiniToolBar, this); 230 # endif /* Q_WS_X11 */ 231 } 241 232 #endif /* !Q_WS_MAC */ 242 233 … … 319 310 maskFull.translate(m_pLeftSpacer->geometry().width(), m_pTopSpacer->geometry().height()); 320 311 321 # ifdef Q_WS_X11322 /* Take into account mini-toolbar mask if necessary: */323 if (m_pMiniToolBar)324 maskFull += m_maskMiniToolbar;325 # endif /* Q_WS_X11 */326 327 312 /* Seamless-window for empty full mask should be empty too, 328 313 * but the QWidget::setMask() wrapper doesn't allow this. -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineWindowSeamless.h
r52870 r52891 43 43 /** Revokes keyboard-focus. */ 44 44 void sltRevokeFocus(); 45 46 #ifdef VBOX_WITH_MASKED_SEAMLESS47 # ifdef Q_WS_X1148 /** Assigns mini-toolbar seamless mask. */49 void sltUpdateMiniToolbarMask(const QRect &geo);50 # endif /* Q_WS_X11 */51 #endif /* VBOX_WITH_MASKED_SEAMLESS */52 45 53 46 private: … … 97 90 /** Holds the guest seamless mask. */ 98 91 QRegion m_maskGuest; 99 # ifdef Q_WS_X11100 /** Holds the mini-toolbar seamless mask. */101 QRect m_maskMiniToolbar;102 # endif /* Q_WS_X11 */103 92 #endif /* VBOX_WITH_MASKED_SEAMLESS */ 104 93 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.cpp
r52874 r52891 52 52 bool fAutoHide /* = true */) 53 53 : QWidget(pParent, 54 #if defined 54 #if defined(Q_WS_WIN) 55 55 Qt::Tool | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint 56 #elif defined (Q_WS_MAC)56 #elif defined(Q_WS_MAC) || defined(Q_WS_X11) 57 57 Qt::Window | Qt::FramelessWindowHint 58 #elif defined (Q_WS_X11) 59 Qt::Widget 60 #endif /* RT_OS_DARWIN */ 58 #endif /* Q_WS_MAC || Q_WS_X11 */ 61 59 ) 62 60 /* Variables: General stuff: */ … … 143 141 void UIRuntimeMiniToolBar::adjustGeometry(int iHostScreen /* = -1 */) 144 142 { 143 #ifndef Q_WS_X11 145 144 /* This method could be called before parent-widget 146 145 * become visible, we should skip everything in that case: */ … … 166 165 default: break; 167 166 } 168 #ifdef Q_WS_X11169 /* Disregard origin under X11,170 * because this is widget, not window: */171 screenRect.moveTopLeft(QPoint(0, 0));172 #endif /* Q_WS_X11 */173 167 iX = screenRect.x() + screenRect.width() / 2 - width() / 2; 174 168 switch (m_alignment) … … 202 196 /* Simulate toolbar auto-hiding: */ 203 197 simulateToolbarAutoHiding(); 198 199 #else /* Q_WS_X11 */ 200 201 /* This method could be called before parent-widget 202 * become visible, we should skip everything in that case: */ 203 if (QApplication::desktop()->screenNumber(parentWidget()) == -1) 204 return; 205 206 /* Determine host-screen number if necessary: */ 207 bool fMoveToHostScreen = true; 208 if (iHostScreen == -1) 209 { 210 fMoveToHostScreen = false; 211 iHostScreen = QApplication::desktop()->screenNumber(this); 212 } 213 214 /* Choose window geometry: */ 215 QRect screenRect; 216 switch (m_geometryType) 217 { 218 case GeometryType_Available: screenRect = QApplication::desktop()->availableGeometry(iHostScreen); break; 219 case GeometryType_Full: screenRect = QApplication::desktop()->screenGeometry(iHostScreen); break; 220 default: break; 221 } 222 223 /* Move to corresponding host-screen: */ 224 if (fMoveToHostScreen) 225 move(screenRect.topLeft()); 226 227 /* Resize embedded-toolbar to minimum size: */ 228 m_pEmbeddedToolbar->resize(m_pEmbeddedToolbar->sizeHint()); 229 230 /* Calculate embedded-toolbar position: */ 231 int iX = 0, iY = 0; 232 iX = screenRect.width() / 2 - m_pEmbeddedToolbar->width() / 2; 233 switch (m_alignment) 234 { 235 case Qt::AlignTop: iY = 0; break; 236 case Qt::AlignBottom: iY = screenRect.height() - m_pEmbeddedToolbar->height(); break; 237 default: break; 238 } 239 240 /* Update auto-hide animation: */ 241 m_shownToolbarPosition = QPoint(iX, iY); 242 switch (m_alignment) 243 { 244 case Qt::AlignTop: m_hiddenToolbarPosition = m_shownToolbarPosition - QPoint(0, m_pEmbeddedToolbar->height() - 3); break; 245 case Qt::AlignBottom: m_hiddenToolbarPosition = m_shownToolbarPosition + QPoint(0, m_pEmbeddedToolbar->height() - 3); break; 246 } 247 m_pAnimation->update(); 248 249 /* Update embedded-toolbar geometry if known: */ 250 const QString strAnimationState = property("AnimationState").toString(); 251 if (strAnimationState == "Start") 252 m_pEmbeddedToolbar->move(m_hiddenToolbarPosition); 253 else if (strAnimationState == "Final") 254 m_pEmbeddedToolbar->move(m_shownToolbarPosition); 255 256 /* Adjust window mask: */ 257 setMask(m_pEmbeddedToolbar->geometry()); 258 259 /* Simulate toolbar auto-hiding: */ 260 simulateToolbarAutoHiding(); 261 #endif /* Q_WS_X11 */ 204 262 } 205 263 … … 238 296 void UIRuntimeMiniToolBar::prepare() 239 297 { 240 #if def Q_WS_MAC298 #if defined(Q_WS_MAC) || defined (Q_WS_X11) 241 299 /* Install own event filter: */ 242 300 installEventFilter(this); 243 #endif /* Q_WS_MAC */301 #endif /* Q_WS_MAC || Q_WS_X11 */ 244 302 245 303 #if defined(Q_WS_MAC) || defined(Q_WS_WIN) … … 259 317 setAttribute(Qt::WA_TranslucentBackground); 260 318 # endif /* Q_WS_WIN */ 261 #endif /* Q_WS_MAC || Q_WS_WIN */ 319 #elif defined(Q_WS_X11) 320 /* Use Qt API to enable translucency if allowed: */ 321 if (QX11Info::isCompositingManagerRunning()) 322 setAttribute(Qt::WA_TranslucentBackground); 323 #endif /* Q_WS_X11 */ 262 324 263 325 /* Make sure we have no focus: */ … … 378 440 } 379 441 442 #ifdef Q_WS_X11 443 void UIRuntimeMiniToolBar::resizeEvent(QResizeEvent*) 444 { 445 /* Adjust mini-toolbar on resize: */ 446 adjustGeometry(); 447 } 448 #endif /* Q_WS_X11 */ 449 380 450 bool UIRuntimeMiniToolBar::eventFilter(QObject *pWatched, QEvent *pEvent) 381 451 { … … 388 458 pEvent->type() == QEvent::FocusIn) 389 459 emit sigNotifyAboutFocusStolen(); 390 #elif defined(Q_WS_MAC) 391 /* Due to Qt bug on Mac OS X window will be activated 392 * even if has Qt::WA_ShowWithoutActivating attribute. */ 460 #elif defined(Q_WS_MAC) || defined(Q_WS_X11) 461 /* Detect if we have window activation stolen. */ 393 462 if (pWatched == this && 394 463 pEvent->type() == QEvent::WindowActivate) 395 464 emit sigNotifyAboutFocusStolen(); 396 #endif /* Q_WS_MAC */465 #endif /* Q_WS_MAC || Q_WS_X11 */ 397 466 398 467 /* Call to base-class: */ … … 423 492 /* Update window mask: */ 424 493 setMask(m_pEmbeddedToolbar->geometry()); 425 426 # ifdef VBOX_WITH_MASKED_SEAMLESS427 /* Notify listeners as well: */428 const QRect windowGeo = geometry();429 emit sigNotifyAboutGeometryChange(windowGeo.intersected(m_pEmbeddedToolbar->geometry().translated(windowGeo.topLeft())));430 # endif /* VBOX_WITH_MASKED_SEAMLESS */431 494 #endif /* Q_WS_X11 */ 432 495 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.h
r52872 r52891 64 64 void sigNotifyAboutFocusStolen(); 65 65 66 #ifdef VBOX_WITH_MASKED_SEAMLESS67 # ifdef Q_WS_X1168 /** Notifies about geometry change. */69 void sigNotifyAboutGeometryChange(const QRect &geo);70 # endif /* Q_WS_X11 */71 #endif /* VBOX_WITH_MASKED_SEAMLESS */72 73 66 public: 74 67 … … 118 111 void enterEvent(QEvent *pEvent); 119 112 void leaveEvent(QEvent *pEvent); 113 114 #ifdef Q_WS_X11 115 /** X11: Resize event handler. */ 116 void resizeEvent(QResizeEvent *pEvent); 117 #endif /* Q_WS_X11 */ 120 118 121 119 /** Filters @a pEvent if <i>this</i> object has been
Note:
See TracChangeset
for help on using the changeset viewer.