Changeset View
Changeset View
Standalone View
Standalone View
debug_console.cpp
Show All 18 Lines | |||||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "debug_console.h" | 20 | #include "debug_console.h" | ||
21 | #include "composite.h" | 21 | #include "composite.h" | ||
22 | #include "x11client.h" | 22 | #include "x11client.h" | ||
23 | #include "input_event.h" | 23 | #include "input_event.h" | ||
24 | #include "internal_client.h" | 24 | #include "internal_client.h" | ||
25 | #include "main.h" | 25 | #include "main.h" | ||
26 | #include "scene.h" | 26 | #include "scene.h" | ||
27 | #include "xdgshellclient.h" | | |||
28 | #include "unmanaged.h" | 27 | #include "unmanaged.h" | ||
29 | #include "wayland_server.h" | 28 | #include "wayland_server.h" | ||
30 | #include "workspace.h" | 29 | #include "workspace.h" | ||
31 | #include "keyboard_input.h" | 30 | #include "keyboard_input.h" | ||
32 | #include "libinput/connection.h" | 31 | #include "libinput/connection.h" | ||
33 | #include "libinput/device.h" | 32 | #include "libinput/device.h" | ||
34 | #include <kwinglplatform.h> | 33 | #include <kwinglplatform.h> | ||
35 | #include <kwinglutils.h> | 34 | #include <kwinglutils.h> | ||
▲ Show 20 Lines • Show All 835 Lines • ▼ Show 20 Line(s) | |||||
871 | } | 870 | } | ||
872 | 871 | | |||
873 | DebugConsoleModel::DebugConsoleModel(QObject *parent) | 872 | DebugConsoleModel::DebugConsoleModel(QObject *parent) | ||
874 | : QAbstractItemModel(parent) | 873 | : QAbstractItemModel(parent) | ||
875 | { | 874 | { | ||
876 | if (waylandServer()) { | 875 | if (waylandServer()) { | ||
877 | const auto clients = waylandServer()->clients(); | 876 | const auto clients = waylandServer()->clients(); | ||
878 | for (auto c : clients) { | 877 | for (auto c : clients) { | ||
879 | m_shellClients.append(c); | 878 | m_waylandClients.append(c); | ||
880 | } | 879 | } | ||
881 | // TODO: that only includes windows getting shown, not those which are only created | 880 | // TODO: that only includes windows getting shown, not those which are only created | ||
882 | connect(waylandServer(), &WaylandServer::shellClientAdded, this, | 881 | connect(waylandServer(), &WaylandServer::shellClientAdded, this, | ||
883 | [this] (XdgShellClient *c) { | 882 | [this] (AbstractClient *c) { | ||
884 | add(s_waylandClientId -1, m_shellClients, c); | 883 | add(s_waylandClientId -1, m_waylandClients, c); | ||
885 | } | 884 | } | ||
886 | ); | 885 | ); | ||
887 | connect(waylandServer(), &WaylandServer::shellClientRemoved, this, | 886 | connect(waylandServer(), &WaylandServer::shellClientRemoved, this, | ||
888 | [this] (XdgShellClient *c) { | 887 | [this] (AbstractClient *c) { | ||
889 | remove(s_waylandClientId -1, m_shellClients, c); | 888 | remove(s_waylandClientId -1, m_waylandClients, c); | ||
890 | } | 889 | } | ||
891 | ); | 890 | ); | ||
892 | } | 891 | } | ||
893 | const auto x11Clients = workspace()->clientList(); | 892 | const auto x11Clients = workspace()->clientList(); | ||
894 | for (auto c : x11Clients) { | 893 | for (auto c : x11Clients) { | ||
895 | m_x11Clients.append(c); | 894 | m_x11Clients.append(c); | ||
896 | } | 895 | } | ||
897 | const auto x11DesktopClients = workspace()->desktopList(); | 896 | const auto x11DesktopClients = workspace()->desktopList(); | ||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | 967 | { | |||
971 | } | 970 | } | ||
972 | 971 | | |||
973 | switch (parent.internalId()) { | 972 | switch (parent.internalId()) { | ||
974 | case s_x11ClientId: | 973 | case s_x11ClientId: | ||
975 | return m_x11Clients.count(); | 974 | return m_x11Clients.count(); | ||
976 | case s_x11UnmanagedId: | 975 | case s_x11UnmanagedId: | ||
977 | return m_unmanageds.count(); | 976 | return m_unmanageds.count(); | ||
978 | case s_waylandClientId: | 977 | case s_waylandClientId: | ||
979 | return m_shellClients.count(); | 978 | return m_waylandClients.count(); | ||
980 | case s_workspaceInternalId: | 979 | case s_workspaceInternalId: | ||
981 | return m_internalClients.count(); | 980 | return m_internalClients.count(); | ||
982 | default: | 981 | default: | ||
983 | break; | 982 | break; | ||
984 | } | 983 | } | ||
985 | 984 | | |||
986 | if (parent.internalId() & s_propertyBitMask) { | 985 | if (parent.internalId() & s_propertyBitMask) { | ||
987 | // properties do not have children | 986 | // properties do not have children | ||
988 | return 0; | 987 | return 0; | ||
989 | } | 988 | } | ||
990 | 989 | | |||
991 | if (parent.internalId() < s_idDistance * (s_x11ClientId + 1)) { | 990 | if (parent.internalId() < s_idDistance * (s_x11ClientId + 1)) { | ||
992 | return propertyCount(parent, &DebugConsoleModel::x11Client); | 991 | return propertyCount(parent, &DebugConsoleModel::x11Client); | ||
993 | } else if (parent.internalId() < s_idDistance * (s_x11UnmanagedId + 1)) { | 992 | } else if (parent.internalId() < s_idDistance * (s_x11UnmanagedId + 1)) { | ||
994 | return propertyCount(parent, &DebugConsoleModel::unmanaged); | 993 | return propertyCount(parent, &DebugConsoleModel::unmanaged); | ||
995 | } else if (parent.internalId() < s_idDistance * (s_waylandClientId + 1)) { | 994 | } else if (parent.internalId() < s_idDistance * (s_waylandClientId + 1)) { | ||
996 | return propertyCount(parent, &DebugConsoleModel::shellClient); | 995 | return propertyCount(parent, &DebugConsoleModel::waylandClient); | ||
997 | } else if (parent.internalId() < s_idDistance * (s_workspaceInternalId + 1)) { | 996 | } else if (parent.internalId() < s_idDistance * (s_workspaceInternalId + 1)) { | ||
998 | return propertyCount(parent, &DebugConsoleModel::internalClient); | 997 | return propertyCount(parent, &DebugConsoleModel::internalClient); | ||
999 | } | 998 | } | ||
1000 | 999 | | |||
1001 | return 0; | 1000 | return 0; | ||
1002 | } | 1001 | } | ||
1003 | 1002 | | |||
1004 | template <class T> | 1003 | template <class T> | ||
Show All 35 Lines | 1028 | { | |||
1040 | } | 1039 | } | ||
1041 | // index for a client (second level) | 1040 | // index for a client (second level) | ||
1042 | switch (parent.internalId()) { | 1041 | switch (parent.internalId()) { | ||
1043 | case s_x11ClientId: | 1042 | case s_x11ClientId: | ||
1044 | return indexForClient(row, column, m_x11Clients, s_x11ClientId); | 1043 | return indexForClient(row, column, m_x11Clients, s_x11ClientId); | ||
1045 | case s_x11UnmanagedId: | 1044 | case s_x11UnmanagedId: | ||
1046 | return indexForClient(row, column, m_unmanageds, s_x11UnmanagedId); | 1045 | return indexForClient(row, column, m_unmanageds, s_x11UnmanagedId); | ||
1047 | case s_waylandClientId: | 1046 | case s_waylandClientId: | ||
1048 | return indexForClient(row, column, m_shellClients, s_waylandClientId); | 1047 | return indexForClient(row, column, m_waylandClients, s_waylandClientId); | ||
1049 | case s_workspaceInternalId: | 1048 | case s_workspaceInternalId: | ||
1050 | return indexForClient(row, column, m_internalClients, s_workspaceInternalId); | 1049 | return indexForClient(row, column, m_internalClients, s_workspaceInternalId); | ||
1051 | default: | 1050 | default: | ||
1052 | break; | 1051 | break; | ||
1053 | } | 1052 | } | ||
1054 | 1053 | | |||
1055 | // index for a property (third level) | 1054 | // index for a property (third level) | ||
1056 | if (parent.internalId() < s_idDistance * (s_x11ClientId + 1)) { | 1055 | if (parent.internalId() < s_idDistance * (s_x11ClientId + 1)) { | ||
1057 | return indexForProperty(row, column, parent, &DebugConsoleModel::x11Client); | 1056 | return indexForProperty(row, column, parent, &DebugConsoleModel::x11Client); | ||
1058 | } else if (parent.internalId() < s_idDistance * (s_x11UnmanagedId + 1)) { | 1057 | } else if (parent.internalId() < s_idDistance * (s_x11UnmanagedId + 1)) { | ||
1059 | return indexForProperty(row, column, parent, &DebugConsoleModel::unmanaged); | 1058 | return indexForProperty(row, column, parent, &DebugConsoleModel::unmanaged); | ||
1060 | } else if (parent.internalId() < s_idDistance * (s_waylandClientId + 1)) { | 1059 | } else if (parent.internalId() < s_idDistance * (s_waylandClientId + 1)) { | ||
1061 | return indexForProperty(row, column, parent, &DebugConsoleModel::shellClient); | 1060 | return indexForProperty(row, column, parent, &DebugConsoleModel::waylandClient); | ||
1062 | } else if (parent.internalId() < s_idDistance * (s_workspaceInternalId + 1)) { | 1061 | } else if (parent.internalId() < s_idDistance * (s_workspaceInternalId + 1)) { | ||
1063 | return indexForProperty(row, column, parent, &DebugConsoleModel::internalClient); | 1062 | return indexForProperty(row, column, parent, &DebugConsoleModel::internalClient); | ||
1064 | } | 1063 | } | ||
1065 | 1064 | | |||
1066 | return QModelIndex(); | 1065 | return QModelIndex(); | ||
1067 | } | 1066 | } | ||
1068 | 1067 | | |||
1069 | QModelIndex DebugConsoleModel::parent(const QModelIndex &child) const | 1068 | QModelIndex DebugConsoleModel::parent(const QModelIndex &child) const | ||
▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Line(s) | 1175 | if (!index.parent().isValid()) { | |||
1190 | default: | 1189 | default: | ||
1191 | return QVariant(); | 1190 | return QVariant(); | ||
1192 | } | 1191 | } | ||
1193 | } | 1192 | } | ||
1194 | if (index.internalId() & s_propertyBitMask) { | 1193 | if (index.internalId() & s_propertyBitMask) { | ||
1195 | if (index.column() >= 2 || role != Qt::DisplayRole) { | 1194 | if (index.column() >= 2 || role != Qt::DisplayRole) { | ||
1196 | return QVariant(); | 1195 | return QVariant(); | ||
1197 | } | 1196 | } | ||
1198 | if (XdgShellClient *c = shellClient(index)) { | 1197 | if (AbstractClient *c = waylandClient(index)) { | ||
1199 | return propertyData(c, index, role); | 1198 | return propertyData(c, index, role); | ||
1200 | } else if (InternalClient *c = internalClient(index)) { | 1199 | } else if (InternalClient *c = internalClient(index)) { | ||
1201 | return propertyData(c, index, role); | 1200 | return propertyData(c, index, role); | ||
1202 | } else if (X11Client *c = x11Client(index)) { | 1201 | } else if (X11Client *c = x11Client(index)) { | ||
1203 | return propertyData(c, index, role); | 1202 | return propertyData(c, index, role); | ||
1204 | } else if (Unmanaged *u = unmanaged(index)) { | 1203 | } else if (Unmanaged *u = unmanaged(index)) { | ||
1205 | return propertyData(u, index, role); | 1204 | return propertyData(u, index, role); | ||
1206 | } | 1205 | } | ||
Show All 10 Lines | 1213 | case s_x11UnmanagedId: { | |||
1217 | } | 1216 | } | ||
1218 | auto u = m_unmanageds.at(index.row()); | 1217 | auto u = m_unmanageds.at(index.row()); | ||
1219 | if (role == Qt::DisplayRole) { | 1218 | if (role == Qt::DisplayRole) { | ||
1220 | return u->window(); | 1219 | return u->window(); | ||
1221 | } | 1220 | } | ||
1222 | break; | 1221 | break; | ||
1223 | } | 1222 | } | ||
1224 | case s_waylandClientId: | 1223 | case s_waylandClientId: | ||
1225 | return clientData(index, role, m_shellClients); | 1224 | return clientData(index, role, m_waylandClients); | ||
1226 | case s_workspaceInternalId: | 1225 | case s_workspaceInternalId: | ||
1227 | return clientData(index, role, m_internalClients); | 1226 | return clientData(index, role, m_internalClients); | ||
1228 | default: | 1227 | default: | ||
1229 | break; | 1228 | break; | ||
1230 | } | 1229 | } | ||
1231 | } | 1230 | } | ||
1232 | 1231 | | |||
1233 | return QVariant(); | 1232 | return QVariant(); | ||
1234 | } | 1233 | } | ||
1235 | 1234 | | |||
1236 | template<class T> | 1235 | template<class T> | ||
1237 | static T *clientForIndex(const QModelIndex &index, const QVector<T*> &clients, int id) | 1236 | static T *clientForIndex(const QModelIndex &index, const QVector<T*> &clients, int id) | ||
1238 | { | 1237 | { | ||
1239 | const qint32 row = (index.internalId() & s_clientBitMask) - (s_idDistance * id); | 1238 | const qint32 row = (index.internalId() & s_clientBitMask) - (s_idDistance * id); | ||
1240 | if (row < 0 || row >= clients.count()) { | 1239 | if (row < 0 || row >= clients.count()) { | ||
1241 | return nullptr; | 1240 | return nullptr; | ||
1242 | } | 1241 | } | ||
1243 | return clients.at(row); | 1242 | return clients.at(row); | ||
1244 | } | 1243 | } | ||
1245 | 1244 | | |||
1246 | XdgShellClient *DebugConsoleModel::shellClient(const QModelIndex &index) const | 1245 | AbstractClient *DebugConsoleModel::waylandClient(const QModelIndex &index) const | ||
1247 | { | 1246 | { | ||
1248 | return clientForIndex(index, m_shellClients, s_waylandClientId); | 1247 | return clientForIndex(index, m_waylandClients, s_waylandClientId); | ||
1249 | } | 1248 | } | ||
1250 | 1249 | | |||
1251 | InternalClient *DebugConsoleModel::internalClient(const QModelIndex &index) const | 1250 | InternalClient *DebugConsoleModel::internalClient(const QModelIndex &index) const | ||
1252 | { | 1251 | { | ||
1253 | return clientForIndex(index, m_internalClients, s_workspaceInternalId); | 1252 | return clientForIndex(index, m_internalClients, s_workspaceInternalId); | ||
1254 | } | 1253 | } | ||
1255 | 1254 | | |||
1256 | X11Client *DebugConsoleModel::x11Client(const QModelIndex &index) const | 1255 | X11Client *DebugConsoleModel::x11Client(const QModelIndex &index) const | ||
Show All 33 Lines | 1268 | { | |||
1290 | for (auto c : workspace()->desktopList()) { | 1289 | for (auto c : workspace()->desktopList()) { | ||
1291 | if (!c->surface()) { | 1290 | if (!c->surface()) { | ||
1292 | continue; | 1291 | continue; | ||
1293 | } | 1292 | } | ||
1294 | connect(c->surface(), &SurfaceInterface::subSurfaceTreeChanged, this, reset); | 1293 | connect(c->surface(), &SurfaceInterface::subSurfaceTreeChanged, this, reset); | ||
1295 | } | 1294 | } | ||
1296 | if (waylandServer()) { | 1295 | if (waylandServer()) { | ||
1297 | connect(waylandServer(), &WaylandServer::shellClientAdded, this, | 1296 | connect(waylandServer(), &WaylandServer::shellClientAdded, this, | ||
1298 | [this, reset] (XdgShellClient *c) { | 1297 | [this, reset] (AbstractClient *c) { | ||
1299 | connect(c->surface(), &SurfaceInterface::subSurfaceTreeChanged, this, reset); | 1298 | connect(c->surface(), &SurfaceInterface::subSurfaceTreeChanged, this, reset); | ||
1300 | reset(); | 1299 | reset(); | ||
1301 | } | 1300 | } | ||
1302 | ); | 1301 | ); | ||
1303 | } | 1302 | } | ||
1304 | connect(workspace(), &Workspace::clientAdded, this, | 1303 | connect(workspace(), &Workspace::clientAdded, this, | ||
1305 | [this, reset] (AbstractClient *c) { | 1304 | [this, reset] (AbstractClient *c) { | ||
1306 | if (c->surface()) { | 1305 | if (c->surface()) { | ||
▲ Show 20 Lines • Show All 290 Lines • Show Last 20 Lines |