diff options
author | Gatis Paeglis <gatis.paeglis@qt.io> | 2018-05-06 16:39:44 +0200 |
---|---|---|
committer | Gatis Paeglis <gatis.paeglis@qt.io> | 2018-06-22 19:50:42 +0000 |
commit | 1acdcdaa4d9c4b6bf86b50ada8a7b194d86f1e4c (patch) | |
tree | 900a2d33723992714d0c92000419b35ada9da36c /src/plugins/platforms/xcb/qxcbwindow.cpp | |
parent | 06af9a1e3891751d89a64e9013e204176c28ebdc (diff) |
xcb: add static overload for setting window name
Change-Id: Ib581a582059e196567514f40b1964696ceaf3a88
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbwindow.cpp')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.cpp | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 4988ed9657..d201dc59d6 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -1360,17 +1360,10 @@ void QXcbWindow::updateNetWmUserTime(xcb_timestamp_t timestamp) xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::_NET_WM_USER_TIME_WINDOW), XCB_ATOM_WINDOW, 32, 1, &m_netWmUserTimeWindow); xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_NET_WM_USER_TIME)); -#ifndef QT_NO_DEBUG - QByteArray ba("Qt NET_WM user time window"); - xcb_change_property(xcb_connection(), - XCB_PROP_MODE_REPLACE, - m_netWmUserTimeWindow, - atom(QXcbAtom::_NET_WM_NAME), - atom(QXcbAtom::UTF8_STRING), - 8, - ba.length(), - ba.constData()); -#endif + + QXcbWindow::setWindowTitle(connection(), m_netWmUserTimeWindow, + QStringLiteral("Qt NET_WM User Time Window")); + } else if (!isSupportedByWM) { // WM no longer supports it, then we should remove the // _NET_WM_USER_TIME_WINDOW atom. @@ -1448,24 +1441,7 @@ void QXcbWindow::setParent(const QPlatformWindow *parent) void QXcbWindow::setWindowTitle(const QString &title) { - QString fullTitle = formatWindowTitle(title, QString::fromUtf8(" \xe2\x80\x94 ")); // unicode character U+2014, EM DASH - const QByteArray ba = std::move(fullTitle).toUtf8(); - xcb_change_property(xcb_connection(), - XCB_PROP_MODE_REPLACE, - m_window, - atom(QXcbAtom::_NET_WM_NAME), - atom(QXcbAtom::UTF8_STRING), - 8, - ba.length(), - ba.constData()); - -#if QT_CONFIG(xcb_xlib) - Display *dpy = static_cast<Display *>(connection()->xlib_display()); - XTextProperty *text = qstringToXTP(dpy, title); - if (text) - XSetWMName(dpy, m_window, text); -#endif - xcb_flush(xcb_connection()); + setWindowTitle(connection(), m_window, title); } void QXcbWindow::setWindowIconText(const QString &title) @@ -2829,6 +2805,28 @@ QXcbScreen *QXcbWindow::xcbScreen() const return static_cast<QXcbScreen *>(screen()); } +void QXcbWindow::setWindowTitle(const QXcbConnection *conn, xcb_window_t window, const QString &title) +{ + QString fullTitle = formatWindowTitle(title, QString::fromUtf8(" \xe2\x80\x94 ")); // unicode character U+2014, EM DASH + const QByteArray ba = std::move(fullTitle).toUtf8(); + xcb_change_property(conn->xcb_connection(), + XCB_PROP_MODE_REPLACE, + window, + conn->atom(QXcbAtom::_NET_WM_NAME), + conn->atom(QXcbAtom::UTF8_STRING), + 8, + ba.length(), + ba.constData()); + +#if QT_CONFIG(xcb_xlib) + Display *dpy = static_cast<Display *>(conn->xlib_display()); + XTextProperty *text = qstringToXTP(dpy, title); + if (text) + XSetWMName(dpy, window, text); +#endif + xcb_flush(conn->xcb_connection()); +} + QString QXcbWindow::windowTitle(const QXcbConnection *conn, xcb_window_t window) { const xcb_atom_t utf8Atom = conn->atom(QXcbAtom::UTF8_STRING); |