Port to QMultiHash.

Reviewers: #plasma, fvogt, graesslin

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D4654
wilder-5.14
Eike Hein 9 years ago
parent ee9f966dd5
commit 5632f4c389
  1. 27
      libtaskmanager/xwindowtasksmodel.cpp

@ -62,7 +62,7 @@ public:
QVector<WId> windows; QVector<WId> windows;
QSet<WId> transients; QSet<WId> transients;
QHash<WId, WId> transientsDemandingAttention; QMultiHash<WId, WId> transientsDemandingAttention;
QHash<WId, KWindowInfo*> windowInfoCache; QHash<WId, KWindowInfo*> windowInfoCache;
QHash<WId, AppData> appDataCache; QHash<WId, AppData> appDataCache;
QHash<WId, QRect> delegateGeometries; QHash<WId, QRect> delegateGeometries;
@ -257,22 +257,10 @@ void XWindowTasksModel::Private::removeWindow(WId window)
} else { // Could be a transient. } else { // Could be a transient.
// Removing a transient might change the demands attention state of the leader. // Removing a transient might change the demands attention state of the leader.
if (transients.remove(window)) { if (transients.remove(window)) {
QMutableHashIterator<WId, WId> i(transientsDemandingAttention); const WId leader = transientsDemandingAttention.key(window, XCB_WINDOW_NONE);
WId leader = 0;
while (i.hasNext()) { if (leader != XCB_WINDOW_NONE) {
i.next(); transientsDemandingAttention.remove(leader, window);
if (i.value() == window) {
if (leader == 0) {
leader = i.key();
}
i.remove();
}
}
if (leader != 0) {
dataChanged(leader, QVector<int>{IsDemandingAttention}); 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); const KWindowInfo info(window, NET::WMState | NET::XAWMState, NET::WM2TransientFor);
if (info.hasState(NET::DemandsAttention)) { 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 leader = info.transientFor();
const WId oldLeader = i.key();
if (leader != oldLeader) { if (leader != oldLeader) {
i.remove(); transientsDemandingAttention.remove(oldLeader, window);
transientsDemandingAttention.insertMulti(leader, window); transientsDemandingAttention.insertMulti(leader, window);
dataChanged(oldLeader, QVector<int>{IsDemandingAttention}); dataChanged(oldLeader, QVector<int>{IsDemandingAttention});
dataChanged(leader, QVector<int>{IsDemandingAttention}); dataChanged(leader, QVector<int>{IsDemandingAttention});

Loading…
Cancel
Save