From d4197293311b21076bb568cc3d8bded24397eb5f Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Wed, 7 Apr 2021 18:53:09 +0200 Subject: [PATCH] debug_console: Improve rendering of non-x11 clients We'd always get "0x0: something" where the 0x0 is the xcb_window which obviously doesn't translate. Instead show the class name so we can easily track what kind of object we are dealing with. It's an easy way to show which shell it's using on Wayland, will be useful in other cases as well. --- src/debug_console.cpp | 12 +++++++----- src/debug_console.h | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/debug_console.cpp b/src/debug_console.cpp index f981a7fec9..61a1a2b201 100644 --- a/src/debug_console.cpp +++ b/src/debug_console.cpp @@ -1139,14 +1139,14 @@ QVariant DebugConsoleModel::propertyData(QObject *object, const QModelIndex &ind } template -QVariant DebugConsoleModel::clientData(const QModelIndex &index, int role, const QVector clients) const +QVariant DebugConsoleModel::clientData(const QModelIndex &index, int role, const QVector clients, const std::function &toString) const { if (index.row() >= clients.count()) { return QVariant(); } auto c = clients.at(index.row()); if (role == Qt::DisplayRole) { - return QStringLiteral("0x%1: %2").arg(c->window(), 0, 16).arg(c->caption()); + return toString(c); } else if (role == Qt::DecorationRole) { return c->icon(); } @@ -1193,9 +1193,11 @@ QVariant DebugConsoleModel::data(const QModelIndex &index, int role) const if (index.column() != 0) { return QVariant(); } + + auto generic = [] (AbstractClient* c) { return c->caption() + QLatin1Char(' ') + QString::fromUtf8(c->metaObject()->className()); }; switch (index.parent().internalId()) { case s_x11ClientId: - return clientData(index, role, m_x11Clients); + return clientData(index, role, m_x11Clients, [] (X11Client* c) { return QStringLiteral("0x%1: %2").arg(c->window(), 0, 16).arg(c->caption()); }); case s_x11UnmanagedId: { if (index.row() >= m_unmanageds.count()) { return QVariant(); @@ -1207,9 +1209,9 @@ QVariant DebugConsoleModel::data(const QModelIndex &index, int role) const break; } case s_waylandClientId: - return clientData(index, role, m_waylandClients); + return clientData(index, role, m_waylandClients, generic); case s_workspaceInternalId: - return clientData(index, role, m_internalClients); + return clientData(index, role, m_internalClients, generic); default: break; } diff --git a/src/debug_console.h b/src/debug_console.h index dc2822dd5a..fb5533fd79 100644 --- a/src/debug_console.h +++ b/src/debug_console.h @@ -17,6 +17,7 @@ #include #include #include +#include class QTextEdit; @@ -62,7 +63,7 @@ private: int propertyCount(const QModelIndex &parent, T *(DebugConsoleModel::*filter)(const QModelIndex&) const) const; QVariant propertyData(QObject *object, const QModelIndex &index, int role) const; template - QVariant clientData(const QModelIndex &index, int role, const QVector clients) const; + QVariant clientData(const QModelIndex &index, int role, const QVector clients, const std::function &toString) const; template void add(int parentRow, QVector &clients, T *client); template