summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2012-11-13 14:10:32 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-15 10:56:52 +0100
commit90de0c417883aa515a694fa56b0e84c8969971fe (patch)
tree76e408cc36fda6c7af8c3c31548ba18f1d586e51 /src/widgets
parentaa309b967745506c5221e4d26e312ee492172059 (diff)
Fix mouse cursor behavior for QMainWindow splitters
The cursor handling has changed in Qt5 somewhat, which made old cursor logic for splitters invalid, causing the splitter resize cursor to persist after hovering over splitter, as well as cursor flicker during splitter drag. Since the cursor is changed always in dispatchEnterLeave, CursorChange event can now come for QMainWindow when cursor hasn't actually changed, so we now check if the cursor is still our adjusted cursor before updating the old stored cursor. We also ensure that our adjusted cursor stays visible if cursor is in fact changed - the changed cursor will be shown when we no longer need adjusted cursor. Additionally, we skip cursor adjustments while we are dragging the splitter to avoid cursor flicker, which is caused by splitter actually moving asynchronously after the mouse event is handled. Task-number: QTBUG-27970 Change-Id: Id9f6a0e9653563e09b883f21396de056a88f78a7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/widgets/qmainwindow.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index 93492bab61..056e2cbacc 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -100,6 +100,7 @@ public:
QCursor separatorCursor(const QList<int> &path) const;
void adjustCursor(const QPoint &pos);
QCursor oldCursor;
+ QCursor adjustedCursor;
uint hasOldCursor : 1;
uint cursorAdjusted : 1;
#endif
@@ -1300,7 +1301,7 @@ void QMainWindowPrivate::adjustCursor(const QPoint &pos)
else
q->unsetCursor();
}
- } else {
+ } else if (layout->movingSeparator.isEmpty()) { // Don't change cursor when moving separator
QList<int> pathToSeparator
= layout->layoutState.dockAreaLayout.findSeparator(pos);
@@ -1324,9 +1325,8 @@ void QMainWindowPrivate::adjustCursor(const QPoint &pos)
oldCursor = q->cursor();
hasOldCursor = q->testAttribute(Qt::WA_SetCursor);
}
- QCursor cursor = separatorCursor(hoverSeparator);
- cursorAdjusted = false; //to not reset the oldCursor in event(CursorChange)
- q->setCursor(cursor);
+ adjustedCursor = separatorCursor(hoverSeparator);
+ q->setCursor(adjustedCursor);
cursorAdjusted = true;
}
}
@@ -1452,9 +1452,15 @@ bool QMainWindow::event(QEvent *event)
#endif // Q_WS_MAC
#if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR)
case QEvent::CursorChange:
- if (d->cursorAdjusted) {
+ // CursorChange events are triggered as mouse moves to new widgets even
+ // if the cursor doesn't actually change, so do not change oldCursor if
+ // the "changed" cursor has same shape as adjusted cursor.
+ if (d->cursorAdjusted && d->adjustedCursor.shape() != cursor().shape()) {
d->oldCursor = cursor();
d->hasOldCursor = testAttribute(Qt::WA_SetCursor);
+
+ // Ensure our adjusted cursor stays visible
+ setCursor(d->adjustedCursor);
}
break;
#endif