diff --git a/README.md b/README.md index 5b32e72..f61e234 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,9 @@ plugin { #which keys to use for labeling windows motionkeys=abcdefghijklmnopqrstuvwxyz1234567890 + + #if a monitor has a focused special workspace, only put easymotion labels on the windows in the special workspace + only_special = true } } ``` diff --git a/globals.hpp b/globals.hpp index 1322568..a0b5364 100644 --- a/globals.hpp +++ b/globals.hpp @@ -26,6 +26,7 @@ struct SMotionActionDesc { float blurA = 1.0f; std::string motionKeys = "abcdefghijklmnopqrstuvwxyz1234567890"; std::string fullscreen_action = "none"; + int only_special = 1; }; inline UP g_pGlobalState; diff --git a/main.cpp b/main.cpp index 29b4e7d..82ebee6 100644 --- a/main.cpp +++ b/main.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -135,6 +136,7 @@ SDispatchResult easymotionDispatch(std::string args) static auto *const BLURA = (Hyprlang::FLOAT* const *)HyprlandAPI::getConfigValue(PHANDLE, "plugin:easymotion:blurA")->getDataStaticPtr(); static auto *const MOTIONKEYS = (Hyprlang::STRING const *)HyprlandAPI::getConfigValue(PHANDLE, "plugin:easymotion:motionkeys")->getDataStaticPtr(); static auto *const FSACTION = (Hyprlang::STRING const *)HyprlandAPI::getConfigValue(PHANDLE, "plugin:easymotion:fullscreen_action")->getDataStaticPtr(); + static auto *const ONLYSPECIAL = (Hyprlang::INT* const *)HyprlandAPI::getConfigValue(PHANDLE, "plugin:easymotion:only_special")->getDataStaticPtr(); CVarList emargs(args, 0, ','); @@ -157,6 +159,7 @@ SDispatchResult easymotionDispatch(std::string args) actionDesc.xray = **XRAY; actionDesc.blurA = **BLURA; actionDesc.fullscreen_action = std::string(*FSACTION); + actionDesc.only_special = **ONLYSPECIAL; for(size_t i = 0; i < emargs.size(); i++) @@ -190,8 +193,20 @@ SDispatchResult easymotionDispatch(std::string args) } } else if (kv[0] == "motionkeys") { actionDesc.motionKeys = kv[1]; + } else if (kv[0] == "blur") { + actionDesc.blur = configStringToInt(kv[1]).value_or(1); + } else if (kv[0] == "xray") { + actionDesc.xray = configStringToInt(kv[1]).value_or(1); + } else if (kv[0] == "blurA") { + try { + actionDesc.blurA = std::stof(kv[1]); + } catch (const std::invalid_argument& ia) { + actionDesc.blurA = 1.0f; + } } else if (kv[0] == "fullscreen_action") { actionDesc.fullscreen_action = kv[1]; + } else if (kv[0] == "only_special") { + actionDesc.only_special = configStringToInt(kv[1]).value_or(1); } } @@ -203,6 +218,8 @@ SDispatchResult easymotionDispatch(std::string args) if (w->m_pWorkspace == m->activeWorkspace || m->activeSpecialWorkspace == w->m_pWorkspace) { if (w->isHidden() || !w->m_bIsMapped || w->m_bFadingOut) continue; + if (m->activeSpecialWorkspace && w->m_pWorkspace != m->activeSpecialWorkspace && actionDesc.only_special) + continue; std::string lstr = actionDesc.motionKeys.substr(key_idx++, 1); addLabelToWindow(w, &actionDesc, lstr); } @@ -263,6 +280,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { HyprlandAPI::addConfigValue(PHANDLE, "plugin:easymotion:xray", Hyprlang::INT{0}); HyprlandAPI::addConfigValue(PHANDLE, "plugin:easymotion:motionkeys", Hyprlang::STRING{"abcdefghijklmnopqrstuvwxyz1234567890"}); HyprlandAPI::addConfigValue(PHANDLE, "plugin:easymotion:fullscreen_action", Hyprlang::STRING{"none"}); + HyprlandAPI::addConfigValue(PHANDLE, "plugin:easymotion:only_special", Hyprlang::INT{1}); g_pGlobalState = makeUnique();