summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Hein <hein@kde.org>2017-02-17 18:20:39 (GMT)
committerEike Hein <hein@kde.org>2017-02-17 18:21:16 (GMT)
commit5632f4c38943b28829ce6013e3dd858b8d9e2a2f (patch)
tree2e6e3ad06c71637f5b47c000163ee5b1d24d4d4d
parentee9f966dd55ce87f75376cae5b90549dace41ea8 (diff)
Port to QMultiHash.
Reviewers: #plasma, fvogt, graesslin Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D4654
-rw-r--r--libtaskmanager/xwindowtasksmodel.cpp27
1 files changed, 7 insertions, 20 deletions
diff --git a/libtaskmanager/xwindowtasksmodel.cpp b/libtaskmanager/xwindowtasksmodel.cpp
index 360ac7c..f8091be 100644
--- a/libtaskmanager/xwindowtasksmodel.cpp
+++ b/libtaskmanager/xwindowtasksmodel.cpp
@@ -62,7 +62,7 @@ public:
QVector<WId> windows;
QSet<WId> transients;
- QHash<WId, WId> transientsDemandingAttention;
+ QMultiHash<WId, WId> transientsDemandingAttention;
QHash<WId, KWindowInfo*> windowInfoCache;
QHash<WId, AppData> appDataCache;
QHash<WId, QRect> delegateGeometries;
@@ -257,22 +257,10 @@ void XWindowTasksModel::Private::removeWindow(WId window)
} else { // Could be a transient.
// Removing a transient might change the demands attention state of the leader.
if (transients.remove(window)) {
- QMutableHashIterator<WId, WId> i(transientsDemandingAttention);
- WId leader = 0;
+ const WId leader = transientsDemandingAttention.key(window, XCB_WINDOW_NONE);
- while (i.hasNext()) {
- i.next();
-
- if (i.value() == window) {
- if (leader == 0) {
- leader = i.key();
- }
-
- i.remove();
- }
- }
-
- if (leader != 0) {
+ if (leader != XCB_WINDOW_NONE) {
+ transientsDemandingAttention.remove(leader, window);
dataChanged(leader, QVector<int>{IsDemandingAttention});
}
}
@@ -307,14 +295,13 @@ void XWindowTasksModel::Private::transientChanged(WId window, NET::Properties pr
const KWindowInfo info(window, NET::WMState | NET::XAWMState, NET::WM2TransientFor);
if (info.hasState(NET::DemandsAttention)) {
- QMutableHashIterator<WId, WId> i(transientsDemandingAttention);
+ const WId oldLeader = transientsDemandingAttention.key(window, XCB_WINDOW_NONE);
- if (i.findNext(window)) {
+ if (oldLeader != XCB_WINDOW_NONE) {
const WId leader = info.transientFor();
- const WId oldLeader = i.key();
if (leader != oldLeader) {
- i.remove();
+ transientsDemandingAttention.remove(oldLeader, window);
transientsDemandingAttention.insertMulti(leader, window);
dataChanged(oldLeader, QVector<int>{IsDemandingAttention});
dataChanged(leader, QVector<int>{IsDemandingAttention});