aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2022-07-06 16:50:11 +0200
committervaxerski <[email protected]>2022-07-06 16:50:11 +0200
commitf9756d10d4d1c5ea7737cf3a237b1f966d6b7a01 (patch)
treec88df1366e9af3097edd2025494564ea92e0cb2a
parent0d7a8cca790e8fa71a83e4dce09fbe5a0af38cbc (diff)
downloadHyprland-f9756d10d4d1c5ea7737cf3a237b1f966d6b7a01.tar.gz
Hyprland-f9756d10d4d1c5ea7737cf3a237b1f966d6b7a01.zip
changed C++ std to C++23, use std::string::contains
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/config/ConfigManager.cpp6
-rw-r--r--src/debug/HyprCtl.cpp2
-rw-r--r--src/events/Windows.cpp14
-rw-r--r--src/helpers/MiscFunctions.cpp6
-rw-r--r--src/managers/AnimationManager.cpp2
-rw-r--r--src/managers/KeybindManager.cpp22
-rw-r--r--src/managers/KeybindManager.hpp2
-rw-r--r--src/managers/XWaylandManager.cpp2
9 files changed, 29 insertions, 29 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c93a9f32..e7c39e93 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,7 +37,7 @@ execute_process(
include_directories(. PRIVATE "subprojects/wlroots/include/")
include_directories(. PRIVATE "subprojects/wlroots/build/include/")
-add_compile_options(-std=c++20 -DWLR_USE_UNSTABLE )
+add_compile_options(-std=c++2b -DWLR_USE_UNSTABLE )
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value -Wno-missing-field-initializers -Wno-narrowing)
find_package(Threads REQUIRED)
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index ee8ab95e..ded23733 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -356,7 +356,7 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
newrule.resolution.x = stoi(curitem.substr(0, curitem.find_first_of('x')));
newrule.resolution.y = stoi(curitem.substr(curitem.find_first_of('x') + 1, curitem.find_first_of('@')));
- if (curitem.find_first_of('@') != std::string::npos)
+ if (curitem.contains("@"))
newrule.refreshRate = stof(curitem.substr(curitem.find_first_of('@') + 1));
nextItem();
@@ -722,7 +722,7 @@ void CConfigManager::parseLine(std::string& line) {
line = line.substr(1);
}
- if (line.find(" {") != std::string::npos) {
+ if (line.contains(" {")) {
auto cat = line.substr(0, line.find(" {"));
transform(cat.begin(), cat.end(), cat.begin(), ::tolower);
if (currentCategory.length() != 0) {
@@ -736,7 +736,7 @@ void CConfigManager::parseLine(std::string& line) {
return;
}
- if (line.find("}") != std::string::npos && currentCategory != "") {
+ if (line.contains("}") && currentCategory != "") {
currentCategory = "";
return;
}
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp
index 65b45901..ad72c68e 100644
--- a/src/debug/HyprCtl.cpp
+++ b/src/debug/HyprCtl.cpp
@@ -158,7 +158,7 @@ std::string dispatchKeyword(std::string in) {
if (COMMAND == "monitor")
g_pConfigManager->m_bWantsMonitorReload = true; // for monitor keywords
- if (COMMAND.find("input") != std::string::npos)
+ if (COMMAND.contains("input"))
g_pInputManager->setKeyboardLayout(); // update kb layout
Debug::log(LOG, "Hyprctl: keyword %s : %s", COMMAND.c_str(), VALUE.c_str());
diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp
index add63140..d7c3e1ec 100644
--- a/src/events/Windows.cpp
+++ b/src/events/Windows.cpp
@@ -152,7 +152,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
try {
std::string alphaPart = r.szRule.substr(r.szRule.find_first_of(' ') + 1);
- if (alphaPart.find_first_of(' ') != std::string::npos) {
+ if (alphaPart.contains(' ')) {
// we have a comma, 2 values
PWINDOW->m_sSpecialRenderData.alpha = std::stof(alphaPart.substr(0, alphaPart.find_first_of(' ')));
PWINDOW->m_sSpecialRenderData.alphaInactive = std::stof(alphaPart.substr(alphaPart.find_first_of(' ') + 1));
@@ -170,9 +170,9 @@ void Events::listener_mapWindow(void* owner, void* data) {
if (requestedWorkspace != "") {
// process requested workspace
- if (requestedWorkspace.find_first_of(' ') != std::string::npos) {
+ if (requestedWorkspace.contains(' ')) {
// check for silent
- if (requestedWorkspace.find("silent") != std::string::npos) {
+ if (requestedWorkspace.contains("silent")) {
workspaceSilent = true;
}
@@ -199,8 +199,8 @@ void Events::listener_mapWindow(void* owner, void* data) {
const auto SIZEXSTR = VALUE.substr(0, VALUE.find(" "));
const auto SIZEYSTR = VALUE.substr(VALUE.find(" ") + 1);
- const auto SIZEX = SIZEXSTR.find('%') == std::string::npos ? std::stoi(SIZEXSTR) : std::stoi(SIZEXSTR.substr(0, SIZEXSTR.length() - 1)) * 0.01f * PMONITOR->vecSize.x;
- const auto SIZEY = SIZEYSTR.find('%') == std::string::npos ? std::stoi(SIZEYSTR) : std::stoi(SIZEYSTR.substr(0, SIZEYSTR.length() - 1)) * 0.01f * PMONITOR->vecSize.y;
+ const auto SIZEX = !SIZEXSTR.contains('%') ? std::stoi(SIZEXSTR) : std::stoi(SIZEXSTR.substr(0, SIZEXSTR.length() - 1)) * 0.01f * PMONITOR->vecSize.x;
+ const auto SIZEY = !SIZEYSTR.contains('%') ? std::stoi(SIZEYSTR) : std::stoi(SIZEYSTR.substr(0, SIZEYSTR.length() - 1)) * 0.01f * PMONITOR->vecSize.y;
Debug::log(LOG, "Rule size, applying to window %x", PWINDOW);
@@ -215,8 +215,8 @@ void Events::listener_mapWindow(void* owner, void* data) {
const auto POSXSTR = VALUE.substr(0, VALUE.find(" "));
const auto POSYSTR = VALUE.substr(VALUE.find(" ") + 1);
- const auto POSX = POSXSTR.find('%') == std::string::npos ? std::stoi(POSXSTR) : std::stoi(POSXSTR.substr(0, POSXSTR.length() - 1)) * 0.01f * PMONITOR->vecSize.x;
- const auto POSY = POSYSTR.find('%') == std::string::npos ? std::stoi(POSYSTR) : std::stoi(POSYSTR.substr(0, POSYSTR.length() - 1)) * 0.01f * PMONITOR->vecSize.y;
+ const auto POSX = !POSXSTR.contains('%') ? std::stoi(POSXSTR) : std::stoi(POSXSTR.substr(0, POSXSTR.length() - 1)) * 0.01f * PMONITOR->vecSize.x;
+ const auto POSY = !POSYSTR.contains('%') ? std::stoi(POSYSTR) : std::stoi(POSYSTR.substr(0, POSYSTR.length() - 1)) * 0.01f * PMONITOR->vecSize.y;
Debug::log(LOG, "Rule move, applying to window %x", PWINDOW);
diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp
index cb1d88d6..126600f3 100644
--- a/src/helpers/MiscFunctions.cpp
+++ b/src/helpers/MiscFunctions.cpp
@@ -137,7 +137,7 @@ float getPlusMinusKeywordResult(std::string source, float relative) {
if (source.find_first_of("+") == 0) {
try {
- if (source.find('.') != std::string::npos)
+ if (source.contains("."))
result = relative + std::stof(source.substr(1));
else
result = relative + std::stoi(source.substr(1));
@@ -147,7 +147,7 @@ float getPlusMinusKeywordResult(std::string source, float relative) {
}
} else if (source.find_first_of("-") == 0) {
try {
- if (source.find('.') != std::string::npos)
+ if (source.contains("."))
result = relative - std::stof(source.substr(1));
else
result = relative - std::stoi(source.substr(1));
@@ -157,7 +157,7 @@ float getPlusMinusKeywordResult(std::string source, float relative) {
}
} else {
try {
- if (source.find('.') != std::string::npos)
+ if (source.contains("."))
result = stof(source);
else
result = stoi(source);
diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp
index 7574998d..96b667f9 100644
--- a/src/managers/AnimationManager.cpp
+++ b/src/managers/AnimationManager.cpp
@@ -309,7 +309,7 @@ void CAnimationManager::onWindowPostCreateClose(CWindow* pWindow, bool close) {
if (pWindow->m_sAdditionalConfigData.animationStyle != "") {
// the window has config'd special anim
if (pWindow->m_sAdditionalConfigData.animationStyle.find("slide") == 0) {
- if (pWindow->m_sAdditionalConfigData.animationStyle.find(' ') != std::string::npos) {
+ if (pWindow->m_sAdditionalConfigData.animationStyle.contains(' ')) {
// has a direction
animationSlide(pWindow, pWindow->m_sAdditionalConfigData.animationStyle.substr(pWindow->m_sAdditionalConfigData.animationStyle.find(' ') + 1), close);
} else {
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index f5ec0e48..d33cd0b6 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -49,21 +49,21 @@ void CKeybindManager::removeKeybind(uint32_t mod, const std::string& key) {
uint32_t CKeybindManager::stringToModMask(std::string mods) {
uint32_t modMask = 0;
- if (mods.find("SHIFT") != std::string::npos)
+ if (mods.contains("SHIFT"))
modMask |= WLR_MODIFIER_SHIFT;
- if (mods.find("CAPS") != std::string::npos)
+ if (mods.contains("CAPS"))
modMask |= WLR_MODIFIER_CAPS;
- if (mods.find("CTRL") != std::string::npos || mods.find("CONTROL") != std::string::npos)
+ if (mods.contains("CTRL") || mods.contains("CONTROL"))
modMask |= WLR_MODIFIER_CTRL;
- if (mods.find("ALT") != std::string::npos)
+ if (mods.contains("ALT"))
modMask |= WLR_MODIFIER_ALT;
- if (mods.find("MOD2") != std::string::npos)
+ if (mods.contains("MOD2"))
modMask |= WLR_MODIFIER_MOD2;
- if (mods.find("MOD3") != std::string::npos)
+ if (mods.contains("MOD3"))
modMask |= WLR_MODIFIER_MOD3;
- if (mods.find("SUPER") != std::string::npos || mods.find("WIN") != std::string::npos || mods.find("LOGO") != std::string::npos || mods.find("MOD4") != std::string::npos)
+ if (mods.contains("SUPER") || mods.contains("WIN") || mods.contains("LOGO") || mods.contains("MOD4"))
modMask |= WLR_MODIFIER_LOGO;
- if (mods.find("MOD5") != std::string::npos)
+ if (mods.contains("MOD5"))
modMask |= WLR_MODIFIER_MOD5;
return modMask;
@@ -823,7 +823,7 @@ void CKeybindManager::moveCurrentWorkspaceToMonitor(std::string args) {
}
void CKeybindManager::moveWorkspaceToMonitor(std::string args) {
- if (args.find_first_of(' ') == std::string::npos)
+ if (!args.contains(' '))
return;
std::string workspace = args.substr(0, args.find_first_of(' '));
@@ -925,7 +925,7 @@ void CKeybindManager::forceRendererReload(std::string args) {
}
void CKeybindManager::resizeActive(std::string args) {
- if (args.find_first_of(' ') == std::string::npos)
+ if (!args.contains(' '))
return;
std::string x = args.substr(0, args.find_first_of(' '));
@@ -974,7 +974,7 @@ void CKeybindManager::resizeActive(std::string args) {
}
void CKeybindManager::moveActive(std::string args) {
- if (args.find_first_of(' ') == std::string::npos)
+ if (!args.contains(' '))
return;
std::string x = args.substr(0, args.find_first_of(' '));
diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp
index 31498677..c667a41c 100644
--- a/src/managers/KeybindManager.hpp
+++ b/src/managers/KeybindManager.hpp
@@ -7,7 +7,7 @@
#include <functional>
struct SKeybind {
- std::string key = 0;
+ std::string key = "";
uint32_t modmask = 0;
std::string handler = "";
std::string arg = "";
diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp
index 48687163..6bb512ee 100644
--- a/src/managers/XWaylandManager.cpp
+++ b/src/managers/XWaylandManager.cpp
@@ -153,7 +153,7 @@ bool CHyprXWaylandManager::shouldBeFloated(CWindow* pWindow) {
if (pWindow->m_uSurface.xwayland->role) {
try {
std::string winrole = std::string(pWindow->m_uSurface.xwayland->role);
- if (winrole.find("pop-up") != std::string::npos || winrole.find("task_dialog") != std::string::npos) {
+ if (winrole.contains("pop-up") || winrole.contains("task_dialog")) {
return true;
}
} catch (std::exception& e) {