xcb: add static overload for setting window name
Change-Id: Ib581a582059e196567514f40b1964696ceaf3a88 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>bb10
parent
06af9a1e38
commit
1acdcdaa4d
|
|
@ -42,6 +42,7 @@
|
|||
#include "qxcbconnection.h"
|
||||
#include "qxcbscreen.h"
|
||||
#include "qxcbmime.h"
|
||||
#include "qxcbwindow.h"
|
||||
|
||||
#include <private/qguiapplication_p.h>
|
||||
#include <QElapsedTimer>
|
||||
|
|
@ -276,18 +277,6 @@ QXcbClipboard::QXcbClipboard(QXcbConnection *c)
|
|||
m_timestamp[QClipboard::Selection] = XCB_CURRENT_TIME;
|
||||
m_owner = connection()->getQtSelectionOwner();
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
QByteArray ba("Qt clipboard window");
|
||||
xcb_change_property(xcb_connection(),
|
||||
XCB_PROP_MODE_REPLACE,
|
||||
m_owner,
|
||||
atom(QXcbAtom::_NET_WM_NAME),
|
||||
atom(QXcbAtom::UTF8_STRING),
|
||||
8,
|
||||
ba.length(),
|
||||
ba.constData());
|
||||
#endif
|
||||
|
||||
if (connection()->hasXFixes()) {
|
||||
const uint32_t mask = XCB_XFIXES_SELECTION_EVENT_MASK_SET_SELECTION_OWNER |
|
||||
XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_WINDOW_DESTROY |
|
||||
|
|
@ -467,17 +456,9 @@ xcb_window_t QXcbClipboard::requestor() const
|
|||
platformScreen->screen()->root_visual, // visual
|
||||
0, // value mask
|
||||
0); // value list
|
||||
#ifndef QT_NO_DEBUG
|
||||
QByteArray ba("Qt clipboard requestor window");
|
||||
xcb_change_property(xcb_connection(),
|
||||
XCB_PROP_MODE_REPLACE,
|
||||
window,
|
||||
atom(QXcbAtom::_NET_WM_NAME),
|
||||
atom(QXcbAtom::UTF8_STRING),
|
||||
8,
|
||||
ba.length(),
|
||||
ba.constData());
|
||||
#endif
|
||||
|
||||
QXcbWindow::setWindowTitle(connection(), window,
|
||||
QStringLiteral("Qt Clipboard Requestor Window"));
|
||||
|
||||
uint32_t mask = XCB_EVENT_MASK_PROPERTY_CHANGE;
|
||||
xcb_change_window_attributes(xcb_connection(), window, XCB_CW_EVENT_MASK, &mask);
|
||||
|
|
|
|||
|
|
@ -1552,6 +1552,9 @@ xcb_window_t QXcbConnection::getQtSelectionOwner()
|
|||
xcbScreen->root_visual, // visual
|
||||
0, // value mask
|
||||
0); // value list
|
||||
|
||||
QXcbWindow::setWindowTitle(connection(), m_qtSelectionOwner,
|
||||
QStringLiteral("Qt Selection Window"));
|
||||
}
|
||||
return m_qtSelectionOwner;
|
||||
}
|
||||
|
|
@ -1576,17 +1579,11 @@ xcb_window_t QXcbConnection::clientLeader()
|
|||
XCB_WINDOW_CLASS_INPUT_OUTPUT,
|
||||
screen->screen()->root_visual,
|
||||
0, 0);
|
||||
#ifndef QT_NO_DEBUG
|
||||
QByteArray ba("Qt client leader window");
|
||||
xcb_change_property(xcb_connection(),
|
||||
XCB_PROP_MODE_REPLACE,
|
||||
m_clientLeader,
|
||||
atom(QXcbAtom::_NET_WM_NAME),
|
||||
atom(QXcbAtom::UTF8_STRING),
|
||||
8,
|
||||
ba.length(),
|
||||
ba.constData());
|
||||
#endif
|
||||
|
||||
|
||||
QXcbWindow::setWindowTitle(connection(), m_clientLeader,
|
||||
QStringLiteral("Qt Client Leader Window"));
|
||||
|
||||
xcb_change_property(xcb_connection(),
|
||||
XCB_PROP_MODE_REPLACE,
|
||||
m_clientLeader,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -182,6 +182,7 @@ public:
|
|||
virtual void create();
|
||||
virtual void destroy();
|
||||
|
||||
static void setWindowTitle(const QXcbConnection *conn, xcb_window_t window, const QString &title);
|
||||
static QString windowTitle(const QXcbConnection *conn, xcb_window_t window);
|
||||
|
||||
public Q_SLOTS:
|
||||
|
|
|
|||
Loading…
Reference in New Issue