diff --git a/src/backends/libinput/device.cpp b/src/backends/libinput/device.cpp index 819ae758b3..a3a30b8db1 100644 --- a/src/backends/libinput/device.cpp +++ b/src/backends/libinput/device.cpp @@ -412,7 +412,7 @@ void Device::setPointerAcceleration(qreal acceleration) if (!m_supportsPointerAcceleration) { return; } - acceleration = qBound(-1.0, acceleration, 1.0); + acceleration = std::clamp(acceleration, -1.0, 1.0); if (libinput_device_config_accel_set_speed(m_device, acceleration) == LIBINPUT_CONFIG_STATUS_SUCCESS) { if (m_pointerAcceleration != acceleration) { m_pointerAcceleration = acceleration; diff --git a/src/effects/desktopgrid/desktopgrideffect.cpp b/src/effects/desktopgrid/desktopgrideffect.cpp index ab11aea35a..12e6fe8b44 100644 --- a/src/effects/desktopgrid/desktopgrideffect.cpp +++ b/src/effects/desktopgrid/desktopgrideffect.cpp @@ -219,7 +219,7 @@ int DesktopGridEffect::gridRows() const case DesktopLayoutMode::LayoutAutomatic: return ceil(sqrt(effects->numberOfDesktops())); case DesktopLayoutMode::LayoutCustom: - return qBound(1, customLayoutRows(), effects->numberOfDesktops()); + return std::clamp(customLayoutRows(), 1, effects->numberOfDesktops()); case DesktopLayoutMode::LayoutPager: default: return effects->desktopGridSize().height(); diff --git a/src/libkwineffects/kwineffects.cpp b/src/libkwineffects/kwineffects.cpp index aa02934480..d0b40e3d6f 100644 --- a/src/libkwineffects/kwineffects.cpp +++ b/src/libkwineffects/kwineffects.cpp @@ -327,7 +327,7 @@ qreal WindowPaintData::crossFadeProgress() const void WindowPaintData::setCrossFadeProgress(qreal factor) { - d->crossFadeProgress = qBound(qreal(0.0), factor, qreal(1.0)); + d->crossFadeProgress = std::clamp(factor, 0.0, 1.0); } qreal WindowPaintData::multiplyOpacity(qreal factor) diff --git a/src/options.cpp b/src/options.cpp index 1656f7aa0a..a069013588 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -861,7 +861,7 @@ void Options::reloadCompositingSettings(bool force) // Compositing settings KConfigGroup config(m_settings->config(), "Compositing"); - setGlSmoothScale(qBound(-1, config.readEntry("GLTextureFilter", Options::defaultGlSmoothScale()), 2)); + setGlSmoothScale(std::clamp(config.readEntry("GLTextureFilter", Options::defaultGlSmoothScale()), -1, 2)); setGlStrictBindingFollowsDriver(!config.hasKey("GLStrictBinding")); if (!isGlStrictBindingFollowsDriver()) { setGlStrictBinding(config.readEntry("GLStrictBinding", Options::defaultGlStrictBinding())); diff --git a/src/plugins/kdecorations/aurorae/src/lib/auroraetheme.cpp b/src/plugins/kdecorations/aurorae/src/lib/auroraetheme.cpp index 2142c61170..a5a1ca975e 100644 --- a/src/plugins/kdecorations/aurorae/src/lib/auroraetheme.cpp +++ b/src/plugins/kdecorations/aurorae/src/lib/auroraetheme.cpp @@ -233,9 +233,9 @@ void AuroraeTheme::borders(int &left, int &top, int &right, int &bottom, bool ma maxMargin = 0; } - left = qBound(minMargin, d->themeConfig.borderLeft(), maxMargin); - right = qBound(minMargin, d->themeConfig.borderRight(), maxMargin); - bottom = qBound(minMargin, d->themeConfig.borderBottom(), maxMargin); + left = std::clamp(d->themeConfig.borderLeft(), minMargin, maxMargin); + right = std::clamp(d->themeConfig.borderRight(), minMargin, maxMargin); + bottom = std::clamp(d->themeConfig.borderBottom(), minMargin, maxMargin); if (d->borderSize == KDecoration2::BorderSize::None) { left = 0; diff --git a/src/plugins/nightcolor/nightcolormanager.cpp b/src/plugins/nightcolor/nightcolormanager.cpp index aeee503db3..9c75a95b2e 100644 --- a/src/plugins/nightcolor/nightcolormanager.cpp +++ b/src/plugins/nightcolor/nightcolormanager.cpp @@ -258,8 +258,8 @@ void NightColorManager::readConfig() break; } - m_dayTargetTemp = qBound(MIN_TEMPERATURE, s->dayTemperature(), DEFAULT_DAY_TEMPERATURE); - m_nightTargetTemp = qBound(MIN_TEMPERATURE, s->nightTemperature(), DEFAULT_DAY_TEMPERATURE); + m_dayTargetTemp = std::clamp(s->dayTemperature(), MIN_TEMPERATURE, DEFAULT_DAY_TEMPERATURE); + m_nightTargetTemp = std::clamp(s->nightTemperature(), MIN_TEMPERATURE, DEFAULT_DAY_TEMPERATURE); double lat, lng; auto correctReadin = [&lat, &lng]() { diff --git a/src/pointer_input.cpp b/src/pointer_input.cpp index 3f58d96fda..f6c588fee8 100644 --- a/src/pointer_input.cpp +++ b/src/pointer_input.cpp @@ -63,8 +63,8 @@ static bool screenContainsPos(const QPointF &pos) static QPointF confineToBoundingBox(const QPointF &pos, const QRectF &boundingBox) { return QPointF( - qBound(boundingBox.left(), pos.x(), boundingBox.right() - 1.0), - qBound(boundingBox.top(), pos.y(), boundingBox.bottom() - 1.0)); + std::clamp(pos.x(), boundingBox.left(), boundingBox.right() - 1.0), + std::clamp(pos.y(), boundingBox.top(), boundingBox.bottom() - 1.0)); } PointerInputRedirection::PointerInputRedirection(InputRedirection *parent) diff --git a/src/virtualdesktops.cpp b/src/virtualdesktops.cpp index eefdd39ff4..7acf23b68c 100644 --- a/src/virtualdesktops.cpp +++ b/src/virtualdesktops.cpp @@ -430,7 +430,7 @@ VirtualDesktop *VirtualDesktopManager::createVirtualDesktop(uint position, const return nullptr; } - position = qBound(0u, position, static_cast(m_desktops.count())); + position = std::clamp(position, 0u, static_cast(m_desktops.count())); QString desktopName = name; if (desktopName.isEmpty()) { @@ -545,7 +545,7 @@ bool VirtualDesktopManager::setCurrent(VirtualDesktop *newDesktop) void VirtualDesktopManager::setCount(uint count) { - count = qBound(1, count, VirtualDesktopManager::maximum()); + count = std::clamp(count, 1, VirtualDesktopManager::maximum()); if (count == uint(m_desktops.count())) { // nothing to change return; @@ -704,7 +704,7 @@ void VirtualDesktopManager::load() } int rows = group.readEntry("Rows", 2); - m_rows = qBound(1, rows, n); + m_rows = std::clamp(rows, 1, n); s_loadingDesktopSettings = false; } diff --git a/src/wayland/plasmavirtualdesktop_interface.cpp b/src/wayland/plasmavirtualdesktop_interface.cpp index 1e9dcf54f7..fc7cb2a68f 100644 --- a/src/wayland/plasmavirtualdesktop_interface.cpp +++ b/src/wayland/plasmavirtualdesktop_interface.cpp @@ -84,7 +84,7 @@ void PlasmaVirtualDesktopManagementInterfacePrivate::org_kde_plasma_virtual_desk const QString &name, uint32_t position) { - Q_EMIT q->desktopCreateRequested(name, qBound(0, position, (quint32)desktops.count())); + Q_EMIT q->desktopCreateRequested(name, std::clamp(position, 0, desktops.size())); } void PlasmaVirtualDesktopManagementInterfacePrivate::org_kde_plasma_virtual_desktop_management_request_remove_virtual_desktop(Resource *resource, diff --git a/src/window.cpp b/src/window.cpp index 28cf7f881e..24bc0d7f0a 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -323,7 +323,7 @@ qreal Window::opacity() const void Window::setOpacity(qreal opacity) { - opacity = qBound(0.0, opacity, 1.0); + opacity = std::clamp(opacity, 0.0, 1.0); if (m_opacity == opacity) { return; } @@ -4204,8 +4204,8 @@ QSizeF Window::constrainClientSize(const QSizeF &size, SizeMode mode) const const QSizeF minimumSize = minSize(); const QSizeF maximumSize = maxSize(); - width = qBound(minimumSize.width(), width, maximumSize.width()); - height = qBound(minimumSize.height(), height, maximumSize.height()); + width = std::clamp(width, minimumSize.width(), maximumSize.width()); + height = std::clamp(height, minimumSize.height(), maximumSize.height()); return QSizeF(width, height); }