summaryrefslogtreecommitdiff
path: root/src/Compositor.cpp
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-07-26 17:30:30 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-07-26 17:30:30 +0200
commit6f2368f8094b8e2f62006a909317e1bb6cc4320f (patch)
tree65a2c71b7c129151bb6eb7a6e944a9319d415129 /src/Compositor.cpp
parent7dc014e967260ce576eaa5d4b0775a2a03bee969 (diff)
Add a pass dispatcher
Diffstat (limited to 'src/Compositor.cpp')
-rw-r--r--src/Compositor.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index 9e4957dc..2b7a78c7 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -1421,4 +1421,59 @@ void CCompositor::scheduleFrameForMonitor(SMonitor* pMonitor) {
return;
wlr_output_schedule_frame(pMonitor->output);
+}
+
+CWindow* CCompositor::getWindowByRegex(const std::string& regexp) {
+ eFocusWindowMode mode = MODE_CLASS_REGEX;
+
+ std::regex regexCheck(regexp);
+ std::string matchCheck;
+ if (regexp.find("title:") == 0) {
+ 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;
+
+ 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;
+ }
+
+ return w.get();
+ }
+
+ return nullptr;
} \ No newline at end of file