From 5b8702fd557afa9d5e426b669b61ed65d8368da0 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Thu, 3 May 2018 20:17:57 +0300 Subject: 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 Reviewed-by: Gatis Paeglis --- src/plugins/platforms/xcb/qxcbconnection.cpp | 1 + src/plugins/platforms/xcb/qxcbconnection.h | 1 + src/plugins/platforms/xcb/qxcbwindow.cpp | 7 +++++++ 3 files changed, 9 insertions(+) (limited to 'src/plugins/platforms/xcb') diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 0e45b1efaf..52f93b9483 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -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" diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index eb8ec5d7d6..e93159aa80 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -119,6 +119,7 @@ namespace QXcbAtom { WM_CLIENT_LEADER, WM_WINDOW_ROLE, SM_CLIENT_ID, + WM_CLIENT_MACHINE, // Clipboard CLIPBOARD, diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index b5f219c22a..d866ae025f 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -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); -- cgit v1.2.3