refactor: Use new hyprutils casts (#11377)
This commit is contained in:
parent
aa6a78f0a4
commit
beee22a95e
116 changed files with 715 additions and 696 deletions
|
|
@ -6,6 +6,9 @@
|
|||
#include <sys/un.h>
|
||||
#include <unistd.h>
|
||||
#include <cstring>
|
||||
#include <hyprutils/memory/Casts.hpp>
|
||||
|
||||
using namespace Hyprutils::Memory;
|
||||
|
||||
static int 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);
|
||||
|
||||
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)"));
|
||||
return "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,8 +26,10 @@
|
|||
|
||||
#include <hyprutils/string/String.hpp>
|
||||
#include <hyprutils/os/Process.hpp>
|
||||
#include <hyprutils/memory/Casts.hpp>
|
||||
using namespace Hyprutils::String;
|
||||
using namespace Hyprutils::OS;
|
||||
using namespace Hyprutils::Memory;
|
||||
|
||||
static std::string execAndGet(std::string cmd) {
|
||||
cmd += " 2>&1";
|
||||
|
|
@ -599,7 +601,7 @@ bool CPluginManager::updateHeaders(bool force) {
|
|||
|
||||
std::print("\n");
|
||||
} 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.m_iSteps = 5;
|
||||
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) {
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -9,9 +9,11 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
|
||||
#include <hyprutils/memory/Casts.hpp>
|
||||
#include "../helpers/Colors.hpp"
|
||||
|
||||
using namespace Hyprutils::Memory;
|
||||
|
||||
static winsize getTerminalSize() {
|
||||
winsize w{};
|
||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
|
||||
|
|
@ -44,7 +46,7 @@ void CProgressBar::print() {
|
|||
percentDone = m_fPercentage;
|
||||
else {
|
||||
// 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)
|
||||
percentDone = std::clamp(percentDone, 0.0f, 1.0f);
|
||||
|
|
@ -54,7 +56,7 @@ void CProgressBar::print() {
|
|||
std::ostringstream oss;
|
||||
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;
|
||||
|
||||
for (; i < filled; ++i)
|
||||
|
|
@ -69,7 +71,7 @@ void CProgressBar::print() {
|
|||
oss << Colors::RESET;
|
||||
|
||||
if (m_fPercentage >= 0.0f)
|
||||
oss << " " << std::format("{}%", static_cast<int>(percentDone * 100.0)) << ' ';
|
||||
oss << " " << std::format("{}%", sc<int>(percentDone * 100.0)) << ' ';
|
||||
else
|
||||
oss << " " << std::format("{} / {}", m_iSteps, m_iMaxSteps) << ' ';
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue