summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2022-09-26 20:49:56 +0100
committerGitHub <noreply@github.com>2022-09-26 20:49:56 +0100
commit7a775c0584db95af25bae1c07952c99c6c1bfe6e (patch)
treeb72b7df6c61f380811668416366d8133116d9129 /src
parentf70b57f360f8117ecca67d6d7f75c1f87b098794 (diff)
parent87afc8c250ba6868c2374ad2a3e0a9374e8f0c1a (diff)
Merge pull request #737 from Dickby/use_max_instead_of_clamp_in_some_places
Replace clamp with max if there is no upper bound.
Diffstat (limited to 'src')
-rw-r--r--src/helpers/AnimatedVariable.cpp2
-rw-r--r--src/helpers/MiscFunctions.cpp4
-rw-r--r--src/layout/DwindleLayout.cpp2
-rw-r--r--src/layout/MasterLayout.cpp2
-rw-r--r--src/render/Renderer.cpp6
5 files changed, 8 insertions, 8 deletions
diff --git a/src/helpers/AnimatedVariable.cpp b/src/helpers/AnimatedVariable.cpp
index 7860fb8f..573844aa 100644
--- a/src/helpers/AnimatedVariable.cpp
+++ b/src/helpers/AnimatedVariable.cpp
@@ -59,5 +59,5 @@ void CAnimatedVariable::unregister() {
}
int CAnimatedVariable::getDurationLeftMs() {
- return std::clamp((int)(m_pConfig->pValues->internalSpeed * 100) - (int)std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - animationBegin).count(), 0, INT_MAX);
+ return std::max((int)(m_pConfig->pValues->internalSpeed * 100) - (int)std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - animationBegin).count(), 0);
}
diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp
index e699d75a..d7df7bd7 100644
--- a/src/helpers/MiscFunctions.cpp
+++ b/src/helpers/MiscFunctions.cpp
@@ -254,9 +254,9 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
} else {
if (g_pCompositor->m_pLastMonitor)
- result = std::clamp((int)getPlusMinusKeywordResult(in, g_pCompositor->m_pLastMonitor->activeWorkspace), 1, INT_MAX);
+ result = std::max((int)getPlusMinusKeywordResult(in, g_pCompositor->m_pLastMonitor->activeWorkspace), 1);
else if (isNumber(in))
- result = std::clamp(std::stoi(in), 1, INT_MAX);
+ result = std::max(std::stoi(in), 1);
else {
Debug::log(ERR, "Relative workspace on no mon!");
result = INT_MAX;
diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp
index 4e4f0829..5399c82d 100644
--- a/src/layout/DwindleLayout.cpp
+++ b/src/layout/DwindleLayout.cpp
@@ -611,7 +611,7 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow*
const auto PNODE = getNodeFromWindow(PWINDOW);
if (!PNODE) {
- PWINDOW->m_vRealSize = Vector2D(std::clamp((PWINDOW->m_vRealSize.goalv() + pixResize).x, (double)20, (double)999999), std::clamp((PWINDOW->m_vRealSize.goalv() + pixResize).y, (double)20, (double)999999));
+ PWINDOW->m_vRealSize = Vector2D(std::max((PWINDOW->m_vRealSize.goalv() + pixResize).x, (double)20), std::max((PWINDOW->m_vRealSize.goalv() + pixResize).y, (double)20));
PWINDOW->updateWindowDecos();
return;
}
diff --git a/src/layout/MasterLayout.cpp b/src/layout/MasterLayout.cpp
index 0a1c5179..7f6a3c75 100644
--- a/src/layout/MasterLayout.cpp
+++ b/src/layout/MasterLayout.cpp
@@ -311,7 +311,7 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow* p
const auto PNODE = getNodeFromWindow(PWINDOW);
if (!PNODE) {
- PWINDOW->m_vRealSize = Vector2D(std::clamp((PWINDOW->m_vRealSize.goalv() + pixResize).x, (double)20, (double)999999), std::clamp((PWINDOW->m_vRealSize.goalv() + pixResize).y, (double)20, (double)999999));
+ PWINDOW->m_vRealSize = Vector2D(std::max((PWINDOW->m_vRealSize.goalv() + pixResize).x, (double)20), std::max((PWINDOW->m_vRealSize.goalv() + pixResize).y, (double)20));
PWINDOW->updateWindowDecos();
return;
}
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 8f673ab3..12cf4850 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -15,7 +15,7 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
if (RDATA->surface && surface == RDATA->surface)
windowBox = {(int)outputX + RDATA->x + x, (int)outputY + RDATA->y + y, RDATA->w, RDATA->h};
else // here we clamp to 2, these might be some tiny specks
- windowBox = {(int)outputX + RDATA->x + x, (int)outputY + RDATA->y + y, std::clamp(surface->current.width, 2, 1337420), std::clamp(surface->current.height, 2, 1337420)};
+ windowBox = {(int)outputX + RDATA->x + x, (int)outputY + RDATA->y + y, std::max(surface->current.width, 2), std::max(surface->current.height, 2)};
if (RDATA->squishOversized) {
if (x + windowBox.width > RDATA->w)
@@ -226,8 +226,8 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
SRenderData renderdata = {pMonitor->output, time, REALPOS.x, REALPOS.y};
renderdata.surface = g_pXWaylandManager->getWindowSurface(pWindow);
- renderdata.w = std::clamp(pWindow->m_vRealSize.vec().x, (double)5, (double)1337420); // clamp the size to min 5,
- renderdata.h = std::clamp(pWindow->m_vRealSize.vec().y, (double)5, (double)1337420); // otherwise we'll have issues later with invalid boxes
+ renderdata.w = std::max(pWindow->m_vRealSize.vec().x, (double)5); // clamp the size to min 5,
+ renderdata.h = std::max(pWindow->m_vRealSize.vec().y, (double)5); // otherwise we'll have issues later with invalid boxes
renderdata.dontRound = (pWindow->m_bIsFullscreen && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) || (!pWindow->m_sSpecialRenderData.rounding);
renderdata.fadeAlpha = pWindow->m_fAlpha.fl() * (pWindow->m_bPinned ? 1.f : (PWORKSPACE->m_fAlpha.fl() / 255.f));
renderdata.alpha = pWindow->m_fActiveInactiveAlpha.fl();