summaryrefslogtreecommitdiff
path: root/src/managers
diff options
context:
space:
mode:
authorKamikadze <40305144+Kam1k4dze@users.noreply.github.com>2025-05-31 23:49:50 +0500
committerGitHub <noreply@github.com>2025-05-31 19:49:50 +0100
commit69c2b2926e128f1fd09080aed43944987a42026f (patch)
treec92596715498f30ae33767d3c93268d4f01aec6f /src/managers
parent4078e1d17c0fb1439ee5a0ba1e539f06a8f47aab (diff)
internal: refactor to use empty() (#10599)
Diffstat (limited to 'src/managers')
-rw-r--r--src/managers/AnimationManager.cpp4
-rw-r--r--src/managers/CursorManager.cpp8
-rw-r--r--src/managers/KeybindManager.cpp10
-rw-r--r--src/managers/ProtocolManager.cpp2
-rw-r--r--src/managers/SeatManager.cpp2
-rw-r--r--src/managers/input/InputManager.cpp10
6 files changed, 18 insertions, 18 deletions
diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp
index f935d3dc..d1da1a36 100644
--- a/src/managers/AnimationManager.cpp
+++ b/src/managers/AnimationManager.cpp
@@ -306,7 +306,7 @@ void CHyprAnimationManager::animationSlide(PHLWINDOW pWindow, std::string force,
Vector2D posOffset;
- if (force != "") {
+ if (!force.empty()) {
if (force == "bottom")
posOffset = Vector2D(GOALPOS.x, PMONITOR->m_position.y + PMONITOR->m_size.y);
else if (force == "left")
@@ -490,7 +490,7 @@ std::string CHyprAnimationManager::styleValidInConfigVar(const std::string& conf
return "";
return "unknown style";
} else if (config.starts_with("layers")) {
- if (style == "fade" || style == "" || style == "slide")
+ if (style.empty() || style == "fade" || style == "slide")
return "";
else if (style.starts_with("popin")) {
// try parsing
diff --git a/src/managers/CursorManager.cpp b/src/managers/CursorManager.cpp
index 9211fc20..cb46dd65 100644
--- a/src/managers/CursorManager.cpp
+++ b/src/managers/CursorManager.cpp
@@ -183,7 +183,7 @@ void CCursorManager::setCursorFromName(const std::string& name) {
auto setHyprCursor = [this](auto const& name) {
m_currentCursorShapeData = m_hyprcursor->getShape(name.c_str(), m_currentStyleInfo);
- if (m_currentCursorShapeData.images.size() < 1) {
+ if (m_currentCursorShapeData.images.empty()) {
// try with '_' first (old hc, etc)
std::string newName = name;
std::ranges::replace(newName, '-', '_');
@@ -191,18 +191,18 @@ void CCursorManager::setCursorFromName(const std::string& name) {
m_currentCursorShapeData = m_hyprcursor->getShape(newName.c_str(), m_currentStyleInfo);
}
- if (m_currentCursorShapeData.images.size() < 1) {
+ if (m_currentCursorShapeData.images.empty()) {
// fallback to a default if available
constexpr const std::array<const char*, 3> fallbackShapes = {"default", "left_ptr", "left-ptr"};
for (auto const& s : fallbackShapes) {
m_currentCursorShapeData = m_hyprcursor->getShape(s, m_currentStyleInfo);
- if (m_currentCursorShapeData.images.size() > 0)
+ if (!m_currentCursorShapeData.images.empty())
break;
}
- if (m_currentCursorShapeData.images.size() < 1) {
+ if (m_currentCursorShapeData.images.empty()) {
Debug::log(ERR, "BUG THIS: No fallback found for a cursor in setCursorFromName");
return false;
}
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 58951281..976e292d 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -164,7 +164,7 @@ CKeybindManager::CKeybindManager() {
m_repeatKeyTimer = makeShared<CEventLoopTimer>(
std::nullopt,
[this](SP<CEventLoopTimer> self, void* data) {
- if (m_activeKeybinds.size() == 0 || g_pSeatManager->m_keyboard.expired())
+ if (m_activeKeybinds.empty() || g_pSeatManager->m_keyboard.expired())
return;
const auto PACTIVEKEEB = g_pSeatManager->m_keyboard.lock();
@@ -288,7 +288,7 @@ void CKeybindManager::updateXKBTranslationState() {
xkb_rule_names rules = {.rules = RULES.c_str(), .model = MODEL.c_str(), .layout = LAYOUT.c_str(), .variant = VARIANT.c_str(), .options = OPTIONS.c_str()};
const auto PCONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
- FILE* const KEYMAPFILE = FILEPATH == "" ? nullptr : fopen(absolutePath(FILEPATH, g_pConfigManager->m_configCurrentPath).c_str(), "r");
+ FILE* const KEYMAPFILE = FILEPATH.empty() ? nullptr : fopen(absolutePath(FILEPATH, g_pConfigManager->m_configCurrentPath).c_str(), "r");
auto PKEYMAP = KEYMAPFILE ? xkb_keymap_new_from_file(PCONTEXT, KEYMAPFILE, XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS) :
xkb_keymap_new_from_names(PCONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
@@ -630,7 +630,7 @@ eMultiKeyCase CKeybindManager::mkKeysymSetMatches(const std::set<xkb_keysym_t> k
if (boundKeysNotPressed.empty() && pressedKeysNotBound.empty())
return MK_FULL_MATCH;
- if (boundKeysNotPressed.size() && pressedKeysNotBound.empty())
+ if (!boundKeysNotPressed.empty() && pressedKeysNotBound.empty())
return MK_PARTIAL_MATCH;
return MK_NO_MATCH;
@@ -2398,7 +2398,7 @@ SDispatchResult CKeybindManager::toggleSwallow(std::string args) {
}
SDispatchResult CKeybindManager::setSubmap(std::string submap) {
- if (submap == "reset" || submap == "") {
+ if (submap == "reset" || submap.empty()) {
m_currentSelectedSubmap = "";
Debug::log(LOG, "Reset active submap to the default one.");
g_pEventManager->postEvent(SHyprIPCEvent{"submap", ""});
@@ -2576,7 +2576,7 @@ SDispatchResult CKeybindManager::sendshortcut(std::string args) {
//if regexp is not empty, send shortcut to current window
//else, dont change focus
- if (regexp != "") {
+ if (!regexp.empty()) {
PWINDOW = g_pCompositor->getWindowByRegex(regexp);
if (!PWINDOW) {
diff --git a/src/managers/ProtocolManager.cpp b/src/managers/ProtocolManager.cpp
index ab542fc2..942e7954 100644
--- a/src/managers/ProtocolManager.cpp
+++ b/src/managers/ProtocolManager.cpp
@@ -209,7 +209,7 @@ CProtocolManager::CProtocolManager() {
break;
}
- if (g_pHyprOpenGL->getDRMFormats().size() > 0) {
+ if (!g_pHyprOpenGL->getDRMFormats().empty()) {
PROTO::mesaDRM = makeUnique<CMesaDRMProtocol>(&wl_drm_interface, 2, "MesaDRM");
PROTO::linuxDma = makeUnique<CLinuxDMABufV1Protocol>(&zwp_linux_dmabuf_v1_interface, 5, "LinuxDMABUF");
} else
diff --git a/src/managers/SeatManager.cpp b/src/managers/SeatManager.cpp
index a7660854..9fe2b26b 100644
--- a/src/managers/SeatManager.cpp
+++ b/src/managers/SeatManager.cpp
@@ -493,7 +493,7 @@ void CSeatManager::refocusGrab() {
if (!m_seatGrab)
return;
- if (m_seatGrab->m_surfs.size() > 0) {
+ if (!m_seatGrab->m_surfs.empty()) {
// try to find a surf in focus first
const auto MOUSE = g_pInputManager->getMouseCoordsInternal();
for (auto const& s : m_seatGrab->m_surfs) {
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index cc0485d8..70f92023 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -1082,7 +1082,7 @@ void CInputManager::applyConfigToKeyboard(SP<IKeyboard> pKeyboard) {
pKeyboard->m_allowed = PERM == PERMISSION_RULE_ALLOW_MODE_ALLOW;
try {
- if (NUMLOCKON == pKeyboard->m_numlockOn && REPEATDELAY == pKeyboard->m_repeatDelay && REPEATRATE == pKeyboard->m_repeatRate && RULES != "" &&
+ if (NUMLOCKON == pKeyboard->m_numlockOn && REPEATDELAY == pKeyboard->m_repeatDelay && REPEATRATE == pKeyboard->m_repeatRate && !RULES.empty() &&
RULES == pKeyboard->m_currentRules.rules && MODEL == pKeyboard->m_currentRules.model && LAYOUT == pKeyboard->m_currentRules.layout &&
VARIANT == pKeyboard->m_currentRules.variant && OPTIONS == pKeyboard->m_currentRules.options && FILEPATH == pKeyboard->m_xkbFilePath) {
Debug::log(LOG, "Not applying config to keyboard, it did not change.");
@@ -1205,7 +1205,7 @@ void CInputManager::setPointerConfigs() {
libinput_device_config_middle_emulation_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
const auto TAP_MAP = g_pConfigManager->getDeviceString(devname, "tap_button_map", "input:touchpad:tap_button_map");
- if (TAP_MAP == "" || TAP_MAP == "lrm")
+ if (TAP_MAP.empty() || TAP_MAP == "lrm")
libinput_device_config_tap_set_button_map(LIBINPUTDEV, LIBINPUT_CONFIG_TAP_MAP_LRM);
else if (TAP_MAP == "lmr")
libinput_device_config_tap_set_button_map(LIBINPUTDEV, LIBINPUT_CONFIG_TAP_MAP_LMR);
@@ -1214,7 +1214,7 @@ void CInputManager::setPointerConfigs() {
}
const auto SCROLLMETHOD = g_pConfigManager->getDeviceString(devname, "scroll_method", "input:scroll_method");
- if (SCROLLMETHOD == "") {
+ if (SCROLLMETHOD.empty()) {
libinput_device_config_scroll_set_method(LIBINPUTDEV, libinput_device_config_scroll_get_default_method(LIBINPUTDEV));
} else if (SCROLLMETHOD == "no_scroll") {
libinput_device_config_scroll_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_SCROLL_NO_SCROLL);
@@ -1330,7 +1330,7 @@ void CInputManager::destroyKeyboard(SP<IKeyboard> pKeyboard) {
std::erase_if(m_keyboards, [pKeyboard](const auto& other) { return other == pKeyboard; });
- if (m_keyboards.size() > 0) {
+ if (!m_keyboards.empty()) {
bool found = false;
for (auto const& k : m_keyboards | std::views::reverse) {
if (!k)
@@ -1354,7 +1354,7 @@ void CInputManager::destroyPointer(SP<IPointer> mouse) {
std::erase_if(m_pointers, [mouse](const auto& other) { return other == mouse; });
- g_pSeatManager->setMouse(m_pointers.size() > 0 ? m_pointers.front() : nullptr);
+ g_pSeatManager->setMouse(!m_pointers.empty() ? m_pointers.front() : nullptr);
if (!g_pSeatManager->m_mouse.expired())
unconstrainMouse();