xcb: set WM_NAME window property
Some older window managers and utilities still ignore _NET_WM_NAME. Task-number: QTBUG-42209 Change-Id: Iff93c8188a0a73b04cdf361add153cd818ac670f Reviewed-by: Uli Schlachter <psychon@znc.in> Reviewed-by: Martin Gräßlin <mgraesslin@kde.org> Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>bb10
parent
be242ed094
commit
641b8d2b84
|
|
@ -1480,6 +1480,7 @@ static const char * xcb_atomnames = {
|
|||
"WM_STATE\0"
|
||||
"WM_CHANGE_STATE\0"
|
||||
"WM_CLASS\0"
|
||||
"WM_NAME\0"
|
||||
|
||||
// Session management
|
||||
"WM_CLIENT_LEADER\0"
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ namespace QXcbAtom {
|
|||
WM_STATE,
|
||||
WM_CHANGE_STATE,
|
||||
WM_CLASS,
|
||||
WM_NAME,
|
||||
|
||||
// Session management
|
||||
WM_CLIENT_LEADER,
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@
|
|||
#include <qpa/qplatformbackingstore.h>
|
||||
#include <qpa/qwindowsysteminterface.h>
|
||||
|
||||
#include <QTextCodec>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef XCB_USE_XLIB
|
||||
|
|
@ -243,6 +244,48 @@ static inline bool positionIncludesFrame(QWindow *w)
|
|||
return qt_window_private(w)->positionPolicy == QWindowPrivate::WindowFrameInclusive;
|
||||
}
|
||||
|
||||
#ifdef XCB_USE_XLIB
|
||||
static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s)
|
||||
{
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
static XTextProperty tp = { 0, 0, 0, 0 };
|
||||
static bool free_prop = true; // we can't free tp.value in case it references
|
||||
// the data of the static QByteArray below.
|
||||
if (tp.value) {
|
||||
if (free_prop)
|
||||
XFree(tp.value);
|
||||
tp.value = 0;
|
||||
free_prop = true;
|
||||
}
|
||||
|
||||
static const QTextCodec* mapper = QTextCodec::codecForLocale();
|
||||
int errCode = 0;
|
||||
if (mapper) {
|
||||
QByteArray mapped = mapper->fromUnicode(s);
|
||||
char* tl[2];
|
||||
tl[0] = mapped.data();
|
||||
tl[1] = 0;
|
||||
errCode = XmbTextListToTextProperty(dpy, tl, 1, XStdICCTextStyle, &tp);
|
||||
if (errCode < 0)
|
||||
qDebug("XmbTextListToTextProperty result code %d", errCode);
|
||||
}
|
||||
if (!mapper || errCode < 0) {
|
||||
mapper = QTextCodec::codecForName("latin1");
|
||||
if (!mapper || !mapper->canEncode(s))
|
||||
return Q_NULLPTR;
|
||||
static QByteArray qcs;
|
||||
qcs = s.toLatin1();
|
||||
tp.value = (uchar*)qcs.data();
|
||||
tp.encoding = XA_STRING;
|
||||
tp.format = 8;
|
||||
tp.nitems = qcs.length();
|
||||
free_prop = false;
|
||||
}
|
||||
return &tp;
|
||||
}
|
||||
#endif // XCB_USE_XLIB
|
||||
|
||||
static const char *wm_window_type_property_id = "_q_xcb_wm_window_type";
|
||||
|
||||
QXcbWindow::QXcbWindow(QWindow *window)
|
||||
|
|
@ -1423,6 +1466,12 @@ void QXcbWindow::setWindowTitle(const QString &title)
|
|||
8,
|
||||
ba.length(),
|
||||
ba.constData()));
|
||||
|
||||
#ifdef XCB_USE_XLIB
|
||||
XTextProperty *text = qstringToXTP(DISPLAY_FROM_XCB(this), title);
|
||||
if (text)
|
||||
XSetWMName(DISPLAY_FROM_XCB(this), m_window, text);
|
||||
#endif
|
||||
xcb_flush(xcb_connection());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue