Skip to content

Commit

Permalink
Gui: fix dockable widget titlebar drag bypass
Browse files Browse the repository at this point in the history
Holding Shift key while dragging a non-overlay dock widget is suppose to
bypass customized drag and drop handling, and let QDockWidget handle it.
  • Loading branch information
realthunder committed Apr 1, 2022
1 parent 4085521 commit 94d3145
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Gui/OverlayWidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2045,6 +2045,15 @@ isNear(const QPoint &a, const QPoint &b, int tol = 16)

void OverlayTitleBar::mouseMoveEvent(QMouseEvent *me)
{
if (ignoreMouse) {
if (!(me->buttons() & Qt::LeftButton))
ignoreMouse = false;
else {
me->ignore();
return;
}
}

if (_Dragging != this && mouseMovePending && (me->buttons() & Qt::LeftButton)) {
if (isNear(dragOffset, me->pos()))
return;
Expand Down Expand Up @@ -2081,6 +2090,7 @@ void OverlayTitleBar::mousePressEvent(QMouseEvent *me)
OverlayTabWidget *tabWidget = qobject_cast<OverlayTabWidget*>(parent);
if (!tabWidget) {
if(QApplication::queryKeyboardModifiers() == Qt::ShiftModifier) {
ignoreMouse = true;
me->ignore();
return;
}
Expand All @@ -2099,7 +2109,7 @@ void OverlayTitleBar::mousePressEvent(QMouseEvent *me)
}
}
}

ignoreMouse = false;
QSize mwSize = getMainWindow()->size();
dragSize.setWidth(std::max(_MinimumOverlaySize,
std::min(mwSize.width()/2, dragSize.width())));
Expand All @@ -2113,6 +2123,11 @@ void OverlayTitleBar::mousePressEvent(QMouseEvent *me)

void OverlayTitleBar::mouseReleaseEvent(QMouseEvent *me)
{
if (ignoreMouse) {
me->ignore();
return;
}

setCursor(Qt::OpenHandCursor);
mouseMovePending = false;
if (_Dragging != this)
Expand Down
1 change: 1 addition & 0 deletions src/Gui/OverlayWidgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ class OverlayTitleBar: public QWidget
int timerId = 0;
bool blink = false;
bool mouseMovePending = false;
bool ignoreMouse = false;
};

class OverlaySizeGrip: public QWidget
Expand Down

0 comments on commit 94d3145

Please sign in to comment.