diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 34 | ||||
-rw-r--r-- | src/gui/kernel/qwindow_p.h | 3 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget_qpa.cpp | 3 |
3 files changed, 25 insertions, 15 deletions
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 27e1571184..39a6603c4b 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -286,6 +286,10 @@ void QWindow::setVisible(bool visible) QGuiApplicationPrivate::hideModalWindow(this); } +#ifndef QT_NO_CURSOR + if (visible) + d->applyCursor(); +#endif d->platformWindow->setVisible(visible); if (!visible) { @@ -1853,11 +1857,10 @@ QCursor QWindow::cursor() const void QWindow::setCursor(const QCursor &cursor) { Q_D(QWindow); - if (QPlatformCursor *platformCursor = d->screen->handle()->cursor()) { - d->cursor = cursor; - QCursor *oc = QGuiApplication::overrideCursor(); - QCursor c = oc ? *oc : d->cursor; - platformCursor->changeCursor(&c, this); + d->cursor = cursor; + // Only attempt to set cursor and emit signal if there is an actual platform cursor + if (d->screen->handle()->cursor()) { + d->applyCursor(); QEvent event(QEvent::CursorChange); QGuiApplication::sendEvent(this, &event); } @@ -1868,19 +1871,20 @@ void QWindow::setCursor(const QCursor &cursor) */ void QWindow::unsetCursor() { - Q_D(QWindow); - if (QPlatformCursor *platformCursor = d->screen->handle()->cursor()) { - d->cursor = Qt::ArrowCursor; - QCursor *oc = QGuiApplication::overrideCursor(); - if (!oc) { - QCursor c = d->cursor; - platformCursor->changeCursor(&c, this); + setCursor(Qt::ArrowCursor); +} + +void QWindowPrivate::applyCursor() +{ + Q_Q(QWindow); + if (platformWindow) { + if (QPlatformCursor *platformCursor = screen->handle()->cursor()) { + QCursor *oc = QGuiApplication::overrideCursor(); + QCursor c = oc ? *oc : cursor; + platformCursor->changeCursor(&c, q); } - QEvent event(QEvent::CursorChange); - QGuiApplication::sendEvent(this, &event); } } - #endif QT_END_NAMESPACE diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h index 57f79f1faa..159f05d1a5 100644 --- a/src/gui/kernel/qwindow_p.h +++ b/src/gui/kernel/qwindow_p.h @@ -97,6 +97,9 @@ public: } void maybeQuitOnLastWindowClosed(); +#ifndef QT_NO_CURSOR + void applyCursor(); +#endif QPoint globalPosition() const { Q_Q(const QWindow); diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index 86d8da254a..e7564261f9 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -547,6 +547,9 @@ void QWidgetPrivate::show_sys() } } +#ifndef QT_NO_CURSOR + qt_qpa_set_cursor(q, false); // Needed in case cursor was set before show +#endif invalidateBuffer(q->rect()); window->setVisible(true); } |