Skip to content

Commit

Permalink
selectors: add a tag: to for matching window tag(s) by regex (#8985)
Browse files Browse the repository at this point in the history
  • Loading branch information
zakk4223 authored Jan 9, 2025
1 parent e66eab7 commit 2d1ebad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2401,6 +2401,9 @@ PHLWINDOW CCompositor::getWindowByRegex(const std::string& regexp_) {
} else if (regexp.starts_with("initialtitle:")) {
mode = MODE_INITIAL_TITLE_REGEX;
regexCheck = regexp.substr(13);
} else if (regexp.starts_with("tag:")) {
mode = MODE_TAG_REGEX;
regexCheck = regexp.substr(4);
} else if (regexp.starts_with("address:")) {
mode = MODE_ADDRESS;
matchCheck = regexp.substr(8);
Expand Down Expand Up @@ -2438,6 +2441,18 @@ PHLWINDOW CCompositor::getWindowByRegex(const std::string& regexp_) {
continue;
break;
}
case MODE_TAG_REGEX: {
bool tagMatched = false;
for (auto const& t : w->m_tags.getTags()) {
if (RE2::FullMatch(t, regexCheck)) {
tagMatched = true;
break;
}
}
if (!tagMatched)
continue;
break;
}
case MODE_ADDRESS: {
std::string addr = std::format("0x{:x}", (uintptr_t)w.get());
if (matchCheck != addr)
Expand Down
1 change: 1 addition & 0 deletions src/managers/KeybindManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ enum eFocusWindowMode : uint8_t {
MODE_INITIAL_CLASS_REGEX,
MODE_TITLE_REGEX,
MODE_INITIAL_TITLE_REGEX,
MODE_TAG_REGEX,
MODE_ADDRESS,
MODE_PID,
MODE_ACTIVE_WINDOW
Expand Down

0 comments on commit 2d1ebad

Please sign in to comment.