mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-23 10:09:49 +01:00
added PID and address-based options for focuswindow, as well as updated hyprctl clients
to be consistent with logs and hyprctl activewindow
This commit is contained in:
parent
afeb040684
commit
dc1f34c5fa
3 changed files with 50 additions and 14 deletions
|
@ -86,7 +86,7 @@ R"#({
|
||||||
"title": "%s",
|
"title": "%s",
|
||||||
"pid": %i
|
"pid": %i
|
||||||
},)#",
|
},)#",
|
||||||
&w,
|
w.get(),
|
||||||
(int)w->m_vRealPosition.vec().x, (int)w->m_vRealPosition.vec().y,
|
(int)w->m_vRealPosition.vec().x, (int)w->m_vRealPosition.vec().y,
|
||||||
(int)w->m_vRealSize.vec().x, (int)w->m_vRealSize.vec().y,
|
(int)w->m_vRealSize.vec().x, (int)w->m_vRealSize.vec().y,
|
||||||
w->m_iWorkspaceID, (w->m_iWorkspaceID == -1 ? "" : g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_szName.c_str() : std::string("Invalid workspace " + std::to_string(w->m_iWorkspaceID)).c_str()),
|
w->m_iWorkspaceID, (w->m_iWorkspaceID == -1 ? "" : g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_szName.c_str() : std::string("Invalid workspace " + std::to_string(w->m_iWorkspaceID)).c_str()),
|
||||||
|
@ -107,7 +107,7 @@ R"#({
|
||||||
for (auto& w : g_pCompositor->m_vWindows) {
|
for (auto& w : g_pCompositor->m_vWindows) {
|
||||||
if (w->m_bIsMapped) {
|
if (w->m_bIsMapped) {
|
||||||
result += getFormat("Window %x -> %s:\n\tat: %i,%i\n\tsize: %i,%i\n\tworkspace: %i (%s)\n\tfloating: %i\n\tmonitor: %i\n\tclass: %s\n\ttitle: %s\n\tpid: %i\n\n",
|
result += getFormat("Window %x -> %s:\n\tat: %i,%i\n\tsize: %i,%i\n\tworkspace: %i (%s)\n\tfloating: %i\n\tmonitor: %i\n\tclass: %s\n\ttitle: %s\n\tpid: %i\n\n",
|
||||||
&w, w->m_szTitle.c_str(), (int)w->m_vRealPosition.vec().x, (int)w->m_vRealPosition.vec().y, (int)w->m_vRealSize.vec().x, (int)w->m_vRealSize.vec().y, w->m_iWorkspaceID, (w->m_iWorkspaceID == -1 ? "" : g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_szName.c_str() : std::string("Invalid workspace " + std::to_string(w->m_iWorkspaceID)).c_str()), (int)w->m_bIsFloating, w->m_iMonitorID, g_pXWaylandManager->getAppIDClass(w.get()).c_str(), g_pXWaylandManager->getTitle(w.get()).c_str(), w->getPID());
|
w.get(), w->m_szTitle.c_str(), (int)w->m_vRealPosition.vec().x, (int)w->m_vRealPosition.vec().y, (int)w->m_vRealSize.vec().x, (int)w->m_vRealSize.vec().y, w->m_iWorkspaceID, (w->m_iWorkspaceID == -1 ? "" : g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_szName.c_str() : std::string("Invalid workspace " + std::to_string(w->m_iWorkspaceID)).c_str()), (int)w->m_bIsFloating, w->m_iMonitorID, g_pXWaylandManager->getAppIDClass(w.get()).c_str(), g_pXWaylandManager->getTitle(w.get()).c_str(), w->getPID());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1063,28 +1063,57 @@ void CKeybindManager::circleNext(std::string arg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKeybindManager::focusWindow(std::string regexp) {
|
void CKeybindManager::focusWindow(std::string regexp) {
|
||||||
bool titleRegex = false;
|
eFocusWindowMode mode = MODE_CLASS_REGEX;
|
||||||
|
|
||||||
std::regex regexCheck(regexp);
|
std::regex regexCheck(regexp);
|
||||||
|
std::string matchCheck;
|
||||||
if (regexp.find("title:") == 0) {
|
if (regexp.find("title:") == 0) {
|
||||||
titleRegex = true;
|
mode = MODE_TITLE_REGEX;
|
||||||
regexCheck = std::regex(regexp.substr(6));
|
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) {
|
for (auto& w : g_pCompositor->m_vWindows) {
|
||||||
if (!w->m_bIsMapped || w->m_bHidden)
|
if (!w->m_bIsMapped || w->m_bHidden)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (titleRegex) {
|
switch (mode) {
|
||||||
const auto windowTitle = g_pXWaylandManager->getTitle(w.get());
|
case MODE_CLASS_REGEX: {
|
||||||
if (!std::regex_search(windowTitle, regexCheck))
|
const auto windowClass = g_pXWaylandManager->getAppIDClass(w.get());
|
||||||
continue;
|
if (!std::regex_search(g_pXWaylandManager->getAppIDClass(w.get()), regexCheck))
|
||||||
}
|
continue;
|
||||||
else {
|
break;
|
||||||
const auto windowClass = g_pXWaylandManager->getAppIDClass(w.get());
|
}
|
||||||
if (!std::regex_search(windowClass, regexCheck))
|
case MODE_TITLE_REGEX: {
|
||||||
continue;
|
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());
|
Debug::log(LOG, "Focusing to window name: %s", w->m_szTitle.c_str());
|
||||||
|
|
||||||
changeworkspace("[internal]" + std::to_string(w->m_iWorkspaceID));
|
changeworkspace("[internal]" + std::to_string(w->m_iWorkspaceID));
|
||||||
|
|
|
@ -66,6 +66,13 @@ private:
|
||||||
static void setSubmap(std::string);
|
static void setSubmap(std::string);
|
||||||
|
|
||||||
friend class CCompositor;
|
friend class CCompositor;
|
||||||
|
|
||||||
|
enum eFocusWindowMode {
|
||||||
|
MODE_CLASS_REGEX = 0,
|
||||||
|
MODE_TITLE_REGEX,
|
||||||
|
MODE_ADDRESS,
|
||||||
|
MODE_PID
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::unique_ptr<CKeybindManager> g_pKeybindManager;
|
inline std::unique_ptr<CKeybindManager> g_pKeybindManager;
|
Loading…
Reference in a new issue