diff options
author | Shawn Rutledge <shawn.rutledge@digia.com> | 2015-03-02 16:53:33 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@digia.com> | 2015-03-06 19:54:57 +0000 |
commit | 8b0fcd871805465629c006fbf5867e0c8a6fdaf0 (patch) | |
tree | 1eb82693fd69533b18685063e0df2741ce567e8d | |
parent | 653bdcca8e683f5a3d485df885c0bed217a02a6b (diff) |
xcb: implement and deprecate QWidget::setWindowIconText()
This is a little-used feature which only affects how minimized icons
are displayed on certain older window managers, and is not necessary
even then. It has not been implemented in Qt 5 until now.
Task-number: QTBUG-44659
Change-Id: Ie6ead7a6f922878b349a096d905bf7f675dc2f31
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
-rw-r--r-- | src/corelib/kernel/qcoreevent.cpp | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qcoreevent.h | 2 | ||||
-rw-r--r-- | src/platformheaders/xcbfunctions/qxcbwindowfunctions.h | 7 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbnativeinterface.cpp | 3 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.cpp | 20 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.h | 3 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 25 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget.h | 2 | ||||
-rw-r--r-- | tests/manual/qscreen/propertywatcher.cpp | 2 |
9 files changed, 56 insertions, 10 deletions
diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp index b2b22ad99c..0a68de8871 100644 --- a/src/corelib/kernel/qcoreevent.cpp +++ b/src/corelib/kernel/qcoreevent.cpp @@ -150,7 +150,7 @@ QT_BEGIN_NAMESPACE \value HoverLeave The mouse cursor leaves a hover widget (QHoverEvent). \value HoverMove The mouse cursor moves inside a hover widget (QHoverEvent). \value IconDrag The main icon of a window has been dragged away (QIconDragEvent). - \value IconTextChange Widget's icon text has been changed. + \value IconTextChange Widget's icon text has been changed. (Deprecated) \value InputMethod An input method is being used (QInputMethodEvent). \value InputMethodQuery A input method query event (QInputMethodQueryEvent) \value KeyboardLayoutChange The keyboard layout has changed. diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h index c208eb1180..53da4a849b 100644 --- a/src/corelib/kernel/qcoreevent.h +++ b/src/corelib/kernel/qcoreevent.h @@ -133,7 +133,7 @@ public: EnabledChange = 98, // enabled state has changed ActivationChange = 99, // window activation has changed StyleChange = 100, // style has changed - IconTextChange = 101, // icon text has changed + IconTextChange = 101, // icon text has changed. Deprecated. ModifiedChange = 102, // modified state has changed MouseTrackingChange = 109, // mouse tracking state has changed diff --git a/src/platformheaders/xcbfunctions/qxcbwindowfunctions.h b/src/platformheaders/xcbfunctions/qxcbwindowfunctions.h index e07679ddcd..accd64f170 100644 --- a/src/platformheaders/xcbfunctions/qxcbwindowfunctions.h +++ b/src/platformheaders/xcbfunctions/qxcbwindowfunctions.h @@ -69,6 +69,13 @@ public: return QXcbFunctionsHelper::callPlatformFunction<void, SetWmWindowType, QWindow *, WmWindowType>(setWmWindowTypeIdentifier(), window, type); } + typedef void (*SetWmWindowIconText)(QWindow *window, const QString &text); + static const QByteArray setWmWindowIconTextIdentifier() { return QByteArrayLiteral("XcbSetWmWindowIconText"); } + static void setWmWindowIconText(QWindow *window, const QString &text) + { + return QXcbFunctionsHelper::callPlatformFunction<void, SetWmWindowIconText, QWindow *, const QString &>(setWmWindowIconTextIdentifier(), window, text); + } + typedef void (*SetParentRelativeBackPixmap)(const QWindow *window); static const QByteArray setParentRelativeBackPixmapIdentifier() { return QByteArrayLiteral("XcbSetParentRelativeBackPixmap"); } static void setParentRelativeBackPixmap(const QWindow *window) diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index 6cb238228f..c6aa25350d 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -331,6 +331,9 @@ QFunctionPointer QXcbNativeInterface::platformFunction(const QByteArray &functio if (function == QXcbWindowFunctions::setWmWindowTypeIdentifier()) return QFunctionPointer(QXcbWindowFunctions::SetWmWindowType(QXcbWindow::setWmWindowTypeStatic)); + if (function == QXcbWindowFunctions::setWmWindowIconTextIdentifier()) + return QFunctionPointer(QXcbWindowFunctions::SetWmWindowIconText(QXcbWindow::setWindowIconTextStatic)); + if (function == QXcbWindowFunctions::setParentRelativeBackPixmapIdentifier()) return QFunctionPointer(QXcbWindowFunctions::SetParentRelativeBackPixmap(QXcbWindow::setParentRelativeBackPixmapStatic)); diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 222f6c1170..6d2f5276b3 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -1393,10 +1393,22 @@ void QXcbWindow::setWindowTitle(const QString &title) xcb_flush(xcb_connection()); } +void QXcbWindow::setWindowIconText(const QString &title) +{ + const QByteArray ba = title.toUtf8(); + Q_XCB_CALL(xcb_change_property(xcb_connection(), + XCB_PROP_MODE_REPLACE, + m_window, + atom(QXcbAtom::_NET_WM_ICON_NAME), + atom(QXcbAtom::UTF8_STRING), + 8, + ba.length(), + ba.constData())); +} + void QXcbWindow::setWindowIcon(const QIcon &icon) { QVector<quint32> icon_data; - if (!icon.isNull()) { QList<QSize> availableSizes = icon.availableSizes(); if (availableSizes.isEmpty()) { @@ -1561,6 +1573,12 @@ void QXcbWindow::setWmWindowTypeStatic(QWindow *window, QXcbWindowFunctions::WmW window->setProperty(wm_window_type_property_id, QVariant::fromValue(static_cast<int>(windowTypes))); } +void QXcbWindow::setWindowIconTextStatic(QWindow *window, const QString &text) +{ + if (window->handle()) + static_cast<QXcbWindow *>(window->handle())->setWindowIconText(text); +} + QXcbWindowFunctions::WmWindowTypes QXcbWindow::wmWindowTypes() const { QXcbWindowFunctions::WmWindowTypes result(0); diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 20c7d5a7b2..cd3c091973 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -86,6 +86,7 @@ public: QPoint mapFromGlobal(const QPoint &pos) const Q_DECL_OVERRIDE; void setWindowTitle(const QString &title) Q_DECL_OVERRIDE; + void setWindowIconText(const QString &title); void setWindowIcon(const QIcon &icon) Q_DECL_OVERRIDE; void raise() Q_DECL_OVERRIDE; void lower() Q_DECL_OVERRIDE; @@ -142,6 +143,8 @@ public: QXcbWindowFunctions::WmWindowTypes wmWindowTypes() const; void setWmWindowType(QXcbWindowFunctions::WmWindowTypes types); + static void setWindowIconTextStatic(QWindow *window, const QString &text); + static void setParentRelativeBackPixmapStatic(QWindow *window); void setParentRelativeBackPixmap(); diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 65b861bc68..6d8bad3149 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -100,6 +100,7 @@ #include "qwindowcontainer_p.h" +#include <QtPlatformHeaders/qxcbwindowfunctions.h> // widget/widget data creation count //#define QWIDGET_EXTRA_DEBUG @@ -704,7 +705,7 @@ void QWidget::setAutoFillBackground(bool enabled) close(). \row \li Top-level windows \li - \l windowModified, \l windowTitle, \l windowIcon, \l windowIconText, + \l windowModified, \l windowTitle, \l windowIcon, \l isActiveWindow, activateWindow(), \l minimized, showMinimized(), \l maximized, showMaximized(), \l fullScreen, showFullScreen(), showNormal(). @@ -5934,7 +5935,7 @@ void QWidget::unsetLocale() window title, if set. This is done by the QPA plugin, so it is shown to the user, but isn't part of the windowTitle string. - \sa windowIcon, windowIconText, windowModified, windowFilePath + \sa windowIcon, windowModified, windowFilePath */ QString QWidget::windowTitle() const { @@ -6029,7 +6030,11 @@ void QWidgetPrivate::setWindowIconText_helper(const QString &title) void QWidgetPrivate::setWindowIconText_sys(const QString &iconText) { - Q_UNUSED(iconText); + Q_Q(QWidget); + // ### The QWidget property is deprecated, but the XCB window function is not. + // It should remain available for the rare application that needs it. + if (QWindow *window = q->windowHandle()) + QXcbWindowFunctions::setWmWindowIconText(window, iconText); } /*! @@ -6039,6 +6044,9 @@ void QWidgetPrivate::setWindowIconText_sys(const QString &iconText) new \a iconText as an argument. \since 5.2 + \obsolete + + This signal is deprecated. */ void QWidget::setWindowIconText(const QString &iconText) @@ -6089,7 +6097,7 @@ void QWidget::setWindowTitle(const QString &title) has been set, windowIcon() returns the application icon (QApplication::windowIcon()). - \sa windowIconText, windowTitle + \sa windowTitle */ QIcon QWidget::windowIcon() const { @@ -6149,10 +6157,15 @@ void QWidgetPrivate::setWindowIcon_sys() /*! \property QWidget::windowIconText - \brief the widget's icon text + \brief the text to be displayed on the icon of a minimized window This property only makes sense for windows. If no icon - text has been set, this functions returns an empty string. + text has been set, this accessor returns an empty string. + It is only implemented on the X11 platform, and only certain + window managers use this window property. + + \obsolete + This property is deprecated. \sa windowIcon, windowTitle */ diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h index c3913e9d45..d49551f4f4 100644 --- a/src/widgets/kernel/qwidget.h +++ b/src/widgets/kernel/qwidget.h @@ -165,7 +165,7 @@ class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice Q_PROPERTY(bool acceptDrops READ acceptDrops WRITE setAcceptDrops) Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle NOTIFY windowTitleChanged DESIGNABLE isWindow) Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon NOTIFY windowIconChanged DESIGNABLE isWindow) - Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText NOTIFY windowIconTextChanged DESIGNABLE isWindow) + Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText NOTIFY windowIconTextChanged DESIGNABLE isWindow) // deprecated Q_PROPERTY(double windowOpacity READ windowOpacity WRITE setWindowOpacity DESIGNABLE isWindow) Q_PROPERTY(bool windowModified READ isWindowModified WRITE setWindowModified DESIGNABLE isWindow) #ifndef QT_NO_TOOLTIP diff --git a/tests/manual/qscreen/propertywatcher.cpp b/tests/manual/qscreen/propertywatcher.cpp index cfb5ea272d..19668a8d26 100644 --- a/tests/manual/qscreen/propertywatcher.cpp +++ b/tests/manual/qscreen/propertywatcher.cpp @@ -50,6 +50,8 @@ PropertyWatcher::PropertyWatcher(QObject *subject, QString annotation, QWidget * if (prop.isReadable()) { PropertyField* field = new PropertyField(m_subject, prop); m_layout->addRow(prop.name(), field); + if (!qstrcmp(prop.name(), "name")) + setWindowIconText(prop.read(subject).toString()); } } QPushButton *updateButton = new QPushButton("update"); |