xcb: Set WM_CLIENT_MACHINE property

It can be useful to detect that a window belongs to an
application running on a remote host. E.g. a window manager
may display the name of the remote host in the window title.
Or it can detect whether a client can be killed.

This property is set by Xlib's function XSetWMProperties(),
which is called by GTK and Qt 4, so it's also good to do
for consistency.

Change-Id: I0693156635cb2696b2fbe7006cbecb25d2680513
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
bb10
Alexander Volkov 2018-05-03 20:17:57 +03:00
parent 17e29fada4
commit 5b8702fd55
3 changed files with 9 additions and 0 deletions

View File

@ -1821,6 +1821,7 @@ static const char * xcb_atomnames = {
"WM_CLIENT_LEADER\0"
"WM_WINDOW_ROLE\0"
"SM_CLIENT_ID\0"
"WM_CLIENT_MACHINE\0"
// Clipboard
"CLIPBOARD\0"

View File

@ -119,6 +119,7 @@ namespace QXcbAtom {
WM_CLIENT_LEADER,
WM_WINDOW_ROLE,
SM_CLIENT_ID,
WM_CLIENT_MACHINE,
// Clipboard
CLIPBOARD,

View File

@ -490,6 +490,13 @@ void QXcbWindow::create()
atom(QXcbAtom::_NET_WM_PID), XCB_ATOM_CARDINAL, 32,
1, &pid);
const QByteArray clientMachine = QSysInfo::machineHostName().toLocal8Bit();
if (!clientMachine.isEmpty()) {
xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window,
atom(QXcbAtom::WM_CLIENT_MACHINE), XCB_ATOM_STRING, 8,
clientMachine.size(), clientMachine.constData());
}
xcb_wm_hints_t hints;
memset(&hints, 0, sizeof(hints));
xcb_wm_hints_set_normal(&hints);