Show widget cursor after restoring last override cursor
qwidget_qpa.cpp was setting cursor directly to platform window, so QWindow didn't actually know what cursor was supposed to be shown. Since QWindow now supports setting cursor and has override cursor handling there, set cursor via QWindow instead of platform window. Also changed QGuiApplication override cursor handling so that it will query the cursor from QWindow if there is no override cursor. With these changes, widget's custom cursor will be properly shown when final override cursor is restored. Task-number: QTBUG-24674 Change-Id: I2d2bb1027779256f9d6de560b6533f45e205ffe9 Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>bb10
parent
b4bf76fffc
commit
8547205fe8
|
|
@ -2328,6 +2328,15 @@ static inline void applyCursor(const QList<QWindow *> &l, const QCursor &c)
|
|||
}
|
||||
}
|
||||
|
||||
static inline void applyWindowCursor(const QList<QWindow *> &l)
|
||||
{
|
||||
for (int i = 0; i < l.size(); ++i) {
|
||||
QWindow *w = l.at(i);
|
||||
if (w->handle() && w->windowType() != Qt::Desktop)
|
||||
applyCursor(w, w->cursor());
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void QGuiApplication::setOverrideCursor(const QCursor &cursor)
|
||||
|
||||
|
|
@ -2376,8 +2385,12 @@ void QGuiApplication::restoreOverrideCursor()
|
|||
if (qGuiApp->d_func()->cursor_list.isEmpty())
|
||||
return;
|
||||
qGuiApp->d_func()->cursor_list.removeFirst();
|
||||
QCursor c(qGuiApp->d_func()->cursor_list.value(0, QCursor()));
|
||||
applyCursor(QGuiApplicationPrivate::window_list, c);
|
||||
if (qGuiApp->d_func()->cursor_list.size() > 0) {
|
||||
QCursor c(qGuiApp->d_func()->cursor_list.value(0));
|
||||
applyCursor(QGuiApplicationPrivate::window_list, c);
|
||||
} else {
|
||||
applyWindowCursor(QGuiApplicationPrivate::window_list);
|
||||
}
|
||||
}
|
||||
#endif// QT_NO_CURSOR
|
||||
|
||||
|
|
|
|||
|
|
@ -1064,9 +1064,7 @@ void QWidgetPrivate::setModal_sys()
|
|||
static inline void applyCursor(QWidget *w, QCursor c)
|
||||
{
|
||||
if (QWindow *window = w->windowHandle())
|
||||
if (const QScreen *screen = window->screen())
|
||||
if (QPlatformCursor *cursor = screen->handle()->cursor())
|
||||
cursor->changeCursor(&c, window);
|
||||
window->setCursor(c);
|
||||
}
|
||||
|
||||
void qt_qpa_set_cursor(QWidget *w, bool force)
|
||||
|
|
@ -1097,10 +1095,7 @@ void qt_qpa_set_cursor(QWidget *w, bool force)
|
|||
return;
|
||||
|
||||
if (w->isWindow() || w->testAttribute(Qt::WA_SetCursor)) {
|
||||
QCursor *oc = QApplication::overrideCursor();
|
||||
if (oc)
|
||||
applyCursor(nativeParent, *oc);
|
||||
else if (w->isEnabled())
|
||||
if (w->isEnabled())
|
||||
applyCursor(nativeParent, w->cursor());
|
||||
else
|
||||
// Enforce the windows behavior of clearing the cursor on
|
||||
|
|
|
|||
Loading…
Reference in New Issue