diff options
| author | JManch <61563764+JManch@users.noreply.github.com> | 2024-10-08 17:50:06 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-08 17:50:06 +0100 |
| commit | e4a26f4f1d9d30569b9e7e6c265fccfd42fa5d72 (patch) | |
| tree | 0251f09426d4aebf73fdc6d78cd79ce1503a19cc /src/Compositor.cpp | |
| parent | 57b632ead88b4558a53e52aa9c098d48362ee768 (diff) | |
dispatchers: allow leading whitespace in window parameter (#8016)
Diffstat (limited to 'src/Compositor.cpp')
| -rw-r--r-- | src/Compositor.cpp | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp index f00e1e34..459aca11 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -2445,13 +2445,31 @@ void CCompositor::scheduleFrameForMonitor(CMonitor* pMonitor, IOutput::scheduleF pMonitor->output->scheduleFrame(reason); } -PHLWINDOW CCompositor::getWindowByRegex(const std::string& regexp) { +PHLWINDOW CCompositor::getWindowByRegex(const std::string& regexp_) { + auto regexp = trim(regexp_); + if (regexp.starts_with("active")) return m_pLastWindow.lock(); + else if (regexp.starts_with("floating") || regexp.starts_with("tiled")) { + // first floating on the current ws + if (!valid(m_pLastWindow)) + return nullptr; + + const bool FLOAT = regexp.starts_with("floating"); + + for (auto const& w : m_vWindows) { + if (!w->m_bIsMapped || w->m_bIsFloating != FLOAT || w->m_pWorkspace != m_pLastWindow->m_pWorkspace || w->isHidden()) + continue; + + return w; + } + + return nullptr; + } eFocusWindowMode mode = MODE_CLASS_REGEX; - std::regex regexCheck(regexp); + std::regex regexCheck(regexp_); std::string matchCheck; if (regexp.starts_with("class:")) { regexCheck = std::regex(regexp.substr(6)); @@ -2470,21 +2488,6 @@ PHLWINDOW CCompositor::getWindowByRegex(const std::string& regexp) { } else if (regexp.starts_with("pid:")) { mode = MODE_PID; matchCheck = regexp.substr(4); - } else if (regexp.starts_with("floating") || regexp.starts_with("tiled")) { - // first floating on the current ws - if (!valid(m_pLastWindow)) - return nullptr; - - const bool FLOAT = regexp.starts_with("floating"); - - for (auto const& w : m_vWindows) { - if (!w->m_bIsMapped || w->m_bIsFloating != FLOAT || w->m_pWorkspace != m_pLastWindow->m_pWorkspace || w->isHidden()) - continue; - - return w; - } - - return nullptr; } for (auto const& w : g_pCompositor->m_vWindows) { |
