mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-23 05:25:58 +01:00
Merge pull request #292 from Dakes/focus-window-title
Changed dispatcher: focusWindowByClass -> focusWindow. Now supports titles & classes
This commit is contained in:
commit
3d294b1aaa
2 changed files with 20 additions and 8 deletions
|
@ -30,7 +30,8 @@ CKeybindManager::CKeybindManager() {
|
||||||
m_mDispatchers["resizeactive"] = resizeActive;
|
m_mDispatchers["resizeactive"] = resizeActive;
|
||||||
m_mDispatchers["moveactive"] = moveActive;
|
m_mDispatchers["moveactive"] = moveActive;
|
||||||
m_mDispatchers["cyclenext"] = circleNext;
|
m_mDispatchers["cyclenext"] = circleNext;
|
||||||
m_mDispatchers["focuswindowbyclass"] = focusWindowByClass;
|
m_mDispatchers["focuswindowbyclass"] = focusWindow;
|
||||||
|
m_mDispatchers["focuswindow"] = focusWindow;
|
||||||
m_mDispatchers["submap"] = setSubmap;
|
m_mDispatchers["submap"] = setSubmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1017,17 +1018,28 @@ void CKeybindManager::circleNext(std::string) {
|
||||||
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, MIDPOINT.x, MIDPOINT.y);
|
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, MIDPOINT.x, MIDPOINT.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKeybindManager::focusWindowByClass(std::string clazz) {
|
void CKeybindManager::focusWindow(std::string regexp) {
|
||||||
std::regex classCheck(clazz);
|
bool titleRegex = false;
|
||||||
|
std::regex regexCheck(regexp);
|
||||||
|
if (regexp.find("title:") == 0) {
|
||||||
|
titleRegex = true;
|
||||||
|
regexCheck = std::regex(regexp.substr(6));
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
const auto windowClass = g_pXWaylandManager->getAppIDClass(w.get());
|
if (titleRegex) {
|
||||||
|
const auto windowTitle = g_pXWaylandManager->getTitle(w.get());
|
||||||
if (!std::regex_search(windowClass, classCheck))
|
if (!std::regex_search(windowTitle, regexCheck))
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const auto windowClass = g_pXWaylandManager->getAppIDClass(w.get());
|
||||||
|
if (!std::regex_search(windowClass, regexCheck))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
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());
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ private:
|
||||||
static void resizeActive(std::string);
|
static void resizeActive(std::string);
|
||||||
static void moveActive(std::string);
|
static void moveActive(std::string);
|
||||||
static void circleNext(std::string);
|
static void circleNext(std::string);
|
||||||
static void focusWindowByClass(std::string);
|
static void focusWindow(std::string);
|
||||||
static void setSubmap(std::string);
|
static void setSubmap(std::string);
|
||||||
|
|
||||||
friend class CCompositor;
|
friend class CCompositor;
|
||||||
|
|
Loading…
Reference in a new issue