config: add screencopy:max_fps

This commit is contained in:
Vaxry 2024-05-02 16:05:56 +01:00
parent 12af841341
commit ccabd97be3
2 changed files with 9 additions and 2 deletions

View File

@ -212,6 +212,7 @@ CPortalManager::CPortalManager() {
m_sConfig.config = std::make_unique<Hyprlang::CConfig>(path.c_str(), Hyprlang::SConfigOptions{.allowMissingConfig = true});
m_sConfig.config->addConfigValue("general:toplevel_dynamic_bind", Hyprlang::INT{0L});
m_sConfig.config->addConfigValue("screencopy:max_fps", Hyprlang::INT{120L});
m_sConfig.config->commence();
m_sConfig.config->parse();

View File

@ -491,8 +491,14 @@ void CScreencopyPortal::onSelectSources(sdbus::MethodCall& call) {
} else if (SHAREDATA.type == TYPE_OUTPUT || SHAREDATA.type == TYPE_GEOMETRY) {
const auto POUTPUT = g_pPortalManager->getOutputFromName(SHAREDATA.output);
if (POUTPUT)
PSESSION->sharingData.framerate = POUTPUT->refreshRate;
if (POUTPUT) {
static auto* const* PFPS = (Hyprlang::INT* const*)g_pPortalManager->m_sConfig.config->getConfigValuePtr("screencopy:max_fps")->getDataStaticPtr();
if (**PFPS <= 0)
PSESSION->sharingData.framerate = POUTPUT->refreshRate;
else
PSESSION->sharingData.framerate = std::clamp(POUTPUT->refreshRate, 1.F, (float)**PFPS);
}
}
PSESSION->selection = SHAREDATA;