summaryrefslogtreecommitdiff
path: root/src/managers/KeybindManager.cpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2022-07-18 23:19:12 +0200
committerGitHub <noreply@github.com>2022-07-18 23:19:12 +0200
commitf35d513bf55d5232936f017aa2697a6b4d64f6e6 (patch)
tree9dfaf54fc3507207cf97130f0ee16b25b9fb9b64 /src/managers/KeybindManager.cpp
parent10a83853ac1785d4dabcef3920ebc5a74fc7707f (diff)
parentf2c0e6ef02ebc639c525a24fcf532b989d2340bb (diff)
Merge pull request #391 from dgerblick/focuswindow-options
focuswindow options + other hyprctl bugs I found when testing
Diffstat (limited to 'src/managers/KeybindManager.cpp')
-rw-r--r--src/managers/KeybindManager.cpp51
1 files changed, 40 insertions, 11 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 1ad338cd..2c91f81f 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -1067,28 +1067,57 @@ void CKeybindManager::circleNext(std::string arg) {
}
void CKeybindManager::focusWindow(std::string regexp) {
- bool titleRegex = false;
+ eFocusWindowMode mode = MODE_CLASS_REGEX;
+
std::regex regexCheck(regexp);
+ std::string matchCheck;
if (regexp.find("title:") == 0) {
- titleRegex = true;
+ mode = MODE_TITLE_REGEX;
regexCheck = std::regex(regexp.substr(6));
}
+ else if (regexp.find("address:") == 0) {
+ mode = MODE_ADDRESS;
+ matchCheck = regexp.substr(8);
+ }
+ else if (regexp.find("pid:") == 0) {
+ mode = MODE_PID;
+ matchCheck = regexp.substr(4);
+ }
for (auto& w : g_pCompositor->m_vWindows) {
if (!w->m_bIsMapped || w->m_bHidden)
continue;
- if (titleRegex) {
- const auto windowTitle = g_pXWaylandManager->getTitle(w.get());
- if (!std::regex_search(windowTitle, regexCheck))
- continue;
- }
- else {
- const auto windowClass = g_pXWaylandManager->getAppIDClass(w.get());
- if (!std::regex_search(windowClass, regexCheck))
- continue;
+ switch (mode) {
+ case MODE_CLASS_REGEX: {
+ const auto windowClass = g_pXWaylandManager->getAppIDClass(w.get());
+ if (!std::regex_search(g_pXWaylandManager->getAppIDClass(w.get()), regexCheck))
+ continue;
+ break;
+ }
+ case MODE_TITLE_REGEX: {
+ const auto windowTitle = g_pXWaylandManager->getTitle(w.get());
+ if (!std::regex_search(windowTitle, regexCheck))
+ continue;
+ break;
+ }
+ case MODE_ADDRESS: {
+ std::string addr = getFormat("0x%x", w.get());
+ if (matchCheck != addr)
+ continue;
+ break;
+ }
+ case MODE_PID: {
+ std::string pid = getFormat("%d", w->getPID());
+ if (matchCheck != pid)
+ continue;
+ break;
+ }
+ default:
+ break;
}
+
Debug::log(LOG, "Focusing to window name: %s", w->m_szTitle.c_str());
changeworkspace("[internal]" + std::to_string(w->m_iWorkspaceID));