config: remove legacy config support (#15539)

This commit is contained in:
Vaxry
2026-07-22 18:35:10 +02:00
committed by GitHub
parent 4588b2958e
commit a9902ea65f
29 changed files with 102 additions and 3696 deletions
-3
View File
@@ -901,9 +901,6 @@ void CCompositor::performUserChecks() {
CHyprColor{1.0, 0.1, 0.1, 1.0}, 15000, ICON_ERROR);
}
if (Config::mgr()->type() == Config::CONFIG_LEGACY)
Notification::overlay()->addNotification(I18n::i18nEngine()->localize(I18n::TXT_KEY_NOTIF_OUTDATED_CONFIG), CHyprColor{}, 15000, ICON_WARNING);
if (!m_watchdogWriteFd.isValid() && !*PNOWATCHDOG)
Notification::overlay()->addNotification(I18n::i18nEngine()->localize(I18n::TXT_KEY_NOTIF_NO_WATCHDOG), CHyprColor{1.0, 0.1, 0.1, 1.0}, 15000, ICON_WARNING);
+3 -22
View File
@@ -1,6 +1,5 @@
#include "ConfigManager.hpp"
#include "supplementary/jeremy/Jeremy.hpp"
#include "legacy/ConfigManager.hpp"
#include "lua/ConfigManager.hpp"
#include "../debug/log/Logger.hpp"
@@ -28,27 +27,10 @@ bool Config::initConfigManager() {
if (CFG_PATH->type == Supplementary::Jeremy::CONFIG_TYPE_REGULAR) {
Log::logger->log(Log::DEBUG, "[cfg] Regular config at {}", filePath.string());
std::error_code ec;
if (filePath.extension() == ".lua") {
// we have lua!
Log::logger->log(Log::DEBUG, "[cfg] Using lua config found at {}", filePath.string());
g_mgr = makeUnique<Lua::CConfigManager>();
} else {
filePath.replace_extension(".conf");
Log::logger->log(Log::DEBUG, "[cfg] Lua config not found, using legacy config at {}", filePath.string());
g_mgr = makeUnique<Legacy::CConfigManager>();
}
g_mgr = makeUnique<Lua::CConfigManager>();
} else {
Log::logger->log(Log::DEBUG, "[cfg] Config is either explicit or special.");
if (filePath.extension() == ".lua") {
Log::logger->log(Log::DEBUG, "[cfg] Config is lua, loading lua mgr");
g_mgr = makeUnique<Lua::CConfigManager>();
} else {
Log::logger->log(Log::DEBUG, "[cfg] Config is NOT lua, loading regular mgr");
g_mgr = makeUnique<Legacy::CConfigManager>();
}
Log::logger->log(Log::DEBUG, "[cfg] Config is either explicit or special");
g_mgr = makeUnique<Lua::CConfigManager>();
}
RASSERT(g_mgr, "failed to create a suitable config manager");
@@ -77,7 +59,6 @@ UP<IConfigManager>& Config::mgr() {
const char* Config::typeToString(eConfigManagerType t) {
switch (t) {
case CONFIG_LUA: return "lua";
case CONFIG_LEGACY: return "hyprlang";
default: return "error";
}
}
+1 -2
View File
@@ -25,8 +25,7 @@ namespace Config {
};
enum eConfigManagerType : uint8_t {
CONFIG_LEGACY = 0,
CONFIG_LUA
CONFIG_LUA,
};
const char* typeToString(eConfigManagerType t);
File diff suppressed because it is too large Load Diff
-155
View File
@@ -1,155 +0,0 @@
#pragma once
#include <hyprutils/animation/AnimationConfig.hpp>
#include <vector>
#include <optional>
#include <xf86drmMode.h>
#include "../../desktop/DesktopTypes.hpp"
#include "../../desktop/rule/Rule.hpp"
#include "../../helpers/memory/Memory.hpp"
#include "../../managers/KeybindManager.hpp"
#include "../ConfigManager.hpp"
#include <hyprlang.hpp>
#define HANDLE void*
namespace Config::Supplementary {
struct SConfigOptionDescription;
};
namespace Config::Legacy {
class CConfigManager;
struct SPluginKeyword {
HANDLE handle = nullptr;
std::string name = "";
Hyprlang::PCONFIGHANDLERFUNC fn = nullptr;
};
struct SPluginVariable {
HANDLE handle = nullptr;
std::string name = "";
};
class CConfigManager : public Config::IConfigManager {
public:
CConfigManager();
virtual eConfigManagerType type() override;
virtual void init() override;
virtual void reload() override;
virtual std::string verify() override;
virtual int getDeviceInt(const std::string&, const std::string&, const std::string& fallback = "") override;
virtual float getDeviceFloat(const std::string&, const std::string&, const std::string& fallback = "") override;
virtual Vector2D getDeviceVec(const std::string&, const std::string&, const std::string& fallback = "") override;
virtual std::string getDeviceString(const std::string&, const std::string&, const std::string& fallback = "") override;
virtual bool deviceConfigExplicitlySet(const std::string&, const std::string&) override;
virtual bool deviceConfigExists(const std::string&) override;
virtual SConfigOptionReply getConfigValue(const std::string&) override;
virtual std::string getMainConfigPath() override;
virtual std::string getErrors() override;
virtual std::string getConfigString() override;
virtual std::string currentConfigPath() override;
virtual const std::vector<std::string>& getConfigPaths() override;
virtual std::expected<void, std::string> generateDefaultConfig(const std::filesystem::path&, bool safeMode) override;
virtual void handlePluginLoads() override;
virtual bool configVerifPassed() override;
virtual std::expected<void, std::string> registerPluginValue(void* handle, SP<Config::Values::IValue> value) override;
virtual void onPluginUnload(void* handle) override;
void addPluginConfigVar(HANDLE handle, const std::string& name, const Hyprlang::CConfigValue& value);
void addPluginKeyword(HANDLE handle, const std::string& name, Hyprlang::PCONFIGHANDLERFUNC fun, Hyprlang::SHandlerOptions opts = {});
void removePluginConfig(HANDLE handle);
std::string parseKeyword(const std::string&, const std::string&);
Hyprlang::CConfigValue* getHyprlangConfigValuePtr(const std::string& name, const std::string& specialCat = "");
// keywords
std::optional<std::string> handleRawExec(const std::string&, const std::string&);
std::optional<std::string> handleExec(const std::string&, const std::string&);
std::optional<std::string> handleExecOnce(const std::string&, const std::string&);
std::optional<std::string> handleExecRawOnce(const std::string&, const std::string&);
std::optional<std::string> handleExecShutdown(const std::string&, const std::string&);
std::optional<std::string> handleMonitor(const std::string&, const std::string&);
std::optional<std::string> handleBind(const std::string&, const std::string&);
std::optional<std::string> handleUnbind(const std::string&, const std::string&);
std::optional<std::string> handleWorkspaceRules(const std::string&, const std::string&);
std::optional<std::string> handleBezier(const std::string&, const std::string&);
std::optional<std::string> handleAnimation(const std::string&, const std::string&);
std::optional<std::string> handleSource(const std::string&, const std::string&);
std::optional<std::string> handleSubmap(const std::string&, const std::string&);
std::optional<std::string> handleBindWS(const std::string&, const std::string&);
std::optional<std::string> handleEnv(const std::string&, const std::string&);
std::optional<std::string> handlePlugin(const std::string&, const std::string&);
std::optional<std::string> handlePermission(const std::string&, const std::string&);
std::optional<std::string> handleGesture(const std::string&, const std::string&);
std::optional<std::string> handleWindowrule(const std::string&, const std::string&);
std::optional<std::string> handleLayerrule(const std::string&, const std::string&);
std::optional<std::string> handleMonitorv2(const std::string& output);
Hyprlang::CParseResult handleMonitorv2();
std::optional<std::string> addRuleFromConfigKey(const std::string& name);
std::optional<std::string> addLayerRuleFromConfigKey(const std::string& name);
Hyprlang::CParseResult reloadRules();
std::string m_configCurrentPath;
bool m_lastConfigVerificationWasSuccessful = true;
private:
// internal methods
std::optional<std::string> resetHLConfig();
std::optional<std::string> verifyConfigExists();
void reloadRuleConfigs();
void postConfigReload(const Hyprlang::CParseResult& result);
void registerConfigVar(const char* name, const Hyprlang::INT& val);
void registerConfigVar(const char* name, const Hyprlang::FLOAT& val);
void registerConfigVar(const char* name, const Hyprlang::VEC2& val);
void registerConfigVar(const char* name, const Hyprlang::STRING& val);
void registerConfigVar(const char* name, Hyprlang::CUSTOMTYPE&& val);
Hyprlang::CConfigValue* getConfigValueSafeDevice(const std::string& dev, const std::string& val, const std::string& fallback);
UP<Hyprlang::CConfig> m_config;
std::vector<std::string> m_configPaths;
std::string m_mainConfigPath;
SSubmap m_currentSubmap;
std::vector<std::string> m_declaredPlugins;
std::vector<SPluginKeyword> m_pluginKeywords;
std::vector<SPluginVariable> m_pluginVariables;
std::vector<SP<Desktop::Rule::IRule>> m_keywordRules;
bool m_isFirstLaunch = true; // For exec-once
bool m_firstExecDispatched = false;
bool m_manualCrashInitiated = false;
std::vector<std::pair<std::string, std::string>> m_failedPluginConfigValues; // for plugin values of unloaded plugins
std::string m_configErrors = "";
uint32_t m_configValueNumber = 0;
friend struct Config::Supplementary::SConfigOptionDescription;
friend class CMonitorRuleParser;
};
WP<CConfigManager> mgr();
}
-23
View File
@@ -1,23 +0,0 @@
#pragma once
#include <string_view>
inline constexpr std::string_view EXAMPLE_CONFIG = R"#(
# This config is a STUB! This should never be generated.
# Use the default lua config from https://github.com/hyprwm/Hyprland/blob/main/example/hyprland.lua
autogenerated = 1
$mainMod = SUPER
$terminal = kitty
$fileManager = dolphin
$menu = hyprlauncher
bind = $mainMod, Q, exec, $terminal
bind = $mainMod, C, killactive,
bind = $mainMod, M, exec, command -v hyprshutdown >/dev/null 2>&1 && hyprshutdown || hyprctl dispatch exit
bind = $mainMod, E, exec, $fileManager
bind = $mainMod, V, togglefloating,
bind = $mainMod, R, exec, $menu
)#";
-868
View File
@@ -1,868 +0,0 @@
#include "DispatcherTranslator.hpp"
#include "../shared/actions/ConfigActions.hpp"
#include "../supplementary/executor/Executor.hpp"
#include "../../Compositor.hpp"
#include "../../desktop/state/FocusState.hpp"
#include "../../output/Monitor.hpp"
#include "../../desktop/view/Group.hpp"
#include "../../managers/KeybindManager.hpp"
#include "../../managers/SeatManager.hpp"
#include "../../managers/input/InputManager.hpp"
#include "../../managers/fullscreen/FullscreenController.hpp"
#include "../../layout/LayoutManager.hpp"
#include "../../state/MonitorState.hpp"
#include "../../state/WorkspaceState.hpp"
#include <hyprutils/string/String.hpp>
#include <hyprutils/string/VarList2.hpp>
using namespace Hyprutils::String;
using namespace Config;
using namespace Config::Legacy;
using namespace Config::Actions;
UP<CDispatcherTranslator>& Legacy::translator() {
static UP<CDispatcherTranslator> p = makeUnique<CDispatcherTranslator>();
return p;
}
SDispatchResult CDispatcherTranslator::run(const std::string& d, const std::string& w) {
if (!m_dispMap.contains(d))
return {.success = false, .error = "Bad dispatcher"};
return m_dispMap.at(d)(w);
}
// helper: convert ActionResult to SDispatchResult
static SDispatchResult wrap(ActionResult res) {
if (!res)
return {.success = false, .error = res.error().message};
return {.passEvent = res->passEvent};
}
// helper: resolve window from regex string, or focused if empty/active
static std::optional<PHLWINDOW> windowFromArg(const std::string& arg) {
if (arg.empty() || arg == "active")
return std::nullopt; // will use xtract(nullopt) -> focused window
return Desktop::viewState()->query().selector(arg).runWindow();
}
// helper: resolve workspace from string and optionally create it
static PHLWORKSPACE resolveWorkspace(const std::string& args) {
const auto& [id, name, isAutoID] = getWorkspaceIDNameFromString(args);
if (id == WORKSPACE_INVALID)
return nullptr;
auto ws = State::workspaceState()->query().id(id).run();
if (!ws) {
const auto PMONITOR = Desktop::focusState()->monitor();
if (PMONITOR)
ws = State::workspaceState()->create(id, PMONITOR->m_id, name, false);
}
return ws;
}
static SDispatchResult exec(const std::string& args) {
const auto PROC = Config::Supplementary::executor()->spawn(args);
if (!PROC.has_value())
return {.success = false, .error = std::format("Failed to start process. No closing bracket in exec rule. {}", args)};
return {.success = PROC.value() > 0, .error = std::format("Failed to start process {}", args)};
}
static SDispatchResult execr(const std::string& args) {
const auto PROC = Config::Supplementary::executor()->spawnRaw(args);
return {.success = PROC && *PROC > 0, .error = std::format("Failed to start process {}", args)};
}
static SDispatchResult killactive(const std::string&) {
return wrap(Actions::closeWindow());
}
static SDispatchResult forcekillactive(const std::string&) {
return wrap(Actions::killWindow());
}
static SDispatchResult closewindow(const std::string& data) {
return wrap(Actions::closeWindow(Desktop::viewState()->query().selector(data).runWindow()));
}
static SDispatchResult killwindow(const std::string& data) {
return wrap(Actions::killWindow(Desktop::viewState()->query().selector(data).runWindow()));
}
static SDispatchResult signalactive(const std::string& args) {
if (!isNumber(args))
return {.success = false, .error = "signalActive: signal has to be int"};
try {
return wrap(Actions::signalWindow(std::stoi(args)));
} catch (...) { return {.success = false, .error = "signalActive: invalid signal format"}; }
}
static SDispatchResult signalwindow(const std::string& args) {
const auto WINDOWREGEX = args.substr(0, args.find_first_of(','));
const auto SIGNAL = args.substr(args.find_first_of(',') + 1);
const auto PWINDOW = Desktop::viewState()->query().selector(WINDOWREGEX).runWindow();
if (!PWINDOW)
return {.success = false, .error = "signalWindow: no window"};
if (!isNumber(SIGNAL))
return {.success = false, .error = "signalWindow: signal has to be int"};
try {
return wrap(Actions::signalWindow(std::stoi(SIGNAL), PWINDOW));
} catch (...) { return {.success = false, .error = "signalWindow: invalid signal format"}; }
}
static SDispatchResult togglefloating(const std::string& args) {
auto w = windowFromArg(args);
return wrap(Actions::floatWindow(TOGGLE_ACTION_TOGGLE, w));
}
static SDispatchResult setfloating(const std::string& args) {
auto w = windowFromArg(args);
return wrap(Actions::floatWindow(TOGGLE_ACTION_ENABLE, w));
}
static SDispatchResult settiled(const std::string& args) {
auto w = windowFromArg(args);
return wrap(Actions::floatWindow(TOGGLE_ACTION_DISABLE, w));
}
static SDispatchResult pseudo(const std::string& args) {
auto w = windowFromArg(args);
return wrap(Actions::pseudoWindow(TOGGLE_ACTION_TOGGLE, w));
}
static SDispatchResult workspace(const std::string& args) {
return wrap(Actions::changeWorkspace(args));
}
static SDispatchResult renameworkspace(const std::string& args) {
try {
const auto FIRSTSPACEPOS = args.find_first_of(' ');
if (FIRSTSPACEPOS != std::string::npos) {
int wsid = std::stoi(args.substr(0, FIRSTSPACEPOS));
std::string name = args.substr(FIRSTSPACEPOS + 1);
const auto PWS = State::workspaceState()->query().id(wsid).run();
if (!PWS)
return {.success = false, .error = "No such workspace"};
return wrap(Actions::renameWorkspace(PWS, name));
} else {
const auto PWS = State::workspaceState()->query().id(std::stoi(args)).run();
if (!PWS)
return {.success = false, .error = "No such workspace"};
return wrap(Actions::renameWorkspace(PWS, ""));
}
} catch (std::exception& e) { return {.success = false, .error = std::format("Invalid arg in renameWorkspace: {}", e.what())}; }
}
static SDispatchResult fullscreen(const std::string& args) {
CVarList2 ARGS(args, 2, ' ');
const Fullscreen::eFullscreenMode MODE = ARGS.size() > 0 && ARGS[0] == "1" ? Fullscreen::FSMODE_MAXIMIZED : Fullscreen::FSMODE_FULLSCREEN;
if (ARGS.size() <= 1 || ARGS[1] == "toggle")
return wrap(Actions::fullscreenWindow(MODE, true));
// "set" means enable, "unset" means disable - but the Action toggles.
// We need to check current state ourselves.
const auto PWINDOW = Desktop::focusState()->window();
if (!PWINDOW)
return {.success = false, .error = "Window not found"};
if (ARGS[1] == "set") {
if (!Fullscreen::controller()->isFullscreen(PWINDOW, MODE))
return wrap(Actions::fullscreenWindow(MODE, true));
return {};
} else if (ARGS[1] == "unset") {
if (Fullscreen::controller()->isFullscreen(PWINDOW, MODE))
return wrap(Actions::fullscreenWindow(MODE, true));
return {};
}
return {};
}
static SDispatchResult fullscreenstate(const std::string& args) {
CVarList2 ARGS(args, 3, ' ');
const auto PWINDOW = Desktop::focusState()->window();
if (!PWINDOW)
return {.success = false, .error = "Window not found"};
int internalMode, clientMode;
try {
internalMode = std::stoi(std::string(ARGS[0]));
} catch (...) { internalMode = -1; }
try {
clientMode = std::stoi(std::string(ARGS[1]));
} catch (...) { clientMode = -1; }
Fullscreen::eFullscreenMode im = internalMode != -1 ? sc<Fullscreen::eFullscreenMode>(internalMode) : Fullscreen::controller()->getFullscreenModes(PWINDOW).internal;
Fullscreen::eFullscreenMode cm = clientMode != -1 ? sc<Fullscreen::eFullscreenMode>(clientMode) : Fullscreen::controller()->getFullscreenModes(PWINDOW).client;
return wrap(Actions::fullscreenWindow(im, cm, true));
}
static SDispatchResult movetoworkspace(const std::string& args) {
PHLWINDOW PWINDOW = Desktop::focusState()->window();
std::string wsArgs = args;
if (args.contains(',')) {
PWINDOW = Desktop::viewState()->query().selector(args.substr(args.find_last_of(',') + 1)).runWindow();
wsArgs = args.substr(0, args.find_last_of(','));
}
auto ws = resolveWorkspace(wsArgs);
if (!ws)
return {.success = false, .error = "Invalid workspace"};
return wrap(Actions::moveToWorkspace(ws, false, PWINDOW));
}
static SDispatchResult movetoworkspacesilent(const std::string& args) {
PHLWINDOW PWINDOW = Desktop::focusState()->window();
std::string wsArgs = args;
if (args.contains(',')) {
PWINDOW = Desktop::viewState()->query().selector(args.substr(args.find_last_of(',') + 1)).runWindow();
wsArgs = args.substr(0, args.find_last_of(','));
}
auto ws = resolveWorkspace(wsArgs);
if (!ws)
return {.success = false, .error = "Invalid workspace"};
return wrap(Actions::moveToWorkspace(ws, true, PWINDOW));
}
static SDispatchResult movefocus(const std::string& args) {
Math::eDirection dir = Math::fromChar(args[0]);
if (dir == Math::DIRECTION_DEFAULT)
return {.success = false, .error = std::format("Unsupported direction: {}", args[0])};
return wrap(Actions::moveFocus(dir));
}
static SDispatchResult movewindow(const std::string& args) {
// "movewindow" dispatcher handles both "mon:<monitor>" and directional moves.
// For mon: prefix, it delegates to movetoworkspace.
bool silent = args.ends_with(" silent");
auto cleanArgs = silent ? args.substr(0, args.length() - 7) : args;
if (cleanArgs.starts_with("mon:")) {
const auto PNEWMONITOR = State::monitorState()->query().relativeTo(Desktop::focusState()->monitor()).configString(cleanArgs.substr(4)).run();
if (!PNEWMONITOR)
return {.success = false, .error = std::format("Monitor {} not found", cleanArgs.substr(4))};
auto ws = PNEWMONITOR->m_activeWorkspace;
return wrap(Actions::moveToWorkspace(ws, silent));
}
Math::eDirection dir = Math::fromChar(cleanArgs[0]);
if (dir == Math::DIRECTION_DEFAULT)
return {.success = false, .error = std::format("Unsupported direction: {}", cleanArgs[0])};
return wrap(Actions::moveInDirection(dir));
}
static SDispatchResult swapwindow(const std::string& args) {
if (isDirection(args))
return wrap(Actions::swapInDirection(Math::fromChar(args[0])));
// regex-based swap: resolve window and use swapInDirection? No - the old code used selector lookup + switchTargets.
// The new Actions don't have a "swap with specific window" variant.
// Fall through to the old swapActive logic via selector lookup + layout switchTargets.
const auto PLASTWINDOW = Desktop::focusState()->window();
if (!PLASTWINDOW)
return {.success = false, .error = "Window to swap with not found"};
if (Fullscreen::controller()->isFullscreen(PLASTWINDOW))
return {.success = false, .error = "Can't swap fullscreen window"};
const auto PWINDOWTOCHANGETO = Desktop::viewState()->query().selector(args).runWindow();
if (!PWINDOWTOCHANGETO || PWINDOWTOCHANGETO == PLASTWINDOW)
return {.success = false, .error = std::format("Can't swap with {}, invalid window", args)};
g_layoutManager->switchTargets(PLASTWINDOW->layoutTarget(), PWINDOWTOCHANGETO->layoutTarget(), true);
PLASTWINDOW->warpCursor();
return {};
}
static SDispatchResult centerwindow(const std::string&) {
return wrap(Actions::center());
}
static SDispatchResult togglegroup(const std::string&) {
return wrap(Actions::toggleGroup());
}
static SDispatchResult changegroupactive(const std::string& args) {
bool forward = !(args == "b" || args == "prev");
// index-based change
if (isNumber(args, false)) {
const auto PWINDOW = Desktop::focusState()->window();
if (!PWINDOW)
return {.success = false, .error = "No window found"};
if (!PWINDOW->m_group)
return {.success = false, .error = "No group"};
if (PWINDOW->m_group->size() == 1)
return {.success = false, .error = "Only one window in group"};
try {
const int INDEX = std::stoi(args);
if (INDEX <= 0)
PWINDOW->m_group->setCurrent(PWINDOW->m_group->size() - 1);
else
PWINDOW->m_group->setCurrent(INDEX - 1);
} catch (...) { return {.success = false, .error = "invalid idx"}; }
return {};
}
return wrap(Actions::changeGroupActive(forward));
}
static SDispatchResult movegroupwindow(const std::string& args) {
return wrap(Actions::moveGroupWindow(!(args == "b" || args == "prev")));
}
static SDispatchResult focusmonitor(const std::string& args) {
const auto PMONITOR = State::monitorState()->query().relativeTo(Desktop::focusState()->monitor()).configString(args).run();
if (!PMONITOR)
return {.success = false, .error = "Monitor not found"};
return wrap(Actions::focusMonitor(PMONITOR));
}
static SDispatchResult movecursortocorner(const std::string& args) {
if (!isNumber(args))
return {.success = false, .error = "moveCursorToCorner, arg has to be a number"};
return wrap(Actions::moveCursorToCorner(std::stoi(args)));
}
static SDispatchResult movecursor(const std::string& args) {
size_t i = args.find_first_of(' ');
if (i == std::string::npos)
return {.success = false, .error = "moveCursor takes 2 arguments"};
auto x_str = args.substr(0, i);
auto y_str = args.substr(i + 1);
if (!isNumber(x_str) || !isNumber(y_str))
return {.success = false, .error = "moveCursor arguments must be numbers"};
return wrap(Actions::moveCursor({std::stoi(x_str), std::stoi(y_str)}));
}
static SDispatchResult workspaceopt(const std::string&) {
return {.success = false, .error = "workspaceopt is deprecated"};
}
static SDispatchResult exitHyprland(const std::string&) {
return wrap(Actions::exit());
}
static SDispatchResult movecurrentworkspacetomonitor(const std::string& args) {
const auto PMONITOR = State::monitorState()->query().relativeTo(Desktop::focusState()->monitor()).configString(args).run();
if (!PMONITOR)
return {.success = false, .error = "Monitor not found"};
const auto PCURRENTWORKSPACE = Desktop::focusState()->monitor()->m_activeWorkspace;
if (!PCURRENTWORKSPACE)
return {.success = false, .error = "Invalid workspace"};
return wrap(Actions::moveToMonitor(PCURRENTWORKSPACE, PMONITOR));
}
static SDispatchResult moveworkspacetomonitor(const std::string& args) {
if (!args.contains(' '))
return {.success = false, .error = "Expected: workspace monitor"};
std::string wsStr = args.substr(0, args.find_first_of(' '));
std::string monStr = args.substr(args.find_first_of(' ') + 1);
const auto PMONITOR = State::monitorState()->query().relativeTo(Desktop::focusState()->monitor()).configString(monStr).run();
if (!PMONITOR)
return {.success = false, .error = "Monitor not found"};
const auto WORKSPACEID = getWorkspaceIDNameFromString(wsStr).id;
if (WORKSPACEID == WORKSPACE_INVALID)
return {.success = false, .error = "Invalid workspace"};
const auto PWORKSPACE = State::workspaceState()->query().id(WORKSPACEID).run();
if (!PWORKSPACE)
return {.success = false, .error = "Workspace not found"};
return wrap(Actions::moveToMonitor(PWORKSPACE, PMONITOR));
}
static SDispatchResult focusworkspaceoncurrentmonitor(const std::string& args) {
auto ws = resolveWorkspace(args);
if (!ws)
return {.success = false, .error = "Invalid workspace"};
return wrap(Actions::changeWorkspaceOnCurrentMonitor(ws));
}
static SDispatchResult togglespecialworkspace(const std::string& args) {
const auto& [workspaceID, workspaceName, isAutoID] = getWorkspaceIDNameFromString("special:" + args);
if (workspaceID == WORKSPACE_INVALID || !State::workspaceState()->isSpecial(workspaceID))
return {.success = false, .error = "Invalid special workspace"};
auto ws = State::workspaceState()->query().id(workspaceID).run();
if (!ws) {
const auto PMONITOR = Desktop::focusState()->monitor();
if (PMONITOR)
ws = State::workspaceState()->create(workspaceID, PMONITOR->m_id, workspaceName);
}
if (!ws)
return {.success = false, .error = "Could not resolve special workspace"};
return wrap(Actions::toggleSpecial(ws));
}
static SDispatchResult forcerendererreload(const std::string&) {
return wrap(Actions::forceRendererReload());
}
static SDispatchResult resizeactive(const std::string& args) {
const auto PWINDOW = Desktop::focusState()->window();
if (!PWINDOW)
return {.success = false, .error = "No window found"};
const auto SIZ = g_pCompositor->parseWindowVectorArgsRelative(args, PWINDOW->size(Desktop::View::IGeometric::GEOMETRIC_GOAL));
if (SIZ.x < 1 || SIZ.y < 1)
return {.success = false, .error = "Invalid size"};
return wrap(Actions::resize(SIZ));
}
static SDispatchResult moveactive(const std::string& args) {
const auto PWINDOW = Desktop::focusState()->window();
if (!PWINDOW)
return {.success = false, .error = "No window found"};
const auto POS = g_pCompositor->parseWindowVectorArgsRelative(args, PWINDOW->position(Desktop::View::IGeometric::GEOMETRIC_GOAL));
return wrap(Actions::move(POS));
}
static SDispatchResult movewindowpixel(const std::string& args) {
const auto WINDOWREGEX = args.substr(args.find_first_of(',') + 1);
const auto MOVECMD = args.substr(0, args.find_first_of(','));
const auto PWINDOW = Desktop::viewState()->query().selector(WINDOWREGEX).runWindow();
if (!PWINDOW)
return {.success = false, .error = "moveWindow: no window"};
const auto POS = g_pCompositor->parseWindowVectorArgsRelative(MOVECMD, PWINDOW->position(Desktop::View::IGeometric::GEOMETRIC_GOAL));
return wrap(Actions::move(POS, false, PWINDOW));
}
static SDispatchResult resizewindowpixel(const std::string& args) {
const auto WINDOWREGEX = args.substr(args.find_first_of(',') + 1);
const auto MOVECMD = args.substr(0, args.find_first_of(','));
const auto PWINDOW = Desktop::viewState()->query().selector(WINDOWREGEX).runWindow();
if (!PWINDOW)
return {.success = false, .error = "resizeWindow: no window"};
const auto SIZ = g_pCompositor->parseWindowVectorArgsRelative(MOVECMD, PWINDOW->size(Desktop::View::IGeometric::GEOMETRIC_GOAL));
if (SIZ.x < 1 || SIZ.y < 1)
return {.success = false, .error = "Invalid size"};
return wrap(Actions::resize(SIZ, false, PWINDOW));
}
static SDispatchResult cyclenext(const std::string& arg) {
CVarList2 args(arg, 0, 's', true);
const bool PREV = args.contains("prev") || args.contains("p") || args.contains("last") || args.contains("l");
const bool NEXT = args.contains("next") || args.contains("n");
std::optional<bool> onlyTiled = {};
std::optional<bool> onlyFloating = {};
if (args.contains("tile") || args.contains("tiled"))
onlyTiled = true;
if (args.contains("float") || args.contains("floating"))
onlyFloating = true;
// "hist" and "visible" modes are not mapped to the new API - they remain niche.
// The new cycleNext uses a simple next/prev boolean.
// PREV is default in classic alt+tab, NEXT overrides it.
return wrap(Actions::cycleNext(NEXT || !PREV, onlyTiled, onlyFloating));
}
static SDispatchResult focuswindow(const std::string& regexp) {
const auto PWINDOW = Desktop::viewState()->query().selector(regexp).runWindow();
if (!PWINDOW)
return {.success = false, .error = "No such window found"};
return wrap(Actions::focus(PWINDOW));
}
static SDispatchResult tagwindow(const std::string& args) {
CVarList2 vars(args, 0, 's', true);
PHLWINDOW PWINDOW = nullptr;
if (vars.size() == 1)
; // use focused (nullptr)
else if (vars.size() == 2)
PWINDOW = Desktop::viewState()->query().selector(std::string(vars[1])).runWindow();
else
return {.success = false, .error = "Invalid number of arguments, expected 1 or 2"};
return wrap(Actions::tag(std::string(vars[0]), PWINDOW));
}
static SDispatchResult toggleswallow(const std::string&) {
return wrap(Actions::toggleSwallow());
}
static SDispatchResult setsubmap(const std::string& submap) {
return wrap(Actions::setSubmap(submap));
}
static SDispatchResult passDispatcher(const std::string& regexp) {
const auto PWINDOW = Desktop::viewState()->query().selector(regexp).runWindow();
if (!PWINDOW)
return {.success = false, .error = "pass: window not found"};
return wrap(Actions::pass(PWINDOW));
}
static SDispatchResult sendshortcut(const std::string& args) {
CVarList2 ARGS(args, 3);
if (ARGS.size() != 3)
return {.success = false, .error = "sendshortcut: invalid args"};
const auto MOD = g_pKeybindManager->stringToModMask(std::string(ARGS[0]));
const auto KEY = std::string(ARGS[1]);
uint32_t keycode = 0;
if (isNumber(KEY) && std::stoi(KEY) > 9)
keycode = std::stoi(KEY);
else if (KEY.starts_with("code:") && isNumber(KEY.substr(5)))
keycode = std::stoi(KEY.substr(5));
else if (KEY.starts_with("mouse:") && isNumber(KEY.substr(6))) {
keycode = std::stoi(KEY.substr(6));
if (keycode < 272)
return {.success = false, .error = "sendshortcut: invalid mouse button"};
} else {
// resolve keycode from key name via xkb
const auto KEYSYM = xkb_keysym_from_name(KEY.c_str(), XKB_KEYSYM_CASE_INSENSITIVE);
keycode = 0;
const auto KB = g_pSeatManager->m_keyboard;
if (!KB)
return {.success = false, .error = "sendshortcut: no kb"};
const auto KEYPAIRSTRING = std::format("{}{}", rc<uintptr_t>(KB.get()), KEY);
if (!g_pKeybindManager->m_keyToCodeCache.contains(KEYPAIRSTRING)) {
xkb_keymap* km = KB->m_xkbKeymap;
xkb_state* ks = KB->m_xkbState;
xkb_keycode_t keycode_min = xkb_keymap_min_keycode(km);
xkb_keycode_t keycode_max = xkb_keymap_max_keycode(km);
for (xkb_keycode_t kc = keycode_min; kc <= keycode_max; ++kc) {
xkb_keysym_t sym = xkb_state_key_get_one_sym(ks, kc);
if (sym == KEYSYM) {
keycode = kc;
g_pKeybindManager->m_keyToCodeCache[KEYPAIRSTRING] = keycode;
}
}
if (!keycode)
return {.success = false, .error = "sendshortcut: key not found"};
} else
keycode = g_pKeybindManager->m_keyToCodeCache[KEYPAIRSTRING];
}
if (!keycode)
return {.success = false, .error = "sendshortcut: invalid key"};
const std::string regexp = std::string(ARGS[2]);
PHLWINDOW PWINDOW = regexp.empty() ? nullptr : Desktop::viewState()->query().selector(regexp).runWindow();
if (!regexp.empty() && !PWINDOW)
return {.success = false, .error = "sendshortcut: window not found"};
return wrap(Actions::pass(MOD, keycode, PWINDOW));
}
static SDispatchResult sendkeystate(const std::string& args) {
CVarList2 ARGS(args, 4);
if (ARGS.size() != 4)
return {.success = false, .error = "sendkeystate: invalid args"};
const auto STATE = ARGS[2];
if (STATE != "down" && STATE != "repeat" && STATE != "up")
return {.success = false, .error = "sendkeystate: invalid state, must be 'down', 'repeat', or 'up'"};
uint32_t keyState = 0;
if (STATE == "down")
keyState = 1;
else if (STATE == "repeat")
keyState = 2;
// Reuse sendshortcut for keycode resolution, but wrap with state
std::string modifiedArgs = std::string(ARGS[0]) + "," + std::string(ARGS[1]) + "," + std::string(ARGS[3]);
// We need to resolve the keycode first, so delegate to sendshortcut parsing.
// But sendkeystate overrides m_passPressed. Let's just call through sendshortcut
// with the proper state set.
const int oldPassPressed = Config::Actions::state()->m_passPressed;
if (keyState == 1 || keyState == 2)
Config::Actions::state()->m_passPressed = 1;
else
Config::Actions::state()->m_passPressed = 0;
auto result = sendshortcut(modifiedArgs);
if (keyState == 2 && result.success)
result = sendshortcut(modifiedArgs);
Config::Actions::state()->m_passPressed = oldPassPressed;
return result;
}
static SDispatchResult layoutmsg(const std::string& msg) {
return wrap(Actions::layoutMessage(msg));
}
static SDispatchResult dpmsDispatcher(const std::string& arg) {
eTogglableAction action;
if (arg.starts_with("on"))
action = TOGGLE_ACTION_ENABLE;
else if (arg.starts_with("toggle"))
action = TOGGLE_ACTION_TOGGLE;
else
action = TOGGLE_ACTION_DISABLE;
std::optional<PHLMONITOR> mon = std::nullopt;
if (arg.find_first_of(' ') != std::string::npos) {
auto port = arg.substr(arg.find_first_of(' ') + 1);
auto pMon = State::monitorState()->query().relativeTo(Desktop::focusState()->monitor()).configString(port).run();
if (pMon)
mon = pMon;
}
return wrap(Actions::dpms(action, mon));
}
static SDispatchResult swapnext(const std::string& arg) {
return wrap(Actions::swapNext(arg != "l" && arg != "last" && arg != "prev" && arg != "b" && arg != "back"));
}
static SDispatchResult swapactiveworkspaces(const std::string& args) {
const auto MON1 = args.substr(0, args.find_first_of(' '));
const auto MON2 = args.substr(args.find_first_of(' ') + 1);
const auto PMON1 = State::monitorState()->query().relativeTo(Desktop::focusState()->monitor()).configString(MON1).run();
const auto PMON2 = State::monitorState()->query().relativeTo(Desktop::focusState()->monitor()).configString(MON2).run();
if (!PMON1 || !PMON2)
return {.success = false, .error = "Monitor not found"};
return wrap(Actions::swapActiveWorkspaces(PMON1, PMON2));
}
static SDispatchResult pin(const std::string& args) {
auto w = windowFromArg(args);
return wrap(Actions::pinWindow(TOGGLE_ACTION_TOGGLE, w));
}
static SDispatchResult mouseDispatcher(const std::string& args) {
return wrap(Actions::mouse(args.substr(1)));
}
static SDispatchResult bringactivetotop(const std::string&) {
return wrap(Actions::alterZOrder("top"));
}
static SDispatchResult alterzorder(const std::string& args) {
const auto WINDOWREGEX = args.substr(args.find_first_of(',') + 1);
const auto POSITION = args.substr(0, args.find_first_of(','));
auto PWINDOW = Desktop::viewState()->query().selector(WINDOWREGEX).runWindow();
if (!PWINDOW && Desktop::focusState()->window() && Desktop::focusState()->window()->m_isFloating)
PWINDOW = Desktop::focusState()->window();
return wrap(Actions::alterZOrder(POSITION, PWINDOW));
}
static SDispatchResult focusurgentorlast(const std::string&) {
return wrap(Actions::focusUrgentOrLast());
}
static SDispatchResult focuscurrentorlast(const std::string&) {
return wrap(Actions::focusCurrentOrLast());
}
static SDispatchResult lockgroups(const std::string& args) {
eTogglableAction action;
if (args == "toggle")
action = TOGGLE_ACTION_TOGGLE;
else if (args == "lock" || args.empty() || args == "lockgroups")
action = TOGGLE_ACTION_ENABLE;
else
action = TOGGLE_ACTION_DISABLE;
return wrap(Actions::lockGroups(action));
}
static SDispatchResult lockactivegroup(const std::string& args) {
eTogglableAction action;
if (args == "toggle")
action = TOGGLE_ACTION_TOGGLE;
else if (args == "lock")
action = TOGGLE_ACTION_ENABLE;
else
action = TOGGLE_ACTION_DISABLE;
return wrap(Actions::lockActiveGroup(action));
}
static SDispatchResult moveintogroup(const std::string& args) {
Math::eDirection dir = Math::fromChar(args[0]);
if (dir == Math::DIRECTION_DEFAULT)
return {.success = false, .error = std::format("Unsupported direction: {}", args[0])};
return wrap(Actions::moveIntoGroup(dir));
}
static SDispatchResult moveintoorcreategroup(const std::string& args) {
Math::eDirection dir = Math::fromChar(args[0]);
if (dir == Math::DIRECTION_DEFAULT)
return {.success = false, .error = std::format("Unsupported direction: {}", args[0])};
return wrap(Actions::moveIntoOrCreateGroup(dir));
}
static SDispatchResult moveoutofgroup(const std::string& args) {
if (args != "active" && args.length() > 1) {
auto PWINDOW = Desktop::viewState()->query().selector(args).runWindow();
return wrap(Actions::moveOutOfGroup(Math::DIRECTION_DEFAULT, PWINDOW));
}
return wrap(Actions::moveOutOfGroup(Math::DIRECTION_DEFAULT));
}
static SDispatchResult movewindoworgroup(const std::string& args) {
Math::eDirection dir = Math::fromChar(args[0]);
if (dir == Math::DIRECTION_DEFAULT)
return {.success = false, .error = std::format("Unsupported direction: {}", args[0])};
return wrap(Actions::moveWindowOrGroup(dir));
}
static SDispatchResult denywindowfromgroup(const std::string& args) {
eTogglableAction action;
if (args == "toggle")
action = TOGGLE_ACTION_TOGGLE;
else if (args == "on")
action = TOGGLE_ACTION_ENABLE;
else
action = TOGGLE_ACTION_DISABLE;
return wrap(Actions::denyWindowFromGroup(action));
}
static SDispatchResult eventDispatcher(const std::string& args) {
return wrap(Actions::event(args));
}
static SDispatchResult globalDispatcher(const std::string& args) {
return wrap(Actions::global(args));
}
static SDispatchResult setprop(const std::string& args) {
CVarList2 vars(args, 3, ' ');
if (vars.size() < 3)
return {.success = false, .error = "Not enough args"};
const auto PWINDOW = Desktop::viewState()->query().selector(std::string(vars[0])).runWindow();
if (!PWINDOW)
return {.success = false, .error = "Window not found"};
// Reconstruct val from remaining args (for multi-arg values like colors)
return wrap(Actions::setProp(std::string(vars[1]), vars.join(" ", 2), PWINDOW));
}
static SDispatchResult forceidle(const std::string& args) {
std::optional<float> duration = getPlusMinusKeywordResult(args, 0);
if (!duration.has_value())
return {.success = false, .error = "Duration invalid in forceIdle"};
return wrap(Actions::forceIdle(duration.value()));
}
static SDispatchResult releaseInputCapture(const std::string& args) {
return wrap(Actions::releaseInputCapture());
}
CDispatcherTranslator::CDispatcherTranslator() {
m_dispMap["exec"] = ::exec;
m_dispMap["execr"] = ::execr;
m_dispMap["killactive"] = ::killactive;
m_dispMap["forcekillactive"] = ::forcekillactive;
m_dispMap["closewindow"] = ::closewindow;
m_dispMap["killwindow"] = ::killwindow;
m_dispMap["signal"] = ::signalactive;
m_dispMap["signalwindow"] = ::signalwindow;
m_dispMap["togglefloating"] = ::togglefloating;
m_dispMap["setfloating"] = ::setfloating;
m_dispMap["settiled"] = ::settiled;
m_dispMap["workspace"] = ::workspace;
m_dispMap["renameworkspace"] = ::renameworkspace;
m_dispMap["fullscreen"] = ::fullscreen;
m_dispMap["fullscreenstate"] = ::fullscreenstate;
m_dispMap["movetoworkspace"] = ::movetoworkspace;
m_dispMap["movetoworkspacesilent"] = ::movetoworkspacesilent;
m_dispMap["pseudo"] = ::pseudo;
m_dispMap["movefocus"] = ::movefocus;
m_dispMap["movewindow"] = ::movewindow;
m_dispMap["swapwindow"] = ::swapwindow;
m_dispMap["centerwindow"] = ::centerwindow;
m_dispMap["togglegroup"] = ::togglegroup;
m_dispMap["changegroupactive"] = ::changegroupactive;
m_dispMap["movegroupwindow"] = ::movegroupwindow;
m_dispMap["focusmonitor"] = ::focusmonitor;
m_dispMap["movecursortocorner"] = ::movecursortocorner;
m_dispMap["movecursor"] = ::movecursor;
m_dispMap["workspaceopt"] = ::workspaceopt;
m_dispMap["exit"] = ::exitHyprland;
m_dispMap["movecurrentworkspacetomonitor"] = ::movecurrentworkspacetomonitor;
m_dispMap["focusworkspaceoncurrentmonitor"] = ::focusworkspaceoncurrentmonitor;
m_dispMap["moveworkspacetomonitor"] = ::moveworkspacetomonitor;
m_dispMap["togglespecialworkspace"] = ::togglespecialworkspace;
m_dispMap["forcerendererreload"] = ::forcerendererreload;
m_dispMap["resizeactive"] = ::resizeactive;
m_dispMap["moveactive"] = ::moveactive;
m_dispMap["cyclenext"] = ::cyclenext;
m_dispMap["focuswindowbyclass"] = ::focuswindow;
m_dispMap["focuswindow"] = ::focuswindow;
m_dispMap["tagwindow"] = ::tagwindow;
m_dispMap["toggleswallow"] = ::toggleswallow;
m_dispMap["submap"] = ::setsubmap;
m_dispMap["pass"] = ::passDispatcher;
m_dispMap["sendshortcut"] = ::sendshortcut;
m_dispMap["sendkeystate"] = ::sendkeystate;
m_dispMap["layoutmsg"] = ::layoutmsg;
m_dispMap["dpms"] = ::dpmsDispatcher;
m_dispMap["movewindowpixel"] = ::movewindowpixel;
m_dispMap["resizewindowpixel"] = ::resizewindowpixel;
m_dispMap["swapnext"] = ::swapnext;
m_dispMap["swapactiveworkspaces"] = ::swapactiveworkspaces;
m_dispMap["pin"] = ::pin;
m_dispMap["mouse"] = ::mouseDispatcher;
m_dispMap["bringactivetotop"] = ::bringactivetotop;
m_dispMap["alterzorder"] = ::alterzorder;
m_dispMap["focusurgentorlast"] = ::focusurgentorlast;
m_dispMap["focuscurrentorlast"] = ::focuscurrentorlast;
m_dispMap["lockgroups"] = ::lockgroups;
m_dispMap["lockactivegroup"] = ::lockactivegroup;
m_dispMap["moveintogroup"] = ::moveintogroup;
m_dispMap["moveintoorcreategroup"] = ::moveintoorcreategroup;
m_dispMap["moveoutofgroup"] = ::moveoutofgroup;
m_dispMap["movewindoworgroup"] = ::movewindoworgroup;
m_dispMap["setignoregrouplock"] = [](const std::string&) -> SDispatchResult { return {}; }; // deprecated
m_dispMap["denywindowfromgroup"] = ::denywindowfromgroup;
m_dispMap["event"] = ::eventDispatcher;
m_dispMap["global"] = ::globalDispatcher;
m_dispMap["setprop"] = ::setprop;
m_dispMap["forceidle"] = ::forceidle;
m_dispMap["releaseinputcapture"] = ::releaseInputCapture;
}
@@ -1,23 +0,0 @@
#pragma once
#include "../../SharedDefs.hpp"
#include "../../helpers/memory/Memory.hpp"
#include <functional>
#include <unordered_map>
#include <string>
namespace Config::Legacy {
class CDispatcherTranslator {
public:
CDispatcherTranslator();
~CDispatcherTranslator() = default;
SDispatchResult run(const std::string& dispatcher, const std::string& data);
private:
std::unordered_map<std::string, std::function<SDispatchResult(const std::string&)>> m_dispMap;
};
UP<CDispatcherTranslator>& translator();
}
+44
View File
@@ -14,6 +14,7 @@
#include "types/LuaConfigUtils.hpp"
#include "types/LuaConfigBool.hpp"
#include "bindings/LuaBindingsInternal.hpp"
#include "../values/ConfigValues.hpp"
@@ -1353,6 +1354,49 @@ void CConfigManager::callLuaFn(int ref) {
}
}
static SDispatchResult dispatchResultFromLua(lua_State* L, int idx) {
SDispatchResult result;
if (!lua_istable(L, idx))
return result;
lua_getfield(L, idx, "pass_event");
result.passEvent = lua_toboolean(L, -1);
lua_pop(L, 1);
lua_getfield(L, idx, "ok");
if (lua_isboolean(L, -1))
result.success = lua_toboolean(L, -1);
lua_pop(L, 1);
if (!result.success) {
lua_getfield(L, idx, "error");
if (lua_isstring(L, -1))
result.error = lua_tostring(L, -1);
lua_pop(L, 1);
}
return result;
}
SDispatchResult CConfigManager::callLuaFnBind(int ref) {
lua_rawgeti(m_lua, LUA_REGISTRYINDEX, ref);
int status = guardedPCall(0, 1, 0, CConfigManager::LUA_TIMEOUT_KEYBIND_CALLBACK_MS, "keybind callback");
if (status != LUA_OK) {
Config::Lua::Bindings::Internal::reportError(m_lua,
Config::Actions::SActionError{std::format("error in keybind lambda: {}", lua_tostring(m_lua, -1)),
Config::Actions::eActionErrorLevel::ERROR, Config::Actions::eActionErrorCode::LUA_ERROR});
lua_pop(m_lua, 1);
return {.success = false, .error = "lua keybind error"};
}
auto result = dispatchResultFromLua(m_lua, -1);
lua_pop(m_lua, 1);
return result;
}
void CConfigManager::callLuaFn(int ref, const std::function<int(lua_State*)>& pushArgs, int timeoutMs, std::string_view context) {
if (ref == LUA_NOREF || ref == LUA_REFNIL)
return;
+1
View File
@@ -96,6 +96,7 @@ namespace Config::Lua {
void callLuaFn(int ref);
void callLuaFn(int ref, const std::function<int(lua_State*)>& pushArgs, int timeoutMs, std::string_view context);
std::expected<void, std::string> registerLuaLayoutProvider(std::string name, lua_State* L, int providerTableIdx);
SDispatchResult callLuaFnBind(int ref);
// execute an arbitrary lua string on the current state.
std::optional<std::string> eval(const std::string& code, bool repl = false);
@@ -32,7 +32,6 @@
#include "../../../managers/input/trackpad/TrackpadGestures.hpp"
#include "../../../managers/input/trackpad/gestures/CloseGesture.hpp"
#include "../../../managers/input/trackpad/gestures/CursorZoomGesture.hpp"
#include "../../../managers/input/trackpad/gestures/DispatcherGesture.hpp"
#include "../../../managers/input/trackpad/gestures/FloatGesture.hpp"
#include "../../../managers/input/trackpad/gestures/FullscreenGesture.hpp"
#include "../../../managers/input/trackpad/gestures/LuaFunctionGesture.hpp"
@@ -27,31 +27,6 @@ static int hlPrint(lua_State* L) {
return 0;
}
static SDispatchResult dispatchResultFromLua(lua_State* L, int idx) {
SDispatchResult result;
if (!lua_istable(L, idx))
return result;
lua_getfield(L, idx, "pass_event");
result.passEvent = lua_toboolean(L, -1);
lua_pop(L, 1);
lua_getfield(L, idx, "ok");
if (lua_isboolean(L, -1))
result.success = lua_toboolean(L, -1);
lua_pop(L, 1);
if (!result.success) {
lua_getfield(L, idx, "error");
if (lua_isstring(L, -1))
result.error = lua_tostring(L, -1);
lua_pop(L, 1);
}
return result;
}
void Internal::registerBindingsImpl(lua_State* L, CConfigManager* mgr) {
Objects::CLuaTimer{}.setup(L);
Objects::CLuaEventSubscription{}.setup(L);
@@ -61,29 +36,6 @@ void Internal::registerBindingsImpl(lua_State* L, CConfigManager* mgr) {
Objects::CLuaKeybind{}.setup(L);
Objects::CLuaNotification{}.setup(L);
g_pKeybindManager->m_dispatchers["__lua"] = [L](std::string arg) -> SDispatchResult {
int ref = std::stoi(arg);
lua_rawgeti(L, LUA_REGISTRYINDEX, ref);
int status = LUA_OK;
if (auto* mgr = CConfigManager::fromLuaState(L); mgr)
status = mgr->guardedPCall(0, 1, 0, CConfigManager::LUA_TIMEOUT_KEYBIND_CALLBACK_MS, "keybind callback");
else
status = lua_pcall(L, 0, 1, 0);
if (status != LUA_OK) {
Config::Lua::Bindings::Internal::reportError(L,
Config::Actions::SActionError{std::format("error in keybind lambda: {}", lua_tostring(L, -1)),
Config::Actions::eActionErrorLevel::ERROR, Config::Actions::eActionErrorCode::LUA_ERROR});
lua_pop(L, 1);
return {.success = false, .error = "lua keybind error"};
}
auto result = dispatchResultFromLua(L, -1);
lua_pop(L, 1);
return result;
};
lua_newtable(L);
Internal::registerConfigRuleBindings(L, mgr);
+1 -4
View File
@@ -32,13 +32,10 @@ std::expected<SConfigStateReply, std::string> Jeremy::getMainConfigPath() {
if (const auto CFG_ENV = getenv("HYPRLAND_CONFIG"); CFG_ENV)
return SConfigStateReply{.path = CFG_ENV, .type = CONFIG_TYPE_EXPLICIT};
const auto LUA_PATHS = Hyprutils::Path::findConfig(ISDEBUG ? "hyprlandd" : "hyprland", "lua");
const auto CONF_PATHS = Hyprutils::Path::findConfig(ISDEBUG ? "hyprlandd" : "hyprland", "conf");
const auto LUA_PATHS = Hyprutils::Path::findConfig(ISDEBUG ? "hyprlandd" : "hyprland", "lua");
if (LUA_PATHS.first.has_value())
return SConfigStateReply{.path = LUA_PATHS.first.value(), .type = CONFIG_TYPE_REGULAR};
else if (CONF_PATHS.first.has_value())
return SConfigStateReply{.path = CONF_PATHS.first.value(), .type = CONFIG_TYPE_REGULAR};
else if (LUA_PATHS.second.has_value()) {
auto CONFIGPATH = Hyprutils::Path::fullConfigPath(LUA_PATHS.second.value(), ISDEBUG ? "hyprlandd" : "hyprland", "lua");
return SConfigStateReply{.path = CONFIGPATH, .type = CONFIG_TYPE_REGULAR};
+1 -117
View File
@@ -33,7 +33,6 @@ using namespace Hyprutils::OS;
#include <aquamarine/input/Input.hpp>
#include "../config/shared/complex/ComplexDataTypes.hpp"
#include "../config/legacy/ConfigManager.hpp"
#include "../config/lua/ConfigManager.hpp"
#include "../config/ConfigValue.hpp"
#include "../config/shared/parserUtils/ParserUtils.hpp"
@@ -1140,121 +1139,7 @@ static std::string dispatchRequest(eHyprCtlOutputFormat format, std::string in)
return ret + "\n\n → Note: dispatch in lua is a shorthand for hl.dispatch(...), your syntax might need to be updated.";
}
const auto DISPATCHSTR = in.substr(0, in.find_first_of(' '));
auto DISPATCHARG = std::string();
if (sc<int>(in.find_first_of(' ')) != -1)
DISPATCHARG = in.substr(in.find_first_of(' ') + 1);
const auto DISPATCHER = g_pKeybindManager->m_dispatchers.find(DISPATCHSTR);
if (DISPATCHER == g_pKeybindManager->m_dispatchers.end())
return "Invalid dispatcher";
SDispatchResult res = DISPATCHER->second(DISPATCHARG);
Log::logger->log(Log::DEBUG, "Hyprctl: dispatcher {} : {}{}", DISPATCHSTR, DISPATCHARG, res.success ? "" : " -> " + res.error);
return res.success ? "ok" : res.error;
}
static std::string dispatchKeyword(eHyprCtlOutputFormat format, std::string in) {
if (Config::mgr()->type() != Config::CONFIG_LEGACY)
return "keyword can't work with non-legacy parsers. Use eval.";
WP<Config::Legacy::CConfigManager> mgr = dynamicPointerCast<Config::Legacy::CConfigManager>(WP<Config::IConfigManager>(Config::mgr()));
// Find the first space to strip the keyword keyword
auto const firstSpacePos = in.find_first_of(' ');
if (firstSpacePos == std::string::npos) // Handle the case where there's no space found (invalid input)
return "Invalid input: no space found";
// Strip the keyword
in = in.substr(firstSpacePos + 1);
// Find the next space for the COMMAND and VALUE
auto const secondSpacePos = in.find_first_of(' ');
if (secondSpacePos == std::string::npos) // Handle the case where there's no second space (invalid input)
return "Invalid input: command and value not properly formatted";
// Extract COMMAND and VALUE
const auto COMMAND = in.substr(0, secondSpacePos);
const auto VALUE = in.substr(secondSpacePos + 1);
// If COMMAND is empty, handle accordingly
if (COMMAND.empty())
return "Invalid input: command is empty";
g_pHyprCtl->m_currentRequestParams.isDynamicKeyword = true;
std::string retval = mgr->parseKeyword(COMMAND, VALUE);
g_pHyprCtl->m_currentRequestParams.isDynamicKeyword = false;
if (COMMAND == "source") {
Config::monitorRuleMgr()->scheduleReload();
g_pEventLoopManager->doLater([mgr] { mgr->reloadRules(); });
}
// if we are executing a dynamic source we have to reload everything, so every if will have a check for source.
if (COMMAND.contains("monitor"))
g_pEventLoopManager->doLater([] { Config::monitorRuleMgr()->scheduleReload(); });
if (COMMAND.contains("input") || COMMAND.contains("device") || COMMAND == "source") {
g_pInputManager->setKeyboardLayout(); // update kb layout
g_pInputManager->setPointerConfigs(); // update mouse cfgs
g_pInputManager->setTouchDeviceConfigs(); // update touch device cfgs
g_pInputManager->setTabletConfigs(); // update tablets
}
if (COMMAND.contains("general:layout") || (COMMAND.contains("workspace") && VALUE.contains("layout:")))
Layout::Supplementary::algoMatcher()->updateWorkspaceLayouts();
if (COMMAND.contains("decoration:screen_shader") || COMMAND == "source")
g_pHyprRenderer->m_reloadScreenShader = true;
if (COMMAND.contains("blur") || COMMAND == "source") {
for (auto const& m : State::monitorState()->monitors()) {
if (m)
m->m_blurFBDirty = true;
}
}
if (COMMAND.contains("misc:disable_autoreload"))
Config::watcher()->update();
// decorations will probably need a repaint
if (COMMAND.contains("decoration:") || COMMAND.contains("border") || COMMAND == "workspace" || COMMAND.contains("zoom_factor") || COMMAND == "source") {
static auto PZOOMFACTOR = CConfigValue<Config::FLOAT>("cursor:zoom_factor");
for (auto const& m : State::monitorState()->monitors()) {
*(m->m_cursorZoom) = *PZOOMFACTOR;
g_pHyprRenderer->damageMonitor(m);
if (m->m_activeWorkspace)
m->m_activeWorkspace->m_space->recalculate();
}
}
if (COMMAND.contains("windowrule ") || COMMAND.contains("windowrule["))
mgr->reloadRules();
if (COMMAND.contains("layerrule") || COMMAND.contains("layerrule[")) {
mgr->reloadRules();
// Damage all monitors to redraw static layers.
for (auto const& m : State::monitorState()->monitors()) {
g_pHyprRenderer->damageMonitor(m);
}
}
if (COMMAND.contains("workspace"))
State::workspacePlacementController()->ensurePersistentWorkspacesPresent(
nullptr, [](PHLWORKSPACE ws, PHLMONITOR mon, bool noWarp) { State::workspacePlacementController()->moveWorkspaceToMonitor(ws, mon, noWarp); });
Log::logger->log(Log::DEBUG, "Hyprctl: keyword {} : {}", COMMAND, VALUE);
if (retval.empty())
return "ok";
return retval;
return "current config provider doesn't support dispatch";
}
static std::string reloadRequest(eHyprCtlOutputFormat format, std::string request) {
@@ -2034,7 +1919,6 @@ CHyprCtl::CHyprCtl() {
registerCommand(SHyprCtlCommand{"switchxkblayout", false, switchXKBLayoutRequest});
registerCommand(SHyprCtlCommand{"output", false, dispatchOutput});
registerCommand(SHyprCtlCommand{"dispatch", false, dispatchRequest});
registerCommand(SHyprCtlCommand{"keyword", false, dispatchKeyword});
registerCommand(SHyprCtlCommand{"setcursor", false, dispatchSetCursor});
registerCommand(SHyprCtlCommand{"getoption", false, dispatchGetOption});
registerCommand(SHyprCtlCommand{"decorations", false, decorationRequest});
+1 -1
View File
@@ -1,6 +1,6 @@
#include "IKeyboard.hpp"
#include "../defines.hpp"
#include "../config/legacy/ConfigManager.hpp"
#include "../config/ConfigManager.hpp"
#include "../managers/input/InputManager.hpp"
#include "../managers/SeatManager.hpp"
#include "../helpers/MiscFunctions.hpp"
+1 -1
View File
@@ -1,7 +1,7 @@
#include "VirtualKeyboard.hpp"
#include "../defines.hpp"
#include "../protocols/VirtualKeyboard.hpp"
#include "../config/legacy/ConfigManager.hpp"
#include "../config/ConfigManager.hpp"
#include <wayland-server-protocol.h>
SP<CVirtualKeyboard> CVirtualKeyboard::create(SP<CVirtualKeyboardV1Resource> keeb) {
-3
View File
@@ -251,7 +251,6 @@ I18n::CI18nEngine::CI18nEngine() {
registerEntry("en_US", TXT_KEY_NOTIF_CM_RELOAD_FAILED, "CM shader reload failed, falling back to rgba/rgbx.");
registerEntry("en_US", TXT_KEY_NOTIF_WIDE_COLOR_NOT_10B, "Monitor {name}: wide color gamut is enabled but the display is not in 10-bit mode.");
registerEntry("en_US", TXT_KEY_NOTIF_NO_WATCHDOG, "Hyprland was started without start-hyprland. This is strongly discouraged unless you are in a debugging environment.");
registerEntry("en_US", TXT_KEY_NOTIF_OUTDATED_CONFIG, "You are using the .conf config format, support for which will be removed in Hyprland 0.57.");
registerEntry("en_US", TXT_KEY_SAFE_MODE_TITLE, "Safe Mode");
registerEntry("en_US", TXT_KEY_SAFE_MODE_DESCRIPTION,
@@ -834,7 +833,6 @@ I18n::CI18nEngine::CI18nEngine() {
registerEntry("ja_JP", TXT_KEY_NOTIF_CM_RELOAD_FAILED, "CM シェーダのリロードに失敗したため、rgba/rgbx を使用します。");
registerEntry("ja_JP", TXT_KEY_NOTIF_WIDE_COLOR_NOT_10B, "広色域が有効なモニタ {name} を使用していますが、画面表示の設定は 10 ビットになっていません。");
registerEntry("ja_JP", TXT_KEY_NOTIF_NO_WATCHDOG, "start-hyprland なしで Hyprland を実行しています。これは、デバッグ目的以外ではおすすめしません。");
registerEntry("ja_JP", TXT_KEY_NOTIF_OUTDATED_CONFIG, ".confのコンフィグレーションフォーマットは、Hyprland 0.57からサポートが失います。");
registerEntry("ja_JP", TXT_KEY_SAFE_MODE_TITLE, "セーフモード");
registerEntry("ja_JP", TXT_KEY_SAFE_MODE_DESCRIPTION,
@@ -1176,7 +1174,6 @@ I18n::CI18nEngine::CI18nEngine() {
registerEntry("pl_PL", TXT_KEY_NOTIF_CM_RELOAD_FAILED, "Nie udało się przeładować shader'a CM, użyto rgba/rgbx.");
registerEntry("pl_PL", TXT_KEY_NOTIF_WIDE_COLOR_NOT_10B, "Monitor {name}: skonfigurowano szeroką głębię barw, ale monitor nie jest w trybie 10-bit.");
registerEntry("pl_PL", TXT_KEY_NOTIF_NO_WATCHDOG, "Hyprland został uruchomiony bez start-hyprland. Nie jest to zalecane, chyba, że jest to środowisko do debugowania.");
registerEntry("pl_PL", TXT_KEY_NOTIF_OUTDATED_CONFIG, "Format konfiguracji .conf, który jest obecnie w użyciu, utraci wsparcie wraz z Hyprland 0.57.");
registerEntry("pl_PL", TXT_KEY_SAFE_MODE_TITLE, "Tryb Bezpieczny");
registerEntry("pl_PL", TXT_KEY_SAFE_MODE_DESCRIPTION,
-1
View File
@@ -39,7 +39,6 @@ namespace I18n {
TXT_KEY_NOTIF_CM_RELOAD_FAILED,
TXT_KEY_NOTIF_WIDE_COLOR_NOT_10B,
TXT_KEY_NOTIF_NO_WATCHDOG,
TXT_KEY_NOTIF_OUTDATED_CONFIG,
TXT_KEY_SAFE_MODE_TITLE,
TXT_KEY_SAFE_MODE_DESCRIPTION,
+1 -1
View File
@@ -1,7 +1,7 @@
#include "defines.hpp"
#include "debug/log/Logger.hpp"
#include "Compositor.hpp"
#include "config/legacy/ConfigManager.hpp"
#include "config/ConfigManager.hpp"
#include "init/initHelpers.hpp"
#include "debug/HyprCtl.hpp"
#include "helpers/env/Env.hpp"
+16 -96
View File
@@ -1,6 +1,6 @@
#include "../config/ConfigValue.hpp"
#include "../config/ConfigManager.hpp"
#include "../config/legacy/DispatcherTranslator.hpp"
#include "../config/lua/ConfigManager.hpp"
#include "../config/shared/actions/ConfigActions.hpp"
#include "../devices/IKeyboard.hpp"
#include "../managers/SeatManager.hpp"
@@ -22,6 +22,7 @@
#include <cstring>
#include <hyprutils/string/String.hpp>
#include <hyprutils/string/Numeric.hpp>
#include <hyprutils/utils/ScopeGuard.hpp>
using namespace Hyprutils::String;
@@ -37,82 +38,6 @@ using namespace Hyprutils::String;
#endif
CKeybindManager::CKeybindManager() {
// initialize all dispatchers
// populate m_dispatchers from the legacy translator
for (const auto& name : {"exec",
"execr",
"killactive",
"forcekillactive",
"closewindow",
"killwindow",
"signal",
"signalwindow",
"togglefloating",
"setfloating",
"settiled",
"workspace",
"renameworkspace",
"fullscreen",
"fullscreenstate",
"movetoworkspace",
"movetoworkspacesilent",
"pseudo",
"movefocus",
"movewindow",
"swapwindow",
"centerwindow",
"togglegroup",
"changegroupactive",
"movegroupwindow",
"focusmonitor",
"movecursortocorner",
"movecursor",
"workspaceopt",
"exit",
"movecurrentworkspacetomonitor",
"focusworkspaceoncurrentmonitor",
"moveworkspacetomonitor",
"togglespecialworkspace",
"forcerendererreload",
"resizeactive",
"moveactive",
"cyclenext",
"focuswindowbyclass",
"focuswindow",
"tagwindow",
"toggleswallow",
"submap",
"pass",
"sendshortcut",
"sendkeystate",
"layoutmsg",
"dpms",
"movewindowpixel",
"resizewindowpixel",
"swapnext",
"swapactiveworkspaces",
"pin",
"mouse",
"bringactivetotop",
"alterzorder",
"focusurgentorlast",
"focuscurrentorlast",
"lockgroups",
"lockactivegroup",
"moveintogroup",
"moveoutofgroup",
"movewindoworgroup",
"moveintoorcreategroup",
"setignoregrouplock",
"denywindowfromgroup",
"event",
"global",
"setprop",
"forceidle",
"releaseinputcapture"}) {
m_dispatchers[name] = [n = std::string(name)](std::string args) -> SDispatchResult { return Config::Legacy::translator()->run(n, args); };
}
m_scrollTimer.reset();
m_longPressTimer = makeShared<CEventLoopTimer>(
@@ -125,10 +50,8 @@ CKeybindManager::CKeybindManager() {
if (!PACTIVEKEEB->m_allowBinds)
return;
const auto DISPATCHER = g_pKeybindManager->m_dispatchers.find(m_lastLongPressKeybind->handler);
Log::logger->log(Log::DEBUG, "Long press timeout passed, calling dispatcher.");
DISPATCHER->second(m_lastLongPressKeybind->arg);
callBindDispatcher(m_lastLongPressKeybind.lock());
},
nullptr);
@@ -148,10 +71,8 @@ CKeybindManager::CKeybindManager() {
if (!k || !k->enabled)
continue;
const auto DISPATCHER = g_pKeybindManager->m_dispatchers.find(k->handler);
Log::logger->log(Log::DEBUG, "Keybind repeat triggered, calling dispatcher.");
DISPATCHER->second(k->arg);
callBindDispatcher(k.lock());
}
self->updateTimeout(std::chrono::milliseconds(1000 / m_repeatKeyRate));
@@ -782,8 +703,6 @@ SDispatchResult CKeybindManager::handleKeybinds(const uint32_t modmask, const SP
const bool SPECIALDISPATCHER = k->handler == "global" || k->handler == "pass" || k->handler == "sendshortcut" || k->handler == "mouse" || k->releasePending;
const bool SPECIALTRIGGERED = std::ranges::find_if(m_pressedSpecialBinds, [&](const auto& other) { return other == k; }) != m_pressedSpecialBinds.end();
const auto DISPATCHER = m_dispatchers.find(k->mouse ? "mouse" : k->handler);
k->releasePending = false; // reset this flag if it's set
m_currentKeybind = k;
@@ -794,22 +713,15 @@ SDispatchResult CKeybindManager::handleKeybinds(const uint32_t modmask, const SP
else if (SPECIALDISPATCHER && pressed)
m_pressedSpecialBinds.emplace_back(k);
// Should never happen, as we check in the ConfigManager, but oh well
if (DISPATCHER == m_dispatchers.end()) {
Log::logger->log(Log::ERR, "Invalid handler in a keybind! (handler {} does not exist)", k->handler);
} else {
// call the dispatcher
Log::logger->log(Log::DEBUG, "Keybind triggered, calling dispatcher ({}, {}, {}, {})", modmask, key.keyName, key.keysym, DISPATCHER->first);
// call the lua callback
{
Log::logger->log(Log::DEBUG, "Keybind triggered, calling dispatcher ({}, {}, {})", modmask, key.keyName, key.keysym);
Config::Actions::state()->m_passPressed = sc<int>(pressed);
auto submapBefore = Config::Actions::state()->m_currentSubmap;
// if the dispatchers says to pass event then we will
if (k->handler == "mouse")
res = DISPATCHER->second((pressed ? "1" : "0") + k->arg);
else
res = DISPATCHER->second(k->arg);
callBindDispatcher(k);
Config::Actions::state()->m_passPressed = -1;
@@ -973,3 +885,11 @@ SDispatchResult CKeybindManager::changeMouseBindMode(const eMouseBindMode MODE)
return {};
}
void CKeybindManager::callBindDispatcher(const SP<SKeybind> k) {
// if the dispatchers says to pass event then we will
// FIXME: now that we got rid of legacy this needs to be fucking fixed what the fuck is this
auto idx = Hyprutils::String::strToNumber<int>(k->arg);
if (idx) // jic
Config::Lua::mgr()->callLuaFnBind(*idx);
}
+20 -26
View File
@@ -103,10 +103,6 @@ enum eMultiKeyCase : uint8_t {
MK_FULL_MATCH
};
namespace Config::Legacy {
class CConfigManager;
}
namespace Config::Lua {
class CConfigManager;
}
@@ -116,31 +112,29 @@ class CKeybindManager {
CKeybindManager();
~CKeybindManager();
bool onKeyEvent(std::any, SP<IKeyboard>);
bool onAxisEvent(const IPointer::SAxisEvent&, SP<IPointer>);
bool onMouseEvent(const IPointer::SButtonEvent&, SP<IPointer>);
void resizeWithBorder(const IPointer::SButtonEvent&);
void onSwitchEvent(const std::string&);
void onSwitchOnEvent(const std::string&);
void onSwitchOffEvent(const std::string&);
bool onKeyEvent(std::any, SP<IKeyboard>);
bool onAxisEvent(const IPointer::SAxisEvent&, SP<IPointer>);
bool onMouseEvent(const IPointer::SButtonEvent&, SP<IPointer>);
void resizeWithBorder(const IPointer::SButtonEvent&);
void onSwitchEvent(const std::string&);
void onSwitchOnEvent(const std::string&);
void onSwitchOffEvent(const std::string&);
SP<SKeybind> addKeybind(SKeybind);
void removeKeybind(uint32_t, const SParsedKey&);
void removeKeybind(const std::string& displayKeys);
uint32_t stringToModMask(std::string);
uint32_t keycodeToModifier(xkb_keycode_t);
SP<SKeybind> findConflictingKeybind(xkb_keysym_t keysym, uint32_t modmask);
void clearKeybinds();
void shadowKeybinds(const xkb_keysym_t& doesntHave = 0, const uint32_t doesntHaveCode = 0);
SSubmap getCurrentSubmap();
SP<SKeybind> addKeybind(SKeybind);
void removeKeybind(uint32_t, const SParsedKey&);
void removeKeybind(const std::string& displayKeys);
uint32_t stringToModMask(std::string);
uint32_t keycodeToModifier(xkb_keycode_t);
SP<SKeybind> findConflictingKeybind(xkb_keysym_t keysym, uint32_t modmask);
void clearKeybinds();
void shadowKeybinds(const xkb_keysym_t& doesntHave = 0, const uint32_t doesntHaveCode = 0);
SSubmap getCurrentSubmap();
std::unordered_map<std::string, std::function<SDispatchResult(std::string)>> m_dispatchers;
bool m_groupsLocked = false;
bool m_groupsLocked = false;
std::vector<SP<SKeybind>> m_keybinds;
std::vector<SP<SKeybind>> m_keybinds;
SP<SKeybind> m_currentKeybind;
SP<SKeybind> m_currentKeybind;
//since we can't find keycode through keyname in xkb:
//on sendshortcut call, we once search for keyname (e.g. "g") the correct keycode (e.g. 42)
@@ -178,11 +172,11 @@ class CKeybindManager {
void updateXKBTranslationState();
bool ensureMouseBindState();
void callBindDispatcher(const SP<SKeybind>);
static SDispatchResult releaseInputCapture(std::string);
friend class CCompositor;
friend class CInputManager;
friend class Config::Legacy::CConfigManager;
friend class Config::Lua::CConfigManager;
friend class CWorkspace;
friend class Pointer::CPointerManager;
+1 -1
View File
@@ -7,7 +7,7 @@
#include <algorithm>
#include "../../config/ConfigValue.hpp"
#include "../../config/shared/actions/ConfigActions.hpp"
#include "../../config/legacy/ConfigManager.hpp"
#include "../../config/ConfigManager.hpp"
#include "../../desktop/view/WLSurface.hpp"
#include "../../desktop/state/FocusState.hpp"
@@ -1,22 +0,0 @@
#include "DispatcherGesture.hpp"
#include "../../../../managers/KeybindManager.hpp"
CDispatcherTrackpadGesture::CDispatcherTrackpadGesture(const std::string& dispatcher, const std::string& data) : m_dispatcher(dispatcher), m_data(data) {
;
}
void CDispatcherTrackpadGesture::begin(const ITrackpadGesture::STrackpadGestureBegin& e) {
; // intentionally blank
}
void CDispatcherTrackpadGesture::update(const ITrackpadGesture::STrackpadGestureUpdate& e) {
; // intentionally blank
}
void CDispatcherTrackpadGesture::end(const ITrackpadGesture::STrackpadGestureEnd& e) {
if (!g_pKeybindManager->m_dispatchers.contains(m_dispatcher))
return;
g_pKeybindManager->m_dispatchers.at(m_dispatcher)(m_data);
}
@@ -1,16 +0,0 @@
#pragma once
#include "ITrackpadGesture.hpp"
class CDispatcherTrackpadGesture : public ITrackpadGesture {
public:
CDispatcherTrackpadGesture(const std::string& dispatcher, const std::string& data);
virtual ~CDispatcherTrackpadGesture() = default;
virtual void begin(const ITrackpadGesture::STrackpadGestureBegin& e);
virtual void update(const ITrackpadGesture::STrackpadGestureUpdate& e);
virtual void end(const ITrackpadGesture::STrackpadGestureEnd& e);
private:
std::string m_dispatcher, m_data;
};
+7 -74
View File
@@ -3,7 +3,7 @@
#include "../debug/HyprCtl.hpp"
#include "../plugins/PluginSystem.hpp"
#include "../managers/eventLoop/EventLoopManager.hpp"
#include "../config/legacy/ConfigManager.hpp"
#include "../config/ConfigManager.hpp"
#include "../config/lua/ConfigManager.hpp"
#include "../notification/NotificationOverlay.hpp"
#include "../layout/target/Target.hpp"
@@ -175,53 +175,15 @@ APICALL bool HyprlandAPI::removeWindowDecoration(HANDLE handle, IHyprWindowDecor
}
APICALL bool HyprlandAPI::addConfigValue(HANDLE handle, const std::string& name, const Hyprlang::CConfigValue& value) {
auto* const PLUGIN = g_pPluginSystem->getPluginByHandle(handle);
if (Config::mgr()->type() != Config::CONFIG_LEGACY)
return false;
if (!g_pPluginSystem->m_allowConfigVars)
return false;
if (!PLUGIN)
return false;
if (!name.starts_with("plugin:"))
return false;
Config::Legacy::mgr()->addPluginConfigVar(handle, name, value);
return true;
return false;
}
APICALL bool HyprlandAPI::addConfigKeyword(HANDLE handle, const std::string& name, Hyprlang::PCONFIGHANDLERFUNC fn, Hyprlang::SHandlerOptions opts) {
auto* const PLUGIN = g_pPluginSystem->getPluginByHandle(handle);
if (Config::mgr()->type() != Config::CONFIG_LEGACY)
return false;
if (!g_pPluginSystem->m_allowConfigVars)
return false;
if (!PLUGIN)
return false;
Config::Legacy::mgr()->addPluginKeyword(handle, name, fn, opts);
return true;
return false;
}
APICALL Hyprlang::CConfigValue* HyprlandAPI::getConfigValue(HANDLE handle, const std::string& name) {
auto* const PLUGIN = g_pPluginSystem->getPluginByHandle(handle);
if (Config::mgr()->type() != Config::CONFIG_LEGACY)
return nullptr;
if (!PLUGIN)
return nullptr;
if (name.starts_with("plugin:"))
return Config::Legacy::mgr()->getHyprlangConfigValuePtr(name.substr(7), "plugin");
return Config::Legacy::mgr()->getHyprlangConfigValuePtr(name);
return nullptr;
}
APICALL void* HyprlandAPI::getFunctionAddressFromSignature(HANDLE handle, const std::string& sig) {
@@ -234,44 +196,15 @@ APICALL void* HyprlandAPI::getFunctionAddressFromSignature(HANDLE handle, const
}
APICALL bool HyprlandAPI::addDispatcher(HANDLE handle, const std::string& name, std::function<void(std::string)> handler) {
auto* const PLUGIN = g_pPluginSystem->getPluginByHandle(handle);
if (!PLUGIN)
return false;
PLUGIN->m_registeredDispatchers.push_back(name);
g_pKeybindManager->m_dispatchers[name] = [handler](std::string arg1) -> SDispatchResult {
handler(arg1);
return {};
};
return true;
return false;
}
APICALL bool HyprlandAPI::addDispatcherV2(HANDLE handle, const std::string& name, std::function<SDispatchResult(std::string)> handler) {
auto* const PLUGIN = g_pPluginSystem->getPluginByHandle(handle);
if (!PLUGIN)
return false;
PLUGIN->m_registeredDispatchers.push_back(name);
g_pKeybindManager->m_dispatchers[name] = handler;
return true;
return false;
}
APICALL bool HyprlandAPI::removeDispatcher(HANDLE handle, const std::string& name) {
auto* const PLUGIN = g_pPluginSystem->getPluginByHandle(handle);
if (!PLUGIN)
return false;
std::erase_if(g_pKeybindManager->m_dispatchers, [&](const auto& other) { return other.first == name; });
std::erase_if(PLUGIN->m_registeredDispatchers, [&](const auto& other) { return other == name; });
return true;
return false;
}
APICALL bool addNotificationV2(HANDLE handle, const std::unordered_map<std::string, std::any>& data) {
+1 -1
View File
@@ -2,7 +2,7 @@
#include "../Compositor.hpp"
#include "../config/ConfigValue.hpp"
#include "../config/shared/actions/ConfigActions.hpp"
#include "../config/legacy/ConfigManager.hpp"
#include "../config/ConfigManager.hpp"
#include "../protocols/PointerGestures.hpp"
#include "../protocols/RelativePointer.hpp"
#include "../protocols/IdleNotify.hpp"
+1 -1
View File
@@ -2,7 +2,7 @@
#include <filesystem>
#include <sys/mman.h>
#include "../config/ConfigValue.hpp"
#include "../config/legacy/ConfigManager.hpp"
#include "../config/ConfigManager.hpp"
#include "../devices/IKeyboard.hpp"
#include "../helpers/time/Time.hpp"
#include "../helpers/MiscFunctions.hpp"
+1 -1
View File
@@ -15,7 +15,7 @@
#include "../helpers/CursorShapes.hpp"
#include "../helpers/TransferFunction.hpp"
#include "../config/ConfigValue.hpp"
#include "../config/legacy/ConfigManager.hpp"
#include "../config/ConfigManager.hpp"
#include "../pointer/PointerManager.hpp"
#include "../desktop/view/LayerSurface.hpp"
#include "../desktop/state/FocusState.hpp"
+1 -1
View File
@@ -6,7 +6,7 @@
#include <cmath>
#include <filesystem>
#include "../config/ConfigValue.hpp"
#include "../config/legacy/ConfigManager.hpp"
#include "../config/ConfigManager.hpp"
#include "../pointer/cursor/CursorManager.hpp"
#include "../pointer/PointerManager.hpp"
#include "../managers/input/InputManager.hpp"