Changeset View
Changeset View
Standalone View
Standalone View
runners/windows/windowsrunner.cpp
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | |||||
69 | // Called in the main thread | 69 | // Called in the main thread | ||
70 | void WindowsRunner::gatherInfo() | 70 | void WindowsRunner::gatherInfo() | ||
71 | { | 71 | { | ||
72 | QMutexLocker locker(&m_mutex); | 72 | QMutexLocker locker(&m_mutex); | ||
73 | if (!m_inSession) { | 73 | if (!m_inSession) { | ||
74 | return; | 74 | return; | ||
75 | } | 75 | } | ||
76 | 76 | | |||
77 | foreach (const WId w, KWindowSystem::windows()) { | 77 | const auto windows = KWindowSystem::windows(); | ||
78 | for (const WId w : windows) { | ||||
78 | KWindowInfo info(w, NET::WMWindowType | NET::WMDesktop | | 79 | KWindowInfo info(w, NET::WMWindowType | NET::WMDesktop | | ||
79 | NET::WMState | NET::XAWMState | | 80 | NET::WMState | NET::XAWMState | | ||
80 | NET::WMName, | 81 | NET::WMName, | ||
81 | NET::WM2WindowClass | NET::WM2WindowRole | NET::WM2AllowedActions); | 82 | NET::WM2WindowClass | NET::WM2WindowRole | NET::WM2AllowedActions); | ||
82 | if (info.valid()) { | 83 | if (info.valid()) { | ||
83 | // ignore NET::Tool and other special window types | 84 | // ignore NET::Tool and other special window types | ||
84 | NET::WindowType wType = info.windowType(NET::NormalMask | NET::DesktopMask | NET::DockMask | | 85 | NET::WindowType wType = info.windowType(NET::NormalMask | NET::DesktopMask | NET::DockMask | | ||
85 | NET::ToolbarMask | NET::MenuMask | NET::DialogMask | | 86 | NET::ToolbarMask | NET::MenuMask | NET::DialogMask | | ||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Line(s) | 128 | { | |||
174 | // keyword match: when term starts with "window" we list all windows | 175 | // keyword match: when term starts with "window" we list all windows | ||
175 | // the list can be restricted to windows matching a given name, class, role or desktop | 176 | // the list can be restricted to windows matching a given name, class, role or desktop | ||
176 | if (term.startsWith(i18nc("Note this is a KRunner keyword", "window") , Qt::CaseInsensitive)) { | 177 | if (term.startsWith(i18nc("Note this is a KRunner keyword", "window") , Qt::CaseInsensitive)) { | ||
177 | const QStringList keywords = term.split(QStringLiteral(" ")); | 178 | const QStringList keywords = term.split(QStringLiteral(" ")); | ||
178 | QString windowName; | 179 | QString windowName; | ||
179 | QString windowClass; | 180 | QString windowClass; | ||
180 | QString windowRole; | 181 | QString windowRole; | ||
181 | int desktop = -1; | 182 | int desktop = -1; | ||
182 | foreach (const QString& keyword, keywords) { | 183 | for (const QString& keyword : keywords) { | ||
183 | if (keyword.endsWith(QLatin1Char('='))) { | 184 | if (keyword.endsWith(QLatin1Char('='))) { | ||
184 | continue; | 185 | continue; | ||
185 | } | 186 | } | ||
186 | if (keyword.startsWith(i18nc("Note this is a KRunner keyword", "name") + QStringLiteral("=") , Qt::CaseInsensitive)) { | 187 | if (keyword.startsWith(i18nc("Note this is a KRunner keyword", "name") + QStringLiteral("=") , Qt::CaseInsensitive)) { | ||
187 | windowName = keyword.split(QStringLiteral("="))[1]; | 188 | windowName = keyword.split(QStringLiteral("="))[1]; | ||
188 | } else if (keyword.startsWith(i18nc("Note this is a KRunner keyword", "class") + QStringLiteral("=") , Qt::CaseInsensitive)) { | 189 | } else if (keyword.startsWith(i18nc("Note this is a KRunner keyword", "class") + QStringLiteral("=") , Qt::CaseInsensitive)) { | ||
189 | windowClass = keyword.split(QStringLiteral("="))[1]; | 190 | windowClass = keyword.split(QStringLiteral("="))[1]; | ||
190 | } else if (keyword.startsWith(i18nc("Note this is a KRunner keyword", "role") + QStringLiteral("=") , Qt::CaseInsensitive)) { | 191 | } else if (keyword.startsWith(i18nc("Note this is a KRunner keyword", "role") + QStringLiteral("=") , Qt::CaseInsensitive)) { | ||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Line(s) | 279 | while (it.hasNext()) { | |||
290 | } else if ((info.name().contains(term, Qt::CaseInsensitive) || | 291 | } else if ((info.name().contains(term, Qt::CaseInsensitive) || | ||
291 | className.contains(term, Qt::CaseInsensitive)) && | 292 | className.contains(term, Qt::CaseInsensitive)) && | ||
292 | actionSupported(info, action)) { | 293 | actionSupported(info, action)) { | ||
293 | matches << windowMatch(info, action, 0.7, Plasma::QueryMatch::PossibleMatch); | 294 | matches << windowMatch(info, action, 0.7, Plasma::QueryMatch::PossibleMatch); | ||
294 | } | 295 | } | ||
295 | } | 296 | } | ||
296 | 297 | | |||
297 | // check for matching desktops by name | 298 | // check for matching desktops by name | ||
298 | foreach (const QString& desktopName, m_desktopNames) { | 299 | for (const QString& desktopName : qAsConst(m_desktopNames)) { | ||
299 | int desktop = m_desktopNames.indexOf(desktopName) +1; | 300 | int desktop = m_desktopNames.indexOf(desktopName) +1; | ||
300 | if (desktopName.contains(term, Qt::CaseInsensitive)) { | 301 | if (desktopName.contains(term, Qt::CaseInsensitive)) { | ||
301 | // desktop name matches - offer switch to | 302 | // desktop name matches - offer switch to | ||
302 | // only add desktops if it hasn't been added by the keyword which is quite likely | 303 | // only add desktops if it hasn't been added by the keyword which is quite likely | ||
303 | if (!desktopAdded && desktop != KWindowSystem::currentDesktop()) { | 304 | if (!desktopAdded && desktop != KWindowSystem::currentDesktop()) { | ||
304 | matches << desktopMatch(desktop, 0.8); | 305 | matches << desktopMatch(desktop, 0.8); | ||
305 | } | 306 | } | ||
306 | 307 | | |||
▲ Show 20 Lines • Show All 178 Lines • Show Last 20 Lines |