internal: refactor to use empty() (#10599)
This commit is contained in:
parent
4078e1d17c
commit
69c2b2926e
20 changed files with 57 additions and 57 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue