summaryrefslogtreecommitdiff
path: root/src/debug/HyprCtl.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-02-24 14:01:58 +0000
committerVaxry <vaxry@vaxry.net>2024-02-24 14:02:03 +0000
commit6f838560252045be5bac2e7492ff8d1e250cf937 (patch)
tree19e8374b6b63f6c14ff47c785ae1c3d8326f1024 /src/debug/HyprCtl.cpp
parentd92da7959a1d271c585d0a7de4c75a389bd1ac05 (diff)
hyprctl: add -r argument
Diffstat (limited to 'src/debug/HyprCtl.cpp')
-rw-r--r--src/debug/HyprCtl.cpp55
1 files changed, 46 insertions, 9 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp
index 842a5ce6..8f29ae72 100644
--- a/src/debug/HyprCtl.cpp
+++ b/src/debug/HyprCtl.cpp
@@ -1476,7 +1476,8 @@ void CHyprCtl::unregisterCommand(const std::shared_ptr<SHyprCtlCommand>& cmd) {
}
std::string CHyprCtl::getReply(std::string request) {
- auto format = eHyprCtlOutputFormat::FORMAT_NORMAL;
+ auto format = eHyprCtlOutputFormat::FORMAT_NORMAL;
+ bool reloadAll = false;
// process flags for non-batch requests
if (!request.starts_with("[[BATCH]]") && request.contains("/")) {
@@ -1497,30 +1498,66 @@ std::string CHyprCtl::getReply(std::string request) {
if (c == 'j')
format = eHyprCtlOutputFormat::FORMAT_JSON;
+ if (c == 'r')
+ reloadAll = true;
}
if (sepIndex < request.size())
request = request.substr(sepIndex + 1); // remove flags and separator so we can compare the rest of the string
}
+ std::string result = "";
+
// parse exact cmds first, then non-exact.
for (auto& cmd : m_vCommands) {
if (!cmd->exact)
continue;
- if (cmd->name == request)
- return cmd->fn(format, request);
+ if (cmd->name == request) {
+ result = cmd->fn(format, request);
+ break;
+ }
}
- for (auto& cmd : m_vCommands) {
- if (cmd->exact)
- continue;
+ if (result.empty())
+ for (auto& cmd : m_vCommands) {
+ if (cmd->exact)
+ continue;
- if (request.starts_with(cmd->name))
- return cmd->fn(format, request);
+ if (request.starts_with(cmd->name)) {
+ result = cmd->fn(format, request);
+ break;
+ }
+ }
+
+ if (result.empty())
+ return "unknown request";
+
+ if (reloadAll) {
+ g_pConfigManager->m_bWantsMonitorReload = true; // for monitor keywords
+
+ g_pInputManager->setKeyboardLayout(); // update kb layout
+ g_pInputManager->setPointerConfigs(); // update mouse cfgs
+ g_pInputManager->setTouchDeviceConfigs(); // update touch device cfgs
+ g_pInputManager->setTabletConfigs(); // update tablets
+
+ static auto* const PLAYOUT = (Hyprlang::STRING const*)g_pConfigManager->getConfigValuePtr("general:layout");
+
+ g_pLayoutManager->switchToLayout(*PLAYOUT); // update layout
+
+ g_pHyprOpenGL->m_bReloadScreenShader = true;
+
+ for (auto& [m, rd] : g_pHyprOpenGL->m_mMonitorRenderResources) {
+ rd.blurFBDirty = true;
+ }
+
+ for (auto& m : g_pCompositor->m_vMonitors) {
+ g_pHyprRenderer->damageMonitor(m.get());
+ g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->ID);
+ }
}
- return "unknown request";
+ return result;
}
std::string CHyprCtl::makeDynamicCall(const std::string& input) {