Add fullscreen_action to set what action to take if a window is

fullscreen
This commit is contained in:
Zakk
2025-04-16 04:08:16 -04:00
parent f907f95e3e
commit 167cda0f20
3 changed files with 28 additions and 3 deletions

View File

@@ -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
}

View File

@@ -6,6 +6,7 @@
#include <hyprland/src/render/decorations/IHyprWindowDecoration.hpp>
#include <hyprland/src/render/OpenGL.hpp>
#include <hyprland/src/devices/IKeyboard.hpp>
#include <hyprland/src/desktop/Workspace.hpp>
#include "globals.hpp"
class CHyprEasyLabel : public IHyprWindowDecoration {
@@ -54,6 +55,7 @@ class CHyprEasyLabel : public IHyprWindowDecoration {
int m_iBorderSize;
CGradientValueData m_cBorderGradient;
WP<CHyprEasyLabel> m_self;
eFullscreenMode m_origFSMode;

View File

@@ -1,3 +1,4 @@
#include <hyprland/src/desktop/Workspace.hpp>
#include <hyprland/src/plugins/PluginAPI.hpp>
#include <unistd.h>
@@ -7,6 +8,7 @@
#include <hyprland/src/desktop/Window.hpp>
#include <hyprland/src/config/ConfigManager.hpp>
#include <hyprland/src/managers/EventManager.hpp>
#include <strings.h>
#include "easymotionDeco.hpp"
#include "globals.hpp"
@@ -20,6 +22,8 @@ APICALL EXPORT std::string PLUGIN_API_VERSION() {
SDispatchResult easymotionExitDispatch(std::string args)
{
for (auto &ml : g_pGlobalState->motionLabels | std::ranges::views::reverse) {
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");
@@ -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<CHyprEasyLabel> motionlabel = makeUnique<CHyprEasyLabel>(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<SGlobalState>();