mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-02 21:05:57 +01:00
config: Expand on window matching (#5518)
* Expand on window matching * Requested changes
This commit is contained in:
parent
f47c89d495
commit
e69bc5b870
2 changed files with 29 additions and 3 deletions
|
@ -2410,13 +2410,24 @@ void CCompositor::scheduleFrameForMonitor(CMonitor* pMonitor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CWindow* CCompositor::getWindowByRegex(const std::string& regexp) {
|
CWindow* CCompositor::getWindowByRegex(const std::string& regexp) {
|
||||||
|
if (regexp.starts_with("active"))
|
||||||
|
return m_pLastWindow;
|
||||||
|
|
||||||
eFocusWindowMode mode = MODE_CLASS_REGEX;
|
eFocusWindowMode mode = MODE_CLASS_REGEX;
|
||||||
|
|
||||||
std::regex regexCheck(regexp);
|
std::regex regexCheck(regexp);
|
||||||
std::string matchCheck;
|
std::string matchCheck;
|
||||||
if (regexp.starts_with("title:")) {
|
if (regexp.starts_with("class:")) {
|
||||||
|
regexCheck = std::regex(regexp.substr(6));
|
||||||
|
} else if (regexp.starts_with("initialclass:")) {
|
||||||
|
mode = MODE_INITIAL_CLASS_REGEX;
|
||||||
|
regexCheck = std::regex(regexp.substr(13));
|
||||||
|
} else if (regexp.starts_with("title:")) {
|
||||||
mode = MODE_TITLE_REGEX;
|
mode = MODE_TITLE_REGEX;
|
||||||
regexCheck = std::regex(regexp.substr(6));
|
regexCheck = std::regex(regexp.substr(6));
|
||||||
|
} else if (regexp.starts_with("initialtitle:")) {
|
||||||
|
mode = MODE_INITIAL_TITLE_REGEX;
|
||||||
|
regexCheck = std::regex(regexp.substr(13));
|
||||||
} else if (regexp.starts_with("address:")) {
|
} else if (regexp.starts_with("address:")) {
|
||||||
mode = MODE_ADDRESS;
|
mode = MODE_ADDRESS;
|
||||||
matchCheck = regexp.substr(8);
|
matchCheck = regexp.substr(8);
|
||||||
|
@ -2447,7 +2458,13 @@ CWindow* CCompositor::getWindowByRegex(const std::string& regexp) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case MODE_CLASS_REGEX: {
|
case MODE_CLASS_REGEX: {
|
||||||
const auto windowClass = g_pXWaylandManager->getAppIDClass(w.get());
|
const auto windowClass = g_pXWaylandManager->getAppIDClass(w.get());
|
||||||
if (!std::regex_search(g_pXWaylandManager->getAppIDClass(w.get()), regexCheck))
|
if (!std::regex_search(windowClass, regexCheck))
|
||||||
|
continue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MODE_INITIAL_CLASS_REGEX: {
|
||||||
|
const auto initialWindowClass = w->m_szInitialClass;
|
||||||
|
if (!std::regex_search(initialWindowClass, regexCheck))
|
||||||
continue;
|
continue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2457,6 +2474,12 @@ CWindow* CCompositor::getWindowByRegex(const std::string& regexp) {
|
||||||
continue;
|
continue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case MODE_INITIAL_TITLE_REGEX: {
|
||||||
|
const auto initialWindowTitle = w->m_szInitialTitle;
|
||||||
|
if (!std::regex_search(initialWindowTitle, regexCheck))
|
||||||
|
continue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case MODE_ADDRESS: {
|
case MODE_ADDRESS: {
|
||||||
std::string addr = std::format("0x{:x}", (uintptr_t)w.get());
|
std::string addr = std::format("0x{:x}", (uintptr_t)w.get());
|
||||||
if (matchCheck != addr)
|
if (matchCheck != addr)
|
||||||
|
|
|
@ -32,9 +32,12 @@ struct SKeybind {
|
||||||
|
|
||||||
enum eFocusWindowMode {
|
enum eFocusWindowMode {
|
||||||
MODE_CLASS_REGEX = 0,
|
MODE_CLASS_REGEX = 0,
|
||||||
|
MODE_INITIAL_CLASS_REGEX,
|
||||||
MODE_TITLE_REGEX,
|
MODE_TITLE_REGEX,
|
||||||
|
MODE_INITIAL_TITLE_REGEX,
|
||||||
MODE_ADDRESS,
|
MODE_ADDRESS,
|
||||||
MODE_PID
|
MODE_PID,
|
||||||
|
MODE_ACTIVE_WINDOW
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SPressedKeyWithMods {
|
struct SPressedKeyWithMods {
|
||||||
|
|
Loading…
Reference in a new issue