mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 07:05:58 +01:00
added focuswindowbyclass
This commit is contained in:
parent
90a859af27
commit
3a2ac11e3e
2 changed files with 27 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
|||
#include "KeybindManager.hpp"
|
||||
|
||||
#include <regex>
|
||||
|
||||
CKeybindManager::CKeybindManager() {
|
||||
// initialize all dispatchers
|
||||
|
||||
|
@ -27,6 +29,7 @@ CKeybindManager::CKeybindManager() {
|
|||
m_mDispatchers["forcerendererreload"] = forceRendererReload;
|
||||
m_mDispatchers["resizeactive"] = resizeActive;
|
||||
m_mDispatchers["cyclenext"] = circleNext;
|
||||
m_mDispatchers["focuswindowbyclass"] = focusWindowByClass;
|
||||
}
|
||||
|
||||
void CKeybindManager::addKeybind(SKeybind kb) {
|
||||
|
@ -881,3 +884,26 @@ void CKeybindManager::circleNext(std::string) {
|
|||
|
||||
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, MIDPOINT.x, MIDPOINT.y);
|
||||
}
|
||||
|
||||
void CKeybindManager::focusWindowByClass(std::string clazz) {
|
||||
std::regex classCheck(clazz);
|
||||
|
||||
for (auto& w : g_pCompositor->m_lWindows) {
|
||||
const auto windowClass = g_pXWaylandManager->getAppIDClass(&w);
|
||||
|
||||
if (!std::regex_search(windowClass, classCheck))
|
||||
continue;
|
||||
|
||||
Debug::log(LOG, "Focusing to window name: %s", w.m_szTitle.c_str());
|
||||
|
||||
changeworkspace(std::to_string(w.m_iWorkspaceID));
|
||||
|
||||
g_pCompositor->focusWindow(&w);
|
||||
|
||||
const auto MIDPOINT = w.m_vRealPosition.goalv() + w.m_vRealSize.goalv() / 2.f;
|
||||
|
||||
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, MIDPOINT.x, MIDPOINT.y);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ private:
|
|||
static void forceRendererReload(std::string);
|
||||
static void resizeActive(std::string);
|
||||
static void circleNext(std::string);
|
||||
static void focusWindowByClass(std::string);
|
||||
|
||||
friend class CCompositor;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue