summaryrefslogtreecommitdiff
path: root/src/debug/HyprCtl.cpp
diff options
context:
space:
mode:
authorMightyPlaza <123664421+MightyPlaza@users.noreply.github.com>2024-10-28 18:18:58 +0000
committerGitHub <noreply@github.com>2024-10-28 18:18:58 +0000
commit7188ee4f992966c5793efebd6dc70ab377820066 (patch)
tree2def434c87730bfa35a9557526df975e568239ca /src/debug/HyprCtl.cpp
parentc7315617eb6186912d03232e1968f32b88f153f2 (diff)
hyprctl: move setprop into dispatchers (#8275)
* move setprop into dispatchers modified: src/debug/HyprCtl.cpp modified: src/managers/KeybindManager.cpp modified: src/managers/KeybindManager.hpp * add deprecated modified: src/debug/HyprCtl.cpp
Diffstat (limited to 'src/debug/HyprCtl.cpp')
-rw-r--r--src/debug/HyprCtl.cpp97
1 files changed, 2 insertions, 95 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp
index bf3ecfc8..93e0f620 100644
--- a/src/debug/HyprCtl.cpp
+++ b/src/debug/HyprCtl.cpp
@@ -1262,101 +1262,8 @@ std::string dispatchSeterror(eHyprCtlOutputFormat format, std::string request) {
}
std::string dispatchSetProp(eHyprCtlOutputFormat format, std::string request) {
- CVarList vars(request, 0, ' ');
-
- if (vars.size() < 4)
- return "not enough args";
-
- const auto PLASTWINDOW = g_pCompositor->m_pLastWindow.lock();
- const auto PWINDOW = g_pCompositor->getWindowByRegex(vars[1]);
-
- if (!PWINDOW)
- return "window not found";
-
- const auto PROP = vars[2];
- const auto VAL = vars[3];
-
- bool noFocus = PWINDOW->m_sWindowData.noFocus.valueOrDefault();
-
- try {
- if (PROP == "animationstyle") {
- PWINDOW->m_sWindowData.animationStyle = CWindowOverridableVar(VAL, PRIORITY_SET_PROP);
- } else if (PROP == "maxsize") {
- PWINDOW->m_sWindowData.maxSize = CWindowOverridableVar(configStringToVector2D(VAL + " " + vars[4]), PRIORITY_SET_PROP);
- PWINDOW->m_vRealSize = Vector2D(std::min((double)PWINDOW->m_sWindowData.maxSize.value().x, PWINDOW->m_vRealSize.goal().x),
- std::min((double)PWINDOW->m_sWindowData.maxSize.value().y, PWINDOW->m_vRealSize.goal().y));
- g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goal());
- PWINDOW->setHidden(false);
- } else if (PROP == "minsize") {
- PWINDOW->m_sWindowData.minSize = CWindowOverridableVar(configStringToVector2D(VAL + " " + vars[4]), PRIORITY_SET_PROP);
- PWINDOW->m_vRealSize = Vector2D(std::max((double)PWINDOW->m_sWindowData.minSize.value().x, PWINDOW->m_vRealSize.goal().x),
- std::max((double)PWINDOW->m_sWindowData.minSize.value().y, PWINDOW->m_vRealSize.goal().y));
- g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goal());
- PWINDOW->setHidden(false);
- } else if (PROP == "alpha") {
- PWINDOW->m_sWindowData.alpha = CWindowOverridableVar(SAlphaValue{std::stof(VAL), PWINDOW->m_sWindowData.alpha.valueOrDefault().m_bOverride}, PRIORITY_SET_PROP);
- } else if (PROP == "alphainactive") {
- PWINDOW->m_sWindowData.alphaInactive =
- CWindowOverridableVar(SAlphaValue{std::stof(VAL), PWINDOW->m_sWindowData.alphaInactive.valueOrDefault().m_bOverride}, PRIORITY_SET_PROP);
- } else if (PROP == "alphafullscreen") {
- PWINDOW->m_sWindowData.alphaFullscreen =
- CWindowOverridableVar(SAlphaValue{std::stof(VAL), PWINDOW->m_sWindowData.alphaFullscreen.valueOrDefault().m_bOverride}, PRIORITY_SET_PROP);
- } else if (PROP == "alphaoverride") {
- PWINDOW->m_sWindowData.alpha =
- CWindowOverridableVar(SAlphaValue{PWINDOW->m_sWindowData.alpha.valueOrDefault().m_fAlpha, (bool)configStringToInt(VAL)}, PRIORITY_SET_PROP);
- } else if (PROP == "alphainactiveoverride") {
- PWINDOW->m_sWindowData.alphaInactive =
- CWindowOverridableVar(SAlphaValue{PWINDOW->m_sWindowData.alphaInactive.valueOrDefault().m_fAlpha, (bool)configStringToInt(VAL)}, PRIORITY_SET_PROP);
- } else if (PROP == "alphafullscreenoverride") {
- PWINDOW->m_sWindowData.alphaFullscreen =
- CWindowOverridableVar(SAlphaValue{PWINDOW->m_sWindowData.alphaFullscreen.valueOrDefault().m_fAlpha, (bool)configStringToInt(VAL)}, PRIORITY_SET_PROP);
- } else if (PROP == "activebordercolor" || PROP == "inactivebordercolor") {
- CGradientValueData colorData = {};
- if (vars.size() > 4) {
- for (int i = 3; i < static_cast<int>(vars.size()); ++i) {
- const auto TOKEN = vars[i];
- if (TOKEN.ends_with("deg"))
- colorData.m_fAngle = std::stoi(TOKEN.substr(0, TOKEN.size() - 3)) * (PI / 180.0);
- else
- colorData.m_vColors.push_back(configStringToInt(TOKEN));
- }
- } else if (VAL != "-1")
- colorData.m_vColors.push_back(configStringToInt(VAL));
-
- if (PROP == "activebordercolor")
- PWINDOW->m_sWindowData.activeBorderColor = CWindowOverridableVar(colorData, PRIORITY_SET_PROP);
- else
- PWINDOW->m_sWindowData.inactiveBorderColor = CWindowOverridableVar(colorData, PRIORITY_SET_PROP);
- } else if (auto search = g_pConfigManager->mbWindowProperties.find(PROP); search != g_pConfigManager->mbWindowProperties.end()) {
- auto pWindowDataElement = search->second(PWINDOW);
- if (VAL == "toggle")
- *pWindowDataElement = CWindowOverridableVar(!pWindowDataElement->valueOrDefault(), PRIORITY_SET_PROP);
- else if (VAL == "unset")
- pWindowDataElement->unset(PRIORITY_SET_PROP);
- else
- *pWindowDataElement = CWindowOverridableVar((bool)configStringToInt(VAL), PRIORITY_SET_PROP);
- } else if (auto search = g_pConfigManager->miWindowProperties.find(PROP); search != g_pConfigManager->miWindowProperties.end()) {
- if (VAL == "unset")
- search->second(PWINDOW)->unset(PRIORITY_SET_PROP);
- else
- *(search->second(PWINDOW)) = CWindowOverridableVar((int)configStringToInt(VAL), PRIORITY_SET_PROP);
- } else {
- return "prop not found";
- }
- } catch (std::exception& e) { return "error in parsing prop value: " + std::string(e.what()); }
-
- g_pCompositor->updateAllWindowsAnimatedDecorationValues();
-
- if (!(PWINDOW->m_sWindowData.noFocus.valueOrDefault() == noFocus)) {
- g_pCompositor->focusWindow(nullptr);
- g_pCompositor->focusWindow(PWINDOW);
- g_pCompositor->focusWindow(PLASTWINDOW);
- }
-
- for (auto const& m : g_pCompositor->m_vMonitors)
- g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->ID);
-
- return "ok";
+ auto result = g_pKeybindManager->m_mDispatchers["setprop"](request.substr(request.find_first_of(' ') + 1, -1));
+ return "DEPRECATED: use hyprctl dispatch setprop instead" + (result.success ? "" : "\n" + result.error);
}
std::string dispatchGetOption(eHyprCtlOutputFormat format, std::string request) {