From beee22a95ed9044950e5486f22edd813e00ffa2c Mon Sep 17 00:00:00 2001 From: Kamikadze <40305144+Kam1k4dze@users.noreply.github.com> Date: Thu, 14 Aug 2025 19:44:56 +0500 Subject: refactor: Use new hyprutils casts (#11377) --- src/managers/AnimationManager.cpp | 8 ++-- src/managers/AnimationManager.hpp | 2 +- src/managers/CursorManager.cpp | 16 +++---- src/managers/DonationNagManager.cpp | 2 +- src/managers/EventManager.cpp | 4 +- src/managers/HookSystemManager.cpp | 2 +- src/managers/KeybindManager.cpp | 34 +++++++-------- src/managers/LayoutManager.cpp | 6 +-- src/managers/PointerManager.cpp | 19 ++++---- src/managers/TokenManager.cpp | 7 +-- src/managers/XCursorManager.cpp | 12 ++--- src/managers/eventLoop/EventLoopManager.cpp | 8 ++-- src/managers/input/IdleInhibitor.cpp | 4 +- src/managers/input/InputManager.cpp | 51 +++++++++++----------- src/managers/input/InputMethodPopup.cpp | 2 +- src/managers/input/Swipe.cpp | 6 +-- src/managers/input/TextInput.cpp | 2 +- src/managers/input/Touch.cpp | 4 +- .../permissions/DynamicPermissionManager.cpp | 8 ++-- 19 files changed, 98 insertions(+), 99 deletions(-) (limited to 'src/managers') diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index a5ede0e5..aac4a869 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -228,17 +228,17 @@ void CHyprAnimationManager::tick() { switch (PAV->m_Type) { case AVARTYPE_FLOAT: { - auto pTypedAV = dynamic_cast*>(PAV.get()); + auto pTypedAV = dc*>(PAV.get()); RASSERT(pTypedAV, "Failed to upcast animated float"); handleUpdate(*pTypedAV, warp); } break; case AVARTYPE_VECTOR: { - auto pTypedAV = dynamic_cast*>(PAV.get()); + auto pTypedAV = dc*>(PAV.get()); RASSERT(pTypedAV, "Failed to upcast animated Vector2D"); handleUpdate(*pTypedAV, warp); } break; case AVARTYPE_COLOR: { - auto pTypedAV = dynamic_cast*>(PAV.get()); + auto pTypedAV = dc*>(PAV.get()); RASSERT(pTypedAV, "Failed to upcast animated CHyprColor"); handleUpdate(*pTypedAV, warp); } break; @@ -268,7 +268,7 @@ void CHyprAnimationManager::scheduleTick() { const auto TOPRES = std::clamp(refreshDelayMs - SINCEPRES, 1.1f, 1000.f); // we can't send 0, that will disarm it - m_animationTimer->updateTimeout(std::chrono::milliseconds((int)std::floor(TOPRES))); + m_animationTimer->updateTimeout(std::chrono::milliseconds(sc(std::floor(TOPRES)))); } void CHyprAnimationManager::onTicked() { diff --git a/src/managers/AnimationManager.hpp b/src/managers/AnimationManager.hpp index 07e30c90..b5e42036 100644 --- a/src/managers/AnimationManager.hpp +++ b/src/managers/AnimationManager.hpp @@ -22,7 +22,7 @@ class CHyprAnimationManager : public Hyprutils::Animation::CAnimationManager { constexpr const eAnimatedVarType EAVTYPE = typeToeAnimatedVarType; const auto PAV = makeShared>(); - PAV->create(EAVTYPE, static_cast(this), PAV, v); + PAV->create(EAVTYPE, sc(this), PAV, v); PAV->setConfig(pConfig); PAV->m_Context.eDamagePolicy = policy; diff --git a/src/managers/CursorManager.cpp b/src/managers/CursorManager.cpp index 84e2e6d8..442da443 100644 --- a/src/managers/CursorManager.cpp +++ b/src/managers/CursorManager.cpp @@ -7,7 +7,7 @@ #include "../helpers/Monitor.hpp" static int cursorAnimTimer(SP self, void* data) { - const auto cursorMgr = reinterpret_cast(data); + const auto cursorMgr = sc(data); cursorMgr->tickAnimatedCursor(); return 1; } @@ -22,13 +22,13 @@ static void hcLogger(enum eHyprcursorLogLevel level, char* message) { CCursorBuffer::CCursorBuffer(cairo_surface_t* surf, const Vector2D& size_, const Vector2D& hot_) : m_hotspot(hot_), m_stride(cairo_image_surface_get_stride(surf)) { size = size_; - m_data = std::vector((uint8_t*)cairo_image_surface_get_data(surf), ((uint8_t*)cairo_image_surface_get_data(surf)) + (cairo_image_surface_get_height(surf) * m_stride)); + m_data = std::vector(cairo_image_surface_get_data(surf), cairo_image_surface_get_data(surf) + (cairo_image_surface_get_height(surf) * m_stride)); } CCursorBuffer::CCursorBuffer(const uint8_t* pixelData, const Vector2D& size_, const Vector2D& hot_) : m_hotspot(hot_), m_stride(4 * size_.x) { size = size_; - m_data = std::vector(pixelData, pixelData + ((int)size_.y * m_stride)); + m_data = std::vector(pixelData, pixelData + (sc(size_.y) * m_stride)); } Aquamarine::eBufferCapability CCursorBuffer::caps() { @@ -167,7 +167,7 @@ void CCursorManager::setCursorFromName(const std::string& name) { auto xcursor = m_xcursor->getShape(name, m_size, m_cursorScale); auto& icon = xcursor->images.front(); - auto buf = makeShared((uint8_t*)icon.pixels.data(), icon.size, icon.hotspot); + auto buf = makeShared(rc(icon.pixels.data()), icon.size, icon.hotspot); setCursorBuffer(buf, icon.hotspot / scale, scale); m_currentXcursor = xcursor; @@ -233,18 +233,18 @@ void CCursorManager::tickAnimatedCursor() { if (!m_hyprcursor->valid() && m_currentXcursor->images.size() > 1) { m_currentAnimationFrame++; - if ((size_t)m_currentAnimationFrame >= m_currentXcursor->images.size()) + if (sc(m_currentAnimationFrame) >= m_currentXcursor->images.size()) m_currentAnimationFrame = 0; float scale = std::ceil(m_cursorScale); auto& icon = m_currentXcursor->images.at(m_currentAnimationFrame); - auto buf = makeShared((uint8_t*)icon.pixels.data(), icon.size, icon.hotspot); + auto buf = makeShared(rc(icon.pixels.data()), icon.size, icon.hotspot); setCursorBuffer(buf, icon.hotspot / scale, scale); setAnimationTimer(m_currentAnimationFrame, m_currentXcursor->images[m_currentAnimationFrame].delay); } else if (m_currentCursorShapeData.images.size() > 1) { m_currentAnimationFrame++; - if ((size_t)m_currentAnimationFrame >= m_currentCursorShapeData.images.size()) + if (sc(m_currentAnimationFrame) >= m_currentCursorShapeData.images.size()) m_currentAnimationFrame = 0; auto hotspot = @@ -281,7 +281,7 @@ void CCursorManager::setXWaylandCursor() { auto xcursor = m_xcursor->getShape("left_ptr", m_size, 1); auto& icon = xcursor->images.front(); - g_pXWayland->setCursor((uint8_t*)icon.pixels.data(), icon.size.x * 4, icon.size, icon.hotspot); + g_pXWayland->setCursor(rc(icon.pixels.data()), icon.size.x * 4, icon.size, icon.hotspot); } } diff --git a/src/managers/DonationNagManager.cpp b/src/managers/DonationNagManager.cpp index 249fbdcf..826439b2 100644 --- a/src/managers/DonationNagManager.cpp +++ b/src/managers/DonationNagManager.cpp @@ -69,7 +69,7 @@ CDonationNagManager::CDonationNagManager() { // don't nag if the last nag was less than a month ago. This is // mostly for first-time nags, as other nags happen in specific time frames shorter than a month if (EPOCH - state.epoch < MONTH_IN_SECONDS) { - Debug::log(LOG, "DonationNag: last nag was {} days ago, too early for a nag.", (int)std::round((EPOCH - state.epoch) / (double)DAY_IN_SECONDS)); + Debug::log(LOG, "DonationNag: last nag was {} days ago, too early for a nag.", sc(std::round((EPOCH - state.epoch) / sc(DAY_IN_SECONDS)))); return; } diff --git a/src/managers/EventManager.cpp b/src/managers/EventManager.cpp index e0d8704b..c4c6c5d7 100644 --- a/src/managers/EventManager.cpp +++ b/src/managers/EventManager.cpp @@ -26,7 +26,7 @@ CEventManager::CEventManager() : m_socketFD(socket(AF_UNIX, SOCK_STREAM | SOCK_C strncpy(SERVERADDRESS.sun_path, PATH.c_str(), sizeof(SERVERADDRESS.sun_path) - 1); - if (bind(m_socketFD.get(), (sockaddr*)&SERVERADDRESS, SUN_LEN(&SERVERADDRESS)) < 0) { + if (bind(m_socketFD.get(), rc(&SERVERADDRESS), SUN_LEN(&SERVERADDRESS)) < 0) { Debug::log(ERR, "Couldn't bind the Hyprland Socket 2. (3) IPC will not work."); return; } @@ -70,7 +70,7 @@ int CEventManager::onServerEvent(int fd, uint32_t mask) { sockaddr_in clientAddress; socklen_t clientSize = sizeof(clientAddress); - CFileDescriptor ACCEPTEDCONNECTION{accept4(m_socketFD.get(), (sockaddr*)&clientAddress, &clientSize, SOCK_CLOEXEC | SOCK_NONBLOCK)}; + CFileDescriptor ACCEPTEDCONNECTION{accept4(m_socketFD.get(), rc(&clientAddress), &clientSize, SOCK_CLOEXEC | SOCK_NONBLOCK)}; if (!ACCEPTEDCONNECTION.isValid()) { if (errno != EAGAIN) { Debug::log(ERR, "Socket2 failed receiving connection, errno: {}", errno); diff --git a/src/managers/HookSystemManager.cpp b/src/managers/HookSystemManager.cpp index 2f1f3a27..a5623f08 100644 --- a/src/managers/HookSystemManager.cpp +++ b/src/managers/HookSystemManager.cpp @@ -62,7 +62,7 @@ void CHookSystemManager::emit(std::vector* const callbacks, SCal } catch (std::exception& e) { // TODO: this works only once...? faultyHandles.push_back(cb.handle); - Debug::log(ERR, "[hookSystem] Hook from plugin {:x} caused a SIGSEGV, queueing for unloading.", (uintptr_t)cb.handle); + Debug::log(ERR, "[hookSystem] Hook from plugin {:x} caused a SIGSEGV, queueing for unloading.", rc(cb.handle)); } } diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 64180e28..bb1222ad 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -779,7 +779,7 @@ SDispatchResult CKeybindManager::handleKeybinds(const uint32_t modmask, const SP // call the dispatcher Debug::log(LOG, "Keybind triggered, calling dispatcher ({}, {}, {}, {})", modmask, key.keyName, key.keysym, DISPATCHER->first); - m_passPressed = (int)pressed; + m_passPressed = sc(pressed); // if the dispatchers says to pass event then we will if (k->handler == "mouse") @@ -942,7 +942,7 @@ uint64_t CKeybindManager::spawnWithRules(std::string args, PHLWORKSPACE pInitial const auto RULESLIST = CVarList(RULES, 0, ';'); for (auto const& r : RULESLIST) { - g_pConfigManager->addExecRule({r, (unsigned long)PROC}); + g_pConfigManager->addExecRule({r, sc(PROC)}); } Debug::log(LOG, "Applied {} rule arguments for exec.", RULESLIST.size()); @@ -1374,8 +1374,8 @@ SDispatchResult CKeybindManager::fullscreenStateActive(std::string args) { clientMode = std::stoi(ARGS[1]); } catch (std::exception& e) { clientMode = -1; } - const SFullscreenState STATE = SFullscreenState{.internal = (internalMode != -1 ? (eFullscreenMode)internalMode : PWINDOW->m_fullscreenState.internal), - .client = (clientMode != -1 ? (eFullscreenMode)clientMode : PWINDOW->m_fullscreenState.client)}; + const SFullscreenState STATE = SFullscreenState{.internal = (internalMode != -1 ? sc(internalMode) : PWINDOW->m_fullscreenState.internal), + .client = (clientMode != -1 ? sc(clientMode) : PWINDOW->m_fullscreenState.client)}; if (internalMode != -1 && clientMode != -1 && PWINDOW->m_fullscreenState.internal == STATE.internal && PWINDOW->m_fullscreenState.client == STATE.client) g_pCompositor->setWindowFullscreenState(PWINDOW, SFullscreenState{.internal = FSMODE_NONE, .client = FSMODE_NONE}); @@ -1685,9 +1685,9 @@ SDispatchResult CKeybindManager::moveActiveTo(std::string args) { const auto BORDERSIZE = PLASTWINDOW->getRealBorderSize(); static auto PGAPSCUSTOMDATA = CConfigValue("general:float_gaps"); static auto PGAPSOUTDATA = CConfigValue("general:gaps_out"); - auto* PGAPSOUT = (CCssGapData*)PGAPSCUSTOMDATA.ptr()->getData(); + auto* PGAPSOUT = sc(PGAPSCUSTOMDATA.ptr()->getData()); if (PGAPSOUT->m_left < 0 || PGAPSOUT->m_right < 0 || PGAPSOUT->m_top < 0 || PGAPSOUT->m_bottom < 0) - PGAPSOUT = (CCssGapData*)PGAPSOUTDATA.ptr()->getData(); + PGAPSOUT = sc(PGAPSOUTDATA.ptr()->getData()); switch (arg) { case 'l': vPosx = PMONITOR->m_reservedTopLeft.x + BORDERSIZE + PMONITOR->m_position.x + PGAPSOUT->m_left; break; @@ -2545,7 +2545,7 @@ SDispatchResult CKeybindManager::sendshortcut(std::string args) { return {.success = false, .error = "sendshortcut: no kb"}; } - const auto KEYPAIRSTRING = std::format("{}{}", (uintptr_t)KB.get(), KEY); + const auto KEYPAIRSTRING = std::format("{}{}", rc(KB.get()), KEY); if (!g_pKeybindManager->m_keyToCodeCache.contains(KEYPAIRSTRING)) { xkb_keymap* km = KB->m_xkbKeymap; @@ -2790,7 +2790,7 @@ SDispatchResult CKeybindManager::pinActive(std::string args) { PWORKSPACE->m_lastFocusedWindow = g_pCompositor->vectorToWindowUnified(g_pInputManager->getMouseCoordsInternal(), RESERVED_EXTENTS | INPUT_EXTENTS); - g_pEventManager->postEvent(SHyprIPCEvent{"pin", std::format("{:x},{}", (uintptr_t)PWINDOW.get(), (int)PWINDOW->m_pinned)}); + g_pEventManager->postEvent(SHyprIPCEvent{"pin", std::format("{:x},{}", rc(PWINDOW.get()), sc(PWINDOW->m_pinned))}); EMIT_HOOK_EVENT("pin", PWINDOW); return {}; @@ -2941,7 +2941,7 @@ void CKeybindManager::moveWindowIntoGroup(PHLWINDOW pWindow, PHLWINDOW pWindowIn g_pCompositor->focusWindow(pWindow); pWindow->warpCursor(); - g_pEventManager->postEvent(SHyprIPCEvent{"moveintogroup", std::format("{:x}", (uintptr_t)pWindow.get())}); + g_pEventManager->postEvent(SHyprIPCEvent{"moveintogroup", std::format("{:x}", rc(pWindow.get()))}); } void CKeybindManager::moveWindowOutOfGroup(PHLWINDOW pWindow, const std::string& dir) { @@ -2982,7 +2982,7 @@ void CKeybindManager::moveWindowOutOfGroup(PHLWINDOW pWindow, const std::string& PWINDOWPREV->warpCursor(); } - g_pEventManager->postEvent(SHyprIPCEvent{"moveoutofgroup", std::format("{:x}", (uintptr_t)pWindow.get())}); + g_pEventManager->postEvent(SHyprIPCEvent{"moveoutofgroup", std::format("{:x}", rc(pWindow.get()))}); } SDispatchResult CKeybindManager::moveIntoGroup(std::string args) { @@ -3097,7 +3097,7 @@ SDispatchResult CKeybindManager::moveWindowOrGroup(std::string args) { } SDispatchResult CKeybindManager::setIgnoreGroupLock(std::string args) { - static auto PIGNOREGROUPLOCK = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("binds:ignore_group_lock"); + static auto PIGNOREGROUPLOCK = rc(g_pConfigManager->getConfigValuePtr("binds:ignore_group_lock")); if (args == "toggle") **PIGNOREGROUPLOCK = !**PIGNOREGROUPLOCK; @@ -3207,17 +3207,17 @@ SDispatchResult CKeybindManager::setProp(std::string args) { CWindowOverridableVar(SAlphaValue{std::stof(VAL), PWINDOW->m_windowData.alphaFullscreen.valueOrDefault().overridden}, PRIORITY_SET_PROP); } else if (PROP == "alphaoverride") { PWINDOW->m_windowData.alpha = - CWindowOverridableVar(SAlphaValue{PWINDOW->m_windowData.alpha.valueOrDefault().alpha, (bool)configStringToInt(VAL).value_or(0)}, PRIORITY_SET_PROP); + CWindowOverridableVar(SAlphaValue{PWINDOW->m_windowData.alpha.valueOrDefault().alpha, sc(configStringToInt(VAL).value_or(0))}, PRIORITY_SET_PROP); } else if (PROP == "alphainactiveoverride") { PWINDOW->m_windowData.alphaInactive = - CWindowOverridableVar(SAlphaValue{PWINDOW->m_windowData.alphaInactive.valueOrDefault().alpha, (bool)configStringToInt(VAL).value_or(0)}, PRIORITY_SET_PROP); + CWindowOverridableVar(SAlphaValue{PWINDOW->m_windowData.alphaInactive.valueOrDefault().alpha, sc(configStringToInt(VAL).value_or(0))}, PRIORITY_SET_PROP); } else if (PROP == "alphafullscreenoverride") { PWINDOW->m_windowData.alphaFullscreen = - CWindowOverridableVar(SAlphaValue{PWINDOW->m_windowData.alphaFullscreen.valueOrDefault().alpha, (bool)configStringToInt(VAL).value_or(0)}, PRIORITY_SET_PROP); + CWindowOverridableVar(SAlphaValue{PWINDOW->m_windowData.alphaFullscreen.valueOrDefault().alpha, sc(configStringToInt(VAL).value_or(0))}, PRIORITY_SET_PROP); } else if (PROP == "activebordercolor" || PROP == "inactivebordercolor") { CGradientValueData colorData = {}; if (vars.size() > 4) { - for (int i = 3; i < static_cast(vars.size()); ++i) { + for (int i = 3; i < sc(vars.size()); ++i) { const auto TOKEN = vars[i]; if (TOKEN.ends_with("deg")) colorData.m_angle = std::stoi(TOKEN.substr(0, TOKEN.size() - 3)) * (PI / 180.0); @@ -3246,7 +3246,7 @@ SDispatchResult CKeybindManager::setProp(std::string args) { else if (VAL == "unset") pWindowDataElement->unset(PRIORITY_SET_PROP); else - *pWindowDataElement = CWindowOverridableVar((bool)configStringToInt(VAL).value_or(0), PRIORITY_SET_PROP); + *pWindowDataElement = CWindowOverridableVar(sc(configStringToInt(VAL).value_or(0)), PRIORITY_SET_PROP); } else if (auto search = NWindowProperties::intWindowProperties.find(PROP); search != NWindowProperties::intWindowProperties.end()) { if (VAL == "unset") search->second(PWINDOW)->unset(PRIORITY_SET_PROP); @@ -3254,7 +3254,7 @@ SDispatchResult CKeybindManager::setProp(std::string args) { const Hyprlang::INT V = std::stoi(VAL.substr(VAL.find(' '))); search->second(PWINDOW)->increment(V, PRIORITY_SET_PROP); } else if (const auto V = configStringToInt(VAL); V) - *(search->second(PWINDOW)) = CWindowOverridableVar((Hyprlang::INT)*V, PRIORITY_SET_PROP); + *(search->second(PWINDOW)) = CWindowOverridableVar(*V, PRIORITY_SET_PROP); } else if (auto search = NWindowProperties::floatWindowProperties.find(PROP); search != NWindowProperties::floatWindowProperties.end()) { if (VAL == "unset") search->second(PWINDOW)->unset(PRIORITY_SET_PROP); diff --git a/src/managers/LayoutManager.cpp b/src/managers/LayoutManager.cpp index 08bbcf44..449d1700 100644 --- a/src/managers/LayoutManager.cpp +++ b/src/managers/LayoutManager.cpp @@ -12,7 +12,7 @@ IHyprLayout* CLayoutManager::getCurrentLayout() { void CLayoutManager::switchToLayout(std::string layout) { for (size_t i = 0; i < m_layouts.size(); ++i) { if (m_layouts[i].first == layout) { - if (i == (size_t)m_currentLayoutID) + if (i == sc(m_currentLayoutID)) return; getCurrentLayout()->onDisable(); @@ -31,7 +31,7 @@ bool CLayoutManager::addLayout(const std::string& name, IHyprLayout* layout) { m_layouts.emplace_back(std::make_pair<>(name, layout)); - Debug::log(LOG, "Added new layout {} at {:x}", name, (uintptr_t)layout); + Debug::log(LOG, "Added new layout {} at {:x}", name, rc(layout)); return true; } @@ -45,7 +45,7 @@ bool CLayoutManager::removeLayout(IHyprLayout* layout) { if (m_currentLayoutID == IT - m_layouts.begin()) switchToLayout("dwindle"); - Debug::log(LOG, "Removed a layout {} at {:x}", IT->first, (uintptr_t)layout); + Debug::log(LOG, "Removed a layout {} at {:x}", IT->first, rc(layout)); std::erase(m_layouts, *IT); diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp index 34bf0976..318ec343 100644 --- a/src/managers/PointerManager.cpp +++ b/src/managers/PointerManager.cpp @@ -502,9 +502,8 @@ SP CPointerManager::renderHWCursorBuffer(SPdmabuf(); auto [data, fmt, size] = buf->beginDataPtr(0); - auto CAIROSURFACE = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, DMABUF.size.x, DMABUF.size.y); - auto CAIRODATASURFACE = - cairo_image_surface_create_for_data((unsigned char*)texData.data(), CAIRO_FORMAT_ARGB32, texture->m_size.x, texture->m_size.y, texture->m_size.x * 4); + auto CAIROSURFACE = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, DMABUF.size.x, DMABUF.size.y); + auto CAIRODATASURFACE = cairo_image_surface_create_for_data(texData.data(), CAIRO_FORMAT_ARGB32, texture->m_size.x, texture->m_size.y, texture->m_size.x * 4); auto CAIRO = cairo_create(CAIROSURFACE); @@ -525,7 +524,7 @@ SP CPointerManager::renderHWCursorBuffer(SP(TR)); // FIXME: this is wrong, and doesn't work for 5, 6 and 7. (flipped + rot) // cba to do it rn, does anyone fucking use that?? @@ -550,7 +549,7 @@ SP CPointerManager::renderHWCursorBuffer(SP(cairo_image_surface_get_height(CAIROSURFACE)) * cairo_image_surface_get_stride(CAIROSURFACE)); cairo_destroy(CAIRO); cairo_surface_destroy(CAIROSURFACE); @@ -664,7 +663,7 @@ CBox CPointerManager::getCursorBoxGlobal() { Vector2D CPointerManager::closestValid(const Vector2D& pos) { static auto PADDING = CConfigValue("cursor:hotspot_padding"); - auto CURSOR_PADDING = std::clamp((int)*PADDING, 0, 100); + auto CURSOR_PADDING = std::clamp(sc(*PADDING), 0, 100); CBox hotBox = {{pos.x - CURSOR_PADDING, pos.y - CURSOR_PADDING}, {2 * CURSOR_PADDING, 2 * CURSOR_PADDING}}; // @@ -809,7 +808,7 @@ void CPointerManager::warpAbsolute(Vector2D abs, SP dev) { switch (dev->getType()) { case HID_TYPE_TABLET: { - CTablet* TAB = reinterpret_cast(dev.get()); + CTablet* TAB = rc(dev.get()); if (!TAB->m_boundOutput.empty()) { mappedArea = outputMappedArea(TAB->m_boundOutput); mappedArea.translate(TAB->m_boundBox.pos()); @@ -826,13 +825,13 @@ void CPointerManager::warpAbsolute(Vector2D abs, SP dev) { break; } case HID_TYPE_TOUCH: { - ITouch* TOUCH = reinterpret_cast(dev.get()); + ITouch* TOUCH = rc(dev.get()); if (!TOUCH->m_boundOutput.empty()) mappedArea = outputMappedArea(TOUCH->m_boundOutput); break; } case HID_TYPE_POINTER: { - IPointer* POINTER = reinterpret_cast(dev.get()); + IPointer* POINTER = rc(dev.get()); if (!POINTER->m_boundOutput.empty()) mappedArea = outputMappedArea(POINTER->m_boundOutput); break; @@ -1118,7 +1117,7 @@ void CPointerManager::setStoredMovement(uint64_t time, const Vector2D& delta, co } void CPointerManager::sendStoredMovement() { - PROTO::relativePointer->sendRelativeMotion((uint64_t)m_storedTime * 1000, m_storedDelta, m_storedUnaccel); + PROTO::relativePointer->sendRelativeMotion(m_storedTime * 1000, m_storedDelta, m_storedUnaccel); m_storedTime = 0; m_storedDelta = Vector2D{}; m_storedUnaccel = Vector2D{}; diff --git a/src/managers/TokenManager.cpp b/src/managers/TokenManager.cpp index 141ea65e..694830db 100644 --- a/src/managers/TokenManager.cpp +++ b/src/managers/TokenManager.cpp @@ -15,9 +15,10 @@ std::string CTokenManager::getRandomUUID() { do { uuid_t uuid_; uuid_generate_random(uuid_); - uuid = std::format("{:02x}{:02x}{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}", (uint16_t)uuid_[0], (uint16_t)uuid_[1], - (uint16_t)uuid_[2], (uint16_t)uuid_[3], (uint16_t)uuid_[4], (uint16_t)uuid_[5], (uint16_t)uuid_[6], (uint16_t)uuid_[7], (uint16_t)uuid_[8], - (uint16_t)uuid_[9], (uint16_t)uuid_[10], (uint16_t)uuid_[11], (uint16_t)uuid_[12], (uint16_t)uuid_[13], (uint16_t)uuid_[14], (uint16_t)uuid_[15]); + uuid = std::format("{:02x}{:02x}{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}", sc(uuid_[0]), sc(uuid_[1]), + sc(uuid_[2]), sc(uuid_[3]), sc(uuid_[4]), sc(uuid_[5]), sc(uuid_[6]), sc(uuid_[7]), + sc(uuid_[8]), sc(uuid_[9]), sc(uuid_[10]), sc(uuid_[11]), sc(uuid_[12]), sc(uuid_[13]), + sc(uuid_[14]), sc(uuid_[15])); } while (m_tokens.contains(uuid)); return uuid; diff --git a/src/managers/XCursorManager.cpp b/src/managers/XCursorManager.cpp index 626c4250..307cbc84 100644 --- a/src/managers/XCursorManager.cpp +++ b/src/managers/XCursorManager.cpp @@ -185,15 +185,15 @@ SP CXCursorManager::getShape(std::string const& shape, int size, floa SP CXCursorManager::createCursor(std::string const& shape, void* ximages) { auto xcursor = makeShared(); - XcursorImages* xImages = (XcursorImages*)ximages; + XcursorImages* xImages = sc(ximages); for (int i = 0; i < xImages->nimage; i++) { auto xImage = xImages->images[i]; SXCursorImage image; - image.size = {(int)xImage->width, (int)xImage->height}; - image.hotspot = {(int)xImage->xhot, (int)xImage->yhot}; - image.pixels.resize((size_t)xImage->width * xImage->height); - std::memcpy(image.pixels.data(), xImage->pixels, (size_t)xImage->width * xImage->height * sizeof(uint32_t)); + image.size = {sc(xImage->width), sc(xImage->height)}; + image.hotspot = {sc(xImage->xhot), sc(xImage->yhot)}; + image.pixels.resize(sc(xImage->width) * xImage->height); + std::memcpy(image.pixels.data(), xImage->pixels, sc(xImage->width) * xImage->height * sizeof(uint32_t)); image.delay = xImage->delay; xcursor->images.emplace_back(image); @@ -530,7 +530,7 @@ std::vector> CXCursorManager::loadAllFromDir(std::string const& pa auto const& full = entry.path().string(); using PcloseType = int (*)(FILE*); - const std::unique_ptr f(fopen(full.c_str(), "r"), static_cast(fclose)); + const std::unique_ptr f(fopen(full.c_str(), "r"), fclose); if (!f) continue; diff --git a/src/managers/eventLoop/EventLoopManager.cpp b/src/managers/eventLoop/EventLoopManager.cpp index b9ac7242..3297d31e 100644 --- a/src/managers/eventLoop/EventLoopManager.cpp +++ b/src/managers/eventLoop/EventLoopManager.cpp @@ -45,7 +45,7 @@ static int timerWrite(int fd, uint32_t mask, void* data) { } static int aquamarineFDWrite(int fd, uint32_t mask, void* data) { - auto POLLFD = (Aquamarine::SPollFD*)data; + auto POLLFD = sc(data); POLLFD->onSignal(); return 1; } @@ -62,7 +62,7 @@ static int handleWaiterFD(int fd, uint32_t mask, void* data) { } if (mask & WL_EVENT_READABLE) - g_pEventLoopManager->onFdReadable((CEventLoopManager::SReadableWaiter*)data); + g_pEventLoopManager->onFdReadable(sc(data)); return 0; } @@ -129,7 +129,7 @@ static void timespecAddNs(timespec* pTimespec, int64_t delta) { pTimespec->tv_sec += delta_s_high; - pTimespec->tv_nsec += (long)delta_ns_low; + pTimespec->tv_nsec += delta_ns_low; if (pTimespec->tv_nsec >= TIMESPEC_NSEC_PER_SEC) { pTimespec->tv_nsec -= TIMESPEC_NSEC_PER_SEC; ++pTimespec->tv_sec; @@ -181,7 +181,7 @@ void CEventLoopManager::doLater(const std::function& fn) { m_idle.eventSource = wl_event_loop_add_idle( m_wayland.loop, [](void* data) { - auto IDLE = (CEventLoopManager::SIdleData*)data; + auto IDLE = sc(data); auto cpy = IDLE->fns; IDLE->fns.clear(); IDLE->eventSource = nullptr; diff --git a/src/managers/input/IdleInhibitor.cpp b/src/managers/input/IdleInhibitor.cpp index 8c33956b..82f43f47 100644 --- a/src/managers/input/IdleInhibitor.cpp +++ b/src/managers/input/IdleInhibitor.cpp @@ -8,7 +8,7 @@ void CInputManager::newIdleInhibitor(std::any inhibitor) { const auto PINHIBIT = m_idleInhibitors.emplace_back(makeUnique()).get(); PINHIBIT->inhibitor = std::any_cast>(inhibitor); - Debug::log(LOG, "New idle inhibitor registered for surface {:x}", (uintptr_t)PINHIBIT->inhibitor->m_surface.get()); + Debug::log(LOG, "New idle inhibitor registered for surface {:x}", rc(PINHIBIT->inhibitor->m_surface.get())); PINHIBIT->inhibitor->m_listeners.destroy = PINHIBIT->inhibitor->m_resource->m_events.destroy.listen([this, PINHIBIT] { std::erase_if(m_idleInhibitors, [PINHIBIT](const auto& other) { return other.get() == PINHIBIT; }); @@ -89,7 +89,7 @@ bool CInputManager::isWindowInhibiting(const PHLWINDOW& w, bool onlyHl) { return; if (WLSurface->visible()) - *(bool*)data = true; + *sc(data) = true; }, &isInhibiting); diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index cbb4c3cc..f8d2a160 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -54,7 +54,7 @@ CInputManager::CInputManager() { if (wl_resource_get_client(event.pMgr->resource()) != g_pSeatManager->m_state.pointerFocusResource->client()) return; - Debug::log(LOG, "cursorImage request: shape {} -> {}", (uint32_t)event.shape, event.shapeName); + Debug::log(LOG, "cursorImage request: shape {} -> {}", sc(event.shape), event.shapeName); m_cursorSurfaceInfo.wlSurface->unassign(); m_cursorSurfaceInfo.vHotspot = {}; @@ -113,11 +113,11 @@ void CInputManager::onMouseMoved(IPointer::SMotionEvent e) { const auto DELTA = *PNOACCEL == 1 ? unaccel : delta; if (g_pSeatManager->m_isPointerFrameSkipped) - g_pPointerManager->storeMovement((uint64_t)e.timeMs, DELTA, unaccel); + g_pPointerManager->storeMovement(e.timeMs, DELTA, unaccel); else - g_pPointerManager->setStoredMovement((uint64_t)e.timeMs, DELTA, unaccel); + g_pPointerManager->setStoredMovement(e.timeMs, DELTA, unaccel); - PROTO::relativePointer->sendRelativeMotion((uint64_t)e.timeMs * 1000, DELTA, unaccel); + PROTO::relativePointer->sendRelativeMotion(sc(e.timeMs) * 1000, DELTA, unaccel); if (e.mouse) recheckMouseWarpOnMouseInput(); @@ -236,13 +236,13 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) { g_pCompositor->warpCursorTo(CLOSEST, true); g_pSeatManager->sendPointerMotion(time, CLOSESTLOCAL); - PROTO::relativePointer->sendRelativeMotion((uint64_t)time * 1000, {}, {}); + PROTO::relativePointer->sendRelativeMotion(sc(time) * 1000, {}, {}); } return; } else - Debug::log(ERR, "BUG THIS: Null SURF/CONSTRAINT in mouse refocus. Ignoring constraints. {:x} {:x}", (uintptr_t)SURF.get(), (uintptr_t)CONSTRAINT.get()); + Debug::log(ERR, "BUG THIS: Null SURF/CONSTRAINT in mouse refocus. Ignoring constraints. {:x} {:x}", rc(SURF.get()), rc(CONSTRAINT.get())); } if (PMONITOR != g_pCompositor->m_lastMonitor && (*PMOUSEFOCUSMON || refocus) && m_forcedFocus.expired()) @@ -644,7 +644,7 @@ void CInputManager::processMouseRequest(const CSeatManager::SSetCursorEvent& eve if (!cursorImageUnlocked()) return; - Debug::log(LOG, "cursorImage request: surface {:x}", (uintptr_t)event.surf.get()); + Debug::log(LOG, "cursorImage request: surface {:x}", rc(event.surf.get())); if (event.surf != m_cursorSurfaceInfo.wlSurface->resource()) { m_cursorSurfaceInfo.wlSurface->unassign(); @@ -937,7 +937,7 @@ void CInputManager::newKeyboard(SP keeb) { setupKeyboard(PNEWKEYBOARD); - Debug::log(LOG, "New keyboard created, pointers Hypr: {:x}", (uintptr_t)PNEWKEYBOARD.get()); + Debug::log(LOG, "New keyboard created, pointers Hypr: {:x}", rc(PNEWKEYBOARD.get())); } void CInputManager::newKeyboard(SP keyboard) { @@ -945,7 +945,7 @@ void CInputManager::newKeyboard(SP keyboard) { setupKeyboard(PNEWKEYBOARD); - Debug::log(LOG, "New keyboard created, pointers Hypr: {:x} and AQ: {:x}", (uintptr_t)PNEWKEYBOARD.get(), (uintptr_t)keyboard.get()); + Debug::log(LOG, "New keyboard created, pointers Hypr: {:x} and AQ: {:x}", rc(PNEWKEYBOARD.get()), rc(keyboard.get())); } void CInputManager::newVirtualKeyboard(SP keyboard) { @@ -953,7 +953,7 @@ void CInputManager::newVirtualKeyboard(SP keyboard) setupKeyboard(PNEWKEYBOARD); - Debug::log(LOG, "New virtual keyboard created at {:x}", (uintptr_t)PNEWKEYBOARD.get()); + Debug::log(LOG, "New virtual keyboard created at {:x}", rc(PNEWKEYBOARD.get())); } void CInputManager::setupKeyboard(SP keeb) { @@ -974,7 +974,7 @@ void CInputManager::setupKeyboard(SP keeb) { return; destroyKeyboard(PKEEB); - Debug::log(LOG, "Destroyed keyboard {:x}", (uintptr_t)keeb); + Debug::log(LOG, "Destroyed keyboard {:x}", rc(keeb)); }); keeb->m_keyboardEvents.key.listenStatic([this, keeb = keeb.get()](const IKeyboard::SKeyEvent& event) { @@ -1035,7 +1035,7 @@ void CInputManager::applyConfigToKeyboard(SP pKeyboard) { const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname); - Debug::log(LOG, "ApplyConfigToKeyboard for \"{}\", hasconfig: {}", devname, (int)HASCONFIG); + Debug::log(LOG, "ApplyConfigToKeyboard for \"{}\", hasconfig: {}", devname, sc(HASCONFIG)); const auto REPEATRATE = g_pConfigManager->getDeviceInt(devname, "repeat_rate", "input:repeat_rate"); const auto REPEATDELAY = g_pConfigManager->getDeviceInt(devname, "repeat_delay", "input:repeat_delay"); @@ -1119,7 +1119,7 @@ void CInputManager::newMouse(SP mouse) { setupMouse(PMOUSE); - Debug::log(LOG, "New mouse created, pointer AQ: {:x}", (uintptr_t)mouse.get()); + Debug::log(LOG, "New mouse created, pointer AQ: {:x}", rc(mouse.get())); } void CInputManager::setupMouse(SP mauz) { @@ -1135,8 +1135,8 @@ void CInputManager::setupMouse(SP mauz) { const auto LIBINPUTDEV = mauz->aq()->getLibinputHandle(); Debug::log(LOG, "New mouse has libinput sens {:.2f} ({:.2f}) with accel profile {} ({})", libinput_device_config_accel_get_speed(LIBINPUTDEV), - libinput_device_config_accel_get_default_speed(LIBINPUTDEV), (int)libinput_device_config_accel_get_profile(LIBINPUTDEV), - (int)libinput_device_config_accel_get_default_profile(LIBINPUTDEV)); + libinput_device_config_accel_get_default_speed(LIBINPUTDEV), sc(libinput_device_config_accel_get_profile(LIBINPUTDEV)), + sc(libinput_device_config_accel_get_default_profile(LIBINPUTDEV))); } g_pPointerManager->attachPointer(mauz); @@ -1223,7 +1223,7 @@ void CInputManager::setPointerConfigs() { const auto TAP_DRAG_LOCK = g_pConfigManager->getDeviceInt(devname, "drag_lock", "input:touchpad:drag_lock"); if (TAP_DRAG_LOCK >= 0 && TAP_DRAG_LOCK <= 2) { - libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, static_cast(TAP_DRAG_LOCK)); + libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, sc(TAP_DRAG_LOCK)); } if (libinput_device_config_tap_get_finger_count(LIBINPUTDEV)) // this is for tapping (like on a laptop) @@ -1241,13 +1241,12 @@ void CInputManager::setPointerConfigs() { } if (libinput_device_config_3fg_drag_get_finger_count(LIBINPUTDEV) >= 3) { - const auto DRAG_3FG_STATE = static_cast(g_pConfigManager->getDeviceInt(devname, "drag_3fg", "input:touchpad:drag_3fg")); + const auto DRAG_3FG_STATE = sc(g_pConfigManager->getDeviceInt(devname, "drag_3fg", "input:touchpad:drag_3fg")); libinput_device_config_3fg_drag_set_enabled(LIBINPUTDEV, DRAG_3FG_STATE); } if (libinput_device_config_dwt_is_available(LIBINPUTDEV)) { - const auto DWT = - static_cast(g_pConfigManager->getDeviceInt(devname, "disable_while_typing", "input:touchpad:disable_while_typing") != 0); + const auto DWT = sc(g_pConfigManager->getDeviceInt(devname, "disable_while_typing", "input:touchpad:disable_while_typing") != 0); libinput_device_config_dwt_set_enabled(LIBINPUTDEV, DWT); } @@ -1319,7 +1318,7 @@ static void removeFromHIDs(WP hid) { } void CInputManager::destroyKeyboard(SP pKeyboard) { - Debug::log(LOG, "Keyboard at {:x} removed", (uintptr_t)pKeyboard.get()); + Debug::log(LOG, "Keyboard at {:x} removed", rc(pKeyboard.get())); std::erase_if(m_keyboards, [pKeyboard](const auto& other) { return other == pKeyboard; }); @@ -1343,7 +1342,7 @@ void CInputManager::destroyKeyboard(SP pKeyboard) { } void CInputManager::destroyPointer(SP mouse) { - Debug::log(LOG, "Pointer at {:x} removed", (uintptr_t)mouse.get()); + Debug::log(LOG, "Pointer at {:x} removed", rc(mouse.get())); std::erase_if(m_pointers, [mouse](const auto& other) { return other == mouse; }); @@ -1356,7 +1355,7 @@ void CInputManager::destroyPointer(SP mouse) { } void CInputManager::destroyTouchDevice(SP touch) { - Debug::log(LOG, "Touch device at {:x} removed", (uintptr_t)touch.get()); + Debug::log(LOG, "Touch device at {:x} removed", rc(touch.get())); std::erase_if(m_touches, [touch](const auto& other) { return other == touch; }); @@ -1364,7 +1363,7 @@ void CInputManager::destroyTouchDevice(SP touch) { } void CInputManager::destroyTablet(SP tablet) { - Debug::log(LOG, "Tablet device at {:x} removed", (uintptr_t)tablet.get()); + Debug::log(LOG, "Tablet device at {:x} removed", rc(tablet.get())); std::erase_if(m_tablets, [tablet](const auto& other) { return other == tablet; }); @@ -1372,7 +1371,7 @@ void CInputManager::destroyTablet(SP tablet) { } void CInputManager::destroyTabletTool(SP tool) { - Debug::log(LOG, "Tablet tool at {:x} removed", (uintptr_t)tool.get()); + Debug::log(LOG, "Tablet tool at {:x} removed", rc(tool.get())); std::erase_if(m_tabletTools, [tool](const auto& other) { return other == tool; }); @@ -1380,7 +1379,7 @@ void CInputManager::destroyTabletTool(SP tool) { } void CInputManager::destroyTabletPad(SP pad) { - Debug::log(LOG, "Tablet pad at {:x} removed", (uintptr_t)pad.get()); + Debug::log(LOG, "Tablet pad at {:x} removed", rc(pad.get())); std::erase_if(m_tabletPads, [pad](const auto& other) { return other == pad; }); @@ -1674,7 +1673,7 @@ void CInputManager::newTouchDevice(SP pDevice) { destroyTouchDevice(PDEV); }); - Debug::log(LOG, "New touch device added at {:x}", (uintptr_t)PNEWDEV.get()); + Debug::log(LOG, "New touch device added at {:x}", rc(PNEWDEV.get())); } void CInputManager::setTouchDeviceConfigs(SP dev) { diff --git a/src/managers/input/InputMethodPopup.cpp b/src/managers/input/InputMethodPopup.cpp index 71fdd5a4..27acd08c 100644 --- a/src/managers/input/InputMethodPopup.cpp +++ b/src/managers/input/InputMethodPopup.cpp @@ -99,7 +99,7 @@ void CInputPopup::updateBox() { if (!cursorRect) { Vector2D coords = OWNER ? OWNER->getSurfaceBoxGlobal().value_or(CBox{0, 0, 500, 500}).pos() : Vector2D{0, 0}; parentBox = {coords, {500, 500}}; - cursorBoxParent = {0, 0, (int)parentBox.w, (int)parentBox.h}; + cursorBoxParent = {0, 0, sc(parentBox.w), sc(parentBox.h)}; } Vector2D currentPopupSize = m_surface->getViewporterCorrectedSize() / m_surface->resource()->m_current.scale; diff --git a/src/managers/input/Swipe.cpp b/src/managers/input/Swipe.cpp index 355ffee3..1d9b80e2 100644 --- a/src/managers/input/Swipe.cpp +++ b/src/managers/input/Swipe.cpp @@ -67,7 +67,7 @@ void CInputManager::endWorkspaceSwipe() { // commit auto workspaceIDLeft = getWorkspaceIDNameFromString((*PSWIPEUSER ? "r-1" : "m-1")).id; auto workspaceIDRight = getWorkspaceIDNameFromString((*PSWIPEUSER ? "r+1" : "m+1")).id; - const auto SWIPEDISTANCE = std::clamp(*PSWIPEDIST, (int64_t)1LL, (int64_t)UINT32_MAX); + const auto SWIPEDISTANCE = std::clamp(*PSWIPEDIST, sc(1LL), sc(UINT32_MAX)); // If we've been swiping off the right end with PSWIPENEW enabled, there is // no workspace there yet, and we need to choose an ID for a new one now. @@ -213,7 +213,7 @@ void CInputManager::updateWorkspaceSwipe(double delta) { static auto PSWIPEUSER = CConfigValue("gestures:workspace_swipe_use_r"); static auto PWORKSPACEGAP = CConfigValue("general:gaps_workspaces"); - const auto SWIPEDISTANCE = std::clamp(*PSWIPEDIST, (int64_t)1LL, (int64_t)UINT32_MAX); + const auto SWIPEDISTANCE = std::clamp(*PSWIPEDIST, sc(1LL), sc(UINT32_MAX)); const auto XDISTANCE = m_activeSwipe.pMonitor->m_size.x + *PWORKSPACEGAP; const auto YDISTANCE = m_activeSwipe.pMonitor->m_size.y + *PWORKSPACEGAP; const auto ANIMSTYLE = m_activeSwipe.pWorkspaceBegin->m_renderOffset->getStyle(); @@ -234,7 +234,7 @@ void CInputManager::updateWorkspaceSwipe(double delta) { m_activeSwipe.pWorkspaceBegin->m_forceRendering = true; - m_activeSwipe.delta = std::clamp(m_activeSwipe.delta, (double)-SWIPEDISTANCE, (double)SWIPEDISTANCE); + m_activeSwipe.delta = std::clamp(m_activeSwipe.delta, sc(-SWIPEDISTANCE), sc(SWIPEDISTANCE)); if ((m_activeSwipe.pWorkspaceBegin->m_id == workspaceIDLeft && *PSWIPENEW && (m_activeSwipe.delta < 0)) || (m_activeSwipe.delta > 0 && m_activeSwipe.pWorkspaceBegin->getWindows() == 0 && workspaceIDRight <= m_activeSwipe.pWorkspaceBegin->m_id) || diff --git a/src/managers/input/TextInput.cpp b/src/managers/input/TextInput.cpp index c1ce2062..5da5e47a 100644 --- a/src/managers/input/TextInput.cpp +++ b/src/managers/input/TextInput.cpp @@ -251,7 +251,7 @@ void CTextInput::commitStateToIME(SP ime) { ime->textChangeCause(ZWP_TEXT_INPUT_V3_CHANGE_CAUSE_INPUT_METHOD); if (m_v1Input->m_pendingContentType.isPending) - ime->textContentType((zwpTextInputV3ContentHint)INPUT->m_pendingContentType.hint, (zwpTextInputV3ContentPurpose)INPUT->m_pendingContentType.purpose); + ime->textContentType(sc(INPUT->m_pendingContentType.hint), sc(INPUT->m_pendingContentType.purpose)); } g_pInputManager->m_relay.updateAllPopups(); diff --git a/src/managers/input/Touch.cpp b/src/managers/input/Touch.cpp index 4a67d2f2..9e19c4e8 100644 --- a/src/managers/input/Touch.cpp +++ b/src/managers/input/Touch.cpp @@ -16,7 +16,7 @@ void CInputManager::onTouchDown(ITouch::SDownEvent e) { static auto PSWIPETOUCH = CConfigValue("gestures:workspace_swipe_touch"); static auto PGAPSOUTDATA = CConfigValue("general:gaps_out"); - auto* const PGAPSOUT = (CCssGapData*)(PGAPSOUTDATA.ptr())->getData(); + auto* const PGAPSOUT = sc((PGAPSOUTDATA.ptr())->getData()); // TODO: WORKSPACERULE.gapsOut.value_or() auto gapsOut = *PGAPSOUT; static auto PBORDERSIZE = CConfigValue("general:border_size"); @@ -126,7 +126,7 @@ void CInputManager::onTouchMove(ITouch::SMotionEvent e) { const bool VERTANIMS = ANIMSTYLE == "slidevert" || ANIMSTYLE.starts_with("slidefadevert"); static auto PSWIPEINVR = CConfigValue("gestures:workspace_swipe_touch_invert"); static auto PSWIPEDIST = CConfigValue("gestures:workspace_swipe_distance"); - const auto SWIPEDISTANCE = std::clamp(*PSWIPEDIST, (int64_t)1LL, (int64_t)UINT32_MAX); + const auto SWIPEDISTANCE = std::clamp(*PSWIPEDIST, sc(1LL), sc(UINT32_MAX)); // Handle the workspace swipe if there is one if (m_activeSwipe.initialDirection == -1) { if (*PSWIPEINVR) diff --git a/src/managers/permissions/DynamicPermissionManager.cpp b/src/managers/permissions/DynamicPermissionManager.cpp index 2f4690fc..3f9d58dd 100644 --- a/src/managers/permissions/DynamicPermissionManager.cpp +++ b/src/managers/permissions/DynamicPermissionManager.cpp @@ -92,7 +92,7 @@ eDynamicPermissionAllowMode CDynamicPermissionManager::clientPermissionMode(wl_c const auto LOOKUP = binaryNameForWlClient(client); - Debug::log(TRACE, "CDynamicPermissionManager::clientHasPermission: checking permission {} for client {:x} (binary {})", permissionToString(permission), (uintptr_t)client, + Debug::log(TRACE, "CDynamicPermissionManager::clientHasPermission: checking permission {} for client {:x} (binary {})", permissionToString(permission), rc(client), LOOKUP.has_value() ? LOOKUP.value() : "lookup failed: " + LOOKUP.error()); // first, check if we have the client + perm combo in our cache. @@ -174,7 +174,7 @@ eDynamicPermissionAllowMode CDynamicPermissionManager::clientPermissionModeWithS if (lookup.has_value()) binaryName = *lookup; } else - binaryName = specialPidToString((eSpecialPidTypes)pid); + binaryName = specialPidToString(sc(pid)); // first, check if we have the client + perm combo in our cache. auto it = std::ranges::find_if(m_rules, [str, permission, pid](const auto& e) { return e->m_keyString == str && pid && pid == e->m_pid && e->m_type == permission; }); @@ -246,14 +246,14 @@ void CDynamicPermissionManager::askForPermission(wl_client* client, const std::s std::string description = ""; if (binaryPath.empty()) - description = std::format(std::runtime_format(permissionToHumanString(type)), std::format("unknown application (wayland client ID 0x{:x})", (uintptr_t)client)); + description = std::format(std::runtime_format(permissionToHumanString(type)), std::format("unknown application (wayland client ID 0x{:x})", rc(client))); else if (client) { std::string binaryName = binaryPath.contains("/") ? binaryPath.substr(binaryPath.find_last_of('/') + 1) : binaryPath; description = std::format(std::runtime_format(permissionToHumanString(type)), std::format("{} ({})", binaryName, binaryPath)); } else { std::string lookup = ""; if (pid < 0) - lookup = specialPidToString((eSpecialPidTypes)pid); + lookup = specialPidToString(sc(pid)); else { const auto LOOKUP = binaryNameForPid(pid); lookup = LOOKUP.value_or("Unknown"); -- cgit v1.2.3