diff --git a/README.md b/README.md index d66aef8..41615b0 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,12 @@ plugin { #rounded corners? Same as hyprland's 'decoration:rounding' config rounding=0 + #what to do if a window is fullscreen + #none: nothing. (easymotion label won't be displayed on that window) + #toggle: take the window out of fullscreen entirely. + #maximize: convert the window to maximized. + #windows are restored to fullscreen after easymotion is exited/selected + fullscreen_action=none #which keys to use for labeling windows motionkeys=abcdefghijklmnopqrstuvwxyz1234567890 } diff --git a/easymotionDeco.hpp b/easymotionDeco.hpp index 1a68aa7..94c28dc 100644 --- a/easymotionDeco.hpp +++ b/easymotionDeco.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "globals.hpp" class CHyprEasyLabel : public IHyprWindowDecoration { @@ -54,6 +55,7 @@ class CHyprEasyLabel : public IHyprWindowDecoration { int m_iBorderSize; CGradientValueData m_cBorderGradient; WP m_self; + eFullscreenMode m_origFSMode; diff --git a/main.cpp b/main.cpp index 423ec74..b4230ce 100644 --- a/main.cpp +++ b/main.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -7,6 +8,7 @@ #include #include #include +#include #include "easymotionDeco.hpp" #include "globals.hpp" @@ -20,7 +22,9 @@ APICALL EXPORT std::string PLUGIN_API_VERSION() { SDispatchResult easymotionExitDispatch(std::string args) { for (auto &ml : g_pGlobalState->motionLabels | std::ranges::views::reverse) { - ml->getOwner()->removeWindowDeco(ml.get()); + if (ml->m_origFSMode != ml->getOwner()->m_sFullscreenState.internal) + g_pCompositor->setWindowFullscreenInternal(ml->getOwner(), ml->m_origFSMode); + ml->getOwner()->removeWindowDeco(ml.get()); } HyprlandAPI::invokeHyprctlCommand("dispatch", "submap reset"); g_pEventManager->postEvent(SHyprIPCEvent{"easymotionexit", ""}); @@ -54,10 +58,22 @@ void addEasyMotionKeybinds() void addLabelToWindow(PHLWINDOW window, SMotionActionDesc *actionDesc, std::string &label) { + static auto *const FSACTION = (Hyprlang::STRING const *)HyprlandAPI::getConfigValue(PHANDLE, "plugin:easymotion:fullscreen_action")->getDataStaticPtr(); UP motionlabel = makeUnique(window, actionDesc); motionlabel->m_szLabel = label; g_pGlobalState->motionLabels.emplace_back(motionlabel); motionlabel->m_self = motionlabel; + motionlabel->draw(window->m_pMonitor.lock(), 1.0); + motionlabel->m_origFSMode = window->m_sFullscreenState.internal; + if ((motionlabel->m_origFSMode != eFullscreenMode::FSMODE_NONE) && strcasecmp(*FSACTION, "none")) + { + if (!strcasecmp(*FSACTION, "maximize")) + { + g_pCompositor->setWindowFullscreenInternal(window, FSMODE_MAXIMIZED); + } else if (!strcasecmp(*FSACTION, "toggle")) { + g_pCompositor->setWindowFullscreenInternal(window, FSMODE_NONE); + } + } HyprlandAPI::addWindowDecoration(PHANDLE, window, std::move(motionlabel)); } @@ -183,11 +199,11 @@ 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 (w->m_pWorkspace->m_bHasFullscreenWindow && + /*if (w->m_pWorkspace->m_bHasFullscreenWindow && w->m_pWorkspace->getFullscreenWindow() != w) { continue; - } + }*/ std::string lstr = actionDesc.motionKeys.substr(key_idx++, 1); addLabelToWindow(w, &actionDesc, lstr); } @@ -247,6 +263,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { HyprlandAPI::addConfigValue(PHANDLE, "plugin:easymotion:blurA", Hyprlang::FLOAT{1.0f}); 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"}); g_pGlobalState = makeUnique();