Changeset View
Changeset View
Standalone View
Standalone View
debug_console.cpp
Show All 15 Lines | |||||
16 | 16 | | |||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "debug_console.h" | 20 | #include "debug_console.h" | ||
21 | #include "composite.h" | 21 | #include "composite.h" | ||
22 | #include "client.h" | 22 | #include "client.h" | ||
23 | #include "input_event.h" | 23 | #include "input_event.h" | ||
24 | #include "internal_client.h" | ||||
24 | #include "main.h" | 25 | #include "main.h" | ||
25 | #include "scene.h" | 26 | #include "scene.h" | ||
26 | #include "shell_client.h" | 27 | #include "shell_client.h" | ||
27 | #include "unmanaged.h" | 28 | #include "unmanaged.h" | ||
28 | #include "wayland_server.h" | 29 | #include "wayland_server.h" | ||
29 | #include "workspace.h" | 30 | #include "workspace.h" | ||
30 | #include "keyboard_input.h" | 31 | #include "keyboard_input.h" | ||
31 | #include "libinput/connection.h" | 32 | #include "libinput/connection.h" | ||
▲ Show 20 Lines • Show All 725 Lines • ▼ Show 20 Line(s) | 652 | default: | |||
757 | break; | 758 | break; | ||
758 | } | 759 | } | ||
759 | return QStyledItemDelegate::displayText(value, locale); | 760 | return QStyledItemDelegate::displayText(value, locale); | ||
760 | } | 761 | } | ||
761 | 762 | | |||
762 | static const int s_x11ClientId = 1; | 763 | static const int s_x11ClientId = 1; | ||
763 | static const int s_x11UnmanagedId = 2; | 764 | static const int s_x11UnmanagedId = 2; | ||
764 | static const int s_waylandClientId = 3; | 765 | static const int s_waylandClientId = 3; | ||
765 | static const int s_waylandInternalId = 4; | 766 | static const int s_workspaceInternalId = 4; | ||
766 | static const quint32 s_propertyBitMask = 0xFFFF0000; | 767 | static const quint32 s_propertyBitMask = 0xFFFF0000; | ||
767 | static const quint32 s_clientBitMask = 0x0000FFFF; | 768 | static const quint32 s_clientBitMask = 0x0000FFFF; | ||
768 | static const quint32 s_idDistance = 10000; | 769 | static const quint32 s_idDistance = 10000; | ||
769 | 770 | | |||
770 | template <class T> | 771 | template <class T> | ||
771 | void DebugConsoleModel::add(int parentRow, QVector<T*> &clients, T *client) | 772 | void DebugConsoleModel::add(int parentRow, QVector<T*> &clients, T *client) | ||
772 | { | 773 | { | ||
773 | beginInsertRows(index(parentRow, 0, QModelIndex()), clients.count(), clients.count()); | 774 | beginInsertRows(index(parentRow, 0, QModelIndex()), clients.count(), clients.count()); | ||
Show All 16 Lines | |||||
790 | DebugConsoleModel::DebugConsoleModel(QObject *parent) | 791 | DebugConsoleModel::DebugConsoleModel(QObject *parent) | ||
791 | : QAbstractItemModel(parent) | 792 | : QAbstractItemModel(parent) | ||
792 | { | 793 | { | ||
793 | if (waylandServer()) { | 794 | if (waylandServer()) { | ||
794 | const auto clients = waylandServer()->clients(); | 795 | const auto clients = waylandServer()->clients(); | ||
795 | for (auto c : clients) { | 796 | for (auto c : clients) { | ||
796 | m_shellClients.append(c); | 797 | m_shellClients.append(c); | ||
797 | } | 798 | } | ||
798 | const auto internals = waylandServer()->internalClients(); | | |||
799 | for (auto c : internals) { | | |||
800 | m_internalClients.append(c); | | |||
801 | } | | |||
802 | // TODO: that only includes windows getting shown, not those which are only created | 799 | // TODO: that only includes windows getting shown, not those which are only created | ||
803 | connect(waylandServer(), &WaylandServer::shellClientAdded, this, | 800 | connect(waylandServer(), &WaylandServer::shellClientAdded, this, | ||
804 | [this] (ShellClient *c) { | 801 | [this] (ShellClient *c) { | ||
805 | if (c->isInternal()) { | | |||
806 | add(s_waylandInternalId -1, m_internalClients, c); | | |||
807 | } else { | | |||
808 | add(s_waylandClientId -1, m_shellClients, c); | 802 | add(s_waylandClientId -1, m_shellClients, c); | ||
809 | } | 803 | } | ||
810 | } | | |||
811 | ); | 804 | ); | ||
812 | connect(waylandServer(), &WaylandServer::shellClientRemoved, this, | 805 | connect(waylandServer(), &WaylandServer::shellClientRemoved, this, | ||
813 | [this] (ShellClient *c) { | 806 | [this] (ShellClient *c) { | ||
814 | remove(s_waylandInternalId -1, m_internalClients, c); | | |||
815 | remove(s_waylandClientId -1, m_shellClients, c); | 807 | remove(s_waylandClientId -1, m_shellClients, c); | ||
816 | } | 808 | } | ||
817 | ); | 809 | ); | ||
818 | } | 810 | } | ||
819 | const auto x11Clients = workspace()->clientList(); | 811 | const auto x11Clients = workspace()->clientList(); | ||
820 | for (auto c : x11Clients) { | 812 | for (auto c : x11Clients) { | ||
821 | m_x11Clients.append(c); | 813 | m_x11Clients.append(c); | ||
822 | } | 814 | } | ||
Show All 25 Lines | 839 | [this] (Unmanaged *u) { | |||
848 | add(s_x11UnmanagedId -1, m_unmanageds, u); | 840 | add(s_x11UnmanagedId -1, m_unmanageds, u); | ||
849 | } | 841 | } | ||
850 | ); | 842 | ); | ||
851 | connect(workspace(), &Workspace::unmanagedRemoved, this, | 843 | connect(workspace(), &Workspace::unmanagedRemoved, this, | ||
852 | [this] (Unmanaged *u) { | 844 | [this] (Unmanaged *u) { | ||
853 | remove(s_x11UnmanagedId -1, m_unmanageds, u); | 845 | remove(s_x11UnmanagedId -1, m_unmanageds, u); | ||
854 | } | 846 | } | ||
855 | ); | 847 | ); | ||
848 | for (InternalClient *client : workspace()->internalClients()) { | ||||
849 | m_internalClients.append(client); | ||||
850 | } | ||||
851 | connect(workspace(), &Workspace::internalClientAdded, this, | ||||
852 | [this](InternalClient *client) { | ||||
853 | add(s_workspaceInternalId -1, m_internalClients, client); | ||||
854 | } | ||||
855 | ); | ||||
856 | connect(workspace(), &Workspace::internalClientRemoved, this, | ||||
857 | [this](InternalClient *client) { | ||||
858 | remove(s_workspaceInternalId -1, m_internalClients, client); | ||||
859 | } | ||||
860 | ); | ||||
856 | } | 861 | } | ||
857 | 862 | | |||
858 | DebugConsoleModel::~DebugConsoleModel() = default; | 863 | DebugConsoleModel::~DebugConsoleModel() = default; | ||
859 | 864 | | |||
860 | int DebugConsoleModel::columnCount(const QModelIndex &parent) const | 865 | int DebugConsoleModel::columnCount(const QModelIndex &parent) const | ||
861 | { | 866 | { | ||
862 | Q_UNUSED(parent) | 867 | Q_UNUSED(parent) | ||
863 | return 2; | 868 | return 2; | ||
Show All 21 Lines | 886 | { | |||
885 | 890 | | |||
886 | switch (parent.internalId()) { | 891 | switch (parent.internalId()) { | ||
887 | case s_x11ClientId: | 892 | case s_x11ClientId: | ||
888 | return m_x11Clients.count(); | 893 | return m_x11Clients.count(); | ||
889 | case s_x11UnmanagedId: | 894 | case s_x11UnmanagedId: | ||
890 | return m_unmanageds.count(); | 895 | return m_unmanageds.count(); | ||
891 | case s_waylandClientId: | 896 | case s_waylandClientId: | ||
892 | return m_shellClients.count(); | 897 | return m_shellClients.count(); | ||
893 | case s_waylandInternalId: | 898 | case s_workspaceInternalId: | ||
894 | return m_internalClients.count(); | 899 | return m_internalClients.count(); | ||
895 | default: | 900 | default: | ||
896 | break; | 901 | break; | ||
897 | } | 902 | } | ||
898 | 903 | | |||
899 | if (parent.internalId() & s_propertyBitMask) { | 904 | if (parent.internalId() & s_propertyBitMask) { | ||
900 | // properties do not have children | 905 | // properties do not have children | ||
901 | return 0; | 906 | return 0; | ||
902 | } | 907 | } | ||
903 | 908 | | |||
904 | if (parent.internalId() < s_idDistance * (s_x11ClientId + 1)) { | 909 | if (parent.internalId() < s_idDistance * (s_x11ClientId + 1)) { | ||
905 | return propertyCount(parent, &DebugConsoleModel::x11Client); | 910 | return propertyCount(parent, &DebugConsoleModel::x11Client); | ||
906 | } else if (parent.internalId() < s_idDistance * (s_x11UnmanagedId + 1)) { | 911 | } else if (parent.internalId() < s_idDistance * (s_x11UnmanagedId + 1)) { | ||
907 | return propertyCount(parent, &DebugConsoleModel::unmanaged); | 912 | return propertyCount(parent, &DebugConsoleModel::unmanaged); | ||
908 | } else if (parent.internalId() < s_idDistance * (s_waylandClientId + 1)) { | 913 | } else if (parent.internalId() < s_idDistance * (s_waylandClientId + 1)) { | ||
909 | return propertyCount(parent, &DebugConsoleModel::shellClient); | 914 | return propertyCount(parent, &DebugConsoleModel::shellClient); | ||
910 | } else if (parent.internalId() < s_idDistance * (s_waylandInternalId + 1)) { | 915 | } else if (parent.internalId() < s_idDistance * (s_workspaceInternalId + 1)) { | ||
911 | return propertyCount(parent, &DebugConsoleModel::internalClient); | 916 | return propertyCount(parent, &DebugConsoleModel::internalClient); | ||
912 | } | 917 | } | ||
913 | 918 | | |||
914 | return 0; | 919 | return 0; | ||
915 | } | 920 | } | ||
916 | 921 | | |||
917 | template <class T> | 922 | template <class T> | ||
918 | QModelIndex DebugConsoleModel::indexForClient(int row, int column, const QVector<T*> &clients, int id) const | 923 | QModelIndex DebugConsoleModel::indexForClient(int row, int column, const QVector<T*> &clients, int id) const | ||
Show All 35 Lines | 947 | { | |||
954 | // index for a client (second level) | 959 | // index for a client (second level) | ||
955 | switch (parent.internalId()) { | 960 | switch (parent.internalId()) { | ||
956 | case s_x11ClientId: | 961 | case s_x11ClientId: | ||
957 | return indexForClient(row, column, m_x11Clients, s_x11ClientId); | 962 | return indexForClient(row, column, m_x11Clients, s_x11ClientId); | ||
958 | case s_x11UnmanagedId: | 963 | case s_x11UnmanagedId: | ||
959 | return indexForClient(row, column, m_unmanageds, s_x11UnmanagedId); | 964 | return indexForClient(row, column, m_unmanageds, s_x11UnmanagedId); | ||
960 | case s_waylandClientId: | 965 | case s_waylandClientId: | ||
961 | return indexForClient(row, column, m_shellClients, s_waylandClientId); | 966 | return indexForClient(row, column, m_shellClients, s_waylandClientId); | ||
962 | case s_waylandInternalId: | 967 | case s_workspaceInternalId: | ||
963 | return indexForClient(row, column, m_internalClients, s_waylandInternalId); | 968 | return indexForClient(row, column, m_internalClients, s_workspaceInternalId); | ||
964 | default: | 969 | default: | ||
965 | break; | 970 | break; | ||
966 | } | 971 | } | ||
967 | 972 | | |||
968 | // index for a property (third level) | 973 | // index for a property (third level) | ||
969 | if (parent.internalId() < s_idDistance * (s_x11ClientId + 1)) { | 974 | if (parent.internalId() < s_idDistance * (s_x11ClientId + 1)) { | ||
970 | return indexForProperty(row, column, parent, &DebugConsoleModel::x11Client); | 975 | return indexForProperty(row, column, parent, &DebugConsoleModel::x11Client); | ||
971 | } else if (parent.internalId() < s_idDistance * (s_x11UnmanagedId + 1)) { | 976 | } else if (parent.internalId() < s_idDistance * (s_x11UnmanagedId + 1)) { | ||
972 | return indexForProperty(row, column, parent, &DebugConsoleModel::unmanaged); | 977 | return indexForProperty(row, column, parent, &DebugConsoleModel::unmanaged); | ||
973 | } else if (parent.internalId() < s_idDistance * (s_waylandClientId + 1)) { | 978 | } else if (parent.internalId() < s_idDistance * (s_waylandClientId + 1)) { | ||
974 | return indexForProperty(row, column, parent, &DebugConsoleModel::shellClient); | 979 | return indexForProperty(row, column, parent, &DebugConsoleModel::shellClient); | ||
975 | } else if (parent.internalId() < s_idDistance * (s_waylandInternalId + 1)) { | 980 | } else if (parent.internalId() < s_idDistance * (s_workspaceInternalId + 1)) { | ||
976 | return indexForProperty(row, column, parent, &DebugConsoleModel::internalClient); | 981 | return indexForProperty(row, column, parent, &DebugConsoleModel::internalClient); | ||
977 | } | 982 | } | ||
978 | 983 | | |||
979 | return QModelIndex(); | 984 | return QModelIndex(); | ||
980 | } | 985 | } | ||
981 | 986 | | |||
982 | QModelIndex DebugConsoleModel::parent(const QModelIndex &child) const | 987 | QModelIndex DebugConsoleModel::parent(const QModelIndex &child) const | ||
983 | { | 988 | { | ||
984 | if (child.internalId() <= s_waylandInternalId) { | 989 | if (child.internalId() <= s_workspaceInternalId) { | ||
985 | return QModelIndex(); | 990 | return QModelIndex(); | ||
986 | } | 991 | } | ||
987 | if (child.internalId() & s_propertyBitMask) { | 992 | if (child.internalId() & s_propertyBitMask) { | ||
988 | // a property | 993 | // a property | ||
989 | const quint32 parentId = child.internalId() & s_clientBitMask; | 994 | const quint32 parentId = child.internalId() & s_clientBitMask; | ||
990 | if (parentId < s_idDistance * (s_x11ClientId + 1)) { | 995 | if (parentId < s_idDistance * (s_x11ClientId + 1)) { | ||
991 | return createIndex(parentId - (s_idDistance * s_x11ClientId), 0, parentId); | 996 | return createIndex(parentId - (s_idDistance * s_x11ClientId), 0, parentId); | ||
992 | } else if (parentId < s_idDistance * (s_x11UnmanagedId + 1)) { | 997 | } else if (parentId < s_idDistance * (s_x11UnmanagedId + 1)) { | ||
993 | return createIndex(parentId - (s_idDistance * s_x11UnmanagedId), 0, parentId); | 998 | return createIndex(parentId - (s_idDistance * s_x11UnmanagedId), 0, parentId); | ||
994 | } else if (parentId < s_idDistance * (s_waylandClientId + 1)) { | 999 | } else if (parentId < s_idDistance * (s_waylandClientId + 1)) { | ||
995 | return createIndex(parentId - (s_idDistance * s_waylandClientId), 0, parentId); | 1000 | return createIndex(parentId - (s_idDistance * s_waylandClientId), 0, parentId); | ||
996 | } else if (parentId < s_idDistance * (s_waylandInternalId + 1)) { | 1001 | } else if (parentId < s_idDistance * (s_workspaceInternalId + 1)) { | ||
997 | return createIndex(parentId - (s_idDistance * s_waylandInternalId), 0, parentId); | 1002 | return createIndex(parentId - (s_idDistance * s_workspaceInternalId), 0, parentId); | ||
998 | } | 1003 | } | ||
999 | return QModelIndex(); | 1004 | return QModelIndex(); | ||
1000 | } | 1005 | } | ||
1001 | if (child.internalId() < s_idDistance * (s_x11ClientId + 1)) { | 1006 | if (child.internalId() < s_idDistance * (s_x11ClientId + 1)) { | ||
1002 | return createIndex(s_x11ClientId -1, 0, s_x11ClientId); | 1007 | return createIndex(s_x11ClientId -1, 0, s_x11ClientId); | ||
1003 | } else if (child.internalId() < s_idDistance * (s_x11UnmanagedId + 1)) { | 1008 | } else if (child.internalId() < s_idDistance * (s_x11UnmanagedId + 1)) { | ||
1004 | return createIndex(s_x11UnmanagedId -1, 0, s_x11UnmanagedId); | 1009 | return createIndex(s_x11UnmanagedId -1, 0, s_x11UnmanagedId); | ||
1005 | } else if (child.internalId() < s_idDistance * (s_waylandClientId + 1)) { | 1010 | } else if (child.internalId() < s_idDistance * (s_waylandClientId + 1)) { | ||
1006 | return createIndex(s_waylandClientId -1, 0, s_waylandClientId); | 1011 | return createIndex(s_waylandClientId -1, 0, s_waylandClientId); | ||
1007 | } else if (child.internalId() < s_idDistance * (s_waylandInternalId + 1)) { | 1012 | } else if (child.internalId() < s_idDistance * (s_workspaceInternalId + 1)) { | ||
1008 | return createIndex(s_waylandInternalId -1, 0, s_waylandInternalId); | 1013 | return createIndex(s_workspaceInternalId -1, 0, s_workspaceInternalId); | ||
1009 | } | 1014 | } | ||
1010 | return QModelIndex(); | 1015 | return QModelIndex(); | ||
1011 | } | 1016 | } | ||
1012 | 1017 | | |||
1013 | QVariant DebugConsoleModel::propertyData(QObject *object, const QModelIndex &index, int role) const | 1018 | QVariant DebugConsoleModel::propertyData(QObject *object, const QModelIndex &index, int role) const | ||
1014 | { | 1019 | { | ||
1015 | Q_UNUSED(role) | 1020 | Q_UNUSED(role) | ||
1016 | const auto property = object->metaObject()->property(index.row()); | 1021 | const auto property = object->metaObject()->property(index.row()); | ||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Line(s) | 1094 | if (!index.parent().isValid()) { | |||
1093 | } | 1098 | } | ||
1094 | switch (index.internalId()) { | 1099 | switch (index.internalId()) { | ||
1095 | case s_x11ClientId: | 1100 | case s_x11ClientId: | ||
1096 | return i18n("X11 Client Windows"); | 1101 | return i18n("X11 Client Windows"); | ||
1097 | case s_x11UnmanagedId: | 1102 | case s_x11UnmanagedId: | ||
1098 | return i18n("X11 Unmanaged Windows"); | 1103 | return i18n("X11 Unmanaged Windows"); | ||
1099 | case s_waylandClientId: | 1104 | case s_waylandClientId: | ||
1100 | return i18n("Wayland Windows"); | 1105 | return i18n("Wayland Windows"); | ||
1101 | case s_waylandInternalId: | 1106 | case s_workspaceInternalId: | ||
1102 | return i18n("Internal Windows"); | 1107 | return i18n("Internal Windows"); | ||
1103 | default: | 1108 | default: | ||
1104 | return QVariant(); | 1109 | return QVariant(); | ||
1105 | } | 1110 | } | ||
1106 | } | 1111 | } | ||
1107 | if (index.internalId() & s_propertyBitMask) { | 1112 | if (index.internalId() & s_propertyBitMask) { | ||
1108 | if (index.column() >= 2 || role != Qt::DisplayRole) { | 1113 | if (index.column() >= 2 || role != Qt::DisplayRole) { | ||
1109 | return QVariant(); | 1114 | return QVariant(); | ||
1110 | } | 1115 | } | ||
1111 | if (ShellClient *c = shellClient(index)) { | 1116 | if (ShellClient *c = shellClient(index)) { | ||
1112 | return propertyData(c, index, role); | 1117 | return propertyData(c, index, role); | ||
1113 | } else if (ShellClient *c = internalClient(index)) { | 1118 | } else if (InternalClient *c = internalClient(index)) { | ||
1114 | return propertyData(c, index, role); | 1119 | return propertyData(c, index, role); | ||
1115 | } else if (Client *c = x11Client(index)) { | 1120 | } else if (Client *c = x11Client(index)) { | ||
1116 | return propertyData(c, index, role); | 1121 | return propertyData(c, index, role); | ||
1117 | } else if (Unmanaged *u = unmanaged(index)) { | 1122 | } else if (Unmanaged *u = unmanaged(index)) { | ||
1118 | return propertyData(u, index, role); | 1123 | return propertyData(u, index, role); | ||
1119 | } | 1124 | } | ||
1120 | } else { | 1125 | } else { | ||
1121 | if (index.column() != 0) { | 1126 | if (index.column() != 0) { | ||
Show All 9 Lines | 1132 | case s_x11UnmanagedId: { | |||
1131 | auto u = m_unmanageds.at(index.row()); | 1136 | auto u = m_unmanageds.at(index.row()); | ||
1132 | if (role == Qt::DisplayRole) { | 1137 | if (role == Qt::DisplayRole) { | ||
1133 | return u->window(); | 1138 | return u->window(); | ||
1134 | } | 1139 | } | ||
1135 | break; | 1140 | break; | ||
1136 | } | 1141 | } | ||
1137 | case s_waylandClientId: | 1142 | case s_waylandClientId: | ||
1138 | return clientData(index, role, m_shellClients); | 1143 | return clientData(index, role, m_shellClients); | ||
1139 | case s_waylandInternalId: | 1144 | case s_workspaceInternalId: | ||
1140 | return clientData(index, role, m_internalClients); | 1145 | return clientData(index, role, m_internalClients); | ||
1141 | default: | 1146 | default: | ||
1142 | break; | 1147 | break; | ||
1143 | } | 1148 | } | ||
1144 | } | 1149 | } | ||
1145 | 1150 | | |||
1146 | return QVariant(); | 1151 | return QVariant(); | ||
1147 | } | 1152 | } | ||
1148 | 1153 | | |||
1149 | template<class T> | 1154 | template<class T> | ||
1150 | static T *clientForIndex(const QModelIndex &index, const QVector<T*> &clients, int id) | 1155 | static T *clientForIndex(const QModelIndex &index, const QVector<T*> &clients, int id) | ||
1151 | { | 1156 | { | ||
1152 | const qint32 row = (index.internalId() & s_clientBitMask) - (s_idDistance * id); | 1157 | const qint32 row = (index.internalId() & s_clientBitMask) - (s_idDistance * id); | ||
1153 | if (row < 0 || row >= clients.count()) { | 1158 | if (row < 0 || row >= clients.count()) { | ||
1154 | return nullptr; | 1159 | return nullptr; | ||
1155 | } | 1160 | } | ||
1156 | return clients.at(row); | 1161 | return clients.at(row); | ||
1157 | } | 1162 | } | ||
1158 | 1163 | | |||
1159 | ShellClient *DebugConsoleModel::shellClient(const QModelIndex &index) const | 1164 | ShellClient *DebugConsoleModel::shellClient(const QModelIndex &index) const | ||
1160 | { | 1165 | { | ||
1161 | return clientForIndex(index, m_shellClients, s_waylandClientId); | 1166 | return clientForIndex(index, m_shellClients, s_waylandClientId); | ||
1162 | } | 1167 | } | ||
1163 | 1168 | | |||
1164 | ShellClient *DebugConsoleModel::internalClient(const QModelIndex &index) const | 1169 | InternalClient *DebugConsoleModel::internalClient(const QModelIndex &index) const | ||
1165 | { | 1170 | { | ||
1166 | return clientForIndex(index, m_internalClients, s_waylandInternalId); | 1171 | return clientForIndex(index, m_internalClients, s_workspaceInternalId); | ||
1167 | } | 1172 | } | ||
1168 | 1173 | | |||
1169 | Client *DebugConsoleModel::x11Client(const QModelIndex &index) const | 1174 | Client *DebugConsoleModel::x11Client(const QModelIndex &index) const | ||
1170 | { | 1175 | { | ||
1171 | return clientForIndex(index, m_x11Clients, s_x11ClientId); | 1176 | return clientForIndex(index, m_x11Clients, s_x11ClientId); | ||
1172 | } | 1177 | } | ||
1173 | 1178 | | |||
1174 | Unmanaged *DebugConsoleModel::unmanaged(const QModelIndex &index) const | 1179 | Unmanaged *DebugConsoleModel::unmanaged(const QModelIndex &index) const | ||
Show All 27 Lines | 1187 | { | |||
1202 | } | 1207 | } | ||
1203 | for (auto c : workspace()->desktopList()) { | 1208 | for (auto c : workspace()->desktopList()) { | ||
1204 | if (!c->surface()) { | 1209 | if (!c->surface()) { | ||
1205 | continue; | 1210 | continue; | ||
1206 | } | 1211 | } | ||
1207 | connect(c->surface(), &SurfaceInterface::subSurfaceTreeChanged, this, reset); | 1212 | connect(c->surface(), &SurfaceInterface::subSurfaceTreeChanged, this, reset); | ||
1208 | } | 1213 | } | ||
1209 | if (waylandServer()) { | 1214 | if (waylandServer()) { | ||
1210 | for (auto c : waylandServer()->internalClients()) { | | |||
1211 | connect(c->surface(), &SurfaceInterface::subSurfaceTreeChanged, this, reset); | | |||
1212 | } | | |||
1213 | connect(waylandServer(), &WaylandServer::shellClientAdded, this, | 1215 | connect(waylandServer(), &WaylandServer::shellClientAdded, this, | ||
1214 | [this, reset] (ShellClient *c) { | 1216 | [this, reset] (ShellClient *c) { | ||
1215 | connect(c->surface(), &SurfaceInterface::subSurfaceTreeChanged, this, reset); | 1217 | connect(c->surface(), &SurfaceInterface::subSurfaceTreeChanged, this, reset); | ||
1216 | reset(); | 1218 | reset(); | ||
1217 | } | 1219 | } | ||
1218 | ); | 1220 | ); | ||
1219 | } | 1221 | } | ||
1220 | connect(workspace(), &Workspace::clientAdded, this, | 1222 | connect(workspace(), &Workspace::clientAdded, this, | ||
Show All 29 Lines | 1251 | { | |||
1250 | if (parent.isValid()) { | 1252 | if (parent.isValid()) { | ||
1251 | using namespace KWayland::Server; | 1253 | using namespace KWayland::Server; | ||
1252 | if (SurfaceInterface *surface = static_cast<SurfaceInterface*>(parent.internalPointer())) { | 1254 | if (SurfaceInterface *surface = static_cast<SurfaceInterface*>(parent.internalPointer())) { | ||
1253 | const auto &children = surface->childSubSurfaces(); | 1255 | const auto &children = surface->childSubSurfaces(); | ||
1254 | return children.count(); | 1256 | return children.count(); | ||
1255 | } | 1257 | } | ||
1256 | return 0; | 1258 | return 0; | ||
1257 | } | 1259 | } | ||
1258 | const int internalClientsCount = waylandServer() ? waylandServer()->internalClients().count() : 0; | | |||
1259 | // toplevel are all windows | 1260 | // toplevel are all windows | ||
1260 | return workspace()->allClientList().count() + | 1261 | return workspace()->allClientList().count() + | ||
1261 | workspace()->desktopList().count() + | 1262 | workspace()->desktopList().count() + | ||
1262 | workspace()->unmanagedList().count() + | 1263 | workspace()->unmanagedList().count(); | ||
1263 | internalClientsCount; | | |||
1264 | } | 1264 | } | ||
1265 | 1265 | | |||
1266 | QModelIndex SurfaceTreeModel::index(int row, int column, const QModelIndex &parent) const | 1266 | QModelIndex SurfaceTreeModel::index(int row, int column, const QModelIndex &parent) const | ||
1267 | { | 1267 | { | ||
1268 | if (column != 0) { | 1268 | if (column != 0) { | ||
1269 | // invalid column | 1269 | // invalid column | ||
1270 | return QModelIndex(); | 1270 | return QModelIndex(); | ||
1271 | } | 1271 | } | ||
Show All 20 Lines | 1291 | if (row < reference + desktopClients.count()) { | |||
1292 | return createIndex(row, column, desktopClients.at(row-reference)->surface()); | 1292 | return createIndex(row, column, desktopClients.at(row-reference)->surface()); | ||
1293 | } | 1293 | } | ||
1294 | reference += desktopClients.count(); | 1294 | reference += desktopClients.count(); | ||
1295 | const auto &unmanaged = workspace()->unmanagedList(); | 1295 | const auto &unmanaged = workspace()->unmanagedList(); | ||
1296 | if (row < reference + unmanaged.count()) { | 1296 | if (row < reference + unmanaged.count()) { | ||
1297 | return createIndex(row, column, unmanaged.at(row-reference)->surface()); | 1297 | return createIndex(row, column, unmanaged.at(row-reference)->surface()); | ||
1298 | } | 1298 | } | ||
1299 | reference += unmanaged.count(); | 1299 | reference += unmanaged.count(); | ||
1300 | if (waylandServer()) { | | |||
1301 | const auto &internal = waylandServer()->internalClients(); | | |||
1302 | if (row < reference + internal.count()) { | | |||
1303 | return createIndex(row, column, internal.at(row-reference)->surface()); | | |||
1304 | } | | |||
1305 | } | | |||
1306 | // not found | 1300 | // not found | ||
1307 | return QModelIndex(); | 1301 | return QModelIndex(); | ||
1308 | } | 1302 | } | ||
1309 | 1303 | | |||
1310 | QModelIndex SurfaceTreeModel::parent(const QModelIndex &child) const | 1304 | QModelIndex SurfaceTreeModel::parent(const QModelIndex &child) const | ||
1311 | { | 1305 | { | ||
1312 | using namespace KWayland::Server; | 1306 | using namespace KWayland::Server; | ||
1313 | if (SurfaceInterface *surface = static_cast<SurfaceInterface*>(child.internalPointer())) { | 1307 | if (SurfaceInterface *surface = static_cast<SurfaceInterface*>(child.internalPointer())) { | ||
Show All 40 Lines | |||||
1354 | row += desktopClients.count(); | 1348 | row += desktopClients.count(); | ||
1355 | const auto &unmanaged = workspace()->unmanagedList(); | 1349 | const auto &unmanaged = workspace()->unmanagedList(); | ||
1356 | for (int i = 0; i < unmanaged.count(); i++) { | 1350 | for (int i = 0; i < unmanaged.count(); i++) { | ||
1357 | if (unmanaged.at(i)->surface() == parent) { | 1351 | if (unmanaged.at(i)->surface() == parent) { | ||
1358 | return createIndex(row + i, 0, parent); | 1352 | return createIndex(row + i, 0, parent); | ||
1359 | } | 1353 | } | ||
1360 | } | 1354 | } | ||
1361 | row += unmanaged.count(); | 1355 | row += unmanaged.count(); | ||
1362 | if (waylandServer()) { | | |||
1363 | const auto &internal = waylandServer()->internalClients(); | | |||
1364 | for (int i = 0; i < internal.count(); i++) { | | |||
1365 | if (internal.at(i)->surface() == parent) { | | |||
1366 | return createIndex(row + i, 0, parent); | | |||
1367 | } | | |||
1368 | } | | |||
1369 | } | | |||
1370 | } | 1356 | } | ||
1371 | return QModelIndex(); | 1357 | return QModelIndex(); | ||
1372 | } | 1358 | } | ||
1373 | 1359 | | |||
1374 | QVariant SurfaceTreeModel::data(const QModelIndex &index, int role) const | 1360 | QVariant SurfaceTreeModel::data(const QModelIndex &index, int role) const | ||
1375 | { | 1361 | { | ||
1376 | if (!index.isValid()) { | 1362 | if (!index.isValid()) { | ||
1377 | return QVariant(); | 1363 | return QVariant(); | ||
▲ Show 20 Lines • Show All 151 Lines • Show Last 20 Lines |