refactor: Use new hyprutils casts (#11377)

This commit is contained in:
Kamikadze
2025-08-14 19:44:56 +05:00
committed by GitHub
parent aa6a78f0a4
commit beee22a95e
116 changed files with 715 additions and 696 deletions

View File

@@ -26,7 +26,9 @@
#include <filesystem> #include <filesystem>
#include <cstdarg> #include <cstdarg>
#include <hyprutils/string/String.hpp> #include <hyprutils/string/String.hpp>
#include <hyprutils/memory/Casts.hpp>
using namespace Hyprutils::String; using namespace Hyprutils::String;
using namespace Hyprutils::Memory;
#include "Strings.hpp" #include "Strings.hpp"
@@ -206,7 +208,7 @@ int request(std::string_view arg, int minArgs = 0, bool needRoll = false) {
strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1); strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1);
if (connect(SERVERSOCKET, (sockaddr*)&serverAddress, SUN_LEN(&serverAddress)) < 0) { if (connect(SERVERSOCKET, rc<sockaddr*>(&serverAddress), SUN_LEN(&serverAddress)) < 0) {
log("Couldn't connect to " + socketPath + ". (4)"); log("Couldn't connect to " + socketPath + ". (4)");
return 4; return 4;
} }
@@ -272,7 +274,7 @@ int requestIPC(std::string_view filename, std::string_view arg) {
strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1); strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1);
if (connect(SERVERSOCKET, (sockaddr*)&serverAddress, SUN_LEN(&serverAddress)) < 0) { if (connect(SERVERSOCKET, rc<sockaddr*>(&serverAddress), SUN_LEN(&serverAddress)) < 0) {
log("Couldn't connect to " + socketPath + ". (3)"); log("Couldn't connect to " + socketPath + ". (3)");
return 3; return 3;
} }
@@ -475,7 +477,7 @@ int main(int argc, char** argv) {
const auto INSTANCES = instances(); const auto INSTANCES = instances();
if (INSTANCENO < 0 || static_cast<std::size_t>(INSTANCENO) >= INSTANCES.size()) { if (INSTANCENO < 0 || sc<std::size_t>(INSTANCENO) >= INSTANCES.size()) {
log("no such instance\n"); log("no such instance\n");
return 1; return 1;
} }

View File

@@ -6,6 +6,9 @@
#include <sys/un.h> #include <sys/un.h>
#include <unistd.h> #include <unistd.h>
#include <cstring> #include <cstring>
#include <hyprutils/memory/Casts.hpp>
using namespace Hyprutils::Memory;
static int getUID() { static int getUID() {
const auto UID = getuid(); const auto UID = getuid();
@@ -46,7 +49,7 @@ std::string NHyprlandSocket::send(const std::string& cmd) {
strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1); strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1);
if (connect(SERVERSOCKET, (sockaddr*)&serverAddress, SUN_LEN(&serverAddress)) < 0) { if (connect(SERVERSOCKET, rc<sockaddr*>(&serverAddress), SUN_LEN(&serverAddress)) < 0) {
std::println("{}", failureString("Couldn't connect to " + socketPath + ". (4)")); std::println("{}", failureString("Couldn't connect to " + socketPath + ". (4)"));
return ""; return "";
} }

View File

@@ -26,8 +26,10 @@
#include <hyprutils/string/String.hpp> #include <hyprutils/string/String.hpp>
#include <hyprutils/os/Process.hpp> #include <hyprutils/os/Process.hpp>
#include <hyprutils/memory/Casts.hpp>
using namespace Hyprutils::String; using namespace Hyprutils::String;
using namespace Hyprutils::OS; using namespace Hyprutils::OS;
using namespace Hyprutils::Memory;
static std::string execAndGet(std::string cmd) { static std::string execAndGet(std::string cmd) {
cmd += " 2>&1"; cmd += " 2>&1";
@@ -599,7 +601,7 @@ bool CPluginManager::updateHeaders(bool force) {
std::print("\n"); std::print("\n");
} else { } else {
progress.printMessageAbove(failureString("failed to install headers with error code {} ({})", (int)HEADERSVALID, headerErrorShort(HEADERSVALID))); progress.printMessageAbove(failureString("failed to install headers with error code {} ({})", sc<int>(HEADERSVALID), headerErrorShort(HEADERSVALID)));
progress.printMessageAbove(infoString("if the problem persists, try running hyprpm purge-cache.")); progress.printMessageAbove(infoString("if the problem persists, try running hyprpm purge-cache."));
progress.m_iSteps = 5; progress.m_iSteps = 5;
progress.m_szCurrentMessage = "Failed"; progress.m_szCurrentMessage = "Failed";
@@ -945,7 +947,7 @@ void CPluginManager::listAllPlugins() {
} }
void CPluginManager::notify(const eNotifyIcons icon, uint32_t color, int durationMs, const std::string& message) { void CPluginManager::notify(const eNotifyIcons icon, uint32_t color, int durationMs, const std::string& message) {
NHyprlandSocket::send("/notify " + std::to_string((int)icon) + " " + std::to_string(durationMs) + " " + std::to_string(color) + " " + message); NHyprlandSocket::send("/notify " + std::to_string(icon) + " " + std::to_string(durationMs) + " " + std::to_string(color) + " " + message);
} }
std::string CPluginManager::headerError(const eHeadersErrors err) { std::string CPluginManager::headerError(const eHeadersErrors err) {

View File

@@ -9,9 +9,11 @@
#include <algorithm> #include <algorithm>
#include <sstream> #include <sstream>
#include <hyprutils/memory/Casts.hpp>
#include "../helpers/Colors.hpp" #include "../helpers/Colors.hpp"
using namespace Hyprutils::Memory;
static winsize getTerminalSize() { static winsize getTerminalSize() {
winsize w{}; winsize w{};
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
@@ -44,7 +46,7 @@ void CProgressBar::print() {
percentDone = m_fPercentage; percentDone = m_fPercentage;
else { else {
// check for divide-by-zero // check for divide-by-zero
percentDone = m_iMaxSteps > 0 ? static_cast<float>(m_iSteps) / m_iMaxSteps : 0.0f; percentDone = m_iMaxSteps > 0 ? sc<float>(m_iSteps) / m_iMaxSteps : 0.0f;
} }
// clamp to ensure no overflows (sanity check) // clamp to ensure no overflows (sanity check)
percentDone = std::clamp(percentDone, 0.0f, 1.0f); percentDone = std::clamp(percentDone, 0.0f, 1.0f);
@@ -54,7 +56,7 @@ void CProgressBar::print() {
std::ostringstream oss; std::ostringstream oss;
oss << ' ' << Colors::GREEN; oss << ' ' << Colors::GREEN;
size_t filled = static_cast<size_t>(std::floor(percentDone * BARWIDTH)); size_t filled = std::floor(percentDone * BARWIDTH);
size_t i = 0; size_t i = 0;
for (; i < filled; ++i) for (; i < filled; ++i)
@@ -69,7 +71,7 @@ void CProgressBar::print() {
oss << Colors::RESET; oss << Colors::RESET;
if (m_fPercentage >= 0.0f) if (m_fPercentage >= 0.0f)
oss << " " << std::format("{}%", static_cast<int>(percentDone * 100.0)) << ' '; oss << " " << std::format("{}%", sc<int>(percentDone * 100.0)) << ' ';
else else
oss << " " << std::format("{} / {}", m_iSteps, m_iMaxSteps) << ' '; oss << " " << std::format("{} / {}", m_iSteps, m_iMaxSteps) << ' ';

View File

@@ -72,7 +72,7 @@ class CTestKeyboard : public IKeyboard {
void sendKey(uint32_t key, bool pressed) { void sendKey(uint32_t key, bool pressed) {
auto event = IKeyboard::SKeyEvent{ auto event = IKeyboard::SKeyEvent{
.timeMs = static_cast<uint32_t>(Time::millis(Time::steadyNow())), .timeMs = sc<uint32_t>(Time::millis(Time::steadyNow())),
.keycode = key, .keycode = key,
.state = pressed ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED, .state = pressed ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED,
}; };

View File

@@ -14,6 +14,8 @@
#include <csignal> #include <csignal>
#include <cerrno> #include <cerrno>
#include <print> #include <print>
#include <hyprutils/memory/Casts.hpp>
using namespace Hyprutils::Memory;
static int getUID() { static int getUID() {
const auto UID = getuid(); const auto UID = getuid();
@@ -95,7 +97,7 @@ std::string getFromSocket(const std::string& cmd) {
strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1); strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1);
if (connect(SERVERSOCKET, (sockaddr*)&serverAddress, SUN_LEN(&serverAddress)) < 0) { if (connect(SERVERSOCKET, rc<sockaddr*>(&serverAddress), SUN_LEN(&serverAddress)) < 0) {
std::println("Couldn't connect to {}. (3)", socketPath); std::println("Couldn't connect to {}. (3)", socketPath);
return ""; return "";
} }

View File

@@ -1058,7 +1058,7 @@ Vector2D CCompositor::vectorToSurfaceLocal(const Vector2D& vec, PHLWINDOW pWindo
pWindow->m_wlSurface->resource()->breadthfirst( pWindow->m_wlSurface->resource()->breadthfirst(
[](SP<CWLSurfaceResource> surf, const Vector2D& offset, void* data) { [](SP<CWLSurfaceResource> surf, const Vector2D& offset, void* data) {
const auto PDATA = (std::tuple<SP<CWLSurfaceResource>, Vector2D>*)data; const auto PDATA = sc<std::tuple<SP<CWLSurfaceResource>, Vector2D>*>(data);
if (surf == std::get<0>(*PDATA)) if (surf == std::get<0>(*PDATA))
std::get<1>(*PDATA) = offset; std::get<1>(*PDATA) = offset;
}, },
@@ -1133,7 +1133,7 @@ void CCompositor::focusWindow(PHLWINDOW pWindow, SP<CWLSurfaceResource> pSurface
g_pEventManager->postEvent(SHyprIPCEvent{"activewindow", ","}); g_pEventManager->postEvent(SHyprIPCEvent{"activewindow", ","});
g_pEventManager->postEvent(SHyprIPCEvent{"activewindowv2", ""}); g_pEventManager->postEvent(SHyprIPCEvent{"activewindowv2", ""});
EMIT_HOOK_EVENT("activeWindow", (PHLWINDOW) nullptr); EMIT_HOOK_EVENT("activeWindow", PHLWINDOW{nullptr});
g_pLayoutManager->getCurrentLayout()->onWindowFocusChange(nullptr); g_pLayoutManager->getCurrentLayout()->onWindowFocusChange(nullptr);
@@ -1206,7 +1206,7 @@ void CCompositor::focusWindow(PHLWINDOW pWindow, SP<CWLSurfaceResource> pSurface
// Send an event // Send an event
g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindow", .data = pWindow->m_class + "," + pWindow->m_title}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindow", .data = pWindow->m_class + "," + pWindow->m_title});
g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindowv2", .data = std::format("{:x}", (uintptr_t)pWindow.get())}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindowv2", .data = std::format("{:x}", rc<uintptr_t>(pWindow.get()))});
EMIT_HOOK_EVENT("activeWindow", pWindow); EMIT_HOOK_EVENT("activeWindow", pWindow);
@@ -1239,7 +1239,7 @@ void CCompositor::focusSurface(SP<CWLSurfaceResource> pSurface, PHLWINDOW pWindo
return; return;
if (g_pSeatManager->m_seatGrab && !g_pSeatManager->m_seatGrab->accepts(pSurface)) { if (g_pSeatManager->m_seatGrab && !g_pSeatManager->m_seatGrab->accepts(pSurface)) {
Debug::log(LOG, "surface {:x} won't receive kb focus because grab rejected it", (uintptr_t)pSurface.get()); Debug::log(LOG, "surface {:x} won't receive kb focus because grab rejected it", rc<uintptr_t>(pSurface.get()));
return; return;
} }
@@ -1253,7 +1253,7 @@ void CCompositor::focusSurface(SP<CWLSurfaceResource> pSurface, PHLWINDOW pWindo
g_pSeatManager->setKeyboardFocus(nullptr); g_pSeatManager->setKeyboardFocus(nullptr);
g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindow", .data = ","}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindow", .data = ","});
g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindowv2", .data = ""}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindowv2", .data = ""});
EMIT_HOOK_EVENT("keyboardFocus", (SP<CWLSurfaceResource>)nullptr); EMIT_HOOK_EVENT("keyboardFocus", SP<CWLSurfaceResource>{nullptr});
m_lastFocus.reset(); m_lastFocus.reset();
return; return;
} }
@@ -1262,9 +1262,9 @@ void CCompositor::focusSurface(SP<CWLSurfaceResource> pSurface, PHLWINDOW pWindo
g_pSeatManager->setKeyboardFocus(pSurface); g_pSeatManager->setKeyboardFocus(pSurface);
if (pWindowOwner) if (pWindowOwner)
Debug::log(LOG, "Set keyboard focus to surface {:x}, with {}", (uintptr_t)pSurface.get(), pWindowOwner); Debug::log(LOG, "Set keyboard focus to surface {:x}, with {}", rc<uintptr_t>(pSurface.get()), pWindowOwner);
else else
Debug::log(LOG, "Set keyboard focus to surface {:x}", (uintptr_t)pSurface.get()); Debug::log(LOG, "Set keyboard focus to surface {:x}", rc<uintptr_t>(pSurface.get()));
g_pXWaylandManager->activateSurface(pSurface, true); g_pXWaylandManager->activateSurface(pSurface, true);
m_lastFocus = pSurface; m_lastFocus = pSurface;
@@ -1334,7 +1334,7 @@ PHLWINDOW CCompositor::getWindowFromSurface(SP<CWLSurfaceResource> pSurface) {
PHLWINDOW CCompositor::getWindowFromHandle(uint32_t handle) { PHLWINDOW CCompositor::getWindowFromHandle(uint32_t handle) {
for (auto const& w : m_windows) { for (auto const& w : m_windows) {
if ((uint32_t)(((uint64_t)w.get()) & 0xFFFFFFFF) == handle) { if (sc<uint32_t>(rc<uint64_t>(w.get()) & 0xFFFFFFFF) == handle) {
return w; return w;
} }
} }
@@ -1868,14 +1868,14 @@ void CCompositor::updateWindowAnimatedDecorationValues(PHLWINDOW pWindow) {
static auto PDIMSTRENGTH = CConfigValue<Hyprlang::FLOAT>("decoration:dim_strength"); static auto PDIMSTRENGTH = CConfigValue<Hyprlang::FLOAT>("decoration:dim_strength");
static auto PDIMENABLED = CConfigValue<Hyprlang::INT>("decoration:dim_inactive"); static auto PDIMENABLED = CConfigValue<Hyprlang::INT>("decoration:dim_inactive");
auto* const ACTIVECOL = (CGradientValueData*)(PACTIVECOL.ptr())->getData(); auto* const ACTIVECOL = sc<CGradientValueData*>((PACTIVECOL.ptr())->getData());
auto* const INACTIVECOL = (CGradientValueData*)(PINACTIVECOL.ptr())->getData(); auto* const INACTIVECOL = sc<CGradientValueData*>((PINACTIVECOL.ptr())->getData());
auto* const NOGROUPACTIVECOL = (CGradientValueData*)(PNOGROUPACTIVECOL.ptr())->getData(); auto* const NOGROUPACTIVECOL = sc<CGradientValueData*>((PNOGROUPACTIVECOL.ptr())->getData());
auto* const NOGROUPINACTIVECOL = (CGradientValueData*)(PNOGROUPINACTIVECOL.ptr())->getData(); auto* const NOGROUPINACTIVECOL = sc<CGradientValueData*>((PNOGROUPINACTIVECOL.ptr())->getData());
auto* const GROUPACTIVECOL = (CGradientValueData*)(PGROUPACTIVECOL.ptr())->getData(); auto* const GROUPACTIVECOL = sc<CGradientValueData*>((PGROUPACTIVECOL.ptr())->getData());
auto* const GROUPINACTIVECOL = (CGradientValueData*)(PGROUPINACTIVECOL.ptr())->getData(); auto* const GROUPINACTIVECOL = sc<CGradientValueData*>((PGROUPINACTIVECOL.ptr())->getData());
auto* const GROUPACTIVELOCKEDCOL = (CGradientValueData*)(PGROUPACTIVELOCKEDCOL.ptr())->getData(); auto* const GROUPACTIVELOCKEDCOL = sc<CGradientValueData*>((PGROUPACTIVELOCKEDCOL.ptr())->getData());
auto* const GROUPINACTIVELOCKEDCOL = (CGradientValueData*)(PGROUPINACTIVELOCKEDCOL.ptr())->getData(); auto* const GROUPINACTIVELOCKEDCOL = sc<CGradientValueData*>((PGROUPINACTIVELOCKEDCOL.ptr())->getData());
auto setBorderColor = [&](CGradientValueData grad) -> void { auto setBorderColor = [&](CGradientValueData grad) -> void {
if (grad == pWindow->m_realBorderColor) if (grad == pWindow->m_realBorderColor)
@@ -2070,7 +2070,7 @@ PHLMONITOR CCompositor::getMonitorFromString(const std::string& name) {
offsetLeft = offsetLeft < 0 ? -((-offsetLeft) % m_monitors.size()) : offsetLeft % m_monitors.size(); offsetLeft = offsetLeft < 0 ? -((-offsetLeft) % m_monitors.size()) : offsetLeft % m_monitors.size();
int currentPlace = 0; int currentPlace = 0;
for (int i = 0; i < (int)m_monitors.size(); i++) { for (int i = 0; i < sc<int>(m_monitors.size()); i++) {
if (m_monitors[i] == m_lastMonitor) { if (m_monitors[i] == m_lastMonitor) {
currentPlace = i; currentPlace = i;
break; break;
@@ -2085,9 +2085,9 @@ PHLMONITOR CCompositor::getMonitorFromString(const std::string& name) {
currentPlace = currentPlace % m_monitors.size(); currentPlace = currentPlace % m_monitors.size();
} }
if (currentPlace != std::clamp(currentPlace, 0, (int)m_monitors.size() - 1)) { if (currentPlace != std::clamp(currentPlace, 0, sc<int>(m_monitors.size()) - 1)) {
Debug::log(WARN, "Error in getMonitorFromString: Vaxry's code sucks."); Debug::log(WARN, "Error in getMonitorFromString: Vaxry's code sucks.");
currentPlace = std::clamp(currentPlace, 0, (int)m_monitors.size() - 1); currentPlace = std::clamp(currentPlace, 0, sc<int>(m_monitors.size()) - 1);
} }
return m_monitors[currentPlace]; return m_monitors[currentPlace];
@@ -2102,7 +2102,7 @@ PHLMONITOR CCompositor::getMonitorFromString(const std::string& name) {
return nullptr; return nullptr;
} }
if (monID > -1 && monID < (MONITORID)m_monitors.size()) { if (monID > -1 && monID < sc<MONITORID>(m_monitors.size())) {
return getMonitorFromID(monID); return getMonitorFromID(monID);
} else { } else {
Debug::log(ERR, "Error in getMonitorFromString: invalid arg 1"); Debug::log(ERR, "Error in getMonitorFromString: invalid arg 1");
@@ -2194,8 +2194,8 @@ void CCompositor::moveWorkspaceToMonitor(PHLWORKSPACE pWorkspace, PHLMONITOR pMo
} }
} else } else
*w->m_realPosition = Vector2D{ *w->m_realPosition = Vector2D{
(pMonitor->m_size.x != 0) ? (int)w->m_realPosition->goal().x % (int)pMonitor->m_size.x : 0, (pMonitor->m_size.x != 0) ? sc<int>(w->m_realPosition->goal().x) % sc<int>(pMonitor->m_size.x) : 0,
(pMonitor->m_size.y != 0) ? (int)w->m_realPosition->goal().y % (int)pMonitor->m_size.y : 0, (pMonitor->m_size.y != 0) ? sc<int>(w->m_realPosition->goal().y) % sc<int>(pMonitor->m_size.y) : 0,
}; };
} }
@@ -2297,8 +2297,9 @@ void CCompositor::updateFullscreenFadeOnWorkspace(PHLWORKSPACE pWorkspace) {
} }
void CCompositor::changeWindowFullscreenModeClient(const PHLWINDOW PWINDOW, const eFullscreenMode MODE, const bool ON) { void CCompositor::changeWindowFullscreenModeClient(const PHLWINDOW PWINDOW, const eFullscreenMode MODE, const bool ON) {
setWindowFullscreenClient(PWINDOW, setWindowFullscreenClient(
(eFullscreenMode)(ON ? (uint8_t)PWINDOW->m_fullscreenState.client | (uint8_t)MODE : ((uint8_t)PWINDOW->m_fullscreenState.client & (uint8_t)~MODE))); PWINDOW,
sc<eFullscreenMode>(ON ? sc<uint8_t>(PWINDOW->m_fullscreenState.client) | sc<uint8_t>(MODE) : (sc<uint8_t>(PWINDOW->m_fullscreenState.client) & sc<uint8_t>(~MODE))));
} }
void CCompositor::setWindowFullscreenInternal(const PHLWINDOW PWINDOW, const eFullscreenMode MODE) { void CCompositor::setWindowFullscreenInternal(const PHLWINDOW PWINDOW, const eFullscreenMode MODE) {
@@ -2322,14 +2323,14 @@ void CCompositor::setWindowFullscreenState(const PHLWINDOW PWINDOW, SFullscreenS
if (!validMapped(PWINDOW) || g_pCompositor->m_unsafeState) if (!validMapped(PWINDOW) || g_pCompositor->m_unsafeState)
return; return;
state.internal = std::clamp(state.internal, (eFullscreenMode)0, FSMODE_MAX); state.internal = std::clamp(state.internal, sc<eFullscreenMode>(0), FSMODE_MAX);
state.client = std::clamp(state.client, (eFullscreenMode)0, FSMODE_MAX); state.client = std::clamp(state.client, sc<eFullscreenMode>(0), FSMODE_MAX);
const auto PMONITOR = PWINDOW->m_monitor.lock(); const auto PMONITOR = PWINDOW->m_monitor.lock();
const auto PWORKSPACE = PWINDOW->m_workspace; const auto PWORKSPACE = PWINDOW->m_workspace;
const eFullscreenMode CURRENT_EFFECTIVE_MODE = (eFullscreenMode)std::bit_floor((uint8_t)PWINDOW->m_fullscreenState.internal); const eFullscreenMode CURRENT_EFFECTIVE_MODE = sc<eFullscreenMode>(std::bit_floor(sc<uint8_t>(PWINDOW->m_fullscreenState.internal)));
const eFullscreenMode EFFECTIVE_MODE = (eFullscreenMode)std::bit_floor((uint8_t)state.internal); const eFullscreenMode EFFECTIVE_MODE = sc<eFullscreenMode>(std::bit_floor(sc<uint8_t>(state.internal)));
if (PWINDOW->m_isFloating && CURRENT_EFFECTIVE_MODE == FSMODE_NONE && EFFECTIVE_MODE != FSMODE_NONE) if (PWINDOW->m_isFloating && CURRENT_EFFECTIVE_MODE == FSMODE_NONE && EFFECTIVE_MODE != FSMODE_NONE)
g_pHyprRenderer->damageWindow(PWINDOW); g_pHyprRenderer->damageWindow(PWINDOW);
@@ -2369,7 +2370,7 @@ void CCompositor::setWindowFullscreenState(const PHLWINDOW PWINDOW, SFullscreenS
PWORKSPACE->m_fullscreenMode = EFFECTIVE_MODE; PWORKSPACE->m_fullscreenMode = EFFECTIVE_MODE;
PWORKSPACE->m_hasFullscreenWindow = EFFECTIVE_MODE != FSMODE_NONE; PWORKSPACE->m_hasFullscreenWindow = EFFECTIVE_MODE != FSMODE_NONE;
g_pEventManager->postEvent(SHyprIPCEvent{.event = "fullscreen", .data = std::to_string((int)EFFECTIVE_MODE != FSMODE_NONE)}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "fullscreen", .data = std::to_string(sc<int>(EFFECTIVE_MODE) != FSMODE_NONE)});
EMIT_HOOK_EVENT("fullscreen", PWINDOW); EMIT_HOOK_EVENT("fullscreen", PWINDOW);
PWINDOW->updateDynamicRules(); PWINDOW->updateDynamicRules();
@@ -2520,7 +2521,7 @@ PHLWINDOW CCompositor::getWindowByRegex(const std::string& regexp_) {
break; break;
} }
case MODE_ADDRESS: { case MODE_ADDRESS: {
std::string addr = std::format("0x{:x}", (uintptr_t)w.get()); std::string addr = std::format("0x{:x}", rc<uintptr_t>(w.get()));
if (matchCheck != addr) if (matchCheck != addr)
continue; continue;
break; break;
@@ -2844,7 +2845,7 @@ PHLWINDOW CCompositor::getForceFocus() {
} }
void CCompositor::arrangeMonitors() { void CCompositor::arrangeMonitors() {
static auto* const PXWLFORCESCALEZERO = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("xwayland:force_zero_scaling"); static auto* const PXWLFORCESCALEZERO = rc<Hyprlang::INT* const*>(g_pConfigManager->getConfigValuePtr("xwayland:force_zero_scaling"));
std::vector<PHLMONITOR> toArrange(m_monitors.begin(), m_monitors.end()); std::vector<PHLMONITOR> toArrange(m_monitors.begin(), m_monitors.end());
std::vector<PHLMONITOR> arranged; std::vector<PHLMONITOR> arranged;
@@ -3000,12 +3001,12 @@ void CCompositor::setPreferredScaleForSurface(SP<CWLSurfaceResource> pSurface, d
const auto PSURFACE = CWLSurface::fromResource(pSurface); const auto PSURFACE = CWLSurface::fromResource(pSurface);
if (!PSURFACE) { if (!PSURFACE) {
Debug::log(WARN, "Orphaned CWLSurfaceResource {:x} in setPreferredScaleForSurface", (uintptr_t)pSurface.get()); Debug::log(WARN, "Orphaned CWLSurfaceResource {:x} in setPreferredScaleForSurface", rc<uintptr_t>(pSurface.get()));
return; return;
} }
PSURFACE->m_lastScaleFloat = scale; PSURFACE->m_lastScaleFloat = scale;
PSURFACE->m_lastScaleInt = static_cast<int32_t>(std::ceil(scale)); PSURFACE->m_lastScaleInt = sc<int32_t>(std::ceil(scale));
} }
void CCompositor::setPreferredTransformForSurface(SP<CWLSurfaceResource> pSurface, wl_output_transform transform) { void CCompositor::setPreferredTransformForSurface(SP<CWLSurfaceResource> pSurface, wl_output_transform transform) {
@@ -3013,7 +3014,7 @@ void CCompositor::setPreferredTransformForSurface(SP<CWLSurfaceResource> pSurfac
const auto PSURFACE = CWLSurface::fromResource(pSurface); const auto PSURFACE = CWLSurface::fromResource(pSurface);
if (!PSURFACE) { if (!PSURFACE) {
Debug::log(WARN, "Orphaned CWLSurfaceResource {:x} in setPreferredTransformForSurface", (uintptr_t)pSurface.get()); Debug::log(WARN, "Orphaned CWLSurfaceResource {:x} in setPreferredTransformForSurface", rc<uintptr_t>(pSurface.get()));
return; return;
} }

View File

@@ -78,7 +78,7 @@ class CGradientValueData : public ICustomConfigValueData {
result += std::format("{:x} ", c.getAsHex()); result += std::format("{:x} ", c.getAsHex());
} }
result += std::format("{}deg", (int)(m_angle * 180.0 / M_PI)); result += std::format("{}deg", sc<int>(m_angle * 180.0 / M_PI));
return result; return result;
} }
}; };

View File

@@ -63,7 +63,7 @@ static Hyprlang::CParseResult configHandleGradientSet(const char* VALUE, void**
if (!*data) if (!*data)
*data = new CGradientValueData(); *data = new CGradientValueData();
const auto DATA = reinterpret_cast<CGradientValueData*>(*data); const auto DATA = sc<CGradientValueData*>(*data);
CVarList varlist(V, 0, ' '); CVarList varlist(V, 0, ' ');
DATA->m_colors.clear(); DATA->m_colors.clear();
@@ -119,7 +119,7 @@ static Hyprlang::CParseResult configHandleGradientSet(const char* VALUE, void**
static void configHandleGradientDestroy(void** data) { static void configHandleGradientDestroy(void** data) {
if (*data) if (*data)
delete reinterpret_cast<CGradientValueData*>(*data); delete sc<CGradientValueData*>(*data);
} }
static Hyprlang::CParseResult configHandleGapSet(const char* VALUE, void** data) { static Hyprlang::CParseResult configHandleGapSet(const char* VALUE, void** data) {
@@ -128,7 +128,7 @@ static Hyprlang::CParseResult configHandleGapSet(const char* VALUE, void** data)
if (!*data) if (!*data)
*data = new CCssGapData(); *data = new CCssGapData();
const auto DATA = reinterpret_cast<CCssGapData*>(*data); const auto DATA = sc<CCssGapData*>(*data);
CVarList varlist(V); CVarList varlist(V);
Hyprlang::CParseResult result; Hyprlang::CParseResult result;
@@ -144,14 +144,14 @@ static Hyprlang::CParseResult configHandleGapSet(const char* VALUE, void** data)
static void configHandleGapDestroy(void** data) { static void configHandleGapDestroy(void** data) {
if (*data) if (*data)
delete reinterpret_cast<CCssGapData*>(*data); delete sc<CCssGapData*>(*data);
} }
static Hyprlang::CParseResult configHandleFontWeightSet(const char* VALUE, void** data) { static Hyprlang::CParseResult configHandleFontWeightSet(const char* VALUE, void** data) {
if (!*data) if (!*data)
*data = new CFontWeightConfigValueData(); *data = new CFontWeightConfigValueData();
const auto DATA = reinterpret_cast<CFontWeightConfigValueData*>(*data); const auto DATA = sc<CFontWeightConfigValueData*>(*data);
Hyprlang::CParseResult result; Hyprlang::CParseResult result;
try { try {
@@ -166,7 +166,7 @@ static Hyprlang::CParseResult configHandleFontWeightSet(const char* VALUE, void*
static void configHandleFontWeightDestroy(void** data) { static void configHandleFontWeightDestroy(void** data) {
if (*data) if (*data)
delete reinterpret_cast<CFontWeightConfigValueData*>(*data); delete sc<CFontWeightConfigValueData*>(*data);
} }
static Hyprlang::CParseResult handleExec(const char* c, const char* v) { static Hyprlang::CParseResult handleExec(const char* c, const char* v) {
@@ -540,7 +540,7 @@ CConfigManager::CConfigManager() {
registerConfigVar("debug:disable_logs", Hyprlang::INT{1}); registerConfigVar("debug:disable_logs", Hyprlang::INT{1});
registerConfigVar("debug:disable_time", Hyprlang::INT{1}); registerConfigVar("debug:disable_time", Hyprlang::INT{1});
registerConfigVar("debug:enable_stdout_logs", Hyprlang::INT{0}); registerConfigVar("debug:enable_stdout_logs", Hyprlang::INT{0});
registerConfigVar("debug:damage_tracking", {(Hyprlang::INT)DAMAGE_TRACKING_FULL}); registerConfigVar("debug:damage_tracking", {sc<Hyprlang::INT>(DAMAGE_TRACKING_FULL)});
registerConfigVar("debug:manual_crash", Hyprlang::INT{0}); registerConfigVar("debug:manual_crash", Hyprlang::INT{0});
registerConfigVar("debug:suppress_errors", Hyprlang::INT{0}); registerConfigVar("debug:suppress_errors", Hyprlang::INT{0});
registerConfigVar("debug:error_limit", Hyprlang::INT{5}); registerConfigVar("debug:error_limit", Hyprlang::INT{5});
@@ -863,8 +863,8 @@ CConfigManager::CConfigManager() {
"https://wiki.hypr.land/Configuring/Variables/#debug"); "https://wiki.hypr.land/Configuring/Variables/#debug");
} }
Debug::m_disableLogs = reinterpret_cast<int64_t* const*>(m_config->getConfigValuePtr("debug:disable_logs")->getDataStaticPtr()); Debug::m_disableLogs = rc<int64_t* const*>(m_config->getConfigValuePtr("debug:disable_logs")->getDataStaticPtr());
Debug::m_disableTime = reinterpret_cast<int64_t* const*>(m_config->getConfigValuePtr("debug:disable_time")->getDataStaticPtr()); Debug::m_disableTime = rc<int64_t* const*>(m_config->getConfigValuePtr("debug:disable_time")->getDataStaticPtr());
if (g_pEventLoopManager && ERR.has_value()) if (g_pEventLoopManager && ERR.has_value())
g_pEventLoopManager->doLater([ERR] { g_pHyprError->queueCreate(ERR.value(), CHyprColor{1.0, 0.1, 0.1, 1.0}); }); g_pEventLoopManager->doLater([ERR] { g_pHyprError->queueCreate(ERR.value(), CHyprColor{1.0, 0.1, 0.1, 1.0}); });
@@ -1233,7 +1233,7 @@ void CConfigManager::postConfigReload(const Hyprlang::CParseResult& result) {
if (Debug::m_disableStdout && m_isFirstLaunch) if (Debug::m_disableStdout && m_isFirstLaunch)
Debug::log(LOG, "Disabling stdout logs! Check the log for further logs."); Debug::log(LOG, "Disabling stdout logs! Check the log for further logs.");
Debug::m_coloredLogs = reinterpret_cast<int64_t* const*>(m_config->getConfigValuePtr("debug:colored_stdout_logs")->getDataStaticPtr()); Debug::m_coloredLogs = rc<int64_t* const*>(m_config->getConfigValuePtr("debug:colored_stdout_logs")->getDataStaticPtr());
for (auto const& m : g_pCompositor->m_monitors) { for (auto const& m : g_pCompositor->m_monitors) {
// mark blur dirty // mark blur dirty
@@ -1362,18 +1362,18 @@ SMonitorRule CConfigManager::getMonitorRuleFor(const PHLMONITOR PMONITOR) {
} }
if (CONFIG->committedProperties & OUTPUT_HEAD_COMMITTED_TRANSFORM) { if (CONFIG->committedProperties & OUTPUT_HEAD_COMMITTED_TRANSFORM) {
Debug::log(LOG, " > overriding transform: {} -> {}", (uint8_t)rule.transform, (uint8_t)CONFIG->transform); Debug::log(LOG, " > overriding transform: {} -> {}", sc<uint8_t>(rule.transform), sc<uint8_t>(CONFIG->transform));
rule.transform = CONFIG->transform; rule.transform = CONFIG->transform;
} }
if (CONFIG->committedProperties & OUTPUT_HEAD_COMMITTED_SCALE) { if (CONFIG->committedProperties & OUTPUT_HEAD_COMMITTED_SCALE) {
Debug::log(LOG, " > overriding scale: {} -> {}", (uint8_t)rule.scale, (uint8_t)CONFIG->scale); Debug::log(LOG, " > overriding scale: {} -> {}", sc<uint8_t>(rule.scale), sc<uint8_t>(CONFIG->scale));
rule.scale = CONFIG->scale; rule.scale = CONFIG->scale;
} }
if (CONFIG->committedProperties & OUTPUT_HEAD_COMMITTED_ADAPTIVE_SYNC) { if (CONFIG->committedProperties & OUTPUT_HEAD_COMMITTED_ADAPTIVE_SYNC) {
Debug::log(LOG, " > overriding vrr: {} -> {}", rule.vrr.value_or(0), CONFIG->adaptiveSync); Debug::log(LOG, " > overriding vrr: {} -> {}", rule.vrr.value_or(0), CONFIG->adaptiveSync);
rule.vrr = (int)CONFIG->adaptiveSync; rule.vrr = sc<int>(CONFIG->adaptiveSync);
} }
return rule; return rule;
@@ -1534,14 +1534,14 @@ std::vector<SP<CWindowRule>> CConfigManager::getMatchingRules(PHLWINDOW pWindow,
if (ARGS[0] == "*") if (ARGS[0] == "*")
internalMode = std::nullopt; internalMode = std::nullopt;
else if (isNumber(ARGS[0])) else if (isNumber(ARGS[0]))
internalMode = (eFullscreenMode)std::stoi(ARGS[0]); internalMode = sc<eFullscreenMode>(std::stoi(ARGS[0]));
else else
throw std::runtime_error("szFullscreenState internal mode not valid"); throw std::runtime_error("szFullscreenState internal mode not valid");
if (ARGS[1] == "*") if (ARGS[1] == "*")
clientMode = std::nullopt; clientMode = std::nullopt;
else if (isNumber(ARGS[1])) else if (isNumber(ARGS[1]))
clientMode = (eFullscreenMode)std::stoi(ARGS[1]); clientMode = sc<eFullscreenMode>(std::stoi(ARGS[1]));
else else
throw std::runtime_error("szFullscreenState client mode not valid"); throw std::runtime_error("szFullscreenState client mode not valid");
@@ -1634,7 +1634,7 @@ std::vector<SP<CWindowRule>> CConfigManager::getMatchingRules(PHLWINDOW pWindow,
hasFullscreen = true; hasFullscreen = true;
} }
std::vector<uint64_t> PIDs = {(uint64_t)pWindow->getPID()}; std::vector<uint64_t> PIDs = {sc<uint64_t>(pWindow->getPID())};
while (getPPIDof(PIDs.back()) > 10) while (getPPIDof(PIDs.back()) > 10)
PIDs.push_back(getPPIDof(PIDs.back())); PIDs.push_back(getPPIDof(PIDs.back()));
@@ -1661,7 +1661,7 @@ std::vector<SP<CLayerRule>> CConfigManager::getMatchingRules(PHLLS pLS) {
for (auto const& lr : m_layerRules) { for (auto const& lr : m_layerRules) {
if (lr->m_targetNamespace.starts_with("address:0x")) { if (lr->m_targetNamespace.starts_with("address:0x")) {
if (std::format("address:0x{:x}", (uintptr_t)pLS.get()) != lr->m_targetNamespace) if (std::format("address:0x{:x}", rc<uintptr_t>(pLS.get())) != lr->m_targetNamespace)
continue; continue;
} else if (!lr->m_targetNamespaceRegex.passes(pLS->m_layerSurface->m_layerNamespace)) } else if (!lr->m_targetNamespaceRegex.passes(pLS->m_layerSurface->m_layerNamespace))
continue; continue;
@@ -1804,7 +1804,7 @@ void CConfigManager::ensureMonitorStatus() {
} }
void CConfigManager::ensureVRR(PHLMONITOR pMonitor) { void CConfigManager::ensureVRR(PHLMONITOR pMonitor) {
static auto PVRR = reinterpret_cast<Hyprlang::INT* const*>(getConfigValuePtr("misc:vrr")); static auto PVRR = rc<Hyprlang::INT* const*>(getConfigValuePtr("misc:vrr"));
static auto ensureVRRForDisplay = [&](PHLMONITOR m) -> void { static auto ensureVRRForDisplay = [&](PHLMONITOR m) -> void {
if (!m->m_output || m->m_createdByUser) if (!m->m_output || m->m_createdByUser)
@@ -2061,7 +2061,7 @@ static bool parseModeLine(const std::string& modeline, drmModeModeInfo& mode) {
}; };
// clang-format on // clang-format on
for (; argno < static_cast<int>(args.size()); argno++) { for (; argno < sc<int>(args.size()); argno++) {
auto key = args[argno]; auto key = args[argno];
std::ranges::transform(key, key.begin(), ::tolower); std::ranges::transform(key, key.begin(), ::tolower);
@@ -2107,7 +2107,7 @@ bool CMonitorRuleParser::parseMode(const std::string& value) {
m_rule.resolution = Vector2D(-1, -3); m_rule.resolution = Vector2D(-1, -3);
else if (parseModeLine(value, m_rule.drmMode)) { else if (parseModeLine(value, m_rule.drmMode)) {
m_rule.resolution = Vector2D(m_rule.drmMode.hdisplay, m_rule.drmMode.vdisplay); m_rule.resolution = Vector2D(m_rule.drmMode.hdisplay, m_rule.drmMode.vdisplay);
m_rule.refreshRate = float(m_rule.drmMode.vrefresh) / 1000; m_rule.refreshRate = sc<float>(m_rule.drmMode.vrefresh) / 1000;
} else { } else {
if (!value.contains("x")) { if (!value.contains("x")) {
@@ -2200,7 +2200,7 @@ bool CMonitorRuleParser::parseTransform(const std::string& value) {
m_error += "invalid transform "; m_error += "invalid transform ";
return false; return false;
} }
m_rule.transform = (wl_output_transform)TSF; m_rule.transform = sc<wl_output_transform>(TSF);
return true; return true;
} }
@@ -2534,7 +2534,7 @@ std::optional<std::string> CConfigManager::handleBind(const std::string& command
const int DESCR_OFFSET = hasDescription ? 1 : 0; const int DESCR_OFFSET = hasDescription ? 1 : 0;
if ((ARGS.size() < 3 && !mouse) || (ARGS.size() < 3 && mouse)) if ((ARGS.size() < 3 && !mouse) || (ARGS.size() < 3 && mouse))
return "bind: too few args"; return "bind: too few args";
else if ((ARGS.size() > (size_t)4 + DESCR_OFFSET && !mouse) || (ARGS.size() > (size_t)3 + DESCR_OFFSET && mouse)) else if ((ARGS.size() > sc<size_t>(4) + DESCR_OFFSET && !mouse) || (ARGS.size() > sc<size_t>(3) + DESCR_OFFSET && mouse))
return "bind: too many args"; return "bind: too many args";
std::set<xkb_keysym_t> KEYSYMS; std::set<xkb_keysym_t> KEYSYMS;
@@ -2870,7 +2870,7 @@ void CConfigManager::updateBlurredLS(const std::string& name, const bool forceBl
for (auto const& lsl : m->m_layerSurfaceLayers) { for (auto const& lsl : m->m_layerSurfaceLayers) {
for (auto const& ls : lsl) { for (auto const& ls : lsl) {
if (BYADDRESS) { if (BYADDRESS) {
if (std::format("0x{:x}", (uintptr_t)ls.get()) == matchName) if (std::format("0x{:x}", rc<uintptr_t>(ls.get())) == matchName)
ls->m_forceBlur = forceBlur; ls->m_forceBlur = forceBlur;
} else if (ls->m_namespace == matchName) } else if (ls->m_namespace == matchName)
ls->m_forceBlur = forceBlur; ls->m_forceBlur = forceBlur;
@@ -3027,7 +3027,7 @@ std::optional<std::string> CConfigManager::handleSource(const std::string& comma
return "source= path " + rawpath + " bogus!"; return "source= path " + rawpath + " bogus!";
} }
std::unique_ptr<glob_t, void (*)(glob_t*)> glob_buf{static_cast<glob_t*>(calloc(1, sizeof(glob_t))), // allocate and zero-initialize std::unique_ptr<glob_t, void (*)(glob_t*)> glob_buf{sc<glob_t*>(calloc(1, sizeof(glob_t))), // allocate and zero-initialize
[](glob_t* g) { [](glob_t* g) {
if (g) { if (g) {
globfree(g); // free internal resources allocated by glob() globfree(g); // free internal resources allocated by glob()
@@ -3191,7 +3191,7 @@ std::string SConfigOptionDescription::jsonify() const {
const auto V = std::any_cast<Hyprlang::VEC2>(CONFIGVALUE); const auto V = std::any_cast<Hyprlang::VEC2>(CONFIGVALUE);
currentValue = std::format("{}, {}", V.x, V.y); currentValue = std::format("{}, {}", V.x, V.y);
} else if (typeid(void*) == std::type_index(CONFIGVALUE.type())) { } else if (typeid(void*) == std::type_index(CONFIGVALUE.type())) {
const auto DATA = (ICustomConfigValueData*)std::any_cast<void*>(CONFIGVALUE); const auto DATA = sc<ICustomConfigValueData*>(std::any_cast<void*>(CONFIGVALUE));
currentValue = DATA->toString(); currentValue = DATA->toString();
} }
@@ -3264,7 +3264,7 @@ std::string SConfigOptionDescription::jsonify() const {
{} {}
}} }}
}})#", }})#",
value, escapeJSONStrings(description), (uint16_t)type, (uint32_t)flags, parseData()); value, escapeJSONStrings(description), sc<uint16_t>(type), sc<uint32_t>(flags), parseData());
return json; return json;
} }

View File

@@ -29,7 +29,7 @@ class CConfigValue {
} }
T* ptr() const { T* ptr() const {
return *(T* const*)p_; return *rc<T* const*>(p_);
} }
T operator*() const { T operator*() const {
@@ -48,26 +48,26 @@ inline std::string* CConfigValue<std::string>::ptr() const {
template <> template <>
inline std::string CConfigValue<std::string>::operator*() const { inline std::string CConfigValue<std::string>::operator*() const {
return std::string{*(Hyprlang::STRING*)p_}; return std::string{*rc<const Hyprlang::STRING*>(p_)};
} }
template <> template <>
inline Hyprlang::STRING* CConfigValue<Hyprlang::STRING>::ptr() const { inline Hyprlang::STRING* CConfigValue<Hyprlang::STRING>::ptr() const {
return (Hyprlang::STRING*)p_; return rc<Hyprlang::STRING*>(*p_);
} }
template <> template <>
inline Hyprlang::STRING CConfigValue<Hyprlang::STRING>::operator*() const { inline Hyprlang::STRING CConfigValue<Hyprlang::STRING>::operator*() const {
return *(Hyprlang::STRING*)p_; return *rc<const Hyprlang::STRING*>(p_);
} }
template <> template <>
inline Hyprlang::CUSTOMTYPE* CConfigValue<Hyprlang::CUSTOMTYPE>::ptr() const { inline Hyprlang::CUSTOMTYPE* CConfigValue<Hyprlang::CUSTOMTYPE>::ptr() const {
return *(Hyprlang::CUSTOMTYPE* const*)p_; return *rc<Hyprlang::CUSTOMTYPE* const*>(p_);
} }
template <> template <>
inline Hyprlang::CUSTOMTYPE CConfigValue<Hyprlang::CUSTOMTYPE>::operator*() const { inline Hyprlang::CUSTOMTYPE CConfigValue<Hyprlang::CUSTOMTYPE>::operator*() const {
RASSERT(false, "Impossible to implement operator* of CConfigValue<Hyprlang::CUSTOMTYPE>, use ptr()"); RASSERT(false, "Impossible to implement operator* of CConfigValue<Hyprlang::CUSTOMTYPE>, use ptr()");
return *ptr(); return *ptr();
} }

View File

@@ -72,15 +72,15 @@ void CConfigWatcher::onInotifyEvent() {
if (bytesRead <= 0) if (bytesRead <= 0)
return; return;
for (size_t offset = 0; offset < (size_t)bytesRead;) { for (size_t offset = 0; offset < sc<size_t>(bytesRead);) {
const auto* ev = (const inotify_event*)(buffer.data() + offset); const auto* ev = rc<const inotify_event*>(buffer.data() + offset);
if (offset + sizeof(inotify_event) > (size_t)bytesRead) { if (offset + sizeof(inotify_event) > sc<size_t>(bytesRead)) {
Debug::log(ERR, "CConfigWatcher: malformed inotify event, truncated header"); Debug::log(ERR, "CConfigWatcher: malformed inotify event, truncated header");
break; break;
} }
if (offset + sizeof(inotify_event) + ev->len > (size_t)(bytesRead)) { if (offset + sizeof(inotify_event) + ev->len > sc<size_t>(bytesRead)) {
Debug::log(ERR, "CConfigWatcher: malformed inotify event, truncated name field"); Debug::log(ERR, "CConfigWatcher: malformed inotify event, truncated name field");
break; break;
} }

View File

@@ -206,8 +206,8 @@ void NCrashReporter::createAndSaveCrash(int sig) {
// convert in memory address to VMA address // convert in memory address to VMA address
Dl_info info; Dl_info info;
struct link_map* linkMap; struct link_map* linkMap;
dladdr1((void*)CALLSTACK[i].adr, &info, (void**)&linkMap, RTLD_DL_LINKMAP); dladdr1(CALLSTACK[i].adr, &info, rc<void**>(&linkMap), RTLD_DL_LINKMAP);
size_t vmaAddr = (size_t)CALLSTACK[i].adr - linkMap->l_addr; size_t vmaAddr = rc<size_t>(CALLSTACK[i].adr) - linkMap->l_addr;
#else #else
// musl doesn't define dladdr1 // musl doesn't define dladdr1
size_t vmaAddr = (size_t)CALLSTACK[i].adr; size_t vmaAddr = (size_t)CALLSTACK[i].adr;

View File

@@ -155,12 +155,13 @@ std::string CHyprCtl::getMonitorData(Hyprutils::Memory::CSharedPointer<CMonitor>
}},)#", }},)#",
m->m_id, escapeJSONStrings(m->m_name), escapeJSONStrings(m->m_shortDescription), escapeJSONStrings(m->m_output->make), escapeJSONStrings(m->m_output->model), m->m_id, escapeJSONStrings(m->m_name), escapeJSONStrings(m->m_shortDescription), escapeJSONStrings(m->m_output->make), escapeJSONStrings(m->m_output->model),
escapeJSONStrings(m->m_output->serial), (int)m->m_pixelSize.x, m->m_pixelSize.y, (int)m->m_output->physicalSize.x, (int)m->m_output->physicalSize.y, m->m_refreshRate, escapeJSONStrings(m->m_output->serial), sc<int>(m->m_pixelSize.x), m->m_pixelSize.y, sc<int>(m->m_output->physicalSize.x), sc<int>(m->m_output->physicalSize.y),
(int)m->m_position.x, (int)m->m_position.y, m->activeWorkspaceID(), (!m->m_activeWorkspace ? "" : escapeJSONStrings(m->m_activeWorkspace->m_name)), m->m_refreshRate, sc<int>(m->m_position.x), sc<int>(m->m_position.y), m->activeWorkspaceID(),
m->activeSpecialWorkspaceID(), escapeJSONStrings(m->m_activeSpecialWorkspace ? m->m_activeSpecialWorkspace->m_name : ""), (int)m->m_reservedTopLeft.x, (!m->m_activeWorkspace ? "" : escapeJSONStrings(m->m_activeWorkspace->m_name)), m->activeSpecialWorkspaceID(),
(int)m->m_reservedTopLeft.y, (int)m->m_reservedBottomRight.x, (int)m->m_reservedBottomRight.y, m->m_scale, (int)m->m_transform, escapeJSONStrings(m->m_activeSpecialWorkspace ? m->m_activeSpecialWorkspace->m_name : ""), sc<int>(m->m_reservedTopLeft.x), sc<int>(m->m_reservedTopLeft.y),
(m == g_pCompositor->m_lastMonitor ? "true" : "false"), (m->m_dpmsStatus ? "true" : "false"), (m->m_output->state->state().adaptiveSync ? "true" : "false"), sc<int>(m->m_reservedBottomRight.x), sc<int>(m->m_reservedBottomRight.y), m->m_scale, sc<int>(m->m_transform), (m == g_pCompositor->m_lastMonitor ? "true" : "false"),
(uint64_t)m->m_solitaryClient.get(), (m->m_tearingState.activelyTearing ? "true" : "false"), (uint64_t)m->m_lastScanout.get(), (m->m_enabled ? "false" : "true"), (m->m_dpmsStatus ? "true" : "false"), (m->m_output->state->state().adaptiveSync ? "true" : "false"), rc<uint64_t>(m->m_solitaryClient.get()),
(m->m_tearingState.activelyTearing ? "true" : "false"), rc<uint64_t>(m->m_lastScanout.get()), (m->m_enabled ? "false" : "true"),
formatToString(m->m_output->state->state().drmFormat), m->m_mirrorOf ? std::format("{}", m->m_mirrorOf->m_id) : "none", availableModesForOutput(m, format)); formatToString(m->m_output->state->state().drmFormat), m->m_mirrorOf ? std::format("{}", m->m_mirrorOf->m_id) : "none", availableModesForOutput(m, format));
} else { } else {
@@ -169,13 +170,13 @@ std::string CHyprCtl::getMonitorData(Hyprutils::Memory::CSharedPointer<CMonitor>
"special workspace: {} ({})\n\treserved: {} {} {} {}\n\tscale: {:.2f}\n\ttransform: {}\n\tfocused: {}\n\t" "special workspace: {} ({})\n\treserved: {} {} {} {}\n\tscale: {:.2f}\n\ttransform: {}\n\tfocused: {}\n\t"
"dpmsStatus: {}\n\tvrr: {}\n\tsolitary: {:x}\n\tactivelyTearing: {}\n\tdirectScanoutTo: {:x}\n\tdisabled: {}\n\tcurrentFormat: {}\n\tmirrorOf: " "dpmsStatus: {}\n\tvrr: {}\n\tsolitary: {:x}\n\tactivelyTearing: {}\n\tdirectScanoutTo: {:x}\n\tdisabled: {}\n\tcurrentFormat: {}\n\tmirrorOf: "
"{}\n\tavailableModes: {}\n\n", "{}\n\tavailableModes: {}\n\n",
m->m_name, m->m_id, (int)m->m_pixelSize.x, (int)m->m_pixelSize.y, m->m_refreshRate, (int)m->m_position.x, (int)m->m_position.y, m->m_shortDescription, m->m_name, m->m_id, sc<int>(m->m_pixelSize.x), sc<int>(m->m_pixelSize.y), m->m_refreshRate, sc<int>(m->m_position.x), sc<int>(m->m_position.y), m->m_shortDescription,
m->m_output->make, m->m_output->model, (int)m->m_output->physicalSize.x, (int)m->m_output->physicalSize.y, m->m_output->serial, m->activeWorkspaceID(), m->m_output->make, m->m_output->model, sc<int>(m->m_output->physicalSize.x), sc<int>(m->m_output->physicalSize.y), m->m_output->serial, m->activeWorkspaceID(),
(!m->m_activeWorkspace ? "" : m->m_activeWorkspace->m_name), m->activeSpecialWorkspaceID(), (m->m_activeSpecialWorkspace ? m->m_activeSpecialWorkspace->m_name : ""), (!m->m_activeWorkspace ? "" : m->m_activeWorkspace->m_name), m->activeSpecialWorkspaceID(), (m->m_activeSpecialWorkspace ? m->m_activeSpecialWorkspace->m_name : ""),
(int)m->m_reservedTopLeft.x, (int)m->m_reservedTopLeft.y, (int)m->m_reservedBottomRight.x, (int)m->m_reservedBottomRight.y, m->m_scale, (int)m->m_transform, sc<int>(m->m_reservedTopLeft.x), sc<int>(m->m_reservedTopLeft.y), sc<int>(m->m_reservedBottomRight.x), sc<int>(m->m_reservedBottomRight.y), m->m_scale,
(m == g_pCompositor->m_lastMonitor ? "yes" : "no"), (int)m->m_dpmsStatus, m->m_output->state->state().adaptiveSync, (uint64_t)m->m_solitaryClient.get(), sc<int>(m->m_transform), (m == g_pCompositor->m_lastMonitor ? "yes" : "no"), sc<int>(m->m_dpmsStatus), m->m_output->state->state().adaptiveSync,
m->m_tearingState.activelyTearing, (uint64_t)m->m_lastScanout.get(), !m->m_enabled, formatToString(m->m_output->state->state().drmFormat), rc<uint64_t>(m->m_solitaryClient.get()), m->m_tearingState.activelyTearing, rc<uint64_t>(m->m_lastScanout.get()), !m->m_enabled,
m->m_mirrorOf ? std::format("{}", m->m_mirrorOf->m_id) : "none", availableModesForOutput(m, format)); formatToString(m->m_output->state->state().drmFormat), m->m_mirrorOf ? std::format("{}", m->m_mirrorOf->m_id) : "none", availableModesForOutput(m, format));
} }
return result; return result;
@@ -235,9 +236,9 @@ static std::string getGroupedData(PHLWINDOW w, eHyprCtlOutputFormat format) {
PHLWINDOW curr = head; PHLWINDOW curr = head;
while (true) { while (true) {
if (isJson) if (isJson)
result << std::format("\"0x{:x}\"", (uintptr_t)curr.get()); result << std::format("\"0x{:x}\"", rc<uintptr_t>(curr.get()));
else else
result << std::format("{:x}", (uintptr_t)curr.get()); result << std::format("{:x}", rc<uintptr_t>(curr.get()));
curr = curr->m_groupData.pNextWindow.lock(); curr = curr->m_groupData.pNextWindow.lock();
// We've wrapped around to the start, break out without trailing comma // We've wrapped around to the start, break out without trailing comma
if (curr == head) if (curr == head)
@@ -289,12 +290,12 @@ std::string CHyprCtl::getWindowData(PHLWINDOW w, eHyprCtlOutputFormat format) {
"xdgTag": "{}", "xdgTag": "{}",
"xdgDescription": "{}" "xdgDescription": "{}"
}},)#", }},)#",
(uintptr_t)w.get(), (w->m_isMapped ? "true" : "false"), (w->isHidden() ? "true" : "false"), (int)w->m_realPosition->goal().x, (int)w->m_realPosition->goal().y, rc<uintptr_t>(w.get()), (w->m_isMapped ? "true" : "false"), (w->isHidden() ? "true" : "false"), sc<int>(w->m_realPosition->goal().x),
(int)w->m_realSize->goal().x, (int)w->m_realSize->goal().y, w->m_workspace ? w->workspaceID() : WORKSPACE_INVALID, sc<int>(w->m_realPosition->goal().y), sc<int>(w->m_realSize->goal().x), sc<int>(w->m_realSize->goal().y), w->m_workspace ? w->workspaceID() : WORKSPACE_INVALID,
escapeJSONStrings(!w->m_workspace ? "" : w->m_workspace->m_name), ((int)w->m_isFloating == 1 ? "true" : "false"), (w->m_isPseudotiled ? "true" : "false"), escapeJSONStrings(!w->m_workspace ? "" : w->m_workspace->m_name), (sc<int>(w->m_isFloating) == 1 ? "true" : "false"), (w->m_isPseudotiled ? "true" : "false"),
(int64_t)w->monitorID(), escapeJSONStrings(w->m_class), escapeJSONStrings(w->m_title), escapeJSONStrings(w->m_initialClass), escapeJSONStrings(w->m_initialTitle), w->monitorID(), escapeJSONStrings(w->m_class), escapeJSONStrings(w->m_title), escapeJSONStrings(w->m_initialClass), escapeJSONStrings(w->m_initialTitle), w->getPID(),
w->getPID(), ((int)w->m_isX11 == 1 ? "true" : "false"), (w->m_pinned ? "true" : "false"), (uint8_t)w->m_fullscreenState.internal, (uint8_t)w->m_fullscreenState.client, (sc<int>(w->m_isX11) == 1 ? "true" : "false"), (w->m_pinned ? "true" : "false"), sc<uint8_t>(w->m_fullscreenState.internal), sc<uint8_t>(w->m_fullscreenState.client),
getGroupedData(w, format), getTagsData(w, format), (uintptr_t)w->m_swallowed.get(), getFocusHistoryID(w), getGroupedData(w, format), getTagsData(w, format), rc<uintptr_t>(w->m_swallowed.get()), getFocusHistoryID(w),
(g_pInputManager->isWindowInhibiting(w, false) ? "true" : "false"), escapeJSONStrings(w->xdgTag().value_or("")), escapeJSONStrings(w->xdgDescription().value_or(""))); (g_pInputManager->isWindowInhibiting(w, false) ? "true" : "false"), escapeJSONStrings(w->xdgTag().value_or("")), escapeJSONStrings(w->xdgDescription().value_or("")));
} else { } else {
return std::format( return std::format(
@@ -303,11 +304,12 @@ std::string CHyprCtl::getWindowData(PHLWINDOW w, eHyprCtlOutputFormat format) {
"{}\n\txwayland: {}\n\tpinned: " "{}\n\txwayland: {}\n\tpinned: "
"{}\n\tfullscreen: {}\n\tfullscreenClient: {}\n\tgrouped: {}\n\ttags: {}\n\tswallowing: {:x}\n\tfocusHistoryID: {}\n\tinhibitingIdle: {}\n\txdgTag: " "{}\n\tfullscreen: {}\n\tfullscreenClient: {}\n\tgrouped: {}\n\ttags: {}\n\tswallowing: {:x}\n\tfocusHistoryID: {}\n\tinhibitingIdle: {}\n\txdgTag: "
"{}\n\txdgDescription: {}\n\n", "{}\n\txdgDescription: {}\n\n",
(uintptr_t)w.get(), w->m_title, (int)w->m_isMapped, (int)w->isHidden(), (int)w->m_realPosition->goal().x, (int)w->m_realPosition->goal().y, rc<uintptr_t>(w.get()), w->m_title, sc<int>(w->m_isMapped), sc<int>(w->isHidden()), sc<int>(w->m_realPosition->goal().x), sc<int>(w->m_realPosition->goal().y),
(int)w->m_realSize->goal().x, (int)w->m_realSize->goal().y, w->m_workspace ? w->workspaceID() : WORKSPACE_INVALID, (!w->m_workspace ? "" : w->m_workspace->m_name), sc<int>(w->m_realSize->goal().x), sc<int>(w->m_realSize->goal().y), w->m_workspace ? w->workspaceID() : WORKSPACE_INVALID,
(int)w->m_isFloating, (int)w->m_isPseudotiled, (int64_t)w->monitorID(), w->m_class, w->m_title, w->m_initialClass, w->m_initialTitle, w->getPID(), (int)w->m_isX11, (!w->m_workspace ? "" : w->m_workspace->m_name), sc<int>(w->m_isFloating), sc<int>(w->m_isPseudotiled), w->monitorID(), w->m_class, w->m_title, w->m_initialClass,
(int)w->m_pinned, (uint8_t)w->m_fullscreenState.internal, (uint8_t)w->m_fullscreenState.client, getGroupedData(w, format), getTagsData(w, format), w->m_initialTitle, w->getPID(), sc<int>(w->m_isX11), sc<int>(w->m_pinned), sc<uint8_t>(w->m_fullscreenState.internal), sc<uint8_t>(w->m_fullscreenState.client),
(uintptr_t)w->m_swallowed.get(), getFocusHistoryID(w), (int)g_pInputManager->isWindowInhibiting(w, false), w->xdgTag().value_or(""), w->xdgDescription().value_or("")); getGroupedData(w, format), getTagsData(w, format), rc<uintptr_t>(w->m_swallowed.get()), getFocusHistoryID(w), sc<int>(g_pInputManager->isWindowInhibiting(w, false)),
w->xdgTag().value_or(""), w->xdgDescription().value_or(""));
} }
} }
@@ -357,12 +359,12 @@ std::string CHyprCtl::getWorkspaceData(PHLWORKSPACE w, eHyprCtlOutputFormat form
}})#", }})#",
w->m_id, escapeJSONStrings(w->m_name), escapeJSONStrings(PMONITOR ? PMONITOR->m_name : "?"), w->m_id, escapeJSONStrings(w->m_name), escapeJSONStrings(PMONITOR ? PMONITOR->m_name : "?"),
escapeJSONStrings(PMONITOR ? std::to_string(PMONITOR->m_id) : "null"), w->getWindows(), w->m_hasFullscreenWindow ? "true" : "false", escapeJSONStrings(PMONITOR ? std::to_string(PMONITOR->m_id) : "null"), w->getWindows(), w->m_hasFullscreenWindow ? "true" : "false",
(uintptr_t)PLASTW.get(), PLASTW ? escapeJSONStrings(PLASTW->m_title) : "", w->isPersistent() ? "true" : "false"); rc<uintptr_t>(PLASTW.get()), PLASTW ? escapeJSONStrings(PLASTW->m_title) : "", w->isPersistent() ? "true" : "false");
} else { } else {
return std::format( return std::format(
"workspace ID {} ({}) on monitor {}:\n\tmonitorID: {}\n\twindows: {}\n\thasfullscreen: {}\n\tlastwindow: 0x{:x}\n\tlastwindowtitle: {}\n\tispersistent: {}\n\n", "workspace ID {} ({}) on monitor {}:\n\tmonitorID: {}\n\twindows: {}\n\thasfullscreen: {}\n\tlastwindow: 0x{:x}\n\tlastwindowtitle: {}\n\tispersistent: {}\n\n",
w->m_id, w->m_name, PMONITOR ? PMONITOR->m_name : "?", PMONITOR ? std::to_string(PMONITOR->m_id) : "null", w->getWindows(), (int)w->m_hasFullscreenWindow, w->m_id, w->m_name, PMONITOR ? PMONITOR->m_name : "?", PMONITOR ? std::to_string(PMONITOR->m_id) : "null", w->getWindows(), sc<int>(w->m_hasFullscreenWindow),
(uintptr_t)PLASTW.get(), PLASTW ? PLASTW->m_title : "", (int)w->isPersistent()); rc<uintptr_t>(PLASTW.get()), PLASTW ? PLASTW->m_title : "", sc<int>(w->isPersistent()));
} }
} }
@@ -370,19 +372,19 @@ static std::string getWorkspaceRuleData(const SWorkspaceRule& r, eHyprCtlOutputF
const auto boolToString = [](const bool b) -> std::string { return b ? "true" : "false"; }; const auto boolToString = [](const bool b) -> std::string { return b ? "true" : "false"; };
if (format == eHyprCtlOutputFormat::FORMAT_JSON) { if (format == eHyprCtlOutputFormat::FORMAT_JSON) {
const std::string monitor = r.monitor.empty() ? "" : std::format(",\n \"monitor\": \"{}\"", escapeJSONStrings(r.monitor)); const std::string monitor = r.monitor.empty() ? "" : std::format(",\n \"monitor\": \"{}\"", escapeJSONStrings(r.monitor));
const std::string default_ = (bool)(r.isDefault) ? std::format(",\n \"default\": {}", boolToString(r.isDefault)) : ""; const std::string default_ = sc<bool>(r.isDefault) ? std::format(",\n \"default\": {}", boolToString(r.isDefault)) : "";
const std::string persistent = (bool)(r.isPersistent) ? std::format(",\n \"persistent\": {}", boolToString(r.isPersistent)) : ""; const std::string persistent = sc<bool>(r.isPersistent) ? std::format(",\n \"persistent\": {}", boolToString(r.isPersistent)) : "";
const std::string gapsIn = (bool)(r.gapsIn) ? const std::string gapsIn = sc<bool>(r.gapsIn) ?
std::format(",\n \"gapsIn\": [{}, {}, {}, {}]", r.gapsIn.value().m_top, r.gapsIn.value().m_right, r.gapsIn.value().m_bottom, r.gapsIn.value().m_left) : std::format(",\n \"gapsIn\": [{}, {}, {}, {}]", r.gapsIn.value().m_top, r.gapsIn.value().m_right, r.gapsIn.value().m_bottom, r.gapsIn.value().m_left) :
""; "";
const std::string gapsOut = (bool)(r.gapsOut) ? const std::string gapsOut = sc<bool>(r.gapsOut) ?
std::format(",\n \"gapsOut\": [{}, {}, {}, {}]", r.gapsOut.value().m_top, r.gapsOut.value().m_right, r.gapsOut.value().m_bottom, r.gapsOut.value().m_left) : std::format(",\n \"gapsOut\": [{}, {}, {}, {}]", r.gapsOut.value().m_top, r.gapsOut.value().m_right, r.gapsOut.value().m_bottom, r.gapsOut.value().m_left) :
""; "";
const std::string borderSize = (bool)(r.borderSize) ? std::format(",\n \"borderSize\": {}", r.borderSize.value()) : ""; const std::string borderSize = sc<bool>(r.borderSize) ? std::format(",\n \"borderSize\": {}", r.borderSize.value()) : "";
const std::string border = (bool)(r.noBorder) ? std::format(",\n \"border\": {}", boolToString(!r.noBorder.value())) : ""; const std::string border = sc<bool>(r.noBorder) ? std::format(",\n \"border\": {}", boolToString(!r.noBorder.value())) : "";
const std::string rounding = (bool)(r.noRounding) ? std::format(",\n \"rounding\": {}", boolToString(!r.noRounding.value())) : ""; const std::string rounding = sc<bool>(r.noRounding) ? std::format(",\n \"rounding\": {}", boolToString(!r.noRounding.value())) : "";
const std::string decorate = (bool)(r.decorate) ? std::format(",\n \"decorate\": {}", boolToString(r.decorate.value())) : ""; const std::string decorate = sc<bool>(r.decorate) ? std::format(",\n \"decorate\": {}", boolToString(r.decorate.value())) : "";
const std::string shadow = (bool)(r.noShadow) ? std::format(",\n \"shadow\": {}", boolToString(!r.noShadow.value())) : ""; const std::string shadow = sc<bool>(r.noShadow) ? std::format(",\n \"shadow\": {}", boolToString(!r.noShadow.value())) : "";
const std::string defaultName = r.defaultName.has_value() ? std::format(",\n \"defaultName\": \"{}\"", escapeJSONStrings(r.defaultName.value())) : ""; const std::string defaultName = r.defaultName.has_value() ? std::format(",\n \"defaultName\": \"{}\"", escapeJSONStrings(r.defaultName.value())) : "";
std::string result = std::string result =
@@ -394,19 +396,20 @@ static std::string getWorkspaceRuleData(const SWorkspaceRule& r, eHyprCtlOutputF
return result; return result;
} else { } else {
const std::string monitor = std::format("\tmonitor: {}\n", r.monitor.empty() ? "<unset>" : escapeJSONStrings(r.monitor)); const std::string monitor = std::format("\tmonitor: {}\n", r.monitor.empty() ? "<unset>" : escapeJSONStrings(r.monitor));
const std::string default_ = std::format("\tdefault: {}\n", (bool)(r.isDefault) ? boolToString(r.isDefault) : "<unset>"); const std::string default_ = std::format("\tdefault: {}\n", sc<bool>(r.isDefault) ? boolToString(r.isDefault) : "<unset>");
const std::string persistent = std::format("\tpersistent: {}\n", (bool)(r.isPersistent) ? boolToString(r.isPersistent) : "<unset>"); const std::string persistent = std::format("\tpersistent: {}\n", sc<bool>(r.isPersistent) ? boolToString(r.isPersistent) : "<unset>");
const std::string gapsIn = (bool)(r.gapsIn) ? std::format("\tgapsIn: {} {} {} {}\n", std::to_string(r.gapsIn.value().m_top), std::to_string(r.gapsIn.value().m_right), const std::string gapsIn = sc<bool>(r.gapsIn) ? std::format("\tgapsIn: {} {} {} {}\n", std::to_string(r.gapsIn.value().m_top), std::to_string(r.gapsIn.value().m_right),
std::to_string(r.gapsIn.value().m_bottom), std::to_string(r.gapsIn.value().m_left)) : std::to_string(r.gapsIn.value().m_bottom), std::to_string(r.gapsIn.value().m_left)) :
std::format("\tgapsIn: <unset>\n"); std::format("\tgapsIn: <unset>\n");
const std::string gapsOut = (bool)(r.gapsOut) ? std::format("\tgapsOut: {} {} {} {}\n", std::to_string(r.gapsOut.value().m_top), std::to_string(r.gapsOut.value().m_right), const std::string gapsOut = sc<bool>(r.gapsOut) ?
std::to_string(r.gapsOut.value().m_bottom), std::to_string(r.gapsOut.value().m_left)) : std::format("\tgapsOut: {} {} {} {}\n", std::to_string(r.gapsOut.value().m_top), std::to_string(r.gapsOut.value().m_right), std::to_string(r.gapsOut.value().m_bottom),
std::format("\tgapsOut: <unset>\n"); std::to_string(r.gapsOut.value().m_left)) :
const std::string borderSize = std::format("\tborderSize: {}\n", (bool)(r.borderSize) ? std::to_string(r.borderSize.value()) : "<unset>"); std::format("\tgapsOut: <unset>\n");
const std::string border = std::format("\tborder: {}\n", (bool)(r.noBorder) ? boolToString(!r.noBorder.value()) : "<unset>"); const std::string borderSize = std::format("\tborderSize: {}\n", sc<bool>(r.borderSize) ? std::to_string(r.borderSize.value()) : "<unset>");
const std::string rounding = std::format("\trounding: {}\n", (bool)(r.noRounding) ? boolToString(!r.noRounding.value()) : "<unset>"); const std::string border = std::format("\tborder: {}\n", sc<bool>(r.noBorder) ? boolToString(!r.noBorder.value()) : "<unset>");
const std::string decorate = std::format("\tdecorate: {}\n", (bool)(r.decorate) ? boolToString(r.decorate.value()) : "<unset>"); const std::string rounding = std::format("\trounding: {}\n", sc<bool>(r.noRounding) ? boolToString(!r.noRounding.value()) : "<unset>");
const std::string shadow = std::format("\tshadow: {}\n", (bool)(r.noShadow) ? boolToString(!r.noShadow.value()) : "<unset>"); const std::string decorate = std::format("\tdecorate: {}\n", sc<bool>(r.decorate) ? boolToString(r.decorate.value()) : "<unset>");
const std::string shadow = std::format("\tshadow: {}\n", sc<bool>(r.noShadow) ? boolToString(!r.noShadow.value()) : "<unset>");
const std::string defaultName = std::format("\tdefaultName: {}\n", r.defaultName.value_or("<unset>")); const std::string defaultName = std::format("\tdefaultName: {}\n", r.defaultName.value_or("<unset>"));
std::string result = std::format("Workspace rule {}:\n{}{}{}{}{}{}{}{}{}{}{}\n", escapeJSONStrings(r.workspaceString), monitor, default_, persistent, gapsIn, gapsOut, std::string result = std::format("Workspace rule {}:\n{}{}{}{}{}{}{}{}{}{}{}\n", escapeJSONStrings(r.workspaceString), monitor, default_, persistent, gapsIn, gapsOut,
@@ -515,8 +518,8 @@ static std::string layersRequest(eHyprCtlOutputFormat format, std::string reques
"namespace": "{}", "namespace": "{}",
"pid": {} "pid": {}
}},)#", }},)#",
(uintptr_t)layer.get(), layer->m_geometry.x, layer->m_geometry.y, layer->m_geometry.width, layer->m_geometry.height, escapeJSONStrings(layer->m_namespace), rc<uintptr_t>(layer.get()), layer->m_geometry.x, layer->m_geometry.y, layer->m_geometry.width, layer->m_geometry.height,
layer->getPID()); escapeJSONStrings(layer->m_namespace), layer->getPID());
} }
trimTrailingComma(result); trimTrailingComma(result);
@@ -547,7 +550,7 @@ static std::string layersRequest(eHyprCtlOutputFormat format, std::string reques
result += std::format("\tLayer level {} ({}):\n", layerLevel, levelNames[layerLevel]); result += std::format("\tLayer level {} ({}):\n", layerLevel, levelNames[layerLevel]);
for (auto const& layer : level) { for (auto const& layer : level) {
result += std::format("\t\tLayer {:x}: xywh: {} {} {} {}, namespace: {}, pid: {}\n", (uintptr_t)layer.get(), layer->m_geometry.x, layer->m_geometry.y, result += std::format("\t\tLayer {:x}: xywh: {} {} {} {}, namespace: {}, pid: {}\n", rc<uintptr_t>(layer.get()), layer->m_geometry.x, layer->m_geometry.y,
layer->m_geometry.width, layer->m_geometry.height, layer->m_namespace, layer->getPID()); layer->m_geometry.width, layer->m_geometry.height, layer->m_namespace, layer->getPID());
} }
@@ -628,7 +631,7 @@ static std::string devicesRequest(eHyprCtlOutputFormat format, std::string reque
"name": "{}", "name": "{}",
"defaultSpeed": {:.5f} "defaultSpeed": {:.5f}
}},)#", }},)#",
(uintptr_t)m.get(), escapeJSONStrings(m->m_hlName), rc<uintptr_t>(m.get()), escapeJSONStrings(m->m_hlName),
m->aq() && m->aq()->getLibinputHandle() ? libinput_device_config_accel_get_default_speed(m->aq()->getLibinputHandle()) : 0.f); m->aq() && m->aq()->getLibinputHandle() ? libinput_device_config_accel_get_default_speed(m->aq()->getLibinputHandle()) : 0.f);
} }
@@ -652,7 +655,7 @@ static std::string devicesRequest(eHyprCtlOutputFormat format, std::string reque
"numLock": {}, "numLock": {},
"main": {} "main": {}
}},)#", }},)#",
(uintptr_t)k.get(), escapeJSONStrings(k->m_hlName), escapeJSONStrings(k->m_currentRules.rules), escapeJSONStrings(k->m_currentRules.model), rc<uintptr_t>(k.get()), escapeJSONStrings(k->m_hlName), escapeJSONStrings(k->m_currentRules.rules), escapeJSONStrings(k->m_currentRules.model),
escapeJSONStrings(k->m_currentRules.layout), escapeJSONStrings(k->m_currentRules.variant), escapeJSONStrings(k->m_currentRules.options), escapeJSONStrings(KM), escapeJSONStrings(k->m_currentRules.layout), escapeJSONStrings(k->m_currentRules.variant), escapeJSONStrings(k->m_currentRules.options), escapeJSONStrings(KM),
(getModState(k, XKB_MOD_NAME_CAPS) ? "true" : "false"), (getModState(k, XKB_MOD_NAME_NUM) ? "true" : "false"), (k->m_active ? "true" : "false")); (getModState(k, XKB_MOD_NAME_CAPS) ? "true" : "false"), (getModState(k, XKB_MOD_NAME_NUM) ? "true" : "false"), (k->m_active ? "true" : "false"));
} }
@@ -672,7 +675,7 @@ static std::string devicesRequest(eHyprCtlOutputFormat format, std::string reque
"name": "{}" "name": "{}"
}} }}
}},)#", }},)#",
(uintptr_t)d.get(), (uintptr_t)d->m_parent.get(), escapeJSONStrings(d->m_parent ? d->m_parent->m_hlName : "")); rc<uintptr_t>(d.get()), rc<uintptr_t>(d->m_parent.get()), escapeJSONStrings(d->m_parent ? d->m_parent->m_hlName : ""));
} }
for (auto const& d : g_pInputManager->m_tablets) { for (auto const& d : g_pInputManager->m_tablets) {
@@ -681,7 +684,7 @@ static std::string devicesRequest(eHyprCtlOutputFormat format, std::string reque
"address": "0x{:x}", "address": "0x{:x}",
"name": "{}" "name": "{}"
}},)#", }},)#",
(uintptr_t)d.get(), escapeJSONStrings(d->m_hlName)); rc<uintptr_t>(d.get()), escapeJSONStrings(d->m_hlName));
} }
for (auto const& d : g_pInputManager->m_tabletTools) { for (auto const& d : g_pInputManager->m_tabletTools) {
@@ -690,7 +693,7 @@ static std::string devicesRequest(eHyprCtlOutputFormat format, std::string reque
"address": "0x{:x}", "address": "0x{:x}",
"type": "tabletTool", "type": "tabletTool",
}},)#", }},)#",
(uintptr_t)d.get()); rc<uintptr_t>(d.get()));
} }
trimTrailingComma(result); trimTrailingComma(result);
@@ -704,7 +707,7 @@ static std::string devicesRequest(eHyprCtlOutputFormat format, std::string reque
"address": "0x{:x}", "address": "0x{:x}",
"name": "{}" "name": "{}"
}},)#", }},)#",
(uintptr_t)d.get(), escapeJSONStrings(d->m_hlName)); rc<uintptr_t>(d.get()), escapeJSONStrings(d->m_hlName));
} }
trimTrailingComma(result); trimTrailingComma(result);
@@ -718,7 +721,7 @@ static std::string devicesRequest(eHyprCtlOutputFormat format, std::string reque
"address": "0x{:x}", "address": "0x{:x}",
"name": "{}" "name": "{}"
}},)#", }},)#",
(uintptr_t)&d, escapeJSONStrings(d.pDevice ? d.pDevice->getName() : "")); rc<uintptr_t>(&d), escapeJSONStrings(d.pDevice ? d.pDevice->getName() : ""));
} }
trimTrailingComma(result); trimTrailingComma(result);
@@ -730,7 +733,7 @@ static std::string devicesRequest(eHyprCtlOutputFormat format, std::string reque
result += "mice:\n"; result += "mice:\n";
for (auto const& m : g_pInputManager->m_pointers) { for (auto const& m : g_pInputManager->m_pointers) {
result += std::format("\tMouse at {:x}:\n\t\t{}\n\t\t\tdefault speed: {:.5f}\n", (uintptr_t)m.get(), m->m_hlName, result += std::format("\tMouse at {:x}:\n\t\t{}\n\t\t\tdefault speed: {:.5f}\n", rc<uintptr_t>(m.get()), m->m_hlName,
(m->aq() && m->aq()->getLibinputHandle() ? libinput_device_config_accel_get_default_speed(m->aq()->getLibinputHandle()) : 0.f)); (m->aq() && m->aq()->getLibinputHandle() ? libinput_device_config_accel_get_default_speed(m->aq()->getLibinputHandle()) : 0.f));
} }
@@ -740,7 +743,7 @@ static std::string devicesRequest(eHyprCtlOutputFormat format, std::string reque
const auto KM = k->getActiveLayout(); const auto KM = k->getActiveLayout();
result += std::format("\tKeyboard at {:x}:\n\t\t{}\n\t\t\trules: r \"{}\", m \"{}\", l \"{}\", v \"{}\", o \"{}\"\n\t\t\tactive keymap: {}\n\t\t\tcapsLock: " result += std::format("\tKeyboard at {:x}:\n\t\t{}\n\t\t\trules: r \"{}\", m \"{}\", l \"{}\", v \"{}\", o \"{}\"\n\t\t\tactive keymap: {}\n\t\t\tcapsLock: "
"{}\n\t\t\tnumLock: {}\n\t\t\tmain: {}\n", "{}\n\t\t\tnumLock: {}\n\t\t\tmain: {}\n",
(uintptr_t)k.get(), k->m_hlName, k->m_currentRules.rules, k->m_currentRules.model, k->m_currentRules.layout, k->m_currentRules.variant, rc<uintptr_t>(k.get()), k->m_hlName, k->m_currentRules.rules, k->m_currentRules.model, k->m_currentRules.layout, k->m_currentRules.variant,
k->m_currentRules.options, KM, (getModState(k, XKB_MOD_NAME_CAPS) ? "yes" : "no"), (getModState(k, XKB_MOD_NAME_NUM) ? "yes" : "no"), k->m_currentRules.options, KM, (getModState(k, XKB_MOD_NAME_CAPS) ? "yes" : "no"), (getModState(k, XKB_MOD_NAME_NUM) ? "yes" : "no"),
(k->m_active ? "yes" : "no")); (k->m_active ? "yes" : "no"));
} }
@@ -748,27 +751,28 @@ static std::string devicesRequest(eHyprCtlOutputFormat format, std::string reque
result += "\n\nTablets:\n"; result += "\n\nTablets:\n";
for (auto const& d : g_pInputManager->m_tabletPads) { for (auto const& d : g_pInputManager->m_tabletPads) {
result += std::format("\tTablet Pad at {:x} (belongs to {:x} -> {})\n", (uintptr_t)d.get(), (uintptr_t)d->m_parent.get(), d->m_parent ? d->m_parent->m_hlName : ""); result +=
std::format("\tTablet Pad at {:x} (belongs to {:x} -> {})\n", rc<uintptr_t>(d.get()), rc<uintptr_t>(d->m_parent.get()), d->m_parent ? d->m_parent->m_hlName : "");
} }
for (auto const& d : g_pInputManager->m_tablets) { for (auto const& d : g_pInputManager->m_tablets) {
result += std::format("\tTablet at {:x}:\n\t\t{}\n\t\t\tsize: {}x{}mm\n", (uintptr_t)d.get(), d->m_hlName, d->aq()->physicalSize.x, d->aq()->physicalSize.y); result += std::format("\tTablet at {:x}:\n\t\t{}\n\t\t\tsize: {}x{}mm\n", rc<uintptr_t>(d.get()), d->m_hlName, d->aq()->physicalSize.x, d->aq()->physicalSize.y);
} }
for (auto const& d : g_pInputManager->m_tabletTools) { for (auto const& d : g_pInputManager->m_tabletTools) {
result += std::format("\tTablet Tool at {:x}\n", (uintptr_t)d.get()); result += std::format("\tTablet Tool at {:x}\n", rc<uintptr_t>(d.get()));
} }
result += "\n\nTouch:\n"; result += "\n\nTouch:\n";
for (auto const& d : g_pInputManager->m_touches) { for (auto const& d : g_pInputManager->m_touches) {
result += std::format("\tTouch Device at {:x}:\n\t\t{}\n", (uintptr_t)d.get(), d->m_hlName); result += std::format("\tTouch Device at {:x}:\n\t\t{}\n", rc<uintptr_t>(d.get()), d->m_hlName);
} }
result += "\n\nSwitches:\n"; result += "\n\nSwitches:\n";
for (auto const& d : g_pInputManager->m_switches) { for (auto const& d : g_pInputManager->m_switches) {
result += std::format("\tSwitch Device at {:x}:\n\t\t{}\n", (uintptr_t)&d, d.pDevice ? d.pDevice->getName() : ""); result += std::format("\tSwitch Device at {:x}:\n\t\t{}\n", rc<uintptr_t>(&d), d.pDevice ? d.pDevice->getName() : "");
} }
} }
@@ -781,7 +785,7 @@ static std::string animationsRequest(eHyprCtlOutputFormat format, std::string re
ret += "animations:\n"; ret += "animations:\n";
for (auto const& ac : g_pConfigManager->getAnimationConfig()) { for (auto const& ac : g_pConfigManager->getAnimationConfig()) {
ret += std::format("\n\tname: {}\n\t\toverriden: {}\n\t\tbezier: {}\n\t\tenabled: {}\n\t\tspeed: {:.2f}\n\t\tstyle: {}\n", ac.first, (int)ac.second->overridden, ret += std::format("\n\tname: {}\n\t\toverriden: {}\n\t\tbezier: {}\n\t\tenabled: {}\n\t\tspeed: {:.2f}\n\t\tstyle: {}\n", ac.first, sc<int>(ac.second->overridden),
ac.second->internalBezier, ac.second->internalEnabled, ac.second->internalSpeed, ac.second->internalStyle); ac.second->internalBezier, ac.second->internalEnabled, ac.second->internalSpeed, ac.second->internalStyle);
} }
@@ -1083,7 +1087,7 @@ std::string systemInfoRequest(eHyprCtlOutputFormat format, std::string request)
for (const auto& m : g_pCompositor->m_monitors) { for (const auto& m : g_pCompositor->m_monitors) {
result += std::format("\n\tPanel {}: {}x{}, {} {} {} {} -> backend {}\n\t\texplicit {}\n\t\tedid:\n\t\t\thdr {}\n\t\t\tchroma {}\n\t\t\tbt2020 {}\n\t\tvrr capable " result += std::format("\n\tPanel {}: {}x{}, {} {} {} {} -> backend {}\n\t\texplicit {}\n\t\tedid:\n\t\t\thdr {}\n\t\t\tchroma {}\n\t\t\tbt2020 {}\n\t\tvrr capable "
"{}\n\t\tnon-desktop {}\n\t\t", "{}\n\t\tnon-desktop {}\n\t\t",
m->m_name, (int)m->m_pixelSize.x, (int)m->m_pixelSize.y, m->m_output->name, m->m_output->make, m->m_output->model, m->m_output->serial, m->m_name, sc<int>(m->m_pixelSize.x), sc<int>(m->m_pixelSize.y), m->m_output->name, m->m_output->make, m->m_output->model, m->m_output->serial,
backend(m->m_output->getBackend()->type()), check(m->m_output->supportsExplicit), check(m->m_output->parsedEDID.hdrMetadata.has_value()), backend(m->m_output->getBackend()->type()), check(m->m_output->supportsExplicit), check(m->m_output->parsedEDID.hdrMetadata.has_value()),
check(m->m_output->parsedEDID.chromaticityCoords.has_value()), check(m->m_output->parsedEDID.supportsBT2020), check(m->m_output->vrrCapable), check(m->m_output->parsedEDID.chromaticityCoords.has_value()), check(m->m_output->parsedEDID.supportsBT2020), check(m->m_output->vrrCapable),
check(m->m_output->nonDesktop)); check(m->m_output->nonDesktop));
@@ -1105,7 +1109,7 @@ static std::string dispatchRequest(eHyprCtlOutputFormat format, std::string in)
const auto DISPATCHSTR = in.substr(0, in.find_first_of(' ')); const auto DISPATCHSTR = in.substr(0, in.find_first_of(' '));
auto DISPATCHARG = std::string(); auto DISPATCHARG = std::string();
if ((int)in.find_first_of(' ') != -1) if (sc<int>(in.find_first_of(' ')) != -1)
DISPATCHARG = in.substr(in.find_first_of(' ') + 1); DISPATCHARG = in.substr(in.find_first_of(' ') + 1);
const auto DISPATCHER = g_pKeybindManager->m_dispatchers.find(DISPATCHSTR); const auto DISPATCHER = g_pKeybindManager->m_dispatchers.find(DISPATCHSTR);
@@ -1222,7 +1226,7 @@ static std::string cursorPosRequest(eHyprCtlOutputFormat format, std::string req
const auto CURSORPOS = g_pInputManager->getMouseCoordsInternal().floor(); const auto CURSORPOS = g_pInputManager->getMouseCoordsInternal().floor();
if (format == eHyprCtlOutputFormat::FORMAT_NORMAL) { if (format == eHyprCtlOutputFormat::FORMAT_NORMAL) {
return std::format("{}, {}", (int)CURSORPOS.x, (int)CURSORPOS.y); return std::format("{}, {}", sc<int>(CURSORPOS.x), sc<int>(CURSORPOS.y));
} else { } else {
return std::format(R"#( return std::format(R"#(
{{ {{
@@ -1230,7 +1234,7 @@ static std::string cursorPosRequest(eHyprCtlOutputFormat format, std::string req
"y": {} "y": {}
}} }}
)#", )#",
(int)CURSORPOS.x, (int)CURSORPOS.y); sc<int>(CURSORPOS.x), sc<int>(CURSORPOS.y));
} }
return "error"; return "error";
@@ -1259,7 +1263,7 @@ static std::string dispatchBatch(eHyprCtlOutputFormat format, std::string reques
} }
} }
return reply.substr(0, std::max(static_cast<int>(reply.size() - DELIMITER.size()), 0)); return reply.substr(0, std::max(sc<int>(reply.size() - DELIMITER.size()), 0));
} }
static std::string dispatchSetCursor(eHyprCtlOutputFormat format, std::string request) { static std::string dispatchSetCursor(eHyprCtlOutputFormat format, std::string request) {
@@ -1315,7 +1319,7 @@ static std::string switchXKBLayoutRequest(eHyprCtlOutputFormat format, std::stri
requestedLayout = std::stoi(CMD); requestedLayout = std::stoi(CMD);
} catch (std::exception& e) { return "invalid arg 2"; } } catch (std::exception& e) { return "invalid arg 2"; }
if (requestedLayout < 0 || (uint64_t)requestedLayout > LAYOUTS - 1) { if (requestedLayout < 0 || sc<uint64_t>(requestedLayout) > LAYOUTS - 1) {
return "layout idx out of range of " + std::to_string(LAYOUTS); return "layout idx out of range of " + std::to_string(LAYOUTS);
} }
@@ -1433,7 +1437,7 @@ static std::string dispatchGetOption(eHyprCtlOutputFormat format, std::string re
else if (TYPE == typeid(Hyprlang::STRING)) else if (TYPE == typeid(Hyprlang::STRING))
return std::format("str: {}\nset: {}", std::any_cast<Hyprlang::STRING>(VAL), VAR->m_bSetByUser); return std::format("str: {}\nset: {}", std::any_cast<Hyprlang::STRING>(VAL), VAR->m_bSetByUser);
else if (TYPE == typeid(void*)) else if (TYPE == typeid(void*))
return std::format("custom type: {}\nset: {}", ((ICustomConfigValueData*)std::any_cast<void*>(VAL))->toString(), VAR->m_bSetByUser); return std::format("custom type: {}\nset: {}", sc<ICustomConfigValueData*>(std::any_cast<void*>(VAL))->toString(), VAR->m_bSetByUser);
} else { } else {
if (TYPE == typeid(Hyprlang::INT)) if (TYPE == typeid(Hyprlang::INT))
return std::format(R"({{"option": "{}", "int": {}, "set": {} }})", curitem, std::any_cast<Hyprlang::INT>(VAL), VAR->m_bSetByUser); return std::format(R"({{"option": "{}", "int": {}, "set": {} }})", curitem, std::any_cast<Hyprlang::INT>(VAL), VAR->m_bSetByUser);
@@ -1445,7 +1449,7 @@ static std::string dispatchGetOption(eHyprCtlOutputFormat format, std::string re
else if (TYPE == typeid(Hyprlang::STRING)) else if (TYPE == typeid(Hyprlang::STRING))
return std::format(R"({{"option": "{}", "str": "{}", "set": {} }})", curitem, escapeJSONStrings(std::any_cast<Hyprlang::STRING>(VAL)), VAR->m_bSetByUser); return std::format(R"({{"option": "{}", "str": "{}", "set": {} }})", curitem, escapeJSONStrings(std::any_cast<Hyprlang::STRING>(VAL)), VAR->m_bSetByUser);
else if (TYPE == typeid(void*)) else if (TYPE == typeid(void*))
return std::format(R"({{"option": "{}", "custom": "{}", "set": {} }})", curitem, ((ICustomConfigValueData*)std::any_cast<void*>(VAL))->toString(), VAR->m_bSetByUser); return std::format(R"({{"option": "{}", "custom": "{}", "set": {} }})", curitem, sc<ICustomConfigValueData*>(std::any_cast<void*>(VAL))->toString(), VAR->m_bSetByUser);
} }
return "invalid type (internal error)"; return "invalid type (internal error)";
@@ -1587,7 +1591,7 @@ static std::string dispatchPlugin(eHyprCtlOutputFormat format, std::string reque
"version": "{}", "version": "{}",
"description": "{}" "description": "{}"
}},)#", }},)#",
escapeJSONStrings(p->m_name), escapeJSONStrings(p->m_author), (uintptr_t)p->m_handle, escapeJSONStrings(p->m_version), escapeJSONStrings(p->m_description)); escapeJSONStrings(p->m_name), escapeJSONStrings(p->m_author), rc<uintptr_t>(p->m_handle), escapeJSONStrings(p->m_version), escapeJSONStrings(p->m_description));
} }
trimTrailingComma(result); trimTrailingComma(result);
result += "]"; result += "]";
@@ -1596,7 +1600,7 @@ static std::string dispatchPlugin(eHyprCtlOutputFormat format, std::string reque
return "no plugins loaded"; return "no plugins loaded";
for (auto const& p : PLUGINS) { for (auto const& p : PLUGINS) {
result += std::format("\nPlugin {} by {}:\n\tHandle: {:x}\n\tVersion: {}\n\tDescription: {}\n", p->m_name, p->m_author, (uintptr_t)p->m_handle, p->m_version, result += std::format("\nPlugin {} by {}:\n\tHandle: {:x}\n\tVersion: {}\n\tDescription: {}\n", p->m_name, p->m_author, rc<uintptr_t>(p->m_handle), p->m_version,
p->m_description); p->m_description);
} }
} }
@@ -1659,7 +1663,7 @@ static std::string dispatchNotify(eHyprCtlOutputFormat format, std::string reque
const auto MESSAGE = vars.join(" ", msgidx); const auto MESSAGE = vars.join(" ", msgidx);
g_pHyprNotificationOverlay->addNotification(MESSAGE, color, time, (eIcons)icon, fontsize); g_pHyprNotificationOverlay->addNotification(MESSAGE, color, time, sc<eIcons>(icon), fontsize);
return "ok"; return "ok";
} }
@@ -1937,7 +1941,7 @@ static int hyprCtlFDTick(int fd, uint32_t mask, void* data) {
sockaddr_in clientAddress; sockaddr_in clientAddress;
socklen_t clientSize = sizeof(clientAddress); socklen_t clientSize = sizeof(clientAddress);
const auto ACCEPTEDCONNECTION = accept4(g_pHyprCtl->m_socketFD.get(), (sockaddr*)&clientAddress, &clientSize, SOCK_CLOEXEC); const auto ACCEPTEDCONNECTION = accept4(g_pHyprCtl->m_socketFD.get(), rc<sockaddr*>(&clientAddress), &clientSize, SOCK_CLOEXEC);
std::array<char, 1024> readBuffer; std::array<char, 1024> readBuffer;
@@ -2033,7 +2037,7 @@ void CHyprCtl::startHyprCtlSocket() {
snprintf(SERVERADDRESS.sun_path, sizeof(SERVERADDRESS.sun_path), "%s", m_socketPath.c_str()); snprintf(SERVERADDRESS.sun_path, sizeof(SERVERADDRESS.sun_path), "%s", m_socketPath.c_str());
if (bind(m_socketFD.get(), (sockaddr*)&SERVERADDRESS, SUN_LEN(&SERVERADDRESS)) < 0) { if (bind(m_socketFD.get(), rc<sockaddr*>(&SERVERADDRESS), SUN_LEN(&SERVERADDRESS)) < 0) {
Debug::log(ERR, "Couldn't start the Hyprland Socket. (2) IPC will not work."); Debug::log(ERR, "Couldn't start the Hyprland Socket. (2) IPC will not work.");
return; return;
} }

View File

@@ -18,7 +18,7 @@ void CHyprMonitorDebugOverlay::renderData(PHLMONITOR pMonitor, float durationUs)
m_lastRenderTimes.emplace_back(durationUs / 1000.f); m_lastRenderTimes.emplace_back(durationUs / 1000.f);
if (m_lastRenderTimes.size() > (long unsigned int)pMonitor->m_refreshRate) if (m_lastRenderTimes.size() > sc<long unsigned int>(pMonitor->m_refreshRate))
m_lastRenderTimes.pop_front(); m_lastRenderTimes.pop_front();
if (!m_monitor) if (!m_monitor)
@@ -33,7 +33,7 @@ void CHyprMonitorDebugOverlay::renderDataNoOverlay(PHLMONITOR pMonitor, float du
m_lastRenderTimesNoOverlay.emplace_back(durationUs / 1000.f); m_lastRenderTimesNoOverlay.emplace_back(durationUs / 1000.f);
if (m_lastRenderTimesNoOverlay.size() > (long unsigned int)pMonitor->m_refreshRate) if (m_lastRenderTimesNoOverlay.size() > sc<long unsigned int>(pMonitor->m_refreshRate))
m_lastRenderTimesNoOverlay.pop_front(); m_lastRenderTimesNoOverlay.pop_front();
if (!m_monitor) if (!m_monitor)
@@ -48,7 +48,7 @@ void CHyprMonitorDebugOverlay::frameData(PHLMONITOR pMonitor) {
m_lastFrametimes.emplace_back(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - m_lastFrame).count() / 1000.f); m_lastFrametimes.emplace_back(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - m_lastFrame).count() / 1000.f);
if (m_lastFrametimes.size() > (long unsigned int)pMonitor->m_refreshRate) if (m_lastFrametimes.size() > sc<long unsigned int>(pMonitor->m_refreshRate))
m_lastFrametimes.pop_front(); m_lastFrametimes.pop_front();
m_lastFrame = std::chrono::high_resolution_clock::now(); m_lastFrame = std::chrono::high_resolution_clock::now();
@@ -59,7 +59,7 @@ void CHyprMonitorDebugOverlay::frameData(PHLMONITOR pMonitor) {
// anim data too // anim data too
const auto PMONITORFORTICKS = g_pHyprRenderer->m_mostHzMonitor ? g_pHyprRenderer->m_mostHzMonitor.lock() : g_pCompositor->m_lastMonitor.lock(); const auto PMONITORFORTICKS = g_pHyprRenderer->m_mostHzMonitor ? g_pHyprRenderer->m_mostHzMonitor.lock() : g_pCompositor->m_lastMonitor.lock();
if (PMONITORFORTICKS == pMonitor) { if (PMONITORFORTICKS == pMonitor) {
if (m_lastAnimationTicks.size() > (long unsigned int)PMONITORFORTICKS->m_refreshRate) if (m_lastAnimationTicks.size() > sc<long unsigned int>(PMONITORFORTICKS->m_refreshRate))
m_lastAnimationTicks.pop_front(); m_lastAnimationTicks.pop_front();
m_lastAnimationTicks.push_back(g_pAnimationManager->m_lastTickTimeMs); m_lastAnimationTicks.push_back(g_pAnimationManager->m_lastTickTimeMs);
@@ -175,7 +175,7 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
else else
cairo_set_source_rgba(g_pDebugOverlay->m_cairo, 1.f, 0.2f, 0.2f, 1.f); cairo_set_source_rgba(g_pDebugOverlay->m_cairo, 1.f, 0.2f, 0.2f, 1.f);
text = std::format("{} FPS", (int)FPS); text = std::format("{} FPS", sc<int>(FPS));
showText(text.c_str(), 16); showText(text.c_str(), 16);
cairo_set_source_rgba(g_pDebugOverlay->m_cairo, 1.f, 1.f, 1.f, 1.f); cairo_set_source_rgba(g_pDebugOverlay->m_cairo, 1.f, 1.f, 1.f, 1.f);
@@ -199,8 +199,8 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
cairo_get_current_point(cr, &posX, &posY); cairo_get_current_point(cr, &posX, &posY);
g_pHyprRenderer->damageBox(m_lastDrawnBox); g_pHyprRenderer->damageBox(m_lastDrawnBox);
m_lastDrawnBox = {(int)g_pCompositor->m_monitors.front()->m_position.x + MARGIN_LEFT - 1, (int)g_pCompositor->m_monitors.front()->m_position.y + offset + MARGIN_TOP - 1, m_lastDrawnBox = {sc<int>(g_pCompositor->m_monitors.front()->m_position.x) + MARGIN_LEFT - 1,
(int)maxTextW + 2, posY - offset - MARGIN_TOP + 2}; sc<int>(g_pCompositor->m_monitors.front()->m_position.y) + offset + MARGIN_TOP - 1, sc<int>(maxTextW) + 2, posY - offset - MARGIN_TOP + 2};
g_pHyprRenderer->damageBox(m_lastDrawnBox); g_pHyprRenderer->damageBox(m_lastDrawnBox);
return posY - offset; return posY - offset;

View File

@@ -58,7 +58,7 @@ void CHyprNotificationOverlay::dismissNotifications(const int amount) {
if (amount == -1) if (amount == -1)
m_notifications.clear(); m_notifications.clear();
else { else {
const int AMT = std::min(amount, static_cast<int>(m_notifications.size())); const int AMT = std::min(amount, sc<int>(m_notifications.size()));
for (int i = 0; i < AMT; ++i) { for (int i = 0; i < AMT; ++i) {
m_notifications.erase(m_notifications.begin()); m_notifications.erase(m_notifications.begin());
@@ -94,7 +94,7 @@ CBox CHyprNotificationOverlay::drawNotifications(PHLMONITOR pMonitor) {
for (auto const& notif : m_notifications) { for (auto const& notif : m_notifications) {
const auto ICONPADFORNOTIF = notif->icon == ICON_NONE ? 0 : ICON_PAD; const auto ICONPADFORNOTIF = notif->icon == ICON_NONE ? 0 : ICON_PAD;
const auto FONTSIZE = std::clamp((int)(notif->fontSize * ((pMonitor->m_pixelSize.x * SCALE) / 1920.f)), 8, 40); const auto FONTSIZE = std::clamp(sc<int>(notif->fontSize * ((pMonitor->m_pixelSize.x * SCALE) / 1920.f)), 8, 40);
// first rect (bg, col) // first rect (bg, col)
const float FIRSTRECTANIMP = const float FIRSTRECTANIMP =
@@ -189,7 +189,7 @@ CBox CHyprNotificationOverlay::drawNotifications(PHLMONITOR pMonitor) {
// cleanup notifs // cleanup notifs
std::erase_if(m_notifications, [](const auto& notif) { return notif->started.getMillis() > notif->timeMs; }); std::erase_if(m_notifications, [](const auto& notif) { return notif->started.getMillis() > notif->timeMs; });
return CBox{(int)(pMonitor->m_position.x + pMonitor->m_size.x - maxWidth - 20), (int)pMonitor->m_position.y, (int)maxWidth + 20, (int)offsetY + 10}; return CBox{sc<int>(pMonitor->m_position.x + pMonitor->m_size.x - maxWidth - 20), sc<int>(pMonitor->m_position.y), sc<int>(maxWidth) + 20, sc<int>(offsetY) + 10};
} }
void CHyprNotificationOverlay::draw(PHLMONITOR pMonitor) { void CHyprNotificationOverlay::draw(PHLMONITOR pMonitor) {

View File

@@ -46,7 +46,8 @@ PHLLS CLayerSurface::create(SP<CLayerShellResource> resource) {
pLS->m_alpha->setValueAndWarp(0.f); pLS->m_alpha->setValueAndWarp(0.f);
Debug::log(LOG, "LayerSurface {:x} (namespace {} layer {}) created on monitor {}", (uintptr_t)resource.get(), resource->m_layerNamespace, (int)pLS->m_layer, pMonitor->m_name); Debug::log(LOG, "LayerSurface {:x} (namespace {} layer {}) created on monitor {}", rc<uintptr_t>(resource.get()), resource->m_layerNamespace, sc<int>(pLS->m_layer),
pMonitor->m_name);
return pLS; return pLS;
} }
@@ -84,7 +85,7 @@ CLayerSurface::~CLayerSurface() {
} }
void CLayerSurface::onDestroy() { void CLayerSurface::onDestroy() {
Debug::log(LOG, "LayerSurface {:x} destroyed", (uintptr_t)m_layerSurface.get()); Debug::log(LOG, "LayerSurface {:x} destroyed", rc<uintptr_t>(m_layerSurface.get()));
const auto PMONITOR = m_monitor.lock(); const auto PMONITOR = m_monitor.lock();
@@ -130,7 +131,7 @@ void CLayerSurface::onDestroy() {
} }
void CLayerSurface::onMap() { void CLayerSurface::onMap() {
Debug::log(LOG, "LayerSurface {:x} mapped", (uintptr_t)m_layerSurface.get()); Debug::log(LOG, "LayerSurface {:x} mapped", rc<uintptr_t>(m_layerSurface.get()));
m_mapped = true; m_mapped = true;
m_interactivity = m_layerSurface->m_current.interactivity; m_interactivity = m_layerSurface->m_current.interactivity;
@@ -196,7 +197,7 @@ void CLayerSurface::onMap() {
} }
void CLayerSurface::onUnmap() { void CLayerSurface::onUnmap() {
Debug::log(LOG, "LayerSurface {:x} unmapped", (uintptr_t)m_layerSurface.get()); Debug::log(LOG, "LayerSurface {:x} unmapped", rc<uintptr_t>(m_layerSurface.get()));
g_pEventManager->postEvent(SHyprIPCEvent{.event = "closelayer", .data = m_layerSurface->m_layerNamespace}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "closelayer", .data = m_layerSurface->m_layerNamespace});
EMIT_HOOK_EVENT("closeLayer", m_self.lock()); EMIT_HOOK_EVENT("closeLayer", m_self.lock());
@@ -249,8 +250,8 @@ void CLayerSurface::onUnmap() {
CBox geomFixed = {m_geometry.x + PMONITOR->m_position.x, m_geometry.y + PMONITOR->m_position.y, m_geometry.width, m_geometry.height}; CBox geomFixed = {m_geometry.x + PMONITOR->m_position.x, m_geometry.y + PMONITOR->m_position.y, m_geometry.width, m_geometry.height};
g_pHyprRenderer->damageBox(geomFixed); g_pHyprRenderer->damageBox(geomFixed);
geomFixed = {m_geometry.x + (int)PMONITOR->m_position.x, m_geometry.y + (int)PMONITOR->m_position.y, (int)m_layerSurface->m_surface->m_current.size.x, geomFixed = {m_geometry.x + sc<int>(PMONITOR->m_position.x), m_geometry.y + sc<int>(PMONITOR->m_position.y), sc<int>(m_layerSurface->m_surface->m_current.size.x),
(int)m_layerSurface->m_surface->m_current.size.y}; sc<int>(m_layerSurface->m_surface->m_current.size.y)};
g_pHyprRenderer->damageBox(geomFixed); g_pHyprRenderer->damageBox(geomFixed);
g_pInputManager->simulateMouseMovement(); g_pInputManager->simulateMouseMovement();
@@ -596,7 +597,7 @@ int CLayerSurface::popupsCount() {
return 0; return 0;
int no = -1; // we have one dummy int no = -1; // we have one dummy
m_popupHead->breadthfirst([](WP<CPopup> p, void* data) { *(int*)data += 1; }, &no); m_popupHead->breadthfirst([](WP<CPopup> p, void* data) { *sc<int*>(data) += 1; }, &no);
return no; return no;
} }

View File

@@ -90,7 +90,7 @@ void CPopup::initAllSignals() {
void CPopup::onNewPopup(SP<CXDGPopupResource> popup) { void CPopup::onNewPopup(SP<CXDGPopupResource> popup) {
const auto& POPUP = m_children.emplace_back(CPopup::create(popup, m_self)); const auto& POPUP = m_children.emplace_back(CPopup::create(popup, m_self));
POPUP->m_self = POPUP; POPUP->m_self = POPUP;
Debug::log(LOG, "New popup at {:x}", (uintptr_t)this); Debug::log(LOG, "New popup at {:x}", rc<uintptr_t>(this));
} }
void CPopup::onDestroy() { void CPopup::onDestroy() {
@@ -104,7 +104,7 @@ void CPopup::onDestroy() {
m_wlSurface.reset(); m_wlSurface.reset();
if (m_fadingOut && m_alpha->isBeingAnimated()) { if (m_fadingOut && m_alpha->isBeingAnimated()) {
Debug::log(LOG, "popup {:x}: skipping full destroy, animating", (uintptr_t)this); Debug::log(LOG, "popup {:x}: skipping full destroy, animating", rc<uintptr_t>(this));
return; return;
} }
@@ -112,7 +112,7 @@ void CPopup::onDestroy() {
} }
void CPopup::fullyDestroy() { void CPopup::fullyDestroy() {
Debug::log(LOG, "popup {:x} fully destroying", (uintptr_t)this); Debug::log(LOG, "popup {:x} fully destroying", rc<uintptr_t>(this));
g_pHyprRenderer->makeEGLCurrent(); g_pHyprRenderer->makeEGLCurrent();
std::erase_if(g_pHyprOpenGL->m_popupFramebuffers, [&](const auto& other) { return other.first.expired() || other.first == m_self; }); std::erase_if(g_pHyprOpenGL->m_popupFramebuffers, [&](const auto& other) { return other.first.expired() || other.first == m_self; });
@@ -151,7 +151,7 @@ void CPopup::onMap() {
m_alpha->setValueAndWarp(0.F); m_alpha->setValueAndWarp(0.F);
*m_alpha = 1.F; *m_alpha = 1.F;
Debug::log(LOG, "popup {:x}: mapped", (uintptr_t)this); Debug::log(LOG, "popup {:x}: mapped", rc<uintptr_t>(this));
} }
void CPopup::onUnmap() { void CPopup::onUnmap() {
@@ -164,7 +164,7 @@ void CPopup::onUnmap() {
return; return;
} }
Debug::log(LOG, "popup {:x}: unmapped", (uintptr_t)this); Debug::log(LOG, "popup {:x}: unmapped", rc<uintptr_t>(this));
// if the popup committed a different size right now, we also need to damage the old size. // if the popup committed a different size right now, we also need to damage the old size.
const Vector2D MAX_DAMAGE_SIZE = {std::max(m_lastSize.x, m_resource->m_surface->m_surface->m_current.size.x), const Vector2D MAX_DAMAGE_SIZE = {std::max(m_lastSize.x, m_resource->m_surface->m_surface->m_current.size.x),
@@ -266,7 +266,7 @@ void CPopup::onCommit(bool ignoreSiblings) {
} }
void CPopup::onReposition() { void CPopup::onReposition() {
Debug::log(LOG, "Popup {:x} requests reposition", (uintptr_t)this); Debug::log(LOG, "Popup {:x} requests reposition", rc<uintptr_t>(this));
m_requestedReposition = true; m_requestedReposition = true;

View File

@@ -148,7 +148,7 @@ void CWLSurface::destroy() {
m_resource.reset(); m_resource.reset();
Debug::log(LOG, "CWLSurface {:x} called destroy()", (uintptr_t)this); Debug::log(LOG, "CWLSurface {:x} called destroy()", rc<uintptr_t>(this));
} }
void CWLSurface::init() { void CWLSurface::init() {
@@ -161,7 +161,7 @@ void CWLSurface::init() {
m_listeners.destroy = m_resource->m_events.destroy.listen([this] { destroy(); }); m_listeners.destroy = m_resource->m_events.destroy.listen([this] { destroy(); });
Debug::log(LOG, "CWLSurface {:x} called init()", (uintptr_t)this); Debug::log(LOG, "CWLSurface {:x} called init()", rc<uintptr_t>(this));
} }
PHLWINDOW CWLSurface::getWindow() const { PHLWINDOW CWLSurface::getWindow() const {

View File

@@ -58,7 +58,7 @@ class CWLSurface {
// track surface data and avoid dupes // track surface data and avoid dupes
float m_lastScaleFloat = 0; float m_lastScaleFloat = 0;
int m_lastScaleInt = 0; int m_lastScaleInt = 0;
wl_output_transform m_lastTransform = (wl_output_transform)-1; wl_output_transform m_lastTransform = sc<wl_output_transform>(-1);
// //
CWLSurface& operator=(SP<CWLSurfaceResource> pSurface) { CWLSurface& operator=(SP<CWLSurfaceResource> pSurface) {

View File

@@ -163,7 +163,7 @@ SBoxExtents CWindow::getFullWindowExtents() {
if (!popup->m_wlSurface || !popup->m_wlSurface->resource()) if (!popup->m_wlSurface || !popup->m_wlSurface->resource())
return; return;
CBox* pSurfaceExtents = (CBox*)data; CBox* pSurfaceExtents = sc<CBox*>(data);
CBox surf = CBox{popup->coordsRelativeToParent(), popup->size()}; CBox surf = CBox{popup->coordsRelativeToParent(), popup->size()};
pSurfaceExtents->x = std::min(surf.x, pSurfaceExtents->x); pSurfaceExtents->x = std::min(surf.x, pSurfaceExtents->x);
pSurfaceExtents->y = std::min(surf.y, pSurfaceExtents->y); pSurfaceExtents->y = std::min(surf.y, pSurfaceExtents->y);
@@ -215,7 +215,7 @@ CBox CWindow::getWindowIdealBoundingBoxIgnoreReserved() {
POS = PMONITOR->m_position; POS = PMONITOR->m_position;
SIZE = PMONITOR->m_size; SIZE = PMONITOR->m_size;
return CBox{(int)POS.x, (int)POS.y, (int)SIZE.x, (int)SIZE.y}; return CBox{sc<int>(POS.x), sc<int>(POS.y), sc<int>(SIZE.x), sc<int>(SIZE.y)};
} }
if (DELTALESSTHAN(POS.y - PMONITOR->m_position.y, PMONITOR->m_reservedTopLeft.y, 1)) { if (DELTALESSTHAN(POS.y - PMONITOR->m_position.y, PMONITOR->m_reservedTopLeft.y, 1)) {
@@ -233,7 +233,7 @@ CBox CWindow::getWindowIdealBoundingBoxIgnoreReserved() {
SIZE.y += PMONITOR->m_reservedBottomRight.y; SIZE.y += PMONITOR->m_reservedBottomRight.y;
} }
return CBox{(int)POS.x, (int)POS.y, (int)SIZE.x, (int)SIZE.y}; return CBox{sc<int>(POS.x), sc<int>(POS.y), sc<int>(SIZE.x), sc<int>(SIZE.y)};
} }
SBoxExtents CWindow::getWindowExtentsUnified(uint64_t properties) { SBoxExtents CWindow::getWindowExtentsUnified(uint64_t properties) {
@@ -450,8 +450,8 @@ void CWindow::moveToWorkspace(PHLWORKSPACE pWorkspace) {
g_pCompositor->updateAllWindowsAnimatedDecorationValues(); g_pCompositor->updateAllWindowsAnimatedDecorationValues();
if (valid(pWorkspace)) { if (valid(pWorkspace)) {
g_pEventManager->postEvent(SHyprIPCEvent{.event = "movewindow", .data = std::format("{:x},{}", (uintptr_t)this, pWorkspace->m_name)}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "movewindow", .data = std::format("{:x},{}", rc<uintptr_t>(this), pWorkspace->m_name)});
g_pEventManager->postEvent(SHyprIPCEvent{.event = "movewindowv2", .data = std::format("{:x},{},{}", (uintptr_t)this, pWorkspace->m_id, pWorkspace->m_name)}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "movewindowv2", .data = std::format("{:x},{},{}", rc<uintptr_t>(this), pWorkspace->m_id, pWorkspace->m_name)});
EMIT_HOOK_EVENT("moveWindow", (std::vector<std::any>{m_self.lock(), pWorkspace})); EMIT_HOOK_EVENT("moveWindow", (std::vector<std::any>{m_self.lock(), pWorkspace}));
} }
@@ -603,7 +603,7 @@ void CWindow::onBorderAngleAnimEnd(WP<CBaseAnimatedVariable> pav) {
if (PAV->getStyle() != "loop" || !PAV->enabled()) if (PAV->getStyle() != "loop" || !PAV->enabled())
return; return;
const auto PANIMVAR = dynamic_cast<CAnimatedVariable<float>*>(PAV.get()); const auto PANIMVAR = dc<CAnimatedVariable<float>*>(PAV.get());
PANIMVAR->setCallbackOnEnd(nullptr); // we remove the callback here because otherwise setvalueandwarp will recurse this PANIMVAR->setCallbackOnEnd(nullptr); // we remove the callback here because otherwise setvalueandwarp will recurse this
@@ -785,7 +785,7 @@ void CWindow::applyDynamicRule(const SP<CWindowRule>& r) {
const CVarList VARS(r->m_rule, 0, ' '); const CVarList VARS(r->m_rule, 0, ' ');
if (auto search = NWindowProperties::intWindowProperties.find(VARS[1]); search != NWindowProperties::intWindowProperties.end()) { if (auto search = NWindowProperties::intWindowProperties.find(VARS[1]); search != NWindowProperties::intWindowProperties.end()) {
try { try {
*(search->second(m_self.lock())) = CWindowOverridableVar(Hyprlang::INT(std::stoi(VARS[2])), priority); *(search->second(m_self.lock())) = CWindowOverridableVar(sc<Hyprlang::INT>(std::stoi(VARS[2])), priority);
} catch (std::exception& e) { Debug::log(ERR, "Rule \"{}\" failed with: {}", r->m_rule, e.what()); } } catch (std::exception& e) { Debug::log(ERR, "Rule \"{}\" failed with: {}", r->m_rule, e.what()); }
} else if (auto search = NWindowProperties::floatWindowProperties.find(VARS[1]); search != NWindowProperties::floatWindowProperties.end()) { } else if (auto search = NWindowProperties::floatWindowProperties.find(VARS[1]); search != NWindowProperties::floatWindowProperties.end()) {
try { try {
@@ -793,7 +793,7 @@ void CWindow::applyDynamicRule(const SP<CWindowRule>& r) {
} catch (std::exception& e) { Debug::log(ERR, "Rule \"{}\" failed with: {}", r->m_rule, e.what()); } } catch (std::exception& e) { Debug::log(ERR, "Rule \"{}\" failed with: {}", r->m_rule, e.what()); }
} else if (auto search = NWindowProperties::boolWindowProperties.find(VARS[1]); search != NWindowProperties::boolWindowProperties.end()) { } else if (auto search = NWindowProperties::boolWindowProperties.find(VARS[1]); search != NWindowProperties::boolWindowProperties.end()) {
try { try {
*(search->second(m_self.lock())) = CWindowOverridableVar(VARS[2].empty() ? true : (bool)std::stoi(VARS[2]), priority); *(search->second(m_self.lock())) = CWindowOverridableVar(VARS[2].empty() ? true : sc<bool>(std::stoi(VARS[2])), priority);
} catch (std::exception& e) { Debug::log(ERR, "Rule \"{}\" failed with: {}", r->m_rule, e.what()); } } catch (std::exception& e) { Debug::log(ERR, "Rule \"{}\" failed with: {}", r->m_rule, e.what()); }
} }
break; break;
@@ -852,16 +852,16 @@ bool CWindow::isInCurvedCorner(double x, double y) {
double y1 = m_realPosition->value().y + m_realSize->value().y - ROUNDING; double y1 = m_realPosition->value().y + m_realSize->value().y - ROUNDING;
if (x < x0 && y < y0) { if (x < x0 && y < y0) {
return std::pow(x0 - x, ROUNDINGPOWER) + std::pow(y0 - y, ROUNDINGPOWER) > std::pow((double)ROUNDING, ROUNDINGPOWER); return std::pow(x0 - x, ROUNDINGPOWER) + std::pow(y0 - y, ROUNDINGPOWER) > std::pow(sc<double>(ROUNDING), ROUNDINGPOWER);
} }
if (x > x1 && y < y0) { if (x > x1 && y < y0) {
return std::pow(x - x1, ROUNDINGPOWER) + std::pow(y0 - y, ROUNDINGPOWER) > std::pow((double)ROUNDING, ROUNDINGPOWER); return std::pow(x - x1, ROUNDINGPOWER) + std::pow(y0 - y, ROUNDINGPOWER) > std::pow(sc<double>(ROUNDING), ROUNDINGPOWER);
} }
if (x < x0 && y > y1) { if (x < x0 && y > y1) {
return std::pow(x0 - x, ROUNDINGPOWER) + std::pow(y - y1, ROUNDINGPOWER) > std::pow((double)ROUNDING, ROUNDINGPOWER); return std::pow(x0 - x, ROUNDINGPOWER) + std::pow(y - y1, ROUNDINGPOWER) > std::pow(sc<double>(ROUNDING), ROUNDINGPOWER);
} }
if (x > x1 && y > y1) { if (x > x1 && y > y1) {
return std::pow(x - x1, ROUNDINGPOWER) + std::pow(y - y1, ROUNDINGPOWER) > std::pow((double)ROUNDING, ROUNDINGPOWER); return std::pow(x - x1, ROUNDINGPOWER) + std::pow(y - y1, ROUNDINGPOWER) > std::pow(sc<double>(ROUNDING), ROUNDINGPOWER);
} }
return false; return false;
@@ -887,7 +887,7 @@ void CWindow::applyGroupRules() {
void CWindow::createGroup() { void CWindow::createGroup() {
if (m_groupData.deny) { if (m_groupData.deny) {
Debug::log(LOG, "createGroup: window:{:x},title:{} is denied as a group, ignored", (uintptr_t)this, this->m_title); Debug::log(LOG, "createGroup: window:{:x},title:{} is denied as a group, ignored", rc<uintptr_t>(this), this->m_title);
return; return;
} }
@@ -906,14 +906,14 @@ void CWindow::createGroup() {
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(monitorID()); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(monitorID());
g_pCompositor->updateAllWindowsAnimatedDecorationValues(); g_pCompositor->updateAllWindowsAnimatedDecorationValues();
g_pEventManager->postEvent(SHyprIPCEvent{.event = "togglegroup", .data = std::format("1,{:x}", (uintptr_t)this)}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "togglegroup", .data = std::format("1,{:x}", rc<uintptr_t>(this))});
} }
} }
void CWindow::destroyGroup() { void CWindow::destroyGroup() {
if (m_groupData.pNextWindow == m_self) { if (m_groupData.pNextWindow == m_self) {
if (m_groupRules & GROUP_SET_ALWAYS) { if (m_groupRules & GROUP_SET_ALWAYS) {
Debug::log(LOG, "destoryGroup: window:{:x},title:{} has rule [group set always], ignored", (uintptr_t)this, this->m_title); Debug::log(LOG, "destoryGroup: window:{:x},title:{} has rule [group set always], ignored", rc<uintptr_t>(this), this->m_title);
return; return;
} }
m_groupData.pNextWindow.reset(); m_groupData.pNextWindow.reset();
@@ -926,7 +926,7 @@ void CWindow::destroyGroup() {
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(monitorID()); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(monitorID());
g_pCompositor->updateAllWindowsAnimatedDecorationValues(); g_pCompositor->updateAllWindowsAnimatedDecorationValues();
g_pEventManager->postEvent(SHyprIPCEvent{.event = "togglegroup", .data = std::format("0,{:x}", (uintptr_t)this)}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "togglegroup", .data = std::format("0,{:x}", rc<uintptr_t>(this))});
return; return;
} }
@@ -940,7 +940,7 @@ void CWindow::destroyGroup() {
curr->setHidden(false); curr->setHidden(false);
members.push_back(curr); members.push_back(curr);
addresses += std::format("{:x},", (uintptr_t)curr.get()); addresses += std::format("{:x},", rc<uintptr_t>(curr.get()));
} while (curr.get() != this); } while (curr.get() != this);
for (auto const& w : members) { for (auto const& w : members) {
@@ -1003,7 +1003,7 @@ int CWindow::getGroupSize() {
bool CWindow::canBeGroupedInto(PHLWINDOW pWindow) { bool CWindow::canBeGroupedInto(PHLWINDOW pWindow) {
static auto ALLOWGROUPMERGE = CConfigValue<Hyprlang::INT>("group:merge_groups_on_drag"); static auto ALLOWGROUPMERGE = CConfigValue<Hyprlang::INT>("group:merge_groups_on_drag");
bool isGroup = m_groupData.pNextWindow; bool isGroup = m_groupData.pNextWindow;
bool disallowDragIntoGroup = g_pInputManager->m_wasDraggingWindow && isGroup && !bool(*ALLOWGROUPMERGE); bool disallowDragIntoGroup = g_pInputManager->m_wasDraggingWindow && isGroup && !sc<bool>(*ALLOWGROUPMERGE);
return !g_pKeybindManager->m_groupsLocked // global group lock disengaged return !g_pKeybindManager->m_groupsLocked // global group lock disengaged
&& ((m_groupRules & GROUP_INVADE && m_firstMap) // window ignore local group locks, or && ((m_groupRules & GROUP_INVADE && m_firstMap) // window ignore local group locks, or
|| (!pWindow->getGroupHead()->m_groupData.locked // target unlocked || (!pWindow->getGroupHead()->m_groupData.locked // target unlocked
@@ -1323,7 +1323,7 @@ int CWindow::popupsCount() {
return 0; return 0;
int no = -1; int no = -1;
m_popupHead->breadthfirst([](WP<CPopup> p, void* d) { *((int*)d) += 1; }, &no); m_popupHead->breadthfirst([](WP<CPopup> p, void* d) { *sc<int*>(d) += 1; }, &no);
return no; return no;
} }
@@ -1332,7 +1332,7 @@ int CWindow::surfacesCount() {
return 1; return 1;
int no = 0; int no = 0;
m_wlSurface->resource()->breadthfirst([](SP<CWLSurfaceResource> r, const Vector2D& offset, void* d) { *((int*)d) += 1; }, &no); m_wlSurface->resource()->breadthfirst([](SP<CWLSurfaceResource> r, const Vector2D& offset, void* d) { *sc<int*>(d) += 1; }, &no);
return no; return no;
} }
@@ -1350,7 +1350,7 @@ bool CWindow::isFullscreen() {
} }
bool CWindow::isEffectiveInternalFSMode(const eFullscreenMode MODE) { bool CWindow::isEffectiveInternalFSMode(const eFullscreenMode MODE) {
return (eFullscreenMode)std::bit_floor((uint8_t)m_fullscreenState.internal) == MODE; return sc<eFullscreenMode>(std::bit_floor(sc<uint8_t>(m_fullscreenState.internal))) == MODE;
} }
WORKSPACEID CWindow::workspaceID() { WORKSPACEID CWindow::workspaceID() {
@@ -1415,7 +1415,7 @@ void CWindow::activate(bool force) {
m_isUrgent = true; m_isUrgent = true;
g_pEventManager->postEvent(SHyprIPCEvent{.event = "urgent", .data = std::format("{:x}", (uintptr_t)this)}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "urgent", .data = std::format("{:x}", rc<uintptr_t>(this))});
EMIT_HOOK_EVENT("urgent", m_self.lock()); EMIT_HOOK_EVENT("urgent", m_self.lock());
if (!force && (!m_windowData.focusOnActivate.valueOr(*PFOCUSONACTIVATE) || (m_suppressedEvents & SUPPRESS_ACTIVATE_FOCUSONLY) || (m_suppressedEvents & SUPPRESS_ACTIVATE))) if (!force && (!m_windowData.focusOnActivate.valueOr(*PFOCUSONACTIVATE) || (m_suppressedEvents & SUPPRESS_ACTIVATE_FOCUSONLY) || (m_suppressedEvents & SUPPRESS_ACTIVATE)))
@@ -1470,17 +1470,17 @@ void CWindow::onUpdateMeta() {
if (m_title != NEWTITLE) { if (m_title != NEWTITLE) {
m_title = NEWTITLE; m_title = NEWTITLE;
g_pEventManager->postEvent(SHyprIPCEvent{.event = "windowtitle", .data = std::format("{:x}", (uintptr_t)this)}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "windowtitle", .data = std::format("{:x}", rc<uintptr_t>(this))});
g_pEventManager->postEvent(SHyprIPCEvent{.event = "windowtitlev2", .data = std::format("{:x},{}", (uintptr_t)this, m_title)}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "windowtitlev2", .data = std::format("{:x},{}", rc<uintptr_t>(this), m_title)});
EMIT_HOOK_EVENT("windowTitle", m_self.lock()); EMIT_HOOK_EVENT("windowTitle", m_self.lock());
if (m_self == g_pCompositor->m_lastWindow) { // if it's the active, let's post an event to update others if (m_self == g_pCompositor->m_lastWindow) { // if it's the active, let's post an event to update others
g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindow", .data = m_class + "," + m_title}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindow", .data = m_class + "," + m_title});
g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindowv2", .data = std::format("{:x}", (uintptr_t)this)}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindowv2", .data = std::format("{:x}", rc<uintptr_t>(this))});
EMIT_HOOK_EVENT("activeWindow", m_self.lock()); EMIT_HOOK_EVENT("activeWindow", m_self.lock());
} }
Debug::log(LOG, "Window {:x} set title to {}", (uintptr_t)this, m_title); Debug::log(LOG, "Window {:x} set title to {}", rc<uintptr_t>(this), m_title);
doUpdate = true; doUpdate = true;
} }
@@ -1490,11 +1490,11 @@ void CWindow::onUpdateMeta() {
if (m_self == g_pCompositor->m_lastWindow) { // if it's the active, let's post an event to update others if (m_self == g_pCompositor->m_lastWindow) { // if it's the active, let's post an event to update others
g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindow", .data = m_class + "," + m_title}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindow", .data = m_class + "," + m_title});
g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindowv2", .data = std::format("{:x}", (uintptr_t)this)}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindowv2", .data = std::format("{:x}", rc<uintptr_t>(this))});
EMIT_HOOK_EVENT("activeWindow", m_self.lock()); EMIT_HOOK_EVENT("activeWindow", m_self.lock());
} }
Debug::log(LOG, "Window {:x} set class to {}", (uintptr_t)this, m_class); Debug::log(LOG, "Window {:x} set class to {}", rc<uintptr_t>(this), m_class);
doUpdate = true; doUpdate = true;
} }
@@ -1549,7 +1549,7 @@ void CWindow::onResourceChangeX11() {
// could be first assoc and we need to catch the class // could be first assoc and we need to catch the class
onUpdateMeta(); onUpdateMeta();
Debug::log(LOG, "xwayland window {:x} -> association to {:x}", (uintptr_t)m_xwaylandSurface.get(), (uintptr_t)m_wlSurface->resource().get()); Debug::log(LOG, "xwayland window {:x} -> association to {:x}", rc<uintptr_t>(m_xwaylandSurface.get()), rc<uintptr_t>(m_wlSurface->resource().get()));
} }
void CWindow::onX11ConfigureRequest(CBox box) { void CWindow::onX11ConfigureRequest(CBox box) {
@@ -1766,8 +1766,8 @@ void CWindow::updateX11SurfaceScale() {
void CWindow::sendWindowSize(bool force) { void CWindow::sendWindowSize(bool force) {
const auto PMONITOR = m_monitor.lock(); const auto PMONITOR = m_monitor.lock();
Debug::log(TRACE, "sendWindowSize: window:{:x},title:{} with real pos {}, real size {} (force: {})", (uintptr_t)this, this->m_title, m_realPosition->goal(), m_realSize->goal(), Debug::log(TRACE, "sendWindowSize: window:{:x},title:{} with real pos {}, real size {} (force: {})", rc<uintptr_t>(this), this->m_title, m_realPosition->goal(),
force); m_realSize->goal(), force);
// TODO: this should be decoupled from setWindowSize IMO // TODO: this should be decoupled from setWindowSize IMO
const auto REPORTPOS = realToReportPosition(); const auto REPORTPOS = realToReportPosition();
@@ -1799,7 +1799,7 @@ void CWindow::setContentType(NContentType::eContentType contentType) {
m_wlSurface->resource()->m_contentType = PROTO::contentType->getContentType(m_wlSurface->resource()); m_wlSurface->resource()->m_contentType = PROTO::contentType->getContentType(m_wlSurface->resource());
// else disallow content type change if proto is used? // else disallow content type change if proto is used?
Debug::log(INFO, "ContentType for window {}", (int)contentType); Debug::log(INFO, "ContentType for window {}", sc<int>(contentType));
m_wlSurface->resource()->m_contentType->m_value = contentType; m_wlSurface->resource()->m_contentType->m_value = contentType;
} }

View File

@@ -106,8 +106,8 @@ struct SWindowData {
CWindowOverridableVar<bool> noFollowMouse = false; CWindowOverridableVar<bool> noFollowMouse = false;
CWindowOverridableVar<bool> noScreenShare = false; CWindowOverridableVar<bool> noScreenShare = false;
CWindowOverridableVar<Hyprlang::INT> borderSize = {std::string("general:border_size"), Hyprlang::INT(0), std::nullopt}; CWindowOverridableVar<Hyprlang::INT> borderSize = {std::string("general:border_size"), sc<Hyprlang::INT>(0), std::nullopt};
CWindowOverridableVar<Hyprlang::INT> rounding = {std::string("decoration:rounding"), Hyprlang::INT(0), std::nullopt}; CWindowOverridableVar<Hyprlang::INT> rounding = {std::string("decoration:rounding"), sc<Hyprlang::INT>(0), std::nullopt};
CWindowOverridableVar<Hyprlang::FLOAT> roundingPower = {std::string("decoration:rounding_power")}; CWindowOverridableVar<Hyprlang::FLOAT> roundingPower = {std::string("decoration:rounding_power")};
CWindowOverridableVar<Hyprlang::FLOAT> scrollMouse = {std::string("input:scroll_factor")}; CWindowOverridableVar<Hyprlang::FLOAT> scrollMouse = {std::string("input:scroll_factor")};
@@ -531,12 +531,12 @@ struct std::formatter<PHLWINDOW, CharT> : std::formatter<CharT> {
auto format(PHLWINDOW const& w, FormatContext& ctx) const { auto format(PHLWINDOW const& w, FormatContext& ctx) const {
auto&& out = ctx.out(); auto&& out = ctx.out();
if (formatAddressOnly) if (formatAddressOnly)
return std::format_to(out, "{:x}", (uintptr_t)w.get()); return std::format_to(out, "{:x}", rc<uintptr_t>(w.get()));
if (!w) if (!w)
return std::format_to(out, "[Window nullptr]"); return std::format_to(out, "[Window nullptr]");
std::format_to(out, "["); std::format_to(out, "[");
std::format_to(out, "Window {:x}: title: \"{}\"", (uintptr_t)w.get(), w->m_title); std::format_to(out, "Window {:x}: title: \"{}\"", rc<uintptr_t>(w.get()), w->m_title);
if (formatWorkspace) if (formatWorkspace)
std::format_to(out, ", workspace: {}", w->m_workspace ? w->workspaceID() : WORKSPACE_INVALID); std::format_to(out, ", workspace: {}", w->m_workspace ? w->workspaceID() : WORKSPACE_INVALID);
if (formatMonitor) if (formatMonitor)

View File

@@ -316,7 +316,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
const auto SHOULDBESPECIAL = configStringToInt(prop); const auto SHOULDBESPECIAL = configStringToInt(prop);
if (SHOULDBESPECIAL && (bool)*SHOULDBESPECIAL != m_isSpecialWorkspace) if (SHOULDBESPECIAL && sc<bool>(*SHOULDBESPECIAL) != m_isSpecialWorkspace)
return false; return false;
continue; continue;
} }
@@ -410,11 +410,11 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
int count; int count;
if (wantsCountGroup) if (wantsCountGroup)
count = getGroups(wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled), count = getGroups(wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>(sc<bool>(wantsOnlyTiled)),
wantsOnlyPinned ? std::optional<bool>(wantsOnlyPinned) : std::nullopt, wantsOnlyPinned ? std::optional<bool>(wantsOnlyPinned) : std::nullopt,
wantsCountVisible ? std::optional<bool>(wantsCountVisible) : std::nullopt); wantsCountVisible ? std::optional<bool>(wantsCountVisible) : std::nullopt);
else else
count = getWindows(wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled), count = getWindows(wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>(sc<bool>(wantsOnlyTiled)),
wantsOnlyPinned ? std::optional<bool>(wantsOnlyPinned) : std::nullopt, wantsOnlyPinned ? std::optional<bool>(wantsOnlyPinned) : std::nullopt,
wantsCountVisible ? std::optional<bool>(wantsCountVisible) : std::nullopt); wantsCountVisible ? std::optional<bool>(wantsCountVisible) : std::nullopt);
@@ -447,10 +447,10 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
WORKSPACEID count; WORKSPACEID count;
if (wantsCountGroup) if (wantsCountGroup)
count = count =
getGroups(wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled), getGroups(wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>(sc<bool>(wantsOnlyTiled)),
wantsOnlyPinned ? std::optional<bool>(wantsOnlyPinned) : std::nullopt, wantsCountVisible ? std::optional<bool>(wantsCountVisible) : std::nullopt); wantsOnlyPinned ? std::optional<bool>(wantsOnlyPinned) : std::nullopt, wantsCountVisible ? std::optional<bool>(wantsCountVisible) : std::nullopt);
else else
count = getWindows(wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled), count = getWindows(wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>(sc<bool>(wantsOnlyTiled)),
wantsOnlyPinned ? std::optional<bool>(wantsOnlyPinned) : std::nullopt, wantsOnlyPinned ? std::optional<bool>(wantsOnlyPinned) : std::nullopt,
wantsCountVisible ? std::optional<bool>(wantsCountVisible) : std::nullopt); wantsCountVisible ? std::optional<bool>(wantsCountVisible) : std::nullopt);

View File

@@ -120,7 +120,7 @@ void IKeyboard::setKeymap(const SStringRuleNames& rules) {
const auto IDX = xkb_map_mod_get_index(m_xkbKeymap, XKB_MOD_NAME_NUM); const auto IDX = xkb_map_mod_get_index(m_xkbKeymap, XKB_MOD_NAME_NUM);
if (IDX != XKB_MOD_INVALID) if (IDX != XKB_MOD_INVALID)
m_modifiersState.locked |= (uint32_t)1 << IDX; m_modifiersState.locked |= sc<uint32_t>(1) << IDX;
// 0 to avoid mods getting stuck if depressed during reload // 0 to avoid mods getting stuck if depressed during reload
updateModifiers(0, 0, m_modifiersState.locked, m_modifiersState.group); updateModifiers(0, 0, m_modifiersState.locked, m_modifiersState.group);
@@ -188,7 +188,7 @@ void IKeyboard::updateXKBTranslationState(xkb_keymap* const keymap) {
m_xkbSymState = nullptr; m_xkbSymState = nullptr;
if (keymap) { if (keymap) {
Debug::log(LOG, "Updating keyboard {:x}'s translation state from a provided keymap", (uintptr_t)this); Debug::log(LOG, "Updating keyboard {:x}'s translation state from a provided keymap", rc<uintptr_t>(this));
m_xkbStaticState = xkb_state_new(keymap); m_xkbStaticState = xkb_state_new(keymap);
m_xkbState = xkb_state_new(keymap); m_xkbState = xkb_state_new(keymap);
m_xkbSymState = xkb_state_new(keymap); m_xkbSymState = xkb_state_new(keymap);
@@ -203,7 +203,7 @@ void IKeyboard::updateXKBTranslationState(xkb_keymap* const keymap) {
for (uint32_t i = 0; i < LAYOUTSNUM; ++i) { for (uint32_t i = 0; i < LAYOUTSNUM; ++i) {
if (xkb_state_layout_index_is_active(STATE, i, XKB_STATE_LAYOUT_EFFECTIVE) == 1) { if (xkb_state_layout_index_is_active(STATE, i, XKB_STATE_LAYOUT_EFFECTIVE) == 1) {
Debug::log(LOG, "Updating keyboard {:x}'s translation state from an active index {}", (uintptr_t)this, i); Debug::log(LOG, "Updating keyboard {:x}'s translation state from an active index {}", rc<uintptr_t>(this), i);
CVarList keyboardLayouts(m_currentRules.layout, 0, ','); CVarList keyboardLayouts(m_currentRules.layout, 0, ',');
CVarList keyboardModels(m_currentRules.model, 0, ','); CVarList keyboardModels(m_currentRules.model, 0, ',');
@@ -246,7 +246,7 @@ void IKeyboard::updateXKBTranslationState(xkb_keymap* const keymap) {
} }
} }
Debug::log(LOG, "Updating keyboard {:x}'s translation state from an unknown index", (uintptr_t)this); Debug::log(LOG, "Updating keyboard {:x}'s translation state from an unknown index", rc<uintptr_t>(this));
xkb_rule_names rules = { xkb_rule_names rules = {
.rules = m_currentRules.rules.c_str(), .rules = m_currentRules.rules.c_str(),
@@ -289,7 +289,7 @@ std::optional<uint32_t> IKeyboard::getLEDs() {
return {}; return {};
uint32_t leds = 0; uint32_t leds = 0;
for (uint32_t i = 0; i < std::min((size_t)LED_COUNT, m_ledIndexes.size()); ++i) { for (uint32_t i = 0; i < std::min(sc<size_t>(LED_COUNT), m_ledIndexes.size()); ++i) {
if (xkb_state_led_index_is_active(m_xkbState, m_ledIndexes[i])) if (xkb_state_led_index_is_active(m_xkbState, m_ledIndexes[i]))
leds |= (1 << i); leds |= (1 << i);
} }

View File

@@ -54,9 +54,9 @@ CMouse::CMouse(SP<Aquamarine::IPointer> mouse_) : m_mouse(mouse_) {
m_listeners.axis = m_mouse->events.axis.listen([this](const Aquamarine::IPointer::SAxisEvent& event) { m_listeners.axis = m_mouse->events.axis.listen([this](const Aquamarine::IPointer::SAxisEvent& event) {
m_pointerEvents.axis.emit(SAxisEvent{ m_pointerEvents.axis.emit(SAxisEvent{
.timeMs = event.timeMs, .timeMs = event.timeMs,
.source = (wl_pointer_axis_source)event.source, .source = sc<wl_pointer_axis_source>(event.source),
.axis = (wl_pointer_axis)event.axis, .axis = sc<wl_pointer_axis>(event.axis),
.relativeDirection = (wl_pointer_axis_relative_direction)event.direction, .relativeDirection = sc<wl_pointer_axis_relative_direction>(event.direction),
.delta = event.delta, .delta = event.delta,
.deltaDiscrete = event.discrete, .deltaDiscrete = event.discrete,
.mouse = true, .mouse = true,

View File

@@ -41,7 +41,7 @@ static void setVector2DAnimToMove(WP<CBaseAnimatedVariable> pav) {
if (!PAV) if (!PAV)
return; return;
CAnimatedVariable<Vector2D>* animvar = dynamic_cast<CAnimatedVariable<Vector2D>*>(PAV.get()); CAnimatedVariable<Vector2D>* animvar = dc<CAnimatedVariable<Vector2D>*>(PAV.get());
animvar->setConfig(g_pConfigManager->getAnimationPropertyConfig("windowsMove")); animvar->setConfig(g_pConfigManager->getAnimationPropertyConfig("windowsMove"));
const auto PHLWINDOW = animvar->m_Context.pWindow.lock(); const auto PHLWINDOW = animvar->m_Context.pWindow.lock();
@@ -50,7 +50,7 @@ static void setVector2DAnimToMove(WP<CBaseAnimatedVariable> pav) {
} }
void Events::listener_mapWindow(void* owner, void* data) { void Events::listener_mapWindow(void* owner, void* data) {
PHLWINDOW PWINDOW = ((CWindow*)owner)->m_self.lock(); PHLWINDOW PWINDOW = sc<CWindow*>(owner)->m_self.lock();
static auto PINACTIVEALPHA = CConfigValue<Hyprlang::FLOAT>("decoration:inactive_opacity"); static auto PINACTIVEALPHA = CConfigValue<Hyprlang::FLOAT>("decoration:inactive_opacity");
static auto PACTIVEALPHA = CConfigValue<Hyprlang::FLOAT>("decoration:active_opacity"); static auto PACTIVEALPHA = CConfigValue<Hyprlang::FLOAT>("decoration:active_opacity");
@@ -223,7 +223,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
try { try {
clientMode = std::stoi(ARGS[1]); clientMode = std::stoi(ARGS[1]);
} catch (std::exception& e) { clientMode = 0; } } catch (std::exception& e) { clientMode = 0; }
requestedFSState = SFullscreenState{.internal = (eFullscreenMode)internalMode, .client = (eFullscreenMode)clientMode}; requestedFSState = SFullscreenState{.internal = sc<eFullscreenMode>(internalMode), .client = sc<eFullscreenMode>(clientMode)};
break; break;
} }
case CWindowRule::RULE_SUPPRESSEVENT: { case CWindowRule::RULE_SUPPRESSEVENT: {
@@ -527,13 +527,13 @@ void Events::listener_mapWindow(void* owner, void* data) {
if (ONSCREEN) { if (ONSCREEN) {
int borderSize = PWINDOW->getRealBorderSize(); int borderSize = PWINDOW->getRealBorderSize();
posX = std::clamp(posX, (int)(PMONITOR->m_reservedTopLeft.x + borderSize), posX = std::clamp(posX, sc<int>(PMONITOR->m_reservedTopLeft.x + borderSize),
std::max((int)(PMONITOR->m_size.x - PMONITOR->m_reservedBottomRight.x - PWINDOW->m_realSize->goal().x - borderSize), std::max(sc<int>(PMONITOR->m_size.x - PMONITOR->m_reservedBottomRight.x - PWINDOW->m_realSize->goal().x - borderSize),
(int)(PMONITOR->m_reservedTopLeft.x + borderSize + 1))); sc<int>(PMONITOR->m_reservedTopLeft.x + borderSize + 1)));
posY = std::clamp(posY, (int)(PMONITOR->m_reservedTopLeft.y + borderSize), posY = std::clamp(posY, sc<int>(PMONITOR->m_reservedTopLeft.y + borderSize),
std::max((int)(PMONITOR->m_size.y - PMONITOR->m_reservedBottomRight.y - PWINDOW->m_realSize->goal().y - borderSize), std::max(sc<int>(PMONITOR->m_size.y - PMONITOR->m_reservedBottomRight.y - PWINDOW->m_realSize->goal().y - borderSize),
(int)(PMONITOR->m_reservedTopLeft.y + borderSize + 1))); sc<int>(PMONITOR->m_reservedTopLeft.y + borderSize + 1)));
} }
Debug::log(LOG, "Rule move, applying to {}", PWINDOW); Debug::log(LOG, "Rule move, applying to {}", PWINDOW);
@@ -631,9 +631,9 @@ void Events::listener_mapWindow(void* owner, void* data) {
} }
if (requestedClientFSMode.has_value() && (PWINDOW->m_suppressedEvents & SUPPRESS_FULLSCREEN)) if (requestedClientFSMode.has_value() && (PWINDOW->m_suppressedEvents & SUPPRESS_FULLSCREEN))
requestedClientFSMode = (eFullscreenMode)((uint8_t)requestedClientFSMode.value_or(FSMODE_NONE) & ~(uint8_t)FSMODE_FULLSCREEN); requestedClientFSMode = sc<eFullscreenMode>(sc<uint8_t>(requestedClientFSMode.value_or(FSMODE_NONE)) & ~sc<uint8_t>(FSMODE_FULLSCREEN));
if (requestedClientFSMode.has_value() && (PWINDOW->m_suppressedEvents & SUPPRESS_MAXIMIZE)) if (requestedClientFSMode.has_value() && (PWINDOW->m_suppressedEvents & SUPPRESS_MAXIMIZE))
requestedClientFSMode = (eFullscreenMode)((uint8_t)requestedClientFSMode.value_or(FSMODE_NONE) & ~(uint8_t)FSMODE_MAXIMIZED); requestedClientFSMode = sc<eFullscreenMode>(sc<uint8_t>(requestedClientFSMode.value_or(FSMODE_NONE)) & ~sc<uint8_t>(FSMODE_MAXIMIZED));
if (!PWINDOW->m_noInitialFocus && (requestedInternalFSMode.has_value() || requestedClientFSMode.has_value() || requestedFSState.has_value())) { if (!PWINDOW->m_noInitialFocus && (requestedInternalFSMode.has_value() || requestedClientFSMode.has_value() || requestedFSState.has_value())) {
// fix fullscreen on requested (basically do a switcheroo) // fix fullscreen on requested (basically do a switcheroo)
@@ -717,7 +717,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
} }
void Events::listener_unmapWindow(void* owner, void* data) { void Events::listener_unmapWindow(void* owner, void* data) {
PHLWINDOW PWINDOW = ((CWindow*)owner)->m_self.lock(); PHLWINDOW PWINDOW = sc<CWindow*>(owner)->m_self.lock();
Debug::log(LOG, "{:c} unmapped", PWINDOW); Debug::log(LOG, "{:c} unmapped", PWINDOW);
@@ -826,7 +826,7 @@ void Events::listener_unmapWindow(void* owner, void* data) {
if (PWINDOW == g_pCompositor->m_lastWindow.lock() || !g_pCompositor->m_lastWindow.lock()) { if (PWINDOW == g_pCompositor->m_lastWindow.lock() || !g_pCompositor->m_lastWindow.lock()) {
g_pEventManager->postEvent(SHyprIPCEvent{"activewindow", ","}); g_pEventManager->postEvent(SHyprIPCEvent{"activewindow", ","});
g_pEventManager->postEvent(SHyprIPCEvent{"activewindowv2", ""}); g_pEventManager->postEvent(SHyprIPCEvent{"activewindowv2", ""});
EMIT_HOOK_EVENT("activeWindow", (PHLWINDOW) nullptr); EMIT_HOOK_EVENT("activeWindow", PHLWINDOW{nullptr});
} }
} else { } else {
Debug::log(LOG, "Unmapped was not focused, ignoring a refocus."); Debug::log(LOG, "Unmapped was not focused, ignoring a refocus.");
@@ -855,7 +855,7 @@ void Events::listener_unmapWindow(void* owner, void* data) {
} }
void Events::listener_commitWindow(void* owner, void* data) { void Events::listener_commitWindow(void* owner, void* data) {
PHLWINDOW PWINDOW = ((CWindow*)owner)->m_self.lock(); PHLWINDOW PWINDOW = sc<CWindow*>(owner)->m_self.lock();
if (!PWINDOW->m_isX11 && PWINDOW->m_xdgSurface->m_initialCommit) { if (!PWINDOW->m_isX11 && PWINDOW->m_xdgSurface->m_initialCommit) {
Vector2D predSize = g_pLayoutManager->getCurrentLayout()->predictSizeForNewWindow(PWINDOW); Vector2D predSize = g_pLayoutManager->getCurrentLayout()->predictSizeForNewWindow(PWINDOW);
@@ -922,7 +922,7 @@ void Events::listener_commitWindow(void* owner, void* data) {
} }
void Events::listener_destroyWindow(void* owner, void* data) { void Events::listener_destroyWindow(void* owner, void* data) {
PHLWINDOW PWINDOW = ((CWindow*)owner)->m_self.lock(); PHLWINDOW PWINDOW = sc<CWindow*>(owner)->m_self.lock();
Debug::log(LOG, "{:c} destroyed, queueing.", PWINDOW); Debug::log(LOG, "{:c} destroyed, queueing.", PWINDOW);
@@ -953,7 +953,7 @@ void Events::listener_destroyWindow(void* owner, void* data) {
} }
void Events::listener_activateX11(void* owner, void* data) { void Events::listener_activateX11(void* owner, void* data) {
PHLWINDOW PWINDOW = ((CWindow*)owner)->m_self.lock(); PHLWINDOW PWINDOW = sc<CWindow*>(owner)->m_self.lock();
Debug::log(LOG, "X11 Activate request for window {}", PWINDOW); Debug::log(LOG, "X11 Activate request for window {}", PWINDOW);
@@ -978,7 +978,7 @@ void Events::listener_activateX11(void* owner, void* data) {
} }
void Events::listener_unmanagedSetGeometry(void* owner, void* data) { void Events::listener_unmanagedSetGeometry(void* owner, void* data) {
PHLWINDOW PWINDOW = ((CWindow*)owner)->m_self.lock(); PHLWINDOW PWINDOW = sc<CWindow*>(owner)->m_self.lock();
if (!PWINDOW->m_isMapped || !PWINDOW->m_xwaylandSurface || !PWINDOW->m_xwaylandSurface->m_overrideRedirect) if (!PWINDOW->m_isMapped || !PWINDOW->m_xwaylandSurface || !PWINDOW->m_xwaylandSurface->m_overrideRedirect)
return; return;

View File

@@ -44,7 +44,7 @@ CAsyncDialogBox::CAsyncDialogBox(const std::string& title, const std::string& de
} }
static int onFdWrite(int fd, uint32_t mask, void* data) { static int onFdWrite(int fd, uint32_t mask, void* data) {
auto box = (CAsyncDialogBox*)data; auto box = sc<CAsyncDialogBox*>(data);
// lock the box to prevent a UAF // lock the box to prevent a UAF
auto lock = box->lockSelf(); auto lock = box->lockSelf();
@@ -68,7 +68,7 @@ void CAsyncDialogBox::onWrite(int fd, uint32_t mask) {
} }
while ((ret = read(m_pipeReadFd.get(), buf.data(), 1023)) > 0) { while ((ret = read(m_pipeReadFd.get(), buf.data(), 1023)) > 0) {
m_stdout += std::string_view{(char*)buf.data(), (size_t)ret}; m_stdout += std::string_view{(buf.data()), sc<size_t>(ret)};
} }
// restore the flags (otherwise libwayland won't give us a hangup) // restore the flags (otherwise libwayland won't give us a hangup)

View File

@@ -25,7 +25,7 @@ CHyprColor::CHyprColor(const Hyprgraphics::CColor& color, float a_) : a(a_) {
} }
uint32_t CHyprColor::getAsHex() const { uint32_t CHyprColor::getAsHex() const {
return (uint32_t)(a * 255.f) * 0x1000000 + (uint32_t)(r * 255.f) * 0x10000 + (uint32_t)(g * 255.f) * 0x100 + (uint32_t)(b * 255.f) * 0x1; return sc<uint32_t>(a * 255.f) * 0x1000000 + sc<uint32_t>(r * 255.f) * 0x10000 + sc<uint32_t>(g * 255.f) * 0x100 + sc<uint32_t>(b * 255.f) * 0x1;
} }
Hyprgraphics::CColor::SSRGB CHyprColor::asRGB() const { Hyprgraphics::CColor::SSRGB CHyprColor::asRGB() const {

View File

@@ -222,7 +222,7 @@ const SPixelFormat* NFormatUtils::getPixelFormatFromDRM(DRMFormat drm) {
const SPixelFormat* NFormatUtils::getPixelFormatFromGL(uint32_t glFormat, uint32_t glType, bool alpha) { const SPixelFormat* NFormatUtils::getPixelFormatFromGL(uint32_t glFormat, uint32_t glType, bool alpha) {
for (auto const& fmt : GLES3_FORMATS) { for (auto const& fmt : GLES3_FORMATS) {
if (fmt.glFormat == (int)glFormat && fmt.glType == (int)glType && fmt.withAlpha == alpha) if (fmt.glFormat == sc<int>(glFormat) && fmt.glType == sc<int>(glType) && fmt.withAlpha == alpha)
return &fmt; return &fmt;
} }

View File

@@ -87,7 +87,7 @@ std::string escapeJSONStrings(const std::string& str) {
case '\t': oss << "\\t"; break; case '\t': oss << "\\t"; break;
default: default:
if ('\x00' <= c && c <= '\x1f') { if ('\x00' <= c && c <= '\x1f') {
oss << "\\u" << std::hex << std::setw(4) << std::setfill('0') << static_cast<int>(c); oss << "\\u" << std::hex << std::setw(4) << std::setfill('0') << sc<int>(c);
} else { } else {
oss << c; oss << c;
} }
@@ -213,7 +213,7 @@ SWorkspaceIDName getWorkspaceIDNameFromString(const std::string& in) {
if (!PLUSMINUSRESULT.has_value()) if (!PLUSMINUSRESULT.has_value())
return {WORKSPACE_INVALID}; return {WORKSPACE_INVALID};
result.id = (int)PLUSMINUSRESULT.value(); result.id = sc<int>(PLUSMINUSRESULT.value());
WORKSPACEID remains = result.id; WORKSPACEID remains = result.id;
@@ -251,7 +251,7 @@ SWorkspaceIDName getWorkspaceIDNameFromString(const std::string& in) {
remains -= 1; remains -= 1;
// traverse valid workspaces until we reach the remains // traverse valid workspaces until we reach the remains
if ((size_t)remains < namedWSes.size()) { if (sc<size_t>(remains) < namedWSes.size()) {
result.id = namedWSes[remains]; result.id = namedWSes[remains];
} else { } else {
remains -= namedWSes.size(); remains -= namedWSes.size();
@@ -272,7 +272,7 @@ SWorkspaceIDName getWorkspaceIDNameFromString(const std::string& in) {
char walkDir = in[1]; char walkDir = in[1];
// sanitize. 0 means invalid oob in - // sanitize. 0 means invalid oob in -
predictedWSID = std::max(predictedWSID, static_cast<int64_t>(0)); predictedWSID = std::max(predictedWSID, sc<int64_t>(0));
// Count how many invalidWSes are in between (how bad the prediction was) // Count how many invalidWSes are in between (how bad the prediction was)
WORKSPACEID beginID = in[1] == '+' ? activeWSID + 1 : predictedWSID; WORKSPACEID beginID = in[1] == '+' ? activeWSID + 1 : predictedWSID;
@@ -295,7 +295,7 @@ SWorkspaceIDName getWorkspaceIDNameFromString(const std::string& in) {
} }
currentItem += remains; currentItem += remains;
currentItem = std::max(currentItem, static_cast<size_t>(0)); currentItem = std::max(currentItem, sc<size_t>(0));
if (currentItem >= namedWSes.size()) { if (currentItem >= namedWSes.size()) {
// At the seam between namedWSes and normal WSes. Behave like r+[diff] at imaginary ws 0 // At the seam between namedWSes and normal WSes. Behave like r+[diff] at imaginary ws 0
size_t diff = currentItem - (namedWSes.size() - 1); size_t diff = currentItem - (namedWSes.size() - 1);
@@ -332,7 +332,7 @@ SWorkspaceIDName getWorkspaceIDNameFromString(const std::string& in) {
// Need remainingWSes more // Need remainingWSes more
auto namedWSIdx = namedWSes.size() - remainingWSes; auto namedWSIdx = namedWSes.size() - remainingWSes;
// Sanitze // Sanitze
namedWSIdx = std::clamp(namedWSIdx, static_cast<size_t>(0), namedWSes.size() - static_cast<size_t>(1)); namedWSIdx = std::clamp(namedWSIdx, sc<size_t>(0), namedWSes.size() - sc<size_t>(1));
finalWSID = namedWSes[namedWSIdx]; finalWSID = namedWSes[namedWSIdx];
} else { } else {
// Couldn't find valid workspace in negative direction, search last first one back up positive direction // Couldn't find valid workspace in negative direction, search last first one back up positive direction
@@ -376,10 +376,10 @@ SWorkspaceIDName getWorkspaceIDNameFromString(const std::string& in) {
if (!PLUSMINUSRESULT.has_value()) if (!PLUSMINUSRESULT.has_value())
return {WORKSPACE_INVALID}; return {WORKSPACE_INVALID};
result.id = (int)PLUSMINUSRESULT.value(); result.id = sc<int>(PLUSMINUSRESULT.value());
// result now has +/- what we should move on mon // result now has +/- what we should move on mon
int remains = (int)result.id; int remains = sc<int>(result.id);
std::vector<WORKSPACEID> validWSes; std::vector<WORKSPACEID> validWSes;
for (auto const& ws : g_pCompositor->getWorkspaces()) { for (auto const& ws : g_pCompositor->getWorkspaces()) {
@@ -400,7 +400,7 @@ SWorkspaceIDName getWorkspaceIDNameFromString(const std::string& in) {
// clamp // clamp
if (currentItem < 0) { if (currentItem < 0) {
currentItem = 0; currentItem = 0;
} else if (currentItem >= (ssize_t)validWSes.size()) { } else if (currentItem >= sc<ssize_t>(validWSes.size())) {
currentItem = validWSes.size() - 1; currentItem = validWSes.size() - 1;
} }
} else { } else {
@@ -409,7 +409,7 @@ SWorkspaceIDName getWorkspaceIDNameFromString(const std::string& in) {
// get the current item // get the current item
WORKSPACEID activeWSID = g_pCompositor->m_lastMonitor->m_activeWorkspace ? g_pCompositor->m_lastMonitor->m_activeWorkspace->m_id : 1; WORKSPACEID activeWSID = g_pCompositor->m_lastMonitor->m_activeWorkspace ? g_pCompositor->m_lastMonitor->m_activeWorkspace->m_id : 1;
for (ssize_t i = 0; i < (ssize_t)validWSes.size(); i++) { for (ssize_t i = 0; i < sc<ssize_t>(validWSes.size()); i++) {
if (validWSes[i] == activeWSID) { if (validWSes[i] == activeWSID) {
currentItem = i; currentItem = i;
break; break;
@@ -420,7 +420,7 @@ SWorkspaceIDName getWorkspaceIDNameFromString(const std::string& in) {
currentItem += remains; currentItem += remains;
// sanitize // sanitize
if (currentItem >= (ssize_t)validWSes.size()) { if (currentItem >= sc<ssize_t>(validWSes.size())) {
currentItem = currentItem % validWSes.size(); currentItem = currentItem % validWSes.size();
} else if (currentItem < 0) { } else if (currentItem < 0) {
currentItem = validWSes.size() + currentItem; currentItem = validWSes.size() + currentItem;
@@ -436,7 +436,7 @@ SWorkspaceIDName getWorkspaceIDNameFromString(const std::string& in) {
if (!PLUSMINUSRESULT.has_value()) if (!PLUSMINUSRESULT.has_value())
return {WORKSPACE_INVALID}; return {WORKSPACE_INVALID};
result.id = std::max((int)PLUSMINUSRESULT.value(), 1); result.id = std::max(sc<int>(PLUSMINUSRESULT.value()), 1);
} else { } else {
Debug::log(ERR, "Relative workspace on no mon!"); Debug::log(ERR, "Relative workspace on no mon!");
return {WORKSPACE_INVALID}; return {WORKSPACE_INVALID};
@@ -642,7 +642,7 @@ std::expected<int64_t, std::string> configStringToInt(const std::string& VALUE)
a = std::round(std::stof(trim(rolling.substr(0, rolling.find(',')))) * 255.f); a = std::round(std::stof(trim(rolling.substr(0, rolling.find(',')))) * 255.f);
} catch (std::exception& e) { return std::unexpected("failed parsing " + VALUEWITHOUTFUNC); } } catch (std::exception& e) { return std::unexpected("failed parsing " + VALUEWITHOUTFUNC); }
return a * (Hyprlang::INT)0x1000000 + *r * (Hyprlang::INT)0x10000 + *g * (Hyprlang::INT)0x100 + *b; return a * sc<Hyprlang::INT>(0x1000000) + *r * sc<Hyprlang::INT>(0x10000) + *g * sc<Hyprlang::INT>(0x100) + *b;
} else if (VALUEWITHOUTFUNC.length() == 8) { } else if (VALUEWITHOUTFUNC.length() == 8) {
const auto RGBA = parseHex(VALUEWITHOUTFUNC); const auto RGBA = parseHex(VALUEWITHOUTFUNC);
@@ -670,7 +670,7 @@ std::expected<int64_t, std::string> configStringToInt(const std::string& VALUE)
if (!r || !g || !b) if (!r || !g || !b)
return std::unexpected("failed parsing " + VALUEWITHOUTFUNC); return std::unexpected("failed parsing " + VALUEWITHOUTFUNC);
return (Hyprlang::INT)0xFF000000 + *r * (Hyprlang::INT)0x10000 + *g * (Hyprlang::INT)0x100 + *b; return sc<Hyprlang::INT>(0xFF000000) + *r * sc<Hyprlang::INT>(0x10000) + *g * sc<Hyprlang::INT>(0x100) + *b;
} else if (VALUEWITHOUTFUNC.length() == 6) { } else if (VALUEWITHOUTFUNC.length() == 6) {
auto r = parseHex(VALUEWITHOUTFUNC); auto r = parseHex(VALUEWITHOUTFUNC);
return r ? *r + 0xFF000000 : r; return r ? *r + 0xFF000000 : r;
@@ -717,7 +717,7 @@ Vector2D configStringToVector2D(const std::string& VALUE) {
if (std::getline(iss, token)) if (std::getline(iss, token))
throw std::invalid_argument("Invalid string format"); throw std::invalid_argument("Invalid string format");
return Vector2D((double)x, (double)y); return Vector2D(sc<double>(x), sc<double>(y));
} }
double normalizeAngleRad(double ang) { double normalizeAngleRad(double ang) {
@@ -910,7 +910,7 @@ std::expected<std::string, std::string> binaryNameForPid(pid_t pid) {
sysctl(mib, miblen, &exe, &sz, NULL, 0); sysctl(mib, miblen, &exe, &sz, NULL, 0);
std::string path = exe; std::string path = exe;
#else #else
std::string path = std::format("/proc/{}/exe", (uint64_t)pid); std::string path = std::format("/proc/{}/exe", sc<uint64_t>(pid));
#endif #endif
std::error_code ec; std::error_code ec;

View File

@@ -213,7 +213,7 @@ void CMonitor::onConnect(bool noRule) {
m_damage.setSize(m_transformedSize); m_damage.setSize(m_transformedSize);
Debug::log(LOG, "Added new monitor with name {} at {:j0} with size {:j0}, pointer {:x}", m_output->name, m_position, m_pixelSize, (uintptr_t)m_output.get()); Debug::log(LOG, "Added new monitor with name {} at {:j0} with size {:j0}, pointer {:x}", m_output->name, m_position, m_pixelSize, rc<uintptr_t>(m_output.get()));
setupDefaultWS(monitorRule); setupDefaultWS(monitorRule);
@@ -577,7 +577,7 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
addBest3Modes([](auto const& a, auto const& b) { addBest3Modes([](auto const& a, auto const& b) {
if (std::round(a->refreshRate) > std::round(b->refreshRate)) if (std::round(a->refreshRate) > std::round(b->refreshRate))
return true; return true;
else if (DELTALESSTHAN((float)a->refreshRate, (float)b->refreshRate, 1.F) && a->pixelSize.x > b->pixelSize.x && a->pixelSize.y > b->pixelSize.y) else if (DELTALESSTHAN(sc<float>(a->refreshRate), sc<float>(b->refreshRate), 1.F) && a->pixelSize.x > b->pixelSize.x && a->pixelSize.y > b->pixelSize.y)
return true; return true;
return false; return false;
}); });
@@ -770,7 +770,7 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
bool set10bit = false; bool set10bit = false;
for (auto const& fmt : formats[(int)!RULE->enable10bit]) { for (auto const& fmt : formats[sc<int>(!RULE->enable10bit)]) {
m_output->state->setFormat(fmt.second); m_output->state->setFormat(fmt.second);
m_prevDrmFormat = m_drmFormat; m_prevDrmFormat = m_drmFormat;
m_drmFormat = fmt.second; m_drmFormat = fmt.second;
@@ -902,8 +902,8 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
// reload to fix mirrors // reload to fix mirrors
g_pConfigManager->m_wantsMonitorReload = true; g_pConfigManager->m_wantsMonitorReload = true;
Debug::log(LOG, "Monitor {} data dump: res {:X}@{:.2f}Hz, scale {:.2f}, transform {}, pos {:X}, 10b {}", m_name, m_pixelSize, m_refreshRate, m_scale, (int)m_transform, Debug::log(LOG, "Monitor {} data dump: res {:X}@{:.2f}Hz, scale {:.2f}, transform {}, pos {:X}, 10b {}", m_name, m_pixelSize, m_refreshRate, m_scale, sc<int>(m_transform),
m_position, (int)m_enabled10bit); m_position, sc<int>(m_enabled10bit));
EMIT_HOOK_EVENT("monitorLayoutChanged", nullptr); EMIT_HOOK_EVENT("monitorLayoutChanged", nullptr);
@@ -1003,7 +1003,7 @@ void CMonitor::setupDefaultWS(const SMonitorRule& monitorRule) {
auto PNEWWORKSPACE = g_pCompositor->getWorkspaceByID(wsID); auto PNEWWORKSPACE = g_pCompositor->getWorkspaceByID(wsID);
Debug::log(LOG, "New monitor: WORKSPACEID {}, exists: {}", wsID, (int)(PNEWWORKSPACE != nullptr)); Debug::log(LOG, "New monitor: WORKSPACEID {}, exists: {}", wsID, sc<int>(PNEWWORKSPACE != nullptr));
if (PNEWWORKSPACE) { if (PNEWWORKSPACE) {
// workspace exists, move it to the newly connected monitor // workspace exists, move it to the newly connected monitor
@@ -1078,7 +1078,7 @@ void CMonitor::setMirror(const std::string& mirrorOf) {
setupDefaultWS(RULE); setupDefaultWS(RULE);
applyMonitorRule((SMonitorRule*)&RULE, true); // will apply the offset and stuff applyMonitorRule(const_cast<SMonitorRule*>(&RULE), true); // will apply the offset and stuff
} else { } else {
PHLMONITOR BACKUPMON = nullptr; PHLMONITOR BACKUPMON = nullptr;
for (auto const& m : g_pCompositor->m_monitors) { for (auto const& m : g_pCompositor->m_monitors) {
@@ -1469,7 +1469,8 @@ bool CMonitor::attemptDirectScanout() {
if (!params.success || !PSURFACE->m_current.texture->m_eglImage /* dmabuf */) if (!params.success || !PSURFACE->m_current.texture->m_eglImage /* dmabuf */)
return false; return false;
Debug::log(TRACE, "attemptDirectScanout: surface {:x} passed, will attempt, buffer {}", (uintptr_t)PSURFACE.get(), (uintptr_t)PSURFACE->m_current.buffer.m_buffer.get()); Debug::log(TRACE, "attemptDirectScanout: surface {:x} passed, will attempt, buffer {}", rc<uintptr_t>(PSURFACE.get()),
rc<uintptr_t>(PSURFACE->m_current.buffer.m_buffer.get()));
auto PBUFFER = PSURFACE->m_current.buffer.m_buffer; auto PBUFFER = PSURFACE->m_current.buffer.m_buffer;
@@ -1532,7 +1533,7 @@ bool CMonitor::attemptDirectScanout() {
if (m_lastScanout.expired()) { if (m_lastScanout.expired()) {
m_lastScanout = PCANDIDATE; m_lastScanout = PCANDIDATE;
Debug::log(LOG, "Entered a direct scanout to {:x}: \"{}\"", (uintptr_t)PCANDIDATE.get(), PCANDIDATE->m_title); Debug::log(LOG, "Entered a direct scanout to {:x}: \"{}\"", rc<uintptr_t>(PCANDIDATE.get()), PCANDIDATE->m_title);
} }
m_scanoutNeedsCursorUpdate = false; m_scanoutNeedsCursorUpdate = false;

View File

@@ -47,7 +47,7 @@ int NSystemd::sdNotify(int unsetEnvironment, const char* state) {
if (unixAddr.sun_path[0] == '@') if (unixAddr.sun_path[0] == '@')
unixAddr.sun_path[0] = '\0'; unixAddr.sun_path[0] = '\0';
if (connect(fd, (const sockaddr*)&unixAddr, sizeof(struct sockaddr_un)) < 0) if (connect(fd, rc<const sockaddr*>(&unixAddr), sizeof(struct sockaddr_un)) < 0)
return -errno; return -errno;
// arbitrary value which seems to be enough for s-d messages // arbitrary value which seems to be enough for s-d messages

View File

@@ -1,4 +1,5 @@
#include "Math.hpp" #include "Math.hpp"
#include "../memory/Memory.hpp"
Hyprutils::Math::eTransform wlTransformToHyprutils(wl_output_transform t) { Hyprutils::Math::eTransform wlTransformToHyprutils(wl_output_transform t) {
switch (t) { switch (t) {
@@ -17,7 +18,7 @@ Hyprutils::Math::eTransform wlTransformToHyprutils(wl_output_transform t) {
wl_output_transform invertTransform(wl_output_transform tr) { wl_output_transform invertTransform(wl_output_transform tr) {
if ((tr & WL_OUTPUT_TRANSFORM_90) && !(tr & WL_OUTPUT_TRANSFORM_FLIPPED)) if ((tr & WL_OUTPUT_TRANSFORM_90) && !(tr & WL_OUTPUT_TRANSFORM_FLIPPED))
tr = (wl_output_transform)(tr ^ (int)WL_OUTPUT_TRANSFORM_180); tr = sc<wl_output_transform>(tr ^ sc<int>(WL_OUTPUT_TRANSFORM_180));
return tr; return tr;
} }

View File

@@ -51,7 +51,7 @@ void CHyprError::createQueued() {
const auto SCALE = PMONITOR->m_scale; const auto SCALE = PMONITOR->m_scale;
const auto FONTSIZE = std::clamp((int)(10.f * ((PMONITOR->m_pixelSize.x * SCALE) / 1920.f)), 8, 40); const auto FONTSIZE = std::clamp(sc<int>(10.f * ((PMONITOR->m_pixelSize.x * SCALE) / 1920.f)), 8, 40);
const auto CAIROSURFACE = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, PMONITOR->m_pixelSize.x, PMONITOR->m_pixelSize.y); const auto CAIROSURFACE = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, PMONITOR->m_pixelSize.x, PMONITOR->m_pixelSize.y);
@@ -82,7 +82,7 @@ void CHyprError::createQueued() {
const double X = PAD; const double X = PAD;
const double Y = TOPBAR ? PAD : PMONITOR->m_pixelSize.y - HEIGHT - PAD; const double Y = TOPBAR ? PAD : PMONITOR->m_pixelSize.y - HEIGHT - PAD;
m_damageBox = {0, 0, (int)PMONITOR->m_pixelSize.x, (int)HEIGHT + (int)PAD * 2}; m_damageBox = {0, 0, sc<int>(PMONITOR->m_pixelSize.x), sc<int>(HEIGHT) + sc<int>(PAD) * 2};
cairo_new_sub_path(CAIRO); cairo_new_sub_path(CAIRO);
cairo_arc(CAIRO, X + WIDTH - RADIUS, Y + RADIUS, RADIUS, -90 * DEGREES, 0 * DEGREES); cairo_arc(CAIRO, X + WIDTH - RADIUS, Y + RADIUS, RADIUS, -90 * DEGREES, 0 * DEGREES);
@@ -195,8 +195,8 @@ void CHyprError::draw() {
CBox monbox = {0, 0, PMONITOR->m_pixelSize.x, PMONITOR->m_pixelSize.y}; CBox monbox = {0, 0, PMONITOR->m_pixelSize.x, PMONITOR->m_pixelSize.y};
m_damageBox.x = (int)PMONITOR->m_position.x; m_damageBox.x = sc<int>(PMONITOR->m_position.x);
m_damageBox.y = (int)PMONITOR->m_position.y; m_damageBox.y = sc<int>(PMONITOR->m_position.y);
if (m_fadeOpacity->isBeingAnimated() || m_monitorChanged) if (m_fadeOpacity->isBeingAnimated() || m_monitorChanged)
g_pHyprRenderer->damageBox(m_damageBox); g_pHyprRenderer->damageBox(m_damageBox);

View File

@@ -139,8 +139,8 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
static auto PGAPSINDATA = CConfigValue<Hyprlang::CUSTOMTYPE>("general:gaps_in"); static auto PGAPSINDATA = CConfigValue<Hyprlang::CUSTOMTYPE>("general:gaps_in");
static auto PGAPSOUTDATA = CConfigValue<Hyprlang::CUSTOMTYPE>("general:gaps_out"); static auto PGAPSOUTDATA = CConfigValue<Hyprlang::CUSTOMTYPE>("general:gaps_out");
auto* const PGAPSIN = (CCssGapData*)(PGAPSINDATA.ptr())->getData(); auto* const PGAPSIN = sc<CCssGapData*>((PGAPSINDATA.ptr())->getData());
auto* const PGAPSOUT = (CCssGapData*)(PGAPSOUTDATA.ptr())->getData(); auto* const PGAPSOUT = sc<CCssGapData*>((PGAPSOUTDATA.ptr())->getData());
auto gapsIn = WORKSPACERULE.gapsIn.value_or(*PGAPSIN); auto gapsIn = WORKSPACERULE.gapsIn.value_or(*PGAPSIN);
auto gapsOut = WORKSPACERULE.gapsOut.value_or(*PGAPSOUT); auto gapsOut = WORKSPACERULE.gapsOut.value_or(*PGAPSOUT);
@@ -179,9 +179,9 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
} }
} }
const auto GAPOFFSETTOPLEFT = Vector2D((double)(DISPLAYLEFT ? gapsOut.m_left : gapsIn.m_left), (double)(DISPLAYTOP ? gapsOut.m_top : gapsIn.m_top)); const auto GAPOFFSETTOPLEFT = Vector2D(sc<double>(DISPLAYLEFT ? gapsOut.m_left : gapsIn.m_left), sc<double>(DISPLAYTOP ? gapsOut.m_top : gapsIn.m_top));
const auto GAPOFFSETBOTTOMRIGHT = Vector2D((double)(DISPLAYRIGHT ? gapsOut.m_right : gapsIn.m_right), (double)(DISPLAYBOTTOM ? gapsOut.m_bottom : gapsIn.m_bottom)); const auto GAPOFFSETBOTTOMRIGHT = Vector2D(sc<double>(DISPLAYRIGHT ? gapsOut.m_right : gapsIn.m_right), sc<double>(DISPLAYBOTTOM ? gapsOut.m_bottom : gapsIn.m_bottom));
calcPos = calcPos + GAPOFFSETTOPLEFT + ratioPadding / 2; calcPos = calcPos + GAPOFFSETTOPLEFT + ratioPadding / 2;
calcSize = calcSize - GAPOFFSETTOPLEFT - GAPOFFSETBOTTOMRIGHT - ratioPadding; calcSize = calcSize - GAPOFFSETTOPLEFT - GAPOFFSETBOTTOMRIGHT - ratioPadding;

View File

@@ -100,7 +100,7 @@ struct std::formatter<SDwindleNodeData*, CharT> : std::formatter<CharT> {
auto out = ctx.out(); auto out = ctx.out();
if (!node) if (!node)
return std::format_to(out, "[Node nullptr]"); return std::format_to(out, "[Node nullptr]");
std::format_to(out, "[Node {:x}: workspace: {}, pos: {:j2}, size: {:j2}", (uintptr_t)node, node->workspaceID, node->box.pos(), node->box.size()); std::format_to(out, "[Node {:x}: workspace: {}, pos: {:j2}, size: {:j2}", rc<uintptr_t>(node), node->workspaceID, node->box.pos(), node->box.size());
if (!node->isNode && !node->pWindow.expired()) if (!node->isNode && !node->pWindow.expired())
std::format_to(out, ", window: {:x}", node->pWindow.lock()); std::format_to(out, ", window: {:x}", node->pWindow.lock());
return std::format_to(out, "]"); return std::format_to(out, "]");

View File

@@ -435,7 +435,7 @@ void IHyprLayout::performSnap(Vector2D& sourcePos, Vector2D& sourceSize, PHLWIND
const auto WSID = DRAGGINGWINDOW->workspaceID(); const auto WSID = DRAGGINGWINDOW->workspaceID();
const bool HASFULLSCREEN = DRAGGINGWINDOW->m_workspace && DRAGGINGWINDOW->m_workspace->m_hasFullscreenWindow; const bool HASFULLSCREEN = DRAGGINGWINDOW->m_workspace && DRAGGINGWINDOW->m_workspace->m_hasFullscreenWindow;
const auto* GAPSIN = *SNAPRESPECTGAPS ? (CCssGapData*)PGAPSIN.ptr()->getData() : &GAPSNONE; const auto* GAPSIN = *SNAPRESPECTGAPS ? sc<CCssGapData*>(PGAPSIN.ptr()->getData()) : &GAPSNONE;
const double GAPSX = GAPSIN->m_left + GAPSIN->m_right; const double GAPSX = GAPSIN->m_left + GAPSIN->m_right;
const double GAPSY = GAPSIN->m_top + GAPSIN->m_bottom; const double GAPSY = GAPSIN->m_top + GAPSIN->m_bottom;
@@ -497,7 +497,7 @@ void IHyprLayout::performSnap(Vector2D& sourcePos, Vector2D& sourceSize, PHLWIND
const auto EXTENTNONE = SBoxExtents{{0, 0}, {0, 0}}; const auto EXTENTNONE = SBoxExtents{{0, 0}, {0, 0}};
const auto* EXTENTDIFF = *SNAPBORDEROVERLAP ? &EXTENTS : &EXTENTNONE; const auto* EXTENTDIFF = *SNAPBORDEROVERLAP ? &EXTENTS : &EXTENTNONE;
const auto MON = DRAGGINGWINDOW->m_monitor.lock(); const auto MON = DRAGGINGWINDOW->m_monitor.lock();
const auto* GAPSOUT = *SNAPRESPECTGAPS ? (CCssGapData*)PGAPSOUT.ptr()->getData() : &GAPSNONE; const auto* GAPSOUT = *SNAPRESPECTGAPS ? sc<CCssGapData*>(PGAPSOUT.ptr()->getData()) : &GAPSNONE;
SRange monX = {MON->m_position.x + MON->m_reservedTopLeft.x + GAPSOUT->m_left, MON->m_position.x + MON->m_size.x - MON->m_reservedBottomRight.x - GAPSOUT->m_right}; SRange monX = {MON->m_position.x + MON->m_reservedTopLeft.x + GAPSOUT->m_left, MON->m_position.x + MON->m_size.x - MON->m_reservedBottomRight.x - GAPSOUT->m_right};
SRange monY = {MON->m_position.y + MON->m_reservedTopLeft.y + GAPSOUT->m_top, MON->m_position.y + MON->m_size.y - MON->m_reservedBottomRight.y - GAPSOUT->m_bottom}; SRange monY = {MON->m_position.y + MON->m_reservedTopLeft.y + GAPSOUT->m_top, MON->m_position.y + MON->m_size.y - MON->m_reservedBottomRight.y - GAPSOUT->m_bottom};
@@ -745,7 +745,7 @@ void IHyprLayout::changeWindowFloatingMode(PHLWINDOW pWindow) {
const auto TILED = isWindowTiled(pWindow); const auto TILED = isWindowTiled(pWindow);
// event // event
g_pEventManager->postEvent(SHyprIPCEvent{"changefloatingmode", std::format("{:x},{}", (uintptr_t)pWindow.get(), (int)TILED)}); g_pEventManager->postEvent(SHyprIPCEvent{"changefloatingmode", std::format("{:x},{}", rc<uintptr_t>(pWindow.get()), sc<int>(TILED))});
EMIT_HOOK_EVENT("changeFloatingMode", pWindow); EMIT_HOOK_EVENT("changeFloatingMode", pWindow);
if (!TILED) { if (!TILED) {

View File

@@ -392,7 +392,7 @@ void CHyprMasterLayout::calculateWorkspace(PHLWORKSPACE pWorkspace) {
nextX = (WSSIZE.x - WIDTH) / 2; nextX = (WSSIZE.x - WIDTH) / 2;
PMASTERNODE->size = Vector2D(WIDTH, WSSIZE.y); PMASTERNODE->size = Vector2D(WIDTH, WSSIZE.y);
PMASTERNODE->position = WSPOS + Vector2D((double)nextX, 0.0); PMASTERNODE->position = WSPOS + Vector2D(nextX, 0.0);
} else { } else {
PMASTERNODE->size = WSSIZE; PMASTERNODE->size = WSSIZE;
PMASTERNODE->position = WSPOS; PMASTERNODE->position = WSPOS;
@@ -661,8 +661,8 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
static auto PANIMATE = CConfigValue<Hyprlang::INT>("misc:animate_manual_resizes"); static auto PANIMATE = CConfigValue<Hyprlang::INT>("misc:animate_manual_resizes");
static auto PGAPSINDATA = CConfigValue<Hyprlang::CUSTOMTYPE>("general:gaps_in"); static auto PGAPSINDATA = CConfigValue<Hyprlang::CUSTOMTYPE>("general:gaps_in");
static auto PGAPSOUTDATA = CConfigValue<Hyprlang::CUSTOMTYPE>("general:gaps_out"); static auto PGAPSOUTDATA = CConfigValue<Hyprlang::CUSTOMTYPE>("general:gaps_out");
auto* PGAPSIN = (CCssGapData*)(PGAPSINDATA.ptr())->getData(); auto* PGAPSIN = sc<CCssGapData*>((PGAPSINDATA.ptr())->getData());
auto* PGAPSOUT = (CCssGapData*)(PGAPSOUTDATA.ptr())->getData(); auto* PGAPSOUT = sc<CCssGapData*>((PGAPSOUTDATA.ptr())->getData());
auto gapsIn = WORKSPACERULE.gapsIn.value_or(*PGAPSIN); auto gapsIn = WORKSPACERULE.gapsIn.value_or(*PGAPSIN);
auto gapsOut = WORKSPACERULE.gapsOut.value_or(*PGAPSOUT); auto gapsOut = WORKSPACERULE.gapsOut.value_or(*PGAPSOUT);
@@ -680,9 +680,9 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
auto calcPos = PWINDOW->m_position; auto calcPos = PWINDOW->m_position;
auto calcSize = PWINDOW->m_size; auto calcSize = PWINDOW->m_size;
const auto OFFSETTOPLEFT = Vector2D((double)(DISPLAYLEFT ? gapsOut.m_left : gapsIn.m_left), (double)(DISPLAYTOP ? gapsOut.m_top : gapsIn.m_top)); const auto OFFSETTOPLEFT = Vector2D(sc<double>(DISPLAYLEFT ? gapsOut.m_left : gapsIn.m_left), sc<double>(DISPLAYTOP ? gapsOut.m_top : gapsIn.m_top));
const auto OFFSETBOTTOMRIGHT = Vector2D((double)(DISPLAYRIGHT ? gapsOut.m_right : gapsIn.m_right), (double)(DISPLAYBOTTOM ? gapsOut.m_bottom : gapsIn.m_bottom)); const auto OFFSETBOTTOMRIGHT = Vector2D(sc<double>(DISPLAYRIGHT ? gapsOut.m_right : gapsIn.m_right), sc<double>(DISPLAYBOTTOM ? gapsOut.m_bottom : gapsIn.m_bottom));
calcPos = calcPos + OFFSETTOPLEFT; calcPos = calcPos + OFFSETTOPLEFT;
calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT; calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT;
@@ -1382,10 +1382,10 @@ void CHyprMasterLayout::runOrientationCycle(SLayoutMessageHeader& header, CVarLi
} }
} }
if (nextOrPrev >= (int)cycle.size()) if (nextOrPrev >= sc<int>(cycle.size()))
nextOrPrev = nextOrPrev % (int)cycle.size(); nextOrPrev = nextOrPrev % sc<int>(cycle.size());
else if (nextOrPrev < 0) else if (nextOrPrev < 0)
nextOrPrev = cycle.size() + (nextOrPrev % (int)cycle.size()); nextOrPrev = cycle.size() + (nextOrPrev % sc<int>(cycle.size()));
PWORKSPACEDATA->orientation = cycle.at(nextOrPrev); PWORKSPACEDATA->orientation = cycle.at(nextOrPrev);
recalculateMonitor(header.pWindow->monitorID()); recalculateMonitor(header.pWindow->monitorID());
@@ -1393,7 +1393,7 @@ void CHyprMasterLayout::runOrientationCycle(SLayoutMessageHeader& header, CVarLi
void CHyprMasterLayout::buildOrientationCycleVectorFromEOperation(std::vector<eOrientation>& cycle) { void CHyprMasterLayout::buildOrientationCycleVectorFromEOperation(std::vector<eOrientation>& cycle) {
for (int i = 0; i <= ORIENTATION_CENTER; ++i) { for (int i = 0; i <= ORIENTATION_CENTER; ++i) {
cycle.push_back((eOrientation)i); cycle.push_back(sc<eOrientation>(i));
} }
} }

View File

@@ -100,7 +100,7 @@ struct std::formatter<SMasterNodeData*, CharT> : std::formatter<CharT> {
auto out = ctx.out(); auto out = ctx.out();
if (!node) if (!node)
return std::format_to(out, "[Node nullptr]"); return std::format_to(out, "[Node nullptr]");
std::format_to(out, "[Node {:x}: workspace: {}, pos: {:j2}, size: {:j2}", (uintptr_t)node, node->workspaceID, node->position, node->size); std::format_to(out, "[Node {:x}: workspace: {}, pos: {:j2}, size: {:j2}", rc<uintptr_t>(node), node->workspaceID, node->position, node->size);
if (node->isMaster) if (node->isMaster)
std::format_to(out, ", master"); std::format_to(out, ", master");
if (!node->pWindow.expired()) if (!node->pWindow.expired())

View File

@@ -228,17 +228,17 @@ void CHyprAnimationManager::tick() {
switch (PAV->m_Type) { switch (PAV->m_Type) {
case AVARTYPE_FLOAT: { case AVARTYPE_FLOAT: {
auto pTypedAV = dynamic_cast<CAnimatedVariable<float>*>(PAV.get()); auto pTypedAV = dc<CAnimatedVariable<float>*>(PAV.get());
RASSERT(pTypedAV, "Failed to upcast animated float"); RASSERT(pTypedAV, "Failed to upcast animated float");
handleUpdate(*pTypedAV, warp); handleUpdate(*pTypedAV, warp);
} break; } break;
case AVARTYPE_VECTOR: { case AVARTYPE_VECTOR: {
auto pTypedAV = dynamic_cast<CAnimatedVariable<Vector2D>*>(PAV.get()); auto pTypedAV = dc<CAnimatedVariable<Vector2D>*>(PAV.get());
RASSERT(pTypedAV, "Failed to upcast animated Vector2D"); RASSERT(pTypedAV, "Failed to upcast animated Vector2D");
handleUpdate(*pTypedAV, warp); handleUpdate(*pTypedAV, warp);
} break; } break;
case AVARTYPE_COLOR: { case AVARTYPE_COLOR: {
auto pTypedAV = dynamic_cast<CAnimatedVariable<CHyprColor>*>(PAV.get()); auto pTypedAV = dc<CAnimatedVariable<CHyprColor>*>(PAV.get());
RASSERT(pTypedAV, "Failed to upcast animated CHyprColor"); RASSERT(pTypedAV, "Failed to upcast animated CHyprColor");
handleUpdate(*pTypedAV, warp); handleUpdate(*pTypedAV, warp);
} break; } 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 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<int>(std::floor(TOPRES))));
} }
void CHyprAnimationManager::onTicked() { void CHyprAnimationManager::onTicked() {

View File

@@ -22,7 +22,7 @@ class CHyprAnimationManager : public Hyprutils::Animation::CAnimationManager {
constexpr const eAnimatedVarType EAVTYPE = typeToeAnimatedVarType<VarType>; constexpr const eAnimatedVarType EAVTYPE = typeToeAnimatedVarType<VarType>;
const auto PAV = makeShared<CAnimatedVariable<VarType>>(); const auto PAV = makeShared<CAnimatedVariable<VarType>>();
PAV->create(EAVTYPE, static_cast<Hyprutils::Animation::CAnimationManager*>(this), PAV, v); PAV->create(EAVTYPE, sc<Hyprutils::Animation::CAnimationManager*>(this), PAV, v);
PAV->setConfig(pConfig); PAV->setConfig(pConfig);
PAV->m_Context.eDamagePolicy = policy; PAV->m_Context.eDamagePolicy = policy;

View File

@@ -7,7 +7,7 @@
#include "../helpers/Monitor.hpp" #include "../helpers/Monitor.hpp"
static int cursorAnimTimer(SP<CEventLoopTimer> self, void* data) { static int cursorAnimTimer(SP<CEventLoopTimer> self, void* data) {
const auto cursorMgr = reinterpret_cast<CCursorManager*>(data); const auto cursorMgr = sc<CCursorManager*>(data);
cursorMgr->tickAnimatedCursor(); cursorMgr->tickAnimatedCursor();
return 1; 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)) { 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_; size = size_;
m_data = std::vector<uint8_t>((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<uint8_t>(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) { CCursorBuffer::CCursorBuffer(const uint8_t* pixelData, const Vector2D& size_, const Vector2D& hot_) : m_hotspot(hot_), m_stride(4 * size_.x) {
size = size_; size = size_;
m_data = std::vector<uint8_t>(pixelData, pixelData + ((int)size_.y * m_stride)); m_data = std::vector<uint8_t>(pixelData, pixelData + (sc<int>(size_.y) * m_stride));
} }
Aquamarine::eBufferCapability CCursorBuffer::caps() { 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 xcursor = m_xcursor->getShape(name, m_size, m_cursorScale);
auto& icon = xcursor->images.front(); auto& icon = xcursor->images.front();
auto buf = makeShared<CCursorBuffer>((uint8_t*)icon.pixels.data(), icon.size, icon.hotspot); auto buf = makeShared<CCursorBuffer>(rc<uint8_t*>(icon.pixels.data()), icon.size, icon.hotspot);
setCursorBuffer(buf, icon.hotspot / scale, scale); setCursorBuffer(buf, icon.hotspot / scale, scale);
m_currentXcursor = xcursor; m_currentXcursor = xcursor;
@@ -233,18 +233,18 @@ void CCursorManager::tickAnimatedCursor() {
if (!m_hyprcursor->valid() && m_currentXcursor->images.size() > 1) { if (!m_hyprcursor->valid() && m_currentXcursor->images.size() > 1) {
m_currentAnimationFrame++; m_currentAnimationFrame++;
if ((size_t)m_currentAnimationFrame >= m_currentXcursor->images.size()) if (sc<size_t>(m_currentAnimationFrame) >= m_currentXcursor->images.size())
m_currentAnimationFrame = 0; m_currentAnimationFrame = 0;
float scale = std::ceil(m_cursorScale); float scale = std::ceil(m_cursorScale);
auto& icon = m_currentXcursor->images.at(m_currentAnimationFrame); auto& icon = m_currentXcursor->images.at(m_currentAnimationFrame);
auto buf = makeShared<CCursorBuffer>((uint8_t*)icon.pixels.data(), icon.size, icon.hotspot); auto buf = makeShared<CCursorBuffer>(rc<uint8_t*>(icon.pixels.data()), icon.size, icon.hotspot);
setCursorBuffer(buf, icon.hotspot / scale, scale); setCursorBuffer(buf, icon.hotspot / scale, scale);
setAnimationTimer(m_currentAnimationFrame, m_currentXcursor->images[m_currentAnimationFrame].delay); setAnimationTimer(m_currentAnimationFrame, m_currentXcursor->images[m_currentAnimationFrame].delay);
} else if (m_currentCursorShapeData.images.size() > 1) { } else if (m_currentCursorShapeData.images.size() > 1) {
m_currentAnimationFrame++; m_currentAnimationFrame++;
if ((size_t)m_currentAnimationFrame >= m_currentCursorShapeData.images.size()) if (sc<size_t>(m_currentAnimationFrame) >= m_currentCursorShapeData.images.size())
m_currentAnimationFrame = 0; m_currentAnimationFrame = 0;
auto hotspot = auto hotspot =
@@ -281,7 +281,7 @@ void CCursorManager::setXWaylandCursor() {
auto xcursor = m_xcursor->getShape("left_ptr", m_size, 1); auto xcursor = m_xcursor->getShape("left_ptr", m_size, 1);
auto& icon = xcursor->images.front(); 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<uint8_t*>(icon.pixels.data()), icon.size.x * 4, icon.size, icon.hotspot);
} }
} }

View File

@@ -69,7 +69,7 @@ CDonationNagManager::CDonationNagManager() {
// don't nag if the last nag was less than a month ago. This is // 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 // mostly for first-time nags, as other nags happen in specific time frames shorter than a month
if (EPOCH - state.epoch < MONTH_IN_SECONDS) { 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<int>(std::round((EPOCH - state.epoch) / sc<double>(DAY_IN_SECONDS))));
return; return;
} }

View File

@@ -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); 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<sockaddr*>(&SERVERADDRESS), SUN_LEN(&SERVERADDRESS)) < 0) {
Debug::log(ERR, "Couldn't bind the Hyprland Socket 2. (3) IPC will not work."); Debug::log(ERR, "Couldn't bind the Hyprland Socket 2. (3) IPC will not work.");
return; return;
} }
@@ -70,7 +70,7 @@ int CEventManager::onServerEvent(int fd, uint32_t mask) {
sockaddr_in clientAddress; sockaddr_in clientAddress;
socklen_t clientSize = sizeof(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<sockaddr*>(&clientAddress), &clientSize, SOCK_CLOEXEC | SOCK_NONBLOCK)};
if (!ACCEPTEDCONNECTION.isValid()) { if (!ACCEPTEDCONNECTION.isValid()) {
if (errno != EAGAIN) { if (errno != EAGAIN) {
Debug::log(ERR, "Socket2 failed receiving connection, errno: {}", errno); Debug::log(ERR, "Socket2 failed receiving connection, errno: {}", errno);

View File

@@ -62,7 +62,7 @@ void CHookSystemManager::emit(std::vector<SCallbackFNPtr>* const callbacks, SCal
} catch (std::exception& e) { } catch (std::exception& e) {
// TODO: this works only once...? // TODO: this works only once...?
faultyHandles.push_back(cb.handle); 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<uintptr_t>(cb.handle));
} }
} }

View File

@@ -779,7 +779,7 @@ SDispatchResult CKeybindManager::handleKeybinds(const uint32_t modmask, const SP
// call the dispatcher // call the dispatcher
Debug::log(LOG, "Keybind triggered, calling dispatcher ({}, {}, {}, {})", modmask, key.keyName, key.keysym, DISPATCHER->first); Debug::log(LOG, "Keybind triggered, calling dispatcher ({}, {}, {}, {})", modmask, key.keyName, key.keysym, DISPATCHER->first);
m_passPressed = (int)pressed; m_passPressed = sc<int>(pressed);
// if the dispatchers says to pass event then we will // if the dispatchers says to pass event then we will
if (k->handler == "mouse") if (k->handler == "mouse")
@@ -942,7 +942,7 @@ uint64_t CKeybindManager::spawnWithRules(std::string args, PHLWORKSPACE pInitial
const auto RULESLIST = CVarList(RULES, 0, ';'); const auto RULESLIST = CVarList(RULES, 0, ';');
for (auto const& r : RULESLIST) { for (auto const& r : RULESLIST) {
g_pConfigManager->addExecRule({r, (unsigned long)PROC}); g_pConfigManager->addExecRule({r, sc<unsigned long>(PROC)});
} }
Debug::log(LOG, "Applied {} rule arguments for exec.", RULESLIST.size()); 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]); clientMode = std::stoi(ARGS[1]);
} catch (std::exception& e) { clientMode = -1; } } catch (std::exception& e) { clientMode = -1; }
const SFullscreenState STATE = SFullscreenState{.internal = (internalMode != -1 ? (eFullscreenMode)internalMode : PWINDOW->m_fullscreenState.internal), const SFullscreenState STATE = SFullscreenState{.internal = (internalMode != -1 ? sc<eFullscreenMode>(internalMode) : PWINDOW->m_fullscreenState.internal),
.client = (clientMode != -1 ? (eFullscreenMode)clientMode : PWINDOW->m_fullscreenState.client)}; .client = (clientMode != -1 ? sc<eFullscreenMode>(clientMode) : PWINDOW->m_fullscreenState.client)};
if (internalMode != -1 && clientMode != -1 && PWINDOW->m_fullscreenState.internal == STATE.internal && PWINDOW->m_fullscreenState.client == STATE.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}); 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(); const auto BORDERSIZE = PLASTWINDOW->getRealBorderSize();
static auto PGAPSCUSTOMDATA = CConfigValue<Hyprlang::CUSTOMTYPE>("general:float_gaps"); static auto PGAPSCUSTOMDATA = CConfigValue<Hyprlang::CUSTOMTYPE>("general:float_gaps");
static auto PGAPSOUTDATA = CConfigValue<Hyprlang::CUSTOMTYPE>("general:gaps_out"); static auto PGAPSOUTDATA = CConfigValue<Hyprlang::CUSTOMTYPE>("general:gaps_out");
auto* PGAPSOUT = (CCssGapData*)PGAPSCUSTOMDATA.ptr()->getData(); auto* PGAPSOUT = sc<CCssGapData*>(PGAPSCUSTOMDATA.ptr()->getData());
if (PGAPSOUT->m_left < 0 || PGAPSOUT->m_right < 0 || PGAPSOUT->m_top < 0 || PGAPSOUT->m_bottom < 0) if (PGAPSOUT->m_left < 0 || PGAPSOUT->m_right < 0 || PGAPSOUT->m_top < 0 || PGAPSOUT->m_bottom < 0)
PGAPSOUT = (CCssGapData*)PGAPSOUTDATA.ptr()->getData(); PGAPSOUT = sc<CCssGapData*>(PGAPSOUTDATA.ptr()->getData());
switch (arg) { switch (arg) {
case 'l': vPosx = PMONITOR->m_reservedTopLeft.x + BORDERSIZE + PMONITOR->m_position.x + PGAPSOUT->m_left; break; 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"}; return {.success = false, .error = "sendshortcut: no kb"};
} }
const auto KEYPAIRSTRING = std::format("{}{}", (uintptr_t)KB.get(), KEY); const auto KEYPAIRSTRING = std::format("{}{}", rc<uintptr_t>(KB.get()), KEY);
if (!g_pKeybindManager->m_keyToCodeCache.contains(KEYPAIRSTRING)) { if (!g_pKeybindManager->m_keyToCodeCache.contains(KEYPAIRSTRING)) {
xkb_keymap* km = KB->m_xkbKeymap; 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); 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<uintptr_t>(PWINDOW.get()), sc<int>(PWINDOW->m_pinned))});
EMIT_HOOK_EVENT("pin", PWINDOW); EMIT_HOOK_EVENT("pin", PWINDOW);
return {}; return {};
@@ -2941,7 +2941,7 @@ void CKeybindManager::moveWindowIntoGroup(PHLWINDOW pWindow, PHLWINDOW pWindowIn
g_pCompositor->focusWindow(pWindow); g_pCompositor->focusWindow(pWindow);
pWindow->warpCursor(); pWindow->warpCursor();
g_pEventManager->postEvent(SHyprIPCEvent{"moveintogroup", std::format("{:x}", (uintptr_t)pWindow.get())}); g_pEventManager->postEvent(SHyprIPCEvent{"moveintogroup", std::format("{:x}", rc<uintptr_t>(pWindow.get()))});
} }
void CKeybindManager::moveWindowOutOfGroup(PHLWINDOW pWindow, const std::string& dir) { void CKeybindManager::moveWindowOutOfGroup(PHLWINDOW pWindow, const std::string& dir) {
@@ -2982,7 +2982,7 @@ void CKeybindManager::moveWindowOutOfGroup(PHLWINDOW pWindow, const std::string&
PWINDOWPREV->warpCursor(); PWINDOWPREV->warpCursor();
} }
g_pEventManager->postEvent(SHyprIPCEvent{"moveoutofgroup", std::format("{:x}", (uintptr_t)pWindow.get())}); g_pEventManager->postEvent(SHyprIPCEvent{"moveoutofgroup", std::format("{:x}", rc<uintptr_t>(pWindow.get()))});
} }
SDispatchResult CKeybindManager::moveIntoGroup(std::string args) { SDispatchResult CKeybindManager::moveIntoGroup(std::string args) {
@@ -3097,7 +3097,7 @@ SDispatchResult CKeybindManager::moveWindowOrGroup(std::string args) {
} }
SDispatchResult CKeybindManager::setIgnoreGroupLock(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<Hyprlang::INT* const*>(g_pConfigManager->getConfigValuePtr("binds:ignore_group_lock"));
if (args == "toggle") if (args == "toggle")
**PIGNOREGROUPLOCK = !**PIGNOREGROUPLOCK; **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); CWindowOverridableVar(SAlphaValue{std::stof(VAL), PWINDOW->m_windowData.alphaFullscreen.valueOrDefault().overridden}, PRIORITY_SET_PROP);
} else if (PROP == "alphaoverride") { } else if (PROP == "alphaoverride") {
PWINDOW->m_windowData.alpha = 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<bool>(configStringToInt(VAL).value_or(0))}, PRIORITY_SET_PROP);
} else if (PROP == "alphainactiveoverride") { } else if (PROP == "alphainactiveoverride") {
PWINDOW->m_windowData.alphaInactive = 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<bool>(configStringToInt(VAL).value_or(0))}, PRIORITY_SET_PROP);
} else if (PROP == "alphafullscreenoverride") { } else if (PROP == "alphafullscreenoverride") {
PWINDOW->m_windowData.alphaFullscreen = 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<bool>(configStringToInt(VAL).value_or(0))}, PRIORITY_SET_PROP);
} else if (PROP == "activebordercolor" || PROP == "inactivebordercolor") { } else if (PROP == "activebordercolor" || PROP == "inactivebordercolor") {
CGradientValueData colorData = {}; CGradientValueData colorData = {};
if (vars.size() > 4) { if (vars.size() > 4) {
for (int i = 3; i < static_cast<int>(vars.size()); ++i) { for (int i = 3; i < sc<int>(vars.size()); ++i) {
const auto TOKEN = vars[i]; const auto TOKEN = vars[i];
if (TOKEN.ends_with("deg")) if (TOKEN.ends_with("deg"))
colorData.m_angle = std::stoi(TOKEN.substr(0, TOKEN.size() - 3)) * (PI / 180.0); 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") else if (VAL == "unset")
pWindowDataElement->unset(PRIORITY_SET_PROP); pWindowDataElement->unset(PRIORITY_SET_PROP);
else else
*pWindowDataElement = CWindowOverridableVar((bool)configStringToInt(VAL).value_or(0), PRIORITY_SET_PROP); *pWindowDataElement = CWindowOverridableVar(sc<bool>(configStringToInt(VAL).value_or(0)), PRIORITY_SET_PROP);
} else if (auto search = NWindowProperties::intWindowProperties.find(PROP); search != NWindowProperties::intWindowProperties.end()) { } else if (auto search = NWindowProperties::intWindowProperties.find(PROP); search != NWindowProperties::intWindowProperties.end()) {
if (VAL == "unset") if (VAL == "unset")
search->second(PWINDOW)->unset(PRIORITY_SET_PROP); 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(' '))); const Hyprlang::INT V = std::stoi(VAL.substr(VAL.find(' ')));
search->second(PWINDOW)->increment(V, PRIORITY_SET_PROP); search->second(PWINDOW)->increment(V, PRIORITY_SET_PROP);
} else if (const auto V = configStringToInt(VAL); V) } 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()) { } else if (auto search = NWindowProperties::floatWindowProperties.find(PROP); search != NWindowProperties::floatWindowProperties.end()) {
if (VAL == "unset") if (VAL == "unset")
search->second(PWINDOW)->unset(PRIORITY_SET_PROP); search->second(PWINDOW)->unset(PRIORITY_SET_PROP);

View File

@@ -12,7 +12,7 @@ IHyprLayout* CLayoutManager::getCurrentLayout() {
void CLayoutManager::switchToLayout(std::string layout) { void CLayoutManager::switchToLayout(std::string layout) {
for (size_t i = 0; i < m_layouts.size(); ++i) { for (size_t i = 0; i < m_layouts.size(); ++i) {
if (m_layouts[i].first == layout) { if (m_layouts[i].first == layout) {
if (i == (size_t)m_currentLayoutID) if (i == sc<size_t>(m_currentLayoutID))
return; return;
getCurrentLayout()->onDisable(); getCurrentLayout()->onDisable();
@@ -31,7 +31,7 @@ bool CLayoutManager::addLayout(const std::string& name, IHyprLayout* layout) {
m_layouts.emplace_back(std::make_pair<>(name, 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<uintptr_t>(layout));
return true; return true;
} }
@@ -45,7 +45,7 @@ bool CLayoutManager::removeLayout(IHyprLayout* layout) {
if (m_currentLayoutID == IT - m_layouts.begin()) if (m_currentLayoutID == IT - m_layouts.begin())
switchToLayout("dwindle"); 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<uintptr_t>(layout));
std::erase(m_layouts, *IT); std::erase(m_layouts, *IT);

View File

@@ -502,9 +502,8 @@ SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager
const auto DMABUF = buf->dmabuf(); const auto DMABUF = buf->dmabuf();
auto [data, fmt, size] = buf->beginDataPtr(0); auto [data, fmt, size] = buf->beginDataPtr(0);
auto CAIROSURFACE = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, DMABUF.size.x, DMABUF.size.y); auto CAIROSURFACE = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, DMABUF.size.x, DMABUF.size.y);
auto CAIRODATASURFACE = 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);
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 CAIRO = cairo_create(CAIROSURFACE); auto CAIRO = cairo_create(CAIROSURFACE);
@@ -525,7 +524,7 @@ SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager
cairo_matrix_scale(&matrixPre, SCALE.x, SCALE.y); cairo_matrix_scale(&matrixPre, SCALE.x, SCALE.y);
if (TR) { if (TR) {
cairo_matrix_rotate(&matrixPre, M_PI_2 * (double)TR); cairo_matrix_rotate(&matrixPre, M_PI_2 * sc<double>(TR));
// FIXME: this is wrong, and doesn't work for 5, 6 and 7. (flipped + rot) // 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?? // cba to do it rn, does anyone fucking use that??
@@ -550,7 +549,7 @@ SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager
cairo_pattern_destroy(PATTERNPRE); cairo_pattern_destroy(PATTERNPRE);
memcpy(data, cairo_image_surface_get_data(CAIROSURFACE), (size_t)cairo_image_surface_get_height(CAIROSURFACE) * cairo_image_surface_get_stride(CAIROSURFACE)); memcpy(data, cairo_image_surface_get_data(CAIROSURFACE), sc<size_t>(cairo_image_surface_get_height(CAIROSURFACE)) * cairo_image_surface_get_stride(CAIROSURFACE));
cairo_destroy(CAIRO); cairo_destroy(CAIRO);
cairo_surface_destroy(CAIROSURFACE); cairo_surface_destroy(CAIROSURFACE);
@@ -664,7 +663,7 @@ CBox CPointerManager::getCursorBoxGlobal() {
Vector2D CPointerManager::closestValid(const Vector2D& pos) { Vector2D CPointerManager::closestValid(const Vector2D& pos) {
static auto PADDING = CConfigValue<Hyprlang::INT>("cursor:hotspot_padding"); static auto PADDING = CConfigValue<Hyprlang::INT>("cursor:hotspot_padding");
auto CURSOR_PADDING = std::clamp((int)*PADDING, 0, 100); auto CURSOR_PADDING = std::clamp(sc<int>(*PADDING), 0, 100);
CBox hotBox = {{pos.x - CURSOR_PADDING, pos.y - CURSOR_PADDING}, {2 * CURSOR_PADDING, 2 * CURSOR_PADDING}}; 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<IHID> dev) {
switch (dev->getType()) { switch (dev->getType()) {
case HID_TYPE_TABLET: { case HID_TYPE_TABLET: {
CTablet* TAB = reinterpret_cast<CTablet*>(dev.get()); CTablet* TAB = rc<CTablet*>(dev.get());
if (!TAB->m_boundOutput.empty()) { if (!TAB->m_boundOutput.empty()) {
mappedArea = outputMappedArea(TAB->m_boundOutput); mappedArea = outputMappedArea(TAB->m_boundOutput);
mappedArea.translate(TAB->m_boundBox.pos()); mappedArea.translate(TAB->m_boundBox.pos());
@@ -826,13 +825,13 @@ void CPointerManager::warpAbsolute(Vector2D abs, SP<IHID> dev) {
break; break;
} }
case HID_TYPE_TOUCH: { case HID_TYPE_TOUCH: {
ITouch* TOUCH = reinterpret_cast<ITouch*>(dev.get()); ITouch* TOUCH = rc<ITouch*>(dev.get());
if (!TOUCH->m_boundOutput.empty()) if (!TOUCH->m_boundOutput.empty())
mappedArea = outputMappedArea(TOUCH->m_boundOutput); mappedArea = outputMappedArea(TOUCH->m_boundOutput);
break; break;
} }
case HID_TYPE_POINTER: { case HID_TYPE_POINTER: {
IPointer* POINTER = reinterpret_cast<IPointer*>(dev.get()); IPointer* POINTER = rc<IPointer*>(dev.get());
if (!POINTER->m_boundOutput.empty()) if (!POINTER->m_boundOutput.empty())
mappedArea = outputMappedArea(POINTER->m_boundOutput); mappedArea = outputMappedArea(POINTER->m_boundOutput);
break; break;
@@ -1118,7 +1117,7 @@ void CPointerManager::setStoredMovement(uint64_t time, const Vector2D& delta, co
} }
void CPointerManager::sendStoredMovement() { 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_storedTime = 0;
m_storedDelta = Vector2D{}; m_storedDelta = Vector2D{};
m_storedUnaccel = Vector2D{}; m_storedUnaccel = Vector2D{};

View File

@@ -15,9 +15,10 @@ std::string CTokenManager::getRandomUUID() {
do { do {
uuid_t uuid_; uuid_t uuid_;
uuid_generate_random(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], uuid = std::format("{:02x}{:02x}{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}", sc<uint16_t>(uuid_[0]), sc<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], sc<uint16_t>(uuid_[2]), sc<uint16_t>(uuid_[3]), sc<uint16_t>(uuid_[4]), sc<uint16_t>(uuid_[5]), sc<uint16_t>(uuid_[6]), sc<uint16_t>(uuid_[7]),
(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]); sc<uint16_t>(uuid_[8]), sc<uint16_t>(uuid_[9]), sc<uint16_t>(uuid_[10]), sc<uint16_t>(uuid_[11]), sc<uint16_t>(uuid_[12]), sc<uint16_t>(uuid_[13]),
sc<uint16_t>(uuid_[14]), sc<uint16_t>(uuid_[15]));
} while (m_tokens.contains(uuid)); } while (m_tokens.contains(uuid));
return uuid; return uuid;

View File

@@ -185,15 +185,15 @@ SP<SXCursors> CXCursorManager::getShape(std::string const& shape, int size, floa
SP<SXCursors> CXCursorManager::createCursor(std::string const& shape, void* ximages) { SP<SXCursors> CXCursorManager::createCursor(std::string const& shape, void* ximages) {
auto xcursor = makeShared<SXCursors>(); auto xcursor = makeShared<SXCursors>();
XcursorImages* xImages = (XcursorImages*)ximages; XcursorImages* xImages = sc<XcursorImages*>(ximages);
for (int i = 0; i < xImages->nimage; i++) { for (int i = 0; i < xImages->nimage; i++) {
auto xImage = xImages->images[i]; auto xImage = xImages->images[i];
SXCursorImage image; SXCursorImage image;
image.size = {(int)xImage->width, (int)xImage->height}; image.size = {sc<int>(xImage->width), sc<int>(xImage->height)};
image.hotspot = {(int)xImage->xhot, (int)xImage->yhot}; image.hotspot = {sc<int>(xImage->xhot), sc<int>(xImage->yhot)};
image.pixels.resize((size_t)xImage->width * xImage->height); image.pixels.resize(sc<size_t>(xImage->width) * xImage->height);
std::memcpy(image.pixels.data(), xImage->pixels, (size_t)xImage->width * xImage->height * sizeof(uint32_t)); std::memcpy(image.pixels.data(), xImage->pixels, sc<size_t>(xImage->width) * xImage->height * sizeof(uint32_t));
image.delay = xImage->delay; image.delay = xImage->delay;
xcursor->images.emplace_back(image); xcursor->images.emplace_back(image);
@@ -530,7 +530,7 @@ std::vector<SP<SXCursors>> CXCursorManager::loadAllFromDir(std::string const& pa
auto const& full = entry.path().string(); auto const& full = entry.path().string();
using PcloseType = int (*)(FILE*); using PcloseType = int (*)(FILE*);
const std::unique_ptr<FILE, PcloseType> f(fopen(full.c_str(), "r"), static_cast<PcloseType>(fclose)); const std::unique_ptr<FILE, PcloseType> f(fopen(full.c_str(), "r"), fclose);
if (!f) if (!f)
continue; continue;

View File

@@ -45,7 +45,7 @@ static int timerWrite(int fd, uint32_t mask, void* data) {
} }
static int aquamarineFDWrite(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<Aquamarine::SPollFD*>(data);
POLLFD->onSignal(); POLLFD->onSignal();
return 1; return 1;
} }
@@ -62,7 +62,7 @@ static int handleWaiterFD(int fd, uint32_t mask, void* data) {
} }
if (mask & WL_EVENT_READABLE) if (mask & WL_EVENT_READABLE)
g_pEventLoopManager->onFdReadable((CEventLoopManager::SReadableWaiter*)data); g_pEventLoopManager->onFdReadable(sc<CEventLoopManager::SReadableWaiter*>(data));
return 0; return 0;
} }
@@ -129,7 +129,7 @@ static void timespecAddNs(timespec* pTimespec, int64_t delta) {
pTimespec->tv_sec += delta_s_high; 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) { if (pTimespec->tv_nsec >= TIMESPEC_NSEC_PER_SEC) {
pTimespec->tv_nsec -= TIMESPEC_NSEC_PER_SEC; pTimespec->tv_nsec -= TIMESPEC_NSEC_PER_SEC;
++pTimespec->tv_sec; ++pTimespec->tv_sec;
@@ -181,7 +181,7 @@ void CEventLoopManager::doLater(const std::function<void()>& fn) {
m_idle.eventSource = wl_event_loop_add_idle( m_idle.eventSource = wl_event_loop_add_idle(
m_wayland.loop, m_wayland.loop,
[](void* data) { [](void* data) {
auto IDLE = (CEventLoopManager::SIdleData*)data; auto IDLE = sc<CEventLoopManager::SIdleData*>(data);
auto cpy = IDLE->fns; auto cpy = IDLE->fns;
IDLE->fns.clear(); IDLE->fns.clear();
IDLE->eventSource = nullptr; IDLE->eventSource = nullptr;

View File

@@ -8,7 +8,7 @@ void CInputManager::newIdleInhibitor(std::any inhibitor) {
const auto PINHIBIT = m_idleInhibitors.emplace_back(makeUnique<SIdleInhibitor>()).get(); const auto PINHIBIT = m_idleInhibitors.emplace_back(makeUnique<SIdleInhibitor>()).get();
PINHIBIT->inhibitor = std::any_cast<SP<CIdleInhibitor>>(inhibitor); PINHIBIT->inhibitor = std::any_cast<SP<CIdleInhibitor>>(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<uintptr_t>(PINHIBIT->inhibitor->m_surface.get()));
PINHIBIT->inhibitor->m_listeners.destroy = PINHIBIT->inhibitor->m_resource->m_events.destroy.listen([this, PINHIBIT] { 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; }); 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; return;
if (WLSurface->visible()) if (WLSurface->visible())
*(bool*)data = true; *sc<bool*>(data) = true;
}, },
&isInhibiting); &isInhibiting);

View File

@@ -54,7 +54,7 @@ CInputManager::CInputManager() {
if (wl_resource_get_client(event.pMgr->resource()) != g_pSeatManager->m_state.pointerFocusResource->client()) if (wl_resource_get_client(event.pMgr->resource()) != g_pSeatManager->m_state.pointerFocusResource->client())
return; return;
Debug::log(LOG, "cursorImage request: shape {} -> {}", (uint32_t)event.shape, event.shapeName); Debug::log(LOG, "cursorImage request: shape {} -> {}", sc<uint32_t>(event.shape), event.shapeName);
m_cursorSurfaceInfo.wlSurface->unassign(); m_cursorSurfaceInfo.wlSurface->unassign();
m_cursorSurfaceInfo.vHotspot = {}; m_cursorSurfaceInfo.vHotspot = {};
@@ -113,11 +113,11 @@ void CInputManager::onMouseMoved(IPointer::SMotionEvent e) {
const auto DELTA = *PNOACCEL == 1 ? unaccel : delta; const auto DELTA = *PNOACCEL == 1 ? unaccel : delta;
if (g_pSeatManager->m_isPointerFrameSkipped) if (g_pSeatManager->m_isPointerFrameSkipped)
g_pPointerManager->storeMovement((uint64_t)e.timeMs, DELTA, unaccel); g_pPointerManager->storeMovement(e.timeMs, DELTA, unaccel);
else 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<uint64_t>(e.timeMs) * 1000, DELTA, unaccel);
if (e.mouse) if (e.mouse)
recheckMouseWarpOnMouseInput(); recheckMouseWarpOnMouseInput();
@@ -236,13 +236,13 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) {
g_pCompositor->warpCursorTo(CLOSEST, true); g_pCompositor->warpCursorTo(CLOSEST, true);
g_pSeatManager->sendPointerMotion(time, CLOSESTLOCAL); g_pSeatManager->sendPointerMotion(time, CLOSESTLOCAL);
PROTO::relativePointer->sendRelativeMotion((uint64_t)time * 1000, {}, {}); PROTO::relativePointer->sendRelativeMotion(sc<uint64_t>(time) * 1000, {}, {});
} }
return; return;
} else } 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<uintptr_t>(SURF.get()), rc<uintptr_t>(CONSTRAINT.get()));
} }
if (PMONITOR != g_pCompositor->m_lastMonitor && (*PMOUSEFOCUSMON || refocus) && m_forcedFocus.expired()) if (PMONITOR != g_pCompositor->m_lastMonitor && (*PMOUSEFOCUSMON || refocus) && m_forcedFocus.expired())
@@ -644,7 +644,7 @@ void CInputManager::processMouseRequest(const CSeatManager::SSetCursorEvent& eve
if (!cursorImageUnlocked()) if (!cursorImageUnlocked())
return; return;
Debug::log(LOG, "cursorImage request: surface {:x}", (uintptr_t)event.surf.get()); Debug::log(LOG, "cursorImage request: surface {:x}", rc<uintptr_t>(event.surf.get()));
if (event.surf != m_cursorSurfaceInfo.wlSurface->resource()) { if (event.surf != m_cursorSurfaceInfo.wlSurface->resource()) {
m_cursorSurfaceInfo.wlSurface->unassign(); m_cursorSurfaceInfo.wlSurface->unassign();
@@ -937,7 +937,7 @@ void CInputManager::newKeyboard(SP<IKeyboard> keeb) {
setupKeyboard(PNEWKEYBOARD); 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<uintptr_t>(PNEWKEYBOARD.get()));
} }
void CInputManager::newKeyboard(SP<Aquamarine::IKeyboard> keyboard) { void CInputManager::newKeyboard(SP<Aquamarine::IKeyboard> keyboard) {
@@ -945,7 +945,7 @@ void CInputManager::newKeyboard(SP<Aquamarine::IKeyboard> keyboard) {
setupKeyboard(PNEWKEYBOARD); 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<uintptr_t>(PNEWKEYBOARD.get()), rc<uintptr_t>(keyboard.get()));
} }
void CInputManager::newVirtualKeyboard(SP<CVirtualKeyboardV1Resource> keyboard) { void CInputManager::newVirtualKeyboard(SP<CVirtualKeyboardV1Resource> keyboard) {
@@ -953,7 +953,7 @@ void CInputManager::newVirtualKeyboard(SP<CVirtualKeyboardV1Resource> keyboard)
setupKeyboard(PNEWKEYBOARD); 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<uintptr_t>(PNEWKEYBOARD.get()));
} }
void CInputManager::setupKeyboard(SP<IKeyboard> keeb) { void CInputManager::setupKeyboard(SP<IKeyboard> keeb) {
@@ -974,7 +974,7 @@ void CInputManager::setupKeyboard(SP<IKeyboard> keeb) {
return; return;
destroyKeyboard(PKEEB); destroyKeyboard(PKEEB);
Debug::log(LOG, "Destroyed keyboard {:x}", (uintptr_t)keeb); Debug::log(LOG, "Destroyed keyboard {:x}", rc<uintptr_t>(keeb));
}); });
keeb->m_keyboardEvents.key.listenStatic([this, keeb = keeb.get()](const IKeyboard::SKeyEvent& event) { keeb->m_keyboardEvents.key.listenStatic([this, keeb = keeb.get()](const IKeyboard::SKeyEvent& event) {
@@ -1035,7 +1035,7 @@ void CInputManager::applyConfigToKeyboard(SP<IKeyboard> pKeyboard) {
const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname); const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname);
Debug::log(LOG, "ApplyConfigToKeyboard for \"{}\", hasconfig: {}", devname, (int)HASCONFIG); Debug::log(LOG, "ApplyConfigToKeyboard for \"{}\", hasconfig: {}", devname, sc<int>(HASCONFIG));
const auto REPEATRATE = g_pConfigManager->getDeviceInt(devname, "repeat_rate", "input:repeat_rate"); const auto REPEATRATE = g_pConfigManager->getDeviceInt(devname, "repeat_rate", "input:repeat_rate");
const auto REPEATDELAY = g_pConfigManager->getDeviceInt(devname, "repeat_delay", "input:repeat_delay"); const auto REPEATDELAY = g_pConfigManager->getDeviceInt(devname, "repeat_delay", "input:repeat_delay");
@@ -1119,7 +1119,7 @@ void CInputManager::newMouse(SP<Aquamarine::IPointer> mouse) {
setupMouse(PMOUSE); 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<uintptr_t>(mouse.get()));
} }
void CInputManager::setupMouse(SP<IPointer> mauz) { void CInputManager::setupMouse(SP<IPointer> mauz) {
@@ -1135,8 +1135,8 @@ void CInputManager::setupMouse(SP<IPointer> mauz) {
const auto LIBINPUTDEV = mauz->aq()->getLibinputHandle(); 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), 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), libinput_device_config_accel_get_default_speed(LIBINPUTDEV), sc<int>(libinput_device_config_accel_get_profile(LIBINPUTDEV)),
(int)libinput_device_config_accel_get_default_profile(LIBINPUTDEV)); sc<int>(libinput_device_config_accel_get_default_profile(LIBINPUTDEV)));
} }
g_pPointerManager->attachPointer(mauz); 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"); const auto TAP_DRAG_LOCK = g_pConfigManager->getDeviceInt(devname, "drag_lock", "input:touchpad:drag_lock");
if (TAP_DRAG_LOCK >= 0 && TAP_DRAG_LOCK <= 2) { if (TAP_DRAG_LOCK >= 0 && TAP_DRAG_LOCK <= 2) {
libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, static_cast<libinput_config_drag_lock_state>(TAP_DRAG_LOCK)); libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, sc<libinput_config_drag_lock_state>(TAP_DRAG_LOCK));
} }
if (libinput_device_config_tap_get_finger_count(LIBINPUTDEV)) // this is for tapping (like on a laptop) 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) { if (libinput_device_config_3fg_drag_get_finger_count(LIBINPUTDEV) >= 3) {
const auto DRAG_3FG_STATE = static_cast<libinput_config_3fg_drag_state>(g_pConfigManager->getDeviceInt(devname, "drag_3fg", "input:touchpad:drag_3fg")); const auto DRAG_3FG_STATE = sc<libinput_config_3fg_drag_state>(g_pConfigManager->getDeviceInt(devname, "drag_3fg", "input:touchpad:drag_3fg"));
libinput_device_config_3fg_drag_set_enabled(LIBINPUTDEV, DRAG_3FG_STATE); libinput_device_config_3fg_drag_set_enabled(LIBINPUTDEV, DRAG_3FG_STATE);
} }
if (libinput_device_config_dwt_is_available(LIBINPUTDEV)) { if (libinput_device_config_dwt_is_available(LIBINPUTDEV)) {
const auto DWT = const auto DWT = sc<enum libinput_config_dwt_state>(g_pConfigManager->getDeviceInt(devname, "disable_while_typing", "input:touchpad:disable_while_typing") != 0);
static_cast<enum libinput_config_dwt_state>(g_pConfigManager->getDeviceInt(devname, "disable_while_typing", "input:touchpad:disable_while_typing") != 0);
libinput_device_config_dwt_set_enabled(LIBINPUTDEV, DWT); libinput_device_config_dwt_set_enabled(LIBINPUTDEV, DWT);
} }
@@ -1319,7 +1318,7 @@ static void removeFromHIDs(WP<IHID> hid) {
} }
void CInputManager::destroyKeyboard(SP<IKeyboard> pKeyboard) { void CInputManager::destroyKeyboard(SP<IKeyboard> pKeyboard) {
Debug::log(LOG, "Keyboard at {:x} removed", (uintptr_t)pKeyboard.get()); Debug::log(LOG, "Keyboard at {:x} removed", rc<uintptr_t>(pKeyboard.get()));
std::erase_if(m_keyboards, [pKeyboard](const auto& other) { return other == pKeyboard; }); std::erase_if(m_keyboards, [pKeyboard](const auto& other) { return other == pKeyboard; });
@@ -1343,7 +1342,7 @@ void CInputManager::destroyKeyboard(SP<IKeyboard> pKeyboard) {
} }
void CInputManager::destroyPointer(SP<IPointer> mouse) { void CInputManager::destroyPointer(SP<IPointer> mouse) {
Debug::log(LOG, "Pointer at {:x} removed", (uintptr_t)mouse.get()); Debug::log(LOG, "Pointer at {:x} removed", rc<uintptr_t>(mouse.get()));
std::erase_if(m_pointers, [mouse](const auto& other) { return other == mouse; }); std::erase_if(m_pointers, [mouse](const auto& other) { return other == mouse; });
@@ -1356,7 +1355,7 @@ void CInputManager::destroyPointer(SP<IPointer> mouse) {
} }
void CInputManager::destroyTouchDevice(SP<ITouch> touch) { void CInputManager::destroyTouchDevice(SP<ITouch> touch) {
Debug::log(LOG, "Touch device at {:x} removed", (uintptr_t)touch.get()); Debug::log(LOG, "Touch device at {:x} removed", rc<uintptr_t>(touch.get()));
std::erase_if(m_touches, [touch](const auto& other) { return other == touch; }); std::erase_if(m_touches, [touch](const auto& other) { return other == touch; });
@@ -1364,7 +1363,7 @@ void CInputManager::destroyTouchDevice(SP<ITouch> touch) {
} }
void CInputManager::destroyTablet(SP<CTablet> tablet) { void CInputManager::destroyTablet(SP<CTablet> tablet) {
Debug::log(LOG, "Tablet device at {:x} removed", (uintptr_t)tablet.get()); Debug::log(LOG, "Tablet device at {:x} removed", rc<uintptr_t>(tablet.get()));
std::erase_if(m_tablets, [tablet](const auto& other) { return other == tablet; }); std::erase_if(m_tablets, [tablet](const auto& other) { return other == tablet; });
@@ -1372,7 +1371,7 @@ void CInputManager::destroyTablet(SP<CTablet> tablet) {
} }
void CInputManager::destroyTabletTool(SP<CTabletTool> tool) { void CInputManager::destroyTabletTool(SP<CTabletTool> tool) {
Debug::log(LOG, "Tablet tool at {:x} removed", (uintptr_t)tool.get()); Debug::log(LOG, "Tablet tool at {:x} removed", rc<uintptr_t>(tool.get()));
std::erase_if(m_tabletTools, [tool](const auto& other) { return other == tool; }); std::erase_if(m_tabletTools, [tool](const auto& other) { return other == tool; });
@@ -1380,7 +1379,7 @@ void CInputManager::destroyTabletTool(SP<CTabletTool> tool) {
} }
void CInputManager::destroyTabletPad(SP<CTabletPad> pad) { void CInputManager::destroyTabletPad(SP<CTabletPad> pad) {
Debug::log(LOG, "Tablet pad at {:x} removed", (uintptr_t)pad.get()); Debug::log(LOG, "Tablet pad at {:x} removed", rc<uintptr_t>(pad.get()));
std::erase_if(m_tabletPads, [pad](const auto& other) { return other == pad; }); std::erase_if(m_tabletPads, [pad](const auto& other) { return other == pad; });
@@ -1674,7 +1673,7 @@ void CInputManager::newTouchDevice(SP<Aquamarine::ITouch> pDevice) {
destroyTouchDevice(PDEV); 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<uintptr_t>(PNEWDEV.get()));
} }
void CInputManager::setTouchDeviceConfigs(SP<ITouch> dev) { void CInputManager::setTouchDeviceConfigs(SP<ITouch> dev) {

View File

@@ -99,7 +99,7 @@ void CInputPopup::updateBox() {
if (!cursorRect) { if (!cursorRect) {
Vector2D coords = OWNER ? OWNER->getSurfaceBoxGlobal().value_or(CBox{0, 0, 500, 500}).pos() : Vector2D{0, 0}; Vector2D coords = OWNER ? OWNER->getSurfaceBoxGlobal().value_or(CBox{0, 0, 500, 500}).pos() : Vector2D{0, 0};
parentBox = {coords, {500, 500}}; parentBox = {coords, {500, 500}};
cursorBoxParent = {0, 0, (int)parentBox.w, (int)parentBox.h}; cursorBoxParent = {0, 0, sc<int>(parentBox.w), sc<int>(parentBox.h)};
} }
Vector2D currentPopupSize = m_surface->getViewporterCorrectedSize() / m_surface->resource()->m_current.scale; Vector2D currentPopupSize = m_surface->getViewporterCorrectedSize() / m_surface->resource()->m_current.scale;

View File

@@ -67,7 +67,7 @@ void CInputManager::endWorkspaceSwipe() {
// commit // commit
auto workspaceIDLeft = getWorkspaceIDNameFromString((*PSWIPEUSER ? "r-1" : "m-1")).id; auto workspaceIDLeft = getWorkspaceIDNameFromString((*PSWIPEUSER ? "r-1" : "m-1")).id;
auto workspaceIDRight = 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<int64_t>(1LL), sc<int64_t>(UINT32_MAX));
// If we've been swiping off the right end with PSWIPENEW enabled, there is // 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. // 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<Hyprlang::INT>("gestures:workspace_swipe_use_r"); static auto PSWIPEUSER = CConfigValue<Hyprlang::INT>("gestures:workspace_swipe_use_r");
static auto PWORKSPACEGAP = CConfigValue<Hyprlang::INT>("general:gaps_workspaces"); static auto PWORKSPACEGAP = CConfigValue<Hyprlang::INT>("general:gaps_workspaces");
const auto SWIPEDISTANCE = std::clamp(*PSWIPEDIST, (int64_t)1LL, (int64_t)UINT32_MAX); const auto SWIPEDISTANCE = std::clamp(*PSWIPEDIST, sc<int64_t>(1LL), sc<int64_t>(UINT32_MAX));
const auto XDISTANCE = m_activeSwipe.pMonitor->m_size.x + *PWORKSPACEGAP; const auto XDISTANCE = m_activeSwipe.pMonitor->m_size.x + *PWORKSPACEGAP;
const auto YDISTANCE = m_activeSwipe.pMonitor->m_size.y + *PWORKSPACEGAP; const auto YDISTANCE = m_activeSwipe.pMonitor->m_size.y + *PWORKSPACEGAP;
const auto ANIMSTYLE = m_activeSwipe.pWorkspaceBegin->m_renderOffset->getStyle(); 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.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<double>(-SWIPEDISTANCE), sc<double>(SWIPEDISTANCE));
if ((m_activeSwipe.pWorkspaceBegin->m_id == workspaceIDLeft && *PSWIPENEW && (m_activeSwipe.delta < 0)) || 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) || (m_activeSwipe.delta > 0 && m_activeSwipe.pWorkspaceBegin->getWindows() == 0 && workspaceIDRight <= m_activeSwipe.pWorkspaceBegin->m_id) ||

View File

@@ -251,7 +251,7 @@ void CTextInput::commitStateToIME(SP<CInputMethodV2> ime) {
ime->textChangeCause(ZWP_TEXT_INPUT_V3_CHANGE_CAUSE_INPUT_METHOD); ime->textChangeCause(ZWP_TEXT_INPUT_V3_CHANGE_CAUSE_INPUT_METHOD);
if (m_v1Input->m_pendingContentType.isPending) if (m_v1Input->m_pendingContentType.isPending)
ime->textContentType((zwpTextInputV3ContentHint)INPUT->m_pendingContentType.hint, (zwpTextInputV3ContentPurpose)INPUT->m_pendingContentType.purpose); ime->textContentType(sc<zwpTextInputV3ContentHint>(INPUT->m_pendingContentType.hint), sc<zwpTextInputV3ContentPurpose>(INPUT->m_pendingContentType.purpose));
} }
g_pInputManager->m_relay.updateAllPopups(); g_pInputManager->m_relay.updateAllPopups();

View File

@@ -16,7 +16,7 @@ void CInputManager::onTouchDown(ITouch::SDownEvent e) {
static auto PSWIPETOUCH = CConfigValue<Hyprlang::INT>("gestures:workspace_swipe_touch"); static auto PSWIPETOUCH = CConfigValue<Hyprlang::INT>("gestures:workspace_swipe_touch");
static auto PGAPSOUTDATA = CConfigValue<Hyprlang::CUSTOMTYPE>("general:gaps_out"); static auto PGAPSOUTDATA = CConfigValue<Hyprlang::CUSTOMTYPE>("general:gaps_out");
auto* const PGAPSOUT = (CCssGapData*)(PGAPSOUTDATA.ptr())->getData(); auto* const PGAPSOUT = sc<CCssGapData*>((PGAPSOUTDATA.ptr())->getData());
// TODO: WORKSPACERULE.gapsOut.value_or() // TODO: WORKSPACERULE.gapsOut.value_or()
auto gapsOut = *PGAPSOUT; auto gapsOut = *PGAPSOUT;
static auto PBORDERSIZE = CConfigValue<Hyprlang::INT>("general:border_size"); static auto PBORDERSIZE = CConfigValue<Hyprlang::INT>("general:border_size");
@@ -126,7 +126,7 @@ void CInputManager::onTouchMove(ITouch::SMotionEvent e) {
const bool VERTANIMS = ANIMSTYLE == "slidevert" || ANIMSTYLE.starts_with("slidefadevert"); const bool VERTANIMS = ANIMSTYLE == "slidevert" || ANIMSTYLE.starts_with("slidefadevert");
static auto PSWIPEINVR = CConfigValue<Hyprlang::INT>("gestures:workspace_swipe_touch_invert"); static auto PSWIPEINVR = CConfigValue<Hyprlang::INT>("gestures:workspace_swipe_touch_invert");
static auto PSWIPEDIST = CConfigValue<Hyprlang::INT>("gestures:workspace_swipe_distance"); static auto PSWIPEDIST = CConfigValue<Hyprlang::INT>("gestures:workspace_swipe_distance");
const auto SWIPEDISTANCE = std::clamp(*PSWIPEDIST, (int64_t)1LL, (int64_t)UINT32_MAX); const auto SWIPEDISTANCE = std::clamp(*PSWIPEDIST, sc<int64_t>(1LL), sc<int64_t>(UINT32_MAX));
// Handle the workspace swipe if there is one // Handle the workspace swipe if there is one
if (m_activeSwipe.initialDirection == -1) { if (m_activeSwipe.initialDirection == -1) {
if (*PSWIPEINVR) if (*PSWIPEINVR)

View File

@@ -92,7 +92,7 @@ eDynamicPermissionAllowMode CDynamicPermissionManager::clientPermissionMode(wl_c
const auto LOOKUP = binaryNameForWlClient(client); 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<uintptr_t>(client),
LOOKUP.has_value() ? LOOKUP.value() : "lookup failed: " + LOOKUP.error()); LOOKUP.has_value() ? LOOKUP.value() : "lookup failed: " + LOOKUP.error());
// first, check if we have the client + perm combo in our cache. // first, check if we have the client + perm combo in our cache.
@@ -174,7 +174,7 @@ eDynamicPermissionAllowMode CDynamicPermissionManager::clientPermissionModeWithS
if (lookup.has_value()) if (lookup.has_value())
binaryName = *lookup; binaryName = *lookup;
} else } else
binaryName = specialPidToString((eSpecialPidTypes)pid); binaryName = specialPidToString(sc<eSpecialPidTypes>(pid));
// first, check if we have the client + perm combo in our cache. // 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; }); 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 = ""; std::string description = "";
if (binaryPath.empty()) 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<uintptr_t>(client)));
else if (client) { else if (client) {
std::string binaryName = binaryPath.contains("/") ? binaryPath.substr(binaryPath.find_last_of('/') + 1) : binaryPath; std::string binaryName = binaryPath.contains("/") ? binaryPath.substr(binaryPath.find_last_of('/') + 1) : binaryPath;
description = std::format(std::runtime_format(permissionToHumanString(type)), std::format("{}</b> ({})", binaryName, binaryPath)); description = std::format(std::runtime_format(permissionToHumanString(type)), std::format("{}</b> ({})", binaryName, binaryPath));
} else { } else {
std::string lookup = ""; std::string lookup = "";
if (pid < 0) if (pid < 0)
lookup = specialPidToString((eSpecialPidTypes)pid); lookup = specialPidToString(sc<eSpecialPidTypes>(pid));
else { else {
const auto LOOKUP = binaryNameForPid(pid); const auto LOOKUP = binaryNameForPid(pid);
lookup = LOOKUP.value_or("Unknown"); lookup = LOOKUP.value_or("Unknown");

View File

@@ -33,7 +33,7 @@ CFunctionHook::SInstructionProbe CFunctionHook::getInstructionLenAt(void* start)
size_t curOffset = 1; size_t curOffset = 1;
size_t insSize = 0; size_t insSize = 0;
while (true) { while (true) {
ud_set_input_buffer(&udis, (uint8_t*)start, curOffset); ud_set_input_buffer(&udis, sc<uint8_t*>(start), curOffset);
insSize = ud_disassemble(&udis); insSize = ud_disassemble(&udis);
if (insSize != curOffset) if (insSize != curOffset)
break; break;
@@ -57,7 +57,7 @@ CFunctionHook::SInstructionProbe CFunctionHook::probeMinimumJumpSize(void* start
while (size <= min) { while (size <= min) {
// find info about this instruction // find info about this instruction
auto probe = getInstructionLenAt((uint8_t*)start + size); auto probe = getInstructionLenAt(sc<uint8_t*>(start) + size);
sizes.push_back(probe.len); sizes.push_back(probe.len);
size += probe.len; size += probe.len;
instrs += probe.assembly + "\n"; instrs += probe.assembly + "\n";
@@ -70,7 +70,7 @@ CFunctionHook::SAssembly CFunctionHook::fixInstructionProbeRIPCalls(const SInstr
SAssembly returns; SAssembly returns;
// analyze the code and fix what we know how to. // analyze the code and fix what we know how to.
uint64_t currentAddress = (uint64_t)m_source; uint64_t currentAddress = rc<uint64_t>(m_source);
// actually newline + 1 // actually newline + 1
size_t lastAsmNewline = 0; size_t lastAsmNewline = 0;
// needle for destination binary // needle for destination binary
@@ -83,7 +83,7 @@ CFunctionHook::SAssembly CFunctionHook::fixInstructionProbeRIPCalls(const SInstr
// copy original bytes to our finalBytes // copy original bytes to our finalBytes
for (size_t i = 0; i < len; ++i) { for (size_t i = 0; i < len; ++i) {
finalBytes[currentDestinationOffset + i] = *(char*)(currentAddress + i); finalBytes[currentDestinationOffset + i] = *rc<char*>(currentAddress + i);
} }
std::string code = probe.assembly.substr(lastAsmNewline, probe.assembly.find('\n', lastAsmNewline) - lastAsmNewline); std::string code = probe.assembly.substr(lastAsmNewline, probe.assembly.find('\n', lastAsmNewline) - lastAsmNewline);
@@ -106,14 +106,14 @@ CFunctionHook::SAssembly CFunctionHook::fixInstructionProbeRIPCalls(const SInstr
if (ADDREND == std::string::npos || ADDRSTART == std::string::npos) if (ADDREND == std::string::npos || ADDRSTART == std::string::npos)
return {}; return {};
const uint64_t PREDICTEDRIP = (uint64_t)m_trampolineAddr + currentDestinationOffset + len; const uint64_t PREDICTEDRIP = rc<uint64_t>(m_trampolineAddr) + currentDestinationOffset + len;
const int32_t NEWRIPOFFSET = DESTINATION - PREDICTEDRIP; const int32_t NEWRIPOFFSET = DESTINATION - PREDICTEDRIP;
size_t ripOffset = 0; size_t ripOffset = 0;
// find %rip usage offset from beginning // find %rip usage offset from beginning
for (int i = len - 4 /* 32-bit */; i > 0; --i) { for (int i = len - 4 /* 32-bit */; i > 0; --i) {
if (*(int32_t*)(currentAddress + i) == OFFSET) { if (*rc<int32_t*>(currentAddress + i) == OFFSET) {
ripOffset = i; ripOffset = i;
break; break;
} }
@@ -123,7 +123,7 @@ CFunctionHook::SAssembly CFunctionHook::fixInstructionProbeRIPCalls(const SInstr
return {}; return {};
// fix offset in the final bytes. This doesn't care about endianness // fix offset in the final bytes. This doesn't care about endianness
*(int32_t*)&finalBytes[currentDestinationOffset + ripOffset] = NEWRIPOFFSET; *rc<int32_t*>(&finalBytes[currentDestinationOffset + ripOffset]) = NEWRIPOFFSET;
currentDestinationOffset += len; currentDestinationOffset += len;
} else { } else {
@@ -157,7 +157,7 @@ bool CFunctionHook::hook() {
// alloc trampoline // alloc trampoline
const auto MAX_TRAMPOLINE_SIZE = HOOK_TRAMPOLINE_MAX_SIZE; // we will never need more. const auto MAX_TRAMPOLINE_SIZE = HOOK_TRAMPOLINE_MAX_SIZE; // we will never need more.
m_trampolineAddr = (void*)g_pFunctionHookSystem->getAddressForTrampo(); m_trampolineAddr = rc<void*>(g_pFunctionHookSystem->getAddressForTrampo());
// probe instructions to be trampolin'd // probe instructions to be trampolin'd
SInstructionProbe probe; SInstructionProbe probe;
@@ -186,31 +186,31 @@ bool CFunctionHook::hook() {
memcpy(m_originalBytes.data(), m_source, ORIGSIZE); memcpy(m_originalBytes.data(), m_source, ORIGSIZE);
// populate trampoline // populate trampoline
memcpy(m_trampolineAddr, PROBEFIXEDASM.bytes.data(), HOOKSIZE); // first, original but fixed func bytes memcpy(m_trampolineAddr, PROBEFIXEDASM.bytes.data(), HOOKSIZE); // first, original but fixed func bytes
memcpy((uint8_t*)m_trampolineAddr + HOOKSIZE, PUSH_RAX, sizeof(PUSH_RAX)); // then, pushq %rax memcpy(sc<uint8_t*>(m_trampolineAddr) + HOOKSIZE, PUSH_RAX, sizeof(PUSH_RAX)); // then, pushq %rax
memcpy((uint8_t*)m_trampolineAddr + HOOKSIZE + sizeof(PUSH_RAX), ABSOLUTE_JMP_ADDRESS, sizeof(ABSOLUTE_JMP_ADDRESS)); // then, jump to source memcpy(sc<uint8_t*>(m_trampolineAddr) + HOOKSIZE + sizeof(PUSH_RAX), ABSOLUTE_JMP_ADDRESS, sizeof(ABSOLUTE_JMP_ADDRESS)); // then, jump to source
// fixup trampoline addr // fixup trampoline addr
*(uint64_t*)((uint8_t*)m_trampolineAddr + TRAMPOLINE_SIZE - sizeof(ABSOLUTE_JMP_ADDRESS) + ABSOLUTE_JMP_ADDRESS_OFFSET) = *rc<uint64_t*>(sc<uint8_t*>(m_trampolineAddr) + TRAMPOLINE_SIZE - sizeof(ABSOLUTE_JMP_ADDRESS) + ABSOLUTE_JMP_ADDRESS_OFFSET) =
(uint64_t)((uint8_t*)m_source + sizeof(ABSOLUTE_JMP_ADDRESS)); rc<uint64_t>(sc<uint8_t*>(m_source) + sizeof(ABSOLUTE_JMP_ADDRESS));
// make jump to hk // make jump to hk
const auto PAGESIZE_VAR = sysconf(_SC_PAGE_SIZE); const auto PAGESIZE_VAR = sysconf(_SC_PAGE_SIZE);
const uint8_t* PROTSTART = (uint8_t*)m_source - ((uint64_t)m_source % PAGESIZE_VAR); const uint8_t* PROTSTART = sc<uint8_t*>(m_source) - (rc<uint64_t>(m_source) % PAGESIZE_VAR);
const size_t PROTLEN = std::ceil((float)(ORIGSIZE + ((uint64_t)m_source - (uint64_t)PROTSTART)) / (float)PAGESIZE_VAR) * PAGESIZE_VAR; const size_t PROTLEN = std::ceil(sc<float>(ORIGSIZE + (rc<uint64_t>(m_source) - rc<uint64_t>(PROTSTART))) / sc<float>(PAGESIZE_VAR)) * PAGESIZE_VAR;
mprotect((uint8_t*)PROTSTART, PROTLEN, PROT_READ | PROT_WRITE | PROT_EXEC); mprotect(const_cast<uint8_t*>(PROTSTART), PROTLEN, PROT_READ | PROT_WRITE | PROT_EXEC);
memcpy((uint8_t*)m_source, ABSOLUTE_JMP_ADDRESS, sizeof(ABSOLUTE_JMP_ADDRESS)); memcpy(m_source, ABSOLUTE_JMP_ADDRESS, sizeof(ABSOLUTE_JMP_ADDRESS));
// make popq %rax and NOP all remaining // make popq %rax and NOP all remaining
memcpy((uint8_t*)m_source + sizeof(ABSOLUTE_JMP_ADDRESS), POP_RAX, sizeof(POP_RAX)); memcpy(sc<uint8_t*>(m_source) + sizeof(ABSOLUTE_JMP_ADDRESS), POP_RAX, sizeof(POP_RAX));
size_t currentOp = sizeof(ABSOLUTE_JMP_ADDRESS) + sizeof(POP_RAX); size_t currentOp = sizeof(ABSOLUTE_JMP_ADDRESS) + sizeof(POP_RAX);
memset((uint8_t*)m_source + currentOp, NOP, ORIGSIZE - currentOp); memset(sc<uint8_t*>(m_source) + currentOp, NOP, ORIGSIZE - currentOp);
// fixup jump addr // fixup jump addr
*(uint64_t*)((uint8_t*)m_source + ABSOLUTE_JMP_ADDRESS_OFFSET) = (uint64_t)(m_destination); *rc<uint64_t*>(sc<uint8_t*>(m_source) + ABSOLUTE_JMP_ADDRESS_OFFSET) = rc<uint64_t>(m_destination);
// revert mprot // revert mprot
mprotect((uint8_t*)PROTSTART, PROTLEN, PROT_READ | PROT_EXEC); mprotect(const_cast<uint8_t*>(PROTSTART), PROTLEN, PROT_READ | PROT_EXEC);
// set original addr to trampo addr // set original addr to trampo addr
m_original = m_trampolineAddr; m_original = m_trampolineAddr;
@@ -232,13 +232,13 @@ bool CFunctionHook::unhook() {
return false; return false;
// allow write to src // allow write to src
mprotect((uint8_t*)m_source - ((uint64_t)m_source) % sysconf(_SC_PAGE_SIZE), sysconf(_SC_PAGE_SIZE), PROT_READ | PROT_WRITE | PROT_EXEC); mprotect(sc<uint8_t*>(m_source) - rc<uint64_t>(m_source) % sysconf(_SC_PAGE_SIZE), sysconf(_SC_PAGE_SIZE), PROT_READ | PROT_WRITE | PROT_EXEC);
// write back original bytes // write back original bytes
memcpy(m_source, m_originalBytes.data(), m_hookLen); memcpy(m_source, m_originalBytes.data(), m_hookLen);
// revert mprot // revert mprot
mprotect((uint8_t*)m_source - ((uint64_t)m_source) % sysconf(_SC_PAGE_SIZE), sysconf(_SC_PAGE_SIZE), PROT_READ | PROT_EXEC); mprotect(sc<uint8_t*>(m_source) - rc<uint64_t>(m_source) % sysconf(_SC_PAGE_SIZE), sysconf(_SC_PAGE_SIZE), PROT_READ | PROT_EXEC);
// reset vars // reset vars
m_active = false; m_active = false;
@@ -352,16 +352,16 @@ uint64_t CHookSystem::getAddressForTrampo() {
for (int i = 0; i <= 2; ++i) { for (int i = 0; i <= 2; ++i) {
const auto PAGEADDR = BASEPAGEADDR + i * PAGESIZE_VAR; const auto PAGEADDR = BASEPAGEADDR + i * PAGESIZE_VAR;
page->addr = (uint64_t)mmap((void*)PAGEADDR, PAGESIZE_VAR, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); page->addr = rc<uint64_t>(mmap(rc<void*>(PAGEADDR), PAGESIZE_VAR, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0));
page->len = PAGESIZE_VAR; page->len = PAGESIZE_VAR;
page->used = 0; page->used = 0;
Debug::log(LOG, "Attempted to allocate 0x{:x}, got 0x{:x}", PAGEADDR, page->addr); Debug::log(LOG, "Attempted to allocate 0x{:x}, got 0x{:x}", PAGEADDR, page->addr);
if (page->addr == (uint64_t)MAP_FAILED) if (page->addr == rc<uint64_t>(MAP_FAILED))
continue; continue;
if (page->addr != PAGEADDR && attempt == 0) { if (page->addr != PAGEADDR && attempt == 0) {
munmap((void*)page->addr, PAGESIZE_VAR); munmap(rc<void*>(page->addr), PAGESIZE_VAR);
page->addr = 0; page->addr = 0;
page->len = 0; page->len = 0;
continue; continue;

View File

@@ -94,7 +94,7 @@ APICALL CFunctionHook* HyprlandAPI::createFunctionHook(HANDLE handle, const void
if (!PLUGIN) if (!PLUGIN)
return nullptr; return nullptr;
return g_pFunctionHookSystem->initHook(handle, (void*)source, (void*)destination); return g_pFunctionHookSystem->initHook(handle, const_cast<void*>(source), const_cast<void*>(destination));
} }
APICALL bool HyprlandAPI::removeFunctionHook(HANDLE handle, CFunctionHook* hook) { APICALL bool HyprlandAPI::removeFunctionHook(HANDLE handle, CFunctionHook* hook) {

View File

@@ -89,8 +89,8 @@ std::expected<CPlugin*, std::string> CPluginSystem::loadPluginInternal(const std
PLUGIN->m_handle = MODULE; PLUGIN->m_handle = MODULE;
PPLUGIN_API_VERSION_FUNC apiVerFunc = (PPLUGIN_API_VERSION_FUNC)dlsym(MODULE, PLUGIN_API_VERSION_FUNC_STR); PPLUGIN_API_VERSION_FUNC apiVerFunc = rc<PPLUGIN_API_VERSION_FUNC>(dlsym(MODULE, PLUGIN_API_VERSION_FUNC_STR));
PPLUGIN_INIT_FUNC initFunc = (PPLUGIN_INIT_FUNC)dlsym(MODULE, PLUGIN_INIT_FUNC_STR); PPLUGIN_INIT_FUNC initFunc = rc<PPLUGIN_INIT_FUNC>(dlsym(MODULE, PLUGIN_INIT_FUNC_STR));
if (!apiVerFunc || !initFunc) { if (!apiVerFunc || !initFunc) {
Debug::log(ERR, " [PluginSystem] Plugin {} could not be loaded. (No apiver/init func)", path); Debug::log(ERR, " [PluginSystem] Plugin {} could not be loaded. (No apiver/init func)", path);
@@ -120,7 +120,7 @@ std::expected<CPlugin*, std::string> CPluginSystem::loadPluginInternal(const std
} }
} catch (std::exception& e) { } catch (std::exception& e) {
m_allowConfigVars = false; m_allowConfigVars = false;
Debug::log(ERR, " [PluginSystem] Plugin {} (Handle {:x}) crashed in init. Unloading.", path, (uintptr_t)MODULE); Debug::log(ERR, " [PluginSystem] Plugin {} (Handle {:x}) crashed in init. Unloading.", path, rc<uintptr_t>(MODULE));
unloadPlugin(PLUGIN, true); // Plugin could've already hooked/done something unloadPlugin(PLUGIN, true); // Plugin could've already hooked/done something
return std::unexpected(std::format("Plugin {} could not be loaded: plugin crashed/threw in main: {}", path, e.what())); return std::unexpected(std::format("Plugin {} could not be loaded: plugin crashed/threw in main: {}", path, e.what()));
} }
@@ -134,7 +134,7 @@ std::expected<CPlugin*, std::string> CPluginSystem::loadPluginInternal(const std
g_pEventLoopManager->doLater([] { g_pConfigManager->reload(); }); g_pEventLoopManager->doLater([] { g_pConfigManager->reload(); });
Debug::log(LOG, R"( [PluginSystem] Plugin {} loaded. Handle: {:x}, path: "{}", author: "{}", description: "{}", version: "{}")", PLUGINDATA.name, (uintptr_t)MODULE, path, Debug::log(LOG, R"( [PluginSystem] Plugin {} loaded. Handle: {:x}, path: "{}", author: "{}", description: "{}", version: "{}")", PLUGINDATA.name, rc<uintptr_t>(MODULE), path,
PLUGINDATA.author, PLUGINDATA.description, PLUGINDATA.version); PLUGINDATA.author, PLUGINDATA.description, PLUGINDATA.version);
return PLUGIN; return PLUGIN;
@@ -145,7 +145,7 @@ void CPluginSystem::unloadPlugin(const CPlugin* plugin, bool eject) {
return; return;
if (!eject) { if (!eject) {
PPLUGIN_EXIT_FUNC exitFunc = (PPLUGIN_EXIT_FUNC)dlsym(plugin->m_handle, PLUGIN_EXIT_FUNC_STR); PPLUGIN_EXIT_FUNC exitFunc = rc<PPLUGIN_EXIT_FUNC>(dlsym(plugin->m_handle, PLUGIN_EXIT_FUNC_STR));
if (exitFunc) if (exitFunc)
exitFunc(); exitFunc();
} }

View File

@@ -27,7 +27,7 @@ void CAlphaModifier::setResource(UP<CWpAlphaModifierSurfaceV1>&& resource) {
return; return;
} }
m_alpha = alpha / (float)UINT32_MAX; m_alpha = alpha / sc<float>(UINT32_MAX);
}); });
m_listeners.surfaceCommitted = m_surface->m_events.commit.listen([this] { m_listeners.surfaceCommitted = m_surface->m_events.commit.listen([this] {

View File

@@ -272,7 +272,7 @@ CColorManagementSurface::CColorManagementSurface(SP<CWpColorManagementSurfaceV1>
m_resource->setSetImageDescription([this](CWpColorManagementSurfaceV1* r, wl_resource* image_description, uint32_t render_intent) { m_resource->setSetImageDescription([this](CWpColorManagementSurfaceV1* r, wl_resource* image_description, uint32_t render_intent) {
LOGM(TRACE, "Set image description for surface={}, desc={}, intent={}", (uintptr_t)r, (uintptr_t)image_description, render_intent); LOGM(TRACE, "Set image description for surface={}, desc={}, intent={}", (uintptr_t)r, (uintptr_t)image_description, render_intent);
const auto PO = (CWpImageDescriptionV1*)wl_resource_get_user_data(image_description); const auto PO = sc<CWpImageDescriptionV1*>(wl_resource_get_user_data(image_description));
if (!PO) { // FIXME check validity if (!PO) { // FIXME check validity
r->error(WP_COLOR_MANAGEMENT_SURFACE_V1_ERROR_IMAGE_DESCRIPTION, "Image description creation failed"); r->error(WP_COLOR_MANAGEMENT_SURFACE_V1_ERROR_IMAGE_DESCRIPTION, "Image description creation failed");
return; return;
@@ -560,7 +560,7 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
default: r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_TF, "Unsupported transfer function"); return; default: r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_TF, "Unsupported transfer function"); return;
} }
m_settings.transferFunction = convertTransferFunction((wpColorManagerV1TransferFunction)tf); m_settings.transferFunction = convertTransferFunction(sc<wpColorManagerV1TransferFunction>(tf));
m_valuesSet |= PC_TF; m_valuesSet |= PC_TF;
}); });
m_resource->setSetTfPower([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t eexp) { m_resource->setSetTfPower([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t eexp) {
@@ -605,7 +605,7 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
} }
m_settings.primariesNameSet = true; m_settings.primariesNameSet = true;
m_settings.primariesNamed = convertPrimaries((wpColorManagerV1Primaries)primaries); m_settings.primariesNamed = convertPrimaries(sc<wpColorManagerV1Primaries>(primaries));
m_settings.primaries = getPrimaries(m_settings.primariesNamed); m_settings.primaries = getPrimaries(m_settings.primariesNamed);
m_valuesSet |= PC_PRIMARIES; m_valuesSet |= PC_PRIMARIES;
}); });
@@ -755,7 +755,7 @@ CColorManagementImageDescriptionInfo::CColorManagementImageDescriptionInfo(SP<CW
m_client = m_resource->client(); m_client = m_resource->client();
const auto toProto = [](float value) { return int32_t(std::round(value * 10000)); }; const auto toProto = [](float value) { return sc<int32_t>(std::round(value * 10000)); };
if (m_settings.icc.fd >= 0) if (m_settings.icc.fd >= 0)
m_resource->sendIccFile(m_settings.icc.fd, m_settings.icc.length); m_resource->sendIccFile(m_settings.icc.fd, m_settings.icc.length);

View File

@@ -41,7 +41,7 @@ void CCursorShapeProtocol::createCursorShapeDevice(CWpCursorShapeManagerV1* pMgr
} }
void CCursorShapeProtocol::onSetShape(CWpCursorShapeDeviceV1* pMgr, uint32_t serial, wpCursorShapeDeviceV1Shape shape) { void CCursorShapeProtocol::onSetShape(CWpCursorShapeDeviceV1* pMgr, uint32_t serial, wpCursorShapeDeviceV1Shape shape) {
if UNLIKELY ((uint32_t)shape == 0 || (uint32_t)shape >= CURSOR_SHAPE_NAMES.size()) { if UNLIKELY (sc<uint32_t>(shape) == 0 || sc<uint32_t>(shape) >= CURSOR_SHAPE_NAMES.size()) {
pMgr->error(WP_CURSOR_SHAPE_DEVICE_V1_ERROR_INVALID_SHAPE, "The shape is invalid"); pMgr->error(WP_CURSOR_SHAPE_DEVICE_V1_ERROR_INVALID_SHAPE, "The shape is invalid");
return; return;
} }

View File

@@ -147,7 +147,7 @@ bool CDRMLeaseRequestResource::good() {
} }
SP<CDRMLeaseConnectorResource> CDRMLeaseConnectorResource::fromResource(wl_resource* res) { SP<CDRMLeaseConnectorResource> CDRMLeaseConnectorResource::fromResource(wl_resource* res) {
auto data = (CDRMLeaseConnectorResource*)(((CWpDrmLeaseConnectorV1*)wl_resource_get_user_data(res))->data()); auto data = sc<CDRMLeaseConnectorResource*>(sc<CWpDrmLeaseConnectorV1*>(wl_resource_get_user_data(res))->data());
return data ? data->m_self.lock() : nullptr; return data ? data->m_self.lock() : nullptr;
} }
@@ -181,7 +181,7 @@ void CDRMLeaseConnectorResource::sendData() {
m_resource->sendName(m_monitor->m_name.c_str()); m_resource->sendName(m_monitor->m_name.c_str());
m_resource->sendDescription(m_monitor->m_description.c_str()); m_resource->sendDescription(m_monitor->m_description.c_str());
auto AQDRMOutput = (Aquamarine::CDRMOutput*)m_monitor->m_output.get(); auto AQDRMOutput = sc<Aquamarine::CDRMOutput*>(m_monitor->m_output.get());
m_resource->sendConnectorId(AQDRMOutput->getConnectorID()); m_resource->sendConnectorId(AQDRMOutput->getConnectorID());
m_resource->sendDone(); m_resource->sendDone();
@@ -265,7 +265,7 @@ CDRMLeaseProtocol::CDRMLeaseProtocol(const wl_interface* iface, const int& ver,
if (backend_->type() != Aquamarine::AQ_BACKEND_DRM) if (backend_->type() != Aquamarine::AQ_BACKEND_DRM)
return; return;
m_backend = ((Aquamarine::CDRMBackend*)backend_.get())->self.lock(); m_backend = sc<Aquamarine::CDRMBackend*>(backend_.get())->self.lock();
m_deviceName = m_backend->gpuName; m_deviceName = m_backend->gpuName;
CFileDescriptor fd{m_backend->getNonMasterFD()}; CFileDescriptor fd{m_backend->getNonMasterFD()};

View File

@@ -61,7 +61,7 @@ CDRMSyncobjSurfaceResource::CDRMSyncobjSurfaceResource(UP<CWpLinuxDrmSyncobjSurf
} }
auto timeline = CDRMSyncobjTimelineResource::fromResource(timeline_); auto timeline = CDRMSyncobjTimelineResource::fromResource(timeline_);
m_pendingAcquire = {timeline->m_timeline, ((uint64_t)hi << 32) | (uint64_t)lo}; m_pendingAcquire = {timeline->m_timeline, (sc<uint64_t>(hi) << 32) | sc<uint64_t>(lo)};
}); });
m_resource->setSetReleasePoint([this](CWpLinuxDrmSyncobjSurfaceV1* r, wl_resource* timeline_, uint32_t hi, uint32_t lo) { m_resource->setSetReleasePoint([this](CWpLinuxDrmSyncobjSurfaceV1* r, wl_resource* timeline_, uint32_t hi, uint32_t lo) {
@@ -71,7 +71,7 @@ CDRMSyncobjSurfaceResource::CDRMSyncobjSurfaceResource(UP<CWpLinuxDrmSyncobjSurf
} }
auto timeline = CDRMSyncobjTimelineResource::fromResource(timeline_); auto timeline = CDRMSyncobjTimelineResource::fromResource(timeline_);
m_pendingRelease = {timeline->m_timeline, ((uint64_t)hi << 32) | (uint64_t)lo}; m_pendingRelease = {timeline->m_timeline, (sc<uint64_t>(hi) << 32) | sc<uint64_t>(lo)};
}); });
m_listeners.surfacePrecommit = m_surface->m_events.precommit.listen([this] { m_listeners.surfacePrecommit = m_surface->m_events.precommit.listen([this] {

View File

@@ -65,7 +65,7 @@ CWLRDataSource::~CWLRDataSource() {
} }
SP<CWLRDataSource> CWLRDataSource::fromResource(wl_resource* res) { SP<CWLRDataSource> CWLRDataSource::fromResource(wl_resource* res) {
auto data = (CWLRDataSource*)(((CZwlrDataControlSourceV1*)wl_resource_get_user_data(res))->data()); auto data = sc<CWLRDataSource*>(sc<CZwlrDataControlSourceV1*>(wl_resource_get_user_data(res))->data());
return data ? data->m_self.lock() : nullptr; return data ? data->m_self.lock() : nullptr;
} }

View File

@@ -20,7 +20,7 @@ CExtWorkspaceGroupResource::CExtWorkspaceGroupResource(WP<CExtWorkspaceManagerRe
m_resource->setOnDestroy([this](auto) { PROTO::extWorkspace->destroyGroup(m_self); }); m_resource->setOnDestroy([this](auto) { PROTO::extWorkspace->destroyGroup(m_self); });
m_resource->setDestroy([this](auto) { PROTO::extWorkspace->destroyGroup(m_self); }); m_resource->setDestroy([this](auto) { PROTO::extWorkspace->destroyGroup(m_self); });
m_resource->sendCapabilities(static_cast<extWorkspaceGroupHandleV1GroupCapabilities>(0)); m_resource->sendCapabilities(sc<extWorkspaceGroupHandleV1GroupCapabilities>(0));
const auto& output = PROTO::outputs.at(m_monitor->m_name); const auto& output = PROTO::outputs.at(m_monitor->m_name);
@@ -41,8 +41,8 @@ bool CExtWorkspaceGroupResource::good() const {
} }
WP<CExtWorkspaceGroupResource> CExtWorkspaceGroupResource::fromResource(wl_resource* resource) { WP<CExtWorkspaceGroupResource> CExtWorkspaceGroupResource::fromResource(wl_resource* resource) {
auto handle = static_cast<CExtWorkspaceGroupHandleV1*>(wl_resource_get_user_data(resource))->data(); auto handle = sc<CExtWorkspaceGroupHandleV1*>(wl_resource_get_user_data(resource))->data();
auto data = static_cast<CExtWorkspaceGroupResource*>(handle); auto data = sc<CExtWorkspaceGroupResource*>(handle);
return data ? data->m_self : WP<CExtWorkspaceGroupResource>(); return data ? data->m_self : WP<CExtWorkspaceGroupResource>();
} }
@@ -105,7 +105,7 @@ CExtWorkspaceResource::CExtWorkspaceResource(WP<CExtWorkspaceManagerResource> ma
id += UINT32_MAX - 1337; id += UINT32_MAX - 1337;
if (id > 0) if (id > 0)
*static_cast<uint32_t*>(wl_array_add(&coordinates, sizeof(uint32_t))) = id; *sc<uint32_t*>(wl_array_add(&coordinates, sizeof(uint32_t))) = id;
m_resource->sendCoordinates(&coordinates); m_resource->sendCoordinates(&coordinates);
wl_array_release(&coordinates); wl_array_release(&coordinates);
@@ -142,7 +142,7 @@ void CExtWorkspaceResource::sendState() {
if (m_workspace->m_isSpecialWorkspace) if (m_workspace->m_isSpecialWorkspace)
state |= EXT_WORKSPACE_HANDLE_V1_STATE_HIDDEN; state |= EXT_WORKSPACE_HANDLE_V1_STATE_HIDDEN;
m_resource->sendState(static_cast<extWorkspaceHandleV1State>(state)); m_resource->sendState(sc<extWorkspaceHandleV1State>(state));
if (m_manager) if (m_manager)
m_manager->scheduleDone(); m_manager->scheduleDone();
@@ -158,7 +158,7 @@ void CExtWorkspaceResource::sendCapabilities() {
if (active && m_workspace->m_isSpecialWorkspace) if (active && m_workspace->m_isSpecialWorkspace)
capabilities |= EXT_WORKSPACE_HANDLE_V1_WORKSPACE_CAPABILITIES_DEACTIVATE; capabilities |= EXT_WORKSPACE_HANDLE_V1_WORKSPACE_CAPABILITIES_DEACTIVATE;
m_resource->sendCapabilities(static_cast<extWorkspaceHandleV1WorkspaceCapabilities>(capabilities)); m_resource->sendCapabilities(sc<extWorkspaceHandleV1WorkspaceCapabilities>(capabilities));
if (m_manager) if (m_manager)
m_manager->scheduleDone(); m_manager->scheduleDone();

View File

@@ -55,7 +55,7 @@ void CForeignToplevelList::onMap(PHLWINDOW pWindow) {
return; return;
} }
const auto IDENTIFIER = std::format("{:08x}->{:016x}", static_cast<uint32_t>((uintptr_t)this & 0xFFFFFFFF), (uintptr_t)pWindow.get()); const auto IDENTIFIER = std::format("{:08x}->{:016x}", sc<uint32_t>(rc<uintptr_t>(this) & 0xFFFFFFFF), rc<uintptr_t>(pWindow.get()));
LOGM(LOG, "Newly mapped window gets an identifier of {}", IDENTIFIER); LOGM(LOG, "Newly mapped window gets an identifier of {}", IDENTIFIER);
m_resource->sendToplevel(NEWHANDLE->m_resource.get()); m_resource->sendToplevel(NEWHANDLE->m_resource.get());
@@ -172,6 +172,6 @@ bool CForeignToplevelProtocol::windowValidForForeign(PHLWINDOW pWindow) {
} }
PHLWINDOW CForeignToplevelProtocol::windowFromHandleResource(wl_resource* res) { PHLWINDOW CForeignToplevelProtocol::windowFromHandleResource(wl_resource* res) {
auto data = (CForeignToplevelHandle*)(((CExtForeignToplevelHandleV1*)wl_resource_get_user_data(res))->data()); auto data = sc<CForeignToplevelHandle*>(sc<CExtForeignToplevelHandleV1*>(wl_resource_get_user_data(res))->data());
return data ? data->window() : nullptr; return data ? data->window() : nullptr;
} }

View File

@@ -109,7 +109,7 @@ CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SP<CZwlrForeignToplevelHand
if UNLIKELY (!PWINDOW->m_isMapped) if UNLIKELY (!PWINDOW->m_isMapped)
return; return;
g_pEventManager->postEvent(SHyprIPCEvent{.event = "minimized", .data = std::format("{:x},1", (uintptr_t)PWINDOW.get())}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "minimized", .data = std::format("{:x},1", rc<uintptr_t>(PWINDOW.get()))});
}); });
m_resource->setUnsetMinimized([this](CZwlrForeignToplevelHandleV1* p) { m_resource->setUnsetMinimized([this](CZwlrForeignToplevelHandleV1* p) {
@@ -121,7 +121,7 @@ CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SP<CZwlrForeignToplevelHand
if UNLIKELY (!PWINDOW->m_isMapped) if UNLIKELY (!PWINDOW->m_isMapped)
return; return;
g_pEventManager->postEvent(SHyprIPCEvent{.event = "minimized", .data = std::format("{:x},0", (uintptr_t)PWINDOW.get())}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "minimized", .data = std::format("{:x},0", rc<uintptr_t>(PWINDOW.get()))});
}); });
m_resource->setClose([this](CZwlrForeignToplevelHandleV1* p) { m_resource->setClose([this](CZwlrForeignToplevelHandleV1* p) {
@@ -179,12 +179,12 @@ void CForeignToplevelHandleWlr::sendState() {
wl_array_init(&state); wl_array_init(&state);
if (PWINDOW == g_pCompositor->m_lastWindow) { if (PWINDOW == g_pCompositor->m_lastWindow) {
auto p = (uint32_t*)wl_array_add(&state, sizeof(uint32_t)); auto p = sc<uint32_t*>(wl_array_add(&state, sizeof(uint32_t)));
*p = ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_ACTIVATED; *p = ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_ACTIVATED;
} }
if (PWINDOW->isFullscreen()) { if (PWINDOW->isFullscreen()) {
auto p = (uint32_t*)wl_array_add(&state, sizeof(uint32_t)); auto p = sc<uint32_t*>(wl_array_add(&state, sizeof(uint32_t)));
if (PWINDOW->isEffectiveInternalFSMode(FSMODE_FULLSCREEN)) if (PWINDOW->isEffectiveInternalFSMode(FSMODE_FULLSCREEN))
*p = ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_FULLSCREEN; *p = ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_FULLSCREEN;
else else
@@ -424,7 +424,7 @@ void CForeignToplevelWlrProtocol::destroyHandle(CForeignToplevelHandleWlr* handl
} }
PHLWINDOW CForeignToplevelWlrProtocol::windowFromHandleResource(wl_resource* res) { PHLWINDOW CForeignToplevelWlrProtocol::windowFromHandleResource(wl_resource* res) {
auto data = (CForeignToplevelHandleWlr*)(((CZwlrForeignToplevelHandleV1*)wl_resource_get_user_data(res))->data()); auto data = sc<CForeignToplevelHandleWlr*>(sc<CZwlrForeignToplevelHandleV1*>(wl_resource_get_user_data(res))->data());
return data ? data->window() : nullptr; return data ? data->window() : nullptr;
} }

View File

@@ -19,7 +19,7 @@ static wpColorManagerV1TransferFunction getWPTransferFunction(frogColorManagedSu
} }
static wpColorManagerV1Primaries getWPPrimaries(frogColorManagedSurfacePrimaries primaries) { static wpColorManagerV1Primaries getWPPrimaries(frogColorManagedSurfacePrimaries primaries) {
return (wpColorManagerV1Primaries)(primaries + 1); return sc<wpColorManagerV1Primaries>(primaries + 1);
} }
CFrogColorManager::CFrogColorManager(SP<CFrogColorManagementFactoryV1> resource_) : m_resource(resource_) { CFrogColorManager::CFrogColorManager(SP<CFrogColorManagementFactoryV1> resource_) : m_resource(resource_) {

View File

@@ -80,10 +80,10 @@ CGammaControl::CGammaControl(SP<CZwlrGammaControlV1> resource_, wl_resource* out
moreBytes = read(gammaFd.get(), buf, BUF_SIZE); moreBytes = read(gammaFd.get(), buf, BUF_SIZE);
} }
if (readBytes < 0 || (size_t)readBytes != m_gammaTable.size() * sizeof(uint16_t) || moreBytes != 0) { if (readBytes < 0 || sc<size_t>(readBytes) != m_gammaTable.size() * sizeof(uint16_t) || moreBytes != 0) {
LOGM(ERR, "Failed to read bytes"); LOGM(ERR, "Failed to read bytes");
if ((size_t)readBytes != m_gammaTable.size() * sizeof(uint16_t) || moreBytes > 0) { if (sc<size_t>(readBytes) != m_gammaTable.size() * sizeof(uint16_t) || moreBytes > 0) {
gamma->error(ZWLR_GAMMA_CONTROL_V1_ERROR_INVALID_GAMMA, "Gamma ramps size mismatch"); gamma->error(ZWLR_GAMMA_CONTROL_V1_ERROR_INVALID_GAMMA, "Gamma ramps size mismatch");
return; return;
} }

View File

@@ -3,7 +3,7 @@
static int onTimer(SP<CEventLoopTimer> self, void* data) { static int onTimer(SP<CEventLoopTimer> self, void* data) {
const auto NOTIF = (CExtIdleNotification*)data; const auto NOTIF = sc<CExtIdleNotification*>(data);
NOTIF->onTimerFired(); NOTIF->onTimerFired();

View File

@@ -58,7 +58,7 @@ void CInputMethodKeyboardGrabV2::sendKeyboardData(SP<IKeyboard> keyboard) {
void CInputMethodKeyboardGrabV2::sendKey(uint32_t time, uint32_t key, wl_keyboard_key_state state) { void CInputMethodKeyboardGrabV2::sendKey(uint32_t time, uint32_t key, wl_keyboard_key_state state) {
const auto SERIAL = g_pSeatManager->nextSerial(g_pSeatManager->seatResourceForClient(m_resource->client())); const auto SERIAL = g_pSeatManager->nextSerial(g_pSeatManager->seatResourceForClient(m_resource->client()));
m_resource->sendKey(SERIAL, time, key, (uint32_t)state); m_resource->sendKey(SERIAL, time, key, sc<uint32_t>(state));
} }
void CInputMethodKeyboardGrabV2::sendMods(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group) { void CInputMethodKeyboardGrabV2::sendMods(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group) {
@@ -243,11 +243,11 @@ void CInputMethodV2::surroundingText(const std::string& text, uint32_t cursor, u
} }
void CInputMethodV2::textChangeCause(zwpTextInputV3ChangeCause changeCause) { void CInputMethodV2::textChangeCause(zwpTextInputV3ChangeCause changeCause) {
m_resource->sendTextChangeCause((uint32_t)changeCause); m_resource->sendTextChangeCause(changeCause);
} }
void CInputMethodV2::textContentType(zwpTextInputV3ContentHint hint, zwpTextInputV3ContentPurpose purpose) { void CInputMethodV2::textContentType(zwpTextInputV3ContentHint hint, zwpTextInputV3ContentPurpose purpose) {
m_resource->sendContentType((uint32_t)hint, (uint32_t)purpose); m_resource->sendContentType(hint, purpose);
} }
void CInputMethodV2::done() { void CInputMethodV2::done() {

View File

@@ -11,7 +11,7 @@ void CLayerShellResource::SState::reset() {
exclusive = 0; exclusive = 0;
interactivity = ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE; interactivity = ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE;
layer = ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM; layer = ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM;
exclusiveEdge = (zwlrLayerSurfaceV1Anchor)0; exclusiveEdge = sc<zwlrLayerSurfaceV1Anchor>(0);
desiredSize = {}; desiredSize = {};
margin = {0, 0, 0, 0}; margin = {0, 0, 0, 0};
} }
@@ -84,7 +84,7 @@ CLayerShellResource::CLayerShellResource(SP<CZwlrLayerSurfaceV1> resource_, SP<C
m_resource->setSetSize([this](CZwlrLayerSurfaceV1* r, uint32_t x, uint32_t y) { m_resource->setSetSize([this](CZwlrLayerSurfaceV1* r, uint32_t x, uint32_t y) {
m_pending.committed |= STATE_SIZE; m_pending.committed |= STATE_SIZE;
m_pending.desiredSize = {(int)x, (int)y}; m_pending.desiredSize = {sc<int>(x), sc<int>(y)};
}); });
m_resource->setSetAnchor([this](CZwlrLayerSurfaceV1* r, zwlrLayerSurfaceV1Anchor anchor) { m_resource->setSetAnchor([this](CZwlrLayerSurfaceV1* r, zwlrLayerSurfaceV1Anchor anchor) {
@@ -150,7 +150,7 @@ CLayerShellResource::CLayerShellResource(SP<CZwlrLayerSurfaceV1> resource_, SP<C
} }
m_pending.committed |= STATE_LAYER; m_pending.committed |= STATE_LAYER;
m_pending.layer = (zwlrLayerShellV1Layer)layer; m_pending.layer = sc<zwlrLayerShellV1Layer>(layer);
}); });
m_resource->setSetExclusiveEdge([this](CZwlrLayerSurfaceV1* r, zwlrLayerSurfaceV1Anchor anchor) { m_resource->setSetExclusiveEdge([this](CZwlrLayerSurfaceV1* r, zwlrLayerSurfaceV1Anchor anchor) {

View File

@@ -58,7 +58,7 @@ class CLayerShellResource {
Vector2D desiredSize; Vector2D desiredSize;
zwlrLayerSurfaceV1KeyboardInteractivity interactivity = ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE; zwlrLayerSurfaceV1KeyboardInteractivity interactivity = ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE;
zwlrLayerShellV1Layer layer = ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM; zwlrLayerShellV1Layer layer = ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM;
zwlrLayerSurfaceV1Anchor exclusiveEdge = (zwlrLayerSurfaceV1Anchor)0; zwlrLayerSurfaceV1Anchor exclusiveEdge = sc<zwlrLayerSurfaceV1Anchor>(0);
uint32_t committed = 0; uint32_t committed = 0;
struct { struct {

View File

@@ -80,7 +80,7 @@ CDMABUFFormatTable::CDMABUFFormatTable(SDMABUFTranche _rendererTranche, std::vec
CFileDescriptor fds[2]; CFileDescriptor fds[2];
allocateSHMFilePair(m_tableSize, fds[0], fds[1]); allocateSHMFilePair(m_tableSize, fds[0], fds[1]);
auto arr = (SDMABUFFormatTableEntry*)mmap(nullptr, m_tableSize, PROT_READ | PROT_WRITE, MAP_SHARED, fds[0].get(), 0); auto arr = sc<SDMABUFFormatTableEntry*>(mmap(nullptr, m_tableSize, PROT_READ | PROT_WRITE, MAP_SHARED, fds[0].get(), 0));
if (arr == MAP_FAILED) { if (arr == MAP_FAILED) {
LOGM(ERR, "mmap failed"); LOGM(ERR, "mmap failed");
@@ -150,7 +150,7 @@ CLinuxDMABUFParamsResource::CLinuxDMABUFParamsResource(UP<CZwpLinuxBufferParamsV
m_attrs->fds[plane] = fd; m_attrs->fds[plane] = fd;
m_attrs->strides[plane] = stride; m_attrs->strides[plane] = stride;
m_attrs->offsets[plane] = offset; m_attrs->offsets[plane] = offset;
m_attrs->modifier = ((uint64_t)modHi << 32) | modLo; m_attrs->modifier = (sc<uint64_t>(modHi) << 32) | modLo;
}); });
m_resource->setCreate([this](CZwpLinuxBufferParamsV1* r, int32_t w, int32_t h, uint32_t fmt, zwpLinuxBufferParamsV1Flags flags) { m_resource->setCreate([this](CZwpLinuxBufferParamsV1* r, int32_t w, int32_t h, uint32_t fmt, zwpLinuxBufferParamsV1Flags flags) {
@@ -279,11 +279,11 @@ bool CLinuxDMABUFParamsResource::verify() {
return false; return false;
} }
for (size_t i = 0; i < (size_t)m_attrs->planes; ++i) { for (size_t i = 0; i < sc<size_t>(m_attrs->planes); ++i) {
if ((uint64_t)m_attrs->offsets.at(i) + (uint64_t)m_attrs->strides.at(i) * m_attrs->size.y > UINT32_MAX) { if (sc<uint64_t>(m_attrs->offsets.at(i)) + sc<uint64_t>(m_attrs->strides.at(i)) * m_attrs->size.y > UINT32_MAX) {
m_resource->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS, m_resource->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS,
std::format("size overflow on plane {}: offset {} + stride {} * height {} = {}, overflows UINT32_MAX", i, (uint64_t)m_attrs->offsets.at(i), std::format("size overflow on plane {}: offset {} + stride {} * height {} = {}, overflows UINT32_MAX", i, sc<uint64_t>(m_attrs->offsets.at(i)),
(uint64_t)m_attrs->strides.at(i), m_attrs->size.y, (uint64_t)m_attrs->offsets.at(i) + (uint64_t)m_attrs->strides.at(i))); sc<uint64_t>(m_attrs->strides.at(i)), m_attrs->size.y, sc<uint64_t>(m_attrs->offsets.at(i)) + sc<uint64_t>(m_attrs->strides.at(i))));
return false; return false;
} }
} }
@@ -311,11 +311,11 @@ bool CLinuxDMABUFFeedbackResource::good() {
void CLinuxDMABUFFeedbackResource::sendTranche(SDMABUFTranche& tranche) { void CLinuxDMABUFFeedbackResource::sendTranche(SDMABUFTranche& tranche) {
struct wl_array deviceArr = { struct wl_array deviceArr = {
.size = sizeof(tranche.device), .size = sizeof(tranche.device),
.data = (void*)&tranche.device, .data = sc<void*>(&tranche.device),
}; };
m_resource->sendTrancheTargetDevice(&deviceArr); m_resource->sendTrancheTargetDevice(&deviceArr);
m_resource->sendTrancheFlags((zwpLinuxDmabufFeedbackV1TrancheFlags)tranche.flags); m_resource->sendTrancheFlags(sc<zwpLinuxDmabufFeedbackV1TrancheFlags>(tranche.flags));
wl_array indices = { wl_array indices = {
.size = tranche.indices.size() * sizeof(tranche.indices.at(0)), .size = tranche.indices.size() * sizeof(tranche.indices.at(0)),
@@ -332,7 +332,7 @@ void CLinuxDMABUFFeedbackResource::sendDefaultFeedback() {
struct wl_array deviceArr = { struct wl_array deviceArr = {
.size = sizeof(mainDevice), .size = sizeof(mainDevice),
.data = (void*)&mainDevice, .data = sc<void*>(&mainDevice),
}; };
m_resource->sendMainDevice(&deviceArr); m_resource->sendMainDevice(&deviceArr);
@@ -577,7 +577,7 @@ void CLinuxDMABufV1Protocol::updateScanoutTranche(SP<CWLSurfaceResource> surface
struct wl_array deviceArr = { struct wl_array deviceArr = {
.size = sizeof(m_mainDevice), .size = sizeof(m_mainDevice),
.data = (void*)&m_mainDevice, .data = sc<void*>(&m_mainDevice),
}; };
feedbackResource->m_resource->sendMainDevice(&deviceArr); feedbackResource->m_resource->sendMainDevice(&deviceArr);

View File

@@ -480,7 +480,7 @@ COutputConfigurationHead::COutputConfigurationHead(SP<CZwlrOutputConfigurationHe
} }
m_state.committedProperties |= OUTPUT_HEAD_COMMITTED_CUSTOM_MODE; m_state.committedProperties |= OUTPUT_HEAD_COMMITTED_CUSTOM_MODE;
m_state.customMode = {{w, h}, (uint32_t)refresh}; m_state.customMode = {{w, h}, sc<uint32_t>(refresh)};
LOGM(LOG, " | configHead for {}: set custom mode to {}x{}@{}", m_monitor->m_name, w, h, refresh); LOGM(LOG, " | configHead for {}: set custom mode to {}x{}@{}", m_monitor->m_name, w, h, refresh);
}); });
@@ -519,7 +519,7 @@ COutputConfigurationHead::COutputConfigurationHead(SP<CZwlrOutputConfigurationHe
} }
m_state.committedProperties |= OUTPUT_HEAD_COMMITTED_TRANSFORM; m_state.committedProperties |= OUTPUT_HEAD_COMMITTED_TRANSFORM;
m_state.transform = (wl_output_transform)transform; m_state.transform = sc<wl_output_transform>(transform);
LOGM(LOG, " | configHead for {}: set transform to {}", m_monitor->m_name, transform); LOGM(LOG, " | configHead for {}: set transform to {}", m_monitor->m_name, transform);
}); });

View File

@@ -65,8 +65,8 @@ void CPresentationFeedback::sendQueued(WP<CQueuedPresentationData> data, const T
tv_sec = TIMESPEC.tv_sec >> 32; tv_sec = TIMESPEC.tv_sec >> 32;
if (data->m_wasPresented) if (data->m_wasPresented)
m_resource->sendPresented((uint32_t)tv_sec, (uint32_t)(TIMESPEC.tv_sec & 0xFFFFFFFF), (uint32_t)(TIMESPEC.tv_nsec), untilRefreshNs, (uint32_t)(seq >> 32), m_resource->sendPresented(sc<uint32_t>(tv_sec), sc<uint32_t>(TIMESPEC.tv_sec & 0xFFFFFFFF), sc<uint32_t>(TIMESPEC.tv_nsec), untilRefreshNs, sc<uint32_t>(seq >> 32),
(uint32_t)(seq & 0xFFFFFFFF), (wpPresentationFeedbackKind)flags); sc<uint32_t>(seq & 0xFFFFFFFF), sc<wpPresentationFeedbackKind>(flags));
else else
m_resource->sendDiscarded(); m_resource->sendDiscarded();

View File

@@ -66,7 +66,7 @@ CPrimarySelectionSource::~CPrimarySelectionSource() {
} }
SP<CPrimarySelectionSource> CPrimarySelectionSource::fromResource(wl_resource* res) { SP<CPrimarySelectionSource> CPrimarySelectionSource::fromResource(wl_resource* res) {
auto data = (CPrimarySelectionSource*)(((CZwpPrimarySelectionSourceV1*)wl_resource_get_user_data(res))->data()); auto data = sc<CPrimarySelectionSource*>(sc<CZwpPrimarySelectionSourceV1*>(wl_resource_get_user_data(res))->data());
return data ? data->m_self.lock() : nullptr; return data ? data->m_self.lock() : nullptr;
} }

View File

@@ -63,7 +63,7 @@ CScreencopyFrame::CScreencopyFrame(SP<CZwlrScreencopyFrameV1> resource_, int32_t
m_dmabufFormat = m_monitor->m_output->state->state().drmFormat; m_dmabufFormat = m_monitor->m_output->state->state().drmFormat;
if (box_.width == 0 && box_.height == 0) if (box_.width == 0 && box_.height == 0)
m_box = {0, 0, (int)(m_monitor->m_size.x), (int)(m_monitor->m_size.y)}; m_box = {0, 0, sc<int>(m_monitor->m_size.x), sc<int>(m_monitor->m_size.y)};
else else
m_box = box_; m_box = box_;
@@ -133,7 +133,7 @@ void CScreencopyFrame::copy(CZwlrScreencopyFrameV1* pFrame, wl_resource* buffer_
m_resource->error(ZWLR_SCREENCOPY_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer format"); m_resource->error(ZWLR_SCREENCOPY_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer format");
PROTO::screencopy->destroyResource(this); PROTO::screencopy->destroyResource(this);
return; return;
} else if ((int)attrs.stride != m_shmStride) { } else if (attrs.stride != m_shmStride) {
LOGM(ERR, "Invalid buffer shm stride in {:x}", (uintptr_t)pFrame); LOGM(ERR, "Invalid buffer shm stride in {:x}", (uintptr_t)pFrame);
m_resource->error(ZWLR_SCREENCOPY_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer stride"); m_resource->error(ZWLR_SCREENCOPY_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer stride");
PROTO::screencopy->destroyResource(this); PROTO::screencopy->destroyResource(this);
@@ -172,7 +172,7 @@ void CScreencopyFrame::share() {
return; return;
} }
m_resource->sendFlags((zwlrScreencopyFrameV1Flags)0); m_resource->sendFlags(sc<zwlrScreencopyFrameV1Flags>(0));
if (m_withDamage) { if (m_withDamage) {
// TODO: add a damage ring for this. // TODO: add a damage ring for this.
m_resource->sendDamage(0, 0, m_buffer->size.x, m_buffer->size.y); m_resource->sendDamage(0, 0, m_buffer->size.x, m_buffer->size.y);
@@ -377,12 +377,12 @@ bool CScreencopyFrame::copyShm() {
// This could be optimized by using a pixel buffer object to make this async, // This could be optimized by using a pixel buffer object to make this async,
// but really clients should just use a dma buffer anyways. // but really clients should just use a dma buffer anyways.
if (packStride == (uint32_t)shm.stride) { if (packStride == sc<uint32_t>(shm.stride)) {
glReadPixels(0, 0, m_box.w, m_box.h, glFormat, PFORMAT->glType, pixelData); glReadPixels(0, 0, m_box.w, m_box.h, glFormat, PFORMAT->glType, pixelData);
} else { } else {
for (size_t i = 0; i < m_box.h; ++i) { for (size_t i = 0; i < m_box.h; ++i) {
uint32_t y = i; uint32_t y = i;
glReadPixels(0, y, m_box.w, 1, glFormat, PFORMAT->glType, ((unsigned char*)pixelData) + i * shm.stride); glReadPixels(0, y, m_box.w, 1, glFormat, PFORMAT->glType, pixelData + i * shm.stride);
} }
} }
@@ -446,11 +446,11 @@ void CScreencopyClient::onTick() {
const bool FRAMEAWAITING = std::ranges::any_of(PROTO::screencopy->m_frames, [&](const auto& frame) { return frame->m_client.get() == this; }); const bool FRAMEAWAITING = std::ranges::any_of(PROTO::screencopy->m_frames, [&](const auto& frame) { return frame->m_client.get() == this; });
if (m_framesInLastHalfSecond > 3 && !m_sentScreencast) { if (m_framesInLastHalfSecond > 3 && !m_sentScreencast) {
EMIT_HOOK_EVENT("screencast", (std::vector<uint64_t>{1, (uint64_t)m_framesInLastHalfSecond, (uint64_t)m_clientOwner})); EMIT_HOOK_EVENT("screencast", (std::vector<uint64_t>{1, sc<uint64_t>(m_framesInLastHalfSecond), sc<uint64_t>(m_clientOwner)}));
g_pEventManager->postEvent(SHyprIPCEvent{"screencast", "1," + std::to_string(m_clientOwner)}); g_pEventManager->postEvent(SHyprIPCEvent{"screencast", "1," + std::to_string(m_clientOwner)});
m_sentScreencast = true; m_sentScreencast = true;
} else if (m_framesInLastHalfSecond < 4 && m_sentScreencast && LASTFRAMEDELTA > 1.0 && !FRAMEAWAITING) { } else if (m_framesInLastHalfSecond < 4 && m_sentScreencast && LASTFRAMEDELTA > 1.0 && !FRAMEAWAITING) {
EMIT_HOOK_EVENT("screencast", (std::vector<uint64_t>{0, (uint64_t)m_framesInLastHalfSecond, (uint64_t)m_clientOwner})); EMIT_HOOK_EVENT("screencast", (std::vector<uint64_t>{0, sc<uint64_t>(m_framesInLastHalfSecond), sc<uint64_t>(m_clientOwner)}));
g_pEventManager->postEvent(SHyprIPCEvent{"screencast", "0," + std::to_string(m_clientOwner)}); g_pEventManager->postEvent(SHyprIPCEvent{"screencast", "0," + std::to_string(m_clientOwner)});
m_sentScreencast = false; m_sentScreencast = false;
} }

View File

@@ -4,14 +4,14 @@
using namespace Hyprutils::OS; using namespace Hyprutils::OS;
static int onListenFdEvent(int fd, uint32_t mask, void* data) { static int onListenFdEvent(int fd, uint32_t mask, void* data) {
auto sc = (CSecurityContext*)data; auto secCtx = sc<CSecurityContext*>(data);
sc->onListen(mask); secCtx->onListen(mask);
return 0; return 0;
} }
static int onCloseFdEvent(int fd, uint32_t mask, void* data) { static int onCloseFdEvent(int fd, uint32_t mask, void* data) {
auto sc = (CSecurityContext*)data; auto secCtx = sc<CSecurityContext*>(data);
sc->onClose(mask); secCtx->onClose(mask);
return 0; return 0;
} }

View File

@@ -12,7 +12,7 @@ CSinglePixelBuffer::CSinglePixelBuffer(uint32_t id, wl_client* client, CHyprColo
m_opaque = col_.a >= 1.F; m_opaque = col_.a >= 1.F;
m_texture = makeShared<CTexture>(DRM_FORMAT_ARGB8888, (uint8_t*)&m_color, 4, Vector2D{1, 1}); m_texture = makeShared<CTexture>(DRM_FORMAT_ARGB8888, rc<uint8_t*>(&m_color), 4, Vector2D{1, 1});
m_resource = CWLBufferResource::create(makeShared<CWlBuffer>(client, 1, id)); m_resource = CWLBufferResource::create(makeShared<CWlBuffer>(client, 1, id));
@@ -50,7 +50,7 @@ Aquamarine::SDMABUFAttrs CSinglePixelBuffer::dmabuf() {
} }
std::tuple<uint8_t*, uint32_t, size_t> CSinglePixelBuffer::beginDataPtr(uint32_t flags) { std::tuple<uint8_t*, uint32_t, size_t> CSinglePixelBuffer::beginDataPtr(uint32_t flags) {
return {(uint8_t*)&m_color, DRM_FORMAT_ARGB8888, 4}; return {rc<uint8_t*>(&m_color), DRM_FORMAT_ARGB8888, 4};
} }
void CSinglePixelBuffer::endDataPtr() { void CSinglePixelBuffer::endDataPtr() {
@@ -87,8 +87,8 @@ CSinglePixelBufferManagerResource::CSinglePixelBufferManagerResource(UP<CWpSingl
m_resource->setOnDestroy([this](CWpSinglePixelBufferManagerV1* r) { PROTO::singlePixel->destroyResource(this); }); m_resource->setOnDestroy([this](CWpSinglePixelBufferManagerV1* r) { PROTO::singlePixel->destroyResource(this); });
m_resource->setCreateU32RgbaBuffer([this](CWpSinglePixelBufferManagerV1* res, uint32_t id, uint32_t r, uint32_t g, uint32_t b, uint32_t a) { m_resource->setCreateU32RgbaBuffer([this](CWpSinglePixelBufferManagerV1* res, uint32_t id, uint32_t r, uint32_t g, uint32_t b, uint32_t a) {
CHyprColor color{r / (float)std::numeric_limits<uint32_t>::max(), g / (float)std::numeric_limits<uint32_t>::max(), b / (float)std::numeric_limits<uint32_t>::max(), CHyprColor color{r / sc<float>(std::numeric_limits<uint32_t>::max()), g / sc<float>(std::numeric_limits<uint32_t>::max()),
a / (float)std::numeric_limits<uint32_t>::max()}; b / sc<float>(std::numeric_limits<uint32_t>::max()), a / sc<float>(std::numeric_limits<uint32_t>::max())};
const auto& RESOURCE = PROTO::singlePixel->m_buffers.emplace_back(makeUnique<CSinglePixelBufferResource>(id, m_resource->client(), color)); const auto& RESOURCE = PROTO::singlePixel->m_buffers.emplace_back(makeUnique<CSinglePixelBufferResource>(id, m_resource->client(), color));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {

View File

@@ -210,7 +210,7 @@ void CTabletToolV2Resource::queueFrame() {
if (m_frameSource) if (m_frameSource)
return; return;
m_frameSource = wl_event_loop_add_idle(g_pCompositor->m_wlEventLoop, [](void* data) { ((CTabletToolV2Resource*)data)->sendFrame(false); }, this); m_frameSource = wl_event_loop_add_idle(g_pCompositor->m_wlEventLoop, [](void* data) { sc<CTabletToolV2Resource*>(data)->sendFrame(false); }, this);
} }
void CTabletToolV2Resource::sendFrame(bool removeSource) { void CTabletToolV2Resource::sendFrame(bool removeSource) {
@@ -604,7 +604,7 @@ void CTabletV2Protocol::buttonTool(SP<CTabletTool> tool, uint32_t button, uint32
continue; continue;
auto serial = g_pSeatManager->nextSerial(g_pSeatManager->seatResourceForClient(t->m_resource->client())); auto serial = g_pSeatManager->nextSerial(g_pSeatManager->seatResourceForClient(t->m_resource->client()));
t->m_resource->sendButton(serial, button, (zwpTabletToolV2ButtonState)state); t->m_resource->sendButton(serial, button, sc<zwpTabletToolV2ButtonState>(state));
t->queueFrame(); t->queueFrame();
} }
} }

View File

@@ -37,8 +37,8 @@ CTextInputV1::CTextInputV1(SP<CZwpTextInputV1> resource_) : m_resource(resource_
[this](CZwpTextInputV1* pMgr, const char* text, uint32_t cursor, uint32_t anchor) { m_pendingSurrounding = {true, std::string(text), cursor, anchor}; }); [this](CZwpTextInputV1* pMgr, const char* text, uint32_t cursor, uint32_t anchor) { m_pendingSurrounding = {true, std::string(text), cursor, anchor}; });
m_resource->setSetContentType([this](CZwpTextInputV1* pMgr, uint32_t hint, uint32_t purpose) { m_resource->setSetContentType([this](CZwpTextInputV1* pMgr, uint32_t hint, uint32_t purpose) {
m_pendingContentType = {true, hint == (uint32_t)ZWP_TEXT_INPUT_V1_CONTENT_HINT_DEFAULT ? (uint32_t)ZWP_TEXT_INPUT_V1_CONTENT_HINT_NONE : hint, m_pendingContentType = {true, hint == sc<uint32_t>(ZWP_TEXT_INPUT_V1_CONTENT_HINT_DEFAULT) ? sc<uint32_t>(ZWP_TEXT_INPUT_V1_CONTENT_HINT_NONE) : hint,
purpose > (uint32_t)ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_PASSWORD ? hint + 1 : hint}; purpose > sc<uint32_t>(ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_PASSWORD) ? hint + 1 : hint};
}); });
m_resource->setSetCursorRectangle([this](CZwpTextInputV1* pMgr, int32_t x, int32_t y, int32_t width, int32_t height) { m_cursorRectangle = CBox{x, y, width, height}; }); m_resource->setSetCursorRectangle([this](CZwpTextInputV1* pMgr, int32_t x, int32_t y, int32_t width, int32_t height) { m_cursorRectangle = CBox{x, y, width, height}; });

View File

@@ -60,11 +60,11 @@ void CToplevelExportClient::onTick() {
const bool FRAMEAWAITING = std::ranges::any_of(PROTO::toplevelExport->m_frames, [&](const auto& frame) { return frame->m_client.get() == this; }); const bool FRAMEAWAITING = std::ranges::any_of(PROTO::toplevelExport->m_frames, [&](const auto& frame) { return frame->m_client.get() == this; });
if (m_framesInLastHalfSecond > 3 && !m_sentScreencast) { if (m_framesInLastHalfSecond > 3 && !m_sentScreencast) {
EMIT_HOOK_EVENT("screencast", (std::vector<uint64_t>{1, (uint64_t)m_framesInLastHalfSecond, (uint64_t)m_clientOwner})); EMIT_HOOK_EVENT("screencast", (std::vector<uint64_t>{1, sc<uint64_t>(m_framesInLastHalfSecond), sc<uint64_t>(m_clientOwner)}));
g_pEventManager->postEvent(SHyprIPCEvent{"screencast", "1," + std::to_string(m_clientOwner)}); g_pEventManager->postEvent(SHyprIPCEvent{"screencast", "1," + std::to_string(m_clientOwner)});
m_sentScreencast = true; m_sentScreencast = true;
} else if (m_framesInLastHalfSecond < 4 && m_sentScreencast && LASTFRAMEDELTA > 1.0 && !FRAMEAWAITING) { } else if (m_framesInLastHalfSecond < 4 && m_sentScreencast && LASTFRAMEDELTA > 1.0 && !FRAMEAWAITING) {
EMIT_HOOK_EVENT("screencast", (std::vector<uint64_t>{0, (uint64_t)m_framesInLastHalfSecond, (uint64_t)m_clientOwner})); EMIT_HOOK_EVENT("screencast", (std::vector<uint64_t>{0, sc<uint64_t>(m_framesInLastHalfSecond), sc<uint64_t>(m_clientOwner)}));
g_pEventManager->postEvent(SHyprIPCEvent{"screencast", "0," + std::to_string(m_clientOwner)}); g_pEventManager->postEvent(SHyprIPCEvent{"screencast", "0," + std::to_string(m_clientOwner)});
m_sentScreencast = false; m_sentScreencast = false;
} }
@@ -116,7 +116,7 @@ CToplevelExportFrame::CToplevelExportFrame(SP<CHyprlandToplevelExportFrameV1> re
m_dmabufFormat = PMONITOR->m_output->state->state().drmFormat; m_dmabufFormat = PMONITOR->m_output->state->state().drmFormat;
m_box = {0, 0, (int)(m_window->m_realSize->value().x * PMONITOR->m_scale), (int)(m_window->m_realSize->value().y * PMONITOR->m_scale)}; m_box = {0, 0, sc<int>(m_window->m_realSize->value().x * PMONITOR->m_scale), sc<int>(m_window->m_realSize->value().y * PMONITOR->m_scale)};
m_box.transform(wlTransformToHyprutils(PMONITOR->m_transform), PMONITOR->m_transformedSize.x, PMONITOR->m_transformedSize.y).round(); m_box.transform(wlTransformToHyprutils(PMONITOR->m_transform), PMONITOR->m_transformedSize.x, PMONITOR->m_transformedSize.y).round();
@@ -180,7 +180,7 @@ void CToplevelExportFrame::copy(CHyprlandToplevelExportFrameV1* pFrame, wl_resou
m_resource->error(HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer format"); m_resource->error(HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer format");
PROTO::toplevelExport->destroyResource(this); PROTO::toplevelExport->destroyResource(this);
return; return;
} else if ((int)attrs.stride != m_shmStride) { } else if (attrs.stride != m_shmStride) {
m_resource->error(HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer stride"); m_resource->error(HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer stride");
PROTO::toplevelExport->destroyResource(this); PROTO::toplevelExport->destroyResource(this);
return; return;
@@ -217,7 +217,7 @@ void CToplevelExportFrame::share() {
} }
} }
m_resource->sendFlags((hyprlandToplevelExportFrameV1Flags)0); m_resource->sendFlags(sc<hyprlandToplevelExportFrameV1Flags>(0));
if (!m_ignoreDamage) if (!m_ignoreDamage)
m_resource->sendDamage(0, 0, m_box.width, m_box.height); m_resource->sendDamage(0, 0, m_box.width, m_box.height);

View File

@@ -29,7 +29,7 @@ CToplevelMappingManager::CToplevelMappingManager(SP<CHyprlandToplevelMappingMana
if (!WINDOW) if (!WINDOW)
NEWHANDLE->m_resource->sendFailed(); NEWHANDLE->m_resource->sendFailed();
else else
NEWHANDLE->m_resource->sendWindowAddress((uint64_t)WINDOW.get() >> 32 & 0xFFFFFFFF, (uint64_t)WINDOW.get() & 0xFFFFFFFF); NEWHANDLE->m_resource->sendWindowAddress(rc<uint64_t>(WINDOW.get()) >> 32 & 0xFFFFFFFF, rc<uint64_t>(WINDOW.get()) & 0xFFFFFFFF);
}); });
m_resource->setGetWindowForToplevelWlr([this](CHyprlandToplevelMappingManagerV1* mgr, uint32_t handle, wl_resource* toplevel) { m_resource->setGetWindowForToplevelWlr([this](CHyprlandToplevelMappingManagerV1* mgr, uint32_t handle, wl_resource* toplevel) {
const auto NEWHANDLE = PROTO::toplevelMapping->m_handles.emplace_back( const auto NEWHANDLE = PROTO::toplevelMapping->m_handles.emplace_back(
@@ -48,7 +48,7 @@ CToplevelMappingManager::CToplevelMappingManager(SP<CHyprlandToplevelMappingMana
if (!WINDOW) if (!WINDOW)
NEWHANDLE->m_resource->sendFailed(); NEWHANDLE->m_resource->sendFailed();
else else
NEWHANDLE->m_resource->sendWindowAddress((uint64_t)WINDOW.get() >> 32 & 0xFFFFFFFF, (uint64_t)WINDOW.get() & 0xFFFFFFFF); NEWHANDLE->m_resource->sendWindowAddress(rc<uint64_t>(WINDOW.get()) >> 32 & 0xFFFFFFFF, rc<uint64_t>(WINDOW.get()) & 0xFFFFFFFF);
}); });
} }

View File

@@ -47,7 +47,7 @@ CVirtualKeyboardV1Resource::CVirtualKeyboardV1Resource(SP<CZwpVirtualKeyboardV1>
m_events.key.emit(IKeyboard::SKeyEvent{ m_events.key.emit(IKeyboard::SKeyEvent{
.timeMs = timeMs, .timeMs = timeMs,
.keycode = key, .keycode = key,
.state = (wl_keyboard_key_state)state, .state = sc<wl_keyboard_key_state>(state),
}); });
const bool CONTAINS = std::ranges::contains(m_pressed, key); const bool CONTAINS = std::ranges::contains(m_pressed, key);
@@ -88,7 +88,7 @@ CVirtualKeyboardV1Resource::CVirtualKeyboardV1Resource(SP<CZwpVirtualKeyboardV1>
return; return;
} }
auto xkbKeymap = xkb_keymap_new_from_string(xkbContext, (const char*)keymapData, XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS); auto xkbKeymap = xkb_keymap_new_from_string(xkbContext, sc<const char*>(keymapData), XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
munmap(keymapData, len); munmap(keymapData, len);
if UNLIKELY (!xkbKeymap) { if UNLIKELY (!xkbKeymap) {

View File

@@ -29,7 +29,7 @@ CVirtualPointerV1Resource::CVirtualPointerV1Resource(SP<CZwlrVirtualPointerV1> r
m_events.warp.emit(IPointer::SMotionAbsoluteEvent{ m_events.warp.emit(IPointer::SMotionAbsoluteEvent{
.timeMs = timeMs, .timeMs = timeMs,
.absolute = {(double)x / xExtent, (double)y / yExtent}, .absolute = {sc<double>(x) / xExtent, sc<double>(y) / yExtent},
}); });
}); });
@@ -37,7 +37,7 @@ CVirtualPointerV1Resource::CVirtualPointerV1Resource(SP<CZwlrVirtualPointerV1> r
m_events.button.emit(IPointer::SButtonEvent{ m_events.button.emit(IPointer::SButtonEvent{
.timeMs = timeMs, .timeMs = timeMs,
.button = button, .button = button,
.state = (wl_pointer_button_state)state, .state = sc<wl_pointer_button_state>(state),
}); });
}); });
@@ -48,7 +48,7 @@ CVirtualPointerV1Resource::CVirtualPointerV1Resource(SP<CZwlrVirtualPointerV1> r
} }
m_axis = axis_; m_axis = axis_;
m_axisEvents[m_axis] = IPointer::SAxisEvent{.timeMs = timeMs, .axis = (wl_pointer_axis)m_axis, .delta = wl_fixed_to_double(value)}; m_axisEvents[m_axis] = IPointer::SAxisEvent{.timeMs = timeMs, .axis = sc<wl_pointer_axis>(m_axis), .delta = wl_fixed_to_double(value)};
}); });
m_resource->setFrame([this](CZwlrVirtualPointerV1* r) { m_resource->setFrame([this](CZwlrVirtualPointerV1* r) {
@@ -62,7 +62,7 @@ CVirtualPointerV1Resource::CVirtualPointerV1Resource(SP<CZwlrVirtualPointerV1> r
m_events.frame.emit(); m_events.frame.emit();
}); });
m_resource->setAxisSource([this](CZwlrVirtualPointerV1* r, uint32_t source) { m_axisEvents[m_axis].source = (wl_pointer_axis_source)source; }); m_resource->setAxisSource([this](CZwlrVirtualPointerV1* r, uint32_t source) { m_axisEvents[m_axis].source = sc<wl_pointer_axis_source>(source); });
m_resource->setAxisStop([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, uint32_t axis_) { m_resource->setAxisStop([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, uint32_t axis_) {
if UNLIKELY (m_axis > WL_POINTER_AXIS_HORIZONTAL_SCROLL) { if UNLIKELY (m_axis > WL_POINTER_AXIS_HORIZONTAL_SCROLL) {
@@ -72,7 +72,7 @@ CVirtualPointerV1Resource::CVirtualPointerV1Resource(SP<CZwlrVirtualPointerV1> r
m_axis = axis_; m_axis = axis_;
m_axisEvents[m_axis].timeMs = timeMs; m_axisEvents[m_axis].timeMs = timeMs;
m_axisEvents[m_axis].axis = (wl_pointer_axis)m_axis; m_axisEvents[m_axis].axis = sc<wl_pointer_axis>(m_axis);
m_axisEvents[m_axis].delta = 0; m_axisEvents[m_axis].delta = 0;
m_axisEvents[m_axis].deltaDiscrete = 0; m_axisEvents[m_axis].deltaDiscrete = 0;
}); });
@@ -85,7 +85,7 @@ CVirtualPointerV1Resource::CVirtualPointerV1Resource(SP<CZwlrVirtualPointerV1> r
m_axis = axis_; m_axis = axis_;
m_axisEvents[m_axis].timeMs = timeMs; m_axisEvents[m_axis].timeMs = timeMs;
m_axisEvents[m_axis].axis = (wl_pointer_axis)m_axis; m_axisEvents[m_axis].axis = sc<wl_pointer_axis>(m_axis);
m_axisEvents[m_axis].delta = wl_fixed_to_double(value); m_axisEvents[m_axis].delta = wl_fixed_to_double(value);
m_axisEvents[m_axis].deltaDiscrete = discrete * 120; m_axisEvents[m_axis].deltaDiscrete = discrete * 120;
}); });

View File

@@ -2,7 +2,7 @@
#include "../Compositor.hpp" #include "../Compositor.hpp"
static void bindManagerInternal(wl_client* client, void* data, uint32_t ver, uint32_t id) { static void bindManagerInternal(wl_client* client, void* data, uint32_t ver, uint32_t id) {
((IWaylandProtocol*)data)->bindManager(client, data, ver, id); sc<IWaylandProtocol*>(data)->bindManager(client, data, ver, id);
} }
static void displayDestroyInternal(struct wl_listener* listener, void* data) { static void displayDestroyInternal(struct wl_listener* listener, void* data) {

View File

@@ -37,7 +37,7 @@ CXDGSystemBellManagerResource::CXDGSystemBellManagerResource(UP<CXdgSystemBellV1
if (w->m_wlSurface->resource() == SURFACE) { if (w->m_wlSurface->resource() == SURFACE) {
g_pEventManager->postEvent(SHyprIPCEvent{ g_pEventManager->postEvent(SHyprIPCEvent{
.event = "bell", .event = "bell",
.data = std::format("{:x}", (uintptr_t)w.get()), .data = std::format("{:x}", rc<uintptr_t>(w.get())),
}); });
return; return;
} }

View File

@@ -99,7 +99,7 @@ Vector2D CXDGPopupResource::accumulateParentOffset() {
} }
SP<CXDGPopupResource> CXDGPopupResource::fromResource(wl_resource* res) { SP<CXDGPopupResource> CXDGPopupResource::fromResource(wl_resource* res) {
auto data = (CXDGPopupResource*)(((CXdgPopup*)wl_resource_get_user_data(res))->data()); auto data = sc<CXDGPopupResource*>(sc<CXdgPopup*>(wl_resource_get_user_data(res))->data());
return data ? data->m_self.lock() : nullptr; return data ? data->m_self.lock() : nullptr;
} }
@@ -146,9 +146,9 @@ CXDGToplevelResource::CXDGToplevelResource(SP<CXdgToplevel> resource_, SP<CXDGSu
if (m_resource->version() >= 5) { if (m_resource->version() >= 5) {
wl_array arr; wl_array arr;
wl_array_init(&arr); wl_array_init(&arr);
auto p = (uint32_t*)wl_array_add(&arr, sizeof(uint32_t)); auto p = sc<uint32_t*>(wl_array_add(&arr, sizeof(uint32_t)));
*p = XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN; *p = XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN;
p = (uint32_t*)wl_array_add(&arr, sizeof(uint32_t)); p = sc<uint32_t*>(wl_array_add(&arr, sizeof(uint32_t)));
*p = XDG_TOPLEVEL_WM_CAPABILITIES_MAXIMIZE; *p = XDG_TOPLEVEL_WM_CAPABILITIES_MAXIMIZE;
m_resource->sendWmCapabilities(&arr); m_resource->sendWmCapabilities(&arr);
wl_array_release(&arr); wl_array_release(&arr);
@@ -239,7 +239,7 @@ CXDGToplevelResource::~CXDGToplevelResource() {
} }
SP<CXDGToplevelResource> CXDGToplevelResource::fromResource(wl_resource* res) { SP<CXDGToplevelResource> CXDGToplevelResource::fromResource(wl_resource* res) {
auto data = (CXDGToplevelResource*)(((CXdgToplevel*)wl_resource_get_user_data(res))->data()); auto data = sc<CXDGToplevelResource*>(sc<CXdgToplevel*>(wl_resource_get_user_data(res))->data());
return data ? data->m_self.lock() : nullptr; return data ? data->m_self.lock() : nullptr;
} }
@@ -491,12 +491,12 @@ bool CXDGSurfaceResource::good() {
} }
SP<CXDGSurfaceResource> CXDGSurfaceResource::fromResource(wl_resource* res) { SP<CXDGSurfaceResource> CXDGSurfaceResource::fromResource(wl_resource* res) {
auto data = (CXDGSurfaceResource*)(((CXdgSurface*)wl_resource_get_user_data(res))->data()); auto data = sc<CXDGSurfaceResource*>(sc<CXdgSurface*>(wl_resource_get_user_data(res))->data());
return data ? data->m_self.lock() : nullptr; return data ? data->m_self.lock() : nullptr;
} }
static void onConfigure(void* data) { static void onConfigure(void* data) {
((CXDGSurfaceResource*)data)->configure(); sc<CXDGSurfaceResource*>(data)->configure();
} }
uint32_t CXDGSurfaceResource::scheduleConfigure() { uint32_t CXDGSurfaceResource::scheduleConfigure() {
@@ -547,14 +547,14 @@ CXDGPositionerResource::CXDGPositionerResource(SP<CXdgPositioner> resource_, SP<
m_resource->setSetGravity([this](CXdgPositioner* r, xdgPositionerGravity g) { m_state.setGravity(g); }); m_resource->setSetGravity([this](CXdgPositioner* r, xdgPositionerGravity g) { m_state.setGravity(g); });
m_resource->setSetConstraintAdjustment([this](CXdgPositioner* r, xdgPositionerConstraintAdjustment a) { m_state.constraintAdjustment = (uint32_t)a; }); m_resource->setSetConstraintAdjustment([this](CXdgPositioner* r, xdgPositionerConstraintAdjustment a) { m_state.constraintAdjustment = sc<uint32_t>(a); });
// TODO: support this shit better. The current impl _works_, but is lacking and could be wrong in a few cases. // TODO: support this shit better. The current impl _works_, but is lacking and could be wrong in a few cases.
// doesn't matter _that_ much for now, though. // doesn't matter _that_ much for now, though.
} }
SP<CXDGPositionerResource> CXDGPositionerResource::fromResource(wl_resource* res) { SP<CXDGPositionerResource> CXDGPositionerResource::fromResource(wl_resource* res) {
auto data = (CXDGPositionerResource*)(((CXdgPositioner*)wl_resource_get_user_data(res))->data()); auto data = sc<CXDGPositionerResource*>(sc<CXdgPositioner*>(wl_resource_get_user_data(res))->data());
return data ? data->m_self.lock() : nullptr; return data ? data->m_self.lock() : nullptr;
} }

View File

@@ -18,7 +18,7 @@ CXWaylandSurfaceResource::CXWaylandSurfaceResource(SP<CXwaylandSurfaceV1> resour
m_client = m_resource->client(); m_client = m_resource->client();
m_resource->setSetSerial([this](CXwaylandSurfaceV1* r, uint32_t lo, uint32_t hi) { m_resource->setSetSerial([this](CXwaylandSurfaceV1* r, uint32_t lo, uint32_t hi) {
m_serial = (((uint64_t)hi) << 32) + lo; m_serial = (sc<uint64_t>(hi) << 32) + lo;
PROTO::xwaylandShell->m_events.newSurface.emit(m_self.lock()); PROTO::xwaylandShell->m_events.newSurface.emit(m_self.lock());
}); });
} }

View File

@@ -28,7 +28,7 @@ static wpColorManagerV1TransferFunction getWPTransferFunction(xxColorManagerV4Tr
} }
static wpColorManagerV1Primaries getWPPrimaries(xxColorManagerV4Primaries primaries) { static wpColorManagerV1Primaries getWPPrimaries(xxColorManagerV4Primaries primaries) {
return (wpColorManagerV1Primaries)(primaries + 1); return sc<wpColorManagerV1Primaries>(primaries + 1);
} }
CXXColorManager::CXXColorManager(SP<CXxColorManagerV4> resource_) : m_resource(resource_) { CXXColorManager::CXXColorManager(SP<CXxColorManagerV4> resource_) : m_resource(resource_) {
@@ -235,7 +235,7 @@ CXXColorManagementSurface::CXXColorManagementSurface(SP<CXxColorManagementSurfac
m_resource->setSetImageDescription([this](CXxColorManagementSurfaceV4* r, wl_resource* image_description, uint32_t render_intent) { m_resource->setSetImageDescription([this](CXxColorManagementSurfaceV4* r, wl_resource* image_description, uint32_t render_intent) {
LOGM(TRACE, "Set image description for surface={}, desc={}, intent={}", (uintptr_t)r, (uintptr_t)image_description, render_intent); LOGM(TRACE, "Set image description for surface={}, desc={}, intent={}", (uintptr_t)r, (uintptr_t)image_description, render_intent);
const auto PO = (CXxImageDescriptionV4*)wl_resource_get_user_data(image_description); const auto PO = sc<CXxImageDescriptionV4*>(wl_resource_get_user_data(image_description));
if (!PO) { // FIXME check validity if (!PO) { // FIXME check validity
r->error(XX_COLOR_MANAGEMENT_SURFACE_V4_ERROR_IMAGE_DESCRIPTION, "Image description creation failed"); r->error(XX_COLOR_MANAGEMENT_SURFACE_V4_ERROR_IMAGE_DESCRIPTION, "Image description creation failed");
return; return;
@@ -425,7 +425,7 @@ CXXColorManagementParametricCreator::CXXColorManagementParametricCreator(SP<CXxI
default: r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_TF, "Unsupported transfer function"); return; default: r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_TF, "Unsupported transfer function"); return;
} }
m_settings.transferFunction = convertTransferFunction(getWPTransferFunction((xxColorManagerV4TransferFunction)tf)); m_settings.transferFunction = convertTransferFunction(getWPTransferFunction(sc<xxColorManagerV4TransferFunction>(tf)));
m_valuesSet |= PC_TF; m_valuesSet |= PC_TF;
}); });
m_resource->setSetTfPower([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t eexp) { m_resource->setSetTfPower([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t eexp) {
@@ -455,7 +455,7 @@ CXXColorManagementParametricCreator::CXXColorManagementParametricCreator(SP<CXxI
case XX_COLOR_MANAGER_V4_PRIMARIES_DISPLAY_P3: case XX_COLOR_MANAGER_V4_PRIMARIES_DISPLAY_P3:
case XX_COLOR_MANAGER_V4_PRIMARIES_ADOBE_RGB: case XX_COLOR_MANAGER_V4_PRIMARIES_ADOBE_RGB:
m_settings.primariesNameSet = true; m_settings.primariesNameSet = true;
m_settings.primariesNamed = convertPrimaries(getWPPrimaries((xxColorManagerV4Primaries)primaries)); m_settings.primariesNamed = convertPrimaries(getWPPrimaries(sc<xxColorManagerV4Primaries>(primaries)));
m_settings.primaries = getPrimaries(m_settings.primariesNamed); m_settings.primaries = getPrimaries(m_settings.primariesNamed);
m_valuesSet |= PC_PRIMARIES; m_valuesSet |= PC_PRIMARIES;
break; break;
@@ -585,7 +585,7 @@ CXXColorManagementImageDescriptionInfo::CXXColorManagementImageDescriptionInfo(S
m_client = m_resource->client(); m_client = m_resource->client();
const auto toProto = [](float value) { return int32_t(std::round(value * 10000)); }; const auto toProto = [](float value) { return sc<int32_t>(std::round(value * 10000)); };
if (m_settings.icc.fd >= 0) if (m_settings.icc.fd >= 0)
m_resource->sendIccFile(m_settings.icc.fd, m_settings.icc.length); m_resource->sendIccFile(m_settings.icc.fd, m_settings.icc.length);

View File

@@ -57,7 +57,7 @@ bool CWLRegionResource::good() {
} }
SP<CWLRegionResource> CWLRegionResource::fromResource(wl_resource* res) { SP<CWLRegionResource> CWLRegionResource::fromResource(wl_resource* res) {
auto data = (CWLRegionResource*)(((CWlRegion*)wl_resource_get_user_data(res))->data()); auto data = sc<CWLRegionResource*>(sc<CWlRegion*>(wl_resource_get_user_data(res))->data());
return data ? data->m_self.lock() : nullptr; return data ? data->m_self.lock() : nullptr;
} }
@@ -167,7 +167,7 @@ CWLSurfaceResource::CWLSurfaceResource(SP<CWlSurface> resource_) : m_resource(re
whenReadable(); whenReadable();
} else if (state->buffer->type() == Aquamarine::BUFFER_TYPE_DMABUF && state->buffer->dmabuf().success) { } else if (state->buffer->type() == Aquamarine::BUFFER_TYPE_DMABUF && state->buffer->dmabuf().success) {
// async buffer and is dmabuf, then we can wait on implicit fences // async buffer and is dmabuf, then we can wait on implicit fences
auto syncFd = dynamic_cast<CDMABuffer*>(state->buffer.m_buffer.get())->exportSyncFile(); auto syncFd = dc<CDMABuffer*>(state->buffer.m_buffer.get())->exportSyncFile();
if (syncFd.isValid()) if (syncFd.isValid())
g_pEventLoopManager->doOnReadable(std::move(syncFd), whenReadable); g_pEventLoopManager->doOnReadable(std::move(syncFd), whenReadable);
@@ -211,7 +211,7 @@ CWLSurfaceResource::CWLSurfaceResource(SP<CWlSurface> resource_) : m_resource(re
m_pending.updated.bits.transform = true; m_pending.updated.bits.transform = true;
m_pending.updated.bits.damage = true; m_pending.updated.bits.damage = true;
m_pending.transform = (wl_output_transform)tr; m_pending.transform = sc<wl_output_transform>(tr);
m_pending.bufferDamage = CBox{{}, m_pending.bufferSize}; m_pending.bufferDamage = CBox{{}, m_pending.bufferSize};
}); });
@@ -270,7 +270,7 @@ void CWLSurfaceResource::dropCurrentBuffer() {
} }
SP<CWLSurfaceResource> CWLSurfaceResource::fromResource(wl_resource* res) { SP<CWLSurfaceResource> CWLSurfaceResource::fromResource(wl_resource* res) {
auto data = (CWLSurfaceResource*)(((CWlSurface*)wl_resource_get_user_data(res))->data()); auto data = sc<CWLSurfaceResource*>(sc<CWlSurface*>(wl_resource_get_user_data(res))->data());
return data ? data->m_self.lock() : nullptr; return data ? data->m_self.lock() : nullptr;
} }
@@ -379,7 +379,7 @@ void CWLSurfaceResource::bfHelper(std::vector<SP<CWLSurfaceResource>> const& nod
for (auto const& n : nodes) { for (auto const& n : nodes) {
Vector2D offset = {}; Vector2D offset = {};
if (n->m_role->role() == SURFACE_ROLE_SUBSURFACE) { if (n->m_role->role() == SURFACE_ROLE_SUBSURFACE) {
auto subsurface = ((CSubsurfaceRole*)n->m_role.get())->m_subsurface.lock(); auto subsurface = sc<CSubsurfaceRole*>(n->m_role.get())->m_subsurface.lock();
offset = subsurface->posRelativeToParent(); offset = subsurface->posRelativeToParent();
} }
@@ -491,7 +491,7 @@ CBox CWLSurfaceResource::extends() {
if (surf->m_role->role() != SURFACE_ROLE_SUBSURFACE) if (surf->m_role->role() != SURFACE_ROLE_SUBSURFACE)
return; return;
((CRegion*)d)->add(CBox{offset, surf->m_current.size}); sc<CRegion*>(d)->add(CBox{offset, surf->m_current.size});
}, },
&full); &full);
return full.getExtents(); return full.getExtents();
@@ -515,7 +515,7 @@ void CWLSurfaceResource::commitState(SSurfaceState& state) {
m_current.texture->m_transform = wlTransformToHyprutils(m_current.transform); m_current.texture->m_transform = wlTransformToHyprutils(m_current.transform);
if (m_role->role() == SURFACE_ROLE_SUBSURFACE) { if (m_role->role() == SURFACE_ROLE_SUBSURFACE) {
auto subsurface = ((CSubsurfaceRole*)m_role.get())->m_subsurface.lock(); auto subsurface = sc<CSubsurfaceRole*>(m_role.get())->m_subsurface.lock();
if (subsurface->m_sync) if (subsurface->m_sync)
return; return;
@@ -525,7 +525,7 @@ void CWLSurfaceResource::commitState(SSurfaceState& state) {
breadthfirst( breadthfirst(
[](SP<CWLSurfaceResource> surf, const Vector2D& offset, void* data) { [](SP<CWLSurfaceResource> surf, const Vector2D& offset, void* data) {
if (surf->m_role->role() == SURFACE_ROLE_SUBSURFACE) { if (surf->m_role->role() == SURFACE_ROLE_SUBSURFACE) {
auto subsurface = ((CSubsurfaceRole*)surf->m_role.get())->m_subsurface.lock(); auto subsurface = sc<CSubsurfaceRole*>(surf->m_role.get())->m_subsurface.lock();
if (!subsurface->m_sync) if (!subsurface->m_sync)
return; return;
} }
@@ -543,7 +543,7 @@ void CWLSurfaceResource::commitState(SSurfaceState& state) {
SImageDescription CWLSurfaceResource::getPreferredImageDescription() { SImageDescription CWLSurfaceResource::getPreferredImageDescription() {
auto parent = m_self; auto parent = m_self;
if (parent->m_role->role() == SURFACE_ROLE_SUBSURFACE) { if (parent->m_role->role() == SURFACE_ROLE_SUBSURFACE) {
auto subsurface = ((CSubsurfaceRole*)parent->m_role.get())->m_subsurface.lock(); auto subsurface = sc<CSubsurfaceRole*>(parent->m_role.get())->m_subsurface.lock();
parent = subsurface->t1Parent(); parent = subsurface->t1Parent();
} }
WP<CMonitor> monitor; WP<CMonitor> monitor;
@@ -611,7 +611,7 @@ void CWLSurfaceResource::updateCursorShm(CRegion damage) {
// bpp is 32 INSALLAH // bpp is 32 INSALLAH
auto begin = 4 * box.y1 * (box.x2 - box.x1) + box.x1; auto begin = 4 * box.y1 * (box.x2 - box.x1) + box.x1;
auto len = 4 * (box.x2 - box.x1); auto len = 4 * (box.x2 - box.x1);
memcpy((uint8_t*)shmData.data() + begin, (uint8_t*)pixelData + begin, len); memcpy(shmData.data() + begin, pixelData + begin, len);
} }
}); });
} }

View File

@@ -157,7 +157,7 @@ CWLDataSourceResource::~CWLDataSourceResource() {
} }
SP<CWLDataSourceResource> CWLDataSourceResource::fromResource(wl_resource* res) { SP<CWLDataSourceResource> CWLDataSourceResource::fromResource(wl_resource* res) {
auto data = (CWLDataSourceResource*)(((CWlDataSource*)wl_resource_get_user_data(res))->data()); auto data = sc<CWLDataSourceResource*>(sc<CWlDataSource*>(wl_resource_get_user_data(res))->data());
return data ? data->m_self.lock() : nullptr; return data ? data->m_self.lock() : nullptr;
} }

View File

@@ -51,7 +51,7 @@ CWLOutputResource::CWLOutputResource(SP<CWlOutput> resource_, PHLMONITOR pMonito
} }
SP<CWLOutputResource> CWLOutputResource::fromResource(wl_resource* res) { SP<CWLOutputResource> CWLOutputResource::fromResource(wl_resource* res) {
auto data = (CWLOutputResource*)(((CWlOutput*)wl_resource_get_user_data(res))->data()); auto data = sc<CWLOutputResource*>(sc<CWlOutput*>(wl_resource_get_user_data(res))->data());
return data ? data->m_self.lock() : nullptr; return data ? data->m_self.lock() : nullptr;
} }
@@ -74,10 +74,10 @@ void CWLOutputResource::updateState() {
if (m_resource->version() >= 2) if (m_resource->version() >= 2)
m_resource->sendScale(std::ceil(m_monitor->m_scale)); m_resource->sendScale(std::ceil(m_monitor->m_scale));
m_resource->sendMode((wl_output_mode)(WL_OUTPUT_MODE_CURRENT), m_monitor->m_pixelSize.x, m_monitor->m_pixelSize.y, m_monitor->m_refreshRate * 1000.0); m_resource->sendMode(WL_OUTPUT_MODE_CURRENT, m_monitor->m_pixelSize.x, m_monitor->m_pixelSize.y, m_monitor->m_refreshRate * 1000.0);
m_resource->sendGeometry(0, 0, m_monitor->m_output->physicalSize.x, m_monitor->m_output->physicalSize.y, (wl_output_subpixel)m_monitor->m_output->subpixel, m_resource->sendGeometry(0, 0, m_monitor->m_output->physicalSize.x, m_monitor->m_output->physicalSize.y, m_monitor->m_output->subpixel, m_monitor->m_output->make.c_str(),
m_monitor->m_output->make.c_str(), m_monitor->m_output->model.c_str(), m_monitor->m_transform); m_monitor->m_output->model.c_str(), m_monitor->m_transform);
if (m_resource->version() >= 2) if (m_resource->version() >= 2)
m_resource->sendDone(); m_resource->sendDone();

View File

@@ -473,7 +473,7 @@ void CWLSeatResource::sendCapabilities(uint32_t caps) {
if (caps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH) if (caps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)
wlCaps |= WL_SEAT_CAPABILITY_TOUCH; wlCaps |= WL_SEAT_CAPABILITY_TOUCH;
m_resource->sendCapabilities((wl_seat_capability)wlCaps); m_resource->sendCapabilities(sc<wl_seat_capability>(wlCaps));
} }
bool CWLSeatResource::good() { bool CWLSeatResource::good() {
@@ -561,6 +561,6 @@ SP<CWLSeatResource> CWLSeatProtocol::seatResourceForClient(wl_client* client) {
std::vector<uint8_t>& CCursorSurfaceRole::cursorPixelData(SP<CWLSurfaceResource> surface) { std::vector<uint8_t>& CCursorSurfaceRole::cursorPixelData(SP<CWLSurfaceResource> surface) {
RASSERT(surface->m_role->role() == SURFACE_ROLE_CURSOR, "cursorPixelData called on a non-cursor surface"); RASSERT(surface->m_role->role() == SURFACE_ROLE_CURSOR, "cursorPixelData called on a non-cursor surface");
auto role = (CCursorSurfaceRole*)surface->m_role.get(); auto role = sc<CCursorSurfaceRole*>(surface->m_role.get());
return role->m_cursorShmPixelData; return role->m_cursorShmPixelData;
} }

View File

@@ -59,7 +59,7 @@ Aquamarine::SSHMAttrs CWLSHMBuffer::shm() {
} }
std::tuple<uint8_t*, uint32_t, size_t> CWLSHMBuffer::beginDataPtr(uint32_t flags) { std::tuple<uint8_t*, uint32_t, size_t> CWLSHMBuffer::beginDataPtr(uint32_t flags) {
return {(uint8_t*)m_pool->m_data + m_offset, m_fmt, m_stride * size.y}; return {sc<uint8_t*>(m_pool->m_data) + m_offset, m_fmt, m_stride * size.y};
} }
void CWLSHMBuffer::endDataPtr() { void CWLSHMBuffer::endDataPtr() {
@@ -101,7 +101,7 @@ static int shmIsSizeValid(CFileDescriptor& fd, size_t size) {
return 0; return 0;
} }
return (size_t)st.st_size >= size; return sc<size_t>(st.st_size) >= size;
} }
CWLSHMPoolResource::CWLSHMPoolResource(SP<CWlShmPool> resource_, CFileDescriptor fd_, size_t size_) : m_resource(resource_) { CWLSHMPoolResource::CWLSHMPoolResource(SP<CWlShmPool> resource_, CFileDescriptor fd_, size_t size_) : m_resource(resource_) {
@@ -119,7 +119,7 @@ CWLSHMPoolResource::CWLSHMPoolResource(SP<CWlShmPool> resource_, CFileDescriptor
m_resource->setOnDestroy([this](CWlShmPool* r) { PROTO::shm->destroyResource(this); }); m_resource->setOnDestroy([this](CWlShmPool* r) { PROTO::shm->destroyResource(this); });
m_resource->setResize([this](CWlShmPool* r, int32_t size_) { m_resource->setResize([this](CWlShmPool* r, int32_t size_) {
if UNLIKELY (size_ < (int32_t)m_pool->m_size) { if UNLIKELY (size_ < sc<int32_t>(m_pool->m_size)) {
r->error(-1, "Shrinking a shm pool is illegal"); r->error(-1, "Shrinking a shm pool is illegal");
return; return;
} }
@@ -188,7 +188,7 @@ CWLSHMResource::CWLSHMResource(SP<CWlShm> resource_) : m_resource(resource_) {
// send a few supported formats. No need for any other I think? // send a few supported formats. No need for any other I think?
for (auto const& s : PROTO::shm->m_shmFormats) { for (auto const& s : PROTO::shm->m_shmFormats) {
m_resource->sendFormat((wl_shm_format)s); m_resource->sendFormat(sc<wl_shm_format>(s));
} }
} }

View File

@@ -116,7 +116,7 @@ Vector2D CWLSubsurfaceResource::posRelativeToParent() {
while (surf->m_role->role() == SURFACE_ROLE_SUBSURFACE && std::ranges::find_if(surfacesVisited, [surf](const auto& other) { return surf == other; }) == surfacesVisited.end()) { while (surf->m_role->role() == SURFACE_ROLE_SUBSURFACE && std::ranges::find_if(surfacesVisited, [surf](const auto& other) { return surf == other; }) == surfacesVisited.end()) {
surfacesVisited.emplace_back(surf); surfacesVisited.emplace_back(surf);
auto subsurface = ((CSubsurfaceRole*)m_parent->m_role.get())->m_subsurface.lock(); auto subsurface = sc<CSubsurfaceRole*>(m_parent->m_role.get())->m_subsurface.lock();
pos += subsurface->m_position; pos += subsurface->m_position;
surf = subsurface->m_parent.lock(); surf = subsurface->m_parent.lock();
} }
@@ -133,7 +133,7 @@ SP<CWLSurfaceResource> CWLSubsurfaceResource::t1Parent() {
while (surf->m_role->role() == SURFACE_ROLE_SUBSURFACE && std::ranges::find_if(surfacesVisited, [surf](const auto& other) { return surf == other; }) == surfacesVisited.end()) { while (surf->m_role->role() == SURFACE_ROLE_SUBSURFACE && std::ranges::find_if(surfacesVisited, [surf](const auto& other) { return surf == other; }) == surfacesVisited.end()) {
surfacesVisited.emplace_back(surf); surfacesVisited.emplace_back(surf);
auto subsurface = ((CSubsurfaceRole*)m_parent->m_role.get())->m_subsurface.lock(); auto subsurface = sc<CSubsurfaceRole*>(m_parent->m_role.get())->m_subsurface.lock();
surf = subsurface->m_parent.lock(); surf = subsurface->m_parent.lock();
} }
return surf; return surf;
@@ -163,7 +163,7 @@ CWLSubcompositorResource::CWLSubcompositorResource(SP<CWlSubcompositor> resource
SP<CWLSurfaceResource> t1Parent = nullptr; SP<CWLSurfaceResource> t1Parent = nullptr;
if (PARENT->m_role->role() == SURFACE_ROLE_SUBSURFACE) { if (PARENT->m_role->role() == SURFACE_ROLE_SUBSURFACE) {
auto subsurface = ((CSubsurfaceRole*)PARENT->m_role.get())->m_subsurface.lock(); auto subsurface = sc<CSubsurfaceRole*>(PARENT->m_role.get())->m_subsurface.lock();
t1Parent = subsurface->t1Parent(); t1Parent = subsurface->t1Parent();
} else } else
t1Parent = PARENT; t1Parent = PARENT;

View File

@@ -2,6 +2,7 @@
#include "color-management-v1.hpp" #include "color-management-v1.hpp"
#include <hyprgraphics/color/Color.hpp> #include <hyprgraphics/color/Color.hpp>
#include "../../helpers/memory/Memory.hpp"
#define SDR_MIN_LUMINANCE 0.2 #define SDR_MIN_LUMINANCE 0.2
#define SDR_MAX_LUMINANCE 80.0 #define SDR_MAX_LUMINANCE 80.0
@@ -42,16 +43,16 @@ namespace NColorManagement {
// NOTE should be ok this way. unsupported primaries/tfs must be rejected earlier. supported enum values should be in sync with proto. // NOTE should be ok this way. unsupported primaries/tfs must be rejected earlier. supported enum values should be in sync with proto.
// might need a proper switch-case and additional INVALID enum value. // might need a proper switch-case and additional INVALID enum value.
inline wpColorManagerV1Primaries convertPrimaries(ePrimaries primaries) { inline wpColorManagerV1Primaries convertPrimaries(ePrimaries primaries) {
return (wpColorManagerV1Primaries)primaries; return sc<wpColorManagerV1Primaries>(primaries);
} }
inline ePrimaries convertPrimaries(wpColorManagerV1Primaries primaries) { inline ePrimaries convertPrimaries(wpColorManagerV1Primaries primaries) {
return (ePrimaries)primaries; return sc<ePrimaries>(primaries);
} }
inline wpColorManagerV1TransferFunction convertTransferFunction(eTransferFunction tf) { inline wpColorManagerV1TransferFunction convertTransferFunction(eTransferFunction tf) {
return (wpColorManagerV1TransferFunction)tf; return sc<wpColorManagerV1TransferFunction>(tf);
} }
inline eTransferFunction convertTransferFunction(wpColorManagerV1TransferFunction tf) { inline eTransferFunction convertTransferFunction(wpColorManagerV1TransferFunction tf) {
return (eTransferFunction)tf; return sc<eTransferFunction>(tf);
} }
using SPCPRimaries = Hyprgraphics::SPCPRimaries; using SPCPRimaries = Hyprgraphics::SPCPRimaries;

Some files were not shown because too many files have changed in this diff Show More