summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qwidget_qpa.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2013-01-14 10:00:12 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-21 21:50:45 +0100
commitc24a7377dd9cfb503b43ef3f5a2d5cac9a4e1b8c (patch)
tree6b1edaa34485618cc1bec879899a8eadffe2bd2a /src/widgets/kernel/qwidget_qpa.cpp
parent1029049e1d8aa84f19fe344e605849c36522a97f (diff)
Regression: Fix setting of custom cursors for native widgets.
Currently, there is no concept of not having a cursor set on a Window. Qt::ArrowCursor is always set instead. This causes bugs when native child widgets are involved, for example setting a cursor on the native widget's parent no longer works since the child's Qt::ArrowCursor applies. Introduce QWindowPrivate::hasCursor tracking whether a cursor has been explicitly set and clear in QWindow::unsetCursor(). Handle 0 in QPlatformCursor::changeCursor() to mean "unsetCursor()": - Windows: Introduce default constructor for QWindowsWindowCursor meaning "0". Search for applicable parent cursor in applyCursor. - XCB: No big changes required, set XCB_CURSOR_NONE for no cursor. - Other platforms: Assume Qt::ArrowCursor when cursor = 0 is passed for now. Task-number: QTBUG-28879 Change-Id: Id82722592f3cd5fe577a5b64dcc600c85cfea484 Reviewed-by: Jonathan Liu <net147@gmail.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com> Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Diffstat (limited to 'src/widgets/kernel/qwidget_qpa.cpp')
-rw-r--r--src/widgets/kernel/qwidget_qpa.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp
index 2aee80ade4..2c2d912009 100644
--- a/src/widgets/kernel/qwidget_qpa.cpp
+++ b/src/widgets/kernel/qwidget_qpa.cpp
@@ -999,6 +999,12 @@ static inline void applyCursor(QWidget *w, QCursor c)
window->setCursor(c);
}
+static inline void unsetCursor(QWidget *w)
+{
+ if (QWindow *window = w->windowHandle())
+ window->unsetCursor();
+}
+
void qt_qpa_set_cursor(QWidget *w, bool force)
{
if (!w->testAttribute(Qt::WA_WState_Created))
@@ -1032,9 +1038,9 @@ void qt_qpa_set_cursor(QWidget *w, bool force)
else
// Enforce the windows behavior of clearing the cursor on
// disabled widgets.
- applyCursor(nativeParent, Qt::ArrowCursor);
+ unsetCursor(nativeParent);
} else {
- applyCursor(nativeParent, Qt::ArrowCursor);
+ unsetCursor(nativeParent);
}
}
#endif //QT_NO_CURSOR