From: Miikka Heikkinen Date: Wed, 3 Oct 2012 09:06:14 +0000 (+0300) Subject: Show widget cursor after restoring last override cursor X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8547205fe882819af9eb4cdd024404ab3b9ad0dc;p=profile%2Fivi%2Fqtbase.git 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 --- diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 7e7997d..84f22de 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -2328,6 +2328,15 @@ static inline void applyCursor(const QList &l, const QCursor &c) } } +static inline void applyWindowCursor(const QList &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 diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index c6680ea..86d8da2 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -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