@@ -221,7 +221,7 @@ void DockWidgetTabPrivate::moveTab(QMouseEvent* ev)
221221 ev->accept ();
222222 int left, top, right, bottom;
223223 _this->getContentsMargins (&left, &top, &right, &bottom);
224- QPoint moveToPos = _this-> mapToParent ( ev->pos () ) - DragStartMousePosition;
224+ QPoint moveToPos = ev->globalPos ( ) - DragStartMousePosition;
225225 moveToPos.setY (0 );
226226 _this->move (moveToPos);
227227 _this->raise ();
@@ -266,14 +266,16 @@ bool DockWidgetTabPrivate::startFloating(eDragState DraggingState)
266266
267267 if (DraggingFloatingWidget == DraggingState)
268268 {
269- FloatingWidget->startFloating (DragStartMousePosition, Size, DraggingFloatingWidget, _this);
269+ FloatingWidget->startFloating (_this->mapFromGlobal (DragStartMousePosition),
270+ Size, DraggingFloatingWidget, _this);
270271 auto Overlay = DockWidget->dockManager ()->containerOverlay ();
271272 Overlay->setAllowedAreas (OuterDockAreas);
272273 this ->FloatingWidget = FloatingWidget;
273274 }
274275 else
275276 {
276- FloatingWidget->startFloating (DragStartMousePosition, Size, DraggingInactive, nullptr );
277+ FloatingWidget->startFloating (_this->mapFromGlobal (DragStartMousePosition),
278+ Size, DraggingInactive, nullptr );
277279 }
278280
279281 return true ;
@@ -304,7 +306,7 @@ void CDockWidgetTab::mousePressEvent(QMouseEvent* ev)
304306 if (ev->button () == Qt::LeftButton)
305307 {
306308 ev->accept ();
307- d->DragStartMousePosition = ev->pos ();
309+ d->DragStartMousePosition = ev->globalPos ();
308310 d->DragState = DraggingMousePressed;
309311 emit clicked ();
310312 return ;
@@ -372,7 +374,7 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
372374 }
373375
374376 // Maybe a fixed drag distance is better here ?
375- int DragDistanceY = qAbs (d->DragStartMousePosition .y () - ev->pos ().y ());
377+ int DragDistanceY = qAbs (d->DragStartMousePosition .y () - ev->globalPos ().y ());
376378 if (DragDistanceY >= CDockManager::startDragDistance ())
377379 {
378380 // If this is the last dock area in a dock container with only
@@ -399,7 +401,7 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
399401 return ;
400402 }
401403 else if (d->DockArea ->openDockWidgetsCount () > 1
402- && (ev->pos () - d->DragStartMousePosition ).manhattanLength () >= QApplication::startDragDistance ()) // Wait a few pixels before start moving
404+ && (ev->globalPos () - d->DragStartMousePosition ).manhattanLength () >= QApplication::startDragDistance ()) // Wait a few pixels before start moving
403405 {
404406 // If we start dragging the tab, we save its inital position to
405407 // restore it later
@@ -424,15 +426,15 @@ void CDockWidgetTab::contextMenuEvent(QContextMenuEvent* ev)
424426 return ;
425427 }
426428
427- d->DragStartMousePosition = ev->pos ();
429+ d->DragStartMousePosition = ev->globalPos ();
428430 QMenu Menu (this );
429431 auto Action = Menu.addAction (tr (" Detach" ), this , SLOT (detachDockWidget ()));
430432 Action->setEnabled (d->DockWidget ->features ().testFlag (CDockWidget::DockWidgetFloatable));
431433 Menu.addSeparator ();
432434 Action = Menu.addAction (tr (" Close" ), this , SIGNAL (closeRequested ()));
433435 Action->setEnabled (isClosable ());
434436 Menu.addAction (tr (" Close Others" ), this , SIGNAL (closeOtherTabsRequested ()));
435- Menu.exec (mapToGlobal ( ev->pos () ));
437+ Menu.exec (ev->globalPos ( ));
436438}
437439
438440
@@ -549,7 +551,7 @@ void CDockWidgetTab::mouseDoubleClickEvent(QMouseEvent *event)
549551 if ((!d->DockArea ->dockContainer ()->isFloating () || d->DockArea ->dockWidgetsCount () > 1 )
550552 && d->DockWidget ->features ().testFlag (CDockWidget::DockWidgetFloatable))
551553 {
552- d->DragStartMousePosition = event->pos ();
554+ d->DragStartMousePosition = event->globalPos ();
553555 d->startFloating (DraggingInactive);
554556 }
555557
@@ -587,21 +589,21 @@ void CDockWidgetTab::detachDockWidget()
587589 {
588590 return ;
589591 }
590- d->DragStartMousePosition = mapFromGlobal ( QCursor::pos () );
592+ d->DragStartMousePosition = QCursor::pos ();
591593 d->startFloating (DraggingInactive);
592594}
593595
594596
595597// ============================================================================
596598bool CDockWidgetTab::event (QEvent *e)
597599{
598- #ifndef QT_NO_TOOLTIP
600+ #ifndef QT_NO_TOOLTIP
599601 if (e->type () == QEvent::ToolTipChange)
600602 {
601603 const auto text = toolTip ();
602604 d->TitleLabel ->setToolTip (text);
603605 }
604- #endif
606+ #endif
605607 return Super::event (e);
606608}
607609
0 commit comments