Skip to content

Commit

Permalink
config: add screencopy:max_fps
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed May 2, 2024
1 parent 12af841 commit ccabd97
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/core/PortalManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 8 additions & 2 deletions src/portals/Screencopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ccabd97

Please sign in to comment.