Skip to content

Instantly share code, notes, and snippets.

@jgriffiths
Created February 27, 2016 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgriffiths/1fb536c6d64d00095f62 to your computer and use it in GitHub Desktop.
Save jgriffiths/1fb536c6d64d00095f62 to your computer and use it in GitHub Desktop.
KWin: Show Qubes VM name as suffix
diff --git a/atoms.cpp b/atoms.cpp
index 55a8aa3..f5432a4 100644
--- a/atoms.cpp
+++ b/atoms.cpp
@@ -59,6 +59,7 @@ Atoms::Atoms()
, kwin_dbus_service(QByteArrayLiteral("_ORG_KDE_KWIN_DBUS_SERVICE"))
, utf8_string(QByteArrayLiteral("UTF8_STRING"))
, wl_surface_id(QByteArrayLiteral("WL_SURFACE_ID"))
+ , qubes_vm_name(QByteArrayLiteral("_QUBES_VMNAME"))
, m_dtSmWindowInfo(QByteArrayLiteral("_DT_SM_WINDOW_INFO"))
, m_motifSupport(QByteArrayLiteral("_MOTIF_WM_INFO"))
, m_helpersRetrieved(false)
diff --git a/atoms.h b/atoms.h
index f265cee..2dffb83 100644
--- a/atoms.h
+++ b/atoms.h
@@ -68,6 +68,7 @@ public:
Xcb::Atom kwin_dbus_service;
Xcb::Atom utf8_string;
Xcb::Atom wl_surface_id;
+ Xcb::Atom qubes_vm_name;
/**
* @internal
diff --git a/client.cpp b/client.cpp
index cb8dbf1..8d0abbc 100644
--- a/client.cpp
+++ b/client.cpp
@@ -1479,6 +1479,16 @@ void Client::setCaption(const QString& _s, bool force)
}
QString shortcut_suffix = !shortcut().isEmpty() ? (QLatin1String(" {") + shortcut().toString() + QLatin1Char('}')) : QString();
cap_suffix = machine_suffix + shortcut_suffix;
+
+ // Qubes: Append the VM name if this isn't a dom0 window
+ QString vm = QString::fromUtf8(Xcb::StringProperty(m_client, atoms->qubes_vm_name));
+ if (!vm.isEmpty()) {
+ if (!cap_suffix.isEmpty()) {
+ cap_suffix += QLatin1String(" ");
+ }
+ cap_suffix += vm;
+ }
+
auto fetchNameInternalPredicate = [this](const Client *cl) {
return (!cl->isSpecialWindow() || cl->isToolbar()) &&
cl != this && cl->caption() == caption();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment