debug: move to hyprutils' logger (#12673)

This commit is contained in:
Vaxry 2025-12-18 17:23:24 +00:00 committed by GitHub
parent f88deb928a
commit 6175ecd4c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
147 changed files with 1696 additions and 1709 deletions

View file

@ -213,7 +213,7 @@ static SDispatchResult scroll(std::string in) {
by = std::stod(in); by = std::stod(in);
} catch (...) { return SDispatchResult{.success = false, .error = "invalid input"}; } } catch (...) { return SDispatchResult{.success = false, .error = "invalid input"}; }
Debug::log(LOG, "tester: scrolling by {}", by); Log::logger->log(Log::DEBUG, "tester: scrolling by {}", by);
g_mouse->m_pointerEvents.axis.emit(IPointer::SAxisEvent{ g_mouse->m_pointerEvents.axis.emit(IPointer::SAxisEvent{
.delta = by, .delta = by,

View file

@ -2,7 +2,7 @@
#include <re2/re2.h> #include <re2/re2.h>
#include "Compositor.hpp" #include "Compositor.hpp"
#include "debug/Log.hpp" #include "debug/log/Logger.hpp"
#include "desktop/DesktopTypes.hpp" #include "desktop/DesktopTypes.hpp"
#include "desktop/state/FocusState.hpp" #include "desktop/state/FocusState.hpp"
#include "helpers/Splashes.hpp" #include "helpers/Splashes.hpp"
@ -32,6 +32,7 @@
#include <helpers/SdDaemon.hpp> // for SdNotify #include <helpers/SdDaemon.hpp> // for SdNotify
#endif #endif
#include "helpers/fs/FsUtils.hpp" #include "helpers/fs/FsUtils.hpp"
#include "helpers/env/Env.hpp"
#include "protocols/FractionalScale.hpp" #include "protocols/FractionalScale.hpp"
#include "protocols/PointerConstraints.hpp" #include "protocols/PointerConstraints.hpp"
#include "protocols/LayerShell.hpp" #include "protocols/LayerShell.hpp"
@ -86,7 +87,7 @@ using enum NContentType::eContentType;
using namespace NColorManagement; using namespace NColorManagement;
static int handleCritSignal(int signo, void* data) { static int handleCritSignal(int signo, void* data) {
Debug::log(LOG, "Hyprland received signal {}", signo); Log::logger->log(Log::DEBUG, "Hyprland received signal {}", signo);
if (signo == SIGTERM || signo == SIGINT || signo == SIGKILL) if (signo == SIGTERM || signo == SIGINT || signo == SIGKILL)
g_pCompositor->stopCompositor(); g_pCompositor->stopCompositor();
@ -125,23 +126,6 @@ static void handleUserSignal(int sig) {
} }
} }
static eLogLevel aqLevelToHl(Aquamarine::eBackendLogLevel level) {
switch (level) {
case Aquamarine::eBackendLogLevel::AQ_LOG_TRACE: return TRACE;
case Aquamarine::eBackendLogLevel::AQ_LOG_DEBUG: return LOG;
case Aquamarine::eBackendLogLevel::AQ_LOG_ERROR: return ERR;
case Aquamarine::eBackendLogLevel::AQ_LOG_WARNING: return WARN;
case Aquamarine::eBackendLogLevel::AQ_LOG_CRITICAL: return CRIT;
default: break;
}
return NONE;
}
static void aqLog(Aquamarine::eBackendLogLevel level, std::string msg) {
Debug::log(aqLevelToHl(level), "[AQ] {}", msg);
}
bool CCompositor::setWatchdogFd(int fd) { bool CCompositor::setWatchdogFd(int fd) {
m_watchdogWriteFd = Hyprutils::OS::CFileDescriptor{fd}; m_watchdogWriteFd = Hyprutils::OS::CFileDescriptor{fd};
return m_watchdogWriteFd.isValid() && !m_watchdogWriteFd.isClosed(); return m_watchdogWriteFd.isValid() && !m_watchdogWriteFd.isClosed();
@ -149,9 +133,9 @@ bool CCompositor::setWatchdogFd(int fd) {
void CCompositor::bumpNofile() { void CCompositor::bumpNofile() {
if (!getrlimit(RLIMIT_NOFILE, &m_originalNofile)) if (!getrlimit(RLIMIT_NOFILE, &m_originalNofile))
Debug::log(LOG, "Old rlimit: soft -> {}, hard -> {}", m_originalNofile.rlim_cur, m_originalNofile.rlim_max); Log::logger->log(Log::DEBUG, "Old rlimit: soft -> {}, hard -> {}", m_originalNofile.rlim_cur, m_originalNofile.rlim_max);
else { else {
Debug::log(ERR, "Failed to get NOFILE rlimits"); Log::logger->log(Log::ERR, "Failed to get NOFILE rlimits");
m_originalNofile.rlim_max = 0; m_originalNofile.rlim_max = 0;
return; return;
} }
@ -161,13 +145,13 @@ void CCompositor::bumpNofile() {
newLimit.rlim_cur = newLimit.rlim_max; newLimit.rlim_cur = newLimit.rlim_max;
if (setrlimit(RLIMIT_NOFILE, &newLimit) < 0) { if (setrlimit(RLIMIT_NOFILE, &newLimit) < 0) {
Debug::log(ERR, "Failed bumping NOFILE limits higher"); Log::logger->log(Log::ERR, "Failed bumping NOFILE limits higher");
m_originalNofile.rlim_max = 0; m_originalNofile.rlim_max = 0;
return; return;
} }
if (!getrlimit(RLIMIT_NOFILE, &newLimit)) if (!getrlimit(RLIMIT_NOFILE, &newLimit))
Debug::log(LOG, "New rlimit: soft -> {}, hard -> {}", newLimit.rlim_cur, newLimit.rlim_max); Log::logger->log(Log::DEBUG, "New rlimit: soft -> {}, hard -> {}", newLimit.rlim_cur, newLimit.rlim_max);
} }
void CCompositor::restoreNofile() { void CCompositor::restoreNofile() {
@ -175,7 +159,7 @@ void CCompositor::restoreNofile() {
return; return;
if (setrlimit(RLIMIT_NOFILE, &m_originalNofile) < 0) if (setrlimit(RLIMIT_NOFILE, &m_originalNofile) < 0)
Debug::log(ERR, "Failed restoring NOFILE limits"); Log::logger->log(Log::ERR, "Failed restoring NOFILE limits");
} }
bool CCompositor::supportsDrmSyncobjTimeline() const { bool CCompositor::supportsDrmSyncobjTimeline() const {
@ -235,27 +219,27 @@ CCompositor::CCompositor(bool onlyConfig) : m_onlyConfigVerification(onlyConfig)
throw std::runtime_error("CCompositor() failed"); throw std::runtime_error("CCompositor() failed");
} }
Debug::init(m_instancePath); Log::logger->initIS(m_instancePath);
Debug::log(LOG, "Instance Signature: {}", m_instanceSignature); Log::logger->log(Log::DEBUG, "Instance Signature: {}", m_instanceSignature);
Debug::log(LOG, "Runtime directory: {}", m_instancePath); Log::logger->log(Log::DEBUG, "Runtime directory: {}", m_instancePath);
Debug::log(LOG, "Hyprland PID: {}", m_hyprlandPID); Log::logger->log(Log::DEBUG, "Hyprland PID: {}", m_hyprlandPID);
Debug::log(LOG, "===== SYSTEM INFO: ====="); Log::logger->log(Log::DEBUG, "===== SYSTEM INFO: =====");
logSystemInfo(); logSystemInfo();
Debug::log(LOG, "========================"); Log::logger->log(Log::DEBUG, "========================");
Debug::log(NONE, "\n\n"); // pad Log::logger->log(Log::DEBUG, "\n\n"); // pad
Debug::log(INFO, "If you are crashing, or encounter any bugs, please consult https://wiki.hypr.land/Crashes-and-Bugs/\n\n"); Log::logger->log(Log::INFO, "If you are crashing, or encounter any bugs, please consult https://wiki.hypr.land/Crashes-and-Bugs/\n\n");
setRandomSplash(); setRandomSplash();
Debug::log(LOG, "\nCurrent splash: {}\n\n", m_currentSplash); Log::logger->log(Log::DEBUG, "\nCurrent splash: {}\n\n", m_currentSplash);
bumpNofile(); bumpNofile();
} }
@ -315,7 +299,7 @@ void CCompositor::initServer(std::string socketName, int socketFd) {
// register crit signal handler // register crit signal handler
m_critSigSource = wl_event_loop_add_signal(m_wlEventLoop, SIGTERM, handleCritSignal, nullptr); m_critSigSource = wl_event_loop_add_signal(m_wlEventLoop, SIGTERM, handleCritSignal, nullptr);
if (!envEnabled("HYPRLAND_NO_CRASHREPORTER")) { if (!Env::envEnabled("HYPRLAND_NO_CRASHREPORTER")) {
signal(SIGSEGV, handleUnrecoverableSignal); signal(SIGSEGV, handleUnrecoverableSignal);
signal(SIGABRT, handleUnrecoverableSignal); signal(SIGABRT, handleUnrecoverableSignal);
} }
@ -323,14 +307,16 @@ void CCompositor::initServer(std::string socketName, int socketFd) {
initManagers(STAGE_PRIORITY); initManagers(STAGE_PRIORITY);
if (envEnabled("HYPRLAND_TRACE")) Log::logger->initCallbacks();
Debug::m_trace = true;
// set the buffer size to 1MB to avoid disconnects due to an app hanging for a short while // set the buffer size to 1MB to avoid disconnects due to an app hanging for a short while
wl_display_set_default_max_buffer_size(m_wlDisplay, 1_MB); wl_display_set_default_max_buffer_size(m_wlDisplay, 1_MB);
Aquamarine::SBackendOptions options{}; Aquamarine::SBackendOptions options{};
options.logFunction = aqLog; SP<Hyprutils::CLI::CLoggerConnection> conn = makeShared<Hyprutils::CLI::CLoggerConnection>(Log::logger->hu());
conn->setLogLevel(Log::DEBUG);
conn->setName("aquamarine");
options.logConnection = std::move(conn);
std::vector<Aquamarine::SBackendImplementationOptions> implementations; std::vector<Aquamarine::SBackendImplementationOptions> implementations;
Aquamarine::SBackendImplementationOptions option; Aquamarine::SBackendImplementationOptions option;
@ -347,7 +333,8 @@ void CCompositor::initServer(std::string socketName, int socketFd) {
m_aqBackend = CBackend::create(implementations, options); m_aqBackend = CBackend::create(implementations, options);
if (!m_aqBackend) { if (!m_aqBackend) {
Debug::log(CRIT, Log::logger->log(
Log::CRIT,
"m_pAqBackend was null! This usually means aquamarine could not find a GPU or encountered some issues. Make sure you're running either on a tty or on a Wayland " "m_pAqBackend was null! This usually means aquamarine could not find a GPU or encountered some issues. Make sure you're running either on a tty or on a Wayland "
"session, NOT an X11 one."); "session, NOT an X11 one.");
throwError("CBackend::create() failed!"); throwError("CBackend::create() failed!");
@ -358,7 +345,8 @@ void CCompositor::initServer(std::string socketName, int socketFd) {
initAllSignals(); initAllSignals();
if (!m_aqBackend->start()) { if (!m_aqBackend->start()) {
Debug::log(CRIT, Log::logger->log(
Log::CRIT,
"m_pAqBackend couldn't start! This usually means aquamarine could not find a GPU or encountered some issues. Make sure you're running either on a tty or on a " "m_pAqBackend couldn't start! This usually means aquamarine could not find a GPU or encountered some issues. Make sure you're running either on a tty or on a "
"Wayland session, NOT an X11 one."); "Wayland session, NOT an X11 one.");
throwError("CBackend::create() failed!"); throwError("CBackend::create() failed!");
@ -367,10 +355,10 @@ void CCompositor::initServer(std::string socketName, int socketFd) {
m_initialized = true; m_initialized = true;
m_drm.fd = m_aqBackend->drmFD(); m_drm.fd = m_aqBackend->drmFD();
Debug::log(LOG, "Running on DRMFD: {}", m_drm.fd); Log::logger->log(Log::DEBUG, "Running on DRMFD: {}", m_drm.fd);
m_drmRenderNode.fd = m_aqBackend->drmRenderNodeFD(); m_drmRenderNode.fd = m_aqBackend->drmRenderNodeFD();
Debug::log(LOG, "Using RENDERNODEFD: {}", m_drmRenderNode.fd); Log::logger->log(Log::DEBUG, "Using RENDERNODEFD: {}", m_drmRenderNode.fd);
#if defined(__linux__) #if defined(__linux__)
auto syncObjSupport = [](auto fd) { auto syncObjSupport = [](auto fd) {
@ -383,15 +371,15 @@ void CCompositor::initServer(std::string socketName, int socketFd) {
}; };
if ((m_drm.syncobjSupport = syncObjSupport(m_drm.fd))) if ((m_drm.syncobjSupport = syncObjSupport(m_drm.fd)))
Debug::log(LOG, "DRM DisplayNode syncobj timeline support: {}", m_drm.syncobjSupport ? "yes" : "no"); Log::logger->log(Log::DEBUG, "DRM DisplayNode syncobj timeline support: {}", m_drm.syncobjSupport ? "yes" : "no");
if ((m_drmRenderNode.syncObjSupport = syncObjSupport(m_drmRenderNode.fd))) if ((m_drmRenderNode.syncObjSupport = syncObjSupport(m_drmRenderNode.fd)))
Debug::log(LOG, "DRM RenderNode syncobj timeline support: {}", m_drmRenderNode.syncObjSupport ? "yes" : "no"); Log::logger->log(Log::DEBUG, "DRM RenderNode syncobj timeline support: {}", m_drmRenderNode.syncObjSupport ? "yes" : "no");
if (!m_drm.syncobjSupport && !m_drmRenderNode.syncObjSupport) if (!m_drm.syncobjSupport && !m_drmRenderNode.syncObjSupport)
Debug::log(LOG, "DRM no syncobj support, disabling explicit sync"); Log::logger->log(Log::DEBUG, "DRM no syncobj support, disabling explicit sync");
#else #else
Debug::log(LOG, "DRM syncobj timeline support: no (not linux)"); Log::logger->log(Log::DEBUG, "DRM syncobj timeline support: no (not linux)");
#endif #endif
if (!socketName.empty() && socketFd != -1) { if (!socketName.empty() && socketFd != -1) {
@ -399,9 +387,9 @@ void CCompositor::initServer(std::string socketName, int socketFd) {
const auto RETVAL = wl_display_add_socket_fd(m_wlDisplay, socketFd); const auto RETVAL = wl_display_add_socket_fd(m_wlDisplay, socketFd);
if (RETVAL >= 0) { if (RETVAL >= 0) {
m_wlDisplaySocket = socketName; m_wlDisplaySocket = socketName;
Debug::log(LOG, "wl_display_add_socket_fd for {} succeeded with {}", socketName, RETVAL); Log::logger->log(Log::DEBUG, "wl_display_add_socket_fd for {} succeeded with {}", socketName, RETVAL);
} else } else
Debug::log(WARN, "wl_display_add_socket_fd for {} returned {}: skipping", socketName, RETVAL); Log::logger->log(Log::WARN, "wl_display_add_socket_fd for {} returned {}: skipping", socketName, RETVAL);
} else { } else {
// get socket, avoid using 0 // get socket, avoid using 0
for (int candidate = 1; candidate <= 32; candidate++) { for (int candidate = 1; candidate <= 32; candidate++) {
@ -409,22 +397,22 @@ void CCompositor::initServer(std::string socketName, int socketFd) {
const auto RETVAL = wl_display_add_socket(m_wlDisplay, CANDIDATESTR.c_str()); const auto RETVAL = wl_display_add_socket(m_wlDisplay, CANDIDATESTR.c_str());
if (RETVAL >= 0) { if (RETVAL >= 0) {
m_wlDisplaySocket = CANDIDATESTR; m_wlDisplaySocket = CANDIDATESTR;
Debug::log(LOG, "wl_display_add_socket for {} succeeded with {}", CANDIDATESTR, RETVAL); Log::logger->log(Log::DEBUG, "wl_display_add_socket for {} succeeded with {}", CANDIDATESTR, RETVAL);
break; break;
} else } else
Debug::log(WARN, "wl_display_add_socket for {} returned {}: skipping candidate {}", CANDIDATESTR, RETVAL, candidate); Log::logger->log(Log::WARN, "wl_display_add_socket for {} returned {}: skipping candidate {}", CANDIDATESTR, RETVAL, candidate);
} }
} }
if (m_wlDisplaySocket.empty()) { if (m_wlDisplaySocket.empty()) {
Debug::log(WARN, "All candidates failed, trying wl_display_add_socket_auto"); Log::logger->log(Log::WARN, "All candidates failed, trying wl_display_add_socket_auto");
const auto SOCKETSTR = wl_display_add_socket_auto(m_wlDisplay); const auto SOCKETSTR = wl_display_add_socket_auto(m_wlDisplay);
if (SOCKETSTR) if (SOCKETSTR)
m_wlDisplaySocket = SOCKETSTR; m_wlDisplaySocket = SOCKETSTR;
} }
if (m_wlDisplaySocket.empty()) { if (m_wlDisplaySocket.empty()) {
Debug::log(CRIT, "m_szWLDisplaySocket NULL!"); Log::logger->log(Log::CRIT, "m_szWLDisplaySocket NULL!");
throwError("m_szWLDisplaySocket was null! (wl_display_add_socket and wl_display_add_socket_auto failed)"); throwError("m_szWLDisplaySocket was null! (wl_display_add_socket and wl_display_add_socket_auto failed)");
} }
@ -446,7 +434,7 @@ void CCompositor::initServer(std::string socketName, int socketFd) {
void CCompositor::initAllSignals() { void CCompositor::initAllSignals() {
m_aqBackend->events.newOutput.listenStatic([this](const SP<Aquamarine::IOutput>& output) { m_aqBackend->events.newOutput.listenStatic([this](const SP<Aquamarine::IOutput>& output) {
Debug::log(LOG, "New aquamarine output with name {}", output->name); Log::logger->log(Log::DEBUG, "New aquamarine output with name {}", output->name);
if (m_initialized) if (m_initialized)
onNewMonitor(output); onNewMonitor(output);
else else
@ -454,42 +442,42 @@ void CCompositor::initAllSignals() {
}); });
m_aqBackend->events.newPointer.listenStatic([](const SP<Aquamarine::IPointer>& dev) { m_aqBackend->events.newPointer.listenStatic([](const SP<Aquamarine::IPointer>& dev) {
Debug::log(LOG, "New aquamarine pointer with name {}", dev->getName()); Log::logger->log(Log::DEBUG, "New aquamarine pointer with name {}", dev->getName());
g_pInputManager->newMouse(dev); g_pInputManager->newMouse(dev);
g_pInputManager->updateCapabilities(); g_pInputManager->updateCapabilities();
}); });
m_aqBackend->events.newKeyboard.listenStatic([](const SP<Aquamarine::IKeyboard>& dev) { m_aqBackend->events.newKeyboard.listenStatic([](const SP<Aquamarine::IKeyboard>& dev) {
Debug::log(LOG, "New aquamarine keyboard with name {}", dev->getName()); Log::logger->log(Log::DEBUG, "New aquamarine keyboard with name {}", dev->getName());
g_pInputManager->newKeyboard(dev); g_pInputManager->newKeyboard(dev);
g_pInputManager->updateCapabilities(); g_pInputManager->updateCapabilities();
}); });
m_aqBackend->events.newTouch.listenStatic([](const SP<Aquamarine::ITouch>& dev) { m_aqBackend->events.newTouch.listenStatic([](const SP<Aquamarine::ITouch>& dev) {
Debug::log(LOG, "New aquamarine touch with name {}", dev->getName()); Log::logger->log(Log::DEBUG, "New aquamarine touch with name {}", dev->getName());
g_pInputManager->newTouchDevice(dev); g_pInputManager->newTouchDevice(dev);
g_pInputManager->updateCapabilities(); g_pInputManager->updateCapabilities();
}); });
m_aqBackend->events.newSwitch.listenStatic([](const SP<Aquamarine::ISwitch>& dev) { m_aqBackend->events.newSwitch.listenStatic([](const SP<Aquamarine::ISwitch>& dev) {
Debug::log(LOG, "New aquamarine switch with name {}", dev->getName()); Log::logger->log(Log::DEBUG, "New aquamarine switch with name {}", dev->getName());
g_pInputManager->newSwitch(dev); g_pInputManager->newSwitch(dev);
}); });
m_aqBackend->events.newTablet.listenStatic([](const SP<Aquamarine::ITablet>& dev) { m_aqBackend->events.newTablet.listenStatic([](const SP<Aquamarine::ITablet>& dev) {
Debug::log(LOG, "New aquamarine tablet with name {}", dev->getName()); Log::logger->log(Log::DEBUG, "New aquamarine tablet with name {}", dev->getName());
g_pInputManager->newTablet(dev); g_pInputManager->newTablet(dev);
}); });
m_aqBackend->events.newTabletPad.listenStatic([](const SP<Aquamarine::ITabletPad>& dev) { m_aqBackend->events.newTabletPad.listenStatic([](const SP<Aquamarine::ITabletPad>& dev) {
Debug::log(LOG, "New aquamarine tablet pad with name {}", dev->getName()); Log::logger->log(Log::DEBUG, "New aquamarine tablet pad with name {}", dev->getName());
g_pInputManager->newTabletPad(dev); g_pInputManager->newTabletPad(dev);
}); });
if (m_aqBackend->hasSession()) { if (m_aqBackend->hasSession()) {
m_aqBackend->session->events.changeActive.listenStatic([this] { m_aqBackend->session->events.changeActive.listenStatic([this] {
if (m_aqBackend->session->active) { if (m_aqBackend->session->active) {
Debug::log(LOG, "Session got activated!"); Log::logger->log(Log::DEBUG, "Session got activated!");
m_sessionActive = true; m_sessionActive = true;
@ -501,7 +489,7 @@ void CCompositor::initAllSignals() {
g_pConfigManager->m_wantsMonitorReload = true; g_pConfigManager->m_wantsMonitorReload = true;
g_pCursorManager->syncGsettings(); g_pCursorManager->syncGsettings();
} else { } else {
Debug::log(LOG, "Session got deactivated!"); Log::logger->log(Log::DEBUG, "Session got deactivated!");
m_sessionActive = false; m_sessionActive = false;
} }
@ -525,7 +513,7 @@ void CCompositor::cleanEnvironment() {
if (m_desktopEnvSet) if (m_desktopEnvSet)
unsetenv("XDG_CURRENT_DESKTOP"); unsetenv("XDG_CURRENT_DESKTOP");
if (m_aqBackend->hasSession() && !envEnabled("HYPRLAND_NO_SD_VARS")) { if (m_aqBackend->hasSession() && !Env::envEnabled("HYPRLAND_NO_SD_VARS")) {
const auto CMD = const auto CMD =
#ifdef USES_SYSTEMD #ifdef USES_SYSTEMD
"systemctl --user unset-environment DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP QT_QPA_PLATFORMTHEME PATH XDG_DATA_DIRS && hash " "systemctl --user unset-environment DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP QT_QPA_PLATFORMTHEME PATH XDG_DATA_DIRS && hash "
@ -537,7 +525,7 @@ void CCompositor::cleanEnvironment() {
} }
void CCompositor::stopCompositor() { void CCompositor::stopCompositor() {
Debug::log(LOG, "Hyprland is stopping!"); Log::logger->log(Log::DEBUG, "Hyprland is stopping!");
// this stops the wayland loop, wl_display_run // this stops the wayland loop, wl_display_run
wl_display_terminate(m_wlDisplay); wl_display_terminate(m_wlDisplay);
@ -557,10 +545,9 @@ void CCompositor::cleanup() {
removeLockFile(); removeLockFile();
m_isShuttingDown = true; m_isShuttingDown = true;
Debug::m_shuttingDown = true;
#ifdef USES_SYSTEMD #ifdef USES_SYSTEMD
if (NSystemd::sdBooted() > 0 && !envEnabled("HYPRLAND_NO_SD_NOTIFY")) if (NSystemd::sdBooted() > 0 && !Env::envEnabled("HYPRLAND_NO_SD_NOTIFY"))
NSystemd::sdNotify(0, "STOPPING=1"); NSystemd::sdNotify(0, "STOPPING=1");
#endif #endif
@ -622,106 +609,104 @@ void CCompositor::cleanup() {
// this frees all wayland resources, including sockets // this frees all wayland resources, including sockets
wl_display_destroy(m_wlDisplay); wl_display_destroy(m_wlDisplay);
Debug::close();
} }
void CCompositor::initManagers(eManagersInitStage stage) { void CCompositor::initManagers(eManagersInitStage stage) {
switch (stage) { switch (stage) {
case STAGE_PRIORITY: { case STAGE_PRIORITY: {
Debug::log(LOG, "Creating the EventLoopManager!"); Log::logger->log(Log::DEBUG, "Creating the EventLoopManager!");
g_pEventLoopManager = makeUnique<CEventLoopManager>(m_wlDisplay, m_wlEventLoop); g_pEventLoopManager = makeUnique<CEventLoopManager>(m_wlDisplay, m_wlEventLoop);
Debug::log(LOG, "Creating the HookSystem!"); Log::logger->log(Log::DEBUG, "Creating the HookSystem!");
g_pHookSystem = makeUnique<CHookSystemManager>(); g_pHookSystem = makeUnique<CHookSystemManager>();
Debug::log(LOG, "Creating the KeybindManager!"); Log::logger->log(Log::DEBUG, "Creating the KeybindManager!");
g_pKeybindManager = makeUnique<CKeybindManager>(); g_pKeybindManager = makeUnique<CKeybindManager>();
Debug::log(LOG, "Creating the AnimationManager!"); Log::logger->log(Log::DEBUG, "Creating the AnimationManager!");
g_pAnimationManager = makeUnique<CHyprAnimationManager>(); g_pAnimationManager = makeUnique<CHyprAnimationManager>();
Debug::log(LOG, "Creating the DynamicPermissionManager!"); Log::logger->log(Log::DEBUG, "Creating the DynamicPermissionManager!");
g_pDynamicPermissionManager = makeUnique<CDynamicPermissionManager>(); g_pDynamicPermissionManager = makeUnique<CDynamicPermissionManager>();
Debug::log(LOG, "Creating the ConfigManager!"); Log::logger->log(Log::DEBUG, "Creating the ConfigManager!");
g_pConfigManager = makeUnique<CConfigManager>(); g_pConfigManager = makeUnique<CConfigManager>();
Debug::log(LOG, "Creating the CHyprError!"); Log::logger->log(Log::DEBUG, "Creating the CHyprError!");
g_pHyprError = makeUnique<CHyprError>(); g_pHyprError = makeUnique<CHyprError>();
Debug::log(LOG, "Creating the LayoutManager!"); Log::logger->log(Log::DEBUG, "Creating the LayoutManager!");
g_pLayoutManager = makeUnique<CLayoutManager>(); g_pLayoutManager = makeUnique<CLayoutManager>();
Debug::log(LOG, "Creating the TokenManager!"); Log::logger->log(Log::DEBUG, "Creating the TokenManager!");
g_pTokenManager = makeUnique<CTokenManager>(); g_pTokenManager = makeUnique<CTokenManager>();
g_pConfigManager->init(); g_pConfigManager->init();
Debug::log(LOG, "Creating the PointerManager!"); Log::logger->log(Log::DEBUG, "Creating the PointerManager!");
g_pPointerManager = makeUnique<CPointerManager>(); g_pPointerManager = makeUnique<CPointerManager>();
Debug::log(LOG, "Creating the EventManager!"); Log::logger->log(Log::DEBUG, "Creating the EventManager!");
g_pEventManager = makeUnique<CEventManager>(); g_pEventManager = makeUnique<CEventManager>();
Debug::log(LOG, "Creating the AsyncResourceGatherer!"); Log::logger->log(Log::DEBUG, "Creating the AsyncResourceGatherer!");
g_pAsyncResourceGatherer = makeUnique<Hyprgraphics::CAsyncResourceGatherer>(); g_pAsyncResourceGatherer = makeUnique<Hyprgraphics::CAsyncResourceGatherer>();
} break; } break;
case STAGE_BASICINIT: { case STAGE_BASICINIT: {
Debug::log(LOG, "Creating the CHyprOpenGLImpl!"); Log::logger->log(Log::DEBUG, "Creating the CHyprOpenGLImpl!");
g_pHyprOpenGL = makeUnique<CHyprOpenGLImpl>(); g_pHyprOpenGL = makeUnique<CHyprOpenGLImpl>();
Debug::log(LOG, "Creating the ProtocolManager!"); Log::logger->log(Log::DEBUG, "Creating the ProtocolManager!");
g_pProtocolManager = makeUnique<CProtocolManager>(); g_pProtocolManager = makeUnique<CProtocolManager>();
Debug::log(LOG, "Creating the SeatManager!"); Log::logger->log(Log::DEBUG, "Creating the SeatManager!");
g_pSeatManager = makeUnique<CSeatManager>(); g_pSeatManager = makeUnique<CSeatManager>();
} break; } break;
case STAGE_LATE: { case STAGE_LATE: {
Debug::log(LOG, "Creating CHyprCtl"); Log::logger->log(Log::DEBUG, "Creating CHyprCtl");
g_pHyprCtl = makeUnique<CHyprCtl>(); g_pHyprCtl = makeUnique<CHyprCtl>();
Debug::log(LOG, "Creating the InputManager!"); Log::logger->log(Log::DEBUG, "Creating the InputManager!");
g_pInputManager = makeUnique<CInputManager>(); g_pInputManager = makeUnique<CInputManager>();
Debug::log(LOG, "Creating the HyprRenderer!"); Log::logger->log(Log::DEBUG, "Creating the HyprRenderer!");
g_pHyprRenderer = makeUnique<CHyprRenderer>(); g_pHyprRenderer = makeUnique<CHyprRenderer>();
Debug::log(LOG, "Creating the XWaylandManager!"); Log::logger->log(Log::DEBUG, "Creating the XWaylandManager!");
g_pXWaylandManager = makeUnique<CHyprXWaylandManager>(); g_pXWaylandManager = makeUnique<CHyprXWaylandManager>();
Debug::log(LOG, "Creating the SessionLockManager!"); Log::logger->log(Log::DEBUG, "Creating the SessionLockManager!");
g_pSessionLockManager = makeUnique<CSessionLockManager>(); g_pSessionLockManager = makeUnique<CSessionLockManager>();
Debug::log(LOG, "Creating the HyprDebugOverlay!"); Log::logger->log(Log::DEBUG, "Creating the HyprDebugOverlay!");
g_pDebugOverlay = makeUnique<CHyprDebugOverlay>(); g_pDebugOverlay = makeUnique<CHyprDebugOverlay>();
Debug::log(LOG, "Creating the HyprNotificationOverlay!"); Log::logger->log(Log::DEBUG, "Creating the HyprNotificationOverlay!");
g_pHyprNotificationOverlay = makeUnique<CHyprNotificationOverlay>(); g_pHyprNotificationOverlay = makeUnique<CHyprNotificationOverlay>();
Debug::log(LOG, "Creating the PluginSystem!"); Log::logger->log(Log::DEBUG, "Creating the PluginSystem!");
g_pPluginSystem = makeUnique<CPluginSystem>(); g_pPluginSystem = makeUnique<CPluginSystem>();
g_pConfigManager->handlePluginLoads(); g_pConfigManager->handlePluginLoads();
Debug::log(LOG, "Creating the DecorationPositioner!"); Log::logger->log(Log::DEBUG, "Creating the DecorationPositioner!");
g_pDecorationPositioner = makeUnique<CDecorationPositioner>(); g_pDecorationPositioner = makeUnique<CDecorationPositioner>();
Debug::log(LOG, "Creating the CursorManager!"); Log::logger->log(Log::DEBUG, "Creating the CursorManager!");
g_pCursorManager = makeUnique<CCursorManager>(); g_pCursorManager = makeUnique<CCursorManager>();
Debug::log(LOG, "Creating the VersionKeeper!"); Log::logger->log(Log::DEBUG, "Creating the VersionKeeper!");
g_pVersionKeeperMgr = makeUnique<CVersionKeeperManager>(); g_pVersionKeeperMgr = makeUnique<CVersionKeeperManager>();
Debug::log(LOG, "Creating the DonationNag!"); Log::logger->log(Log::DEBUG, "Creating the DonationNag!");
g_pDonationNagManager = makeUnique<CDonationNagManager>(); g_pDonationNagManager = makeUnique<CDonationNagManager>();
Debug::log(LOG, "Creating the WelcomeManager!"); Log::logger->log(Log::DEBUG, "Creating the WelcomeManager!");
g_pWelcomeManager = makeUnique<CWelcomeManager>(); g_pWelcomeManager = makeUnique<CWelcomeManager>();
Debug::log(LOG, "Creating the ANRManager!"); Log::logger->log(Log::DEBUG, "Creating the ANRManager!");
g_pANRManager = makeUnique<CANRManager>(); g_pANRManager = makeUnique<CANRManager>();
Debug::log(LOG, "Starting XWayland"); Log::logger->log(Log::DEBUG, "Starting XWayland");
g_pXWayland = makeUnique<CXWayland>(g_pCompositor->m_wantsXwayland); g_pXWayland = makeUnique<CXWayland>(g_pCompositor->m_wantsXwayland);
} break; } break;
default: UNREACHABLE(); default: UNREACHABLE();
@ -756,7 +741,7 @@ void CCompositor::prepareFallbackOutput() {
} }
if (!headless) { if (!headless) {
Debug::log(WARN, "No headless in prepareFallbackOutput?!"); Log::logger->log(Log::WARN, "No headless in prepareFallbackOutput?!");
return; return;
} }
@ -773,7 +758,7 @@ void CCompositor::startCompositor() {
/* Session-less Hyprland usually means a nest, don't update the env in that case */ /* Session-less Hyprland usually means a nest, don't update the env in that case */
m_aqBackend->hasSession() && m_aqBackend->hasSession() &&
/* Activation environment management is not disabled */ /* Activation environment management is not disabled */
!envEnabled("HYPRLAND_NO_SD_VARS")) { !Env::envEnabled("HYPRLAND_NO_SD_VARS")) {
const auto CMD = const auto CMD =
#ifdef USES_SYSTEMD #ifdef USES_SYSTEMD
"systemctl --user import-environment DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP QT_QPA_PLATFORMTHEME PATH XDG_DATA_DIRS && hash " "systemctl --user import-environment DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP QT_QPA_PLATFORMTHEME PATH XDG_DATA_DIRS && hash "
@ -783,7 +768,7 @@ void CCompositor::startCompositor() {
CKeybindManager::spawn(CMD); CKeybindManager::spawn(CMD);
} }
Debug::log(LOG, "Running on WAYLAND_DISPLAY: {}", m_wlDisplaySocket); Log::logger->log(Log::DEBUG, "Running on WAYLAND_DISPLAY: {}", m_wlDisplaySocket);
prepareFallbackOutput(); prepareFallbackOutput();
@ -792,10 +777,10 @@ void CCompositor::startCompositor() {
#ifdef USES_SYSTEMD #ifdef USES_SYSTEMD
if (NSystemd::sdBooted() > 0) { if (NSystemd::sdBooted() > 0) {
// tell systemd that we are ready so it can start other bond, following, related units // tell systemd that we are ready so it can start other bond, following, related units
if (!envEnabled("HYPRLAND_NO_SD_NOTIFY")) if (!Env::envEnabled("HYPRLAND_NO_SD_NOTIFY"))
NSystemd::sdNotify(0, "READY=1"); NSystemd::sdNotify(0, "READY=1");
} else } else
Debug::log(LOG, "systemd integration is baked in but system itself is not booted à la systemd!"); Log::logger->log(Log::DEBUG, "systemd integration is baked in but system itself is not booted à la systemd!");
#endif #endif
createLockFile(); createLockFile();
@ -805,7 +790,7 @@ void CCompositor::startCompositor() {
write(m_watchdogWriteFd.get(), "vax", 3); write(m_watchdogWriteFd.get(), "vax", 3);
// This blocks until we are done. // This blocks until we are done.
Debug::log(LOG, "Hyprland is ready, running the event loop!"); Log::logger->log(Log::DEBUG, "Hyprland is ready, running the event loop!");
g_pEventLoopManager->enterLoop(); g_pEventLoopManager->enterLoop();
} }
@ -842,7 +827,7 @@ PHLMONITOR CCompositor::getMonitorFromCursor() {
PHLMONITOR CCompositor::getMonitorFromVector(const Vector2D& point) { PHLMONITOR CCompositor::getMonitorFromVector(const Vector2D& point) {
if (m_monitors.empty()) { if (m_monitors.empty()) {
Debug::log(WARN, "getMonitorFromVector called with empty monitor list"); Log::logger->log(Log::WARN, "getMonitorFromVector called with empty monitor list");
return nullptr; return nullptr;
} }
@ -868,7 +853,7 @@ PHLMONITOR CCompositor::getMonitorFromVector(const Vector2D& point) {
} }
if (!pBestMon) { // ????? if (!pBestMon) { // ?????
Debug::log(WARN, "getMonitorFromVector no close mon???"); Log::logger->log(Log::WARN, "getMonitorFromVector no close mon???");
return m_monitors.front(); return m_monitors.front();
} }
@ -1310,7 +1295,7 @@ void CCompositor::cleanupFadingOut(const MONITORID& monid) {
w.reset(); w.reset();
Debug::log(LOG, "Cleanup: destroyed a window"); Log::logger->log(Log::DEBUG, "Cleanup: destroyed a window");
return; return;
} }
} }
@ -1347,7 +1332,7 @@ void CCompositor::cleanupFadingOut(const MONITORID& monid) {
ls.reset(); ls.reset();
Debug::log(LOG, "Cleanup: destroyed a layersurface"); Log::logger->log(Log::DEBUG, "Cleanup: destroyed a layersurface");
return; return;
} }
@ -1621,7 +1606,7 @@ PHLWORKSPACE CCompositor::getWorkspaceByString(const std::string& str) {
try { try {
return getWorkspaceByID(getWorkspaceIDNameFromString(str).id); return getWorkspaceByID(getWorkspaceIDNameFromString(str).id);
} catch (std::exception& e) { Debug::log(ERR, "Error in getWorkspaceByString, invalid id"); } } catch (std::exception& e) { Log::logger->log(Log::ERR, "Error in getWorkspaceByString, invalid id"); }
return nullptr; return nullptr;
} }
@ -1871,7 +1856,7 @@ PHLMONITOR CCompositor::getMonitorFromString(const std::string& name) {
const auto OFFSET = name[0] == '-' ? name : name.substr(1); const auto OFFSET = name[0] == '-' ? name : name.substr(1);
if (!isNumber(OFFSET)) { if (!isNumber(OFFSET)) {
Debug::log(ERR, "Error in getMonitorFromString: Not a number in relative."); Log::logger->log(Log::ERR, "Error in getMonitorFromString: Not a number in relative.");
return nullptr; return nullptr;
} }
@ -1895,7 +1880,7 @@ PHLMONITOR CCompositor::getMonitorFromString(const std::string& name) {
} }
if (currentPlace != std::clamp(currentPlace, 0, sc<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."); Log::logger->log(Log::WARN, "Error in getMonitorFromString: Vaxry's code sucks.");
currentPlace = std::clamp(currentPlace, 0, sc<int>(m_monitors.size()) - 1); currentPlace = std::clamp(currentPlace, 0, sc<int>(m_monitors.size()) - 1);
} }
@ -1907,14 +1892,14 @@ PHLMONITOR CCompositor::getMonitorFromString(const std::string& name) {
monID = std::stoi(name); monID = std::stoi(name);
} catch (std::exception& e) { } catch (std::exception& e) {
// shouldn't happen but jic // shouldn't happen but jic
Debug::log(ERR, "Error in getMonitorFromString: invalid num"); Log::logger->log(Log::ERR, "Error in getMonitorFromString: invalid num");
return nullptr; return nullptr;
} }
if (monID > -1 && monID < sc<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"); Log::logger->log(Log::ERR, "Error in getMonitorFromString: invalid arg 1");
return nullptr; return nullptr;
} }
} else { } else {
@ -1940,7 +1925,7 @@ void CCompositor::moveWorkspaceToMonitor(PHLWORKSPACE pWorkspace, PHLMONITOR pMo
if (pWorkspace->m_monitor == pMonitor) if (pWorkspace->m_monitor == pMonitor)
return; return;
Debug::log(LOG, "moveWorkspaceToMonitor: Moving {} to monitor {}", pWorkspace->m_id, pMonitor->m_id); Log::logger->log(Log::DEBUG, "moveWorkspaceToMonitor: Moving {} to monitor {}", pWorkspace->m_id, pMonitor->m_id);
const auto POLDMON = pWorkspace->m_monitor.lock(); const auto POLDMON = pWorkspace->m_monitor.lock();
@ -1969,13 +1954,13 @@ void CCompositor::moveWorkspaceToMonitor(PHLWORKSPACE pWorkspace, PHLMONITOR pMo
}()) }())
nextWorkspaceOnMonitorID++; nextWorkspaceOnMonitorID++;
Debug::log(LOG, "moveWorkspaceToMonitor: Plugging gap with new {}", nextWorkspaceOnMonitorID); Log::logger->log(Log::DEBUG, "moveWorkspaceToMonitor: Plugging gap with new {}", nextWorkspaceOnMonitorID);
if (POLDMON) if (POLDMON)
newWorkspace = g_pCompositor->createNewWorkspace(nextWorkspaceOnMonitorID, POLDMON->m_id); newWorkspace = g_pCompositor->createNewWorkspace(nextWorkspaceOnMonitorID, POLDMON->m_id);
} }
Debug::log(LOG, "moveWorkspaceToMonitor: Plugging gap with existing {}", nextWorkspaceOnMonitorID); Log::logger->log(Log::DEBUG, "moveWorkspaceToMonitor: Plugging gap with existing {}", nextWorkspaceOnMonitorID);
if (POLDMON) if (POLDMON)
POLDMON->changeWorkspace(nextWorkspaceOnMonitorID, false, true, true); POLDMON->changeWorkspace(nextWorkspaceOnMonitorID, false, true, true);
} }
@ -2015,7 +2000,7 @@ void CCompositor::moveWorkspaceToMonitor(PHLWORKSPACE pWorkspace, PHLMONITOR pMo
} }
if (SWITCHINGISACTIVE && POLDMON == Desktop::focusState()->monitor()) { // if it was active, preserve its' status. If it wasn't, don't. if (SWITCHINGISACTIVE && POLDMON == Desktop::focusState()->monitor()) { // if it was active, preserve its' status. If it wasn't, don't.
Debug::log(LOG, "moveWorkspaceToMonitor: SWITCHINGISACTIVE, active {} -> {}", pMonitor->activeWorkspaceID(), pWorkspace->m_id); Log::logger->log(Log::DEBUG, "moveWorkspaceToMonitor: SWITCHINGISACTIVE, active {} -> {}", pMonitor->activeWorkspaceID(), pWorkspace->m_id);
if (valid(pMonitor->m_activeWorkspace)) { if (valid(pMonitor->m_activeWorkspace)) {
pMonitor->m_activeWorkspace->m_visible = false; pMonitor->m_activeWorkspace->m_visible = false;
@ -2419,7 +2404,7 @@ Vector2D CCompositor::parseWindowVectorArgsRelative(const std::string& args, con
} }
if (!isNumber(x) || !isNumber(y)) { if (!isNumber(x) || !isNumber(y)) {
Debug::log(ERR, "parseWindowVectorArgsRelative: args not numbers"); Log::logger->log(Log::ERR, "parseWindowVectorArgsRelative: args not numbers");
return relativeTo; return relativeTo;
} }
@ -2449,7 +2434,7 @@ PHLWORKSPACE CCompositor::createNewWorkspace(const WORKSPACEID& id, const MONITO
const auto PMONITOR = getMonitorFromID(monID); const auto PMONITOR = getMonitorFromID(monID);
if (!PMONITOR) { if (!PMONITOR) {
Debug::log(ERR, "BUG THIS: No pMonitor for new workspace in createNewWorkspace"); Log::logger->log(Log::ERR, "BUG THIS: No pMonitor for new workspace in createNewWorkspace");
return nullptr; return nullptr;
} }
@ -2682,7 +2667,7 @@ void CCompositor::checkMonitorOverlaps() {
for (const auto& m : m_monitors) { for (const auto& m : m_monitors) {
if (!monitorRegion.copy().intersect(m->logicalBox()).empty()) { if (!monitorRegion.copy().intersect(m->logicalBox()).empty()) {
Debug::log(ERR, "Monitor {}: detected overlap with layout", m->m_name); Log::logger->log(Log::ERR, "Monitor {}: detected overlap with layout", m->m_name);
g_pHyprNotificationOverlay->addNotification(I18n::i18nEngine()->localize(I18n::TXT_KEY_NOTIF_INVALID_MONITOR_LAYOUT, {{"name", m->m_name}}), CHyprColor{}, 15000, g_pHyprNotificationOverlay->addNotification(I18n::i18nEngine()->localize(I18n::TXT_KEY_NOTIF_INVALID_MONITOR_LAYOUT, {{"name", m->m_name}}), CHyprColor{}, 15000,
ICON_WARNING); ICON_WARNING);
@ -2700,14 +2685,14 @@ void CCompositor::arrangeMonitors() {
std::vector<PHLMONITOR> arranged; std::vector<PHLMONITOR> arranged;
arranged.reserve(toArrange.size()); arranged.reserve(toArrange.size());
Debug::log(LOG, "arrangeMonitors: {} to arrange", toArrange.size()); Log::logger->log(Log::DEBUG, "arrangeMonitors: {} to arrange", toArrange.size());
for (auto it = toArrange.begin(); it != toArrange.end();) { for (auto it = toArrange.begin(); it != toArrange.end();) {
auto m = *it; auto m = *it;
if (m->m_activeMonitorRule.offset != Vector2D{-INT32_MAX, -INT32_MAX}) { if (m->m_activeMonitorRule.offset != Vector2D{-INT32_MAX, -INT32_MAX}) {
// explicit. // explicit.
Debug::log(LOG, "arrangeMonitors: {} explicit {:j}", m->m_name, m->m_activeMonitorRule.offset); Log::logger->log(Log::DEBUG, "arrangeMonitors: {} explicit {:j}", m->m_name, m->m_activeMonitorRule.offset);
m->moveTo(m->m_activeMonitorRule.offset); m->moveTo(m->m_activeMonitorRule.offset);
arranged.push_back(m); arranged.push_back(m);
@ -2782,7 +2767,7 @@ void CCompositor::arrangeMonitors() {
} }
default: UNREACHABLE(); default: UNREACHABLE();
} }
Debug::log(LOG, "arrangeMonitors: {} auto {:j}", m->m_name, m->m_position); Log::logger->log(Log::DEBUG, "arrangeMonitors: {} auto {:j}", m->m_name, m->m_position);
m->moveTo(newPosition); m->moveTo(newPosition);
arranged.emplace_back(m); arranged.emplace_back(m);
} }
@ -2791,7 +2776,7 @@ void CCompositor::arrangeMonitors() {
// and set xwayland positions aka auto for all // and set xwayland positions aka auto for all
maxXOffsetRight = 0; maxXOffsetRight = 0;
for (auto const& m : m_monitors) { for (auto const& m : m_monitors) {
Debug::log(LOG, "arrangeMonitors: {} xwayland [{}, {}]", m->m_name, maxXOffsetRight, 0); Log::logger->log(Log::DEBUG, "arrangeMonitors: {} xwayland [{}, {}]", m->m_name, maxXOffsetRight, 0);
m->m_xwaylandPosition = {maxXOffsetRight, 0}; m->m_xwaylandPosition = {maxXOffsetRight, 0};
maxXOffsetRight += (*PXWLFORCESCALEZERO ? m->m_transformedSize.x : m->m_size.x); maxXOffsetRight += (*PXWLFORCESCALEZERO ? m->m_transformedSize.x : m->m_size.x);
@ -2815,7 +2800,7 @@ void CCompositor::enterUnsafeState() {
if (m_unsafeState) if (m_unsafeState)
return; return;
Debug::log(LOG, "Entering unsafe state"); Log::logger->log(Log::DEBUG, "Entering unsafe state");
if (!m_unsafeOutput->m_enabled) if (!m_unsafeOutput->m_enabled)
m_unsafeOutput->onConnect(false); m_unsafeOutput->onConnect(false);
@ -2829,7 +2814,7 @@ void CCompositor::leaveUnsafeState() {
if (!m_unsafeState) if (!m_unsafeState)
return; return;
Debug::log(LOG, "Leaving unsafe state"); Log::logger->log(Log::DEBUG, "Leaving unsafe state");
m_unsafeState = false; m_unsafeState = false;
@ -2857,7 +2842,7 @@ void CCompositor::setPreferredScaleForSurface(SP<CWLSurfaceResource> pSurface, d
const auto PSURFACE = Desktop::View::CWLSurface::fromResource(pSurface); const auto PSURFACE = Desktop::View::CWLSurface::fromResource(pSurface);
if (!PSURFACE) { if (!PSURFACE) {
Debug::log(WARN, "Orphaned CWLSurfaceResource {:x} in setPreferredScaleForSurface", rc<uintptr_t>(pSurface.get())); Log::logger->log(Log::WARN, "Orphaned CWLSurfaceResource {:x} in setPreferredScaleForSurface", rc<uintptr_t>(pSurface.get()));
return; return;
} }
@ -2870,7 +2855,7 @@ void CCompositor::setPreferredTransformForSurface(SP<CWLSurfaceResource> pSurfac
const auto PSURFACE = Desktop::View::CWLSurface::fromResource(pSurface); const auto PSURFACE = Desktop::View::CWLSurface::fromResource(pSurface);
if (!PSURFACE) { if (!PSURFACE) {
Debug::log(WARN, "Orphaned CWLSurfaceResource {:x} in setPreferredTransformForSurface", rc<uintptr_t>(pSurface.get())); Log::logger->log(Log::WARN, "Orphaned CWLSurfaceResource {:x} in setPreferredTransformForSurface", rc<uintptr_t>(pSurface.get()));
return; return;
} }
@ -2926,7 +2911,7 @@ void CCompositor::onNewMonitor(SP<Aquamarine::IOutput> output) {
output->name = "FALLBACK"; // we are allowed to do this :) output->name = "FALLBACK"; // we are allowed to do this :)
} }
Debug::log(LOG, "New output with name {}", output->name); Log::logger->log(Log::DEBUG, "New output with name {}", output->name);
PNEWMONITOR->m_name = output->name; PNEWMONITOR->m_name = output->name;
PNEWMONITOR->m_self = PNEWMONITOR; PNEWMONITOR->m_self = PNEWMONITOR;
@ -2965,24 +2950,24 @@ void CCompositor::onNewMonitor(SP<Aquamarine::IOutput> output) {
PNEWMONITOR->m_frameScheduler->onFrame(); PNEWMONITOR->m_frameScheduler->onFrame();
if (PROTO::colorManagement && shouldChangePreferredImageDescription()) { if (PROTO::colorManagement && shouldChangePreferredImageDescription()) {
Debug::log(ERR, "FIXME: color management protocol is enabled, need a preferred image description id"); Log::logger->log(Log::ERR, "FIXME: color management protocol is enabled, need a preferred image description id");
PROTO::colorManagement->onImagePreferredChanged(0); PROTO::colorManagement->onImagePreferredChanged(0);
} }
} }
SImageDescription CCompositor::getPreferredImageDescription() { SImageDescription CCompositor::getPreferredImageDescription() {
if (!PROTO::colorManagement) { if (!PROTO::colorManagement) {
Debug::log(ERR, "FIXME: color management protocol is not enabled, returning empty image description"); Log::logger->log(Log::ERR, "FIXME: color management protocol is not enabled, returning empty image description");
return SImageDescription{}; return SImageDescription{};
} }
Debug::log(WARN, "FIXME: color management protocol is enabled, determine correct preferred image description"); Log::logger->log(Log::WARN, "FIXME: color management protocol is enabled, determine correct preferred image description");
// should determine some common settings to avoid unnecessary transformations while keeping maximum displayable precision // should determine some common settings to avoid unnecessary transformations while keeping maximum displayable precision
return m_monitors.size() == 1 ? m_monitors[0]->m_imageDescription : SImageDescription{.primaries = NColorPrimaries::BT709}; return m_monitors.size() == 1 ? m_monitors[0]->m_imageDescription : SImageDescription{.primaries = NColorPrimaries::BT709};
} }
SImageDescription CCompositor::getHDRImageDescription() { SImageDescription CCompositor::getHDRImageDescription() {
if (!PROTO::colorManagement) { if (!PROTO::colorManagement) {
Debug::log(ERR, "FIXME: color management protocol is not enabled, returning empty image description"); Log::logger->log(Log::ERR, "FIXME: color management protocol is not enabled, returning empty image description");
return SImageDescription{}; return SImageDescription{};
} }
@ -3002,7 +2987,7 @@ SImageDescription CCompositor::getHDRImageDescription() {
} }
bool CCompositor::shouldChangePreferredImageDescription() { bool CCompositor::shouldChangePreferredImageDescription() {
Debug::log(WARN, "FIXME: color management protocol is enabled and outputs changed, check preferred image description changes"); Log::logger->log(Log::WARN, "FIXME: color management protocol is enabled and outputs changed, check preferred image description changes");
return false; return false;
} }
@ -3040,7 +3025,7 @@ void CCompositor::ensurePersistentWorkspacesPresent(const std::vector<SWorkspace
} }
if (id == WORKSPACE_INVALID) { if (id == WORKSPACE_INVALID) {
Debug::log(ERR, "ensurePersistentWorkspacesPresent: couldn't resolve id for workspace {}", rule.workspaceString); Log::logger->log(Log::ERR, "ensurePersistentWorkspacesPresent: couldn't resolve id for workspace {}", rule.workspaceString);
continue; continue;
} }
PWORKSPACE = getWorkspaceByID(id); PWORKSPACE = getWorkspaceByID(id);
@ -3052,7 +3037,7 @@ void CCompositor::ensurePersistentWorkspacesPresent(const std::vector<SWorkspace
} }
if (!PMONITOR) { if (!PMONITOR) {
Debug::log(ERR, "ensurePersistentWorkspacesPresent: couldn't resolve monitor for {}, skipping", rule.monitor); Log::logger->log(Log::ERR, "ensurePersistentWorkspacesPresent: couldn't resolve monitor for {}, skipping", rule.monitor);
continue; continue;
} }
@ -3064,12 +3049,12 @@ void CCompositor::ensurePersistentWorkspacesPresent(const std::vector<SWorkspace
if (PWORKSPACE) { if (PWORKSPACE) {
if (PWORKSPACE->m_monitor == PMONITOR) { if (PWORKSPACE->m_monitor == PMONITOR) {
Debug::log(LOG, "ensurePersistentWorkspacesPresent: workspace persistent {} already on {}", rule.workspaceString, PMONITOR->m_name); Log::logger->log(Log::DEBUG, "ensurePersistentWorkspacesPresent: workspace persistent {} already on {}", rule.workspaceString, PMONITOR->m_name);
continue; continue;
} }
Debug::log(LOG, "ensurePersistentWorkspacesPresent: workspace persistent {} not on {}, moving", rule.workspaceString, PMONITOR->m_name); Log::logger->log(Log::DEBUG, "ensurePersistentWorkspacesPresent: workspace persistent {} not on {}, moving", rule.workspaceString, PMONITOR->m_name);
moveWorkspaceToMonitor(PWORKSPACE, PMONITOR); moveWorkspaceToMonitor(PWORKSPACE, PMONITOR);
continue; continue;
} }

View file

@ -118,7 +118,7 @@ class CCssGapData : public ICustomConfigValueData {
break; break;
} }
default: { default: {
Debug::log(WARN, "Too many arguments provided for gaps."); Log::logger->log(Log::WARN, "Too many arguments provided for gaps.");
*this = CCssGapData(toInt(varlist[0]), toInt(varlist[1]), toInt(varlist[2]), toInt(varlist[3])); *this = CCssGapData(toInt(varlist[0]), toInt(varlist[1]), toInt(varlist[2]), toInt(varlist[3]));
break; break;
} }

View file

@ -90,7 +90,7 @@ static Hyprlang::CParseResult configHandleGradientSet(const char* VALUE, void**
try { try {
DATA->m_angle = std::stoi(std::string(var.substr(0, var.find("deg")))) * (PI / 180.0); // radians DATA->m_angle = std::stoi(std::string(var.substr(0, var.find("deg")))) * (PI / 180.0); // radians
} catch (...) { } catch (...) {
Debug::log(WARN, "Error parsing gradient {}", V); Log::logger->log(Log::WARN, "Error parsing gradient {}", V);
parseError = "Error parsing gradient " + V; parseError = "Error parsing gradient " + V;
} }
@ -98,7 +98,7 @@ static Hyprlang::CParseResult configHandleGradientSet(const char* VALUE, void**
} }
if (DATA->m_colors.size() >= 10) { if (DATA->m_colors.size() >= 10) {
Debug::log(WARN, "Error parsing gradient {}: max colors is 10.", V); Log::logger->log(Log::WARN, "Error parsing gradient {}: max colors is 10.", V);
parseError = "Error parsing gradient " + V + ": max colors is 10."; parseError = "Error parsing gradient " + V + ": max colors is 10.";
break; break;
} }
@ -109,13 +109,13 @@ static Hyprlang::CParseResult configHandleGradientSet(const char* VALUE, void**
throw std::runtime_error(std::format("failed to parse {} as a color", var)); throw std::runtime_error(std::format("failed to parse {} as a color", var));
DATA->m_colors.emplace_back(COL.value()); DATA->m_colors.emplace_back(COL.value());
} catch (std::exception& e) { } catch (std::exception& e) {
Debug::log(WARN, "Error parsing gradient {}", V); Log::logger->log(Log::WARN, "Error parsing gradient {}", V);
parseError = "Error parsing gradient " + V + ": " + e.what(); parseError = "Error parsing gradient " + V + ": " + e.what();
} }
} }
if (DATA->m_colors.empty()) { if (DATA->m_colors.empty()) {
Debug::log(WARN, "Error parsing gradient {}", V); Log::logger->log(Log::WARN, "Error parsing gradient {}", V);
if (parseError.empty()) if (parseError.empty())
parseError = "Error parsing gradient " + V + ": No colors?"; parseError = "Error parsing gradient " + V + ": No colors?";
@ -880,18 +880,16 @@ CConfigManager::CConfigManager() {
resetHLConfig(); resetHLConfig();
if (CONFIG_OPTIONS.size() != m_configValueNumber - 1 /* autogenerated is special */) if (CONFIG_OPTIONS.size() != m_configValueNumber - 1 /* autogenerated is special */)
Debug::log(LOG, "Warning: config descriptions have {} entries, but there are {} config values. This should fail tests!!", CONFIG_OPTIONS.size(), m_configValueNumber); Log::logger->log(Log::DEBUG, "Warning: config descriptions have {} entries, but there are {} config values. This should fail tests!!", CONFIG_OPTIONS.size(),
m_configValueNumber);
if (!g_pCompositor->m_onlyConfigVerification) { if (!g_pCompositor->m_onlyConfigVerification) {
Debug::log( Log::logger->log(
INFO, Log::DEBUG,
"!!!!HEY YOU, YES YOU!!!!: further logs to stdout / logfile are disabled by default. BEFORE SENDING THIS LOG, ENABLE THEM. Use debug:disable_logs = false to do so: " "!!!!HEY YOU, YES YOU!!!!: further logs to stdout / logfile are disabled by default. BEFORE SENDING THIS LOG, ENABLE THEM. Use debug:disable_logs = false to do so: "
"https://wiki.hypr.land/Configuring/Variables/#debug"); "https://wiki.hypr.land/Configuring/Variables/#debug");
} }
Debug::m_disableLogs = rc<int64_t* const*>(m_config->getConfigValuePtr("debug:disable_logs")->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}); });
} }
@ -923,14 +921,14 @@ std::optional<std::string> CConfigManager::generateConfig(std::string configPath
std::error_code ec; std::error_code ec;
bool created = std::filesystem::create_directories(parentPath, ec); bool created = std::filesystem::create_directories(parentPath, ec);
if (ec) { if (ec) {
Debug::log(ERR, "Couldn't create config home directory ({}): {}", ec.message(), parentPath); Log::logger->log(Log::ERR, "Couldn't create config home directory ({}): {}", ec.message(), parentPath);
return "Config could not be generated."; return "Config could not be generated.";
} }
if (created) if (created)
Debug::log(WARN, "Creating config home directory"); Log::logger->log(Log::WARN, "Creating config home directory");
} }
Debug::log(WARN, "No config file found; attempting to generate."); Log::logger->log(Log::WARN, "No config file found; attempting to generate.");
std::ofstream ofs; std::ofstream ofs;
ofs.open(configPath, std::ios::trunc); ofs.open(configPath, std::ios::trunc);
if (!safeMode) { if (!safeMode) {
@ -1002,7 +1000,7 @@ std::string CConfigManager::getConfigString() {
std::ifstream configFile(path); std::ifstream configFile(path);
configString += ("\n\nConfig File: " + path + ": "); configString += ("\n\nConfig File: " + path + ": ");
if (!configFile.is_open()) { if (!configFile.is_open()) {
Debug::log(LOG, "Config file not readable/found!"); Log::logger->log(Log::DEBUG, "Config file not readable/found!");
configString += "Read Failed\n"; configString += "Read Failed\n";
continue; continue;
} }
@ -1129,7 +1127,7 @@ std::optional<std::string> CConfigManager::resetHLConfig() {
// paths // paths
m_configPaths.clear(); m_configPaths.clear();
std::string mainConfigPath = getMainConfigPath(); std::string mainConfigPath = getMainConfigPath();
Debug::log(LOG, "Using config: {}", mainConfigPath); Log::logger->log(Log::DEBUG, "Using config: {}", mainConfigPath);
m_configPaths.emplace_back(mainConfigPath); m_configPaths.emplace_back(mainConfigPath);
const auto RET = verifyConfigExists(); const auto RET = verifyConfigExists();
@ -1397,11 +1395,9 @@ void CConfigManager::postConfigReload(const Hyprlang::CParseResult& result) {
g_pHyprRenderer->initiateManualCrash(); g_pHyprRenderer->initiateManualCrash();
} }
Debug::m_disableStdout = !std::any_cast<Hyprlang::INT>(m_config->getConfigValue("debug:enable_stdout_logs")); auto disableStdout = !std::any_cast<Hyprlang::INT>(m_config->getConfigValue("debug:enable_stdout_logs"));
if (Debug::m_disableStdout && m_isFirstLaunch) if (disableStdout && m_isFirstLaunch)
Debug::log(LOG, "Disabling stdout logs! Check the log for further logs."); Log::logger->log(Log::DEBUG, "Disabling stdout logs! Check the log for further logs.");
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
@ -1435,7 +1431,7 @@ void CConfigManager::postConfigReload(const Hyprlang::CParseResult& result) {
void CConfigManager::init() { void CConfigManager::init() {
g_pConfigWatcher->setOnChange([this](const CConfigWatcher::SConfigWatchEvent& e) { g_pConfigWatcher->setOnChange([this](const CConfigWatcher::SConfigWatchEvent& e) {
Debug::log(LOG, "CConfigManager: file {} modified, reloading", e.file); Log::logger->log(Log::DEBUG, "CConfigManager: file {} modified, reloading", e.file);
reload(); reload();
}); });
@ -1516,35 +1512,35 @@ SMonitorRule CConfigManager::getMonitorRuleFor(const PHLMONITOR PMONITOR) {
if (!CONFIG) if (!CONFIG)
return rule; return rule;
Debug::log(LOG, "CConfigManager::getMonitorRuleFor: found a wlr_output_manager override for {}", PMONITOR->m_name); Log::logger->log(Log::DEBUG, "CConfigManager::getMonitorRuleFor: found a wlr_output_manager override for {}", PMONITOR->m_name);
Debug::log(LOG, " > overriding enabled: {} -> {}", !rule.disabled, !CONFIG->enabled); Log::logger->log(Log::DEBUG, " > overriding enabled: {} -> {}", !rule.disabled, !CONFIG->enabled);
rule.disabled = !CONFIG->enabled; rule.disabled = !CONFIG->enabled;
if ((CONFIG->committedProperties & OUTPUT_HEAD_COMMITTED_MODE) || (CONFIG->committedProperties & OUTPUT_HEAD_COMMITTED_CUSTOM_MODE)) { if ((CONFIG->committedProperties & OUTPUT_HEAD_COMMITTED_MODE) || (CONFIG->committedProperties & OUTPUT_HEAD_COMMITTED_CUSTOM_MODE)) {
Debug::log(LOG, " > overriding mode: {:.0f}x{:.0f}@{:.2f}Hz -> {:.0f}x{:.0f}@{:.2f}Hz", rule.resolution.x, rule.resolution.y, rule.refreshRate, CONFIG->resolution.x, Log::logger->log(Log::DEBUG, " > overriding mode: {:.0f}x{:.0f}@{:.2f}Hz -> {:.0f}x{:.0f}@{:.2f}Hz", rule.resolution.x, rule.resolution.y, rule.refreshRate,
CONFIG->resolution.y, CONFIG->refresh / 1000.F); CONFIG->resolution.x, CONFIG->resolution.y, CONFIG->refresh / 1000.F);
rule.resolution = CONFIG->resolution; rule.resolution = CONFIG->resolution;
rule.refreshRate = CONFIG->refresh / 1000.F; rule.refreshRate = CONFIG->refresh / 1000.F;
} }
if (CONFIG->committedProperties & OUTPUT_HEAD_COMMITTED_POSITION) { if (CONFIG->committedProperties & OUTPUT_HEAD_COMMITTED_POSITION) {
Debug::log(LOG, " > overriding offset: {:.0f}, {:.0f} -> {:.0f}, {:.0f}", rule.offset.x, rule.offset.y, CONFIG->position.x, CONFIG->position.y); Log::logger->log(Log::DEBUG, " > overriding offset: {:.0f}, {:.0f} -> {:.0f}, {:.0f}", rule.offset.x, rule.offset.y, CONFIG->position.x, CONFIG->position.y);
rule.offset = CONFIG->position; rule.offset = CONFIG->position;
} }
if (CONFIG->committedProperties & OUTPUT_HEAD_COMMITTED_TRANSFORM) { if (CONFIG->committedProperties & OUTPUT_HEAD_COMMITTED_TRANSFORM) {
Debug::log(LOG, " > overriding transform: {} -> {}", sc<uint8_t>(rule.transform), sc<uint8_t>(CONFIG->transform)); Log::logger->log(Log::DEBUG, " > 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: {} -> {}", sc<uint8_t>(rule.scale), sc<uint8_t>(CONFIG->scale)); Log::logger->log(Log::DEBUG, " > 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); Log::logger->log(Log::DEBUG, " > overriding vrr: {} -> {}", rule.vrr.value_or(0), CONFIG->adaptiveSync);
rule.vrr = sc<int>(CONFIG->adaptiveSync); rule.vrr = sc<int>(CONFIG->adaptiveSync);
} }
@ -1557,7 +1553,7 @@ SMonitorRule CConfigManager::getMonitorRuleFor(const PHLMONITOR PMONITOR) {
} }
} }
Debug::log(WARN, "No rule found for {}, trying to use the first.", PMONITOR->m_name); Log::logger->log(Log::WARN, "No rule found for {}, trying to use the first.", PMONITOR->m_name);
for (auto const& r : m_monitorRules) { for (auto const& r : m_monitorRules) {
if (r.name.empty()) { if (r.name.empty()) {
@ -1565,7 +1561,7 @@ SMonitorRule CConfigManager::getMonitorRuleFor(const PHLMONITOR PMONITOR) {
} }
} }
Debug::log(WARN, "No rules configured. Using the default hardcoded one."); Log::logger->log(Log::WARN, "No rules configured. Using the default hardcoded one.");
return applyWlrOutputConfig(SMonitorRule{.autoDir = eAutoDirs::DIR_AUTO_RIGHT, return applyWlrOutputConfig(SMonitorRule{.autoDir = eAutoDirs::DIR_AUTO_RIGHT,
.name = "", .name = "",
@ -1767,7 +1763,7 @@ void CConfigManager::ensureVRR(PHLMONITOR pMonitor) {
m->m_output->state->setAdaptiveSync(false); m->m_output->state->setAdaptiveSync(false);
if (!m->m_state.commit()) if (!m->m_state.commit())
Debug::log(ERR, "Couldn't commit output {} in ensureVRR -> false", m->m_output->name); Log::logger->log(Log::ERR, "Couldn't commit output {} in ensureVRR -> false", m->m_output->name);
} }
m->m_vrrActive = false; m->m_vrrActive = false;
return; return;
@ -1777,12 +1773,12 @@ void CConfigManager::ensureVRR(PHLMONITOR pMonitor) {
m->m_output->state->setAdaptiveSync(true); m->m_output->state->setAdaptiveSync(true);
if (!m->m_state.test()) { if (!m->m_state.test()) {
Debug::log(LOG, "Pending output {} does not accept VRR.", m->m_output->name); Log::logger->log(Log::DEBUG, "Pending output {} does not accept VRR.", m->m_output->name);
m->m_output->state->setAdaptiveSync(false); m->m_output->state->setAdaptiveSync(false);
} }
if (!m->m_state.commit()) if (!m->m_state.commit())
Debug::log(ERR, "Couldn't commit output {} in ensureVRR -> true", m->m_output->name); Log::logger->log(Log::ERR, "Couldn't commit output {} in ensureVRR -> true", m->m_output->name);
} }
m->m_vrrActive = true; m->m_vrrActive = true;
return; return;
@ -1809,7 +1805,7 @@ void CConfigManager::ensureVRR(PHLMONITOR pMonitor) {
m->m_output->state->setAdaptiveSync(true); m->m_output->state->setAdaptiveSync(true);
if (!m->m_state.test()) { if (!m->m_state.test()) {
Debug::log(LOG, "Pending output {} does not accept VRR.", m->m_output->name); Log::logger->log(Log::DEBUG, "Pending output {} does not accept VRR.", m->m_output->name);
m->m_output->state->setAdaptiveSync(false); m->m_output->state->setAdaptiveSync(false);
} }
} }
@ -1981,7 +1977,7 @@ static bool parseModeLine(const std::string& modeline, drmModeModeInfo& mode) {
return false; return false;
if (args.size() < 10) { if (args.size() < 10) {
Debug::log(ERR, "modeline parse error: expected at least 9 arguments, got {}", args.size() - 1); Log::logger->log(Log::ERR, "modeline parse error: expected at least 9 arguments, got {}", args.size() - 1);
return false; return false;
} }
@ -2000,7 +1996,7 @@ static bool parseModeLine(const std::string& modeline, drmModeModeInfo& mode) {
mode.vtotal = std::stoi(args[argno++]); mode.vtotal = std::stoi(args[argno++]);
mode.vrefresh = mode.clock * 1000.0 * 1000.0 / mode.htotal / mode.vtotal; mode.vrefresh = mode.clock * 1000.0 * 1000.0 / mode.htotal / mode.vtotal;
} catch (const std::exception& e) { } catch (const std::exception& e) {
Debug::log(ERR, "modeline parse error: invalid numeric value: {}", e.what()); Log::logger->log(Log::ERR, "modeline parse error: invalid numeric value: {}", e.what());
return false; return false;
} }
@ -2023,7 +2019,7 @@ static bool parseModeLine(const std::string& modeline, drmModeModeInfo& mode) {
if (it != flagsmap.end()) if (it != flagsmap.end())
mode.flags |= it->second; mode.flags |= it->second;
else else
Debug::log(ERR, "Invalid flag {} in modeline", key); Log::logger->log(Log::ERR, "Invalid flag {} in modeline", key);
} }
snprintf(mode.name, sizeof(mode.name), "%dx%d@%d", mode.hdisplay, mode.vdisplay, mode.vrefresh / 1000); snprintf(mode.name, sizeof(mode.name), "%dx%d@%d", mode.hdisplay, mode.vdisplay, mode.vrefresh / 1000);
@ -2105,7 +2101,7 @@ bool CMonitorRuleParser::parsePosition(const std::string& value, bool isFirst) {
else if (value == "auto-center-down") else if (value == "auto-center-down")
m_rule.autoDir = eAutoDirs::DIR_AUTO_CENTER_DOWN; m_rule.autoDir = eAutoDirs::DIR_AUTO_CENTER_DOWN;
else { else {
Debug::log(WARN, Log::logger->log(Log::WARN,
"Invalid auto direction. Valid options are 'auto'," "Invalid auto direction. Valid options are 'auto',"
"'auto-up', 'auto-down', 'auto-left', 'auto-right'," "'auto-up', 'auto-down', 'auto-left', 'auto-right',"
"'auto-center-up', 'auto-center-down'," "'auto-center-up', 'auto-center-down',"
@ -2160,7 +2156,7 @@ bool CMonitorRuleParser::parseTransform(const std::string& value) {
const auto TSF = std::stoi(value); const auto TSF = std::stoi(value);
if (std::clamp(TSF, 0, 7) != TSF) { if (std::clamp(TSF, 0, 7) != TSF) {
Debug::log(ERR, "Invalid transform {} in monitor", TSF); Log::logger->log(Log::ERR, "Invalid transform {} in monitor", TSF);
m_error += "invalid transform "; m_error += "invalid transform ";
return false; return false;
} }
@ -2268,7 +2264,7 @@ std::optional<std::string> CConfigManager::handleMonitor(const std::string& comm
// fall // fall
} else { } else {
Debug::log(ERR, "ConfigManager parseMonitor, curitem bogus???"); Log::logger->log(Log::ERR, "ConfigManager parseMonitor, curitem bogus???");
return "parse error: curitem bogus"; return "parse error: curitem bogus";
} }
@ -2319,7 +2315,7 @@ std::optional<std::string> CConfigManager::handleMonitor(const std::string& comm
m_workspaceRules.emplace_back(wsRule); m_workspaceRules.emplace_back(wsRule);
argno++; argno++;
} else { } else {
Debug::log(ERR, "Config error: invalid monitor syntax at \"{}\"", ARGS[argno]); Log::logger->log(Log::ERR, "Config error: invalid monitor syntax at \"{}\"", ARGS[argno]);
return "invalid syntax at \"" + std::string(ARGS[argno]) + "\""; return "invalid syntax at \"" + std::string(ARGS[argno]) + "\"";
} }
@ -2536,12 +2532,12 @@ std::optional<std::string> CConfigManager::handleBind(const std::string& command
const auto DISPATCHER = g_pKeybindManager->m_dispatchers.find(HANDLER); const auto DISPATCHER = g_pKeybindManager->m_dispatchers.find(HANDLER);
if (DISPATCHER == g_pKeybindManager->m_dispatchers.end()) { if (DISPATCHER == g_pKeybindManager->m_dispatchers.end()) {
Debug::log(ERR, "Invalid dispatcher: {}", HANDLER); Log::logger->log(Log::ERR, "Invalid dispatcher: {}", HANDLER);
return "Invalid dispatcher, requested \"" + HANDLER + "\" does not exist"; return "Invalid dispatcher, requested \"" + HANDLER + "\" does not exist";
} }
if (MOD == 0 && !MODSTR.empty()) { if (MOD == 0 && !MODSTR.empty()) {
Debug::log(ERR, "Invalid mod: {}", MODSTR); Log::logger->log(Log::ERR, "Invalid mod: {}", MODSTR);
return "Invalid mod, requested mod \"" + MODSTR + "\" is not a valid mod."; return "Invalid mod, requested mod \"" + MODSTR + "\" is not a valid mod.";
} }
@ -2549,7 +2545,7 @@ std::optional<std::string> CConfigManager::handleBind(const std::string& command
SParsedKey parsedKey = parseKey(KEY); SParsedKey parsedKey = parseKey(KEY);
if (parsedKey.catchAll && m_currentSubmap.name.empty()) { if (parsedKey.catchAll && m_currentSubmap.name.empty()) {
Debug::log(ERR, "Catchall not allowed outside of submap!"); Log::logger->log(Log::ERR, "Catchall not allowed outside of submap!");
return "Invalid catchall, catchall keybinds are only allowed in submaps."; return "Invalid catchall, catchall keybinds are only allowed in submaps.";
} }
@ -2599,7 +2595,7 @@ std::optional<std::string> CConfigManager::handleWorkspaceRules(const std::strin
// auto wsIdent = removeBeginEndSpacesTabs(value.substr(FIRST_DELIM + 1, (WORKSPACE_DELIM - FIRST_DELIM - 1))); // auto wsIdent = removeBeginEndSpacesTabs(value.substr(FIRST_DELIM + 1, (WORKSPACE_DELIM - FIRST_DELIM - 1)));
// id = getWorkspaceIDFromString(wsIdent, name); // id = getWorkspaceIDFromString(wsIdent, name);
// if (id == WORKSPACE_INVALID) { // if (id == WORKSPACE_INVALID) {
// Debug::log(ERR, "Invalid workspace identifier found: {}", wsIdent); // Log::logger->log(Log::ERR, "Invalid workspace identifier found: {}", wsIdent);
// return "Invalid workspace identifier found: " + wsIdent; // return "Invalid workspace identifier found: " + wsIdent;
// } // }
// wsRule.monitor = first_ident; // wsRule.monitor = first_ident;
@ -2665,7 +2661,7 @@ std::optional<std::string> CConfigManager::handleWorkspaceRules(const std::strin
std::string opt = rule.substr(delim + 10); std::string opt = rule.substr(delim + 10);
if (!opt.contains(":")) { if (!opt.contains(":")) {
// invalid // invalid
Debug::log(ERR, "Invalid workspace rule found: {}", rule); Log::logger->log(Log::ERR, "Invalid workspace rule found: {}", rule);
return "Invalid workspace rule found: " + rule; return "Invalid workspace rule found: " + rule;
} }
@ -2709,7 +2705,7 @@ std::optional<std::string> CConfigManager::handleSubmap(const std::string&, cons
std::optional<std::string> CConfigManager::handleSource(const std::string& command, const std::string& rawpath) { std::optional<std::string> CConfigManager::handleSource(const std::string& command, const std::string& rawpath) {
if (rawpath.length() < 2) { if (rawpath.length() < 2) {
Debug::log(ERR, "source= path garbage"); Log::logger->log(Log::ERR, "source= path garbage");
return "source= path " + rawpath + " bogus!"; return "source= path " + rawpath + " bogus!";
} }
@ -2723,7 +2719,7 @@ std::optional<std::string> CConfigManager::handleSource(const std::string& comma
if (auto r = glob(absolutePath(rawpath, m_configCurrentPath).c_str(), GLOB_TILDE, nullptr, glob_buf.get()); r != 0) { if (auto r = glob(absolutePath(rawpath, m_configCurrentPath).c_str(), GLOB_TILDE, nullptr, glob_buf.get()); r != 0) {
std::string err = std::format("source= globbing error: {}", r == GLOB_NOMATCH ? "found no match" : GLOB_ABORTED ? "read error" : "out of memory"); std::string err = std::format("source= globbing error: {}", r == GLOB_NOMATCH ? "found no match" : GLOB_ABORTED ? "read error" : "out of memory");
Debug::log(ERR, "{}", err); Log::logger->log(Log::ERR, "{}", err);
return err; return err;
} }
@ -2736,7 +2732,7 @@ std::optional<std::string> CConfigManager::handleSource(const std::string& comma
auto file_status = std::filesystem::status(value, ec); auto file_status = std::filesystem::status(value, ec);
if (ec) { if (ec) {
Debug::log(ERR, "source= file from glob result is inaccessible ({}): {}", ec.message(), value); Log::logger->log(Log::ERR, "source= file from glob result is inaccessible ({}): {}", ec.message(), value);
return "source= file " + value + " is inaccessible!"; return "source= file " + value + " is inaccessible!";
} }
@ -2749,10 +2745,10 @@ std::optional<std::string> CConfigManager::handleSource(const std::string& comma
if (THISRESULT.error && errorsFromParsing.empty()) if (THISRESULT.error && errorsFromParsing.empty())
errorsFromParsing += THISRESULT.getError(); errorsFromParsing += THISRESULT.getError();
} else if (std::filesystem::is_directory(file_status)) { } else if (std::filesystem::is_directory(file_status)) {
Debug::log(WARN, "source= skipping directory {}", value); Log::logger->log(Log::WARN, "source= skipping directory {}", value);
continue; continue;
} else { } else {
Debug::log(WARN, "source= skipping non-regular-file {}", value); Log::logger->log(Log::WARN, "source= skipping non-regular-file {}", value);
continue; continue;
} }
} }
@ -3007,7 +3003,7 @@ std::string SConfigOptionDescription::jsonify() const {
[this](auto&& val) { [this](auto&& val) {
const auto PTR = g_pConfigManager->m_config->getConfigValuePtr(value.c_str()); const auto PTR = g_pConfigManager->m_config->getConfigValuePtr(value.c_str());
if (!PTR) { if (!PTR) {
Debug::log(ERR, "invalid SConfigOptionDescription: no config option {} exists", value); Log::logger->log(Log::ERR, "invalid SConfigOptionDescription: no config option {} exists", value);
return std::string{""}; return std::string{""};
} }
const char* const EXPLICIT = PTR->m_bSetByUser ? "true" : "false"; const char* const EXPLICIT = PTR->m_bSetByUser ? "true" : "false";
@ -3084,7 +3080,7 @@ std::string SConfigOptionDescription::jsonify() const {
val.gradient, currentValue, EXPLICIT); val.gradient, currentValue, EXPLICIT);
} }
} catch (std::bad_any_cast& e) { Debug::log(ERR, "Bad any_cast on value {} in descriptions", value); } } catch (std::bad_any_cast& e) { Log::logger->log(Log::ERR, "Bad any_cast on value {} in descriptions", value); }
return std::string{""}; return std::string{""};
}, },
data); data);
@ -3109,7 +3105,7 @@ void CConfigManager::ensurePersistentWorkspacesPresent() {
} }
void CConfigManager::storeFloatingSize(PHLWINDOW window, const Vector2D& size) { void CConfigManager::storeFloatingSize(PHLWINDOW window, const Vector2D& size) {
Debug::log(LOG, "storing floating size {}x{} for window {}::{}", size.x, size.y, window->m_initialClass, window->m_initialTitle); Log::logger->log(Log::DEBUG, "storing floating size {}x{} for window {}::{}", size.x, size.y, window->m_initialClass, window->m_initialTitle);
// true -> use m_initialClass and m_initialTitle // true -> use m_initialClass and m_initialTitle
SFloatCache id{window, true}; SFloatCache id{window, true};
m_mStoredFloatingSizes[id] = size; m_mStoredFloatingSizes[id] = size;
@ -3120,9 +3116,9 @@ std::optional<Vector2D> CConfigManager::getStoredFloatingSize(PHLWINDOW window)
// and m_class and m_title are just "initial" ones. // and m_class and m_title are just "initial" ones.
// false -> use m_class and m_title // false -> use m_class and m_title
SFloatCache id{window, false}; SFloatCache id{window, false};
Debug::log(LOG, "Hash for window {}::{} = {}", window->m_class, window->m_title, id.hash); Log::logger->log(Log::DEBUG, "Hash for window {}::{} = {}", window->m_class, window->m_title, id.hash);
if (m_mStoredFloatingSizes.contains(id)) { if (m_mStoredFloatingSizes.contains(id)) {
Debug::log(LOG, "got stored size {}x{} for window {}::{}", m_mStoredFloatingSizes[id].x, m_mStoredFloatingSizes[id].y, window->m_class, window->m_title); Log::logger->log(Log::DEBUG, "got stored size {}x{} for window {}::{}", m_mStoredFloatingSizes[id].x, m_mStoredFloatingSizes[id].y, window->m_class, window->m_title);
return m_mStoredFloatingSizes[id]; return m_mStoredFloatingSizes[id];
} }
return std::nullopt; return std::nullopt;

View file

@ -3,7 +3,7 @@
#include <linux/limits.h> #include <linux/limits.h>
#endif #endif
#include <sys/inotify.h> #include <sys/inotify.h>
#include "../debug/Log.hpp" #include "../debug/log/Logger.hpp"
#include <ranges> #include <ranges>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
@ -13,14 +13,14 @@ using namespace Hyprutils::OS;
CConfigWatcher::CConfigWatcher() : m_inotifyFd(inotify_init()) { CConfigWatcher::CConfigWatcher() : m_inotifyFd(inotify_init()) {
if (!m_inotifyFd.isValid()) { if (!m_inotifyFd.isValid()) {
Debug::log(ERR, "CConfigWatcher couldn't open an inotify node. Config will not be automatically reloaded"); Log::logger->log(Log::ERR, "CConfigWatcher couldn't open an inotify node. Config will not be automatically reloaded");
return; return;
} }
// TODO: make CFileDescriptor take F_GETFL, F_SETFL // TODO: make CFileDescriptor take F_GETFL, F_SETFL
const int FLAGS = fcntl(m_inotifyFd.get(), F_GETFL, 0); const int FLAGS = fcntl(m_inotifyFd.get(), F_GETFL, 0);
if (fcntl(m_inotifyFd.get(), F_SETFL, FLAGS | O_NONBLOCK) < 0) { if (fcntl(m_inotifyFd.get(), F_SETFL, FLAGS | O_NONBLOCK) < 0) {
Debug::log(ERR, "CConfigWatcher couldn't non-block inotify node. Config will not be automatically reloaded"); Log::logger->log(Log::ERR, "CConfigWatcher couldn't non-block inotify node. Config will not be automatically reloaded");
m_inotifyFd.reset(); m_inotifyFd.reset();
return; return;
} }
@ -78,19 +78,19 @@ void CConfigWatcher::onInotifyEvent() {
const auto* ev = rc<const inotify_event*>(buffer.data() + offset); const auto* ev = rc<const inotify_event*>(buffer.data() + offset);
if (offset + sizeof(inotify_event) > sc<size_t>(bytesRead)) { if (offset + sizeof(inotify_event) > sc<size_t>(bytesRead)) {
Debug::log(ERR, "CConfigWatcher: malformed inotify event, truncated header"); Log::logger->log(Log::ERR, "CConfigWatcher: malformed inotify event, truncated header");
break; break;
} }
if (offset + sizeof(inotify_event) + ev->len > sc<size_t>(bytesRead)) { if (offset + sizeof(inotify_event) + ev->len > sc<size_t>(bytesRead)) {
Debug::log(ERR, "CConfigWatcher: malformed inotify event, truncated name field"); Log::logger->log(Log::ERR, "CConfigWatcher: malformed inotify event, truncated name field");
break; break;
} }
const auto WD = std::ranges::find_if(m_watches, [wd = ev->wd](const auto& e) { return e.wd == wd; }); const auto WD = std::ranges::find_if(m_watches, [wd = ev->wd](const auto& e) { return e.wd == wd; });
if (WD == m_watches.end()) if (WD == m_watches.end())
Debug::log(ERR, "CConfigWatcher: got an event for wd {} which we don't have?!", ev->wd); Log::logger->log(Log::ERR, "CConfigWatcher: got an event for wd {} which we don't have?!", ev->wd);
else else
m_watchCallback(SConfigWatchEvent{ m_watchCallback(SConfigWatchEvent{
.file = WD->file, .file = WD->file,

View file

@ -40,7 +40,7 @@ using namespace Hyprutils::OS;
#include "../devices/ITouch.hpp" #include "../devices/ITouch.hpp"
#include "../devices/Tablet.hpp" #include "../devices/Tablet.hpp"
#include "../protocols/GlobalShortcuts.hpp" #include "../protocols/GlobalShortcuts.hpp"
#include "debug/RollingLogFollow.hpp" #include "debug/log/RollingLogFollow.hpp"
#include "config/ConfigManager.hpp" #include "config/ConfigManager.hpp"
#include "helpers/MiscFunctions.hpp" #include "helpers/MiscFunctions.hpp"
#include "../desktop/view/LayerSurface.hpp" #include "../desktop/view/LayerSurface.hpp"
@ -957,11 +957,10 @@ static std::string rollinglogRequest(eHyprCtlOutputFormat format, std::string re
if (format == eHyprCtlOutputFormat::FORMAT_JSON) { if (format == eHyprCtlOutputFormat::FORMAT_JSON) {
result += "[\n\"log\":\""; result += "[\n\"log\":\"";
result += escapeJSONStrings(Debug::m_rollingLog); result += escapeJSONStrings(Log::logger->rolling());
result += "\"]"; result += "\"]";
} else { } else
result = Debug::m_rollingLog; result = Log::logger->rolling();
}
return result; return result;
} }
@ -1260,7 +1259,7 @@ static std::string dispatchRequest(eHyprCtlOutputFormat format, std::string in)
SDispatchResult res = DISPATCHER->second(DISPATCHARG); SDispatchResult res = DISPATCHER->second(DISPATCHARG);
Debug::log(LOG, "Hyprctl: dispatcher {} : {}{}", DISPATCHSTR, DISPATCHARG, res.success ? "" : " -> " + res.error); Log::logger->log(Log::DEBUG, "Hyprctl: dispatcher {} : {}{}", DISPATCHSTR, DISPATCHARG, res.success ? "" : " -> " + res.error);
return res.success ? "ok" : res.error; return res.success ? "ok" : res.error;
} }
@ -1340,7 +1339,7 @@ static std::string dispatchKeyword(eHyprCtlOutputFormat format, std::string in)
if (COMMAND.contains("workspace")) if (COMMAND.contains("workspace"))
g_pConfigManager->ensurePersistentWorkspacesPresent(); g_pConfigManager->ensurePersistentWorkspacesPresent();
Debug::log(LOG, "Hyprctl: keyword {} : {}", COMMAND, VALUE); Log::logger->log(Log::DEBUG, "Hyprctl: keyword {} : {}", COMMAND, VALUE);
if (retval.empty()) if (retval.empty())
return "ok"; return "ok";
@ -2223,23 +2222,23 @@ static bool successWrite(int fd, const std::string& data, bool needLog = true) {
return true; return true;
if (needLog) if (needLog)
Debug::log(ERR, "Couldn't write to socket. Error: " + std::string(strerror(errno))); Log::logger->log(Log::ERR, "Couldn't write to socket. Error: " + std::string(strerror(errno)));
return false; return false;
} }
static void runWritingDebugLogThread(const int conn) { static void runWritingDebugLogThread(const int conn) {
using namespace std::chrono_literals; using namespace std::chrono_literals;
Debug::log(LOG, "In followlog thread, got connection, start writing: {}", conn); Log::logger->log(Log::DEBUG, "In followlog thread, got connection, start writing: {}", conn);
//will be finished, when reading side close connection //will be finished, when reading side close connection
std::thread([conn]() { std::thread([conn]() {
while (Debug::SRollingLogFollow::get().isRunning()) { while (Log::SRollingLogFollow::get().isRunning()) {
if (Debug::SRollingLogFollow::get().isEmpty(conn)) { if (Log::SRollingLogFollow::get().isEmpty(conn)) {
std::this_thread::sleep_for(1000ms); std::this_thread::sleep_for(1000ms);
continue; continue;
} }
auto line = Debug::SRollingLogFollow::get().getLog(conn); auto line = Log::SRollingLogFollow::get().getLog(conn);
if (!successWrite(conn, line)) if (!successWrite(conn, line))
// We cannot write, when connection is closed. So thread will successfully exit by itself // We cannot write, when connection is closed. So thread will successfully exit by itself
break; break;
@ -2247,7 +2246,7 @@ static void runWritingDebugLogThread(const int conn) {
std::this_thread::sleep_for(100ms); std::this_thread::sleep_for(100ms);
} }
close(conn); close(conn);
Debug::SRollingLogFollow::get().stopFor(conn); Log::SRollingLogFollow::get().stopFor(conn);
}).detach(); }).detach();
} }
@ -2273,10 +2272,10 @@ static int hyprCtlFDTick(int fd, uint32_t mask, void* data) {
CRED_T creds; CRED_T creds;
uint32_t len = sizeof(creds); uint32_t len = sizeof(creds);
if (getsockopt(ACCEPTEDCONNECTION, CRED_LVL, CRED_OPT, &creds, &len) == -1) if (getsockopt(ACCEPTEDCONNECTION, CRED_LVL, CRED_OPT, &creds, &len) == -1)
Debug::log(ERR, "Hyprctl: failed to get peer creds"); Log::logger->log(Log::ERR, "Hyprctl: failed to get peer creds");
else { else {
g_pHyprCtl->m_currentRequestParams.pid = creds.CRED_PID; g_pHyprCtl->m_currentRequestParams.pid = creds.CRED_PID;
Debug::log(LOG, "Hyprctl: new connection from pid {}", creds.CRED_PID); Log::logger->log(Log::DEBUG, "Hyprctl: new connection from pid {}", creds.CRED_PID);
} }
// //
@ -2311,7 +2310,7 @@ static int hyprCtlFDTick(int fd, uint32_t mask, void* data) {
try { try {
reply = g_pHyprCtl->getReply(request); reply = g_pHyprCtl->getReply(request);
} catch (std::exception& e) { } catch (std::exception& e) {
Debug::log(ERR, "Error in request: {}", e.what()); Log::logger->log(Log::ERR, "Error in request: {}", e.what());
reply = "Err: " + std::string(e.what()); reply = "Err: " + std::string(e.what());
} }
@ -2331,10 +2330,10 @@ static int hyprCtlFDTick(int fd, uint32_t mask, void* data) {
successWrite(ACCEPTEDCONNECTION, reply); successWrite(ACCEPTEDCONNECTION, reply);
if (isFollowUpRollingLogRequest(request)) { if (isFollowUpRollingLogRequest(request)) {
Debug::log(LOG, "Followup rollinglog request received. Starting thread to write to socket."); Log::logger->log(Log::DEBUG, "Followup rollinglog request received. Starting thread to write to socket.");
Debug::SRollingLogFollow::get().startFor(ACCEPTEDCONNECTION); Log::SRollingLogFollow::get().startFor(ACCEPTEDCONNECTION);
runWritingDebugLogThread(ACCEPTEDCONNECTION); runWritingDebugLogThread(ACCEPTEDCONNECTION);
Debug::log(LOG, Debug::SRollingLogFollow::get().debugInfo()); Log::logger->log(Log::DEBUG, Log::SRollingLogFollow::get().debugInfo());
} else } else
close(ACCEPTEDCONNECTION); close(ACCEPTEDCONNECTION);
@ -2351,7 +2350,7 @@ void CHyprCtl::startHyprCtlSocket() {
m_socketFD = CFileDescriptor{socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0)}; m_socketFD = CFileDescriptor{socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0)};
if (!m_socketFD.isValid()) { if (!m_socketFD.isValid()) {
Debug::log(ERR, "Couldn't start the Hyprland Socket. (1) IPC will not work."); Log::logger->log(Log::ERR, "Couldn't start the Hyprland Socket. (1) IPC will not work.");
return; return;
} }
@ -2362,14 +2361,14 @@ 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(), rc<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."); Log::logger->log(Log::ERR, "Couldn't start the Hyprland Socket. (2) IPC will not work.");
return; return;
} }
// 10 max queued. // 10 max queued.
listen(m_socketFD.get(), 10); listen(m_socketFD.get(), 10);
Debug::log(LOG, "Hypr socket started at {}", m_socketPath); Log::logger->log(Log::DEBUG, "Hypr socket started at {}", m_socketPath);
m_eventSource = wl_event_loop_add_fd(g_pCompositor->m_wlEventLoop, m_socketFD.get(), WL_EVENT_READABLE, hyprCtlFDTick, nullptr); m_eventSource = wl_event_loop_add_fd(g_pCompositor->m_wlEventLoop, m_socketFD.get(), WL_EVENT_READABLE, hyprCtlFDTick, nullptr);
} }

View file

@ -1,78 +0,0 @@
#include "Log.hpp"
#include "../defines.hpp"
#include "RollingLogFollow.hpp"
#include <fstream>
#include <print>
#include <fcntl.h>
void Debug::init(const std::string& IS) {
m_logFile = IS + (ISDEBUG ? "/hyprlandd.log" : "/hyprland.log");
m_logOfs.open(m_logFile, std::ios::out | std::ios::app);
auto handle = m_logOfs.native_handle();
fcntl(handle, F_SETFD, FD_CLOEXEC);
}
void Debug::close() {
m_logOfs.close();
}
void Debug::log(eLogLevel level, std::string str) {
if (level == TRACE && !m_trace)
return;
if (m_shuttingDown)
return;
std::lock_guard<std::mutex> guard(m_logMutex);
std::string coloredStr = str;
//NOLINTBEGIN
switch (level) {
case LOG:
str = "[LOG] " + str;
coloredStr = str;
break;
case WARN:
str = "[WARN] " + str;
coloredStr = "\033[1;33m" + str + "\033[0m"; // yellow
break;
case ERR:
str = "[ERR] " + str;
coloredStr = "\033[1;31m" + str + "\033[0m"; // red
break;
case CRIT:
str = "[CRITICAL] " + str;
coloredStr = "\033[1;35m" + str + "\033[0m"; // magenta
break;
case INFO:
str = "[INFO] " + str;
coloredStr = "\033[1;32m" + str + "\033[0m"; // green
break;
case TRACE:
str = "[TRACE] " + str;
coloredStr = "\033[1;34m" + str + "\033[0m"; // blue
break;
default: break;
}
//NOLINTEND
m_rollingLog += str + "\n";
if (m_rollingLog.size() > ROLLING_LOG_SIZE)
m_rollingLog = m_rollingLog.substr(m_rollingLog.size() - ROLLING_LOG_SIZE);
if (SRollingLogFollow::get().isRunning())
SRollingLogFollow::get().addLog(str);
if (!m_disableLogs || !**m_disableLogs) {
// log to a file
m_logOfs << str << "\n";
m_logOfs.flush();
}
// log it to the stdout too.
if (!m_disableStdout) {
std::println("{}", ((m_coloredLogs && !**m_coloredLogs) ? str : coloredStr));
std::fflush(stdout);
}
}

View file

@ -1,75 +0,0 @@
#pragma once
#include <string>
#include <format>
#include <iostream>
#include <fstream>
#include <chrono>
#include <mutex>
#define LOGMESSAGESIZE 1024
#define ROLLING_LOG_SIZE 4096
enum eLogLevel : int8_t {
NONE = -1,
LOG = 0,
WARN,
ERR,
CRIT,
INFO,
TRACE
};
// NOLINTNEXTLINE(readability-identifier-naming)
namespace Debug {
inline std::string m_logFile;
inline std::ofstream m_logOfs;
inline int64_t* const* m_disableLogs = nullptr;
inline int64_t* const* m_disableTime = nullptr;
inline bool m_disableStdout = false;
inline bool m_trace = false;
inline bool m_shuttingDown = false;
inline int64_t* const* m_coloredLogs = nullptr;
inline std::string m_rollingLog = ""; // rolling log contains the ROLLING_LOG_SIZE tail of the log
inline std::mutex m_logMutex;
void init(const std::string& IS);
void close();
//
void log(eLogLevel level, std::string str);
template <typename... Args>
//NOLINTNEXTLINE
void log(eLogLevel level, std::format_string<Args...> fmt, Args&&... args) {
if (level == TRACE && !m_trace)
return;
if (m_shuttingDown)
return;
std::string logMsg = "";
// print date and time to the ofs
if (m_disableTime && !**m_disableTime) {
#ifndef _LIBCPP_VERSION
static auto current_zone = std::chrono::current_zone();
const auto zt = std::chrono::zoned_time{current_zone, std::chrono::system_clock::now()};
const auto hms = std::chrono::hh_mm_ss{zt.get_local_time() - std::chrono::floor<std::chrono::days>(zt.get_local_time())};
#else
// TODO: current clang 17 does not support `zoned_time`, remove this once clang 19 is ready
const auto hms = std::chrono::hh_mm_ss{std::chrono::system_clock::now() - std::chrono::floor<std::chrono::days>(std::chrono::system_clock::now())};
#endif
logMsg += std::format("[{}] ", hms);
}
// no need for try {} catch {} because std::format_string<Args...> ensures that vformat never throw std::format_error
// because
// 1. any faulty format specifier that sucks will cause a compilation error.
// 2. and `std::bad_alloc` is catastrophic, (Almost any operation in stdlib could throw this.)
// 3. this is actually what std::format in stdlib does
logMsg += std::vformat(fmt.get(), std::make_format_args(args...));
log(level, logMsg);
}
};

View file

@ -2,7 +2,7 @@
#ifdef USE_TRACY_GPU #ifdef USE_TRACY_GPU
#include "Log.hpp" #include "log/Logger.hpp"
#include <GL/gl.h> #include <GL/gl.h>
#include <GLES2/gl2ext.h> #include <GLES2/gl2ext.h>

View file

@ -248,5 +248,5 @@ void CrashReporter::createAndSaveCrash(int sig) {
finalCrashReport += "\n\nLog tail:\n"; finalCrashReport += "\n\nLog tail:\n";
finalCrashReport += std::string_view(Debug::m_rollingLog).substr(Debug::m_rollingLog.find('\n') + 1); finalCrashReport += Log::logger->rolling();
} }

64
src/debug/log/Logger.cpp Normal file
View file

@ -0,0 +1,64 @@
#include "Logger.hpp"
#include "RollingLogFollow.hpp"
#include "../../defines.hpp"
#include "../../managers/HookSystemManager.hpp"
#include "../../config/ConfigValue.hpp"
using namespace Log;
CLogger::CLogger() {
const auto IS_TRACE = Env::isTrace();
m_logger.setLogLevel(IS_TRACE ? Hyprutils::CLI::LOG_TRACE : Hyprutils::CLI::LOG_DEBUG);
}
void CLogger::log(Hyprutils::CLI::eLogLevel level, const std::string_view& str) {
static bool TRACE = Env::isTrace();
if (!m_logsEnabled)
return;
if (level == Hyprutils::CLI::LOG_TRACE && !TRACE)
return;
if (SRollingLogFollow::get().isRunning())
SRollingLogFollow::get().addLog(str);
m_logger.log(level, str);
}
void CLogger::initIS(const std::string_view& IS) {
// NOLINTNEXTLINE
m_logger.setOutputFile(std::string{IS} + (ISDEBUG ? "/hyprlandd.log" : "/hyprland.log"));
m_logger.setEnableRolling(true);
m_logger.setEnableColor(false);
m_logger.setEnableStdout(true);
m_logger.setTime(false);
}
void CLogger::initCallbacks() {
static auto P = g_pHookSystem->hookDynamic("configReloaded", [this](void* hk, SCallbackInfo& info, std::any param) { recheckCfg(); });
recheckCfg();
}
void CLogger::recheckCfg() {
static auto PDISABLELOGS = CConfigValue<Hyprlang::INT>("debug:disable_logs");
static auto PDISABLETIME = CConfigValue<Hyprlang::INT>("debug:disable_time");
static auto PENABLESTDOUT = CConfigValue<Hyprlang::INT>("debug:enable_stdout_logs");
static auto PENABLECOLOR = CConfigValue<Hyprlang::INT>("debug:colored_stdout_logs");
m_logger.setEnableStdout(!*PDISABLELOGS && *PENABLESTDOUT);
m_logsEnabled = !*PDISABLELOGS;
m_logger.setTime(!*PDISABLETIME);
m_logger.setEnableColor(*PENABLECOLOR);
}
const std::string& CLogger::rolling() {
return m_logger.rollingLog();
}
Hyprutils::CLI::CLogger& CLogger::hu() {
return m_logger;
}

61
src/debug/log/Logger.hpp Normal file
View file

@ -0,0 +1,61 @@
#pragma once
#include <hyprutils/cli/Logger.hpp>
#include "../../helpers/memory/Memory.hpp"
#include "../../helpers/env/Env.hpp"
namespace Log {
class CLogger {
public:
CLogger();
~CLogger() = default;
void initIS(const std::string_view& IS);
void initCallbacks();
void log(Hyprutils::CLI::eLogLevel level, const std::string_view& str);
template <typename... Args>
//NOLINTNEXTLINE
void log(Hyprutils::CLI::eLogLevel level, std::format_string<Args...> fmt, Args&&... args) {
static bool TRACE = Env::isTrace();
if (!m_logsEnabled)
return;
if (level == Hyprutils::CLI::LOG_TRACE && !TRACE)
return;
std::string logMsg = "";
// no need for try {} catch {} because std::format_string<Args...> ensures that vformat never throw std::format_error
// because
// 1. any faulty format specifier that sucks will cause a compilation error.
// 2. and `std::bad_alloc` is catastrophic, (Almost any operation in stdlib could throw this.)
// 3. this is actually what std::format in stdlib does
logMsg += std::vformat(fmt.get(), std::make_format_args(args...));
log(level, logMsg);
}
const std::string& rolling();
Hyprutils::CLI::CLogger& hu();
private:
void recheckCfg();
Hyprutils::CLI::CLogger m_logger;
bool m_logsEnabled = true;
};
inline UP<CLogger> logger = makeUnique<CLogger>();
//
inline constexpr const Hyprutils::CLI::eLogLevel DEBUG = Hyprutils::CLI::LOG_DEBUG;
inline constexpr const Hyprutils::CLI::eLogLevel WARN = Hyprutils::CLI::LOG_WARN;
inline constexpr const Hyprutils::CLI::eLogLevel ERR = Hyprutils::CLI::LOG_ERR;
inline constexpr const Hyprutils::CLI::eLogLevel CRIT = Hyprutils::CLI::LOG_CRIT;
inline constexpr const Hyprutils::CLI::eLogLevel INFO = Hyprutils::CLI::LOG_DEBUG;
inline constexpr const Hyprutils::CLI::eLogLevel TRACE = Hyprutils::CLI::LOG_TRACE;
};

View file

@ -1,9 +1,11 @@
#pragma once #pragma once
#include <shared_mutex> #include <shared_mutex>
#include <unordered_map>
#include <format>
#include <vector>
// NOLINTNEXTLINE(readability-identifier-naming) namespace Log {
namespace Debug {
struct SRollingLogFollow { struct SRollingLogFollow {
std::unordered_map<int, std::string> m_socketToRollingLogFollowQueue; std::unordered_map<int, std::string> m_socketToRollingLogFollowQueue;
std::shared_mutex m_mutex; std::shared_mutex m_mutex;
@ -30,12 +32,14 @@ namespace Debug {
return ret; return ret;
}; };
void addLog(const std::string& log) { void addLog(const std::string_view& log) {
std::unique_lock<std::shared_mutex> w(m_mutex); std::unique_lock<std::shared_mutex> w(m_mutex);
m_running = true; m_running = true;
std::vector<int> to_erase; std::vector<int> to_erase;
for (const auto& p : m_socketToRollingLogFollowQueue) for (const auto& p : m_socketToRollingLogFollowQueue) {
m_socketToRollingLogFollowQueue[p.first] += log + "\n"; m_socketToRollingLogFollowQueue[p.first] += log;
m_socketToRollingLogFollowQueue[p.first] += "\n";
}
} }
bool isRunning() { bool isRunning() {

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "includes.hpp" #include "includes.hpp"
#include "debug/Log.hpp" #include "debug/log/Logger.hpp"
#include "helpers/Color.hpp" #include "helpers/Color.hpp"
#include "macros.hpp" #include "macros.hpp"
#include "desktop/DesktopTypes.hpp" #include "desktop/DesktopTypes.hpp"

View file

@ -60,7 +60,7 @@ SWorkspaceIDName CWorkspace::getPrevWorkspaceIDName() const {
} }
CWorkspace::~CWorkspace() { CWorkspace::~CWorkspace() {
Debug::log(LOG, "Destroying workspace ID {}", m_id); Log::logger->log(Log::DEBUG, "Destroying workspace ID {}", m_id);
// check if g_pHookSystem and g_pEventManager exist, they might be destroyed as in when the compositor is closing. // check if g_pHookSystem and g_pEventManager exist, they might be destroyed as in when the compositor is closing.
if (g_pHookSystem) if (g_pHookSystem)
@ -90,7 +90,7 @@ void CWorkspace::rememberPrevWorkspace(const PHLWORKSPACE& prev) {
} }
if (prev->m_id == m_id) { if (prev->m_id == m_id) {
Debug::log(LOG, "Tried to set prev workspace to the same as current one"); Log::logger->log(Log::DEBUG, "Tried to set prev workspace to the same as current one");
return; return;
} }
@ -156,14 +156,14 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
if (cur == 'r') { if (cur == 'r') {
WORKSPACEID from = 0, to = 0; WORKSPACEID from = 0, to = 0;
if (!prop.starts_with("r[") || !prop.ends_with("]")) { if (!prop.starts_with("r[") || !prop.ends_with("]")) {
Debug::log(LOG, "Invalid selector {}", selector); Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
return false; return false;
} }
prop = prop.substr(2, prop.length() - 3); prop = prop.substr(2, prop.length() - 3);
if (!prop.contains("-")) { if (!prop.contains("-")) {
Debug::log(LOG, "Invalid selector {}", selector); Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
return false; return false;
} }
@ -171,7 +171,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
const auto LHS = prop.substr(0, DASHPOS), RHS = prop.substr(DASHPOS + 1); const auto LHS = prop.substr(0, DASHPOS), RHS = prop.substr(DASHPOS + 1);
if (!isNumber(LHS) || !isNumber(RHS)) { if (!isNumber(LHS) || !isNumber(RHS)) {
Debug::log(LOG, "Invalid selector {}", selector); Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
return false; return false;
} }
@ -179,12 +179,12 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
from = std::stoll(LHS); from = std::stoll(LHS);
to = std::stoll(RHS); to = std::stoll(RHS);
} catch (std::exception& e) { } catch (std::exception& e) {
Debug::log(LOG, "Invalid selector {}", selector); Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
return false; return false;
} }
if (to < from || to < 1 || from < 1) { if (to < from || to < 1 || from < 1) {
Debug::log(LOG, "Invalid selector {}", selector); Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
return false; return false;
} }
@ -195,7 +195,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
if (cur == 's') { if (cur == 's') {
if (!prop.starts_with("s[") || !prop.ends_with("]")) { if (!prop.starts_with("s[") || !prop.ends_with("]")) {
Debug::log(LOG, "Invalid selector {}", selector); Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
return false; return false;
} }
@ -210,7 +210,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
if (cur == 'm') { if (cur == 'm') {
if (!prop.starts_with("m[") || !prop.ends_with("]")) { if (!prop.starts_with("m[") || !prop.ends_with("]")) {
Debug::log(LOG, "Invalid selector {}", selector); Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
return false; return false;
} }
@ -225,7 +225,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
if (cur == 'n') { if (cur == 'n') {
if (!prop.starts_with("n[") || !prop.ends_with("]")) { if (!prop.starts_with("n[") || !prop.ends_with("]")) {
Debug::log(LOG, "Invalid selector {}", selector); Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
return false; return false;
} }
@ -246,7 +246,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
if (cur == 'w') { if (cur == 'w') {
WORKSPACEID from = 0, to = 0; WORKSPACEID from = 0, to = 0;
if (!prop.starts_with("w[") || !prop.ends_with("]")) { if (!prop.starts_with("w[") || !prop.ends_with("]")) {
Debug::log(LOG, "Invalid selector {}", selector); Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
return false; return false;
} }
@ -284,14 +284,14 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
// try single // try single
if (!isNumber(prop)) { if (!isNumber(prop)) {
Debug::log(LOG, "Invalid selector {}", selector); Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
return false; return false;
} }
try { try {
from = std::stoll(prop); from = std::stoll(prop);
} catch (std::exception& e) { } catch (std::exception& e) {
Debug::log(LOG, "Invalid selector {}", selector); Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
return false; return false;
} }
@ -314,7 +314,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
const auto LHS = prop.substr(0, DASHPOS), RHS = prop.substr(DASHPOS + 1); const auto LHS = prop.substr(0, DASHPOS), RHS = prop.substr(DASHPOS + 1);
if (!isNumber(LHS) || !isNumber(RHS)) { if (!isNumber(LHS) || !isNumber(RHS)) {
Debug::log(LOG, "Invalid selector {}", selector); Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
return false; return false;
} }
@ -322,12 +322,12 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
from = std::stoll(LHS); from = std::stoll(LHS);
to = std::stoll(RHS); to = std::stoll(RHS);
} catch (std::exception& e) { } catch (std::exception& e) {
Debug::log(LOG, "Invalid selector {}", selector); Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
return false; return false;
} }
if (to < from || to < 1 || from < 1) { if (to < from || to < 1 || from < 1) {
Debug::log(LOG, "Invalid selector {}", selector); Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
return false; return false;
} }
@ -348,7 +348,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
if (cur == 'f') { if (cur == 'f') {
if (!prop.starts_with("f[") || !prop.ends_with("]")) { if (!prop.starts_with("f[") || !prop.ends_with("]")) {
Debug::log(LOG, "Invalid selector {}", selector); Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
return false; return false;
} }
@ -357,7 +357,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
try { try {
FSSTATE = std::stoi(prop); FSSTATE = std::stoi(prop);
} catch (std::exception& e) { } catch (std::exception& e) {
Debug::log(LOG, "Invalid selector {}", selector); Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
return false; return false;
} }
@ -379,7 +379,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
continue; continue;
} }
Debug::log(LOG, "Invalid selector {}", selector); Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
return false; return false;
} }
@ -522,7 +522,7 @@ void CWorkspace::rename(const std::string& name) {
if (g_pCompositor->isWorkspaceSpecial(m_id)) if (g_pCompositor->isWorkspaceSpecial(m_id))
return; return;
Debug::log(LOG, "CWorkspace::rename: Renaming workspace {} to '{}'", m_id, name); Log::logger->log(Log::DEBUG, "CWorkspace::rename: Renaming workspace {} to '{}'", m_id, name);
m_name = name; m_name = name;
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(m_self.lock()); const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(m_self.lock());

View file

@ -1,5 +1,5 @@
#include "Rule.hpp" #include "Rule.hpp"
#include "../../debug/Log.hpp" #include "../../debug/log/Logger.hpp"
#include <re2/re2.h> #include <re2/re2.h>
#include "matchEngine/RegexMatchEngine.hpp" #include "matchEngine/RegexMatchEngine.hpp"
@ -84,7 +84,7 @@ IRule::IRule(const std::string& name) : m_name(name) {
void IRule::registerMatch(eRuleProperty p, const std::string& s) { void IRule::registerMatch(eRuleProperty p, const std::string& s) {
if (!RULE_ENGINES.contains(p)) { if (!RULE_ENGINES.contains(p)) {
Debug::log(ERR, "BUG THIS: IRule: RULE_ENGINES does not contain rule idx {}", sc<std::underlying_type_t<eRuleProperty>>(p)); Log::logger->log(Log::ERR, "BUG THIS: IRule: RULE_ENGINES does not contain rule idx {}", sc<std::underlying_type_t<eRuleProperty>>(p));
return; return;
} }

View file

@ -1,5 +1,5 @@
#include "LayerRule.hpp" #include "LayerRule.hpp"
#include "../../../debug/Log.hpp" #include "../../../debug/log/Logger.hpp"
#include "../../view/LayerSurface.hpp" #include "../../view/LayerSurface.hpp"
using namespace Desktop; using namespace Desktop;
@ -28,7 +28,7 @@ bool CLayerRule::matches(PHLLS ls) {
for (const auto& [prop, engine] : m_matchEngines) { for (const auto& [prop, engine] : m_matchEngines) {
switch (prop) { switch (prop) {
default: { default: {
Debug::log(TRACE, "CLayerRule::matches: skipping prop entry {}", sc<std::underlying_type_t<eRuleProperty>>(prop)); Log::logger->log(Log::TRACE, "CLayerRule::matches: skipping prop entry {}", sc<std::underlying_type_t<eRuleProperty>>(prop));
break; break;
} }

View file

@ -38,7 +38,7 @@ void CLayerRuleApplicator::applyDynamicRule(const SP<CLayerRule>& rule) {
for (const auto& [key, effect] : rule->effects()) { for (const auto& [key, effect] : rule->effects()) {
switch (key) { switch (key) {
case LAYER_RULE_EFFECT_NONE: { case LAYER_RULE_EFFECT_NONE: {
Debug::log(ERR, "CLayerRuleApplicator::applyDynamicRule: BUG THIS: LAYER_RULE_EFFECT_NONE??"); Log::logger->log(Log::ERR, "CLayerRuleApplicator::applyDynamicRule: BUG THIS: LAYER_RULE_EFFECT_NONE??");
break; break;
} }
case LAYER_RULE_EFFECT_NO_ANIM: { case LAYER_RULE_EFFECT_NO_ANIM: {
@ -75,21 +75,21 @@ void CLayerRuleApplicator::applyDynamicRule(const SP<CLayerRule>& rule) {
try { try {
m_noScreenShare.first.set(std::stoi(effect), Types::PRIORITY_WINDOW_RULE); m_noScreenShare.first.set(std::stoi(effect), Types::PRIORITY_WINDOW_RULE);
m_noScreenShare.second |= rule->getPropertiesMask(); m_noScreenShare.second |= rule->getPropertiesMask();
} catch (...) { Debug::log(ERR, "CLayerRuleApplicator::applyDynamicRule: invalid order {}", effect); } } catch (...) { Log::logger->log(Log::ERR, "CLayerRuleApplicator::applyDynamicRule: invalid order {}", effect); }
break; break;
} }
case LAYER_RULE_EFFECT_ABOVE_LOCK: { case LAYER_RULE_EFFECT_ABOVE_LOCK: {
try { try {
m_aboveLock.first.set(std::clamp(std::stoull(effect), 0ULL, 2ULL), Types::PRIORITY_WINDOW_RULE); m_aboveLock.first.set(std::clamp(std::stoull(effect), 0ULL, 2ULL), Types::PRIORITY_WINDOW_RULE);
m_aboveLock.second |= rule->getPropertiesMask(); m_aboveLock.second |= rule->getPropertiesMask();
} catch (...) { Debug::log(ERR, "CLayerRuleApplicator::applyDynamicRule: invalid order {}", effect); } } catch (...) { Log::logger->log(Log::ERR, "CLayerRuleApplicator::applyDynamicRule: invalid order {}", effect); }
break; break;
} }
case LAYER_RULE_EFFECT_IGNORE_ALPHA: { case LAYER_RULE_EFFECT_IGNORE_ALPHA: {
try { try {
m_ignoreAlpha.first.set(std::clamp(std::stof(effect), 0.F, 1.F), Types::PRIORITY_WINDOW_RULE); m_ignoreAlpha.first.set(std::clamp(std::stof(effect), 0.F, 1.F), Types::PRIORITY_WINDOW_RULE);
m_ignoreAlpha.second |= rule->getPropertiesMask(); m_ignoreAlpha.second |= rule->getPropertiesMask();
} catch (...) { Debug::log(ERR, "CLayerRuleApplicator::applyDynamicRule: invalid order {}", effect); } } catch (...) { Log::logger->log(Log::ERR, "CLayerRuleApplicator::applyDynamicRule: invalid order {}", effect); }
break; break;
} }
case LAYER_RULE_EFFECT_ANIMATION: { case LAYER_RULE_EFFECT_ANIMATION: {

View file

@ -1,12 +1,12 @@
#include "IntMatchEngine.hpp" #include "IntMatchEngine.hpp"
#include "../../../debug/Log.hpp" #include "../../../debug/log/Logger.hpp"
using namespace Desktop::Rule; using namespace Desktop::Rule;
CIntMatchEngine::CIntMatchEngine(const std::string& s) { CIntMatchEngine::CIntMatchEngine(const std::string& s) {
try { try {
m_value = std::stoi(s); m_value = std::stoi(s);
} catch (...) { Debug::log(ERR, "CIntMatchEngine: invalid input {}", s); } } catch (...) { Log::logger->log(Log::ERR, "CIntMatchEngine: invalid input {}", s); }
} }
bool CIntMatchEngine::match(int other) { bool CIntMatchEngine::match(int other) {

View file

@ -32,7 +32,7 @@ bool CWindowRule::matches(PHLWINDOW w, bool allowEnvLookup) {
for (const auto& [prop, engine] : m_matchEngines) { for (const auto& [prop, engine] : m_matchEngines) {
switch (prop) { switch (prop) {
default: { default: {
Debug::log(TRACE, "CWindowRule::matches: skipping prop entry {}", sc<std::underlying_type_t<eRuleProperty>>(prop)); Log::logger->log(Log::TRACE, "CWindowRule::matches: skipping prop entry {}", sc<std::underlying_type_t<eRuleProperty>>(prop));
break; break;
} }

View file

@ -96,7 +96,7 @@ CWindowRuleApplicator::SRuleResult CWindowRuleApplicator::applyDynamicRule(const
switch (key) { switch (key) {
default: { default: {
if (key <= WINDOW_RULE_EFFECT_LAST_STATIC) { if (key <= WINDOW_RULE_EFFECT_LAST_STATIC) {
Debug::log(TRACE, "CWindowRuleApplicator::applyDynamicRule: Skipping effect {}, not dynamic", sc<std::underlying_type_t<eWindowRuleEffect>>(key)); Log::logger->log(Log::TRACE, "CWindowRuleApplicator::applyDynamicRule: Skipping effect {}, not dynamic", sc<std::underlying_type_t<eWindowRuleEffect>>(key));
break; break;
} }
@ -118,21 +118,21 @@ CWindowRuleApplicator::SRuleResult CWindowRuleApplicator::applyDynamicRule(const
} }
case WINDOW_RULE_EFFECT_NONE: { case WINDOW_RULE_EFFECT_NONE: {
Debug::log(ERR, "CWindowRuleApplicator::applyDynamicRule: BUG THIS: WINDOW_RULE_EFFECT_NONE??"); Log::logger->log(Log::ERR, "CWindowRuleApplicator::applyDynamicRule: BUG THIS: WINDOW_RULE_EFFECT_NONE??");
break; break;
} }
case WINDOW_RULE_EFFECT_ROUNDING: { case WINDOW_RULE_EFFECT_ROUNDING: {
try { try {
m_rounding.first.set(std::stoull(effect), Types::PRIORITY_WINDOW_RULE); m_rounding.first.set(std::stoull(effect), Types::PRIORITY_WINDOW_RULE);
m_rounding.second |= rule->getPropertiesMask(); m_rounding.second |= rule->getPropertiesMask();
} catch (...) { Debug::log(ERR, "CWindowRuleApplicator::applyDynamicRule: invalid rounding {}", effect); } } catch (...) { Log::logger->log(Log::ERR, "CWindowRuleApplicator::applyDynamicRule: invalid rounding {}", effect); }
break; break;
} }
case WINDOW_RULE_EFFECT_ROUNDING_POWER: { case WINDOW_RULE_EFFECT_ROUNDING_POWER: {
try { try {
m_roundingPower.first.set(std::clamp(std::stof(effect), 1.F, 10.F), Types::PRIORITY_WINDOW_RULE); m_roundingPower.first.set(std::clamp(std::stof(effect), 1.F, 10.F), Types::PRIORITY_WINDOW_RULE);
m_roundingPower.second |= rule->getPropertiesMask(); m_roundingPower.second |= rule->getPropertiesMask();
} catch (...) { Debug::log(ERR, "CWindowRuleApplicator::applyDynamicRule: invalid rounding_power {}", effect); } } catch (...) { Log::logger->log(Log::ERR, "CWindowRuleApplicator::applyDynamicRule: invalid rounding_power {}", effect); }
break; break;
} }
case WINDOW_RULE_EFFECT_PERSISTENT_SIZE: { case WINDOW_RULE_EFFECT_PERSISTENT_SIZE: {
@ -179,16 +179,16 @@ CWindowRuleApplicator::SRuleResult CWindowRuleApplicator::applyDynamicRule(const
// Includes sanity checks for the number of colors in each gradient // Includes sanity checks for the number of colors in each gradient
if (activeBorderGradient.m_colors.size() > 10 || inactiveBorderGradient.m_colors.size() > 10) if (activeBorderGradient.m_colors.size() > 10 || inactiveBorderGradient.m_colors.size() > 10)
Debug::log(WARN, "Bordercolor rule \"{}\" has more than 10 colors in one gradient, ignoring", effect); Log::logger->log(Log::WARN, "Bordercolor rule \"{}\" has more than 10 colors in one gradient, ignoring", effect);
else if (activeBorderGradient.m_colors.empty()) else if (activeBorderGradient.m_colors.empty())
Debug::log(WARN, "Bordercolor rule \"{}\" has no colors, ignoring", effect); Log::logger->log(Log::WARN, "Bordercolor rule \"{}\" has no colors, ignoring", effect);
else if (inactiveBorderGradient.m_colors.empty()) else if (inactiveBorderGradient.m_colors.empty())
m_activeBorderColor.first = Types::COverridableVar(activeBorderGradient, Types::PRIORITY_WINDOW_RULE); m_activeBorderColor.first = Types::COverridableVar(activeBorderGradient, Types::PRIORITY_WINDOW_RULE);
else { else {
m_activeBorderColor.first = Types::COverridableVar(activeBorderGradient, Types::PRIORITY_WINDOW_RULE); m_activeBorderColor.first = Types::COverridableVar(activeBorderGradient, Types::PRIORITY_WINDOW_RULE);
m_inactiveBorderColor.first = Types::COverridableVar(inactiveBorderGradient, Types::PRIORITY_WINDOW_RULE); m_inactiveBorderColor.first = Types::COverridableVar(inactiveBorderGradient, Types::PRIORITY_WINDOW_RULE);
} }
} catch (std::exception& e) { Debug::log(ERR, "BorderColor rule \"{}\" failed with: {}", effect, e.what()); } } catch (std::exception& e) { Log::logger->log(Log::ERR, "BorderColor rule \"{}\" failed with: {}", effect, e.what()); }
m_activeBorderColor.second = rule->getPropertiesMask(); m_activeBorderColor.second = rule->getPropertiesMask();
m_inactiveBorderColor.second = rule->getPropertiesMask(); m_inactiveBorderColor.second = rule->getPropertiesMask();
break; break;
@ -203,7 +203,7 @@ CWindowRuleApplicator::SRuleResult CWindowRuleApplicator::applyDynamicRule(const
else if (effect == "fullscreen") else if (effect == "fullscreen")
m_idleInhibitMode.first.set(IDLEINHIBIT_FULLSCREEN, Types::PRIORITY_WINDOW_RULE); m_idleInhibitMode.first.set(IDLEINHIBIT_FULLSCREEN, Types::PRIORITY_WINDOW_RULE);
else else
Debug::log(ERR, "Rule idleinhibit: unknown mode {}", effect); Log::logger->log(Log::ERR, "Rule idleinhibit: unknown mode {}", effect);
m_idleInhibitMode.second = rule->getPropertiesMask(); m_idleInhibitMode.second = rule->getPropertiesMask();
break; break;
} }
@ -246,7 +246,7 @@ CWindowRuleApplicator::SRuleResult CWindowRuleApplicator::applyDynamicRule(const
m_alphaInactive.first = m_alpha.first; m_alphaInactive.first = m_alpha.first;
m_alphaFullscreen.first = m_alpha.first; m_alphaFullscreen.first = m_alpha.first;
} }
} catch (std::exception& e) { Debug::log(ERR, "Opacity rule \"{}\" failed with: {}", effect, e.what()); } } catch (std::exception& e) { Log::logger->log(Log::ERR, "Opacity rule \"{}\" failed with: {}", effect, e.what()); }
m_alpha.second = rule->getPropertiesMask(); m_alpha.second = rule->getPropertiesMask();
m_alphaInactive.second = rule->getPropertiesMask(); m_alphaInactive.second = rule->getPropertiesMask();
m_alphaFullscreen.second = rule->getPropertiesMask(); m_alphaFullscreen.second = rule->getPropertiesMask();
@ -270,14 +270,14 @@ CWindowRuleApplicator::SRuleResult CWindowRuleApplicator::applyDynamicRule(const
const auto VEC = configStringToVector2D(effect); const auto VEC = configStringToVector2D(effect);
if (VEC.x < 1 || VEC.y < 1) { if (VEC.x < 1 || VEC.y < 1) {
Debug::log(ERR, "Invalid size for maxsize"); Log::logger->log(Log::ERR, "Invalid size for maxsize");
break; break;
} }
m_maxSize.first = Types::COverridableVar(VEC, Types::PRIORITY_WINDOW_RULE); m_maxSize.first = Types::COverridableVar(VEC, Types::PRIORITY_WINDOW_RULE);
m_window->clampWindowSize(std::nullopt, m_maxSize.first.value()); m_window->clampWindowSize(std::nullopt, m_maxSize.first.value());
} catch (std::exception& e) { Debug::log(ERR, "maxsize rule \"{}\" failed with: {}", effect, e.what()); } } catch (std::exception& e) { Log::logger->log(Log::ERR, "maxsize rule \"{}\" failed with: {}", effect, e.what()); }
m_maxSize.second = rule->getPropertiesMask(); m_maxSize.second = rule->getPropertiesMask();
break; break;
} }
@ -293,13 +293,13 @@ CWindowRuleApplicator::SRuleResult CWindowRuleApplicator::applyDynamicRule(const
const auto VEC = configStringToVector2D(effect); const auto VEC = configStringToVector2D(effect);
if (VEC.x < 1 || VEC.y < 1) { if (VEC.x < 1 || VEC.y < 1) {
Debug::log(ERR, "Invalid size for maxsize"); Log::logger->log(Log::ERR, "Invalid size for maxsize");
break; break;
} }
m_minSize.first = Types::COverridableVar(VEC, Types::PRIORITY_WINDOW_RULE); m_minSize.first = Types::COverridableVar(VEC, Types::PRIORITY_WINDOW_RULE);
m_window->clampWindowSize(std::nullopt, m_minSize.first.value()); m_window->clampWindowSize(std::nullopt, m_minSize.first.value());
} catch (std::exception& e) { Debug::log(ERR, "minsize rule \"{}\" failed with: {}", effect, e.what()); } } catch (std::exception& e) { Log::logger->log(Log::ERR, "minsize rule \"{}\" failed with: {}", effect, e.what()); }
m_minSize.second = rule->getPropertiesMask(); m_minSize.second = rule->getPropertiesMask();
break; break;
} }
@ -310,7 +310,7 @@ CWindowRuleApplicator::SRuleResult CWindowRuleApplicator::applyDynamicRule(const
m_borderSize.second |= rule->getPropertiesMask(); m_borderSize.second |= rule->getPropertiesMask();
if (oldBorderSize != m_borderSize.first.valueOrDefault()) if (oldBorderSize != m_borderSize.first.valueOrDefault())
result.needsRelayout = true; result.needsRelayout = true;
} catch (...) { Debug::log(ERR, "CWindowRuleApplicator::applyDynamicRule: invalid border_size {}", effect); } } catch (...) { Log::logger->log(Log::ERR, "CWindowRuleApplicator::applyDynamicRule: invalid border_size {}", effect); }
break; break;
} }
case WINDOW_RULE_EFFECT_ALLOWS_INPUT: { case WINDOW_RULE_EFFECT_ALLOWS_INPUT: {
@ -432,14 +432,14 @@ CWindowRuleApplicator::SRuleResult CWindowRuleApplicator::applyDynamicRule(const
try { try {
m_scrollMouse.first.set(std::clamp(std::stof(effect), 0.01F, 10.F), Types::PRIORITY_WINDOW_RULE); m_scrollMouse.first.set(std::clamp(std::stof(effect), 0.01F, 10.F), Types::PRIORITY_WINDOW_RULE);
m_scrollMouse.second |= rule->getPropertiesMask(); m_scrollMouse.second |= rule->getPropertiesMask();
} catch (...) { Debug::log(ERR, "CWindowRuleApplicator::applyDynamicRule: invalid scroll_mouse {}", effect); } } catch (...) { Log::logger->log(Log::ERR, "CWindowRuleApplicator::applyDynamicRule: invalid scroll_mouse {}", effect); }
break; break;
} }
case WINDOW_RULE_EFFECT_SCROLL_TOUCHPAD: { case WINDOW_RULE_EFFECT_SCROLL_TOUCHPAD: {
try { try {
m_scrollTouchpad.first.set(std::clamp(std::stof(effect), 0.01F, 10.F), Types::PRIORITY_WINDOW_RULE); m_scrollTouchpad.first.set(std::clamp(std::stof(effect), 0.01F, 10.F), Types::PRIORITY_WINDOW_RULE);
m_scrollTouchpad.second |= rule->getPropertiesMask(); m_scrollTouchpad.second |= rule->getPropertiesMask();
} catch (...) { Debug::log(ERR, "CWindowRuleApplicator::applyDynamicRule: invalid scroll_touchpad {}", effect); } } catch (...) { Log::logger->log(Log::ERR, "CWindowRuleApplicator::applyDynamicRule: invalid scroll_touchpad {}", effect); }
break; break;
} }
} }
@ -451,7 +451,7 @@ CWindowRuleApplicator::SRuleResult CWindowRuleApplicator::applyStaticRule(const
for (const auto& [key, effect] : rule->effects()) { for (const auto& [key, effect] : rule->effects()) {
switch (key) { switch (key) {
default: { default: {
Debug::log(TRACE, "CWindowRuleApplicator::applyStaticRule: Skipping effect {}, not static", sc<std::underlying_type_t<eWindowRuleEffect>>(key)); Log::logger->log(Log::TRACE, "CWindowRuleApplicator::applyStaticRule: Skipping effect {}, not static", sc<std::underlying_type_t<eWindowRuleEffect>>(key));
break; break;
} }
@ -477,7 +477,7 @@ CWindowRuleApplicator::SRuleResult CWindowRuleApplicator::applyStaticRule(const
static_.fullscreenStateInternal = std::stoi(std::string{vars[0]}); static_.fullscreenStateInternal = std::stoi(std::string{vars[0]});
if (!vars[1].empty()) if (!vars[1].empty())
static_.fullscreenStateClient = std::stoi(std::string{vars[1]}); static_.fullscreenStateClient = std::stoi(std::string{vars[1]});
} catch (...) { Debug::log(ERR, "CWindowRuleApplicator::applyStaticRule: invalid fullscreen state {}", effect); } } catch (...) { Log::logger->log(Log::ERR, "CWindowRuleApplicator::applyStaticRule: invalid fullscreen state {}", effect); }
break; break;
} }
case WINDOW_RULE_EFFECT_MOVE: { case WINDOW_RULE_EFFECT_MOVE: {
@ -532,7 +532,7 @@ CWindowRuleApplicator::SRuleResult CWindowRuleApplicator::applyStaticRule(const
case WINDOW_RULE_EFFECT_NOCLOSEFOR: { case WINDOW_RULE_EFFECT_NOCLOSEFOR: {
try { try {
static_.noCloseFor = std::stoi(effect); static_.noCloseFor = std::stoi(effect);
} catch (...) { Debug::log(ERR, "CWindowRuleApplicator::applyStaticRule: invalid no close for {}", effect); } } catch (...) { Log::logger->log(Log::ERR, "CWindowRuleApplicator::applyStaticRule: invalid no close for {}", effect); }
break; break;
} }
} }

View file

@ -67,7 +67,7 @@ static SFullscreenWorkspaceFocusResult onFullscreenWorkspaceFocusWindow(PHLWINDO
g_pCompositor->setWindowFullscreenInternal(pWindow, FSMODE); g_pCompositor->setWindowFullscreenInternal(pWindow, FSMODE);
break; break;
default: Debug::log(ERR, "Invalid misc:on_focus_under_fullscreen mode: {}", *PONFOCUSUNDERFS); break; default: Log::logger->log(Log::ERR, "Invalid misc:on_focus_under_fullscreen mode: {}", *PONFOCUSUNDERFS); break;
} }
return {}; return {};
@ -89,7 +89,7 @@ void CFocusState::fullWindowFocus(PHLWINDOW pWindow, SP<CWLSurfaceResource> surf
static auto PMODALPARENTBLOCKING = CConfigValue<Hyprlang::INT>("general:modal_parent_blocking"); static auto PMODALPARENTBLOCKING = CConfigValue<Hyprlang::INT>("general:modal_parent_blocking");
if (*PMODALPARENTBLOCKING && pWindow && pWindow->m_xdgSurface && pWindow->m_xdgSurface->m_toplevel && pWindow->m_xdgSurface->m_toplevel->anyChildModal()) { if (*PMODALPARENTBLOCKING && pWindow && pWindow->m_xdgSurface && pWindow->m_xdgSurface->m_toplevel && pWindow->m_xdgSurface->m_toplevel->anyChildModal()) {
Debug::log(LOG, "Refusing focus to window shadowed by modal dialog"); Log::logger->log(Log::DEBUG, "Refusing focus to window shadowed by modal dialog");
return; return;
} }
@ -102,12 +102,12 @@ void CFocusState::rawWindowFocus(PHLWINDOW pWindow, SP<CWLSurfaceResource> surfa
if (!pWindow || !pWindow->priorityFocus()) { if (!pWindow || !pWindow->priorityFocus()) {
if (g_pSessionLockManager->isSessionLocked()) { if (g_pSessionLockManager->isSessionLocked()) {
Debug::log(LOG, "Refusing a keyboard focus to a window because of a sessionlock"); Log::logger->log(Log::DEBUG, "Refusing a keyboard focus to a window because of a sessionlock");
return; return;
} }
if (!g_pInputManager->m_exclusiveLSes.empty()) { if (!g_pInputManager->m_exclusiveLSes.empty()) {
Debug::log(LOG, "Refusing a keyboard focus to a window because of an exclusive ls"); Log::logger->log(Log::DEBUG, "Refusing a keyboard focus to a window because of an exclusive ls");
return; return;
} }
} }
@ -148,7 +148,7 @@ void CFocusState::rawWindowFocus(PHLWINDOW pWindow, SP<CWLSurfaceResource> surfa
} }
if (pWindow->m_ruleApplicator->noFocus().valueOrDefault()) { if (pWindow->m_ruleApplicator->noFocus().valueOrDefault()) {
Debug::log(LOG, "Ignoring focus to nofocus window!"); Log::logger->log(Log::DEBUG, "Ignoring focus to nofocus window!");
return; return;
} }
@ -234,7 +234,7 @@ void CFocusState::rawSurfaceFocus(SP<CWLSurfaceResource> pSurface, PHLWINDOW pWi
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", rc<uintptr_t>(pSurface.get())); Log::logger->log(Log::DEBUG, "surface {:x} won't receive kb focus because grab rejected it", rc<uintptr_t>(pSurface.get()));
return; return;
} }
@ -257,9 +257,9 @@ void CFocusState::rawSurfaceFocus(SP<CWLSurfaceResource> pSurface, PHLWINDOW pWi
g_pSeatManager->setKeyboardFocus(pSurface); g_pSeatManager->setKeyboardFocus(pSurface);
if (pWindowOwner) if (pWindowOwner)
Debug::log(LOG, "Set keyboard focus to surface {:x}, with {}", rc<uintptr_t>(pSurface.get()), pWindowOwner); Log::logger->log(Log::DEBUG, "Set keyboard focus to surface {:x}, with {}", rc<uintptr_t>(pSurface.get()), pWindowOwner);
else else
Debug::log(LOG, "Set keyboard focus to surface {:x}", rc<uintptr_t>(pSurface.get())); Log::logger->log(Log::DEBUG, "Set keyboard focus to surface {:x}", rc<uintptr_t>(pSurface.get()));
g_pXWaylandManager->activateSurface(pSurface, true); g_pXWaylandManager->activateSurface(pSurface, true);
m_focusSurface = pSurface; m_focusSurface = pSurface;
@ -324,7 +324,7 @@ void CFocusState::addWindowToHistory(PHLWINDOW w) {
void CFocusState::moveWindowToLatestInHistory(PHLWINDOW w) { void CFocusState::moveWindowToLatestInHistory(PHLWINDOW w) {
const auto HISTORYPIVOT = std::ranges::find_if(m_windowFocusHistory, [&w](const auto& other) { return other.lock() == w; }); const auto HISTORYPIVOT = std::ranges::find_if(m_windowFocusHistory, [&w](const auto& other) { return other.lock() == w; });
if (HISTORYPIVOT == m_windowFocusHistory.end()) if (HISTORYPIVOT == m_windowFocusHistory.end())
Debug::log(TRACE, "CFocusState: {} has no pivot in history, ignoring request to move to latest", w); Log::logger->log(Log::TRACE, "CFocusState: {} has no pivot in history, ignoring request to move to latest", w);
else else
std::rotate(m_windowFocusHistory.begin(), HISTORYPIVOT, HISTORYPIVOT + 1); std::rotate(m_windowFocusHistory.begin(), HISTORYPIVOT, HISTORYPIVOT + 1);
} }

View file

@ -24,7 +24,7 @@ PHLLS CLayerSurface::create(SP<CLayerShellResource> resource) {
pLS->m_wlSurface->assign(resource->m_surface.lock(), pLS); pLS->m_wlSurface->assign(resource->m_surface.lock(), pLS);
if (!pMonitor) { if (!pMonitor) {
Debug::log(ERR, "New LS has no monitor??"); Log::logger->log(Log::ERR, "New LS has no monitor??");
return pLS; return pLS;
} }
@ -50,8 +50,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 {}", rc<uintptr_t>(resource.get()), resource->m_layerNamespace, sc<int>(pLS->m_layer), Log::logger->log(Log::DEBUG, "LayerSurface {:x} (namespace {} layer {}) created on monitor {}", rc<uintptr_t>(resource.get()), resource->m_layerNamespace,
pMonitor->m_name); sc<int>(pLS->m_layer), pMonitor->m_name);
return pLS; return pLS;
} }
@ -116,19 +116,19 @@ bool CLayerSurface::desktopComponent() const {
} }
void CLayerSurface::onDestroy() { void CLayerSurface::onDestroy() {
Debug::log(LOG, "LayerSurface {:x} destroyed", rc<uintptr_t>(m_layerSurface.get())); Log::logger->log(Log::DEBUG, "LayerSurface {:x} destroyed", rc<uintptr_t>(m_layerSurface.get()));
const auto PMONITOR = m_monitor.lock(); const auto PMONITOR = m_monitor.lock();
if (!PMONITOR) if (!PMONITOR)
Debug::log(WARN, "Layersurface destroyed on an invalid monitor (removed?)"); Log::logger->log(Log::WARN, "Layersurface destroyed on an invalid monitor (removed?)");
if (!m_fadingOut) { if (!m_fadingOut) {
if (m_mapped) { if (m_mapped) {
Debug::log(LOG, "Forcing an unmap of a LS that did a straight destroy!"); Log::logger->log(Log::DEBUG, "Forcing an unmap of a LS that did a straight destroy!");
onUnmap(); onUnmap();
} else { } else {
Debug::log(LOG, "Removing LayerSurface that wasn't mapped."); Log::logger->log(Log::DEBUG, "Removing LayerSurface that wasn't mapped.");
if (m_alpha) if (m_alpha)
g_pDesktopAnimationManager->startAnimation(m_self.lock(), CDesktopAnimationManager::ANIMATION_TYPE_OUT); g_pDesktopAnimationManager->startAnimation(m_self.lock(), CDesktopAnimationManager::ANIMATION_TYPE_OUT);
m_fadingOut = true; m_fadingOut = true;
@ -162,7 +162,7 @@ void CLayerSurface::onDestroy() {
} }
void CLayerSurface::onMap() { void CLayerSurface::onMap() {
Debug::log(LOG, "LayerSurface {:x} mapped", rc<uintptr_t>(m_layerSurface.get())); Log::logger->log(Log::DEBUG, "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;
@ -229,7 +229,7 @@ void CLayerSurface::onMap() {
} }
void CLayerSurface::onUnmap() { void CLayerSurface::onUnmap() {
Debug::log(LOG, "LayerSurface {:x} unmapped", rc<uintptr_t>(m_layerSurface.get())); Log::logger->log(Log::DEBUG, "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());
@ -237,7 +237,7 @@ void CLayerSurface::onUnmap() {
std::erase_if(g_pInputManager->m_exclusiveLSes, [this](const auto& other) { return !other || other == m_self; }); std::erase_if(g_pInputManager->m_exclusiveLSes, [this](const auto& other) { return !other || other == m_self; });
if (!m_monitor || g_pCompositor->m_unsafeState) { if (!m_monitor || g_pCompositor->m_unsafeState) {
Debug::log(WARN, "Layersurface unmapping on invalid monitor (removed?) ignoring."); Log::logger->log(Log::WARN, "Layersurface unmapping on invalid monitor (removed?) ignoring.");
g_pCompositor->addToFadingOutSafe(m_self.lock()); g_pCompositor->addToFadingOutSafe(m_self.lock());

View file

@ -137,7 +137,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}", rc<uintptr_t>(this)); Log::logger->log(Log::DEBUG, "New popup at {:x}", rc<uintptr_t>(this));
} }
void CPopup::onDestroy() { void CPopup::onDestroy() {
@ -156,7 +156,7 @@ void CPopup::onDestroy() {
m_listeners.newPopup.reset(); m_listeners.newPopup.reset();
if (m_fadingOut && m_alpha->isBeingAnimated()) { if (m_fadingOut && m_alpha->isBeingAnimated()) {
Debug::log(LOG, "popup {:x}: skipping full destroy, animating", rc<uintptr_t>(this)); Log::logger->log(Log::DEBUG, "popup {:x}: skipping full destroy, animating", rc<uintptr_t>(this));
return; return;
} }
@ -164,7 +164,7 @@ void CPopup::onDestroy() {
} }
void CPopup::fullyDestroy() { void CPopup::fullyDestroy() {
Debug::log(LOG, "popup {:x} fully destroying", rc<uintptr_t>(this)); Log::logger->log(Log::DEBUG, "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; });
@ -203,7 +203,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", rc<uintptr_t>(this)); Log::logger->log(Log::DEBUG, "popup {:x}: mapped", rc<uintptr_t>(this));
} }
void CPopup::onUnmap() { void CPopup::onUnmap() {
@ -211,12 +211,12 @@ void CPopup::onUnmap() {
return; return;
if (!m_resource || !m_resource->m_surface) { if (!m_resource || !m_resource->m_surface) {
Debug::log(ERR, "CPopup: orphaned (no surface/resource) and unmaps??"); Log::logger->log(Log::ERR, "CPopup: orphaned (no surface/resource) and unmaps??");
onDestroy(); onDestroy();
return; return;
} }
Debug::log(LOG, "popup {:x}: unmapped", rc<uintptr_t>(this)); Log::logger->log(Log::DEBUG, "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),
@ -271,7 +271,7 @@ void CPopup::onUnmap() {
void CPopup::onCommit(bool ignoreSiblings) { void CPopup::onCommit(bool ignoreSiblings) {
if (!m_resource || !m_resource->m_surface) { if (!m_resource || !m_resource->m_surface) {
Debug::log(ERR, "CPopup: orphaned (no surface/resource) and commits??"); Log::logger->log(Log::ERR, "CPopup: orphaned (no surface/resource) and commits??");
onDestroy(); onDestroy();
return; return;
} }
@ -286,7 +286,7 @@ void CPopup::onCommit(bool ignoreSiblings) {
static auto PLOGDAMAGE = CConfigValue<Hyprlang::INT>("debug:log_damage"); static auto PLOGDAMAGE = CConfigValue<Hyprlang::INT>("debug:log_damage");
if (*PLOGDAMAGE) if (*PLOGDAMAGE)
Debug::log(LOG, "Refusing to commit damage from a subsurface of {} because it's invisible.", m_windowOwner.lock()); Log::logger->log(Log::DEBUG, "Refusing to commit damage from a subsurface of {} because it's invisible.", m_windowOwner.lock());
return; return;
} }
@ -318,7 +318,7 @@ void CPopup::onCommit(bool ignoreSiblings) {
} }
void CPopup::onReposition() { void CPopup::onReposition() {
Debug::log(LOG, "Popup {:x} requests reposition", rc<uintptr_t>(this)); Log::logger->log(Log::DEBUG, "Popup {:x} requests reposition", rc<uintptr_t>(this));
m_requestedReposition = true; m_requestedReposition = true;

View file

@ -142,7 +142,7 @@ void CSubsurface::onCommit() {
static auto PLOGDAMAGE = CConfigValue<Hyprlang::INT>("debug:log_damage"); static auto PLOGDAMAGE = CConfigValue<Hyprlang::INT>("debug:log_damage");
if (*PLOGDAMAGE) if (*PLOGDAMAGE)
Debug::log(LOG, "Refusing to commit damage from a subsurface of {} because it's invisible.", m_windowParent.lock()); Log::logger->log(Log::DEBUG, "Refusing to commit damage from a subsurface of {} because it's invisible.", m_windowParent.lock());
return; return;
} }

View file

@ -132,7 +132,7 @@ void CWLSurface::destroy() {
m_resource.reset(); m_resource.reset();
Debug::log(LOG, "CWLSurface {:x} called destroy()", rc<uintptr_t>(this)); Log::logger->log(Log::DEBUG, "CWLSurface {:x} called destroy()", rc<uintptr_t>(this));
} }
void CWLSurface::init() { void CWLSurface::init() {
@ -145,7 +145,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()", rc<uintptr_t>(this)); Log::logger->log(Log::DEBUG, "CWLSurface {:x} called init()", rc<uintptr_t>(this));
} }
SP<IView> CWLSurface::view() const { SP<IView> CWLSurface::view() const {

View file

@ -10,6 +10,7 @@
#include <any> #include <any>
#include <bit> #include <bit>
#include <fstream>
#include <string_view> #include <string_view>
#include "Window.hpp" #include "Window.hpp"
#include "LayerSurface.hpp" #include "LayerSurface.hpp"
@ -719,7 +720,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", rc<uintptr_t>(this), this->m_title); Log::logger->log(Log::DEBUG, "createGroup: window:{:x},title:{} is denied as a group, ignored", rc<uintptr_t>(this), this->m_title);
return; return;
} }
@ -747,7 +748,7 @@ void CWindow::createGroup() {
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", rc<uintptr_t>(this), this->m_title); Log::logger->log(Log::DEBUG, "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();
@ -1305,7 +1306,7 @@ void CWindow::activate(bool force) {
return; return;
if (!m_isMapped) { if (!m_isMapped) {
Debug::log(LOG, "Ignoring CWindow::activate focus/warp, window is not mapped yet."); Log::logger->log(Log::DEBUG, "Ignoring CWindow::activate focus/warp, window is not mapped yet.");
return; return;
} }
@ -1367,7 +1368,7 @@ void CWindow::onUpdateMeta() {
EMIT_HOOK_EVENT("activeWindow", m_self.lock()); EMIT_HOOK_EVENT("activeWindow", m_self.lock());
} }
Debug::log(LOG, "Window {:x} set title to {}", rc<uintptr_t>(this), m_title); Log::logger->log(Log::DEBUG, "Window {:x} set title to {}", rc<uintptr_t>(this), m_title);
doUpdate = true; doUpdate = true;
} }
@ -1381,7 +1382,7 @@ void CWindow::onUpdateMeta() {
EMIT_HOOK_EVENT("activeWindow", m_self.lock()); EMIT_HOOK_EVENT("activeWindow", m_self.lock());
} }
Debug::log(LOG, "Window {:x} set class to {}", rc<uintptr_t>(this), m_class); Log::logger->log(Log::DEBUG, "Window {:x} set class to {}", rc<uintptr_t>(this), m_class);
doUpdate = true; doUpdate = true;
} }
@ -1442,7 +1443,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}", rc<uintptr_t>(m_xwaylandSurface.get()), rc<uintptr_t>(m_wlSurface->resource().get())); Log::logger->log(Log::DEBUG, "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) {
@ -1649,7 +1650,7 @@ 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: {})", rc<uintptr_t>(this), this->m_title, m_realPosition->goal(), Log::logger->log(Log::TRACE, "sendWindowSize: window:{:x},title:{} with real pos {}, real size {} (force: {})", rc<uintptr_t>(this), this->m_title, m_realPosition->goal(),
m_realSize->goal(), force); m_realSize->goal(), force);
// TODO: this should be decoupled from setWindowSize IMO // TODO: this should be decoupled from setWindowSize IMO
@ -1682,7 +1683,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 {}", sc<int>(contentType)); Log::logger->log(Log::INFO, "ContentType for window {}", sc<int>(contentType));
m_wlSurface->resource()->m_contentType->m_value = contentType; m_wlSurface->resource()->m_contentType->m_value = contentType;
} }
@ -1952,13 +1953,13 @@ void CWindow::mapWindow() {
const auto WINDOWENV = getEnv(); const auto WINDOWENV = getEnv();
if (WINDOWENV.contains("HL_INITIAL_WORKSPACE_TOKEN")) { if (WINDOWENV.contains("HL_INITIAL_WORKSPACE_TOKEN")) {
const auto SZTOKEN = WINDOWENV.at("HL_INITIAL_WORKSPACE_TOKEN"); const auto SZTOKEN = WINDOWENV.at("HL_INITIAL_WORKSPACE_TOKEN");
Debug::log(LOG, "New window contains HL_INITIAL_WORKSPACE_TOKEN: {}", SZTOKEN); Log::logger->log(Log::DEBUG, "New window contains HL_INITIAL_WORKSPACE_TOKEN: {}", SZTOKEN);
const auto TOKEN = g_pTokenManager->getToken(SZTOKEN); const auto TOKEN = g_pTokenManager->getToken(SZTOKEN);
if (TOKEN) { if (TOKEN) {
// find workspace and use it // find workspace and use it
Desktop::View::SInitialWorkspaceToken WS = std::any_cast<Desktop::View::SInitialWorkspaceToken>(TOKEN->m_data); Desktop::View::SInitialWorkspaceToken WS = std::any_cast<Desktop::View::SInitialWorkspaceToken>(TOKEN->m_data);
Debug::log(LOG, "HL_INITIAL_WORKSPACE_TOKEN {} -> {}", SZTOKEN, WS.workspace); Log::logger->log(Log::DEBUG, "HL_INITIAL_WORKSPACE_TOKEN {} -> {}", SZTOKEN, WS.workspace);
if (g_pCompositor->getWorkspaceByString(WS.workspace) != m_workspace) { if (g_pCompositor->getWorkspaceByString(WS.workspace) != m_workspace) {
requestedWorkspace = WS.workspace; requestedWorkspace = WS.workspace;
@ -2023,10 +2024,10 @@ void CWindow::mapWindow() {
m_workspace = PMONITOR->m_activeSpecialWorkspace ? PMONITOR->m_activeSpecialWorkspace : PMONITOR->m_activeWorkspace; m_workspace = PMONITOR->m_activeSpecialWorkspace ? PMONITOR->m_activeSpecialWorkspace : PMONITOR->m_activeWorkspace;
PWORKSPACE = m_workspace; PWORKSPACE = m_workspace;
Debug::log(LOG, "Rule monitor, applying to {:mw}", m_self.lock()); Log::logger->log(Log::DEBUG, "Rule monitor, applying to {:mw}", m_self.lock());
requestedFSMonitor = MONITOR_INVALID; requestedFSMonitor = MONITOR_INVALID;
} else } else
Debug::log(ERR, "No monitor in monitor {} rule", MONITORSTR); Log::logger->log(Log::ERR, "No monitor in monitor {} rule", MONITORSTR);
} }
} }
@ -2043,7 +2044,7 @@ void CWindow::mapWindow() {
if (JUSTWORKSPACE == PWORKSPACE->m_name || JUSTWORKSPACE == "name:" + PWORKSPACE->m_name) if (JUSTWORKSPACE == PWORKSPACE->m_name || JUSTWORKSPACE == "name:" + PWORKSPACE->m_name)
requestedWorkspace = ""; requestedWorkspace = "";
Debug::log(LOG, "Rule workspace matched by {}, {} applied.", m_self.lock(), m_ruleApplicator->static_.workspace); Log::logger->log(Log::DEBUG, "Rule workspace matched by {}, {} applied.", m_self.lock(), m_ruleApplicator->static_.workspace);
requestedFSMonitor = MONITOR_INVALID; requestedFSMonitor = MONITOR_INVALID;
} }
@ -2072,7 +2073,7 @@ void CWindow::mapWindow() {
else if (var == "fullscreenoutput") else if (var == "fullscreenoutput")
m_suppressedEvents |= Desktop::View::SUPPRESS_FULLSCREEN_OUTPUT; m_suppressedEvents |= Desktop::View::SUPPRESS_FULLSCREEN_OUTPUT;
else else
Debug::log(ERR, "Error while parsing suppressevent windowrule: unknown event type {}", var); Log::logger->log(Log::ERR, "Error while parsing suppressevent windowrule: unknown event type {}", var);
} }
} }
@ -2117,7 +2118,7 @@ void CWindow::mapWindow() {
else if (vPrev == "lock") else if (vPrev == "lock")
m_groupRules |= Desktop::View::GROUP_LOCK_ALWAYS; m_groupRules |= Desktop::View::GROUP_LOCK_ALWAYS;
else else
Debug::log(ERR, "windowrule `group` does not support `{} always`", vPrev); Log::logger->log(Log::ERR, "windowrule `group` does not support `{} always`", vPrev);
} }
vPrev = v; vPrev = v;
} }
@ -2200,7 +2201,7 @@ void CWindow::mapWindow() {
m_workspace = PMONITOR->m_activeSpecialWorkspace ? PMONITOR->m_activeSpecialWorkspace : PMONITOR->m_activeWorkspace; m_workspace = PMONITOR->m_activeSpecialWorkspace ? PMONITOR->m_activeSpecialWorkspace : PMONITOR->m_activeWorkspace;
PWORKSPACE = m_workspace; PWORKSPACE = m_workspace;
Debug::log(LOG, "Requested monitor, applying to {:mw}", m_self.lock()); Log::logger->log(Log::DEBUG, "Requested monitor, applying to {:mw}", m_self.lock());
} }
if (PWORKSPACE->m_defaultFloating) if (PWORKSPACE->m_defaultFloating)
@ -2231,7 +2232,7 @@ void CWindow::mapWindow() {
if (!m_ruleApplicator->static_.size.empty()) { if (!m_ruleApplicator->static_.size.empty()) {
const auto COMPUTED = calculateExpression(m_ruleApplicator->static_.size); const auto COMPUTED = calculateExpression(m_ruleApplicator->static_.size);
if (!COMPUTED) if (!COMPUTED)
Debug::log(ERR, "failed to parse {} as an expression", m_ruleApplicator->static_.size); Log::logger->log(Log::ERR, "failed to parse {} as an expression", m_ruleApplicator->static_.size);
else { else {
*m_realSize = *COMPUTED; *m_realSize = *COMPUTED;
setHidden(false); setHidden(false);
@ -2241,7 +2242,7 @@ void CWindow::mapWindow() {
if (!m_ruleApplicator->static_.position.empty()) { if (!m_ruleApplicator->static_.position.empty()) {
const auto COMPUTED = calculateExpression(m_ruleApplicator->static_.position); const auto COMPUTED = calculateExpression(m_ruleApplicator->static_.position);
if (!COMPUTED) if (!COMPUTED)
Debug::log(ERR, "failed to parse {} as an expression", m_ruleApplicator->static_.position); Log::logger->log(Log::ERR, "failed to parse {} as an expression", m_ruleApplicator->static_.position);
else { else {
*m_realPosition = *COMPUTED + PMONITOR->m_position; *m_realPosition = *COMPUTED + PMONITOR->m_position;
setHidden(false); setHidden(false);
@ -2266,7 +2267,7 @@ void CWindow::mapWindow() {
if (!m_ruleApplicator->static_.size.empty()) { if (!m_ruleApplicator->static_.size.empty()) {
const auto COMPUTED = calculateExpression(m_ruleApplicator->static_.size); const auto COMPUTED = calculateExpression(m_ruleApplicator->static_.size);
if (!COMPUTED) if (!COMPUTED)
Debug::log(ERR, "failed to parse {} as an expression", m_ruleApplicator->static_.size); Log::logger->log(Log::ERR, "failed to parse {} as an expression", m_ruleApplicator->static_.size);
else { else {
setPseudo = true; setPseudo = true;
m_pseudoSize = *COMPUTED; m_pseudoSize = *COMPUTED;
@ -2359,7 +2360,7 @@ void CWindow::mapWindow() {
m_firstMap = false; m_firstMap = false;
Debug::log(LOG, "Map request dispatched, monitor {}, window pos: {:5j}, window size: {:5j}", PMONITOR->m_name, m_realPosition->goal(), m_realSize->goal()); Log::logger->log(Log::DEBUG, "Map request dispatched, monitor {}, window pos: {:5j}, window size: {:5j}", PMONITOR->m_name, m_realPosition->goal(), m_realSize->goal());
// emit the hook event here after basic stuff has been initialized // emit the hook event here after basic stuff has been initialized
EMIT_HOOK_EVENT("openWindow", m_self.lock()); EMIT_HOOK_EVENT("openWindow", m_self.lock());
@ -2398,7 +2399,7 @@ void CWindow::mapWindow() {
} }
void CWindow::unmapWindow() { void CWindow::unmapWindow() {
Debug::log(LOG, "{:c} unmapped", m_self.lock()); Log::logger->log(Log::DEBUG, "{:c} unmapped", m_self.lock());
static auto PEXITRETAINSFS = CConfigValue<Hyprlang::INT>("misc:exit_window_retains_fullscreen"); static auto PEXITRETAINSFS = CConfigValue<Hyprlang::INT>("misc:exit_window_retains_fullscreen");
@ -2406,7 +2407,7 @@ void CWindow::unmapWindow() {
const auto CURRENTFSMODE = m_fullscreenState.internal; const auto CURRENTFSMODE = m_fullscreenState.internal;
if (!wlSurface()->exists() || !m_isMapped) { if (!wlSurface()->exists() || !m_isMapped) {
Debug::log(WARN, "{} unmapped without being mapped??", m_self.lock()); Log::logger->log(Log::WARN, "{} unmapped without being mapped??", m_self.lock());
m_fadingOut = false; m_fadingOut = false;
return; return;
} }
@ -2422,7 +2423,7 @@ void CWindow::unmapWindow() {
EMIT_HOOK_EVENT("closeWindow", m_self.lock()); EMIT_HOOK_EVENT("closeWindow", m_self.lock());
if (m_isFloating && !m_isX11 && m_ruleApplicator->persistentSize().valueOrDefault()) { if (m_isFloating && !m_isX11 && m_ruleApplicator->persistentSize().valueOrDefault()) {
Debug::log(LOG, "storing floating size {}x{} for window {}::{} on close", m_realSize->value().x, m_realSize->value().y, m_class, m_title); Log::logger->log(Log::DEBUG, "storing floating size {}x{} for window {}::{} on close", m_realSize->value().x, m_realSize->value().y, m_class, m_title);
g_pConfigManager->storeFloatingSize(m_self.lock(), m_realSize->value()); g_pConfigManager->storeFloatingSize(m_self.lock(), m_realSize->value());
} }
@ -2485,7 +2486,7 @@ void CWindow::unmapWindow() {
else else
PWINDOWCANDIDATE = g_pLayoutManager->getCurrentLayout()->getNextWindowCandidate(m_self.lock()); PWINDOWCANDIDATE = g_pLayoutManager->getCurrentLayout()->getNextWindowCandidate(m_self.lock());
Debug::log(LOG, "On closed window, new focused candidate is {}", PWINDOWCANDIDATE); Log::logger->log(Log::DEBUG, "On closed window, new focused candidate is {}", PWINDOWCANDIDATE);
if (PWINDOWCANDIDATE != Desktop::focusState()->window() && PWINDOWCANDIDATE) { if (PWINDOWCANDIDATE != Desktop::focusState()->window() && PWINDOWCANDIDATE) {
Desktop::focusState()->fullWindowFocus(PWINDOWCANDIDATE); Desktop::focusState()->fullWindowFocus(PWINDOWCANDIDATE);
@ -2505,7 +2506,7 @@ void CWindow::unmapWindow() {
EMIT_HOOK_EVENT("activeWindow", PHLWINDOW{nullptr}); EMIT_HOOK_EVENT("activeWindow", PHLWINDOW{nullptr});
} }
} else { } else {
Debug::log(LOG, "Unmapped was not focused, ignoring a refocus."); Log::logger->log(Log::DEBUG, "Unmapped was not focused, ignoring a refocus.");
} }
m_fadingOut = true; m_fadingOut = true;
@ -2533,7 +2534,7 @@ void CWindow::commitWindow() {
if (!m_isX11 && m_xdgSurface->m_initialCommit) { if (!m_isX11 && m_xdgSurface->m_initialCommit) {
Vector2D predSize = g_pLayoutManager->getCurrentLayout()->predictSizeForNewWindow(m_self.lock()); Vector2D predSize = g_pLayoutManager->getCurrentLayout()->predictSizeForNewWindow(m_self.lock());
Debug::log(LOG, "Layout predicts size {} for {}", predSize, m_self.lock()); Log::logger->log(Log::DEBUG, "Layout predicts size {} for {}", predSize, m_self.lock());
m_xdgSurface->m_toplevel->setSize(predSize); m_xdgSurface->m_toplevel->setSize(predSize);
return; return;
@ -2594,7 +2595,7 @@ void CWindow::commitWindow() {
} }
void CWindow::destroyWindow() { void CWindow::destroyWindow() {
Debug::log(LOG, "{:c} destroyed, queueing.", m_self.lock()); Log::logger->log(Log::DEBUG, "{:c} destroyed, queueing.", m_self.lock());
if (m_self.lock() == Desktop::focusState()->window()) { if (m_self.lock() == Desktop::focusState()->window()) {
Desktop::focusState()->window().reset(); Desktop::focusState()->window().reset();
@ -2612,7 +2613,7 @@ void CWindow::destroyWindow() {
m_xdgSurface.reset(); m_xdgSurface.reset();
if (!m_fadingOut) { if (!m_fadingOut) {
Debug::log(LOG, "Unmapped {} removed instantly", m_self.lock()); Log::logger->log(Log::DEBUG, "Unmapped {} removed instantly", m_self.lock());
g_pCompositor->removeWindowFromVectorSafe(m_self.lock()); // most likely X11 unmanaged or sumn g_pCompositor->removeWindowFromVectorSafe(m_self.lock()); // most likely X11 unmanaged or sumn
} }
@ -2623,11 +2624,11 @@ void CWindow::destroyWindow() {
} }
void CWindow::activateX11() { void CWindow::activateX11() {
Debug::log(LOG, "X11 Activate request for window {}", m_self.lock()); Log::logger->log(Log::DEBUG, "X11 Activate request for window {}", m_self.lock());
if (isX11OverrideRedirect()) { if (isX11OverrideRedirect()) {
Debug::log(LOG, "Unmanaged X11 {} requests activate", m_self.lock()); Log::logger->log(Log::DEBUG, "Unmanaged X11 {} requests activate", m_self.lock());
if (Desktop::focusState()->window() && Desktop::focusState()->window()->getPID() != getPID()) if (Desktop::focusState()->window() && Desktop::focusState()->window()->getPID() != getPID())
return; return;
@ -2669,7 +2670,7 @@ void CWindow::unmanagedSetGeometry() {
if (abs(std::floor(POS.x) - LOGICALPOS.x) > 2 || abs(std::floor(POS.y) - LOGICALPOS.y) > 2 || abs(std::floor(SIZ.x) - m_xwaylandSurface->m_geometry.width) > 2 || if (abs(std::floor(POS.x) - LOGICALPOS.x) > 2 || abs(std::floor(POS.y) - LOGICALPOS.y) > 2 || abs(std::floor(SIZ.x) - m_xwaylandSurface->m_geometry.width) > 2 ||
abs(std::floor(SIZ.y) - m_xwaylandSurface->m_geometry.height) > 2) { abs(std::floor(SIZ.y) - m_xwaylandSurface->m_geometry.height) > 2) {
Debug::log(LOG, "Unmanaged window {} requests geometry update to {:j} {:j}", m_self.lock(), LOGICALPOS, m_xwaylandSurface->m_geometry.size()); Log::logger->log(Log::DEBUG, "Unmanaged window {} requests geometry update to {:j} {:j}", m_self.lock(), LOGICALPOS, m_xwaylandSurface->m_geometry.size());
g_pHyprRenderer->damageWindow(m_self.lock()); g_pHyprRenderer->damageWindow(m_self.lock());
m_realPosition->setValueAndWarp(Vector2D(LOGICALPOS.x, LOGICALPOS.y)); m_realPosition->setValueAndWarp(Vector2D(LOGICALPOS.x, LOGICALPOS.y));

View file

@ -56,7 +56,7 @@ void IKeyboard::clearManuallyAllocd() {
void IKeyboard::setKeymap(const SStringRuleNames& rules) { void IKeyboard::setKeymap(const SStringRuleNames& rules) {
if (m_keymapOverridden) { if (m_keymapOverridden) {
Debug::log(LOG, "Ignoring setKeymap: keymap is overridden"); Log::logger->log(Log::DEBUG, "Ignoring setKeymap: keymap is overridden");
return; return;
} }
@ -72,20 +72,20 @@ void IKeyboard::setKeymap(const SStringRuleNames& rules) {
const auto CONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS); const auto CONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
if (!CONTEXT) { if (!CONTEXT) {
Debug::log(ERR, "setKeymap: CONTEXT null??"); Log::logger->log(Log::ERR, "setKeymap: CONTEXT null??");
return; return;
} }
clearManuallyAllocd(); clearManuallyAllocd();
Debug::log(LOG, "Attempting to create a keymap for layout {} with variant {} (rules: {}, model: {}, options: {})", rules.layout, rules.variant, rules.rules, rules.model, Log::logger->log(Log::DEBUG, "Attempting to create a keymap for layout {} with variant {} (rules: {}, model: {}, options: {})", rules.layout, rules.variant, rules.rules,
rules.options); rules.model, rules.options);
if (!m_xkbFilePath.empty()) { if (!m_xkbFilePath.empty()) {
auto path = absolutePath(m_xkbFilePath, g_pConfigManager->m_configCurrentPath); auto path = absolutePath(m_xkbFilePath, g_pConfigManager->m_configCurrentPath);
if (FILE* const KEYMAPFILE = fopen(path.c_str(), "r"); !KEYMAPFILE) if (FILE* const KEYMAPFILE = fopen(path.c_str(), "r"); !KEYMAPFILE)
Debug::log(ERR, "Cannot open input:kb_file= file for reading"); Log::logger->log(Log::ERR, "Cannot open input:kb_file= file for reading");
else { else {
m_xkbKeymap = xkb_keymap_new_from_file(CONTEXT, KEYMAPFILE, XKB_KEYMAP_FORMAT_TEXT_V2, XKB_KEYMAP_COMPILE_NO_FLAGS); m_xkbKeymap = xkb_keymap_new_from_file(CONTEXT, KEYMAPFILE, XKB_KEYMAP_FORMAT_TEXT_V2, XKB_KEYMAP_COMPILE_NO_FLAGS);
fclose(KEYMAPFILE); fclose(KEYMAPFILE);
@ -99,8 +99,8 @@ void IKeyboard::setKeymap(const SStringRuleNames& rules) {
g_pConfigManager->addParseError("Invalid keyboard layout passed. ( rules: " + rules.rules + ", model: " + rules.model + ", variant: " + rules.variant + g_pConfigManager->addParseError("Invalid keyboard layout passed. ( rules: " + rules.rules + ", model: " + rules.model + ", variant: " + rules.variant +
", options: " + rules.options + ", layout: " + rules.layout + " )"); ", options: " + rules.options + ", layout: " + rules.layout + " )");
Debug::log(ERR, "Keyboard layout {} with variant {} (rules: {}, model: {}, options: {}) couldn't have been loaded.", rules.layout, rules.variant, rules.rules, rules.model, Log::logger->log(Log::ERR, "Keyboard layout {} with variant {} (rules: {}, model: {}, options: {}) couldn't have been loaded.", rules.layout, rules.variant, rules.rules,
rules.options); rules.model, rules.options);
memset(&XKBRULES, 0, sizeof(XKBRULES)); memset(&XKBRULES, 0, sizeof(XKBRULES));
m_currentRules.rules = ""; m_currentRules.rules = "";
@ -129,12 +129,12 @@ void IKeyboard::setKeymap(const SStringRuleNames& rules) {
for (size_t i = 0; i < std::min(LEDNAMES.size(), m_ledIndexes.size()); ++i) { for (size_t i = 0; i < std::min(LEDNAMES.size(), m_ledIndexes.size()); ++i) {
m_ledIndexes[i] = xkb_map_led_get_index(m_xkbKeymap, LEDNAMES[i]); m_ledIndexes[i] = xkb_map_led_get_index(m_xkbKeymap, LEDNAMES[i]);
Debug::log(LOG, "xkb: LED index {} (name {}) got index {}", i, LEDNAMES[i], m_ledIndexes[i]); Log::logger->log(Log::DEBUG, "xkb: LED index {} (name {}) got index {}", i, LEDNAMES[i], m_ledIndexes[i]);
} }
for (size_t i = 0; i < std::min(MODNAMES.size(), m_modIndexes.size()); ++i) { for (size_t i = 0; i < std::min(MODNAMES.size(), m_modIndexes.size()); ++i) {
m_modIndexes[i] = xkb_map_mod_get_index(m_xkbKeymap, MODNAMES[i]); m_modIndexes[i] = xkb_map_mod_get_index(m_xkbKeymap, MODNAMES[i]);
Debug::log(LOG, "xkb: Mod index {} (name {}) got index {}", i, MODNAMES[i], m_modIndexes[i]); Log::logger->log(Log::DEBUG, "xkb: Mod index {} (name {}) got index {}", i, MODNAMES[i], m_modIndexes[i]);
} }
updateKeymapFD(); updateKeymapFD();
@ -145,7 +145,7 @@ void IKeyboard::setKeymap(const SStringRuleNames& rules) {
} }
void IKeyboard::updateKeymapFD() { void IKeyboard::updateKeymapFD() {
Debug::log(LOG, "Updating keymap fd for keyboard {}", m_deviceName); Log::logger->log(Log::DEBUG, "Updating keymap fd for keyboard {}", m_deviceName);
if (m_xkbKeymapFD.isValid()) if (m_xkbKeymapFD.isValid())
m_xkbKeymapFD.reset(); m_xkbKeymapFD.reset();
@ -162,11 +162,11 @@ void IKeyboard::updateKeymapFD() {
CFileDescriptor rw, ro, rwV1, roV1; CFileDescriptor rw, ro, rwV1, roV1;
if (!allocateSHMFilePair(m_xkbKeymapString.length() + 1, rw, ro)) if (!allocateSHMFilePair(m_xkbKeymapString.length() + 1, rw, ro))
Debug::log(ERR, "IKeyboard: failed to allocate shm pair for the keymap"); Log::logger->log(Log::ERR, "IKeyboard: failed to allocate shm pair for the keymap");
else if (!allocateSHMFilePair(m_xkbKeymapV1String.length() + 1, rwV1, roV1)) { else if (!allocateSHMFilePair(m_xkbKeymapV1String.length() + 1, rwV1, roV1)) {
ro.reset(); ro.reset();
rw.reset(); rw.reset();
Debug::log(ERR, "IKeyboard: failed to allocate shm pair for keymap V1"); Log::logger->log(Log::ERR, "IKeyboard: failed to allocate shm pair for keymap V1");
} else { } else {
auto keymapFDDest = mmap(nullptr, m_xkbKeymapString.length() + 1, PROT_READ | PROT_WRITE, MAP_SHARED, rw.get(), 0); auto keymapFDDest = mmap(nullptr, m_xkbKeymapString.length() + 1, PROT_READ | PROT_WRITE, MAP_SHARED, rw.get(), 0);
auto keymapV1FDDest = mmap(nullptr, m_xkbKeymapV1String.length() + 1, PROT_READ | PROT_WRITE, MAP_SHARED, rwV1.get(), 0); auto keymapV1FDDest = mmap(nullptr, m_xkbKeymapV1String.length() + 1, PROT_READ | PROT_WRITE, MAP_SHARED, rwV1.get(), 0);
@ -174,7 +174,7 @@ void IKeyboard::updateKeymapFD() {
rwV1.reset(); rwV1.reset();
if (keymapFDDest == MAP_FAILED || keymapV1FDDest == MAP_FAILED) { if (keymapFDDest == MAP_FAILED || keymapV1FDDest == MAP_FAILED) {
Debug::log(ERR, "IKeyboard: failed to mmap a shm pair for the keymap"); Log::logger->log(Log::ERR, "IKeyboard: failed to mmap a shm pair for the keymap");
ro.reset(); ro.reset();
roV1.reset(); roV1.reset();
} else { } else {
@ -187,7 +187,7 @@ void IKeyboard::updateKeymapFD() {
} }
} }
Debug::log(LOG, "Updated keymap fd to {}, keymap V1 to: {}", m_xkbKeymapFD.get(), m_xkbKeymapV1FD.get()); Log::logger->log(Log::DEBUG, "Updated keymap fd to {}, keymap V1 to: {}", m_xkbKeymapFD.get(), m_xkbKeymapV1FD.get());
} }
void IKeyboard::updateXKBTranslationState(xkb_keymap* const keymap) { void IKeyboard::updateXKBTranslationState(xkb_keymap* const keymap) {
@ -206,7 +206,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", rc<uintptr_t>(this)); Log::logger->log(Log::DEBUG, "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);
@ -221,7 +221,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 {}", rc<uintptr_t>(this), i); Log::logger->log(Log::DEBUG, "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, ',');
@ -241,14 +241,14 @@ void IKeyboard::updateXKBTranslationState(xkb_keymap* const keymap) {
auto KEYMAP = xkb_keymap_new_from_names2(PCONTEXT, &rules, XKB_KEYMAP_FORMAT_TEXT_V2, XKB_KEYMAP_COMPILE_NO_FLAGS); auto KEYMAP = xkb_keymap_new_from_names2(PCONTEXT, &rules, XKB_KEYMAP_FORMAT_TEXT_V2, XKB_KEYMAP_COMPILE_NO_FLAGS);
if (!KEYMAP) { if (!KEYMAP) {
Debug::log(ERR, "updateXKBTranslationState: keymap failed 1, fallback without model/variant"); Log::logger->log(Log::ERR, "updateXKBTranslationState: keymap failed 1, fallback without model/variant");
rules.model = ""; rules.model = "";
rules.variant = ""; rules.variant = "";
KEYMAP = xkb_keymap_new_from_names2(PCONTEXT, &rules, XKB_KEYMAP_FORMAT_TEXT_V2, XKB_KEYMAP_COMPILE_NO_FLAGS); KEYMAP = xkb_keymap_new_from_names2(PCONTEXT, &rules, XKB_KEYMAP_FORMAT_TEXT_V2, XKB_KEYMAP_COMPILE_NO_FLAGS);
} }
if (!KEYMAP) { if (!KEYMAP) {
Debug::log(ERR, "updateXKBTranslationState: keymap failed 2, fallback to us"); Log::logger->log(Log::ERR, "updateXKBTranslationState: keymap failed 2, fallback to us");
rules.layout = "us"; rules.layout = "us";
KEYMAP = xkb_keymap_new_from_names2(PCONTEXT, &rules, XKB_KEYMAP_FORMAT_TEXT_V2, XKB_KEYMAP_COMPILE_NO_FLAGS); KEYMAP = xkb_keymap_new_from_names2(PCONTEXT, &rules, XKB_KEYMAP_FORMAT_TEXT_V2, XKB_KEYMAP_COMPILE_NO_FLAGS);
} }
@ -264,7 +264,7 @@ void IKeyboard::updateXKBTranslationState(xkb_keymap* const keymap) {
} }
} }
Debug::log(LOG, "Updating keyboard {:x}'s translation state from an unknown index", rc<uintptr_t>(this)); Log::logger->log(Log::DEBUG, "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(),

View file

@ -12,7 +12,7 @@ static std::vector<std::pair<pid_t, WP<CAsyncDialogBox>>> asyncDialogBoxes;
// //
SP<CAsyncDialogBox> CAsyncDialogBox::create(const std::string& title, const std::string& description, std::vector<std::string> buttons) { SP<CAsyncDialogBox> CAsyncDialogBox::create(const std::string& title, const std::string& description, std::vector<std::string> buttons) {
if (!NFsUtils::executableExistsInPath("hyprland-dialog")) { if (!NFsUtils::executableExistsInPath("hyprland-dialog")) {
Debug::log(ERR, "CAsyncDialogBox: cannot create, no hyprland-dialog"); Log::logger->log(Log::ERR, "CAsyncDialogBox: cannot create, no hyprland-dialog");
return nullptr; return nullptr;
} }
@ -63,7 +63,7 @@ void CAsyncDialogBox::onWrite(int fd, uint32_t mask) {
// TODO: can we avoid this without risking a blocking read()? // TODO: can we avoid this without risking a blocking read()?
int fdFlags = fcntl(fd, F_GETFL, 0); int fdFlags = fcntl(fd, F_GETFL, 0);
if (fcntl(fd, F_SETFL, fdFlags | O_NONBLOCK) < 0) { if (fcntl(fd, F_SETFL, fdFlags | O_NONBLOCK) < 0) {
Debug::log(ERR, "CAsyncDialogBox::onWrite: fcntl 1 failed!"); Log::logger->log(Log::ERR, "CAsyncDialogBox::onWrite: fcntl 1 failed!");
return; return;
} }
@ -73,13 +73,13 @@ void CAsyncDialogBox::onWrite(int fd, uint32_t mask) {
// restore the flags (otherwise libwayland won't give us a hangup) // restore the flags (otherwise libwayland won't give us a hangup)
if (fcntl(fd, F_SETFL, fdFlags) < 0) { if (fcntl(fd, F_SETFL, fdFlags) < 0) {
Debug::log(ERR, "CAsyncDialogBox::onWrite: fcntl 2 failed!"); Log::logger->log(Log::ERR, "CAsyncDialogBox::onWrite: fcntl 2 failed!");
return; return;
} }
} }
if (mask & (WL_EVENT_HANGUP | WL_EVENT_ERROR)) { if (mask & (WL_EVENT_HANGUP | WL_EVENT_ERROR)) {
Debug::log(LOG, "CAsyncDialogBox: dialog {:x} hung up, closed."); Log::logger->log(Log::DEBUG, "CAsyncDialogBox: dialog {:x} hung up, closed.");
m_promiseResolver->resolve(m_stdout); m_promiseResolver->resolve(m_stdout);
std::erase_if(asyncDialogBoxes, [this](const auto& e) { return e.first == m_dialogPid; }); std::erase_if(asyncDialogBoxes, [this](const auto& e) { return e.first == m_dialogPid; });
@ -102,7 +102,7 @@ SP<CPromise<std::string>> CAsyncDialogBox::open() {
int outPipe[2]; int outPipe[2];
if (pipe(outPipe)) { if (pipe(outPipe)) {
Debug::log(ERR, "CAsyncDialogBox::open: failed to pipe()"); Log::logger->log(Log::ERR, "CAsyncDialogBox::open: failed to pipe()");
return nullptr; return nullptr;
} }
@ -113,14 +113,14 @@ SP<CPromise<std::string>> CAsyncDialogBox::open() {
m_readEventSource = wl_event_loop_add_fd(g_pEventLoopManager->m_wayland.loop, m_pipeReadFd.get(), WL_EVENT_READABLE, ::onFdWrite, this); m_readEventSource = wl_event_loop_add_fd(g_pEventLoopManager->m_wayland.loop, m_pipeReadFd.get(), WL_EVENT_READABLE, ::onFdWrite, this);
if (!m_readEventSource) { if (!m_readEventSource) {
Debug::log(ERR, "CAsyncDialogBox::open: failed to add read fd to loop"); Log::logger->log(Log::ERR, "CAsyncDialogBox::open: failed to add read fd to loop");
return nullptr; return nullptr;
} }
m_selfReference = m_selfWeakReference.lock(); m_selfReference = m_selfWeakReference.lock();
if (!proc.runAsync()) { if (!proc.runAsync()) {
Debug::log(ERR, "CAsyncDialogBox::open: failed to run async"); Log::logger->log(Log::ERR, "CAsyncDialogBox::open: failed to run async");
wl_event_source_remove(m_readEventSource); wl_event_source_remove(m_readEventSource);
return nullptr; return nullptr;
} }

View file

@ -1,7 +1,7 @@
#include "Format.hpp" #include "Format.hpp"
#include <vector> #include <vector>
#include "../includes.hpp" #include "../includes.hpp"
#include "debug/Log.hpp" #include "debug/log/Logger.hpp"
#include "../macros.hpp" #include "../macros.hpp"
#include <xf86drm.h> #include <xf86drm.h>
#include <drm_fourcc.h> #include <drm_fourcc.h>

View file

@ -19,6 +19,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>
#include <fstream>
#ifdef HAS_EXECINFO #ifdef HAS_EXECINFO
#include <execinfo.h> #include <execinfo.h>
#endif #endif
@ -103,7 +104,7 @@ std::optional<float> getPlusMinusKeywordResult(std::string source, float relativ
try { try {
return relative + stof(source); return relative + stof(source);
} catch (...) { } catch (...) {
Debug::log(ERR, "Invalid arg \"{}\" in getPlusMinusKeywordResult!", source); Log::logger->log(Log::ERR, "Invalid arg \"{}\" in getPlusMinusKeywordResult!", source);
return {}; return {};
} }
} }
@ -148,7 +149,7 @@ SWorkspaceIDName getWorkspaceIDNameFromString(const std::string& in) {
const bool same_mon = in.substr(5).contains("m"); const bool same_mon = in.substr(5).contains("m");
const bool next = in.substr(5).contains("n"); const bool next = in.substr(5).contains("n");
if ((same_mon || next) && !Desktop::focusState()->monitor()) { if ((same_mon || next) && !Desktop::focusState()->monitor()) {
Debug::log(ERR, "Empty monitor workspace on monitor null!"); Log::logger->log(Log::ERR, "Empty monitor workspace on monitor null!");
return {WORKSPACE_INVALID}; return {WORKSPACE_INVALID};
} }
@ -186,14 +187,14 @@ SWorkspaceIDName getWorkspaceIDNameFromString(const std::string& in) {
const auto PLASTWORKSPACE = g_pCompositor->getWorkspaceByID(PREVWORKSPACEIDNAME.id); const auto PLASTWORKSPACE = g_pCompositor->getWorkspaceByID(PREVWORKSPACEIDNAME.id);
if (!PLASTWORKSPACE) { if (!PLASTWORKSPACE) {
Debug::log(LOG, "previous workspace {} doesn't exist yet", PREVWORKSPACEIDNAME.id); Log::logger->log(Log::DEBUG, "previous workspace {} doesn't exist yet", PREVWORKSPACEIDNAME.id);
return {PREVWORKSPACEIDNAME.id, PREVWORKSPACEIDNAME.name}; return {PREVWORKSPACEIDNAME.id, PREVWORKSPACEIDNAME.name};
} }
return {PLASTWORKSPACE->m_id, PLASTWORKSPACE->m_name}; return {PLASTWORKSPACE->m_id, PLASTWORKSPACE->m_name};
} else if (in == "next") { } else if (in == "next") {
if (!Desktop::focusState()->monitor() || !Desktop::focusState()->monitor()->m_activeWorkspace) { if (!Desktop::focusState()->monitor() || !Desktop::focusState()->monitor()->m_activeWorkspace) {
Debug::log(ERR, "no active monitor or workspace for 'next'"); Log::logger->log(Log::ERR, "no active monitor or workspace for 'next'");
return {WORKSPACE_INVALID}; return {WORKSPACE_INVALID};
} }
@ -211,7 +212,7 @@ SWorkspaceIDName getWorkspaceIDNameFromString(const std::string& in) {
if (in[0] == 'r' && (in[1] == '-' || in[1] == '+' || in[1] == '~') && isNumber(in.substr(2))) { if (in[0] == 'r' && (in[1] == '-' || in[1] == '+' || in[1] == '~') && isNumber(in.substr(2))) {
bool absolute = in[1] == '~'; bool absolute = in[1] == '~';
if (!Desktop::focusState()->monitor()) { if (!Desktop::focusState()->monitor()) {
Debug::log(ERR, "Relative monitor workspace on monitor null!"); Log::logger->log(Log::ERR, "Relative monitor workspace on monitor null!");
return {WORKSPACE_INVALID}; return {WORKSPACE_INVALID};
} }
@ -373,7 +374,7 @@ SWorkspaceIDName getWorkspaceIDNameFromString(const std::string& in) {
bool absolute = in[1] == '~'; bool absolute = in[1] == '~';
if (!Desktop::focusState()->monitor()) { if (!Desktop::focusState()->monitor()) {
Debug::log(ERR, "Relative monitor workspace on monitor null!"); Log::logger->log(Log::ERR, "Relative monitor workspace on monitor null!");
return {WORKSPACE_INVALID}; return {WORKSPACE_INVALID};
} }
@ -445,7 +446,7 @@ SWorkspaceIDName getWorkspaceIDNameFromString(const std::string& in) {
result.id = std::max(sc<int>(PLUSMINUSRESULT.value()), 1); result.id = std::max(sc<int>(PLUSMINUSRESULT.value()), 1);
} else { } else {
Debug::log(ERR, "Relative workspace on no mon!"); Log::logger->log(Log::ERR, "Relative workspace on no mon!");
return {WORKSPACE_INVALID}; return {WORKSPACE_INVALID};
} }
} else if (isNumber(in)) } else if (isNumber(in))
@ -524,12 +525,12 @@ void logSystemInfo() {
uname(&unameInfo); uname(&unameInfo);
Debug::log(LOG, "System name: {}", std::string{unameInfo.sysname}); Log::logger->log(Log::DEBUG, "System name: {}", std::string{unameInfo.sysname});
Debug::log(LOG, "Node name: {}", std::string{unameInfo.nodename}); Log::logger->log(Log::DEBUG, "Node name: {}", std::string{unameInfo.nodename});
Debug::log(LOG, "Release: {}", std::string{unameInfo.release}); Log::logger->log(Log::DEBUG, "Release: {}", std::string{unameInfo.release});
Debug::log(LOG, "Version: {}", std::string{unameInfo.version}); Log::logger->log(Log::DEBUG, "Version: {}", std::string{unameInfo.version});
Debug::log(NONE, "\n"); Log::logger->log(Log::DEBUG, "\n");
#if defined(__DragonFly__) || defined(__FreeBSD__) #if defined(__DragonFly__) || defined(__FreeBSD__)
const std::string GPUINFO = execAndGet("pciconf -lv | grep -F -A4 vga"); const std::string GPUINFO = execAndGet("pciconf -lv | grep -F -A4 vga");
@ -555,16 +556,16 @@ void logSystemInfo() {
#else #else
const std::string GPUINFO = execAndGet("lspci -vnn | grep -E '(VGA|Display|3D)'"); const std::string GPUINFO = execAndGet("lspci -vnn | grep -E '(VGA|Display|3D)'");
#endif #endif
Debug::log(LOG, "GPU information:\n{}\n", GPUINFO); Log::logger->log(Log::DEBUG, "GPU information:\n{}\n", GPUINFO);
if (GPUINFO.contains("NVIDIA")) { if (GPUINFO.contains("NVIDIA")) {
Debug::log(WARN, "Warning: you're using an NVIDIA GPU. Make sure you follow the instructions on the wiki if anything is amiss.\n"); Log::logger->log(Log::WARN, "Warning: you're using an NVIDIA GPU. Make sure you follow the instructions on the wiki if anything is amiss.\n");
} }
// log etc // log etc
Debug::log(LOG, "os-release:"); Log::logger->log(Log::DEBUG, "os-release:");
Debug::log(NONE, "{}", NFsUtils::readFileAsString("/etc/os-release").value_or("error")); Log::logger->log(Log::DEBUG, "{}", NFsUtils::readFileAsString("/etc/os-release").value_or("error"));
} }
int64_t getPPIDof(int64_t pid) { int64_t getPPIDof(int64_t pid) {
@ -767,17 +768,10 @@ std::vector<SCallstackFrameInfo> getBacktrace() {
} }
void throwError(const std::string& err) { void throwError(const std::string& err) {
Debug::log(CRIT, "Critical error thrown: {}", err); Log::logger->log(Log::CRIT, "Critical error thrown: {}", err);
throw std::runtime_error(err); throw std::runtime_error(err);
} }
bool envEnabled(const std::string& env) {
const auto ENV = getenv(env.c_str());
if (!ENV)
return false;
return std::string(ENV) == "1";
}
std::pair<CFileDescriptor, std::string> openExclusiveShm() { std::pair<CFileDescriptor, std::string> openExclusiveShm() {
// Only absolute paths can be shared across different shm_open() calls // Only absolute paths can be shared across different shm_open() calls
std::string name = "/" + g_pTokenManager->getRandomUUID(); std::string name = "/" + g_pTokenManager->getRandomUUID();
@ -872,7 +866,7 @@ bool isNvidiaDriverVersionAtLeast(int threshold) {
if (firstDot != std::string::npos) if (firstDot != std::string::npos)
driverMajor = std::stoi(driverInfo.substr(0, firstDot)); driverMajor = std::stoi(driverInfo.substr(0, firstDot));
Debug::log(LOG, "Parsed NVIDIA major version: {}", driverMajor); Log::logger->log(Log::DEBUG, "Parsed NVIDIA major version: {}", driverMajor);
} catch (std::exception& e) { } catch (std::exception& e) {
driverMajor = 0; // Default to 0 if parsing fails driverMajor = 0; // Default to 0 if parsing fails

View file

@ -36,7 +36,6 @@ std::optional<float> getPlusMinusKeywordResult(std::string in
double normalizeAngleRad(double ang); double normalizeAngleRad(double ang);
std::vector<SCallstackFrameInfo> getBacktrace(); std::vector<SCallstackFrameInfo> getBacktrace();
void throwError(const std::string& err); void throwError(const std::string& err);
bool envEnabled(const std::string& env);
Hyprutils::OS::CFileDescriptor allocateSHMFile(size_t len); Hyprutils::OS::CFileDescriptor allocateSHMFile(size_t len);
bool allocateSHMFilePair(size_t size, Hyprutils::OS::CFileDescriptor& rw_fd_ptr, Hyprutils::OS::CFileDescriptor& ro_fd_ptr); bool allocateSHMFilePair(size_t size, Hyprutils::OS::CFileDescriptor& rw_fd_ptr, Hyprutils::OS::CFileDescriptor& ro_fd_ptr);
float stringToPercentage(const std::string& VALUE, const float REL); float stringToPercentage(const std::string& VALUE, const float REL);

View file

@ -33,7 +33,7 @@
#include "../desktop/view/LayerSurface.hpp" #include "../desktop/view/LayerSurface.hpp"
#include "../desktop/state/FocusState.hpp" #include "../desktop/state/FocusState.hpp"
#include <aquamarine/output/Output.hpp> #include <aquamarine/output/Output.hpp>
#include "debug/Log.hpp" #include "debug/log/Logger.hpp"
#include "debug/HyprNotificationOverlay.hpp" #include "debug/HyprNotificationOverlay.hpp"
#include "MonitorFrameScheduler.hpp" #include "MonitorFrameScheduler.hpp"
#include <hyprutils/string/String.hpp> #include <hyprutils/string/String.hpp>
@ -146,14 +146,14 @@ void CMonitor::onConnect(bool noRule) {
}); });
m_listeners.destroy = m_output->events.destroy.listen([this] { m_listeners.destroy = m_output->events.destroy.listen([this] {
Debug::log(LOG, "Destroy called for monitor {}", m_name); Log::logger->log(Log::DEBUG, "Destroy called for monitor {}", m_name);
onDisconnect(true); onDisconnect(true);
m_output = nullptr; m_output = nullptr;
m_renderingInitPassed = false; m_renderingInitPassed = false;
Debug::log(LOG, "Removing monitor {} from realMonitors", m_name); Log::logger->log(Log::DEBUG, "Removing monitor {} from realMonitors", m_name);
std::erase_if(g_pCompositor->m_realMonitors, [&](PHLMONITOR& el) { return el.get() == this; }); std::erase_if(g_pCompositor->m_realMonitors, [&](PHLMONITOR& el) { return el.get() == this; });
}); });
@ -165,7 +165,7 @@ void CMonitor::onConnect(bool noRule) {
if (m_createdByUser) if (m_createdByUser)
return; return;
Debug::log(LOG, "Reapplying monitor rule for {} from a state request", m_name); Log::logger->log(Log::DEBUG, "Reapplying monitor rule for {} from a state request", m_name);
applyMonitorRule(&m_activeMonitorRule, true); applyMonitorRule(&m_activeMonitorRule, true);
return; return;
} }
@ -224,7 +224,7 @@ void CMonitor::onConnect(bool noRule) {
m_output->state->setEnabled(false); m_output->state->setEnabled(false);
if (!m_state.commit()) if (!m_state.commit())
Debug::log(ERR, "Couldn't commit disabled state on output {}", m_output->name); Log::logger->log(Log::ERR, "Couldn't commit disabled state on output {}", m_output->name);
m_enabled = false; m_enabled = false;
@ -233,7 +233,7 @@ void CMonitor::onConnect(bool noRule) {
} }
if (m_output->nonDesktop) { if (m_output->nonDesktop) {
Debug::log(LOG, "Not configuring non-desktop output"); Log::logger->log(Log::DEBUG, "Not configuring non-desktop output");
for (auto& [name, lease] : PROTO::lease) { for (auto& [name, lease] : PROTO::lease) {
if (!lease || m_output->getBackend() != lease->getBackend()) if (!lease || m_output->getBackend() != lease->getBackend())
@ -270,11 +270,11 @@ void CMonitor::onConnect(bool noRule) {
applyMonitorRule(&monitorRule, true); applyMonitorRule(&monitorRule, true);
if (!m_state.commit()) if (!m_state.commit())
Debug::log(WARN, "state.commit() failed in CMonitor::onCommit"); Log::logger->log(Log::WARN, "state.commit() failed in CMonitor::onCommit");
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, rc<uintptr_t>(m_output.get())); Log::logger->log(Log::DEBUG, "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);
@ -317,18 +317,18 @@ void CMonitor::onConnect(bool noRule) {
} }
} }
Debug::log(LOG, "checking if we have seen this monitor before: {}", m_name); Log::logger->log(Log::DEBUG, "checking if we have seen this monitor before: {}", m_name);
// if we saw this monitor before, set it to the workspace it was on // if we saw this monitor before, set it to the workspace it was on
if (g_pCompositor->m_seenMonitorWorkspaceMap.contains(m_name)) { if (g_pCompositor->m_seenMonitorWorkspaceMap.contains(m_name)) {
auto workspaceID = g_pCompositor->m_seenMonitorWorkspaceMap[m_name]; auto workspaceID = g_pCompositor->m_seenMonitorWorkspaceMap[m_name];
Debug::log(LOG, "Monitor {} was on workspace {}, setting it to that", m_name, workspaceID); Log::logger->log(Log::DEBUG, "Monitor {} was on workspace {}, setting it to that", m_name, workspaceID);
auto ws = g_pCompositor->getWorkspaceByID(workspaceID); auto ws = g_pCompositor->getWorkspaceByID(workspaceID);
if (ws) { if (ws) {
g_pCompositor->moveWorkspaceToMonitor(ws, m_self.lock()); g_pCompositor->moveWorkspaceToMonitor(ws, m_self.lock());
changeWorkspace(ws, true, false, false); changeWorkspace(ws, true, false, false);
} }
} else } else
Debug::log(LOG, "Monitor {} was not on any workspace", m_name); Log::logger->log(Log::DEBUG, "Monitor {} was not on any workspace", m_name);
if (!found) if (!found)
Desktop::focusState()->rawMonitorFocus(m_self.lock()); Desktop::focusState()->rawMonitorFocus(m_self.lock());
@ -360,7 +360,7 @@ void CMonitor::onDisconnect(bool destroy) {
if (!m_enabled || g_pCompositor->m_isShuttingDown) if (!m_enabled || g_pCompositor->m_isShuttingDown)
return; return;
Debug::log(LOG, "onDisconnect called for {}", m_output->name); Log::logger->log(Log::DEBUG, "onDisconnect called for {}", m_output->name);
m_events.disconnect.emit(); m_events.disconnect.emit();
if (g_pHyprOpenGL) if (g_pHyprOpenGL)
@ -368,7 +368,7 @@ void CMonitor::onDisconnect(bool destroy) {
// record what workspace this monitor was on // record what workspace this monitor was on
if (m_activeWorkspace) { if (m_activeWorkspace) {
Debug::log(LOG, "Disconnecting Monitor {} was on workspace {}", m_name, m_activeWorkspace->m_id); Log::logger->log(Log::DEBUG, "Disconnecting Monitor {} was on workspace {}", m_name, m_activeWorkspace->m_id);
g_pCompositor->m_seenMonitorWorkspaceMap[m_name] = m_activeWorkspace->m_id; g_pCompositor->m_seenMonitorWorkspaceMap[m_name] = m_activeWorkspace->m_id;
} }
@ -412,10 +412,10 @@ void CMonitor::onDisconnect(bool destroy) {
} }
std::erase_if(g_pCompositor->m_monitors, [&](PHLMONITOR& el) { return el.get() == this; }); std::erase_if(g_pCompositor->m_monitors, [&](PHLMONITOR& el) { return el.get() == this; });
Debug::log(LOG, "Removed monitor {}!", m_name); Log::logger->log(Log::DEBUG, "Removed monitor {}!", m_name);
if (!BACKUPMON) { if (!BACKUPMON) {
Debug::log(WARN, "Unplugged last monitor, entering an unsafe state. Good luck my friend."); Log::logger->log(Log::WARN, "Unplugged last monitor, entering an unsafe state. Good luck my friend.");
g_pCompositor->enterUnsafeState(); g_pCompositor->enterUnsafeState();
} }
@ -453,7 +453,7 @@ void CMonitor::onDisconnect(bool destroy) {
m_output->state->setEnabled(false); m_output->state->setEnabled(false);
if (!m_state.commit()) if (!m_state.commit())
Debug::log(WARN, "state.commit() failed in CMonitor::onDisconnect"); Log::logger->log(Log::WARN, "state.commit() failed in CMonitor::onDisconnect");
if (Desktop::focusState()->monitor() == m_self) if (Desktop::focusState()->monitor() == m_self)
Desktop::focusState()->rawMonitorFocus(BACKUPMON ? BACKUPMON : g_pCompositor->m_unsafeOutput.lock()); Desktop::focusState()->rawMonitorFocus(BACKUPMON ? BACKUPMON : g_pCompositor->m_unsafeOutput.lock());
@ -560,7 +560,7 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
static auto PDISABLESCALECHECKS = CConfigValue<Hyprlang::INT>("debug:disable_scale_checks"); static auto PDISABLESCALECHECKS = CConfigValue<Hyprlang::INT>("debug:disable_scale_checks");
Debug::log(LOG, "Applying monitor rule for {}", m_name); Log::logger->log(Log::DEBUG, "Applying monitor rule for {}", m_name);
m_activeMonitorRule = *pMonitorRule; m_activeMonitorRule = *pMonitorRule;
@ -585,7 +585,7 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
if (!m_enabled) { if (!m_enabled) {
onConnect(true); // enable it. onConnect(true); // enable it.
Debug::log(LOG, "Monitor {} is disabled but is requested to be enabled", m_name); Log::logger->log(Log::DEBUG, "Monitor {} is disabled but is requested to be enabled", m_name);
force = true; force = true;
} }
@ -605,7 +605,7 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
RULE->supportsWideColor == m_supportsWideColor && RULE->supportsHDR == m_supportsHDR && RULE->minLuminance == m_minLuminance && RULE->maxLuminance == m_maxLuminance && RULE->supportsWideColor == m_supportsWideColor && RULE->supportsHDR == m_supportsHDR && RULE->minLuminance == m_minLuminance && RULE->maxLuminance == m_maxLuminance &&
RULE->maxAvgLuminance == m_maxAvgLuminance && !std::memcmp(&m_customDrmMode, &RULE->drmMode, sizeof(m_customDrmMode)) && m_reservedArea == RULE->reservedArea) { RULE->maxAvgLuminance == m_maxAvgLuminance && !std::memcmp(&m_customDrmMode, &RULE->drmMode, sizeof(m_customDrmMode)) && m_reservedArea == RULE->reservedArea) {
Debug::log(LOG, "Not applying a new rule to {} because it's already applied!", m_name); Log::logger->log(Log::DEBUG, "Not applying a new rule to {} because it's already applied!", m_name);
setMirror(RULE->mirrorOf); setMirror(RULE->mirrorOf);
@ -642,7 +642,7 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
// last fallback is always preferred mode // last fallback is always preferred mode
if (!m_output->preferredMode()) if (!m_output->preferredMode())
Debug::log(ERR, "Monitor {} has NO PREFERRED MODE", m_output->name); Log::logger->log(Log::ERR, "Monitor {} has NO PREFERRED MODE", m_output->name);
else else
requestedModes.push_back(m_output->preferredMode()); requestedModes.push_back(m_output->preferredMode());
@ -717,7 +717,7 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
// then if requested is custom, try custom mode first // then if requested is custom, try custom mode first
if (RULE->drmMode.type == DRM_MODE_TYPE_USERDEF) { if (RULE->drmMode.type == DRM_MODE_TYPE_USERDEF) {
if (m_output->getBackend()->type() != Aquamarine::eBackendType::AQ_BACKEND_DRM) if (m_output->getBackend()->type() != Aquamarine::eBackendType::AQ_BACKEND_DRM)
Debug::log(ERR, "Tried to set custom modeline on non-DRM output"); Log::logger->log(Log::ERR, "Tried to set custom modeline on non-DRM output");
else else
requestedModes.push_back(makeShared<Aquamarine::SOutputMode>( requestedModes.push_back(makeShared<Aquamarine::SOutputMode>(
Aquamarine::SOutputMode{.pixelSize = {RULE->drmMode.hdisplay, RULE->drmMode.vdisplay}, .refreshRate = RULE->drmMode.vrefresh, .modeInfo = RULE->drmMode})); Aquamarine::SOutputMode{.pixelSize = {RULE->drmMode.hdisplay, RULE->drmMode.vdisplay}, .refreshRate = RULE->drmMode.vrefresh, .modeInfo = RULE->drmMode}));
@ -737,13 +737,13 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
m_drmFormat = DRM_FORMAT_XRGB8888; m_drmFormat = DRM_FORMAT_XRGB8888;
m_output->state->resetExplicitFences(); m_output->state->resetExplicitFences();
if (Debug::m_trace) { if (Env::isTrace()) {
Debug::log(TRACE, "Monitor {} requested modes:", m_name); Log::logger->log(Log::TRACE, "Monitor {} requested modes:", m_name);
if (requestedModes.empty()) if (requestedModes.empty())
Debug::log(TRACE, "| None"); Log::logger->log(Log::TRACE, "| None");
else { else {
for (auto const& mode : requestedModes | std::views::reverse) { for (auto const& mode : requestedModes | std::views::reverse) {
Debug::log(TRACE, "| {:X0}@{:.2f}Hz", mode->pixelSize, mode->refreshRate / 1000.f); Log::logger->log(Log::TRACE, "| {:X0}@{:.2f}Hz", mode->pixelSize, mode->refreshRate / 1000.f);
} }
} }
} }
@ -755,7 +755,7 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
m_output->state->setCustomMode(mode); m_output->state->setCustomMode(mode);
if (!m_state.test()) { if (!m_state.test()) {
Debug::log(ERR, "Monitor {}: REJECTED custom mode {}!", m_name, modeStr); Log::logger->log(Log::ERR, "Monitor {}: REJECTED custom mode {}!", m_name, modeStr);
continue; continue;
} }
@ -764,9 +764,9 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
m_output->state->setMode(mode); m_output->state->setMode(mode);
if (!m_state.test()) { if (!m_state.test()) {
Debug::log(ERR, "Monitor {}: REJECTED available mode {}!", m_name, modeStr); Log::logger->log(Log::ERR, "Monitor {}: REJECTED available mode {}!", m_name, modeStr);
if (mode->preferred) if (mode->preferred)
Debug::log(ERR, "Monitor {}: REJECTED preferred mode!!!", m_name); Log::logger->log(Log::ERR, "Monitor {}: REJECTED preferred mode!!!", m_name);
continue; continue;
} }
@ -780,11 +780,11 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
success = true; success = true;
if (mode->preferred) if (mode->preferred)
Debug::log(LOG, "Monitor {}: requested {}, using preferred mode {}", m_name, requestedStr, modeStr); Log::logger->log(Log::DEBUG, "Monitor {}: requested {}, using preferred mode {}", m_name, requestedStr, modeStr);
else if (mode->modeInfo.has_value() && mode->modeInfo->type == DRM_MODE_TYPE_USERDEF) else if (mode->modeInfo.has_value() && mode->modeInfo->type == DRM_MODE_TYPE_USERDEF)
Debug::log(LOG, "Monitor {}: requested {}, using custom mode {}", m_name, requestedStr, modeStr); Log::logger->log(Log::DEBUG, "Monitor {}: requested {}, using custom mode {}", m_name, requestedStr, modeStr);
else else
Debug::log(LOG, "Monitor {}: requested {}, using available mode {}", m_name, requestedStr, modeStr); Log::logger->log(Log::DEBUG, "Monitor {}: requested {}, using available mode {}", m_name, requestedStr, modeStr);
break; break;
} }
@ -798,7 +798,7 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
m_output->state->setCustomMode(mode); m_output->state->setCustomMode(mode);
if (m_state.test()) { if (m_state.test()) {
Debug::log(LOG, "Monitor {}: requested {}, using custom mode {}", m_name, requestedStr, modeStr); Log::logger->log(Log::DEBUG, "Monitor {}: requested {}, using custom mode {}", m_name, requestedStr, modeStr);
refreshRate = mode->refreshRate / 1000.f; refreshRate = mode->refreshRate / 1000.f;
m_size = mode->pixelSize; m_size = mode->pixelSize;
@ -807,7 +807,7 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
success = true; success = true;
} else } else
Debug::log(ERR, "Monitor {}: REJECTED custom mode {}!", m_name, modeStr); Log::logger->log(Log::ERR, "Monitor {}: REJECTED custom mode {}!", m_name, modeStr);
} }
// try any of the modes if none of the above work // try any of the modes if none of the above work
@ -820,7 +820,7 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
auto errorMessage = I18n::i18nEngine()->localize(I18n::TXT_KEY_NOTIF_MONITOR_MODE_FAIL, auto errorMessage = I18n::i18nEngine()->localize(I18n::TXT_KEY_NOTIF_MONITOR_MODE_FAIL,
{{"name", m_name}, {"mode", std::format("{:X0}@{:.2f}Hz", mode->pixelSize, mode->refreshRate / 1000.f)}}); {{"name", m_name}, {"mode", std::format("{:X0}@{:.2f}Hz", mode->pixelSize, mode->refreshRate / 1000.f)}});
Debug::log(WARN, errorMessage); Log::logger->log(Log::WARN, errorMessage);
g_pHyprNotificationOverlay->addNotification(errorMessage, CHyprColor(0xff0000ff), 5000, ICON_WARNING); g_pHyprNotificationOverlay->addNotification(errorMessage, CHyprColor(0xff0000ff), 5000, ICON_WARNING);
m_refreshRate = mode->refreshRate / 1000.f; m_refreshRate = mode->refreshRate / 1000.f;
@ -835,7 +835,7 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
} }
if (!success) { if (!success) {
Debug::log(ERR, "Monitor {} has NO FALLBACK MODES, and an INVALID one was requested: {:X0}@{:.2f}Hz", m_name, RULE->resolution, RULE->refreshRate); Log::logger->log(Log::ERR, "Monitor {} has NO FALLBACK MODES, and an INVALID one was requested: {:X0}@{:.2f}Hz", m_name, RULE->resolution, RULE->refreshRate);
return true; return true;
} }
@ -863,9 +863,9 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
m_drmFormat = fmt.second; m_drmFormat = fmt.second;
if (!m_state.test()) { if (!m_state.test()) {
Debug::log(ERR, "output {} failed basic test on format {}", m_name, fmt.first); Log::logger->log(Log::ERR, "output {} failed basic test on format {}", m_name, fmt.first);
} else { } else {
Debug::log(LOG, "output {} succeeded basic test on format {}", m_name, fmt.first); Log::logger->log(Log::DEBUG, "output {} succeeded basic test on format {}", m_name, fmt.first);
if (RULE->enable10bit && fmt.first.contains("101010")) if (RULE->enable10bit && fmt.first.contains("101010"))
set10bit = true; set10bit = true;
break; break;
@ -937,13 +937,13 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
if (autoScale) if (autoScale)
m_scale = std::round(scaleZero); m_scale = std::round(scaleZero);
else { else {
Debug::log(ERR, "Invalid scale passed to monitor, {} failed to find a clean divisor", m_scale); Log::logger->log(Log::ERR, "Invalid scale passed to monitor, {} failed to find a clean divisor", m_scale);
g_pConfigManager->addParseError("Invalid scale passed to monitor " + m_name + ", failed to find a clean divisor"); g_pConfigManager->addParseError("Invalid scale passed to monitor " + m_name + ", failed to find a clean divisor");
m_scale = getDefaultScale(); m_scale = getDefaultScale();
} }
} else { } else {
if (!autoScale) { if (!autoScale) {
Debug::log(ERR, "Invalid scale passed to monitor, {} found suggestion {}", m_scale, searchScale); Log::logger->log(Log::ERR, "Invalid scale passed to monitor, {} found suggestion {}", m_scale, searchScale);
static auto PDISABLENOTIFICATION = CConfigValue<Hyprlang::INT>("misc:disable_scale_notification"); static auto PDISABLENOTIFICATION = CConfigValue<Hyprlang::INT>("misc:disable_scale_notification");
if (!*PDISABLENOTIFICATION) if (!*PDISABLENOTIFICATION)
g_pHyprNotificationOverlay->addNotification( g_pHyprNotificationOverlay->addNotification(
@ -959,7 +959,7 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
m_output->scheduleFrame(); m_output->scheduleFrame();
if (!m_state.commit()) if (!m_state.commit())
Debug::log(ERR, "Couldn't commit output named {}", m_output->name); Log::logger->log(Log::ERR, "Couldn't commit output named {}", m_output->name);
Vector2D xfmd = m_transform % 2 == 1 ? Vector2D{m_pixelSize.y, m_pixelSize.x} : m_pixelSize; Vector2D xfmd = m_transform % 2 == 1 ? Vector2D{m_pixelSize.y, m_pixelSize.x} : m_pixelSize;
m_size = (xfmd / m_scale).round(); m_size = (xfmd / m_scale).round();
@ -994,8 +994,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, sc<int>(m_transform), Log::logger->log(Log::DEBUG, "Monitor {} data dump: res {:X}@{:.2f}Hz, scale {:.2f}, transform {}, pos {:X}, 10b {}", m_name, m_pixelSize, m_refreshRate, m_scale,
m_position, sc<int>(m_enabled10bit)); sc<int>(m_transform), m_position, sc<int>(m_enabled10bit));
EMIT_HOOK_EVENT("monitorLayoutChanged", nullptr); EMIT_HOOK_EVENT("monitorLayoutChanged", nullptr);
@ -1090,12 +1090,12 @@ void CMonitor::setupDefaultWS(const SMonitorRule& monitorRule) {
wsID = std::ranges::distance(g_pCompositor->getWorkspaces()) + 1; wsID = std::ranges::distance(g_pCompositor->getWorkspaces()) + 1;
newDefaultWorkspaceName = std::to_string(wsID); newDefaultWorkspaceName = std::to_string(wsID);
Debug::log(LOG, "Invalid workspace= directive name in monitor parsing, workspace name \"{}\" is invalid.", g_pConfigManager->getDefaultWorkspaceFor(m_name)); Log::logger->log(Log::DEBUG, "Invalid workspace= directive name in monitor parsing, workspace name \"{}\" is invalid.", g_pConfigManager->getDefaultWorkspaceFor(m_name));
} }
auto PNEWWORKSPACE = g_pCompositor->getWorkspaceByID(wsID); auto PNEWWORKSPACE = g_pCompositor->getWorkspaceByID(wsID);
Debug::log(LOG, "New monitor: WORKSPACEID {}, exists: {}", wsID, sc<int>(PNEWWORKSPACE != nullptr)); Log::logger->log(Log::DEBUG, "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
@ -1124,12 +1124,12 @@ void CMonitor::setMirror(const std::string& mirrorOf) {
return; return;
if (PMIRRORMON && PMIRRORMON->isMirror()) { if (PMIRRORMON && PMIRRORMON->isMirror()) {
Debug::log(ERR, "Cannot mirror a mirror!"); Log::logger->log(Log::ERR, "Cannot mirror a mirror!");
return; return;
} }
if (PMIRRORMON == m_self) { if (PMIRRORMON == m_self) {
Debug::log(ERR, "Cannot mirror self!"); Log::logger->log(Log::ERR, "Cannot mirror self!");
return; return;
} }
@ -1257,7 +1257,7 @@ void CMonitor::changeWorkspace(const PHLWORKSPACE& pWorkspace, bool internal, bo
if (pWorkspace->m_isSpecialWorkspace) { if (pWorkspace->m_isSpecialWorkspace) {
if (m_activeSpecialWorkspace != pWorkspace) { if (m_activeSpecialWorkspace != pWorkspace) {
Debug::log(LOG, "changeworkspace on special, togglespecialworkspace to id {}", pWorkspace->m_id); Log::logger->log(Log::DEBUG, "changeworkspace on special, togglespecialworkspace to id {}", pWorkspace->m_id);
setSpecialWorkspace(pWorkspace); setSpecialWorkspace(pWorkspace);
} }
return; return;
@ -1693,7 +1693,7 @@ uint8_t CMonitor::isTearingBlocked(bool full) {
if (!*PTEARINGENABLED) { if (!*PTEARINGENABLED) {
reasons |= TC_USER; reasons |= TC_USER;
if (!full) { if (!full) {
Debug::log(WARN, "Tearing commit requested but the master switch general:allow_tearing is off, ignoring"); Log::logger->log(Log::WARN, "Tearing commit requested but the master switch general:allow_tearing is off, ignoring");
return reasons; return reasons;
} }
} }
@ -1701,7 +1701,7 @@ uint8_t CMonitor::isTearingBlocked(bool full) {
if (g_pHyprOpenGL->m_renderData.mouseZoomFactor != 1.0) { if (g_pHyprOpenGL->m_renderData.mouseZoomFactor != 1.0) {
reasons |= TC_ZOOM; reasons |= TC_ZOOM;
if (!full) { if (!full) {
Debug::log(WARN, "Tearing commit requested but scale factor is not 1, ignoring"); Log::logger->log(Log::WARN, "Tearing commit requested but scale factor is not 1, ignoring");
return reasons; return reasons;
} }
} }
@ -1709,7 +1709,7 @@ uint8_t CMonitor::isTearingBlocked(bool full) {
if (!m_tearingState.canTear) { if (!m_tearingState.canTear) {
reasons |= TC_SUPPORT; reasons |= TC_SUPPORT;
if (!full) { if (!full) {
Debug::log(WARN, "Tearing commit requested but monitor doesn't support it, ignoring"); Log::logger->log(Log::WARN, "Tearing commit requested but monitor doesn't support it, ignoring");
return reasons; return reasons;
} }
} }
@ -1821,7 +1821,7 @@ bool CMonitor::attemptDirectScanout() {
const auto PSURFACE = PCANDIDATE->getSolitaryResource(); const auto PSURFACE = PCANDIDATE->getSolitaryResource();
const auto params = PSURFACE->m_current.buffer->dmabuf(); const auto params = PSURFACE->m_current.buffer->dmabuf();
Debug::log(TRACE, "attemptDirectScanout: surface {:x} passed, will attempt, buffer {} fmt: {} -> {} (mod {})", rc<uintptr_t>(PSURFACE.get()), Log::logger->log(Log::TRACE, "attemptDirectScanout: surface {:x} passed, will attempt, buffer {} fmt: {} -> {} (mod {})", rc<uintptr_t>(PSURFACE.get()),
rc<uintptr_t>(PSURFACE->m_current.buffer.m_buffer.get()), m_drmFormat, params.format, params.modifier); rc<uintptr_t>(PSURFACE->m_current.buffer.m_buffer.get()), m_drmFormat, params.format, params.modifier);
auto PBUFFER = PSURFACE->m_current.buffer.m_buffer; auto PBUFFER = PSURFACE->m_current.buffer.m_buffer;
@ -1832,12 +1832,12 @@ bool CMonitor::attemptDirectScanout() {
if (m_scanoutNeedsCursorUpdate) { if (m_scanoutNeedsCursorUpdate) {
if (!m_state.test()) { if (!m_state.test()) {
Debug::log(TRACE, "attemptDirectScanout: failed basic test on cursor update"); Log::logger->log(Log::TRACE, "attemptDirectScanout: failed basic test on cursor update");
return false; return false;
} }
if (!m_output->commit()) { if (!m_output->commit()) {
Debug::log(TRACE, "attemptDirectScanout: failed to commit cursor update"); Log::logger->log(Log::TRACE, "attemptDirectScanout: failed to commit cursor update");
m_lastScanout.reset(); m_lastScanout.reset();
return false; return false;
} }
@ -1865,12 +1865,12 @@ bool CMonitor::attemptDirectScanout() {
} }
m_output->state->setBuffer(PBUFFER); m_output->state->setBuffer(PBUFFER);
Debug::log(TRACE, "attemptDirectScanout: setting presentation mode"); Log::logger->log(Log::TRACE, "attemptDirectScanout: setting presentation mode");
m_output->state->setPresentationMode(m_tearingState.activelyTearing ? Aquamarine::eOutputPresentationMode::AQ_OUTPUT_PRESENTATION_IMMEDIATE : m_output->state->setPresentationMode(m_tearingState.activelyTearing ? Aquamarine::eOutputPresentationMode::AQ_OUTPUT_PRESENTATION_IMMEDIATE :
Aquamarine::eOutputPresentationMode::AQ_OUTPUT_PRESENTATION_VSYNC); Aquamarine::eOutputPresentationMode::AQ_OUTPUT_PRESENTATION_VSYNC);
if (!m_state.test()) { if (!m_state.test()) {
Debug::log(TRACE, "attemptDirectScanout: failed basic test"); Log::logger->log(Log::TRACE, "attemptDirectScanout: failed basic test");
return false; return false;
} }
@ -1884,14 +1884,14 @@ bool CMonitor::attemptDirectScanout() {
bool ok = m_output->commit(); bool ok = m_output->commit();
if (!ok) { if (!ok) {
Debug::log(TRACE, "attemptDirectScanout: failed to scanout surface"); Log::logger->log(Log::TRACE, "attemptDirectScanout: failed to scanout surface");
m_lastScanout.reset(); m_lastScanout.reset();
return false; return false;
} }
if (m_lastScanout.expired()) { if (m_lastScanout.expired()) {
m_lastScanout = PCANDIDATE; m_lastScanout = PCANDIDATE;
Debug::log(LOG, "Entered a direct scanout to {:x}: \"{}\"", rc<uintptr_t>(PCANDIDATE.get()), PCANDIDATE->m_title); Log::logger->log(Log::DEBUG, "Entered a direct scanout to {:x}: \"{}\"", rc<uintptr_t>(PCANDIDATE.get()), PCANDIDATE->m_title);
} }
m_scanoutNeedsCursorUpdate = false; m_scanoutNeedsCursorUpdate = false;
@ -1947,7 +1947,7 @@ void CMonitor::commitDPMSState(bool state) {
m_output->state->setEnabled(state); m_output->state->setEnabled(state);
if (!m_state.commit()) { if (!m_state.commit()) {
Debug::log(ERR, "Couldn't commit output {} for DPMS = {}, will retry.", m_name, state); Log::logger->log(Log::ERR, "Couldn't commit output {} for DPMS = {}, will retry.", m_name, state);
// retry in 2 frames. This could happen when the DRM backend rejects our commit // retry in 2 frames. This could happen when the DRM backend rejects our commit
// because disable + enable were sent almost instantly // because disable + enable were sent almost instantly
@ -1961,7 +1961,7 @@ void CMonitor::commitDPMSState(bool state) {
m_output->state->resetExplicitFences(); m_output->state->resetExplicitFences();
m_output->state->setEnabled(m_dpmsStatus); m_output->state->setEnabled(m_dpmsStatus);
if (!m_state.commit()) { if (!m_state.commit()) {
Debug::log(ERR, "Couldn't retry committing output {} for DPMS = {}", m_name, m_dpmsStatus); Log::logger->log(Log::ERR, "Couldn't retry committing output {} for DPMS = {}", m_name, m_dpmsStatus);
return; return;
} }
@ -1978,7 +1978,7 @@ void CMonitor::commitDPMSState(bool state) {
} }
void CMonitor::debugLastPresentation(const std::string& message) { void CMonitor::debugLastPresentation(const std::string& message) {
Debug::log(TRACE, "{} (last presentation {} - {} fps)", message, m_lastPresentationTimer.getMillis(), Log::logger->log(Log::TRACE, "{} (last presentation {} - {} fps)", message, m_lastPresentationTimer.getMillis(),
m_lastPresentationTimer.getMillis() > 0 ? 1000.0f / m_lastPresentationTimer.getMillis() : 0.0f); m_lastPresentationTimer.getMillis() > 0 ? 1000.0f / m_lastPresentationTimer.getMillis() : 0.0f);
} }
@ -1991,7 +1991,7 @@ void CMonitor::onCursorMovedOnMonitor() {
// output->state->addDamage(CRegion{}); // output->state->addDamage(CRegion{});
// output->state->setPresentationMode(Aquamarine::eOutputPresentationMode::AQ_OUTPUT_PRESENTATION_IMMEDIATE); // output->state->setPresentationMode(Aquamarine::eOutputPresentationMode::AQ_OUTPUT_PRESENTATION_IMMEDIATE);
// if (!output->commit()) // if (!output->commit())
// Debug::log(ERR, "onCursorMovedOnMonitor: tearing and wanted to update cursor, failed."); // Log::logger->log(Log::ERR, "onCursorMovedOnMonitor: tearing and wanted to update cursor, failed.");
// FIXME: try to do the above. We currently can't just render because drm is a fucking bitch // FIXME: try to do the above. We currently can't just render because drm is a fucking bitch
// and throws a "nO pRoP cAn Be ChAnGeD dUrInG AsYnC fLiP" on crtc_x // and throws a "nO pRoP cAn Be ChAnGeD dUrInG AsYnC fLiP" on crtc_x
@ -2094,7 +2094,7 @@ CMonitorState::CMonitorState(CMonitor* owner) : m_owner(owner) {
void CMonitorState::ensureBufferPresent() { void CMonitorState::ensureBufferPresent() {
const auto STATE = m_owner->m_output->state->state(); const auto STATE = m_owner->m_output->state->state();
if (!STATE.enabled) { if (!STATE.enabled) {
Debug::log(TRACE, "CMonitorState::ensureBufferPresent: Ignoring, monitor is not enabled"); Log::logger->log(Log::TRACE, "CMonitorState::ensureBufferPresent: Ignoring, monitor is not enabled");
return; return;
} }
@ -2105,7 +2105,7 @@ void CMonitorState::ensureBufferPresent() {
// this is required for modesetting being possible and might be missing in case of first tests in the renderer // this is required for modesetting being possible and might be missing in case of first tests in the renderer
// where we test modes and buffers // where we test modes and buffers
Debug::log(LOG, "CMonitorState::ensureBufferPresent: no buffer or mismatched format, attaching one from the swapchain for modeset being possible"); Log::logger->log(Log::DEBUG, "CMonitorState::ensureBufferPresent: no buffer or mismatched format, attaching one from the swapchain for modeset being possible");
m_owner->m_output->state->setBuffer(m_owner->m_output->swapchain->next(nullptr)); m_owner->m_output->state->setBuffer(m_owner->m_output->swapchain->next(nullptr));
m_owner->m_output->swapchain->rollback(); // restore the counter, don't advance the swapchain m_owner->m_output->swapchain->rollback(); // restore the counter, don't advance the swapchain
} }
@ -2136,7 +2136,7 @@ bool CMonitorState::updateSwapchain() {
const auto& STATE = m_owner->m_output->state->state(); const auto& STATE = m_owner->m_output->state->state();
const auto& MODE = STATE.mode ? STATE.mode : STATE.customMode; const auto& MODE = STATE.mode ? STATE.mode : STATE.customMode;
if (!MODE) { if (!MODE) {
Debug::log(WARN, "updateSwapchain: No mode?"); Log::logger->log(Log::WARN, "updateSwapchain: No mode?");
return true; return true;
} }
options.format = m_owner->m_drmFormat; options.format = m_owner->m_drmFormat;

View file

@ -24,12 +24,12 @@ void CMonitorFrameScheduler::onSyncFired() {
if (std::chrono::duration_cast<std::chrono::microseconds>(hrc::now() - m_lastRenderBegun).count() / 1000.F < 1000.F / m_monitor->m_refreshRate) { if (std::chrono::duration_cast<std::chrono::microseconds>(hrc::now() - m_lastRenderBegun).count() / 1000.F < 1000.F / m_monitor->m_refreshRate) {
// we are in. Frame is valid. We can just render as normal. // we are in. Frame is valid. We can just render as normal.
Debug::log(TRACE, "CMonitorFrameScheduler: {} -> onSyncFired, didn't miss.", m_monitor->m_name); Log::logger->log(Log::TRACE, "CMonitorFrameScheduler: {} -> onSyncFired, didn't miss.", m_monitor->m_name);
m_renderAtFrame = true; m_renderAtFrame = true;
return; return;
} }
Debug::log(TRACE, "CMonitorFrameScheduler: {} -> onSyncFired, missed.", m_monitor->m_name); Log::logger->log(Log::TRACE, "CMonitorFrameScheduler: {} -> onSyncFired, missed.", m_monitor->m_name);
// we are out. The frame is taking too long to render. Begin rendering immediately, but don't commit yet. // we are out. The frame is taking too long to render. Begin rendering immediately, but don't commit yet.
m_pendingThird = true; m_pendingThird = true;
@ -56,11 +56,11 @@ void CMonitorFrameScheduler::onPresented() {
if (!m_pendingThird) if (!m_pendingThird)
return; return;
Debug::log(TRACE, "CMonitorFrameScheduler: {} -> onPresented, missed, committing pending.", m_monitor->m_name); Log::logger->log(Log::TRACE, "CMonitorFrameScheduler: {} -> onPresented, missed, committing pending.", m_monitor->m_name);
m_pendingThird = false; m_pendingThird = false;
Debug::log(TRACE, "CMonitorFrameScheduler: {} -> onPresented, missed, committing pending at the earliest convenience.", m_monitor->m_name); Log::logger->log(Log::TRACE, "CMonitorFrameScheduler: {} -> onPresented, missed, committing pending at the earliest convenience.", m_monitor->m_name);
m_pendingThird = false; m_pendingThird = false;
@ -101,11 +101,11 @@ void CMonitorFrameScheduler::onFrame() {
} }
if (!m_renderAtFrame) { if (!m_renderAtFrame) {
Debug::log(TRACE, "CMonitorFrameScheduler: {} -> frame event, but m_renderAtFrame = false.", m_monitor->m_name); Log::logger->log(Log::TRACE, "CMonitorFrameScheduler: {} -> frame event, but m_renderAtFrame = false.", m_monitor->m_name);
return; return;
} }
Debug::log(TRACE, "CMonitorFrameScheduler: {} -> frame event, render = true, rendering normally.", m_monitor->m_name); Log::logger->log(Log::TRACE, "CMonitorFrameScheduler: {} -> frame event, render = true, rendering normally.", m_monitor->m_name);
m_lastRenderBegun = hrc::now(); m_lastRenderBegun = hrc::now();
@ -132,7 +132,7 @@ void CMonitorFrameScheduler::onFinishRender() {
bool CMonitorFrameScheduler::canRender() { bool CMonitorFrameScheduler::canRender() {
if ((g_pCompositor->m_aqBackend->hasSession() && !g_pCompositor->m_aqBackend->session->active) || !g_pCompositor->m_sessionActive || g_pCompositor->m_unsafeState) { if ((g_pCompositor->m_aqBackend->hasSession() && !g_pCompositor->m_aqBackend->session->active) || !g_pCompositor->m_sessionActive || g_pCompositor->m_unsafeState) {
Debug::log(WARN, "Attempted to render frame on inactive session!"); Log::logger->log(Log::WARN, "Attempted to render frame on inactive session!");
if (g_pCompositor->m_unsafeState && std::ranges::any_of(g_pCompositor->m_monitors.begin(), g_pCompositor->m_monitors.end(), [&](auto& m) { if (g_pCompositor->m_unsafeState && std::ranges::any_of(g_pCompositor->m_monitors.begin(), g_pCompositor->m_monitors.end(), [&](auto& m) {
return m->m_output != g_pCompositor->m_unsafeOutput->m_output; return m->m_output != g_pCompositor->m_unsafeOutput->m_output;

19
src/helpers/env/Env.cpp vendored Normal file
View file

@ -0,0 +1,19 @@
#include "Env.hpp"
#include <cstdlib>
#include <string_view>
bool Env::envEnabled(const std::string& env) {
auto ret = getenv(env.c_str());
if (!ret)
return false;
const std::string_view sv = ret;
return !sv.empty() && sv != "0";
}
bool Env::isTrace() {
static bool TRACE = envEnabled("HYPRLAND_TRACE");
return TRACE;
}

8
src/helpers/env/Env.hpp vendored Normal file
View file

@ -0,0 +1,8 @@
#pragma once
#include <string>
namespace Env {
bool envEnabled(const std::string& env);
bool isTrace();
}

View file

@ -1,8 +1,9 @@
#include "FsUtils.hpp" #include "FsUtils.hpp"
#include "../../debug/Log.hpp" #include "../../debug/log/Logger.hpp"
#include <cstdlib> #include <cstdlib>
#include <filesystem> #include <filesystem>
#include <fstream>
#include <hyprutils/string/String.hpp> #include <hyprutils/string/String.hpp>
#include <hyprutils/string/VarList.hpp> #include <hyprutils/string/VarList.hpp>
@ -17,7 +18,7 @@ std::optional<std::string> NFsUtils::getDataHome() {
const auto HOME = getenv("HOME"); const auto HOME = getenv("HOME");
if (!HOME) { if (!HOME) {
Debug::log(ERR, "FsUtils::getDataHome: can't get data home: no $HOME or $XDG_DATA_HOME"); Log::logger->log(Log::ERR, "FsUtils::getDataHome: can't get data home: no $HOME or $XDG_DATA_HOME");
return std::nullopt; return std::nullopt;
} }
@ -27,26 +28,26 @@ std::optional<std::string> NFsUtils::getDataHome() {
std::error_code ec; std::error_code ec;
if (!std::filesystem::exists(dataRoot, ec) || ec) { if (!std::filesystem::exists(dataRoot, ec) || ec) {
Debug::log(ERR, "FsUtils::getDataHome: can't get data home: inaccessible / missing"); Log::logger->log(Log::ERR, "FsUtils::getDataHome: can't get data home: inaccessible / missing");
return std::nullopt; return std::nullopt;
} }
dataRoot += "hyprland/"; dataRoot += "hyprland/";
if (!std::filesystem::exists(dataRoot, ec) || ec) { if (!std::filesystem::exists(dataRoot, ec) || ec) {
Debug::log(LOG, "FsUtils::getDataHome: no hyprland data home, creating."); Log::logger->log(Log::DEBUG, "FsUtils::getDataHome: no hyprland data home, creating.");
std::filesystem::create_directory(dataRoot, ec); std::filesystem::create_directory(dataRoot, ec);
if (ec) { if (ec) {
Debug::log(ERR, "FsUtils::getDataHome: can't create new data home for hyprland"); Log::logger->log(Log::ERR, "FsUtils::getDataHome: can't create new data home for hyprland");
return std::nullopt; return std::nullopt;
} }
std::filesystem::permissions(dataRoot, std::filesystem::perms::owner_read | std::filesystem::perms::owner_write | std::filesystem::perms::owner_exec, ec); std::filesystem::permissions(dataRoot, std::filesystem::perms::owner_read | std::filesystem::perms::owner_write | std::filesystem::perms::owner_exec, ec);
if (ec) if (ec)
Debug::log(WARN, "FsUtils::getDataHome: couldn't set perms on hyprland data store. Proceeding anyways."); Log::logger->log(Log::WARN, "FsUtils::getDataHome: couldn't set perms on hyprland data store. Proceeding anyways.");
} }
if (!std::filesystem::exists(dataRoot, ec) || ec) { if (!std::filesystem::exists(dataRoot, ec) || ec) {
Debug::log(ERR, "FsUtils::getDataHome: no hyprland data home, failed to create."); Log::logger->log(Log::ERR, "FsUtils::getDataHome: no hyprland data home, failed to create.");
return std::nullopt; return std::nullopt;
} }
@ -69,7 +70,7 @@ std::optional<std::string> NFsUtils::readFileAsString(const std::string& path) {
bool NFsUtils::writeToFile(const std::string& path, const std::string& content) { bool NFsUtils::writeToFile(const std::string& path, const std::string& content) {
std::ofstream of(path, std::ios::trunc); std::ofstream of(path, std::ios::trunc);
if (!of.good()) { if (!of.good()) {
Debug::log(ERR, "CVersionKeeperManager: couldn't open an ofstream for writing the version file."); Log::logger->log(Log::ERR, "CVersionKeeperManager: couldn't open an ofstream for writing the version file.");
return false; return false;
} }

View file

@ -1,6 +1,6 @@
#include "Expression.hpp" #include "Expression.hpp"
#include "muParser.h" #include "muParser.h"
#include "../../debug/Log.hpp" #include "../../debug/log/Logger.hpp"
using namespace Math; using namespace Math;
@ -16,7 +16,7 @@ std::optional<double> CExpression::compute(const std::string& expr) {
try { try {
m_parser->SetExpr(expr); m_parser->SetExpr(expr);
return m_parser->Eval(); return m_parser->Eval();
} catch (mu::Parser::exception_type& e) { Debug::log(ERR, "CExpression::compute: mu threw: {}", e.GetMsg()); } } catch (mu::Parser::exception_type& e) { Log::logger->log(Log::ERR, "CExpression::compute: mu threw: {}", e.GetMsg()); }
return std::nullopt; return std::nullopt;
} }

View file

@ -25,7 +25,7 @@ CSyncReleaser::CSyncReleaser(SP<CSyncTimeline> timeline, uint64_t point) : m_tim
CSyncReleaser::~CSyncReleaser() { CSyncReleaser::~CSyncReleaser() {
if (!m_timeline) { if (!m_timeline) {
Debug::log(ERR, "CSyncReleaser destructing without a timeline"); Log::logger->log(Log::ERR, "CSyncReleaser destructing without a timeline");
return; return;
} }

View file

@ -16,7 +16,7 @@ SP<CSyncTimeline> CSyncTimeline::create(int drmFD_) {
timeline->m_self = timeline; timeline->m_self = timeline;
if (drmSyncobjCreate(drmFD_, 0, &timeline->m_handle)) { if (drmSyncobjCreate(drmFD_, 0, &timeline->m_handle)) {
Debug::log(ERR, "CSyncTimeline: failed to create a drm syncobj??"); Log::logger->log(Log::ERR, "CSyncTimeline: failed to create a drm syncobj??");
return nullptr; return nullptr;
} }
@ -33,7 +33,7 @@ SP<CSyncTimeline> CSyncTimeline::create(int drmFD_, CFileDescriptor&& drmSyncobj
timeline->m_self = timeline; timeline->m_self = timeline;
if (drmSyncobjFDToHandle(drmFD_, timeline->m_syncobjFD.get(), &timeline->m_handle)) { if (drmSyncobjFDToHandle(drmFD_, timeline->m_syncobjFD.get(), &timeline->m_handle)) {
Debug::log(ERR, "CSyncTimeline: failed to create a drm syncobj from fd??"); Log::logger->log(Log::ERR, "CSyncTimeline: failed to create a drm syncobj from fd??");
return nullptr; return nullptr;
} }
@ -57,7 +57,7 @@ std::optional<bool> CSyncTimeline::check(uint64_t point, uint32_t flags) {
uint32_t signaled = 0; uint32_t signaled = 0;
int ret = drmSyncobjTimelineWait(m_drmFD, &m_handle, &point, 1, 0, flags, &signaled); int ret = drmSyncobjTimelineWait(m_drmFD, &m_handle, &point, 1, 0, flags, &signaled);
if (ret != 0 && ret != -ETIME_ERR) { if (ret != 0 && ret != -ETIME_ERR) {
Debug::log(ERR, "CSyncTimeline::check: drmSyncobjTimelineWait failed"); Log::logger->log(Log::ERR, "CSyncTimeline::check: drmSyncobjTimelineWait failed");
return std::nullopt; return std::nullopt;
} }
@ -68,12 +68,12 @@ bool CSyncTimeline::addWaiter(std::function<void()>&& waiter, uint64_t point, ui
auto eventFd = CFileDescriptor(eventfd(0, EFD_CLOEXEC)); auto eventFd = CFileDescriptor(eventfd(0, EFD_CLOEXEC));
if (!eventFd.isValid()) { if (!eventFd.isValid()) {
Debug::log(ERR, "CSyncTimeline::addWaiter: failed to acquire an eventfd"); Log::logger->log(Log::ERR, "CSyncTimeline::addWaiter: failed to acquire an eventfd");
return false; return false;
} }
if (drmSyncobjEventfd(m_drmFD, m_handle, point, eventFd.get(), flags)) { if (drmSyncobjEventfd(m_drmFD, m_handle, point, eventFd.get(), flags)) {
Debug::log(ERR, "CSyncTimeline::addWaiter: drmSyncobjEventfd failed"); Log::logger->log(Log::ERR, "CSyncTimeline::addWaiter: drmSyncobjEventfd failed");
return false; return false;
} }
@ -87,18 +87,18 @@ CFileDescriptor CSyncTimeline::exportAsSyncFileFD(uint64_t src) {
uint32_t syncHandle = 0; uint32_t syncHandle = 0;
if (drmSyncobjCreate(m_drmFD, 0, &syncHandle)) { if (drmSyncobjCreate(m_drmFD, 0, &syncHandle)) {
Debug::log(ERR, "exportAsSyncFileFD: drmSyncobjCreate failed"); Log::logger->log(Log::ERR, "exportAsSyncFileFD: drmSyncobjCreate failed");
return {}; return {};
} }
if (drmSyncobjTransfer(m_drmFD, syncHandle, 0, m_handle, src, 0)) { if (drmSyncobjTransfer(m_drmFD, syncHandle, 0, m_handle, src, 0)) {
Debug::log(ERR, "exportAsSyncFileFD: drmSyncobjTransfer failed"); Log::logger->log(Log::ERR, "exportAsSyncFileFD: drmSyncobjTransfer failed");
drmSyncobjDestroy(m_drmFD, syncHandle); drmSyncobjDestroy(m_drmFD, syncHandle);
return {}; return {};
} }
if (drmSyncobjExportSyncFile(m_drmFD, syncHandle, &sync)) { if (drmSyncobjExportSyncFile(m_drmFD, syncHandle, &sync)) {
Debug::log(ERR, "exportAsSyncFileFD: drmSyncobjExportSyncFile failed"); Log::logger->log(Log::ERR, "exportAsSyncFileFD: drmSyncobjExportSyncFile failed");
drmSyncobjDestroy(m_drmFD, syncHandle); drmSyncobjDestroy(m_drmFD, syncHandle);
return {}; return {};
} }
@ -111,18 +111,18 @@ bool CSyncTimeline::importFromSyncFileFD(uint64_t dst, CFileDescriptor& fd) {
uint32_t syncHandle = 0; uint32_t syncHandle = 0;
if (drmSyncobjCreate(m_drmFD, 0, &syncHandle)) { if (drmSyncobjCreate(m_drmFD, 0, &syncHandle)) {
Debug::log(ERR, "importFromSyncFileFD: drmSyncobjCreate failed"); Log::logger->log(Log::ERR, "importFromSyncFileFD: drmSyncobjCreate failed");
return false; return false;
} }
if (drmSyncobjImportSyncFile(m_drmFD, syncHandle, fd.get())) { if (drmSyncobjImportSyncFile(m_drmFD, syncHandle, fd.get())) {
Debug::log(ERR, "importFromSyncFileFD: drmSyncobjImportSyncFile failed"); Log::logger->log(Log::ERR, "importFromSyncFileFD: drmSyncobjImportSyncFile failed");
drmSyncobjDestroy(m_drmFD, syncHandle); drmSyncobjDestroy(m_drmFD, syncHandle);
return false; return false;
} }
if (drmSyncobjTransfer(m_drmFD, m_handle, dst, syncHandle, 0, 0)) { if (drmSyncobjTransfer(m_drmFD, m_handle, dst, syncHandle, 0, 0)) {
Debug::log(ERR, "importFromSyncFileFD: drmSyncobjTransfer failed"); Log::logger->log(Log::ERR, "importFromSyncFileFD: drmSyncobjTransfer failed");
drmSyncobjDestroy(m_drmFD, syncHandle); drmSyncobjDestroy(m_drmFD, syncHandle);
return false; return false;
} }
@ -133,12 +133,12 @@ bool CSyncTimeline::importFromSyncFileFD(uint64_t dst, CFileDescriptor& fd) {
bool CSyncTimeline::transfer(SP<CSyncTimeline> from, uint64_t fromPoint, uint64_t toPoint) { bool CSyncTimeline::transfer(SP<CSyncTimeline> from, uint64_t fromPoint, uint64_t toPoint) {
if (m_drmFD != from->m_drmFD) { if (m_drmFD != from->m_drmFD) {
Debug::log(ERR, "CSyncTimeline::transfer: cannot transfer timelines between gpus, {} -> {}", from->m_drmFD, m_drmFD); Log::logger->log(Log::ERR, "CSyncTimeline::transfer: cannot transfer timelines between gpus, {} -> {}", from->m_drmFD, m_drmFD);
return false; return false;
} }
if (drmSyncobjTransfer(m_drmFD, m_handle, toPoint, from->m_handle, fromPoint, 0)) { if (drmSyncobjTransfer(m_drmFD, m_handle, toPoint, from->m_handle, fromPoint, 0)) {
Debug::log(ERR, "CSyncTimeline::transfer: drmSyncobjTransfer failed"); Log::logger->log(Log::ERR, "CSyncTimeline::transfer: drmSyncobjTransfer failed");
return false; return false;
} }
@ -147,5 +147,5 @@ bool CSyncTimeline::transfer(SP<CSyncTimeline> from, uint64_t fromPoint, uint64_
void CSyncTimeline::signal(uint64_t point) { void CSyncTimeline::signal(uint64_t point) {
if (drmSyncobjTimelineSignal(m_drmFD, &m_handle, &point, 1)) if (drmSyncobjTimelineSignal(m_drmFD, &m_handle, &point, 1))
Debug::log(ERR, "CSyncTimeline::signal: drmSyncobjTimelineSignal failed"); Log::logger->log(Log::ERR, "CSyncTimeline::signal: drmSyncobjTimelineSignal failed");
} }

View file

@ -10,20 +10,20 @@ void NInit::gainRealTime() {
struct sched_param param; struct sched_param param;
if (pthread_getschedparam(pthread_self(), &old_policy, &param)) { if (pthread_getschedparam(pthread_self(), &old_policy, &param)) {
Debug::log(WARN, "Failed to get old pthread scheduling priority"); Log::logger->log(Log::WARN, "Failed to get old pthread scheduling priority");
return; return;
} }
param.sched_priority = minPrio; param.sched_priority = minPrio;
if (pthread_setschedparam(pthread_self(), SCHED_RR, &param)) { if (pthread_setschedparam(pthread_self(), SCHED_RR, &param)) {
Debug::log(WARN, "Failed to change process scheduling strategy"); Log::logger->log(Log::WARN, "Failed to change process scheduling strategy");
return; return;
} }
pthread_atfork(nullptr, nullptr, []() { pthread_atfork(nullptr, nullptr, []() {
const struct sched_param param = {.sched_priority = 0}; const struct sched_param param = {.sched_priority = 0};
if (pthread_setschedparam(pthread_self(), SCHED_OTHER, &param)) if (pthread_setschedparam(pthread_self(), SCHED_OTHER, &param))
Debug::log(WARN, "Failed to reset process scheduling strategy"); Log::logger->log(Log::WARN, "Failed to reset process scheduling strategy");
}); });
} }

View file

@ -118,7 +118,7 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SP<SDwindleNodeData> pNode, bool
PMONITOR = WS->m_monitor.lock(); PMONITOR = WS->m_monitor.lock();
if (!PMONITOR || !WS) { if (!PMONITOR || !WS) {
Debug::log(ERR, "Orphaned Node {}!!", pNode); Log::logger->log(Log::ERR, "Orphaned Node {}!!", pNode);
return; return;
} }
@ -135,7 +135,7 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SP<SDwindleNodeData> pNode, bool
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(g_pCompositor->getWorkspaceByID(pNode->workspaceID)); const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(g_pCompositor->getWorkspaceByID(pNode->workspaceID));
if (!validMapped(PWINDOW)) { if (!validMapped(PWINDOW)) {
Debug::log(ERR, "Node {} holding invalid {}!!", pNode, PWINDOW); Log::logger->log(Log::ERR, "Node {} holding invalid {}!!", pNode, PWINDOW);
onWindowRemovedTiling(PWINDOW); onWindowRemovedTiling(PWINDOW);
return; return;
} }
@ -316,7 +316,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dir
} else } else
OPENINGON = getFirstNodeOnWorkspace(pWindow->workspaceID()); OPENINGON = getFirstNodeOnWorkspace(pWindow->workspaceID());
Debug::log(LOG, "OPENINGON: {}, Monitor: {}", OPENINGON, PMONITOR->m_id); Log::logger->log(Log::DEBUG, "OPENINGON: {}, Monitor: {}", OPENINGON, PMONITOR->m_id);
if (OPENINGON && OPENINGON->workspaceID != PNODE->workspaceID) { if (OPENINGON && OPENINGON->workspaceID != PNODE->workspaceID) {
// special workspace handling // special workspace handling
@ -489,7 +489,7 @@ void CHyprDwindleLayout::onWindowRemovedTiling(PHLWINDOW pWindow) {
const auto PNODE = getNodeFromWindow(pWindow); const auto PNODE = getNodeFromWindow(pWindow);
if (!PNODE) { if (!PNODE) {
Debug::log(ERR, "onWindowRemovedTiling node null?"); Log::logger->log(Log::ERR, "onWindowRemovedTiling node null?");
return; return;
} }
@ -502,7 +502,7 @@ void CHyprDwindleLayout::onWindowRemovedTiling(PHLWINDOW pWindow) {
const auto PPARENT = PNODE->pParent; const auto PPARENT = PNODE->pParent;
if (!PPARENT) { if (!PPARENT) {
Debug::log(LOG, "Removing last node (dwindle)"); Log::logger->log(Log::DEBUG, "Removing last node (dwindle)");
std::erase(m_dwindleNodesData, PNODE); std::erase(m_dwindleNodesData, PNODE);
return; return;
} }
@ -1015,7 +1015,7 @@ std::any CHyprDwindleLayout::layoutMessage(SLayoutMessageHeader header, std::str
std::string direction = ARGS[1]; std::string direction = ARGS[1];
if (direction.empty()) { if (direction.empty()) {
Debug::log(ERR, "Expected direction for preselect"); Log::logger->log(Log::ERR, "Expected direction for preselect");
return ""; return "";
} }

View file

@ -24,7 +24,7 @@ void IHyprLayout::onWindowCreated(PHLWINDOW pWindow, eDirection direction) {
const auto STOREDSIZE = HASPERSISTENTSIZE ? g_pConfigManager->getStoredFloatingSize(pWindow) : std::nullopt; const auto STOREDSIZE = HASPERSISTENTSIZE ? g_pConfigManager->getStoredFloatingSize(pWindow) : std::nullopt;
if (STOREDSIZE.has_value()) { if (STOREDSIZE.has_value()) {
Debug::log(LOG, "using stored size {}x{} for new window {}::{}", STOREDSIZE->x, STOREDSIZE->y, pWindow->m_class, pWindow->m_title); Log::logger->log(Log::DEBUG, "using stored size {}x{} for new window {}::{}", STOREDSIZE->x, STOREDSIZE->y, pWindow->m_class, pWindow->m_title);
pWindow->m_lastFloatingSize = STOREDSIZE.value(); pWindow->m_lastFloatingSize = STOREDSIZE.value();
} else if (desiredGeometry.width <= 5 || desiredGeometry.height <= 5) { } else if (desiredGeometry.width <= 5 || desiredGeometry.height <= 5) {
const auto PMONITOR = pWindow->m_monitor.lock(); const auto PMONITOR = pWindow->m_monitor.lock();
@ -117,7 +117,7 @@ void IHyprLayout::onWindowCreatedFloating(PHLWINDOW pWindow) {
static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>("xwayland:force_zero_scaling"); static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>("xwayland:force_zero_scaling");
if (!PMONITOR) { if (!PMONITOR) {
Debug::log(ERR, "{:m} has an invalid monitor in onWindowCreatedFloating!!!", pWindow); Log::logger->log(Log::ERR, "{:m} has an invalid monitor in onWindowCreatedFloating!!!", pWindow);
return; return;
} }
@ -248,7 +248,7 @@ void IHyprLayout::onBeginDragWindow() {
// Window will be floating. Let's check if it's valid. It should be, but I don't like crashing. // Window will be floating. Let's check if it's valid. It should be, but I don't like crashing.
if (!validMapped(DRAGGINGWINDOW)) { if (!validMapped(DRAGGINGWINDOW)) {
Debug::log(ERR, "Dragging attempted on an invalid window!"); Log::logger->log(Log::ERR, "Dragging attempted on an invalid window!");
CKeybindManager::changeMouseBindMode(MBIND_INVALID); CKeybindManager::changeMouseBindMode(MBIND_INVALID);
return; return;
} }
@ -745,7 +745,7 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
void IHyprLayout::changeWindowFloatingMode(PHLWINDOW pWindow) { void IHyprLayout::changeWindowFloatingMode(PHLWINDOW pWindow) {
if (pWindow->isFullscreen()) { if (pWindow->isFullscreen()) {
Debug::log(LOG, "changeWindowFloatingMode: fullscreen"); Log::logger->log(Log::DEBUG, "changeWindowFloatingMode: fullscreen");
g_pCompositor->setWindowFullscreenInternal(pWindow, FSMODE_NONE); g_pCompositor->setWindowFullscreenInternal(pWindow, FSMODE_NONE);
} }
@ -864,7 +864,7 @@ void IHyprLayout::moveActiveWindow(const Vector2D& delta, PHLWINDOW pWindow) {
return; return;
if (!PWINDOW->m_isFloating) { if (!PWINDOW->m_isFloating) {
Debug::log(LOG, "Dwindle cannot move a tiled window in moveActiveWindow!"); Log::logger->log(Log::DEBUG, "Dwindle cannot move a tiled window in moveActiveWindow!");
return; return;
} }
@ -970,7 +970,7 @@ Vector2D IHyprLayout::predictSizeForNewWindowFloating(PHLWINDOW pWindow) { // ge
const auto STOREDSIZE = HASPERSISTENTSIZE ? g_pConfigManager->getStoredFloatingSize(pWindow) : std::nullopt; const auto STOREDSIZE = HASPERSISTENTSIZE ? g_pConfigManager->getStoredFloatingSize(pWindow) : std::nullopt;
if (STOREDSIZE.has_value()) { if (STOREDSIZE.has_value()) {
Debug::log(LOG, "using stored size {}x{} for new floating window {}::{}", STOREDSIZE->x, STOREDSIZE->y, pWindow->m_class, pWindow->m_title); Log::logger->log(Log::DEBUG, "using stored size {}x{} for new floating window {}::{}", STOREDSIZE->x, STOREDSIZE->y, pWindow->m_class, pWindow->m_title);
return STOREDSIZE.value(); return STOREDSIZE.value();
} }
@ -1008,14 +1008,14 @@ bool IHyprLayout::updateDragWindow() {
if (g_pInputManager->m_dragThresholdReached) { if (g_pInputManager->m_dragThresholdReached) {
if (WAS_FULLSCREEN) { if (WAS_FULLSCREEN) {
Debug::log(LOG, "Dragging a fullscreen window"); Log::logger->log(Log::DEBUG, "Dragging a fullscreen window");
g_pCompositor->setWindowFullscreenInternal(DRAGGINGWINDOW, FSMODE_NONE); g_pCompositor->setWindowFullscreenInternal(DRAGGINGWINDOW, FSMODE_NONE);
} }
const auto PWORKSPACE = DRAGGINGWINDOW->m_workspace; const auto PWORKSPACE = DRAGGINGWINDOW->m_workspace;
if (PWORKSPACE->m_hasFullscreenWindow && (!DRAGGINGWINDOW->m_isFloating || (!DRAGGINGWINDOW->m_createdOverFullscreen && !DRAGGINGWINDOW->m_pinned))) { if (PWORKSPACE->m_hasFullscreenWindow && (!DRAGGINGWINDOW->m_isFloating || (!DRAGGINGWINDOW->m_createdOverFullscreen && !DRAGGINGWINDOW->m_pinned))) {
Debug::log(LOG, "Rejecting drag on a fullscreen workspace. (window under fullscreen)"); Log::logger->log(Log::DEBUG, "Rejecting drag on a fullscreen workspace. (window under fullscreen)");
g_pKeybindManager->changeMouseBindMode(MBIND_INVALID); g_pKeybindManager->changeMouseBindMode(MBIND_INVALID);
return true; return true;
} }

View file

@ -649,7 +649,7 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
PMONITOR = WS->m_monitor.lock(); PMONITOR = WS->m_monitor.lock();
if (!PMONITOR || !WS) { if (!PMONITOR || !WS) {
Debug::log(ERR, "Orphaned Node {}!!", pNode); Log::logger->log(Log::ERR, "Orphaned Node {}!!", pNode);
return; return;
} }
@ -678,7 +678,7 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
auto gapsIn = WORKSPACERULE.gapsIn.value_or(*PGAPSIN); auto gapsIn = WORKSPACERULE.gapsIn.value_or(*PGAPSIN);
if (!validMapped(PWINDOW)) { if (!validMapped(PWINDOW)) {
Debug::log(ERR, "Node {} holding invalid {}!!", pNode, PWINDOW); Log::logger->log(Log::ERR, "Node {} holding invalid {}!!", pNode, PWINDOW);
return; return;
} }
@ -1092,7 +1092,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
CVarList vars(message, 0, ' '); CVarList vars(message, 0, ' ');
if (vars.size() < 1 || vars[0].empty()) { if (vars.size() < 1 || vars[0].empty()) {
Debug::log(ERR, "layoutmsg called without params"); Log::logger->log(Log::ERR, "layoutmsg called without params");
return 0; return 0;
} }

View file

@ -6,7 +6,7 @@
#include <utility> #include <utility>
#include "helpers/memory/Memory.hpp" #include "helpers/memory/Memory.hpp"
#include "debug/Log.hpp" #include "debug/log/Logger.hpp"
#ifndef NDEBUG #ifndef NDEBUG
#ifdef HYPRLAND_DEBUG #ifdef HYPRLAND_DEBUG
@ -45,7 +45,7 @@
#define RASSERT(expr, reason, ...) \ #define RASSERT(expr, reason, ...) \
if (!(expr)) { \ if (!(expr)) { \
Debug::log(CRIT, "\n==========================================================================================\nASSERTION FAILED! \n\n{}\n\nat: line {} in {}", \ Log::logger->log(Log::CRIT, "\n==========================================================================================\nASSERTION FAILED! \n\n{}\n\nat: line {} in {}", \
std::format(reason, ##__VA_ARGS__), __LINE__, \ std::format(reason, ##__VA_ARGS__), __LINE__, \
([]() constexpr -> std::string { return std::string(__FILE__).substr(std::string(__FILE__).find_last_of('/') + 1); })()); \ ([]() constexpr -> std::string { return std::string(__FILE__).substr(std::string(__FILE__).find_last_of('/') + 1); })()); \
std::print("Assertion failed! See the log in /tmp/hypr/hyprland.log for more info."); \ std::print("Assertion failed! See the log in /tmp/hypr/hyprland.log for more info."); \
@ -83,7 +83,7 @@
#if ISDEBUG #if ISDEBUG
#define UNREACHABLE() \ #define UNREACHABLE() \
{ \ { \
Debug::log(CRIT, "\n\nMEMORY CORRUPTED: Unreachable failed! (Reached an unreachable position, memory corruption!!!)"); \ Log::logger->log(Log::CRIT, "\n\nMEMORY CORRUPTED: Unreachable failed! (Reached an unreachable position, memory corruption!!!)"); \
raise(SIGABRT); \ raise(SIGABRT); \
std::unreachable(); \ std::unreachable(); \
} }
@ -98,7 +98,7 @@
__CALL__; \ __CALL__; \
auto err = glGetError(); \ auto err = glGetError(); \
if (err != GL_NO_ERROR) { \ if (err != GL_NO_ERROR) { \
Debug::log(ERR, "[GLES] Error in call at {}@{}: 0x{:x}", __LINE__, \ Log::logger->log(Log::ERR, "[GLES] Error in call at {}@{}: 0x{:x}", __LINE__, \
([]() constexpr -> std::string { return std::string(__FILE__).substr(std::string(__FILE__).find_last_of('/') + 1); })(), err); \ ([]() constexpr -> std::string { return std::string(__FILE__).substr(std::string(__FILE__).find_last_of('/') + 1); })(), err); \
} \ } \
} }

View file

@ -1,9 +1,10 @@
#include "defines.hpp" #include "defines.hpp"
#include "debug/Log.hpp" #include "debug/log/Logger.hpp"
#include "Compositor.hpp" #include "Compositor.hpp"
#include "config/ConfigManager.hpp" #include "config/ConfigManager.hpp"
#include "init/initHelpers.hpp" #include "init/initHelpers.hpp"
#include "debug/HyprCtl.hpp" #include "debug/HyprCtl.hpp"
#include "helpers/env/Env.hpp"
#include <csignal> #include <csignal>
#include <cstdio> #include <cstdio>
@ -132,7 +133,7 @@ int main(int argc, char** argv) {
return 1; return 1;
} }
Debug::log(LOG, "User-specified config location: '{}'", configPath); Log::logger->log(Log::DEBUG, "User-specified config location: '{}'", configPath);
it++; it++;
@ -219,17 +220,17 @@ int main(int argc, char** argv) {
g_pCompositor->m_safeMode = true; g_pCompositor->m_safeMode = true;
if (!watchdogOk) if (!watchdogOk)
Debug::log(WARN, "WARNING: Hyprland is being launched without start-hyprland. This is highly advised against."); Log::logger->log(Log::WARN, "WARNING: Hyprland is being launched without start-hyprland. This is highly advised against.");
g_pCompositor->initServer(socketName, socketFd); g_pCompositor->initServer(socketName, socketFd);
if (verifyConfig) if (verifyConfig)
return !g_pConfigManager->m_lastConfigVerificationWasSuccessful; return !g_pConfigManager->m_lastConfigVerificationWasSuccessful;
if (!envEnabled("HYPRLAND_NO_RT")) if (!Env::envEnabled("HYPRLAND_NO_RT"))
NInit::gainRealTime(); NInit::gainRealTime();
Debug::log(LOG, "Hyprland init finished."); Log::logger->log(Log::DEBUG, "Hyprland init finished.");
// If all's good to go, start. // If all's good to go, start.
g_pCompositor->startCompositor(); g_pCompositor->startCompositor();
@ -238,7 +239,7 @@ int main(int argc, char** argv) {
g_pCompositor.reset(); g_pCompositor.reset();
Debug::log(LOG, "Hyprland has reached the end."); Log::logger->log(Log::DEBUG, "Hyprland has reached the end.");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View file

@ -1,7 +1,7 @@
#include "ANRManager.hpp" #include "ANRManager.hpp"
#include "../helpers/fs/FsUtils.hpp" #include "../helpers/fs/FsUtils.hpp"
#include "../debug/Log.hpp" #include "../debug/log/Logger.hpp"
#include "../macros.hpp" #include "../macros.hpp"
#include "HookSystemManager.hpp" #include "HookSystemManager.hpp"
#include "../Compositor.hpp" #include "../Compositor.hpp"
@ -17,7 +17,7 @@ static constexpr auto TIMER_TIMEOUT = std::chrono::milliseconds(1500);
CANRManager::CANRManager() { CANRManager::CANRManager() {
if (!NFsUtils::executableExistsInPath("hyprland-dialog")) { if (!NFsUtils::executableExistsInPath("hyprland-dialog")) {
Debug::log(ERR, "hyprland-dialog missing from PATH, cannot start ANRManager"); Log::logger->log(Log::ERR, "hyprland-dialog missing from PATH, cannot start ANRManager");
return; return;
} }
@ -206,7 +206,7 @@ void CANRManager::SANRData::runDialog(const std::string& appName, const std::str
dialogBox->open()->then([dialogWmPID, this, OPTION_TERMINATE_STR, OPTION_WAIT_STR](SP<CPromiseResult<std::string>> r) { dialogBox->open()->then([dialogWmPID, this, OPTION_TERMINATE_STR, OPTION_WAIT_STR](SP<CPromiseResult<std::string>> r) {
if (r->hasError()) { if (r->hasError()) {
Debug::log(ERR, "CANRManager::SANRData::runDialog: error spawning dialog"); Log::logger->log(Log::ERR, "CANRManager::SANRData::runDialog: error spawning dialog");
return; return;
} }
@ -217,7 +217,7 @@ void CANRManager::SANRData::runDialog(const std::string& appName, const std::str
else if (result.starts_with(OPTION_WAIT_STR)) else if (result.starts_with(OPTION_WAIT_STR))
dialogSaidWait = true; dialogSaidWait = true;
else else
Debug::log(ERR, "CANRManager::SANRData::runDialog: lambda: unrecognized result: {}", result); Log::logger->log(Log::ERR, "CANRManager::SANRData::runDialog: lambda: unrecognized result: {}", result);
}); });
} }

View file

@ -16,7 +16,7 @@ static void hcLogger(enum eHyprcursorLogLevel level, char* message) {
if (level == HC_LOG_TRACE) if (level == HC_LOG_TRACE)
return; return;
Debug::log(NONE, "[hc] {}", message); Log::logger->log(Log::DEBUG, "[hc] {}", 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)) {
@ -83,11 +83,11 @@ CCursorManager::CCursorManager() {
} }
if (m_size <= 0) { if (m_size <= 0) {
Debug::log(WARN, "HYPRCURSOR_SIZE size not set, defaulting to size 24"); Log::logger->log(Log::WARN, "HYPRCURSOR_SIZE size not set, defaulting to size 24");
m_size = 24; m_size = 24;
} }
} else { } else {
Debug::log(ERR, "Hyprcursor failed loading theme \"{}\", falling back to Xcursor.", m_theme); Log::logger->log(Log::ERR, "Hyprcursor failed loading theme \"{}\", falling back to Xcursor.", m_theme);
auto const* SIZE = getenv("XCURSOR_SIZE"); auto const* SIZE = getenv("XCURSOR_SIZE");
if (SIZE) { if (SIZE) {
@ -97,7 +97,7 @@ CCursorManager::CCursorManager() {
} }
if (m_size <= 0) { if (m_size <= 0) {
Debug::log(WARN, "XCURSOR_SIZE size not set, defaulting to size 24"); Log::logger->log(Log::WARN, "XCURSOR_SIZE size not set, defaulting to size 24");
m_size = 24; m_size = 24;
} }
} }
@ -203,7 +203,7 @@ void CCursorManager::setCursorFromName(const std::string& name) {
} }
if (m_currentCursorShapeData.images.empty()) { if (m_currentCursorShapeData.images.empty()) {
Debug::log(ERR, "BUG THIS: No fallback found for a cursor in setCursorFromName"); Log::logger->log(Log::ERR, "BUG THIS: No fallback found for a cursor in setCursorFromName");
return false; return false;
} }
} }
@ -328,7 +328,7 @@ bool CCursorManager::changeTheme(const std::string& name, const int size) {
m_hyprcursor = makeUnique<Hyprcursor::CHyprcursorManager>(m_theme.empty() ? nullptr : m_theme.c_str(), options); m_hyprcursor = makeUnique<Hyprcursor::CHyprcursorManager>(m_theme.empty() ? nullptr : m_theme.c_str(), options);
if (!m_hyprcursor->valid()) { if (!m_hyprcursor->valid()) {
Debug::log(ERR, "Hyprcursor failed loading theme \"{}\", falling back to XCursor.", m_theme); Log::logger->log(Log::ERR, "Hyprcursor failed loading theme \"{}\", falling back to XCursor.", m_theme);
m_xcursor->loadTheme(m_theme.empty() ? xcursor_theme : m_theme, m_size, m_cursorScale); m_xcursor->loadTheme(m_theme.empty() ? xcursor_theme : m_theme, m_size, m_cursorScale);
} }
} else } else

View file

@ -1,5 +1,5 @@
#include "DonationNagManager.hpp" #include "DonationNagManager.hpp"
#include "../debug/Log.hpp" #include "../debug/log/Logger.hpp"
#include "VersionKeeperManager.hpp" #include "VersionKeeperManager.hpp"
#include "eventLoop/EventLoopManager.hpp" #include "eventLoop/EventLoopManager.hpp"
#include "../config/ConfigValue.hpp" #include "../config/ConfigValue.hpp"
@ -69,12 +69,12 @@ 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.", sc<int>(std::round((EPOCH - state.epoch) / sc<double>(DAY_IN_SECONDS)))); Log::logger->log(Log::DEBUG, "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;
} }
if (!NFsUtils::executableExistsInPath("hyprland-donate-screen")) { if (!NFsUtils::executableExistsInPath("hyprland-donate-screen")) {
Debug::log(ERR, "DonationNag: executable doesn't exist, skipping."); Log::logger->log(Log::ERR, "DonationNag: executable doesn't exist, skipping.");
return; return;
} }
@ -91,7 +91,7 @@ CDonationNagManager::CDonationNagManager() {
if (DAY < nagPoint.dayStart || DAY > nagPoint.dayEnd) if (DAY < nagPoint.dayStart || DAY > nagPoint.dayEnd)
continue; continue;
Debug::log(LOG, "DonationNag: hit nag month {} days {}-{}, it's {} today, nagging", MONTH, nagPoint.dayStart, nagPoint.dayEnd, DAY); Log::logger->log(Log::DEBUG, "DonationNag: hit nag month {} days {}-{}, it's {} today, nagging", MONTH, nagPoint.dayStart, nagPoint.dayEnd, DAY);
fire(); fire();
@ -103,10 +103,10 @@ CDonationNagManager::CDonationNagManager() {
} }
if (!m_fired) if (!m_fired)
Debug::log(LOG, "DonationNag: didn't hit any nagging periods, checking update"); Log::logger->log(Log::DEBUG, "DonationNag: didn't hit any nagging periods, checking update");
if (state.major < currentMajor) { if (state.major < currentMajor) {
Debug::log(LOG, "DonationNag: hit nag for major update {} -> {}", state.major, currentMajor); Log::logger->log(Log::DEBUG, "DonationNag: hit nag for major update {} -> {}", state.major, currentMajor);
fire(); fire();
@ -116,7 +116,7 @@ CDonationNagManager::CDonationNagManager() {
} }
if (!m_fired) if (!m_fired)
Debug::log(LOG, "DonationNag: didn't hit nagging conditions"); Log::logger->log(Log::DEBUG, "DonationNag: didn't hit nagging conditions");
} }
bool CDonationNagManager::fired() { bool CDonationNagManager::fired() {

View file

@ -13,27 +13,27 @@ using namespace Hyprutils::OS;
CEventManager::CEventManager() : m_socketFD(socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0)) { CEventManager::CEventManager() : m_socketFD(socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0)) {
if (!m_socketFD.isValid()) { if (!m_socketFD.isValid()) {
Debug::log(ERR, "Couldn't start the Hyprland Socket 2. (1) IPC will not work."); Log::logger->log(Log::ERR, "Couldn't start the Hyprland Socket 2. (1) IPC will not work.");
return; return;
} }
sockaddr_un SERVERADDRESS = {.sun_family = AF_UNIX}; sockaddr_un SERVERADDRESS = {.sun_family = AF_UNIX};
const auto PATH = g_pCompositor->m_instancePath + "/.socket2.sock"; const auto PATH = g_pCompositor->m_instancePath + "/.socket2.sock";
if (PATH.length() > sizeof(SERVERADDRESS.sun_path) - 1) { if (PATH.length() > sizeof(SERVERADDRESS.sun_path) - 1) {
Debug::log(ERR, "Socket2 path is too long. (2) IPC will not work."); Log::logger->log(Log::ERR, "Socket2 path is too long. (2) IPC will not work.");
return; return;
} }
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(), rc<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."); Log::logger->log(Log::ERR, "Couldn't bind the Hyprland Socket 2. (3) IPC will not work.");
return; return;
} }
// 10 max queued. // 10 max queued.
if (listen(m_socketFD.get(), 10) < 0) { if (listen(m_socketFD.get(), 10) < 0) {
Debug::log(ERR, "Couldn't listen on the Hyprland Socket 2. (4) IPC will not work."); Log::logger->log(Log::ERR, "Couldn't listen on the Hyprland Socket 2. (4) IPC will not work.");
return; return;
} }
@ -59,7 +59,7 @@ int CEventManager::onClientEvent(int fd, uint32_t mask, void* data) {
int CEventManager::onServerEvent(int fd, uint32_t mask) { int CEventManager::onServerEvent(int fd, uint32_t mask) {
if (mask & WL_EVENT_ERROR || mask & WL_EVENT_HANGUP) { if (mask & WL_EVENT_ERROR || mask & WL_EVENT_HANGUP) {
Debug::log(ERR, "Socket2 hangup?? IPC broke"); Log::logger->log(Log::ERR, "Socket2 hangup?? IPC broke");
wl_event_source_remove(m_eventSource); wl_event_source_remove(m_eventSource);
m_eventSource = nullptr; m_eventSource = nullptr;
@ -73,7 +73,7 @@ int CEventManager::onServerEvent(int fd, uint32_t mask) {
CFileDescriptor ACCEPTEDCONNECTION{accept4(m_socketFD.get(), rc<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); Log::logger->log(Log::ERR, "Socket2 failed receiving connection, errno: {}", errno);
wl_event_source_remove(m_eventSource); wl_event_source_remove(m_eventSource);
m_eventSource = nullptr; m_eventSource = nullptr;
m_socketFD.reset(); m_socketFD.reset();
@ -82,7 +82,7 @@ int CEventManager::onServerEvent(int fd, uint32_t mask) {
return 0; return 0;
} }
Debug::log(LOG, "Socket2 accepted a new client at FD {}", ACCEPTEDCONNECTION.get()); Log::logger->log(Log::DEBUG, "Socket2 accepted a new client at FD {}", ACCEPTEDCONNECTION.get());
// add to event loop so we can close it when we need to // add to event loop so we can close it when we need to
auto* eventSource = wl_event_loop_add_fd(g_pCompositor->m_wlEventLoop, ACCEPTEDCONNECTION.get(), 0, onServerEvent, nullptr); auto* eventSource = wl_event_loop_add_fd(g_pCompositor->m_wlEventLoop, ACCEPTEDCONNECTION.get(), 0, onServerEvent, nullptr);
@ -97,7 +97,7 @@ int CEventManager::onServerEvent(int fd, uint32_t mask) {
int CEventManager::onClientEvent(int fd, uint32_t mask) { int CEventManager::onClientEvent(int fd, uint32_t mask) {
if (mask & WL_EVENT_ERROR || mask & WL_EVENT_HANGUP) { if (mask & WL_EVENT_ERROR || mask & WL_EVENT_HANGUP) {
Debug::log(LOG, "Socket2 fd {} hung up", fd); Log::logger->log(Log::DEBUG, "Socket2 fd {} hung up", fd);
removeClientByFD(fd); removeClientByFD(fd);
return 0; return 0;
} }
@ -142,7 +142,7 @@ std::string CEventManager::formatEvent(const SHyprIPCEvent& event) const {
void CEventManager::postEvent(const SHyprIPCEvent& event) { void CEventManager::postEvent(const SHyprIPCEvent& event) {
if (g_pCompositor->m_isShuttingDown) { if (g_pCompositor->m_isShuttingDown) {
Debug::log(WARN, "Suppressed (shutting down) event of type {}, content: {}", event.event, event.data); Log::logger->log(Log::WARN, "Suppressed (shutting down) event of type {}, content: {}", event.event, event.data);
return; return;
} }
@ -154,7 +154,7 @@ void CEventManager::postEvent(const SHyprIPCEvent& event) {
if (QUEUESIZE > 0 || write(it->fd.get(), sharedEvent->c_str(), sharedEvent->length()) < 0) { if (QUEUESIZE > 0 || write(it->fd.get(), sharedEvent->c_str(), sharedEvent->length()) < 0) {
if (QUEUESIZE >= MAX_QUEUED_EVENTS) { if (QUEUESIZE >= MAX_QUEUED_EVENTS) {
// too many events queued, remove the client // too many events queued, remove the client
Debug::log(ERR, "Socket2 fd {} overflowed event queue, removing", it->fd.get()); Log::logger->log(Log::ERR, "Socket2 fd {} overflowed event queue, removing", it->fd.get());
it = removeClientByFD(it->fd.get()); it = removeClientByFD(it->fd.get());
continue; continue;
} }

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.", rc<uintptr_t>(cb.handle)); Log::logger->log(Log::ERR, "[hookSystem] Hook from plugin {:x} caused a SIGSEGV, queueing for unloading.", rc<uintptr_t>(cb.handle));
} }
} }
@ -77,7 +77,7 @@ void CHookSystemManager::emit(std::vector<SCallbackFNPtr>* const callbacks, SCal
std::vector<SCallbackFNPtr>* CHookSystemManager::getVecForEvent(const std::string& event) { std::vector<SCallbackFNPtr>* CHookSystemManager::getVecForEvent(const std::string& event) {
if (!m_registeredHooks.contains(event)) if (!m_registeredHooks.contains(event))
Debug::log(LOG, "[hookSystem] New hook event registered: {}", event); Log::logger->log(Log::DEBUG, "[hookSystem] New hook event registered: {}", event);
return &m_registeredHooks[event]; return &m_registeredHooks[event];
} }

View file

@ -13,7 +13,7 @@
#include "Compositor.hpp" #include "Compositor.hpp"
#include "TokenManager.hpp" #include "TokenManager.hpp"
#include "eventLoop/EventLoopManager.hpp" #include "eventLoop/EventLoopManager.hpp"
#include "debug/Log.hpp" #include "debug/log/Logger.hpp"
#include "../managers/HookSystemManager.hpp" #include "../managers/HookSystemManager.hpp"
#include "../managers/input/InputManager.hpp" #include "../managers/input/InputManager.hpp"
#include "../managers/animation/DesktopAnimationManager.hpp" #include "../managers/animation/DesktopAnimationManager.hpp"
@ -163,7 +163,7 @@ CKeybindManager::CKeybindManager() {
const auto DISPATCHER = g_pKeybindManager->m_dispatchers.find(m_lastLongPressKeybind->handler); const auto DISPATCHER = g_pKeybindManager->m_dispatchers.find(m_lastLongPressKeybind->handler);
Debug::log(LOG, "Long press timeout passed, calling dispatcher."); Log::logger->log(Log::DEBUG, "Long press timeout passed, calling dispatcher.");
DISPATCHER->second(m_lastLongPressKeybind->arg); DISPATCHER->second(m_lastLongPressKeybind->arg);
}, },
nullptr); nullptr);
@ -181,7 +181,7 @@ CKeybindManager::CKeybindManager() {
for (const auto& k : m_activeKeybinds) { for (const auto& k : m_activeKeybinds) {
const auto DISPATCHER = g_pKeybindManager->m_dispatchers.find(k->handler); const auto DISPATCHER = g_pKeybindManager->m_dispatchers.find(k->handler);
Debug::log(LOG, "Keybind repeat triggered, calling dispatcher."); Log::logger->log(Log::DEBUG, "Keybind repeat triggered, calling dispatcher.");
DISPATCHER->second(k->arg); DISPATCHER->second(k->arg);
} }
@ -307,8 +307,8 @@ void CKeybindManager::updateXKBTranslationState() {
", layout: " + LAYOUT + " )", ", layout: " + LAYOUT + " )",
CHyprColor(1.0, 50.0 / 255.0, 50.0 / 255.0, 1.0)); CHyprColor(1.0, 50.0 / 255.0, 50.0 / 255.0, 1.0));
Debug::log(ERR, "[XKBTranslationState] Keyboard layout {} with variant {} (rules: {}, model: {}, options: {}) couldn't have been loaded.", rules.layout, rules.variant, Log::logger->log(Log::ERR, "[XKBTranslationState] Keyboard layout {} with variant {} (rules: {}, model: {}, options: {}) couldn't have been loaded.", rules.layout,
rules.rules, rules.model, rules.options); rules.variant, rules.rules, rules.model, rules.options);
memset(&rules, 0, sizeof(rules)); memset(&rules, 0, sizeof(rules));
PKEYMAP = xkb_keymap_new_from_names2(PCONTEXT, &rules, XKB_KEYMAP_FORMAT_TEXT_V2, XKB_KEYMAP_COMPILE_NO_FLAGS); PKEYMAP = xkb_keymap_new_from_names2(PCONTEXT, &rules, XKB_KEYMAP_FORMAT_TEXT_V2, XKB_KEYMAP_COMPILE_NO_FLAGS);
@ -349,7 +349,7 @@ bool CKeybindManager::tryMoveFocusToMonitor(PHLMONITOR monitor) {
if (!LASTMONITOR) if (!LASTMONITOR)
return false; return false;
if (LASTMONITOR == monitor) { if (LASTMONITOR == monitor) {
Debug::log(LOG, "Tried to move to active monitor"); Log::logger->log(Log::DEBUG, "Tried to move to active monitor");
return false; return false;
} }
@ -429,7 +429,7 @@ bool CKeybindManager::onKeyEvent(std::any event, SP<IKeyboard> pKeyboard) {
return true; return true;
if (!m_xkbTranslationState) { if (!m_xkbTranslationState) {
Debug::log(ERR, "BUG THIS: m_pXKBTranslationState nullptr!"); Log::logger->log(Log::ERR, "BUG THIS: m_pXKBTranslationState nullptr!");
updateXKBTranslationState(); updateXKBTranslationState();
if (!m_xkbTranslationState) if (!m_xkbTranslationState)
@ -497,7 +497,7 @@ bool CKeybindManager::onKeyEvent(std::any event, SP<IKeyboard> pKeyboard) {
} }
} }
if (!foundInPressedKeys) { if (!foundInPressedKeys) {
Debug::log(ERR, "BUG THIS: key not found in m_dPressedKeys"); Log::logger->log(Log::ERR, "BUG THIS: key not found in m_dPressedKeys");
// fallback with wrong `KEY.modmaskAtPressTime`, this can be buggy // fallback with wrong `KEY.modmaskAtPressTime`, this can be buggy
suppressEvent = !handleKeybinds(MODS, KEY, false, pKeyboard).passEvent; suppressEvent = !handleKeybinds(MODS, KEY, false, pKeyboard).passEvent;
} }
@ -582,7 +582,7 @@ bool CKeybindManager::onMouseEvent(const IPointer::SButtonEvent& e) {
} }
} }
if (!foundInPressedKeys) { if (!foundInPressedKeys) {
Debug::log(ERR, "BUG THIS: key not found in m_dPressedKeys (2)"); Log::logger->log(Log::ERR, "BUG THIS: key not found in m_dPressedKeys (2)");
// fallback with wrong `KEY.modmaskAtPressTime`, this can be buggy // fallback with wrong `KEY.modmaskAtPressTime`, this can be buggy
suppressEvent = !handleKeybinds(MODS, KEY, false, nullptr).passEvent; suppressEvent = !handleKeybinds(MODS, KEY, false, nullptr).passEvent;
} }
@ -768,10 +768,10 @@ SDispatchResult CKeybindManager::handleKeybinds(const uint32_t modmask, const SP
// Should never happen, as we check in the ConfigManager, but oh well // Should never happen, as we check in the ConfigManager, but oh well
if (DISPATCHER == m_dispatchers.end()) { if (DISPATCHER == m_dispatchers.end()) {
Debug::log(ERR, "Invalid handler in a keybind! (handler {} does not exist)", k->handler); Log::logger->log(Log::ERR, "Invalid handler in a keybind! (handler {} does not exist)", k->handler);
} else { } else {
// call the dispatcher // call the dispatcher
Debug::log(LOG, "Keybind triggered, calling dispatcher ({}, {}, {}, {})", modmask, key.keyName, key.keysym, DISPATCHER->first); Log::logger->log(Log::DEBUG, "Keybind triggered, calling dispatcher ({}, {}, {}, {})", modmask, key.keyName, key.keysym, DISPATCHER->first);
m_passPressed = sc<int>(pressed); m_passPressed = sc<int>(pressed);
@ -809,7 +809,7 @@ SDispatchResult CKeybindManager::handleKeybinds(const uint32_t modmask, const SP
res.passEvent |= !found; res.passEvent |= !found;
if (!found && !*PDISABLEINHIBIT && PROTO::shortcutsInhibit->isInhibited()) { if (!found && !*PDISABLEINHIBIT && PROTO::shortcutsInhibit->isInhibited()) {
Debug::log(LOG, "Keybind handling is disabled due to an inhibitor"); Log::logger->log(Log::DEBUG, "Keybind handling is disabled due to an inhibitor");
res.success = false; res.success = false;
if (res.error.empty()) if (res.error.empty())
@ -876,7 +876,7 @@ bool CKeybindManager::handleVT(xkb_keysym_t keysym) {
if (!CURRENT_TTY.has_value() || *CURRENT_TTY == TTY) if (!CURRENT_TTY.has_value() || *CURRENT_TTY == TTY)
return true; return true;
Debug::log(LOG, "Switching from VT {} to VT {}", *CURRENT_TTY, TTY); Log::logger->log(Log::DEBUG, "Switching from VT {} to VT {}", *CURRENT_TTY, TTY);
g_pCompositor->m_aqBackend->session->switchVT(TTY); g_pCompositor->m_aqBackend->session->switchVT(TTY);
} }
@ -928,7 +928,7 @@ uint64_t CKeybindManager::spawnWithRules(std::string args, PHLWORKSPACE pInitial
Desktop::Rule::ruleEngine()->registerRule(std::move(rule)); Desktop::Rule::ruleEngine()->registerRule(std::move(rule));
Debug::log(LOG, "Applied rule arguments for exec."); Log::logger->log(Log::DEBUG, "Applied rule arguments for exec.");
} }
const uint64_t PROC = spawnRawProc(args, pInitialWorkspace, execToken); const uint64_t PROC = spawnRawProc(args, pInitialWorkspace, execToken);
@ -942,13 +942,13 @@ SDispatchResult CKeybindManager::spawnRaw(std::string args) {
} }
uint64_t CKeybindManager::spawnRawProc(std::string args, PHLWORKSPACE pInitialWorkspace, const std::string& execRuleToken) { uint64_t CKeybindManager::spawnRawProc(std::string args, PHLWORKSPACE pInitialWorkspace, const std::string& execRuleToken) {
Debug::log(LOG, "Executing {}", args); Log::logger->log(Log::DEBUG, "Executing {}", args);
const auto HLENV = getHyprlandLaunchEnv(pInitialWorkspace); const auto HLENV = getHyprlandLaunchEnv(pInitialWorkspace);
pid_t child = fork(); pid_t child = fork();
if (child < 0) { if (child < 0) {
Debug::log(LOG, "Fail to fork"); Log::logger->log(Log::DEBUG, "Fail to fork");
return 0; return 0;
} }
if (child == 0) { if (child == 0) {
@ -980,7 +980,7 @@ uint64_t CKeybindManager::spawnRawProc(std::string args, PHLWORKSPACE pInitialWo
} }
// run in parent // run in parent
Debug::log(LOG, "Process Created with pid {}", child); Log::logger->log(Log::DEBUG, "Process Created with pid {}", child);
return child; return child;
} }
@ -989,7 +989,7 @@ SDispatchResult CKeybindManager::killActive(std::string args) {
const auto PWINDOW = Desktop::focusState()->window(); const auto PWINDOW = Desktop::focusState()->window();
if (!PWINDOW) { if (!PWINDOW) {
Debug::log(ERR, "killActive: no window found"); Log::logger->log(Log::ERR, "killActive: no window found");
return {.success = false, .error = "killActive: no window found"}; return {.success = false, .error = "killActive: no window found"};
} }
@ -1011,7 +1011,7 @@ SDispatchResult CKeybindManager::closeWindow(std::string args) {
const auto PWINDOW = g_pCompositor->getWindowByRegex(args); const auto PWINDOW = g_pCompositor->getWindowByRegex(args);
if (!PWINDOW) { if (!PWINDOW) {
Debug::log(ERR, "closeWindow: no window found"); Log::logger->log(Log::ERR, "closeWindow: no window found");
return {.success = false, .error = "closeWindow: no window found"}; return {.success = false, .error = "closeWindow: no window found"};
} }
@ -1027,7 +1027,7 @@ SDispatchResult CKeybindManager::killWindow(std::string args) {
const auto PWINDOW = g_pCompositor->getWindowByRegex(args); const auto PWINDOW = g_pCompositor->getWindowByRegex(args);
if (!PWINDOW) { if (!PWINDOW) {
Debug::log(ERR, "killWindow: no window found"); Log::logger->log(Log::ERR, "killWindow: no window found");
return {.success = false, .error = "killWindow: no window found"}; return {.success = false, .error = "killWindow: no window found"};
} }
@ -1043,12 +1043,12 @@ SDispatchResult CKeybindManager::signalActive(std::string args) {
try { try {
const auto SIGNALNUM = std::stoi(args); const auto SIGNALNUM = std::stoi(args);
if (SIGNALNUM < 1 || SIGNALNUM > 31) { if (SIGNALNUM < 1 || SIGNALNUM > 31) {
Debug::log(ERR, "signalActive: invalid signal number {}", SIGNALNUM); Log::logger->log(Log::ERR, "signalActive: invalid signal number {}", SIGNALNUM);
return {.success = false, .error = std::format("signalActive: invalid signal number {}", SIGNALNUM)}; return {.success = false, .error = std::format("signalActive: invalid signal number {}", SIGNALNUM)};
} }
kill(Desktop::focusState()->window()->getPID(), SIGNALNUM); kill(Desktop::focusState()->window()->getPID(), SIGNALNUM);
} catch (const std::exception& e) { } catch (const std::exception& e) {
Debug::log(ERR, "signalActive: invalid signal format \"{}\"", args); Log::logger->log(Log::ERR, "signalActive: invalid signal format \"{}\"", args);
return {.success = false, .error = std::format("signalActive: invalid signal format \"{}\"", args)}; return {.success = false, .error = std::format("signalActive: invalid signal format \"{}\"", args)};
} }
@ -1064,7 +1064,7 @@ SDispatchResult CKeybindManager::signalWindow(std::string args) {
const auto PWINDOW = g_pCompositor->getWindowByRegex(WINDOWREGEX); const auto PWINDOW = g_pCompositor->getWindowByRegex(WINDOWREGEX);
if (!PWINDOW) { if (!PWINDOW) {
Debug::log(ERR, "signalWindow: no window"); Log::logger->log(Log::ERR, "signalWindow: no window");
return {.success = false, .error = "signalWindow: no window"}; return {.success = false, .error = "signalWindow: no window"};
} }
@ -1074,12 +1074,12 @@ SDispatchResult CKeybindManager::signalWindow(std::string args) {
try { try {
const auto SIGNALNUM = std::stoi(SIGNAL); const auto SIGNALNUM = std::stoi(SIGNAL);
if (SIGNALNUM < 1 || SIGNALNUM > 31) { if (SIGNALNUM < 1 || SIGNALNUM > 31) {
Debug::log(ERR, "signalWindow: invalid signal number {}", SIGNALNUM); Log::logger->log(Log::ERR, "signalWindow: invalid signal number {}", SIGNALNUM);
return {.success = false, .error = std::format("signalWindow: invalid signal number {}", SIGNALNUM)}; return {.success = false, .error = std::format("signalWindow: invalid signal number {}", SIGNALNUM)};
} }
kill(PWINDOW->getPID(), SIGNALNUM); kill(PWINDOW->getPID(), SIGNALNUM);
} catch (const std::exception& e) { } catch (const std::exception& e) {
Debug::log(ERR, "signalWindow: invalid signal format \"{}\"", SIGNAL); Log::logger->log(Log::ERR, "signalWindow: invalid signal format \"{}\"", SIGNAL);
return {.success = false, .error = std::format("signalWindow: invalid signal format \"{}\"", SIGNAL)}; return {.success = false, .error = std::format("signalWindow: invalid signal format \"{}\"", SIGNAL)};
} }
@ -1190,7 +1190,7 @@ static SWorkspaceIDName getWorkspaceToChangeFromArgs(std::string args, PHLWORKSP
const SWorkspaceIDName PPREVWS = PER_MON ? PMONITOR->getPrevWorkspaceIDName(PCURRENTWORKSPACE->m_id) : PCURRENTWORKSPACE->getPrevWorkspaceIDName(); const SWorkspaceIDName PPREVWS = PER_MON ? PMONITOR->getPrevWorkspaceIDName(PCURRENTWORKSPACE->m_id) : PCURRENTWORKSPACE->getPrevWorkspaceIDName();
// Do nothing if there's no previous workspace, otherwise switch to it. // Do nothing if there's no previous workspace, otherwise switch to it.
if (PPREVWS.id == -1 || PPREVWS.id == PCURRENTWORKSPACE->m_id) { if (PPREVWS.id == -1 || PPREVWS.id == PCURRENTWORKSPACE->m_id) {
Debug::log(LOG, "No previous workspace to change to"); Log::logger->log(Log::DEBUG, "No previous workspace to change to");
return {.id = WORKSPACE_NOT_CHANGED}; return {.id = WORKSPACE_NOT_CHANGED};
} }
@ -1219,7 +1219,7 @@ SDispatchResult CKeybindManager::changeworkspace(std::string args) {
const auto& [workspaceToChangeTo, workspaceName, isAutoID] = getWorkspaceToChangeFromArgs(args, PCURRENTWORKSPACE, PMONITOR); const auto& [workspaceToChangeTo, workspaceName, isAutoID] = getWorkspaceToChangeFromArgs(args, PCURRENTWORKSPACE, PMONITOR);
if (workspaceToChangeTo == WORKSPACE_INVALID) { if (workspaceToChangeTo == WORKSPACE_INVALID) {
Debug::log(ERR, "Error in changeworkspace, invalid value"); Log::logger->log(Log::ERR, "Error in changeworkspace, invalid value");
return {.success = false, .error = "Error in changeworkspace, invalid value"}; return {.success = false, .error = "Error in changeworkspace, invalid value"};
} }
@ -1383,12 +1383,12 @@ SDispatchResult CKeybindManager::moveActiveToWorkspace(std::string args) {
const auto& [WORKSPACEID, workspaceName, isAutoID] = getWorkspaceIDNameFromString(args); const auto& [WORKSPACEID, workspaceName, isAutoID] = getWorkspaceIDNameFromString(args);
if (WORKSPACEID == WORKSPACE_INVALID) { if (WORKSPACEID == WORKSPACE_INVALID) {
Debug::log(LOG, "Invalid workspace in moveActiveToWorkspace"); Log::logger->log(Log::DEBUG, "Invalid workspace in moveActiveToWorkspace");
return {.success = false, .error = "Invalid workspace in moveActiveToWorkspace"}; return {.success = false, .error = "Invalid workspace in moveActiveToWorkspace"};
} }
if (WORKSPACEID == PWINDOW->workspaceID()) { if (WORKSPACEID == PWINDOW->workspaceID()) {
Debug::log(LOG, "Not moving to workspace because it didn't change."); Log::logger->log(Log::DEBUG, "Not moving to workspace because it didn't change.");
return {.success = false, .error = "Not moving to workspace because it didn't change."}; return {.success = false, .error = "Not moving to workspace because it didn't change."};
} }
@ -1444,7 +1444,7 @@ SDispatchResult CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
const auto& [WORKSPACEID, workspaceName, isAutoID] = getWorkspaceIDNameFromString(args); const auto& [WORKSPACEID, workspaceName, isAutoID] = getWorkspaceIDNameFromString(args);
if (WORKSPACEID == WORKSPACE_INVALID) { if (WORKSPACEID == WORKSPACE_INVALID) {
Debug::log(ERR, "Error in moveActiveToWorkspaceSilent, invalid value"); Log::logger->log(Log::ERR, "Error in moveActiveToWorkspaceSilent, invalid value");
return {.success = false, .error = "Error in moveActiveToWorkspaceSilent, invalid value"}; return {.success = false, .error = "Error in moveActiveToWorkspaceSilent, invalid value"};
} }
@ -1482,7 +1482,7 @@ SDispatchResult CKeybindManager::moveFocusTo(std::string args) {
char arg = args[0]; char arg = args[0];
if (!isDirection(args)) { if (!isDirection(args)) {
Debug::log(ERR, "Cannot move focus in direction {}, unsupported direction. Supported: l,r,u/t,d/b", arg); Log::logger->log(Log::ERR, "Cannot move focus in direction {}, unsupported direction. Supported: l,r,u/t,d/b", arg);
return {.success = false, .error = std::format("Cannot move focus in direction {}, unsupported direction. Supported: l,r,u/t,d/b", arg)}; return {.success = false, .error = std::format("Cannot move focus in direction {}, unsupported direction. Supported: l,r,u/t,d/b", arg)};
} }
@ -1518,7 +1518,7 @@ SDispatchResult CKeybindManager::moveFocusTo(std::string args) {
return {}; return {};
} }
Debug::log(LOG, "No window found in direction {}, looking for a monitor", arg); Log::logger->log(Log::DEBUG, "No window found in direction {}, looking for a monitor", arg);
if (*PMONITORFALLBACK && tryMoveFocusToMonitor(g_pCompositor->getMonitorInDirection(arg))) if (*PMONITORFALLBACK && tryMoveFocusToMonitor(g_pCompositor->getMonitorInDirection(arg)))
return {}; return {};
@ -1527,7 +1527,7 @@ SDispatchResult CKeybindManager::moveFocusTo(std::string args) {
if (*PNOFALLBACK) if (*PNOFALLBACK)
return {.success = false, .error = std::format("Nothing to focus to in direction {}", arg)}; return {.success = false, .error = std::format("Nothing to focus to in direction {}", arg)};
Debug::log(LOG, "No monitor found in direction {}, getting the inverse edge", arg); Log::logger->log(Log::DEBUG, "No monitor found in direction {}, getting the inverse edge", arg);
const auto PMONITOR = PLASTWINDOW->m_monitor.lock(); const auto PMONITOR = PLASTWINDOW->m_monitor.lock();
@ -1612,11 +1612,11 @@ SDispatchResult CKeybindManager::swapActive(std::string args) {
PWINDOWTOCHANGETO = g_pCompositor->getWindowByRegex(args); PWINDOWTOCHANGETO = g_pCompositor->getWindowByRegex(args);
if (!PWINDOWTOCHANGETO || PWINDOWTOCHANGETO == PLASTWINDOW) { if (!PWINDOWTOCHANGETO || PWINDOWTOCHANGETO == PLASTWINDOW) {
Debug::log(ERR, "Can't swap with {}, invalid window", args); Log::logger->log(Log::ERR, "Can't swap with {}, invalid window", args);
return {.success = false, .error = std::format("Can't swap with {}, invalid window", args)}; return {.success = false, .error = std::format("Can't swap with {}, invalid window", args)};
} }
Debug::log(LOG, "Swapping active window with {}", args); Log::logger->log(Log::DEBUG, "Swapping active window with {}", args);
updateRelativeCursorCoords(); updateRelativeCursorCoords();
g_pLayoutManager->getCurrentLayout()->switchWindows(PLASTWINDOW, PWINDOWTOCHANGETO); g_pLayoutManager->getCurrentLayout()->switchWindows(PLASTWINDOW, PWINDOWTOCHANGETO);
@ -1644,7 +1644,7 @@ SDispatchResult CKeybindManager::moveActiveTo(std::string args) {
} }
if (!isDirection(args)) { if (!isDirection(args)) {
Debug::log(ERR, "Cannot move window in direction {}, unsupported direction. Supported: l,r,u/t,d/b", arg); Log::logger->log(Log::ERR, "Cannot move window in direction {}, unsupported direction. Supported: l,r,u/t,d/b", arg);
return {.success = false, .error = std::format("Cannot move window in direction {}, unsupported direction. Supported: l,r,u/t,d/b", arg)}; return {.success = false, .error = std::format("Cannot move window in direction {}, unsupported direction. Supported: l,r,u/t,d/b", arg)};
} }
@ -1807,7 +1807,7 @@ SDispatchResult CKeybindManager::alterSplitRatio(std::string args) {
splitResult = getPlusMinusKeywordResult(args, 0); splitResult = getPlusMinusKeywordResult(args, 0);
if (!splitResult.has_value()) { if (!splitResult.has_value()) {
Debug::log(ERR, "Splitratio invalid in alterSplitRatio!"); Log::logger->log(Log::ERR, "Splitratio invalid in alterSplitRatio!");
return {.success = false, .error = "Splitratio invalid in alterSplitRatio!"}; return {.success = false, .error = "Splitratio invalid in alterSplitRatio!"};
} }
@ -1830,14 +1830,14 @@ SDispatchResult CKeybindManager::focusMonitor(std::string arg) {
SDispatchResult CKeybindManager::moveCursorToCorner(std::string arg) { SDispatchResult CKeybindManager::moveCursorToCorner(std::string arg) {
if (!isNumber(arg)) { if (!isNumber(arg)) {
Debug::log(ERR, "moveCursorToCorner, arg has to be a number."); Log::logger->log(Log::ERR, "moveCursorToCorner, arg has to be a number.");
return {.success = false, .error = "moveCursorToCorner, arg has to be a number."}; return {.success = false, .error = "moveCursorToCorner, arg has to be a number."};
} }
const auto CORNER = std::stoi(arg); const auto CORNER = std::stoi(arg);
if (CORNER < 0 || CORNER > 3) { if (CORNER < 0 || CORNER > 3) {
Debug::log(ERR, "moveCursorToCorner, corner not 0 - 3."); Log::logger->log(Log::ERR, "moveCursorToCorner, corner not 0 - 3.");
return {.success = false, .error = "moveCursorToCorner, corner not 0 - 3."}; return {.success = false, .error = "moveCursorToCorner, corner not 0 - 3."};
} }
@ -1875,7 +1875,7 @@ SDispatchResult CKeybindManager::moveCursor(std::string args) {
size_t i = args.find_first_of(' '); size_t i = args.find_first_of(' ');
if (i == std::string::npos) { if (i == std::string::npos) {
Debug::log(ERR, "moveCursor, takes 2 arguments."); Log::logger->log(Log::ERR, "moveCursor, takes 2 arguments.");
return {.success = false, .error = "moveCursor, takes 2 arguments"}; return {.success = false, .error = "moveCursor, takes 2 arguments"};
} }
@ -1883,11 +1883,11 @@ SDispatchResult CKeybindManager::moveCursor(std::string args) {
y_str = args.substr(i + 1); y_str = args.substr(i + 1);
if (!isNumber(x_str)) { if (!isNumber(x_str)) {
Debug::log(ERR, "moveCursor, x argument has to be a number."); Log::logger->log(Log::ERR, "moveCursor, x argument has to be a number.");
return {.success = false, .error = "moveCursor, x argument has to be a number."}; return {.success = false, .error = "moveCursor, x argument has to be a number."};
} }
if (!isNumber(y_str)) { if (!isNumber(y_str)) {
Debug::log(ERR, "moveCursor, y argument has to be a number."); Log::logger->log(Log::ERR, "moveCursor, y argument has to be a number.");
return {.success = false, .error = "moveCursor, y argument has to be a number."}; return {.success = false, .error = "moveCursor, y argument has to be a number."};
} }
@ -1945,7 +1945,7 @@ SDispatchResult CKeybindManager::workspaceOpt(std::string args) {
} }
} }
} else { } else {
Debug::log(ERR, "Invalid arg in workspaceOpt, opt \"{}\" doesn't exist.", args); Log::logger->log(Log::ERR, "Invalid arg in workspaceOpt, opt \"{}\" doesn't exist.", args);
return {.success = false, .error = std::format("Invalid arg in workspaceOpt, opt \"{}\" doesn't exist.", args)}; return {.success = false, .error = std::format("Invalid arg in workspaceOpt, opt \"{}\" doesn't exist.", args)};
} }
@ -1970,7 +1970,7 @@ SDispatchResult CKeybindManager::renameWorkspace(std::string args) {
else else
return {.success = false, .error = "No such workspace"}; return {.success = false, .error = "No such workspace"};
} catch (std::exception& e) { } catch (std::exception& e) {
Debug::log(ERR, R"(Invalid arg in renameWorkspace, expected numeric id only or a numeric id and string name. "{}": "{}")", args, e.what()); Log::logger->log(Log::ERR, R"(Invalid arg in renameWorkspace, expected numeric id only or a numeric id and string name. "{}": "{}")", args, e.what());
return {.success = false, .error = std::format(R"(Invalid arg in renameWorkspace, expected numeric id only or a numeric id and string name. "{}": "{}")", args, e.what())}; return {.success = false, .error = std::format(R"(Invalid arg in renameWorkspace, expected numeric id only or a numeric id and string name. "{}": "{}")", args, e.what())};
} }
@ -1991,14 +1991,14 @@ SDispatchResult CKeybindManager::moveCurrentWorkspaceToMonitor(std::string args)
PHLMONITOR PMONITOR = g_pCompositor->getMonitorFromString(args); PHLMONITOR PMONITOR = g_pCompositor->getMonitorFromString(args);
if (!PMONITOR) { if (!PMONITOR) {
Debug::log(ERR, "Ignoring moveCurrentWorkspaceToMonitor: monitor doesn't exist"); Log::logger->log(Log::ERR, "Ignoring moveCurrentWorkspaceToMonitor: monitor doesn't exist");
return {.success = false, .error = "Ignoring moveCurrentWorkspaceToMonitor: monitor doesn't exist"}; return {.success = false, .error = "Ignoring moveCurrentWorkspaceToMonitor: monitor doesn't exist"};
} }
// get the current workspace // get the current workspace
const auto PCURRENTWORKSPACE = Desktop::focusState()->monitor()->m_activeWorkspace; const auto PCURRENTWORKSPACE = Desktop::focusState()->monitor()->m_activeWorkspace;
if (!PCURRENTWORKSPACE) { if (!PCURRENTWORKSPACE) {
Debug::log(ERR, "moveCurrentWorkspaceToMonitor invalid workspace!"); Log::logger->log(Log::ERR, "moveCurrentWorkspaceToMonitor invalid workspace!");
return {.success = false, .error = "moveCurrentWorkspaceToMonitor invalid workspace!"}; return {.success = false, .error = "moveCurrentWorkspaceToMonitor invalid workspace!"};
} }
@ -2017,21 +2017,21 @@ SDispatchResult CKeybindManager::moveWorkspaceToMonitor(std::string args) {
const auto PMONITOR = g_pCompositor->getMonitorFromString(monitor); const auto PMONITOR = g_pCompositor->getMonitorFromString(monitor);
if (!PMONITOR) { if (!PMONITOR) {
Debug::log(ERR, "Ignoring moveWorkspaceToMonitor: monitor doesn't exist"); Log::logger->log(Log::ERR, "Ignoring moveWorkspaceToMonitor: monitor doesn't exist");
return {.success = false, .error = "Ignoring moveWorkspaceToMonitor: monitor doesn't exist"}; return {.success = false, .error = "Ignoring moveWorkspaceToMonitor: monitor doesn't exist"};
} }
const auto WORKSPACEID = getWorkspaceIDNameFromString(workspace).id; const auto WORKSPACEID = getWorkspaceIDNameFromString(workspace).id;
if (WORKSPACEID == WORKSPACE_INVALID) { if (WORKSPACEID == WORKSPACE_INVALID) {
Debug::log(ERR, "moveWorkspaceToMonitor invalid workspace!"); Log::logger->log(Log::ERR, "moveWorkspaceToMonitor invalid workspace!");
return {.success = false, .error = "moveWorkspaceToMonitor invalid workspace!"}; return {.success = false, .error = "moveWorkspaceToMonitor invalid workspace!"};
} }
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(WORKSPACEID); const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(WORKSPACEID);
if (!PWORKSPACE) { if (!PWORKSPACE) {
Debug::log(ERR, "moveWorkspaceToMonitor workspace doesn't exist!"); Log::logger->log(Log::ERR, "moveWorkspaceToMonitor workspace doesn't exist!");
return {.success = false, .error = "moveWorkspaceToMonitor workspace doesn't exist!"}; return {.success = false, .error = "moveWorkspaceToMonitor workspace doesn't exist!"};
} }
@ -2043,14 +2043,14 @@ SDispatchResult CKeybindManager::moveWorkspaceToMonitor(std::string args) {
SDispatchResult CKeybindManager::focusWorkspaceOnCurrentMonitor(std::string args) { SDispatchResult CKeybindManager::focusWorkspaceOnCurrentMonitor(std::string args) {
auto [workspaceID, workspaceName, isAutoID] = getWorkspaceIDNameFromString(args); auto [workspaceID, workspaceName, isAutoID] = getWorkspaceIDNameFromString(args);
if (workspaceID == WORKSPACE_INVALID) { if (workspaceID == WORKSPACE_INVALID) {
Debug::log(ERR, "focusWorkspaceOnCurrentMonitor invalid workspace!"); Log::logger->log(Log::ERR, "focusWorkspaceOnCurrentMonitor invalid workspace!");
return {.success = false, .error = "focusWorkspaceOnCurrentMonitor invalid workspace!"}; return {.success = false, .error = "focusWorkspaceOnCurrentMonitor invalid workspace!"};
} }
const auto PCURRMONITOR = Desktop::focusState()->monitor(); const auto PCURRMONITOR = Desktop::focusState()->monitor();
if (!PCURRMONITOR) { if (!PCURRMONITOR) {
Debug::log(ERR, "focusWorkspaceOnCurrentMonitor monitor doesn't exist!"); Log::logger->log(Log::ERR, "focusWorkspaceOnCurrentMonitor monitor doesn't exist!");
return {.success = false, .error = "focusWorkspaceOnCurrentMonitor monitor doesn't exist!"}; return {.success = false, .error = "focusWorkspaceOnCurrentMonitor monitor doesn't exist!"};
} }
@ -2078,7 +2078,7 @@ SDispatchResult CKeybindManager::focusWorkspaceOnCurrentMonitor(std::string args
if (pWorkspace->m_monitor != PCURRMONITOR) { if (pWorkspace->m_monitor != PCURRMONITOR) {
const auto POLDMONITOR = pWorkspace->m_monitor.lock(); const auto POLDMONITOR = pWorkspace->m_monitor.lock();
if (!POLDMONITOR) { // wat if (!POLDMONITOR) { // wat
Debug::log(ERR, "focusWorkspaceOnCurrentMonitor old monitor doesn't exist!"); Log::logger->log(Log::ERR, "focusWorkspaceOnCurrentMonitor old monitor doesn't exist!");
return {.success = false, .error = "focusWorkspaceOnCurrentMonitor old monitor doesn't exist!"}; return {.success = false, .error = "focusWorkspaceOnCurrentMonitor old monitor doesn't exist!"};
} }
if (POLDMONITOR->activeWorkspaceID() == workspaceID) { if (POLDMONITOR->activeWorkspaceID() == workspaceID) {
@ -2097,7 +2097,7 @@ SDispatchResult CKeybindManager::focusWorkspaceOnCurrentMonitor(std::string args
SDispatchResult CKeybindManager::toggleSpecialWorkspace(std::string args) { SDispatchResult CKeybindManager::toggleSpecialWorkspace(std::string args) {
const auto& [workspaceID, workspaceName, isAutoID] = getWorkspaceIDNameFromString("special:" + args); const auto& [workspaceID, workspaceName, isAutoID] = getWorkspaceIDNameFromString("special:" + args);
if (workspaceID == WORKSPACE_INVALID || !g_pCompositor->isWorkspaceSpecial(workspaceID)) { if (workspaceID == WORKSPACE_INVALID || !g_pCompositor->isWorkspaceSpecial(workspaceID)) {
Debug::log(ERR, "Invalid workspace passed to special"); Log::logger->log(Log::ERR, "Invalid workspace passed to special");
return {.success = false, .error = "Invalid workspace passed to special"}; return {.success = false, .error = "Invalid workspace passed to special"};
} }
@ -2118,12 +2118,12 @@ SDispatchResult CKeybindManager::toggleSpecialWorkspace(std::string args) {
if (requestedWorkspaceIsAlreadyOpen && specialOpenOnMonitor == workspaceID) { if (requestedWorkspaceIsAlreadyOpen && specialOpenOnMonitor == workspaceID) {
// already open on this monitor // already open on this monitor
Debug::log(LOG, "Toggling special workspace {} to closed", workspaceID); Log::logger->log(Log::DEBUG, "Toggling special workspace {} to closed", workspaceID);
PMONITOR->setSpecialWorkspace(nullptr); PMONITOR->setSpecialWorkspace(nullptr);
focusedWorkspace = PMONITOR->m_activeWorkspace; focusedWorkspace = PMONITOR->m_activeWorkspace;
} else { } else {
Debug::log(LOG, "Toggling special workspace {} to open", workspaceID); Log::logger->log(Log::DEBUG, "Toggling special workspace {} to open", workspaceID);
auto PSPECIALWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceID); auto PSPECIALWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceID);
if (!PSPECIALWORKSPACE) if (!PSPECIALWORKSPACE)
@ -2213,7 +2213,7 @@ SDispatchResult CKeybindManager::moveWindow(std::string args) {
const auto PWINDOW = g_pCompositor->getWindowByRegex(WINDOWREGEX); const auto PWINDOW = g_pCompositor->getWindowByRegex(WINDOWREGEX);
if (!PWINDOW) { if (!PWINDOW) {
Debug::log(ERR, "moveWindow: no window"); Log::logger->log(Log::ERR, "moveWindow: no window");
return {.success = false, .error = "moveWindow: no window"}; return {.success = false, .error = "moveWindow: no window"};
} }
@ -2235,7 +2235,7 @@ SDispatchResult CKeybindManager::resizeWindow(std::string args) {
const auto PWINDOW = g_pCompositor->getWindowByRegex(WINDOWREGEX); const auto PWINDOW = g_pCompositor->getWindowByRegex(WINDOWREGEX);
if (!PWINDOW) { if (!PWINDOW) {
Debug::log(ERR, "resizeWindow: no window"); Log::logger->log(Log::ERR, "resizeWindow: no window");
return {.success = false, .error = "resizeWindow: no window"}; return {.success = false, .error = "resizeWindow: no window"};
} }
@ -2293,11 +2293,11 @@ SDispatchResult CKeybindManager::focusWindow(std::string regexp) {
if (!PWINDOW) if (!PWINDOW)
return {.success = false, .error = "No such window found"}; return {.success = false, .error = "No such window found"};
Debug::log(LOG, "Focusing to window name: {}", PWINDOW->m_title); Log::logger->log(Log::DEBUG, "Focusing to window name: {}", PWINDOW->m_title);
const auto PWORKSPACE = PWINDOW->m_workspace; const auto PWORKSPACE = PWINDOW->m_workspace;
if (!PWORKSPACE) { if (!PWORKSPACE) {
Debug::log(ERR, "BUG THIS: null workspace in focusWindow"); Log::logger->log(Log::ERR, "BUG THIS: null workspace in focusWindow");
return {.success = false, .error = "BUG THIS: null workspace in focusWindow"}; return {.success = false, .error = "BUG THIS: null workspace in focusWindow"};
} }
@ -2305,7 +2305,7 @@ SDispatchResult CKeybindManager::focusWindow(std::string regexp) {
if (Desktop::focusState()->monitor() && Desktop::focusState()->monitor()->m_activeWorkspace != PWINDOW->m_workspace && if (Desktop::focusState()->monitor() && Desktop::focusState()->monitor()->m_activeWorkspace != PWINDOW->m_workspace &&
Desktop::focusState()->monitor()->m_activeSpecialWorkspace != PWINDOW->m_workspace) { Desktop::focusState()->monitor()->m_activeSpecialWorkspace != PWINDOW->m_workspace) {
Debug::log(LOG, "Fake executing workspace to move focus"); Log::logger->log(Log::DEBUG, "Fake executing workspace to move focus");
changeworkspace(PWORKSPACE->getConfigName()); changeworkspace(PWORKSPACE->getConfigName());
} }
@ -2359,7 +2359,7 @@ SDispatchResult CKeybindManager::toggleSwallow(std::string args) {
SDispatchResult CKeybindManager::setSubmap(std::string submap) { SDispatchResult CKeybindManager::setSubmap(std::string submap) {
if (submap == "reset" || submap.empty()) { if (submap == "reset" || submap.empty()) {
m_currentSelectedSubmap.name = ""; m_currentSelectedSubmap.name = "";
Debug::log(LOG, "Reset active submap to the default one."); Log::logger->log(Log::DEBUG, "Reset active submap to the default one.");
g_pEventManager->postEvent(SHyprIPCEvent{"submap", ""}); g_pEventManager->postEvent(SHyprIPCEvent{"submap", ""});
EMIT_HOOK_EVENT("submap", m_currentSelectedSubmap.name); EMIT_HOOK_EVENT("submap", m_currentSelectedSubmap.name);
return {}; return {};
@ -2368,14 +2368,14 @@ SDispatchResult CKeybindManager::setSubmap(std::string submap) {
for (const auto& k : g_pKeybindManager->m_keybinds) { for (const auto& k : g_pKeybindManager->m_keybinds) {
if (k->submap.name == submap) { if (k->submap.name == submap) {
m_currentSelectedSubmap.name = submap; m_currentSelectedSubmap.name = submap;
Debug::log(LOG, "Changed keybind submap to {}", submap); Log::logger->log(Log::DEBUG, "Changed keybind submap to {}", submap);
g_pEventManager->postEvent(SHyprIPCEvent{"submap", submap}); g_pEventManager->postEvent(SHyprIPCEvent{"submap", submap});
EMIT_HOOK_EVENT("submap", m_currentSelectedSubmap.name); EMIT_HOOK_EVENT("submap", m_currentSelectedSubmap.name);
return {}; return {};
} }
} }
Debug::log(ERR, "Cannot set submap {}, submap doesn't exist (wasn't registered!)", submap); Log::logger->log(Log::ERR, "Cannot set submap {}, submap doesn't exist (wasn't registered!)", submap);
return {.success = false, .error = std::format("Cannot set submap {}, submap doesn't exist (wasn't registered!)", submap)}; return {.success = false, .error = std::format("Cannot set submap {}, submap doesn't exist (wasn't registered!)", submap)};
} }
@ -2385,12 +2385,12 @@ SDispatchResult CKeybindManager::pass(std::string regexp) {
const auto PWINDOW = g_pCompositor->getWindowByRegex(regexp); const auto PWINDOW = g_pCompositor->getWindowByRegex(regexp);
if (!PWINDOW) { if (!PWINDOW) {
Debug::log(ERR, "pass: window not found"); Log::logger->log(Log::ERR, "pass: window not found");
return {.success = false, .error = "pass: window not found"}; return {.success = false, .error = "pass: window not found"};
} }
if (!g_pSeatManager->m_keyboard) { if (!g_pSeatManager->m_keyboard) {
Debug::log(ERR, "No kb in pass?"); Log::logger->log(Log::ERR, "No kb in pass?");
return {.success = false, .error = "No kb in pass?"}; return {.success = false, .error = "No kb in pass?"};
} }
@ -2459,7 +2459,7 @@ SDispatchResult CKeybindManager::sendshortcut(std::string args) {
// args=<NEW_MODKEYS><NEW_KEY>[,WINDOW_RULES] // args=<NEW_MODKEYS><NEW_KEY>[,WINDOW_RULES]
const auto ARGS = CVarList(args, 3); const auto ARGS = CVarList(args, 3);
if (ARGS.size() != 3) { if (ARGS.size() != 3) {
Debug::log(ERR, "sendshortcut: invalid args"); Log::logger->log(Log::ERR, "sendshortcut: invalid args");
return {.success = false, .error = "sendshortcut: invalid args"}; return {.success = false, .error = "sendshortcut: invalid args"};
} }
@ -2477,7 +2477,7 @@ SDispatchResult CKeybindManager::sendshortcut(std::string args) {
keycode = std::stoi(KEY.substr(6)); keycode = std::stoi(KEY.substr(6));
isMouse = true; isMouse = true;
if (keycode < 272) { if (keycode < 272) {
Debug::log(ERR, "sendshortcut: invalid mouse button"); Log::logger->log(Log::ERR, "sendshortcut: invalid mouse button");
return {.success = false, .error = "sendshortcut: invalid mouse button"}; return {.success = false, .error = "sendshortcut: invalid mouse button"};
} }
} else { } else {
@ -2492,7 +2492,7 @@ SDispatchResult CKeybindManager::sendshortcut(std::string args) {
const auto KB = g_pSeatManager->m_keyboard; const auto KB = g_pSeatManager->m_keyboard;
if (!KB) { if (!KB) {
Debug::log(ERR, "sendshortcut: no kb"); Log::logger->log(Log::ERR, "sendshortcut: no kb");
return {.success = false, .error = "sendshortcut: no kb"}; return {.success = false, .error = "sendshortcut: no kb"};
} }
@ -2516,7 +2516,7 @@ SDispatchResult CKeybindManager::sendshortcut(std::string args) {
} }
if (!keycode) { if (!keycode) {
Debug::log(ERR, "sendshortcut: key not found"); Log::logger->log(Log::ERR, "sendshortcut: key not found");
return {.success = false, .error = "sendshortcut: key not found"}; return {.success = false, .error = "sendshortcut: key not found"};
} }
@ -2525,7 +2525,7 @@ SDispatchResult CKeybindManager::sendshortcut(std::string args) {
} }
if (!keycode) { if (!keycode) {
Debug::log(ERR, "sendshortcut: invalid key"); Log::logger->log(Log::ERR, "sendshortcut: invalid key");
return {.success = false, .error = "sendshortcut: invalid key"}; return {.success = false, .error = "sendshortcut: invalid key"};
} }
@ -2539,12 +2539,12 @@ SDispatchResult CKeybindManager::sendshortcut(std::string args) {
PWINDOW = g_pCompositor->getWindowByRegex(regexp); PWINDOW = g_pCompositor->getWindowByRegex(regexp);
if (!PWINDOW) { if (!PWINDOW) {
Debug::log(ERR, "sendshortcut: window not found"); Log::logger->log(Log::ERR, "sendshortcut: window not found");
return {.success = false, .error = "sendshortcut: window not found"}; return {.success = false, .error = "sendshortcut: window not found"};
} }
if (!g_pSeatManager->m_keyboard) { if (!g_pSeatManager->m_keyboard) {
Debug::log(ERR, "No kb in sendshortcut?"); Log::logger->log(Log::ERR, "No kb in sendshortcut?");
return {.success = false, .error = "No kb in sendshortcut?"}; return {.success = false, .error = "No kb in sendshortcut?"};
} }
@ -2704,7 +2704,7 @@ SDispatchResult CKeybindManager::pinActive(std::string args) {
PWINDOW = Desktop::focusState()->window(); PWINDOW = Desktop::focusState()->window();
if (!PWINDOW) { if (!PWINDOW) {
Debug::log(ERR, "pin: window not found"); Log::logger->log(Log::ERR, "pin: window not found");
return {.success = false, .error = "pin: window not found"}; return {.success = false, .error = "pin: window not found"};
} }
@ -2716,7 +2716,7 @@ SDispatchResult CKeybindManager::pinActive(std::string args) {
const auto PMONITOR = PWINDOW->m_monitor.lock(); const auto PMONITOR = PWINDOW->m_monitor.lock();
if (!PMONITOR) { if (!PMONITOR) {
Debug::log(ERR, "pin: monitor not found"); Log::logger->log(Log::ERR, "pin: monitor not found");
return {.success = false, .error = "pin: window not found"}; return {.success = false, .error = "pin: window not found"};
} }
@ -2803,7 +2803,7 @@ SDispatchResult CKeybindManager::alterZOrder(std::string args) {
PWINDOW = Desktop::focusState()->window(); PWINDOW = Desktop::focusState()->window();
if (!PWINDOW) { if (!PWINDOW) {
Debug::log(ERR, "alterZOrder: no window"); Log::logger->log(Log::ERR, "alterZOrder: no window");
return {.success = false, .error = "alterZOrder: no window"}; return {.success = false, .error = "alterZOrder: no window"};
} }
@ -2812,7 +2812,7 @@ SDispatchResult CKeybindManager::alterZOrder(std::string args) {
else if (POSITION == "bottom") else if (POSITION == "bottom")
g_pCompositor->changeWindowZOrder(PWINDOW, false); g_pCompositor->changeWindowZOrder(PWINDOW, false);
else { else {
Debug::log(ERR, "alterZOrder: bad position: {}", POSITION); Log::logger->log(Log::ERR, "alterZOrder: bad position: {}", POSITION);
return {.success = false, .error = "alterZOrder: bad position: {}"}; return {.success = false, .error = "alterZOrder: bad position: {}"};
} }
@ -2933,7 +2933,7 @@ SDispatchResult CKeybindManager::moveIntoGroup(std::string args) {
return {}; return {};
if (!isDirection(args)) { if (!isDirection(args)) {
Debug::log(ERR, "Cannot move into group in direction {}, unsupported direction. Supported: l,r,u/t,d/b", arg); Log::logger->log(Log::ERR, "Cannot move into group in direction {}, unsupported direction. Supported: l,r,u/t,d/b", arg);
return {.success = false, .error = std::format("Cannot move into group in direction {}, unsupported direction. Supported: l,r,u/t,d/b", arg)}; return {.success = false, .error = std::format("Cannot move into group in direction {}, unsupported direction. Supported: l,r,u/t,d/b", arg)};
} }
@ -2986,7 +2986,7 @@ SDispatchResult CKeybindManager::moveWindowOrGroup(std::string args) {
static auto PIGNOREGROUPLOCK = CConfigValue<Hyprlang::INT>("binds:ignore_group_lock"); static auto PIGNOREGROUPLOCK = CConfigValue<Hyprlang::INT>("binds:ignore_group_lock");
if (!isDirection(args)) { if (!isDirection(args)) {
Debug::log(ERR, "Cannot move into group in direction {}, unsupported direction. Supported: l,r,u/t,d/b", arg); Log::logger->log(Log::ERR, "Cannot move into group in direction {}, unsupported direction. Supported: l,r,u/t,d/b", arg);
return {.success = false, .error = std::format("Cannot move into group in direction {}, unsupported direction. Supported: l,r,u/t,d/b", arg)}; return {.success = false, .error = std::format("Cannot move into group in direction {}, unsupported direction. Supported: l,r,u/t,d/b", arg)};
} }
@ -3138,7 +3138,7 @@ static void parsePropTrivial(Desktop::Types::COverridableVar<T>& prop, const std
prop = Desktop::Types::COverridableVar<T>(std::stof(s), Desktop::Types::PRIORITY_SET_PROP); prop = Desktop::Types::COverridableVar<T>(std::stof(s), Desktop::Types::PRIORITY_SET_PROP);
} else if constexpr (std::is_same_v<T, std::string>) } else if constexpr (std::is_same_v<T, std::string>)
prop = Desktop::Types::COverridableVar<T>(s, Desktop::Types::PRIORITY_SET_PROP); prop = Desktop::Types::COverridableVar<T>(s, Desktop::Types::PRIORITY_SET_PROP);
} catch (...) { Debug::log(ERR, "Hyprctl: parsePropTrivial: failed to parse setprop for {}", s); } } catch (...) { Log::logger->log(Log::ERR, "Hyprctl: parsePropTrivial: failed to parse setprop for {}", s); }
} }
SDispatchResult CKeybindManager::setProp(std::string args) { SDispatchResult CKeybindManager::setProp(std::string args) {
@ -3302,7 +3302,7 @@ SDispatchResult CKeybindManager::forceIdle(std::string args) {
std::optional<float> duration = getPlusMinusKeywordResult(args, 0); std::optional<float> duration = getPlusMinusKeywordResult(args, 0);
if (!duration.has_value()) { if (!duration.has_value()) {
Debug::log(ERR, "Duration invalid in forceIdle!"); Log::logger->log(Log::ERR, "Duration invalid in forceIdle!");
return {.success = false, .error = "Duration invalid in forceIdle!"}; return {.success = false, .error = "Duration invalid in forceIdle!"};
} }
@ -3315,14 +3315,14 @@ SDispatchResult CKeybindManager::sendkeystate(std::string args) {
// args=<NEW_MODKEYS><NEW_KEY><STATE>[,WINDOW_RULES] // args=<NEW_MODKEYS><NEW_KEY><STATE>[,WINDOW_RULES]
const auto ARGS = CVarList(args, 4); const auto ARGS = CVarList(args, 4);
if (ARGS.size() != 4) { if (ARGS.size() != 4) {
Debug::log(ERR, "sendkeystate: invalid args"); Log::logger->log(Log::ERR, "sendkeystate: invalid args");
return {.success = false, .error = "sendkeystate: invalid args"}; return {.success = false, .error = "sendkeystate: invalid args"};
} }
const auto STATE = ARGS[2]; const auto STATE = ARGS[2];
if (STATE != "down" && STATE != "repeat" && STATE != "up") { if (STATE != "down" && STATE != "repeat" && STATE != "up") {
Debug::log(ERR, "sendkeystate: invalid state, must be 'down', 'repeat', or 'up'"); Log::logger->log(Log::ERR, "sendkeystate: invalid state, must be 'down', 'repeat', or 'up'");
return {.success = false, .error = "sendkeystate: invalid state, must be 'down', 'repeat', or 'up'"}; return {.success = false, .error = "sendkeystate: invalid state, must be 'down', 'repeat', or 'up'"};
} }

View file

@ -22,7 +22,7 @@ void CLayoutManager::switchToLayout(std::string layout) {
} }
} }
Debug::log(ERR, "Unknown layout!"); Log::logger->log(Log::ERR, "Unknown layout!");
} }
bool CLayoutManager::addLayout(const std::string& name, IHyprLayout* layout) { bool CLayoutManager::addLayout(const std::string& name, IHyprLayout* layout) {
@ -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, rc<uintptr_t>(layout)); Log::logger->log(Log::DEBUG, "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, rc<uintptr_t>(layout)); Log::logger->log(Log::DEBUG, "Removed a layout {} at {:x}", IT->first, rc<uintptr_t>(layout));
std::erase(m_layouts, *IT); std::erase(m_layouts, *IT);

View file

@ -243,7 +243,7 @@ void CPointerManager::resetCursorImage(bool apply) {
for (auto const& ms : m_monitorStates) { for (auto const& ms : m_monitorStates) {
if (!ms->monitor || !ms->monitor->m_enabled || !ms->monitor->m_dpmsStatus) { if (!ms->monitor || !ms->monitor->m_enabled || !ms->monitor->m_dpmsStatus) {
Debug::log(TRACE, "Not updating hw cursors: disabled / dpms off display"); Log::logger->log(Log::TRACE, "Not updating hw cursors: disabled / dpms off display");
continue; continue;
} }
@ -260,7 +260,7 @@ void CPointerManager::updateCursorBackend() {
for (auto const& m : g_pCompositor->m_monitors) { for (auto const& m : g_pCompositor->m_monitors) {
if (!m->m_enabled || !m->m_dpmsStatus) { if (!m->m_enabled || !m->m_dpmsStatus) {
Debug::log(TRACE, "Not updating hw cursors: disabled / dpms off display"); Log::logger->log(Log::TRACE, "Not updating hw cursors: disabled / dpms off display");
continue; continue;
} }
@ -275,7 +275,7 @@ void CPointerManager::updateCursorBackend() {
} }
if (state->softwareLocks > 0 || g_pConfigManager->shouldUseSoftwareCursors(m) || !attemptHardwareCursor(state)) { if (state->softwareLocks > 0 || g_pConfigManager->shouldUseSoftwareCursors(m) || !attemptHardwareCursor(state)) {
Debug::log(TRACE, "Output {} rejected hardware cursors, falling back to sw", m->m_name); Log::logger->log(Log::TRACE, "Output {} rejected hardware cursors, falling back to sw", m->m_name);
state->box = getCursorBoxLogicalForMonitor(state->monitor.lock()); state->box = getCursorBoxLogicalForMonitor(state->monitor.lock());
state->hardwareFailed = true; state->hardwareFailed = true;
@ -305,11 +305,11 @@ void CPointerManager::onCursorMoved() {
auto CROSSES = !m->logicalBox().intersection(CURSORBOX).empty(); auto CROSSES = !m->logicalBox().intersection(CURSORBOX).empty();
if (!CROSSES && state->cursorFrontBuffer) { if (!CROSSES && state->cursorFrontBuffer) {
Debug::log(TRACE, "onCursorMoved for output {}: cursor left the viewport, removing it from the backend", m->m_name); Log::logger->log(Log::TRACE, "onCursorMoved for output {}: cursor left the viewport, removing it from the backend", m->m_name);
setHWCursorBuffer(state, nullptr); setHWCursorBuffer(state, nullptr);
continue; continue;
} else if (CROSSES && !state->cursorFrontBuffer) { } else if (CROSSES && !state->cursorFrontBuffer) {
Debug::log(TRACE, "onCursorMoved for output {}: cursor entered the output, but no front buffer, forcing recalc", m->m_name); Log::logger->log(Log::TRACE, "onCursorMoved for output {}: cursor entered the output, but no front buffer, forcing recalc", m->m_name);
recalc = true; recalc = true;
} }
@ -343,7 +343,7 @@ bool CPointerManager::attemptHardwareCursor(SP<CPointerManager::SMonitorPointerS
auto texture = getCurrentCursorTexture(); auto texture = getCurrentCursorTexture();
if (!texture) { if (!texture) {
Debug::log(TRACE, "[pointer] no texture for hw cursor -> hiding"); Log::logger->log(Log::TRACE, "[pointer] no texture for hw cursor -> hiding");
setHWCursorBuffer(state, nullptr); setHWCursorBuffer(state, nullptr);
return true; return true;
} }
@ -351,7 +351,7 @@ bool CPointerManager::attemptHardwareCursor(SP<CPointerManager::SMonitorPointerS
auto buffer = renderHWCursorBuffer(state, texture); auto buffer = renderHWCursorBuffer(state, texture);
if (!buffer) { if (!buffer) {
Debug::log(TRACE, "[pointer] hw cursor failed rendering"); Log::logger->log(Log::TRACE, "[pointer] hw cursor failed rendering");
setHWCursorBuffer(state, nullptr); setHWCursorBuffer(state, nullptr);
return false; return false;
} }
@ -359,7 +359,7 @@ bool CPointerManager::attemptHardwareCursor(SP<CPointerManager::SMonitorPointerS
bool success = setHWCursorBuffer(state, buffer); bool success = setHWCursorBuffer(state, buffer);
if (!success) { if (!success) {
Debug::log(TRACE, "[pointer] hw cursor failed applying, hiding"); Log::logger->log(Log::TRACE, "[pointer] hw cursor failed applying, hiding");
setHWCursorBuffer(state, nullptr); setHWCursorBuffer(state, nullptr);
return false; return false;
} else } else
@ -374,7 +374,7 @@ bool CPointerManager::setHWCursorBuffer(SP<SMonitorPointerState> state, SP<Aquam
const auto HOTSPOT = transformedHotspot(state->monitor.lock()); const auto HOTSPOT = transformedHotspot(state->monitor.lock());
Debug::log(TRACE, "[pointer] hw transformed hotspot for {}: {}", state->monitor->m_name, HOTSPOT); Log::logger->log(Log::TRACE, "[pointer] hw transformed hotspot for {}: {}", state->monitor->m_name, HOTSPOT);
if (!state->monitor->m_output->setCursor(buf, HOTSPOT)) if (!state->monitor->m_output->setCursor(buf, HOTSPOT))
return false; return false;
@ -402,7 +402,7 @@ SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager
if (maxSize != Vector2D{-1, -1}) { if (maxSize != Vector2D{-1, -1}) {
if (cursorSize.x > maxSize.x || cursorSize.y > maxSize.y) { if (cursorSize.x > maxSize.x || cursorSize.y > maxSize.y) {
Debug::log(TRACE, "hardware cursor too big! {} > {}", m_currentCursorImage.size, maxSize); Log::logger->log(Log::TRACE, "hardware cursor too big! {} > {}", m_currentCursorImage.size, maxSize);
return nullptr; return nullptr;
} }
} else } else
@ -440,7 +440,7 @@ SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager
options.format = DRM_FORMAT_ARGB8888; options.format = DRM_FORMAT_ARGB8888;
if (!state->monitor->m_cursorSwapchain->reconfigure(options)) { if (!state->monitor->m_cursorSwapchain->reconfigure(options)) {
Debug::log(TRACE, "Failed to reconfigure cursor swapchain"); Log::logger->log(Log::TRACE, "Failed to reconfigure cursor swapchain");
return nullptr; return nullptr;
} }
} }
@ -455,7 +455,7 @@ SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager
auto buf = state->monitor->m_cursorSwapchain->next(nullptr); auto buf = state->monitor->m_cursorSwapchain->next(nullptr);
if (!buf) { if (!buf) {
Debug::log(TRACE, "Failed to acquire a buffer from the cursor swapchain"); Log::logger->log(Log::TRACE, "Failed to acquire a buffer from the cursor swapchain");
return nullptr; return nullptr;
} }
@ -470,12 +470,12 @@ SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager
bool flipRB = false; bool flipRB = false;
if (SURFACE->m_current.texture) { if (SURFACE->m_current.texture) {
Debug::log(TRACE, "Cursor CPU surface: format {}, expecting AR24", NFormatUtils::drmFormatName(SURFACE->m_current.texture->m_drmFormat)); Log::logger->log(Log::TRACE, "Cursor CPU surface: format {}, expecting AR24", NFormatUtils::drmFormatName(SURFACE->m_current.texture->m_drmFormat));
if (SURFACE->m_current.texture->m_drmFormat == DRM_FORMAT_ABGR8888) { if (SURFACE->m_current.texture->m_drmFormat == DRM_FORMAT_ABGR8888) {
Debug::log(TRACE, "Cursor CPU surface format AB24, will flip. WARNING: this will break on big endian!"); Log::logger->log(Log::TRACE, "Cursor CPU surface format AB24, will flip. WARNING: this will break on big endian!");
flipRB = true; flipRB = true;
} else if (SURFACE->m_current.texture->m_drmFormat != DRM_FORMAT_ARGB8888) { } else if (SURFACE->m_current.texture->m_drmFormat != DRM_FORMAT_ARGB8888) {
Debug::log(TRACE, "Cursor CPU surface format rejected, falling back to sw"); Log::logger->log(Log::TRACE, "Cursor CPU surface format rejected, falling back to sw");
return nullptr; return nullptr;
} }
} }
@ -493,7 +493,7 @@ SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager
} }
} }
} else { } else {
Debug::log(TRACE, "Cannot use dumb copy on dmabuf cursor buffers"); Log::logger->log(Log::TRACE, "Cannot use dumb copy on dmabuf cursor buffers");
return nullptr; return nullptr;
} }
} }
@ -566,7 +566,7 @@ SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager
auto RBO = g_pHyprRenderer->getOrCreateRenderbuffer(buf, state->monitor->m_cursorSwapchain->currentOptions().format); auto RBO = g_pHyprRenderer->getOrCreateRenderbuffer(buf, state->monitor->m_cursorSwapchain->currentOptions().format);
if (!RBO) { if (!RBO) {
Debug::log(TRACE, "Failed to create cursor RB with format {}, mod {}", buf->dmabuf().format, buf->dmabuf().modifier); Log::logger->log(Log::TRACE, "Failed to create cursor RB with format {}, mod {}", buf->dmabuf().format, buf->dmabuf().modifier);
return nullptr; return nullptr;
} }
@ -576,8 +576,8 @@ SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager
g_pHyprOpenGL->clear(CHyprColor{0.F, 0.F, 0.F, 0.F}); g_pHyprOpenGL->clear(CHyprColor{0.F, 0.F, 0.F, 0.F});
CBox xbox = {{}, Vector2D{m_currentCursorImage.size / m_currentCursorImage.scale * state->monitor->m_scale}.round()}; CBox xbox = {{}, Vector2D{m_currentCursorImage.size / m_currentCursorImage.scale * state->monitor->m_scale}.round()};
Debug::log(TRACE, "[pointer] monitor: {}, size: {}, hw buf: {}, scale: {:.2f}, monscale: {:.2f}, xbox: {}", state->monitor->m_name, m_currentCursorImage.size, cursorSize, Log::logger->log(Log::TRACE, "[pointer] monitor: {}, size: {}, hw buf: {}, scale: {:.2f}, monscale: {:.2f}, xbox: {}", state->monitor->m_name, m_currentCursorImage.size,
m_currentCursorImage.scale, state->monitor->m_scale, xbox.size()); cursorSize, m_currentCursorImage.scale, state->monitor->m_scale, xbox.size());
g_pHyprOpenGL->renderTexture(texture, xbox, {}); g_pHyprOpenGL->renderTexture(texture, xbox, {});
@ -989,7 +989,7 @@ void CPointerManager::attachPointer(SP<IPointer> pointer) {
PROTO::idle->onActivity(); PROTO::idle->onActivity();
}); });
Debug::log(LOG, "Attached pointer {} to global", pointer->m_hlName); Log::logger->log(Log::DEBUG, "Attached pointer {} to global", pointer->m_hlName);
} }
void CPointerManager::attachTouch(SP<ITouch> touch) { void CPointerManager::attachTouch(SP<ITouch> touch) {
@ -1030,7 +1030,7 @@ void CPointerManager::attachTouch(SP<ITouch> touch) {
listener->frame = touch->m_touchEvents.frame.listen([] { g_pSeatManager->sendTouchFrame(); }); listener->frame = touch->m_touchEvents.frame.listen([] { g_pSeatManager->sendTouchFrame(); });
Debug::log(LOG, "Attached touch {} to global", touch->m_hlName); Log::logger->log(Log::DEBUG, "Attached touch {} to global", touch->m_hlName);
} }
void CPointerManager::attachTablet(SP<CTablet> tablet) { void CPointerManager::attachTablet(SP<CTablet> tablet) {
@ -1075,7 +1075,7 @@ void CPointerManager::attachTablet(SP<CTablet> tablet) {
}); });
// clang-format on // clang-format on
Debug::log(LOG, "Attached tablet {} to global", tablet->m_hlName); Log::logger->log(Log::DEBUG, "Attached tablet {} to global", tablet->m_hlName);
} }
void CPointerManager::detachPointer(SP<IPointer> pointer) { void CPointerManager::detachPointer(SP<IPointer> pointer) {

View file

@ -99,7 +99,7 @@ void CProtocolManager::onMonitorModeChange(PHLMONITOR pMonitor) {
} }
if (PROTO::colorManagement && g_pCompositor->shouldChangePreferredImageDescription()) { if (PROTO::colorManagement && g_pCompositor->shouldChangePreferredImageDescription()) {
Debug::log(ERR, "FIXME: color management protocol is enabled, need a preferred image description id"); Log::logger->log(Log::ERR, "FIXME: color management protocol is enabled, need a preferred image description id");
PROTO::colorManagement->onImagePreferredChanged(0); PROTO::colorManagement->onImagePreferredChanged(0);
} }
} }
@ -222,9 +222,9 @@ CProtocolManager::CProtocolManager() {
if (g_pHyprOpenGL->m_exts.EGL_ANDROID_native_fence_sync_ext && !PROTO::sync) { if (g_pHyprOpenGL->m_exts.EGL_ANDROID_native_fence_sync_ext && !PROTO::sync) {
if (g_pCompositor->supportsDrmSyncobjTimeline()) { if (g_pCompositor->supportsDrmSyncobjTimeline()) {
PROTO::sync = makeUnique<CDRMSyncobjProtocol>(&wp_linux_drm_syncobj_manager_v1_interface, 1, "DRMSyncobj"); PROTO::sync = makeUnique<CDRMSyncobjProtocol>(&wp_linux_drm_syncobj_manager_v1_interface, 1, "DRMSyncobj");
Debug::log(LOG, "DRM Syncobj Timeline support detected, enabling explicit sync protocol"); Log::logger->log(Log::DEBUG, "DRM Syncobj Timeline support detected, enabling explicit sync protocol");
} else } else
Debug::log(WARN, "DRM Syncobj Timeline not supported, skipping explicit sync protocol"); Log::logger->log(Log::WARN, "DRM Syncobj Timeline not supported, skipping explicit sync protocol");
} }
} }
@ -232,7 +232,7 @@ CProtocolManager::CProtocolManager() {
PROTO::mesaDRM = makeUnique<CMesaDRMProtocol>(&wl_drm_interface, 2, "MesaDRM"); PROTO::mesaDRM = makeUnique<CMesaDRMProtocol>(&wl_drm_interface, 2, "MesaDRM");
PROTO::linuxDma = makeUnique<CLinuxDMABufV1Protocol>(&zwp_linux_dmabuf_v1_interface, 5, "LinuxDMABUF"); PROTO::linuxDma = makeUnique<CLinuxDMABufV1Protocol>(&zwp_linux_dmabuf_v1_interface, 5, "LinuxDMABUF");
} else } else
Debug::log(WARN, "ProtocolManager: Not binding linux-dmabuf and MesaDRM: DMABUF not available"); Log::logger->log(Log::WARN, "ProtocolManager: Not binding linux-dmabuf and MesaDRM: DMABUF not available");
} }
CProtocolManager::~CProtocolManager() { CProtocolManager::~CProtocolManager() {

View file

@ -114,7 +114,7 @@ void CSeatManager::setKeyboardFocus(SP<CWLSurfaceResource> surf) {
return; return;
if (!m_keyboard) { if (!m_keyboard) {
Debug::log(ERR, "BUG THIS: setKeyboardFocus without a valid keyboard set"); Log::logger->log(Log::ERR, "BUG THIS: setKeyboardFocus without a valid keyboard set");
return; return;
} }
@ -217,14 +217,14 @@ void CSeatManager::setPointerFocus(SP<CWLSurfaceResource> surf, const Vector2D&
if (PROTO::data->dndActive() && surf) { if (PROTO::data->dndActive() && surf) {
if (m_state.dndPointerFocus == surf) if (m_state.dndPointerFocus == surf)
return; return;
Debug::log(LOG, "[seatmgr] Refusing pointer focus during an active dnd, but setting dndPointerFocus"); Log::logger->log(Log::DEBUG, "[seatmgr] Refusing pointer focus during an active dnd, but setting dndPointerFocus");
m_state.dndPointerFocus = surf; m_state.dndPointerFocus = surf;
m_events.dndPointerFocusChange.emit(); m_events.dndPointerFocusChange.emit();
return; return;
} }
if (!m_mouse) { if (!m_mouse) {
Debug::log(ERR, "BUG THIS: setPointerFocus without a valid mouse set"); Log::logger->log(Log::ERR, "BUG THIS: setPointerFocus without a valid mouse set");
return; return;
} }
@ -545,13 +545,13 @@ void CSeatManager::refocusGrab() {
void CSeatManager::onSetCursor(SP<CWLSeatResource> seatResource, uint32_t serial, SP<CWLSurfaceResource> surf, const Vector2D& hotspot) { void CSeatManager::onSetCursor(SP<CWLSeatResource> seatResource, uint32_t serial, SP<CWLSurfaceResource> surf, const Vector2D& hotspot) {
if (!m_state.pointerFocusResource || !seatResource || seatResource->client() != m_state.pointerFocusResource->client()) { if (!m_state.pointerFocusResource || !seatResource || seatResource->client() != m_state.pointerFocusResource->client()) {
Debug::log(LOG, "[seatmgr] Rejecting a setCursor because the client ain't in focus"); Log::logger->log(Log::DEBUG, "[seatmgr] Rejecting a setCursor because the client ain't in focus");
return; return;
} }
// TODO: fix this. Probably should be done in the CWlPointer as the serial could be lost by us. // TODO: fix this. Probably should be done in the CWlPointer as the serial could be lost by us.
// if (!serialValid(seatResource, serial)) { // if (!serialValid(seatResource, serial)) {
// Debug::log(LOG, "[seatmgr] Rejecting a setCursor because the serial is invalid"); // Log::logger->log(Log::DEBUG, "[seatmgr] Rejecting a setCursor because the serial is invalid");
// return; // return;
// } // }
@ -564,7 +564,7 @@ SP<CWLSeatResource> CSeatManager::seatResourceForClient(wl_client* client) {
void CSeatManager::setCurrentSelection(SP<IDataSource> source) { void CSeatManager::setCurrentSelection(SP<IDataSource> source) {
if (source == m_selection.currentSelection) { if (source == m_selection.currentSelection) {
Debug::log(WARN, "[seat] duplicated setCurrentSelection?"); Log::logger->log(Log::WARN, "[seat] duplicated setCurrentSelection?");
return; return;
} }
@ -590,7 +590,7 @@ void CSeatManager::setCurrentSelection(SP<IDataSource> source) {
void CSeatManager::setCurrentPrimarySelection(SP<IDataSource> source) { void CSeatManager::setCurrentPrimarySelection(SP<IDataSource> source) {
if (source == m_selection.currentPrimarySelection) { if (source == m_selection.currentPrimarySelection) {
Debug::log(WARN, "[seat] duplicated setCurrentPrimarySelection?"); Log::logger->log(Log::WARN, "[seat] duplicated setCurrentPrimarySelection?");
return; return;
} }
@ -661,7 +661,7 @@ void CSeatManager::setGrab(SP<CSeatGrab> grab) {
// If this was a popup grab, focus its parent window to maintain context // If this was a popup grab, focus its parent window to maintain context
if (validMapped(parentWindow)) { if (validMapped(parentWindow)) {
Desktop::focusState()->rawWindowFocus(parentWindow); Desktop::focusState()->rawWindowFocus(parentWindow);
Debug::log(LOG, "[seatmgr] Refocused popup parent window {} (follow_mouse={})", parentWindow->m_title, *PFOLLOWMOUSE); Log::logger->log(Log::DEBUG, "[seatmgr] Refocused popup parent window {} (follow_mouse={})", parentWindow->m_title, *PFOLLOWMOUSE);
} else } else
g_pInputManager->refocusLastWindow(PMONITOR); g_pInputManager->refocusLastWindow(PMONITOR);
} else } else

View file

@ -52,7 +52,7 @@ void CSessionLockManager::onNewSessionLock(SP<CSessionLock> pLock) {
static auto PALLOWRELOCK = CConfigValue<Hyprlang::INT>("misc:allow_session_lock_restore"); static auto PALLOWRELOCK = CConfigValue<Hyprlang::INT>("misc:allow_session_lock_restore");
if (PROTO::sessionLock->isLocked() && !*PALLOWRELOCK) { if (PROTO::sessionLock->isLocked() && !*PALLOWRELOCK) {
LOGM(LOG, "Cannot re-lock, misc:allow_session_lock_restore is disabled"); LOGM(Log::DEBUG, "Cannot re-lock, misc:allow_session_lock_restore is disabled");
pLock->sendDenied(); pLock->sendDenied();
return; return;
} }
@ -60,7 +60,7 @@ void CSessionLockManager::onNewSessionLock(SP<CSessionLock> pLock) {
if (m_sessionLock && !clientDenied() && !clientLocked()) if (m_sessionLock && !clientDenied() && !clientLocked())
return; // Not allowing to relock in case the old lock is still in a limbo return; // Not allowing to relock in case the old lock is still in a limbo
LOGM(LOG, "Session got locked by {:x}", (uintptr_t)pLock.get()); LOGM(Log::DEBUG, "Session got locked by {:x}", (uintptr_t)pLock.get());
m_sessionLock = makeUnique<SSessionLock>(); m_sessionLock = makeUnique<SSessionLock>();
m_sessionLock->lock = pLock; m_sessionLock->lock = pLock;
@ -123,7 +123,7 @@ void CSessionLockManager::onNewSessionLock(SP<CSessionLock> pLock) {
return; return;
} }
LOGM(WARN, "Kicking lockscreen client, because it failed to render to all outputs within 5 seconds"); LOGM(Log::WARN, "Kicking lockscreen client, because it failed to render to all outputs within 5 seconds");
g_pSessionLockManager->m_sessionLock->lock->sendDenied(); g_pSessionLockManager->m_sessionLock->lock->sendDenied();
g_pSessionLockManager->m_sessionLock->hasSentDenied = true; g_pSessionLockManager->m_sessionLock->hasSentDenied = true;
}, },

View file

@ -1,5 +1,5 @@
#include "VersionKeeperManager.hpp" #include "VersionKeeperManager.hpp"
#include "../debug/Log.hpp" #include "../debug/log/Logger.hpp"
#include "../macros.hpp" #include "../macros.hpp"
#include "../version.h" #include "../version.h"
#include "../helpers/MiscFunctions.hpp" #include "../helpers/MiscFunctions.hpp"
@ -35,19 +35,19 @@ CVersionKeeperManager::CVersionKeeperManager() {
} }
if (!isVersionOlderThanRunning(*LASTVER)) { if (!isVersionOlderThanRunning(*LASTVER)) {
Debug::log(LOG, "CVersionKeeperManager: Read version {} matches or is older than running.", *LASTVER); Log::logger->log(Log::DEBUG, "CVersionKeeperManager: Read version {} matches or is older than running.", *LASTVER);
return; return;
} }
NFsUtils::writeToFile(*DATAROOT + "/" + VERSION_FILE_NAME, HYPRLAND_VERSION); NFsUtils::writeToFile(*DATAROOT + "/" + VERSION_FILE_NAME, HYPRLAND_VERSION);
if (*PNONOTIFY) { if (*PNONOTIFY) {
Debug::log(LOG, "CVersionKeeperManager: updated, but update news is disabled in the config :("); Log::logger->log(Log::DEBUG, "CVersionKeeperManager: updated, but update news is disabled in the config :(");
return; return;
} }
if (!NFsUtils::executableExistsInPath("hyprland-update-screen")) { if (!NFsUtils::executableExistsInPath("hyprland-update-screen")) {
Debug::log(ERR, "CVersionKeeperManager: hyprland-update-screen doesn't seem to exist, skipping notif about update..."); Log::logger->log(Log::ERR, "CVersionKeeperManager: hyprland-update-screen doesn't seem to exist, skipping notif about update...");
return; return;
} }

View file

@ -1,5 +1,5 @@
#include "WelcomeManager.hpp" #include "WelcomeManager.hpp"
#include "../debug/Log.hpp" #include "../debug/log/Logger.hpp"
#include "../config/ConfigValue.hpp" #include "../config/ConfigValue.hpp"
#include "../helpers/fs/FsUtils.hpp" #include "../helpers/fs/FsUtils.hpp"
@ -11,12 +11,12 @@ CWelcomeManager::CWelcomeManager() {
static auto PAUTOGEN = CConfigValue<Hyprlang::INT>("autogenerated"); static auto PAUTOGEN = CConfigValue<Hyprlang::INT>("autogenerated");
if (!*PAUTOGEN) { if (!*PAUTOGEN) {
Debug::log(LOG, "[welcome] skipping, not autogen"); Log::logger->log(Log::DEBUG, "[welcome] skipping, not autogen");
return; return;
} }
if (!NFsUtils::executableExistsInPath("hyprland-welcome")) { if (!NFsUtils::executableExistsInPath("hyprland-welcome")) {
Debug::log(LOG, "[welcome] skipping, no welcome app"); Log::logger->log(Log::DEBUG, "[welcome] skipping, no welcome app");
return; return;
} }

View file

@ -13,10 +13,11 @@ extern "C" {
#include "config/ConfigValue.hpp" #include "config/ConfigValue.hpp"
#include "helpers/CursorShapes.hpp" #include "helpers/CursorShapes.hpp"
#include "../managers/CursorManager.hpp" #include "../managers/CursorManager.hpp"
#include "debug/Log.hpp" #include "debug/log/Logger.hpp"
#include "XCursorManager.hpp" #include "XCursorManager.hpp"
#include <memory> #include <memory>
#include <variant> #include <variant>
#include <fstream>
// clang-format off // clang-format off
static std::vector<uint32_t> HYPR_XCURSOR_PIXELS = { static std::vector<uint32_t> HYPR_XCURSOR_PIXELS = {
@ -121,7 +122,7 @@ void CXCursorManager::loadTheme(std::string const& name, int size, float scale)
auto paths = themePaths(m_themeName); auto paths = themePaths(m_themeName);
if (paths.empty()) { if (paths.empty()) {
Debug::log(ERR, "XCursor librarypath is empty loading standard XCursors"); Log::logger->log(Log::ERR, "XCursor librarypath is empty loading standard XCursors");
m_cursors = loadStandardCursors(m_themeName, m_lastLoadSize); m_cursors = loadStandardCursors(m_themeName, m_lastLoadSize);
} else { } else {
for (auto const& p : paths) { for (auto const& p : paths) {
@ -129,12 +130,12 @@ void CXCursorManager::loadTheme(std::string const& name, int size, float scale)
auto dirCursors = loadAllFromDir(p, m_lastLoadSize); auto dirCursors = loadAllFromDir(p, m_lastLoadSize);
std::ranges::copy_if(dirCursors, std::back_inserter(m_cursors), std::ranges::copy_if(dirCursors, std::back_inserter(m_cursors),
[this](auto const& p) { return std::ranges::none_of(m_cursors, [&p](auto const& dp) { return dp->shape == p->shape; }); }); [this](auto const& p) { return std::ranges::none_of(m_cursors, [&p](auto const& dp) { return dp->shape == p->shape; }); });
} catch (std::exception& e) { Debug::log(ERR, "XCursor path {} can't be loaded: threw error {}", p, e.what()); } } catch (std::exception& e) { Log::logger->log(Log::ERR, "XCursor path {} can't be loaded: threw error {}", p, e.what()); }
} }
} }
if (m_cursors.empty()) { if (m_cursors.empty()) {
Debug::log(ERR, "XCursor failed finding any shapes in theme \"{}\".", m_themeName); Log::logger->log(Log::ERR, "XCursor failed finding any shapes in theme \"{}\".", m_themeName);
m_defaultCursor = m_hyprCursor; m_defaultCursor = m_hyprCursor;
return; return;
} }
@ -147,12 +148,12 @@ void CXCursorManager::loadTheme(std::string const& name, int size, float scale)
auto it = std::ranges::find_if(m_cursors, [&legacyName](auto const& c) { return c->shape == legacyName; }); auto it = std::ranges::find_if(m_cursors, [&legacyName](auto const& c) { return c->shape == legacyName; });
if (it == m_cursors.end()) { if (it == m_cursors.end()) {
Debug::log(LOG, "XCursor failed to find a legacy shape with name {}, skipping", legacyName); Log::logger->log(Log::DEBUG, "XCursor failed to find a legacy shape with name {}, skipping", legacyName);
continue; continue;
} }
if (std::ranges::any_of(m_cursors, [&shape](auto const& dp) { return dp->shape == shape; })) { if (std::ranges::any_of(m_cursors, [&shape](auto const& dp) { return dp->shape == shape; })) {
Debug::log(LOG, "XCursor already has a shape {} loaded, skipping", shape); Log::logger->log(Log::DEBUG, "XCursor already has a shape {} loaded, skipping", shape);
continue; continue;
} }
@ -179,7 +180,7 @@ SP<SXCursors> CXCursorManager::getShape(std::string const& shape, int size, floa
return c; return c;
} }
Debug::log(WARN, "XCursor couldn't find shape {} , using default cursor instead", shape); Log::logger->log(Log::WARN, "XCursor couldn't find shape {} , using default cursor instead", shape);
return m_defaultCursor; return m_defaultCursor;
} }
@ -221,7 +222,7 @@ std::set<std::string> CXCursorManager::themePaths(std::string const& theme) {
std::string line; std::string line;
std::vector<std::string> themes; std::vector<std::string> themes;
Debug::log(LOG, "XCursor parsing index.theme {}", indexTheme); Log::logger->log(Log::DEBUG, "XCursor parsing index.theme {}", indexTheme);
while (std::getline(infile, line)) { while (std::getline(infile, line)) {
if (line.empty()) if (line.empty())
@ -290,12 +291,12 @@ std::set<std::string> CXCursorManager::themePaths(std::string const& theme) {
std::stringstream ss(path); std::stringstream ss(path);
std::string line; std::string line;
Debug::log(LOG, "XCursor scanning theme {}", t); Log::logger->log(Log::DEBUG, "XCursor scanning theme {}", t);
while (std::getline(ss, line, ':')) { while (std::getline(ss, line, ':')) {
auto p = expandTilde(line + "/" + t + "/cursors"); auto p = expandTilde(line + "/" + t + "/cursors");
if (std::filesystem::exists(p) && std::filesystem::is_directory(p)) { if (std::filesystem::exists(p) && std::filesystem::is_directory(p)) {
Debug::log(LOG, "XCursor using theme path {}", p); Log::logger->log(Log::DEBUG, "XCursor using theme path {}", p);
paths.insert(p); paths.insert(p);
} }
@ -303,7 +304,7 @@ std::set<std::string> CXCursorManager::themePaths(std::string const& theme) {
if (std::filesystem::exists(inherit) && std::filesystem::is_regular_file(inherit)) { if (std::filesystem::exists(inherit) && std::filesystem::is_regular_file(inherit)) {
auto inheritThemes = getInheritThemes(inherit); auto inheritThemes = getInheritThemes(inherit);
for (auto const& i : inheritThemes) { for (auto const& i : inheritThemes) {
Debug::log(LOG, "XCursor theme {} inherits {}", t, i); Log::logger->log(Log::DEBUG, "XCursor theme {} inherits {}", t, i);
inherits.insert(i); inherits.insert(i);
} }
} }
@ -496,11 +497,11 @@ std::vector<SP<SXCursors>> CXCursorManager::loadStandardCursors(std::string cons
auto xImages = XcursorShapeLoadImages(i << 1 /* wtf xcursor? */, name.c_str(), size); auto xImages = XcursorShapeLoadImages(i << 1 /* wtf xcursor? */, name.c_str(), size);
if (!xImages) { if (!xImages) {
Debug::log(WARN, "XCursor failed to find a shape with name {}, trying size 24.", shape); Log::logger->log(Log::WARN, "XCursor failed to find a shape with name {}, trying size 24.", shape);
xImages = XcursorShapeLoadImages(i << 1 /* wtf xcursor? */, name.c_str(), 24); xImages = XcursorShapeLoadImages(i << 1 /* wtf xcursor? */, name.c_str(), 24);
if (!xImages) { if (!xImages) {
Debug::log(WARN, "XCursor failed to find a shape with name {}, skipping", shape); Log::logger->log(Log::WARN, "XCursor failed to find a shape with name {}, skipping", shape);
continue; continue;
} }
} }
@ -528,7 +529,7 @@ std::vector<SP<SXCursors>> CXCursorManager::loadAllFromDir(std::string const& pa
for (const auto& entry : std::filesystem::directory_iterator(path)) { for (const auto& entry : std::filesystem::directory_iterator(path)) {
std::error_code e1, e2; std::error_code e1, e2;
if ((!entry.is_regular_file(e1) && !entry.is_symlink(e2)) || e1 || e2) { if ((!entry.is_regular_file(e1) && !entry.is_symlink(e2)) || e1 || e2) {
Debug::log(WARN, "XCursor failed to load shape {}: {}", entry.path().stem().string(), e1 ? e1.message() : e2.message()); Log::logger->log(Log::WARN, "XCursor failed to load shape {}: {}", entry.path().stem().string(), e1 ? e1.message() : e2.message());
continue; continue;
} }
@ -542,11 +543,11 @@ std::vector<SP<SXCursors>> CXCursorManager::loadAllFromDir(std::string const& pa
auto xImages = XcursorFileLoadImages(f.get(), size); auto xImages = XcursorFileLoadImages(f.get(), size);
if (!xImages) { if (!xImages) {
Debug::log(WARN, "XCursor failed to load image {}, trying size 24.", full); Log::logger->log(Log::WARN, "XCursor failed to load image {}, trying size 24.", full);
xImages = XcursorFileLoadImages(f.get(), 24); xImages = XcursorFileLoadImages(f.get(), 24);
if (!xImages) { if (!xImages) {
Debug::log(WARN, "XCursor failed to load image {}, skipping", full); Log::logger->log(Log::WARN, "XCursor failed to load image {}, skipping", full);
continue; continue;
} }
} }
@ -578,7 +579,7 @@ void CXCursorManager::syncGsettings() {
auto* gSettingsSchemaSource = g_settings_schema_source_get_default(); auto* gSettingsSchemaSource = g_settings_schema_source_get_default();
if (!gSettingsSchemaSource) { if (!gSettingsSchemaSource) {
Debug::log(WARN, "GSettings default schema source does not exist, can't sync GSettings"); Log::logger->log(Log::WARN, "GSettings default schema source does not exist, can't sync GSettings");
return false; return false;
} }
@ -596,14 +597,14 @@ void CXCursorManager::syncGsettings() {
using SettingValue = std::variant<std::string, int>; using SettingValue = std::variant<std::string, int>;
auto setValue = [&checkParamExists](std::string const& paramName, const SettingValue& paramValue, std::string const& category) { auto setValue = [&checkParamExists](std::string const& paramName, const SettingValue& paramValue, std::string const& category) {
if (!checkParamExists(paramName, category)) { if (!checkParamExists(paramName, category)) {
Debug::log(WARN, "GSettings parameter doesn't exist {} in {}", paramName, category); Log::logger->log(Log::WARN, "GSettings parameter doesn't exist {} in {}", paramName, category);
return; return;
} }
auto* gsettings = g_settings_new(category.c_str()); auto* gsettings = g_settings_new(category.c_str());
if (!gsettings) { if (!gsettings) {
Debug::log(WARN, "GSettings failed to allocate new settings with category {}", category); Log::logger->log(Log::WARN, "GSettings failed to allocate new settings with category {}", category);
return; return;
} }

View file

@ -30,13 +30,13 @@ void CHyprXWaylandManager::activateSurface(SP<CWLSurfaceResource> pSurface, bool
auto HLSurface = Desktop::View::CWLSurface::fromResource(pSurface); auto HLSurface = Desktop::View::CWLSurface::fromResource(pSurface);
if (!HLSurface) { if (!HLSurface) {
Debug::log(TRACE, "CHyprXWaylandManager::activateSurface on non-desktop surface, ignoring"); Log::logger->log(Log::TRACE, "CHyprXWaylandManager::activateSurface on non-desktop surface, ignoring");
return; return;
} }
const auto PWINDOW = Desktop::View::CWindow::fromView(HLSurface->view()); const auto PWINDOW = Desktop::View::CWindow::fromView(HLSurface->view());
if (!PWINDOW) { if (!PWINDOW) {
Debug::log(TRACE, "CHyprXWaylandManager::activateSurface on non-window surface, ignoring"); Log::logger->log(Log::TRACE, "CHyprXWaylandManager::activateSurface on non-window surface, ignoring");
return; return;
} }

View file

@ -279,7 +279,7 @@ void CDesktopAnimationManager::startAnimation(PHLWORKSPACE ws, eAnimationType ty
if (percstr.ends_with('%')) { if (percstr.ends_with('%')) {
try { try {
movePerc = std::stoi(percstr.substr(0, percstr.length() - 1)); movePerc = std::stoi(percstr.substr(0, percstr.length() - 1));
} catch (std::exception& e) { Debug::log(ERR, "Error in startAnim: invalid percentage"); } } catch (std::exception& e) { Log::logger->log(Log::ERR, "Error in startAnim: invalid percentage"); }
} }
if (ANIMSTYLE.starts_with("slidefade")) { if (ANIMSTYLE.starts_with("slidefade")) {

View file

@ -1,5 +1,5 @@
#include "EventLoopManager.hpp" #include "EventLoopManager.hpp"
#include "../../debug/Log.hpp" #include "../../debug/log/Logger.hpp"
#include "../../Compositor.hpp" #include "../../Compositor.hpp"
#include "../../config/ConfigWatcher.hpp" #include "../../config/ConfigWatcher.hpp"
@ -57,7 +57,7 @@ static int configWatcherWrite(int fd, uint32_t mask, void* data) {
static int handleWaiterFD(int fd, uint32_t mask, void* data) { static int handleWaiterFD(int fd, uint32_t mask, void* data) {
if (mask & (WL_EVENT_HANGUP | WL_EVENT_ERROR)) { if (mask & (WL_EVENT_HANGUP | WL_EVENT_ERROR)) {
Debug::log(ERR, "handleWaiterFD: readable waiter error"); Log::logger->log(Log::ERR, "handleWaiterFD: readable waiter error");
return 0; return 0;
} }
@ -96,7 +96,7 @@ void CEventLoopManager::enterLoop() {
wl_display_run(m_wayland.display); wl_display_run(m_wayland.display);
Debug::log(LOG, "Kicked off the event loop! :("); Log::logger->log(Log::DEBUG, "Kicked off the event loop! :(");
} }
void CEventLoopManager::onTimerFire() { void CEventLoopManager::onTimerFire() {

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}", rc<uintptr_t>(PINHIBIT->inhibitor->m_surface.get())); Log::logger->log(Log::DEBUG, "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; });
@ -18,7 +18,7 @@ void CInputManager::newIdleInhibitor(std::any inhibitor) {
auto WLSurface = Desktop::View::CWLSurface::fromResource(PINHIBIT->inhibitor->m_surface.lock()); auto WLSurface = Desktop::View::CWLSurface::fromResource(PINHIBIT->inhibitor->m_surface.lock());
if (!WLSurface) { if (!WLSurface) {
Debug::log(LOG, "Inhibitor has no HL Surface attached to it, likely meaning it's a non-desktop element. Assuming it's visible."); Log::logger->log(Log::DEBUG, "Inhibitor has no HL Surface attached to it, likely meaning it's a non-desktop element. Assuming it's visible.");
PINHIBIT->nonDesktop = true; PINHIBIT->nonDesktop = true;
recheckIdleInhibitorStatus(); recheckIdleInhibitorStatus();
return; return;

View file

@ -56,7 +56,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 {} -> {}", sc<uint32_t>(event.shape), event.shapeName); Log::logger->log(Log::DEBUG, "cursorImage request: shape {} -> {}", sc<uint32_t>(event.shape), event.shapeName);
m_cursorSurfaceInfo.wlSurface->unassign(); m_cursorSurfaceInfo.wlSurface->unassign();
m_cursorSurfaceInfo.vHotspot = {}; m_cursorSurfaceInfo.vHotspot = {};
@ -275,7 +275,8 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, st
return; return;
} else } else
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())); Log::logger->log(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 != Desktop::focusState()->monitor() && (*PMOUSEFOCUSMON || refocus) && m_forcedFocus.expired()) if (PMONITOR != Desktop::focusState()->monitor() && (*PMOUSEFOCUSMON || refocus) && m_forcedFocus.expired())
@ -676,7 +677,7 @@ void CInputManager::onMouseButton(IPointer::SButtonEvent e) {
} }
void CInputManager::processMouseRequest(const CSeatManager::SSetCursorEvent& event) { void CInputManager::processMouseRequest(const CSeatManager::SSetCursorEvent& event) {
Debug::log(LOG, "cursorImage request: surface {:x}", rc<uintptr_t>(event.surf.get())); Log::logger->log(Log::DEBUG, "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();
@ -725,13 +726,13 @@ eClickBehaviorMode CInputManager::getClickMode() {
void CInputManager::setClickMode(eClickBehaviorMode mode) { void CInputManager::setClickMode(eClickBehaviorMode mode) {
switch (mode) { switch (mode) {
case CLICKMODE_DEFAULT: case CLICKMODE_DEFAULT:
Debug::log(LOG, "SetClickMode: DEFAULT"); Log::logger->log(Log::DEBUG, "SetClickMode: DEFAULT");
m_clickBehavior = CLICKMODE_DEFAULT; m_clickBehavior = CLICKMODE_DEFAULT;
g_pHyprRenderer->setCursorFromName("left_ptr", true); g_pHyprRenderer->setCursorFromName("left_ptr", true);
break; break;
case CLICKMODE_KILL: case CLICKMODE_KILL:
Debug::log(LOG, "SetClickMode: KILL"); Log::logger->log(Log::DEBUG, "SetClickMode: KILL");
m_clickBehavior = CLICKMODE_KILL; m_clickBehavior = CLICKMODE_KILL;
// remove constraints // remove constraints
@ -831,7 +832,7 @@ void CInputManager::processMouseDownKill(const IPointer::SButtonEvent& e) {
g_pCompositor->vectorToWindowUnified(getMouseCoordsInternal(), Desktop::View::RESERVED_EXTENTS | Desktop::View::INPUT_EXTENTS | Desktop::View::ALLOW_FLOATING); g_pCompositor->vectorToWindowUnified(getMouseCoordsInternal(), Desktop::View::RESERVED_EXTENTS | Desktop::View::INPUT_EXTENTS | Desktop::View::ALLOW_FLOATING);
if (!PWINDOW) { if (!PWINDOW) {
Debug::log(ERR, "Cannot kill invalid window!"); Log::logger->log(Log::ERR, "Cannot kill invalid window!");
break; break;
} }
@ -960,7 +961,7 @@ void CInputManager::newKeyboard(SP<IKeyboard> keeb) {
setupKeyboard(PNEWKEYBOARD); setupKeyboard(PNEWKEYBOARD);
Debug::log(LOG, "New keyboard created, pointers Hypr: {:x}", rc<uintptr_t>(PNEWKEYBOARD.get())); Log::logger->log(Log::DEBUG, "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) {
@ -968,7 +969,7 @@ void CInputManager::newKeyboard(SP<Aquamarine::IKeyboard> keyboard) {
setupKeyboard(PNEWKEYBOARD); setupKeyboard(PNEWKEYBOARD);
Debug::log(LOG, "New keyboard created, pointers Hypr: {:x} and AQ: {:x}", rc<uintptr_t>(PNEWKEYBOARD.get()), rc<uintptr_t>(keyboard.get())); Log::logger->log(Log::DEBUG, "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) {
@ -976,7 +977,7 @@ void CInputManager::newVirtualKeyboard(SP<CVirtualKeyboardV1Resource> keyboard)
setupKeyboard(PNEWKEYBOARD); setupKeyboard(PNEWKEYBOARD);
Debug::log(LOG, "New virtual keyboard created at {:x}", rc<uintptr_t>(PNEWKEYBOARD.get())); Log::logger->log(Log::DEBUG, "New virtual keyboard created at {:x}", rc<uintptr_t>(PNEWKEYBOARD.get()));
} }
void CInputManager::setupKeyboard(SP<IKeyboard> keeb) { void CInputManager::setupKeyboard(SP<IKeyboard> keeb) {
@ -987,7 +988,7 @@ void CInputManager::setupKeyboard(SP<IKeyboard> keeb) {
try { try {
keeb->m_hlName = getNameForNewDevice(keeb->m_deviceName); keeb->m_hlName = getNameForNewDevice(keeb->m_deviceName);
} catch (std::exception& e) { } catch (std::exception& e) {
Debug::log(ERR, "Keyboard had no name???"); // logic error Log::logger->log(Log::ERR, "Keyboard had no name???"); // logic error
} }
keeb->m_events.destroy.listenStatic([this, keeb = keeb.get()] { keeb->m_events.destroy.listenStatic([this, keeb = keeb.get()] {
@ -997,7 +998,7 @@ void CInputManager::setupKeyboard(SP<IKeyboard> keeb) {
return; return;
destroyKeyboard(PKEEB); destroyKeyboard(PKEEB);
Debug::log(LOG, "Destroyed keyboard {:x}", rc<uintptr_t>(keeb)); Log::logger->log(Log::DEBUG, "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) {
@ -1062,7 +1063,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, sc<int>(HASCONFIG)); Log::logger->log(Log::DEBUG, "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");
@ -1088,11 +1089,11 @@ void CInputManager::applyConfigToKeyboard(SP<IKeyboard> pKeyboard) {
if (PERM == PERMISSION_RULE_ALLOW_MODE_PENDING) { if (PERM == PERMISSION_RULE_ALLOW_MODE_PENDING) {
const auto PROMISE = g_pDynamicPermissionManager->promiseFor(-1, pKeyboard->m_hlName, PERMISSION_TYPE_KEYBOARD); const auto PROMISE = g_pDynamicPermissionManager->promiseFor(-1, pKeyboard->m_hlName, PERMISSION_TYPE_KEYBOARD);
if (!PROMISE) if (!PROMISE)
Debug::log(ERR, "BUG THIS: No promise for client permission for keyboard"); Log::logger->log(Log::ERR, "BUG THIS: No promise for client permission for keyboard");
else { else {
PROMISE->then([k = WP<IKeyboard>{pKeyboard}](SP<CPromiseResult<eDynamicPermissionAllowMode>> r) { PROMISE->then([k = WP<IKeyboard>{pKeyboard}](SP<CPromiseResult<eDynamicPermissionAllowMode>> r) {
if (r->hasError()) { if (r->hasError()) {
Debug::log(ERR, "BUG THIS: No permission returned for keyboard"); Log::logger->log(Log::ERR, "BUG THIS: No permission returned for keyboard");
return; return;
} }
@ -1109,7 +1110,7 @@ void CInputManager::applyConfigToKeyboard(SP<IKeyboard> pKeyboard) {
if (NUMLOCKON == pKeyboard->m_numlockOn && REPEATDELAY == pKeyboard->m_repeatDelay && REPEATRATE == pKeyboard->m_repeatRate && RULES == pKeyboard->m_currentRules.rules && if (NUMLOCKON == pKeyboard->m_numlockOn && REPEATDELAY == pKeyboard->m_repeatDelay && REPEATRATE == pKeyboard->m_repeatRate && RULES == pKeyboard->m_currentRules.rules &&
MODEL == pKeyboard->m_currentRules.model && LAYOUT == pKeyboard->m_currentRules.layout && VARIANT == pKeyboard->m_currentRules.variant && MODEL == pKeyboard->m_currentRules.model && LAYOUT == pKeyboard->m_currentRules.layout && VARIANT == pKeyboard->m_currentRules.variant &&
OPTIONS == pKeyboard->m_currentRules.options && FILEPATH == pKeyboard->m_xkbFilePath) { OPTIONS == pKeyboard->m_currentRules.options && FILEPATH == pKeyboard->m_xkbFilePath) {
Debug::log(LOG, "Not applying config to keyboard, it did not change."); Log::logger->log(Log::DEBUG, "Not applying config to keyboard, it did not change.");
return; return;
} }
} catch (std::exception& e) { } catch (std::exception& e) {
@ -1128,7 +1129,7 @@ void CInputManager::applyConfigToKeyboard(SP<IKeyboard> pKeyboard) {
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->m_hlName + "," + LAYOUTSTR}); g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->m_hlName + "," + LAYOUTSTR});
EMIT_HOOK_EVENT("activeLayout", (std::vector<std::any>{pKeyboard, LAYOUTSTR})); EMIT_HOOK_EVENT("activeLayout", (std::vector<std::any>{pKeyboard, LAYOUTSTR}));
Debug::log(LOG, "Set the keyboard layout to {} and variant to {} for keyboard \"{}\"", pKeyboard->m_currentRules.layout, pKeyboard->m_currentRules.variant, Log::logger->log(Log::DEBUG, "Set the keyboard layout to {} and variant to {} for keyboard \"{}\"", pKeyboard->m_currentRules.layout, pKeyboard->m_currentRules.variant,
pKeyboard->m_hlName); pKeyboard->m_hlName);
} }
@ -1137,7 +1138,7 @@ void CInputManager::newVirtualMouse(SP<CVirtualPointerV1Resource> mouse) {
setupMouse(PMOUSE); setupMouse(PMOUSE);
Debug::log(LOG, "New virtual mouse created"); Log::logger->log(Log::DEBUG, "New virtual mouse created");
} }
void CInputManager::newMouse(SP<IPointer> mouse) { void CInputManager::newMouse(SP<IPointer> mouse) {
@ -1145,7 +1146,7 @@ void CInputManager::newMouse(SP<IPointer> mouse) {
setupMouse(mouse); setupMouse(mouse);
Debug::log(LOG, "New mouse created, pointer Hypr: {:x}", rc<uintptr_t>(mouse.get())); Log::logger->log(Log::DEBUG, "New mouse created, pointer Hypr: {:x}", rc<uintptr_t>(mouse.get()));
} }
void CInputManager::newMouse(SP<Aquamarine::IPointer> mouse) { void CInputManager::newMouse(SP<Aquamarine::IPointer> mouse) {
@ -1153,7 +1154,7 @@ void CInputManager::newMouse(SP<Aquamarine::IPointer> mouse) {
setupMouse(PMOUSE); setupMouse(PMOUSE);
Debug::log(LOG, "New mouse created, pointer AQ: {:x}", rc<uintptr_t>(mouse.get())); Log::logger->log(Log::DEBUG, "New mouse created, pointer AQ: {:x}", rc<uintptr_t>(mouse.get()));
} }
void CInputManager::setupMouse(SP<IPointer> mauz) { void CInputManager::setupMouse(SP<IPointer> mauz) {
@ -1162,13 +1163,13 @@ void CInputManager::setupMouse(SP<IPointer> mauz) {
try { try {
mauz->m_hlName = getNameForNewDevice(mauz->m_deviceName); mauz->m_hlName = getNameForNewDevice(mauz->m_deviceName);
} catch (std::exception& e) { } catch (std::exception& e) {
Debug::log(ERR, "Mouse had no name???"); // logic error Log::logger->log(Log::ERR, "Mouse had no name???"); // logic error
} }
if (mauz->aq() && mauz->aq()->getLibinputHandle()) { if (mauz->aq() && mauz->aq()->getLibinputHandle()) {
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), Log::logger->log(Log::DEBUG, "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), sc<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)),
sc<int>(libinput_device_config_accel_get_default_profile(LIBINPUTDEV))); sc<int>(libinput_device_config_accel_get_default_profile(LIBINPUTDEV)));
} }
@ -1237,7 +1238,7 @@ void CInputManager::setPointerConfigs() {
else if (TAP_MAP == "lmr") else if (TAP_MAP == "lmr")
libinput_device_config_tap_set_button_map(LIBINPUTDEV, LIBINPUT_CONFIG_TAP_MAP_LMR); libinput_device_config_tap_set_button_map(LIBINPUTDEV, LIBINPUT_CONFIG_TAP_MAP_LMR);
else else
Debug::log(WARN, "Tap button mapping unknown"); Log::logger->log(Log::WARN, "Tap button mapping unknown");
} }
const auto SCROLLMETHOD = g_pConfigManager->getDeviceString(devname, "scroll_method", "input:scroll_method"); const auto SCROLLMETHOD = g_pConfigManager->getDeviceString(devname, "scroll_method", "input:scroll_method");
@ -1252,7 +1253,7 @@ void CInputManager::setPointerConfigs() {
} else if (SCROLLMETHOD == "on_button_down") { } else if (SCROLLMETHOD == "on_button_down") {
libinput_device_config_scroll_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN); libinput_device_config_scroll_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN);
} else { } else {
Debug::log(WARN, "Scroll method unknown"); Log::logger->log(Log::WARN, "Scroll method unknown");
} }
if (g_pConfigManager->getDeviceInt(devname, "tap-and-drag", "input:touchpad:tap-and-drag") == 0) if (g_pConfigManager->getDeviceInt(devname, "tap-and-drag", "input:touchpad:tap-and-drag") == 0)
@ -1331,15 +1332,15 @@ void CInputManager::setPointerConfigs() {
} }
libinput_config_accel_set_points(CONFIG, LIBINPUT_ACCEL_TYPE_SCROLL, scrollStep, scrollPoints.size(), scrollPoints.data()); libinput_config_accel_set_points(CONFIG, LIBINPUT_ACCEL_TYPE_SCROLL, scrollStep, scrollPoints.size(), scrollPoints.data());
} catch (std::exception& e) { Debug::log(ERR, "Invalid values in scroll_points"); } } catch (std::exception& e) { Log::logger->log(Log::ERR, "Invalid values in scroll_points"); }
} }
libinput_config_accel_set_points(CONFIG, LIBINPUT_ACCEL_TYPE_MOTION, accelStep, accelPoints.size(), accelPoints.data()); libinput_config_accel_set_points(CONFIG, LIBINPUT_ACCEL_TYPE_MOTION, accelStep, accelPoints.size(), accelPoints.data());
libinput_device_config_accel_apply(LIBINPUTDEV, CONFIG); libinput_device_config_accel_apply(LIBINPUTDEV, CONFIG);
libinput_config_accel_destroy(CONFIG); libinput_config_accel_destroy(CONFIG);
} catch (std::exception& e) { Debug::log(ERR, "Invalid values in custom accel profile"); } } catch (std::exception& e) { Log::logger->log(Log::ERR, "Invalid values in custom accel profile"); }
} else { } else {
Debug::log(WARN, "Unknown acceleration profile, falling back to default"); Log::logger->log(Log::WARN, "Unknown acceleration profile, falling back to default");
} }
const auto SCROLLBUTTON = g_pConfigManager->getDeviceInt(devname, "scroll_button", "input:scroll_button"); const auto SCROLLBUTTON = g_pConfigManager->getDeviceInt(devname, "scroll_button", "input:scroll_button");
@ -1351,7 +1352,7 @@ void CInputManager::setPointerConfigs() {
libinput_device_config_scroll_set_button_lock(LIBINPUTDEV, libinput_device_config_scroll_set_button_lock(LIBINPUTDEV,
SCROLLBUTTONLOCK == 0 ? LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_DISABLED : LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_ENABLED); SCROLLBUTTONLOCK == 0 ? LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_DISABLED : LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_ENABLED);
Debug::log(LOG, "Applied config to mouse {}, sens {:.2f}", m->m_hlName, LIBINPUTSENS); Log::logger->log(Log::DEBUG, "Applied config to mouse {}, sens {:.2f}", m->m_hlName, LIBINPUTSENS);
} }
} }
} }
@ -1362,7 +1363,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", rc<uintptr_t>(pKeyboard.get())); Log::logger->log(Log::DEBUG, "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; });
@ -1386,7 +1387,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", rc<uintptr_t>(mouse.get())); Log::logger->log(Log::DEBUG, "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; });
@ -1399,7 +1400,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", rc<uintptr_t>(touch.get())); Log::logger->log(Log::DEBUG, "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; });
@ -1407,7 +1408,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", rc<uintptr_t>(tablet.get())); Log::logger->log(Log::DEBUG, "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; });
@ -1415,7 +1416,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", rc<uintptr_t>(tool.get())); Log::logger->log(Log::DEBUG, "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; });
@ -1423,7 +1424,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", rc<uintptr_t>(pad.get())); Log::logger->log(Log::DEBUG, "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; });
@ -1541,7 +1542,7 @@ void CInputManager::onKeyboardMod(SP<IKeyboard> pKeyboard) {
const auto LAYOUT = pKeyboard->getActiveLayout(); const auto LAYOUT = pKeyboard->getActiveLayout();
Debug::log(LOG, "LAYOUT CHANGED TO {} GROUP {}", LAYOUT, MODS.group); Log::logger->log(Log::DEBUG, "LAYOUT CHANGED TO {} GROUP {}", LAYOUT, MODS.group);
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->m_hlName + "," + LAYOUT}); g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->m_hlName + "," + LAYOUT});
EMIT_HOOK_EVENT("activeLayout", (std::vector<std::any>{pKeyboard, LAYOUT})); EMIT_HOOK_EVENT("activeLayout", (std::vector<std::any>{pKeyboard, LAYOUT}));
@ -1571,7 +1572,7 @@ void CInputManager::refocus(std::optional<Vector2D> overridePos) {
bool CInputManager::refocusLastWindow(PHLMONITOR pMonitor) { bool CInputManager::refocusLastWindow(PHLMONITOR pMonitor) {
if (!m_exclusiveLSes.empty()) { if (!m_exclusiveLSes.empty()) {
Debug::log(LOG, "CInputManager::refocusLastWindow: ignoring, exclusive LS present."); Log::logger->log(Log::DEBUG, "CInputManager::refocusLastWindow: ignoring, exclusive LS present.");
return false; return false;
} }
@ -1735,7 +1736,7 @@ void CInputManager::newTouchDevice(SP<Aquamarine::ITouch> pDevice) {
try { try {
PNEWDEV->m_hlName = getNameForNewDevice(PNEWDEV->m_deviceName); PNEWDEV->m_hlName = getNameForNewDevice(PNEWDEV->m_deviceName);
} catch (std::exception& e) { } catch (std::exception& e) {
Debug::log(ERR, "Touch Device had no name???"); // logic error Log::logger->log(Log::ERR, "Touch Device had no name???"); // logic error
} }
setTouchDeviceConfigs(PNEWDEV); setTouchDeviceConfigs(PNEWDEV);
@ -1750,7 +1751,7 @@ void CInputManager::newTouchDevice(SP<Aquamarine::ITouch> pDevice) {
destroyTouchDevice(PDEV); destroyTouchDevice(PDEV);
}); });
Debug::log(LOG, "New touch device added at {:x}", rc<uintptr_t>(PNEWDEV.get())); Log::logger->log(Log::DEBUG, "New touch device added at {:x}", rc<uintptr_t>(PNEWDEV.get()));
} }
void CInputManager::setTouchDeviceConfigs(SP<ITouch> dev) { void CInputManager::setTouchDeviceConfigs(SP<ITouch> dev) {
@ -1764,7 +1765,7 @@ void CInputManager::setTouchDeviceConfigs(SP<ITouch> dev) {
libinput_device_config_send_events_set_mode(LIBINPUTDEV, mode); libinput_device_config_send_events_set_mode(LIBINPUTDEV, mode);
if (libinput_device_config_calibration_has_matrix(LIBINPUTDEV)) { if (libinput_device_config_calibration_has_matrix(LIBINPUTDEV)) {
Debug::log(LOG, "Setting calibration matrix for device {}", PTOUCHDEV->m_hlName); Log::logger->log(Log::DEBUG, "Setting calibration matrix for device {}", PTOUCHDEV->m_hlName);
// default value of transform being -1 means it's unset. // default value of transform being -1 means it's unset.
const int ROTATION = std::clamp(g_pConfigManager->getDeviceInt(PTOUCHDEV->m_hlName, "transform", "input:touchdevice:transform"), -1, 7); const int ROTATION = std::clamp(g_pConfigManager->getDeviceInt(PTOUCHDEV->m_hlName, "transform", "input:touchdevice:transform"), -1, 7);
if (ROTATION > -1) if (ROTATION > -1)
@ -1785,10 +1786,10 @@ void CInputManager::setTouchDeviceConfigs(SP<ITouch> dev) {
PTOUCHDEV->m_boundOutput = bound ? output : ""; PTOUCHDEV->m_boundOutput = bound ? output : "";
const auto PMONITOR = bound ? g_pCompositor->getMonitorFromName(output) : nullptr; const auto PMONITOR = bound ? g_pCompositor->getMonitorFromName(output) : nullptr;
if (PMONITOR) { if (PMONITOR) {
Debug::log(LOG, "Binding touch device {} to output {}", PTOUCHDEV->m_hlName, PMONITOR->m_name); Log::logger->log(Log::DEBUG, "Binding touch device {} to output {}", PTOUCHDEV->m_hlName, PMONITOR->m_name);
// wlr_cursor_map_input_to_output(g_pCompositor->m_sWLRCursor, &PTOUCHDEV->wlr()->base, PMONITOR->output); // wlr_cursor_map_input_to_output(g_pCompositor->m_sWLRCursor, &PTOUCHDEV->wlr()->base, PMONITOR->output);
} else if (bound) } else if (bound)
Debug::log(ERR, "Failed to bind touch device {} to output '{}': monitor not found", PTOUCHDEV->m_hlName, output); Log::logger->log(Log::ERR, "Failed to bind touch device {} to output '{}': monitor not found", PTOUCHDEV->m_hlName, output);
} }
}; };
@ -1812,7 +1813,7 @@ void CInputManager::setTabletConfigs() {
t->m_relativeInput = RELINPUT; t->m_relativeInput = RELINPUT;
const int ROTATION = std::clamp(g_pConfigManager->getDeviceInt(NAME, "transform", "input:tablet:transform"), -1, 7); const int ROTATION = std::clamp(g_pConfigManager->getDeviceInt(NAME, "transform", "input:tablet:transform"), -1, 7);
Debug::log(LOG, "Setting calibration matrix for device {}", NAME); Log::logger->log(Log::DEBUG, "Setting calibration matrix for device {}", NAME);
if (ROTATION > -1) if (ROTATION > -1)
libinput_device_config_calibration_set_matrix(LIBINPUTDEV, MATRICES[ROTATION]); libinput_device_config_calibration_set_matrix(LIBINPUTDEV, MATRICES[ROTATION]);
@ -1823,7 +1824,7 @@ void CInputManager::setTabletConfigs() {
const auto OUTPUT = g_pConfigManager->getDeviceString(NAME, "output", "input:tablet:output"); const auto OUTPUT = g_pConfigManager->getDeviceString(NAME, "output", "input:tablet:output");
if (OUTPUT != STRVAL_EMPTY) { if (OUTPUT != STRVAL_EMPTY) {
Debug::log(LOG, "Binding tablet {} to output {}", NAME, OUTPUT); Log::logger->log(Log::DEBUG, "Binding tablet {} to output {}", NAME, OUTPUT);
t->m_boundOutput = OUTPUT; t->m_boundOutput = OUTPUT;
} else } else
t->m_boundOutput = ""; t->m_boundOutput = "";
@ -1854,22 +1855,22 @@ void CInputManager::newSwitch(SP<Aquamarine::ISwitch> pDevice) {
const auto PNEWDEV = &m_switches.emplace_back(); const auto PNEWDEV = &m_switches.emplace_back();
PNEWDEV->pDevice = pDevice; PNEWDEV->pDevice = pDevice;
Debug::log(LOG, "New switch with name \"{}\" added", pDevice->getName()); Log::logger->log(Log::DEBUG, "New switch with name \"{}\" added", pDevice->getName());
PNEWDEV->listeners.destroy = pDevice->events.destroy.listen([this, PNEWDEV] { destroySwitch(PNEWDEV); }); PNEWDEV->listeners.destroy = pDevice->events.destroy.listen([this, PNEWDEV] { destroySwitch(PNEWDEV); });
PNEWDEV->listeners.fire = pDevice->events.fire.listen([PNEWDEV](const Aquamarine::ISwitch::SFireEvent& event) { PNEWDEV->listeners.fire = pDevice->events.fire.listen([PNEWDEV](const Aquamarine::ISwitch::SFireEvent& event) {
const auto NAME = PNEWDEV->pDevice->getName(); const auto NAME = PNEWDEV->pDevice->getName();
Debug::log(LOG, "Switch {} fired, triggering binds.", NAME); Log::logger->log(Log::DEBUG, "Switch {} fired, triggering binds.", NAME);
g_pKeybindManager->onSwitchEvent(NAME); g_pKeybindManager->onSwitchEvent(NAME);
if (event.enable) { if (event.enable) {
Debug::log(LOG, "Switch {} turn on, triggering binds.", NAME); Log::logger->log(Log::DEBUG, "Switch {} turn on, triggering binds.", NAME);
g_pKeybindManager->onSwitchOnEvent(NAME); g_pKeybindManager->onSwitchOnEvent(NAME);
} else { } else {
Debug::log(LOG, "Switch {} turn off, triggering binds.", NAME); Log::logger->log(Log::DEBUG, "Switch {} turn off, triggering binds.", NAME);
g_pKeybindManager->onSwitchOffEvent(NAME); g_pKeybindManager->onSwitchOffEvent(NAME);
} }
}); });

View file

@ -30,7 +30,7 @@ void CInputPopup::onDestroy() {
} }
void CInputPopup::onMap() { void CInputPopup::onMap() {
Debug::log(LOG, "Mapped an IME Popup"); Log::logger->log(Log::DEBUG, "Mapped an IME Popup");
updateBox(); updateBox();
damageEntire(); damageEntire();
@ -44,7 +44,7 @@ void CInputPopup::onMap() {
} }
void CInputPopup::onUnmap() { void CInputPopup::onUnmap() {
Debug::log(LOG, "Unmapped an IME Popup"); Log::logger->log(Log::DEBUG, "Unmapped an IME Popup");
damageEntire(); damageEntire();
} }
@ -57,7 +57,7 @@ void CInputPopup::damageEntire() {
const auto OWNER = queryOwner(); const auto OWNER = queryOwner();
if (!OWNER) { if (!OWNER) {
Debug::log(ERR, "BUG THIS: No owner in imepopup::damageentire"); Log::logger->log(Log::ERR, "BUG THIS: No owner in imepopup::damageentire");
return; return;
} }
CBox box = globalBox(); CBox box = globalBox();
@ -68,7 +68,7 @@ void CInputPopup::damageSurface() {
const auto OWNER = queryOwner(); const auto OWNER = queryOwner();
if (!OWNER) { if (!OWNER) {
Debug::log(ERR, "BUG THIS: No owner in imepopup::damagesurface"); Log::logger->log(Log::ERR, "BUG THIS: No owner in imepopup::damagesurface");
return; return;
} }
@ -150,7 +150,7 @@ CBox CInputPopup::globalBox() {
const auto OWNER = queryOwner(); const auto OWNER = queryOwner();
if (!OWNER) { if (!OWNER) {
Debug::log(ERR, "BUG THIS: No owner in imepopup::globalbox"); Log::logger->log(Log::ERR, "BUG THIS: No owner in imepopup::globalbox");
return {}; return {};
} }
CBox parentBox = OWNER->getSurfaceBoxGlobal().value_or(CBox{0, 0, 500, 500}); CBox parentBox = OWNER->getSurfaceBoxGlobal().value_or(CBox{0, 0, 500, 500});

View file

@ -17,7 +17,7 @@ CInputMethodRelay::CInputMethodRelay() {
void CInputMethodRelay::onNewIME(SP<CInputMethodV2> pIME) { void CInputMethodRelay::onNewIME(SP<CInputMethodV2> pIME) {
if (!m_inputMethod.expired()) { if (!m_inputMethod.expired()) {
Debug::log(ERR, "Cannot register 2 IMEs at once!"); Log::logger->log(Log::ERR, "Cannot register 2 IMEs at once!");
pIME->unavailable(); pIME->unavailable();
@ -30,7 +30,7 @@ void CInputMethodRelay::onNewIME(SP<CInputMethodV2> pIME) {
const auto PTI = getFocusedTextInput(); const auto PTI = getFocusedTextInput();
if (!PTI) { if (!PTI) {
Debug::log(LOG, "No focused TextInput on IME Commit"); Log::logger->log(Log::DEBUG, "No focused TextInput on IME Commit");
return; return;
} }
@ -40,7 +40,7 @@ void CInputMethodRelay::onNewIME(SP<CInputMethodV2> pIME) {
m_listeners.destroyIME = pIME->m_events.destroy.listen([this] { m_listeners.destroyIME = pIME->m_events.destroy.listen([this] {
const auto PTI = getFocusedTextInput(); const auto PTI = getFocusedTextInput();
Debug::log(LOG, "IME Destroy"); Log::logger->log(Log::DEBUG, "IME Destroy");
if (PTI) if (PTI)
PTI->leave(); PTI->leave();
@ -50,7 +50,7 @@ void CInputMethodRelay::onNewIME(SP<CInputMethodV2> pIME) {
m_listeners.newPopup = pIME->m_events.newPopup.listen([this](const SP<CInputMethodPopupV2>& popup) { m_listeners.newPopup = pIME->m_events.newPopup.listen([this](const SP<CInputMethodPopupV2>& popup) {
m_inputMethodPopups.emplace_back(makeUnique<CInputPopup>(popup)); m_inputMethodPopups.emplace_back(makeUnique<CInputPopup>(popup));
Debug::log(LOG, "New input popup"); Log::logger->log(Log::DEBUG, "New input popup");
}); });
if (!Desktop::focusState()->surface()) if (!Desktop::focusState()->surface())

View file

@ -231,7 +231,7 @@ void CInputManager::newTablet(SP<Aquamarine::ITablet> pDevice) {
try { try {
PNEWTABLET->m_hlName = g_pInputManager->getNameForNewDevice(pDevice->getName()); PNEWTABLET->m_hlName = g_pInputManager->getNameForNewDevice(pDevice->getName());
} catch (std::exception& e) { } catch (std::exception& e) {
Debug::log(ERR, "Tablet had no name???"); // logic error Log::logger->log(Log::ERR, "Tablet had no name???"); // logic error
} }
g_pPointerManager->attachTablet(PNEWTABLET); g_pPointerManager->attachTablet(PNEWTABLET);
@ -257,7 +257,7 @@ SP<CTabletTool> CInputManager::ensureTabletToolPresent(SP<Aquamarine::ITabletToo
try { try {
PTOOL->m_hlName = g_pInputManager->getNameForNewDevice(pTool->getName()); PTOOL->m_hlName = g_pInputManager->getNameForNewDevice(pTool->getName());
} catch (std::exception& e) { } catch (std::exception& e) {
Debug::log(ERR, "Tablet had no name???"); // logic error Log::logger->log(Log::ERR, "Tablet had no name???"); // logic error
} }
PTOOL->m_events.destroy.listenStatic([this, tool = PTOOL.get()] { PTOOL->m_events.destroy.listenStatic([this, tool = PTOOL.get()] {
@ -275,7 +275,7 @@ void CInputManager::newTabletPad(SP<Aquamarine::ITabletPad> pDevice) {
try { try {
PNEWPAD->m_hlName = g_pInputManager->getNameForNewDevice(pDevice->getName()); PNEWPAD->m_hlName = g_pInputManager->getNameForNewDevice(pDevice->getName());
} catch (std::exception& e) { } catch (std::exception& e) {
Debug::log(ERR, "Pad had no name???"); // logic error Log::logger->log(Log::ERR, "Pad had no name???"); // logic error
} }
PNEWPAD->m_events.destroy.listenStatic([this, pad = PNEWPAD.get()] { PNEWPAD->m_events.destroy.listenStatic([this, pad = PNEWPAD.get()] {

View file

@ -50,10 +50,10 @@ void CTextInput::initCallbacks() {
} }
void CTextInput::onEnabled(SP<CWLSurfaceResource> surfV1) { void CTextInput::onEnabled(SP<CWLSurfaceResource> surfV1) {
Debug::log(LOG, "TI ENABLE"); Log::logger->log(Log::DEBUG, "TI ENABLE");
if (g_pInputManager->m_relay.m_inputMethod.expired()) { if (g_pInputManager->m_relay.m_inputMethod.expired()) {
// Debug::log(WARN, "Enabling TextInput on no IME!"); // Log::logger->log(Log::WARN, "Enabling TextInput on no IME!");
return; return;
} }
@ -70,7 +70,7 @@ void CTextInput::onEnabled(SP<CWLSurfaceResource> surfV1) {
void CTextInput::onDisabled() { void CTextInput::onDisabled() {
if (g_pInputManager->m_relay.m_inputMethod.expired()) { if (g_pInputManager->m_relay.m_inputMethod.expired()) {
// Debug::log(WARN, "Disabling TextInput on no IME!"); // Log::logger->log(Log::WARN, "Disabling TextInput on no IME!");
return; return;
} }
@ -107,12 +107,12 @@ void CTextInput::onReset() {
void CTextInput::onCommit() { void CTextInput::onCommit() {
if (g_pInputManager->m_relay.m_inputMethod.expired()) { if (g_pInputManager->m_relay.m_inputMethod.expired()) {
// Debug::log(WARN, "Committing TextInput on no IME!"); // Log::logger->log(Log::WARN, "Committing TextInput on no IME!");
return; return;
} }
if (!(isV3() ? m_v3Input->m_current.enabled.value : m_v1Input->m_active)) { if (!(isV3() ? m_v3Input->m_current.enabled.value : m_v1Input->m_active)) {
Debug::log(WARN, "Disabled TextInput commit?"); Log::logger->log(Log::WARN, "Disabled TextInput commit?");
return; return;
} }
@ -132,7 +132,7 @@ void CTextInput::setFocusedSurface(SP<CWLSurfaceResource> pSurface) {
m_listeners.surfaceDestroy.reset(); m_listeners.surfaceDestroy.reset();
m_listeners.surfaceUnmap = pSurface->m_events.unmap.listen([this] { m_listeners.surfaceUnmap = pSurface->m_events.unmap.listen([this] {
Debug::log(LOG, "Unmap TI owner1"); Log::logger->log(Log::DEBUG, "Unmap TI owner1");
if (m_enterLocks) if (m_enterLocks)
m_enterLocks--; m_enterLocks--;
@ -152,7 +152,7 @@ void CTextInput::setFocusedSurface(SP<CWLSurfaceResource> pSurface) {
}); });
m_listeners.surfaceDestroy = pSurface->m_events.destroy.listen([this] { m_listeners.surfaceDestroy = pSurface->m_events.destroy.listen([this] {
Debug::log(LOG, "Destroy TI owner1"); Log::logger->log(Log::DEBUG, "Destroy TI owner1");
if (m_enterLocks) if (m_enterLocks)
m_enterLocks--; m_enterLocks--;
@ -188,7 +188,7 @@ void CTextInput::enter(SP<CWLSurfaceResource> pSurface) {
m_enterLocks++; m_enterLocks++;
if (m_enterLocks != 1) { if (m_enterLocks != 1) {
Debug::log(ERR, "BUG THIS: TextInput has != 1 locks in enter"); Log::logger->log(Log::ERR, "BUG THIS: TextInput has != 1 locks in enter");
leave(); leave();
m_enterLocks = 1; m_enterLocks = 1;
} }
@ -208,7 +208,7 @@ void CTextInput::leave() {
m_enterLocks--; m_enterLocks--;
if (m_enterLocks != 0) { if (m_enterLocks != 0) {
Debug::log(ERR, "BUG THIS: TextInput has != 0 locks in leave"); Log::logger->log(Log::ERR, "BUG THIS: TextInput has != 0 locks in leave");
m_enterLocks = 0; m_enterLocks = 0;
} }

View file

@ -9,7 +9,7 @@
#include "../../devices/ITouch.hpp" #include "../../devices/ITouch.hpp"
#include "../SeatManager.hpp" #include "../SeatManager.hpp"
#include "../HookSystemManager.hpp" #include "../HookSystemManager.hpp"
#include "debug/Log.hpp" #include "debug/log/Logger.hpp"
#include "UnifiedWorkspaceSwipeGesture.hpp" #include "UnifiedWorkspaceSwipeGesture.hpp"
void CInputManager::onTouchDown(ITouch::SDownEvent e) { void CInputManager::onTouchDown(ITouch::SDownEvent e) {
@ -66,7 +66,7 @@ void CInputManager::onTouchDown(ITouch::SDownEvent e) {
if (g_pSessionLockManager->isSessionLocked() && m_foundLSToFocus.expired()) { if (g_pSessionLockManager->isSessionLocked() && m_foundLSToFocus.expired()) {
m_touchData.touchFocusLockSurface = g_pSessionLockManager->getSessionLockSurfaceForMonitor(PMONITOR->m_id); m_touchData.touchFocusLockSurface = g_pSessionLockManager->getSessionLockSurfaceForMonitor(PMONITOR->m_id);
if (!m_touchData.touchFocusLockSurface) if (!m_touchData.touchFocusLockSurface)
Debug::log(WARN, "The session is locked but can't find a lock surface"); Log::logger->log(Log::WARN, "The session is locked but can't find a lock surface");
else else
m_touchData.touchFocusSurface = m_touchData.touchFocusLockSurface->surface->surface(); m_touchData.touchFocusSurface = m_touchData.touchFocusLockSurface->surface->surface();
} else { } else {

View file

@ -15,7 +15,7 @@ void CUnifiedWorkspaceSwipeGesture::begin() {
const auto PWORKSPACE = Desktop::focusState()->monitor()->m_activeWorkspace; const auto PWORKSPACE = Desktop::focusState()->monitor()->m_activeWorkspace;
Debug::log(LOG, "CUnifiedWorkspaceSwipeGesture::begin: Starting a swipe from {}", PWORKSPACE->m_name); Log::logger->log(Log::DEBUG, "CUnifiedWorkspaceSwipeGesture::begin: Starting a swipe from {}", PWORKSPACE->m_name);
m_workspaceBegin = PWORKSPACE; m_workspaceBegin = PWORKSPACE;
m_delta = 0; m_delta = 0;
@ -261,7 +261,7 @@ void CUnifiedWorkspaceSwipeGesture::end() {
g_pInputManager->unconstrainMouse(); g_pInputManager->unconstrainMouse();
Debug::log(LOG, "Ended swipe to the left"); Log::logger->log(Log::DEBUG, "Ended swipe to the left");
pSwitchedTo = PWORKSPACEL; pSwitchedTo = PWORKSPACEL;
} else { } else {
@ -288,7 +288,7 @@ void CUnifiedWorkspaceSwipeGesture::end() {
g_pInputManager->unconstrainMouse(); g_pInputManager->unconstrainMouse();
Debug::log(LOG, "Ended swipe to the right"); Log::logger->log(Log::DEBUG, "Ended swipe to the right");
pSwitchedTo = PWORKSPACER; pSwitchedTo = PWORKSPACER;
} }

View file

@ -103,7 +103,7 @@ std::expected<void, std::string> CTrackpadGestures::removeGesture(size_t fingerC
void CTrackpadGestures::gestureBegin(const IPointer::SSwipeBeginEvent& e) { void CTrackpadGestures::gestureBegin(const IPointer::SSwipeBeginEvent& e) {
if (m_activeGesture) { if (m_activeGesture) {
Debug::log(ERR, "CTrackpadGestures::gestureBegin (swipe) but m_activeGesture is already present"); Log::logger->log(Log::ERR, "CTrackpadGestures::gestureBegin (swipe) but m_activeGesture is already present");
return; return;
} }
@ -121,7 +121,7 @@ void CTrackpadGestures::gestureUpdate(const IPointer::SSwipeUpdateEvent& e) {
// 5 was chosen because I felt like that's a good number. // 5 was chosen because I felt like that's a good number.
if (!m_activeGesture && (std::abs(m_currentTotalDelta.x) < 5 && std::abs(m_currentTotalDelta.y) < 5)) { if (!m_activeGesture && (std::abs(m_currentTotalDelta.x) < 5 && std::abs(m_currentTotalDelta.y) < 5)) {
Debug::log(TRACE, "CTrackpadGestures::gestureUpdate (swipe): gesture delta too small to start considering, waiting"); Log::logger->log(Log::TRACE, "CTrackpadGestures::gestureUpdate (swipe): gesture delta too small to start considering, waiting");
return; return;
} }
@ -174,7 +174,7 @@ void CTrackpadGestures::gestureEnd(const IPointer::SSwipeEndEvent& e) {
void CTrackpadGestures::gestureBegin(const IPointer::SPinchBeginEvent& e) { void CTrackpadGestures::gestureBegin(const IPointer::SPinchBeginEvent& e) {
if (m_activeGesture) { if (m_activeGesture) {
Debug::log(ERR, "CTrackpadGestures::gestureBegin (pinch) but m_activeGesture is already present"); Log::logger->log(Log::ERR, "CTrackpadGestures::gestureBegin (pinch) but m_activeGesture is already present");
return; return;
} }
@ -189,7 +189,7 @@ void CTrackpadGestures::gestureUpdate(const IPointer::SPinchUpdateEvent& e) {
// 0.1 was chosen because I felt like that's a good number. // 0.1 was chosen because I felt like that's a good number.
if (!m_activeGesture && std::abs(e.scale - 1.F) < 0.1) { if (!m_activeGesture && std::abs(e.scale - 1.F) < 0.1) {
Debug::log(TRACE, "CTrackpadGestures::gestureUpdate (pinch): gesture delta too small to start considering, waiting"); Log::logger->log(Log::TRACE, "CTrackpadGestures::gestureUpdate (pinch): gesture delta too small to start considering, waiting");
return; return;
} }

View file

@ -82,19 +82,19 @@ 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), rc<uintptr_t>(client), Log::logger->log(Log::TRACE, "CDynamicPermissionManager::clientHasPermission: checking permission {} for client {:x} (binary {})", permissionToString(permission),
LOOKUP.has_value() ? LOOKUP.value() : "lookup failed: " + LOOKUP.error()); rc<uintptr_t>(client), 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.
auto it = std::ranges::find_if(m_rules, [client, permission](const auto& e) { return e->m_client == client && e->m_type == permission; }); auto it = std::ranges::find_if(m_rules, [client, permission](const auto& e) { return e->m_client == client && e->m_type == permission; });
if (it == m_rules.end()) { if (it == m_rules.end()) {
Debug::log(TRACE, "CDynamicPermissionManager::clientHasPermission: permission not cached, checking binary name"); Log::logger->log(Log::TRACE, "CDynamicPermissionManager::clientHasPermission: permission not cached, checking binary name");
if (!LOOKUP.has_value()) if (!LOOKUP.has_value())
Debug::log(TRACE, "CDynamicPermissionManager::clientHasPermission: binary name check failed"); Log::logger->log(Log::TRACE, "CDynamicPermissionManager::clientHasPermission: binary name check failed");
else { else {
const auto BINNAME = LOOKUP.value().contains("/") ? LOOKUP.value().substr(LOOKUP.value().find_last_of('/') + 1) : LOOKUP.value(); const auto BINNAME = LOOKUP.value().contains("/") ? LOOKUP.value().substr(LOOKUP.value().find_last_of('/') + 1) : LOOKUP.value();
Debug::log(TRACE, "CDynamicPermissionManager::clientHasPermission: binary path {}, name {}", LOOKUP.value(), BINNAME); Log::logger->log(Log::TRACE, "CDynamicPermissionManager::clientHasPermission: binary path {}, name {}", LOOKUP.value(), BINNAME);
it = std::ranges::find_if(m_rules, [clientBinaryPath = LOOKUP.value(), permission](const auto& e) { it = std::ranges::find_if(m_rules, [clientBinaryPath = LOOKUP.value(), permission](const auto& e) {
if (e->m_type != permission) if (e->m_type != permission)
@ -114,29 +114,29 @@ eDynamicPermissionAllowMode CDynamicPermissionManager::clientPermissionMode(wl_c
}); });
if (it == m_rules.end()) if (it == m_rules.end())
Debug::log(TRACE, "CDynamicPermissionManager::clientHasPermission: no rule for binary"); Log::logger->log(Log::TRACE, "CDynamicPermissionManager::clientHasPermission: no rule for binary");
else { else {
if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_ALLOW) { if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_ALLOW) {
Debug::log(TRACE, "CDynamicPermissionManager::clientHasPermission: permission allowed by config rule"); Log::logger->log(Log::TRACE, "CDynamicPermissionManager::clientHasPermission: permission allowed by config rule");
return PERMISSION_RULE_ALLOW_MODE_ALLOW; return PERMISSION_RULE_ALLOW_MODE_ALLOW;
} else if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_DENY) { } else if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_DENY) {
Debug::log(TRACE, "CDynamicPermissionManager::clientHasPermission: permission denied by config rule"); Log::logger->log(Log::TRACE, "CDynamicPermissionManager::clientHasPermission: permission denied by config rule");
return PERMISSION_RULE_ALLOW_MODE_DENY; return PERMISSION_RULE_ALLOW_MODE_DENY;
} else if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_PENDING) { } else if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_PENDING) {
Debug::log(TRACE, "CDynamicPermissionManager::clientHasPermission: permission pending by config rule"); Log::logger->log(Log::TRACE, "CDynamicPermissionManager::clientHasPermission: permission pending by config rule");
return PERMISSION_RULE_ALLOW_MODE_PENDING; return PERMISSION_RULE_ALLOW_MODE_PENDING;
} else } else
Debug::log(TRACE, "CDynamicPermissionManager::clientHasPermission: permission ask by config rule"); Log::logger->log(Log::TRACE, "CDynamicPermissionManager::clientHasPermission: permission ask by config rule");
} }
} }
} else if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_ALLOW) { } else if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_ALLOW) {
Debug::log(TRACE, "CDynamicPermissionManager::clientHasPermission: permission allowed before by user"); Log::logger->log(Log::TRACE, "CDynamicPermissionManager::clientHasPermission: permission allowed before by user");
return PERMISSION_RULE_ALLOW_MODE_ALLOW; return PERMISSION_RULE_ALLOW_MODE_ALLOW;
} else if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_DENY) { } else if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_DENY) {
Debug::log(TRACE, "CDynamicPermissionManager::clientHasPermission: permission denied before by user"); Log::logger->log(Log::TRACE, "CDynamicPermissionManager::clientHasPermission: permission denied before by user");
return PERMISSION_RULE_ALLOW_MODE_DENY; return PERMISSION_RULE_ALLOW_MODE_DENY;
} else if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_PENDING) { } else if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_PENDING) {
Debug::log(TRACE, "CDynamicPermissionManager::clientHasPermission: permission pending before by user"); Log::logger->log(Log::TRACE, "CDynamicPermissionManager::clientHasPermission: permission pending before by user");
return PERMISSION_RULE_ALLOW_MODE_PENDING; return PERMISSION_RULE_ALLOW_MODE_PENDING;
} }
@ -158,7 +158,7 @@ eDynamicPermissionAllowMode CDynamicPermissionManager::clientPermissionModeWithS
if (pid > 0) { if (pid > 0) {
lookup = binaryNameForPid(pid); lookup = binaryNameForPid(pid);
Debug::log(TRACE, "CDynamicPermissionManager::clientHasPermission: checking permission {} for key {} (binary {})", permissionToString(permission), str, Log::logger->log(Log::TRACE, "CDynamicPermissionManager::clientHasPermission: checking permission {} for key {} (binary {})", permissionToString(permission), str,
lookup.has_value() ? lookup.value() : "lookup failed: " + lookup.error()); lookup.has_value() ? lookup.value() : "lookup failed: " + lookup.error());
if (lookup.has_value()) if (lookup.has_value())
@ -169,7 +169,7 @@ eDynamicPermissionAllowMode CDynamicPermissionManager::clientPermissionModeWithS
// 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; });
if (it == m_rules.end()) { if (it == m_rules.end()) {
Debug::log(TRACE, "CDynamicPermissionManager::clientHasPermission: permission not cached, checking key"); Log::logger->log(Log::TRACE, "CDynamicPermissionManager::clientHasPermission: permission not cached, checking key");
it = std::ranges::find_if(m_rules, [key = str, permission, &lookup](const auto& e) { it = std::ranges::find_if(m_rules, [key = str, permission, &lookup](const auto& e) {
if (e->m_type != permission) if (e->m_type != permission)
@ -186,33 +186,33 @@ eDynamicPermissionAllowMode CDynamicPermissionManager::clientPermissionModeWithS
}); });
if (it == m_rules.end()) if (it == m_rules.end())
Debug::log(TRACE, "CDynamicPermissionManager::clientHasPermission: no rule for key"); Log::logger->log(Log::TRACE, "CDynamicPermissionManager::clientHasPermission: no rule for key");
else { else {
if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_ALLOW) { if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_ALLOW) {
Debug::log(TRACE, "CDynamicPermissionManager::clientHasPermission: permission allowed by config rule"); Log::logger->log(Log::TRACE, "CDynamicPermissionManager::clientHasPermission: permission allowed by config rule");
return PERMISSION_RULE_ALLOW_MODE_ALLOW; return PERMISSION_RULE_ALLOW_MODE_ALLOW;
} else if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_DENY) { } else if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_DENY) {
Debug::log(TRACE, "CDynamicPermissionManager::clientHasPermission: permission denied by config rule"); Log::logger->log(Log::TRACE, "CDynamicPermissionManager::clientHasPermission: permission denied by config rule");
return PERMISSION_RULE_ALLOW_MODE_DENY; return PERMISSION_RULE_ALLOW_MODE_DENY;
} else if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_PENDING) { } else if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_PENDING) {
Debug::log(TRACE, "CDynamicPermissionManager::clientHasPermission: permission pending by config rule"); Log::logger->log(Log::TRACE, "CDynamicPermissionManager::clientHasPermission: permission pending by config rule");
return PERMISSION_RULE_ALLOW_MODE_PENDING; return PERMISSION_RULE_ALLOW_MODE_PENDING;
} else if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_ASK) { } else if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_ASK) {
Debug::log(TRACE, "CDynamicPermissionManager::clientHasPermission: permission ask by config rule"); Log::logger->log(Log::TRACE, "CDynamicPermissionManager::clientHasPermission: permission ask by config rule");
askForPermission(nullptr, str, permission, pid); askForPermission(nullptr, str, permission, pid);
return PERMISSION_RULE_ALLOW_MODE_PENDING; return PERMISSION_RULE_ALLOW_MODE_PENDING;
} else } else
Debug::log(TRACE, "CDynamicPermissionManager::clientHasPermission: permission ask by config rule"); Log::logger->log(Log::TRACE, "CDynamicPermissionManager::clientHasPermission: permission ask by config rule");
} }
} else if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_ALLOW) { } else if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_ALLOW) {
Debug::log(TRACE, "CDynamicPermissionManager::clientHasPermission: permission allowed before by user"); Log::logger->log(Log::TRACE, "CDynamicPermissionManager::clientHasPermission: permission allowed before by user");
return PERMISSION_RULE_ALLOW_MODE_ALLOW; return PERMISSION_RULE_ALLOW_MODE_ALLOW;
} else if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_DENY) { } else if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_DENY) {
Debug::log(TRACE, "CDynamicPermissionManager::clientHasPermission: permission denied before by user"); Log::logger->log(Log::TRACE, "CDynamicPermissionManager::clientHasPermission: permission denied before by user");
return PERMISSION_RULE_ALLOW_MODE_DENY; return PERMISSION_RULE_ALLOW_MODE_DENY;
} else if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_PENDING) { } else if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_PENDING) {
Debug::log(TRACE, "CDynamicPermissionManager::clientHasPermission: permission pending before by user"); Log::logger->log(Log::TRACE, "CDynamicPermissionManager::clientHasPermission: permission pending before by user");
return PERMISSION_RULE_ALLOW_MODE_PENDING; return PERMISSION_RULE_ALLOW_MODE_PENDING;
} }
@ -272,7 +272,7 @@ void CDynamicPermissionManager::askForPermission(wl_client* client, const std::s
rule->m_dialogBox->m_priority = true; rule->m_dialogBox->m_priority = true;
if (!rule->m_dialogBox) { if (!rule->m_dialogBox) {
Debug::log(ERR, "CDynamicPermissionManager::askForPermission: hyprland-guiutils likely missing, cannot ask! Disabling permission control..."); Log::logger->log(Log::ERR, "CDynamicPermissionManager::askForPermission: hyprland-guiutils likely missing, cannot ask! Disabling permission control...");
rule->m_allowMode = PERMISSION_RULE_ALLOW_MODE_ALLOW; rule->m_allowMode = PERMISSION_RULE_ALLOW_MODE_ALLOW;
return; return;
} }
@ -284,7 +284,7 @@ void CDynamicPermissionManager::askForPermission(wl_client* client, const std::s
if (pr->hasError()) { if (pr->hasError()) {
// not reachable for now // not reachable for now
Debug::log(TRACE, "CDynamicPermissionRule: error spawning dialog box"); Log::logger->log(Log::TRACE, "CDynamicPermissionRule: error spawning dialog box");
if (r->m_promiseResolverForExternal) if (r->m_promiseResolverForExternal)
r->m_promiseResolverForExternal->reject("error spawning dialog box"); r->m_promiseResolverForExternal->reject("error spawning dialog box");
r->m_promiseResolverForExternal.reset(); r->m_promiseResolverForExternal.reset();
@ -293,7 +293,7 @@ void CDynamicPermissionManager::askForPermission(wl_client* client, const std::s
const std::string& result = pr->result(); const std::string& result = pr->result();
Debug::log(TRACE, "CDynamicPermissionRule: user returned {}", result); Log::logger->log(Log::TRACE, "CDynamicPermissionRule: user returned {}", result);
if (result.starts_with(ALLOW_ONCE)) if (result.starts_with(ALLOW_ONCE))
r->m_allowMode = PERMISSION_RULE_ALLOW_MODE_ALLOW; r->m_allowMode = PERMISSION_RULE_ALLOW_MODE_ALLOW;

View file

@ -1,5 +1,5 @@
#include "HookSystem.hpp" #include "HookSystem.hpp"
#include "../debug/Log.hpp" #include "../debug/log/Logger.hpp"
#include "../helpers/varlist/VarList.hpp" #include "../helpers/varlist/VarList.hpp"
#include "../managers/TokenManager.hpp" #include "../managers/TokenManager.hpp"
#include "../helpers/MiscFunctions.hpp" #include "../helpers/MiscFunctions.hpp"
@ -146,7 +146,7 @@ bool CFunctionHook::hook() {
if (g_pFunctionHookSystem->m_activeHooks.contains(rc<uint64_t>(m_source))) { if (g_pFunctionHookSystem->m_activeHooks.contains(rc<uint64_t>(m_source))) {
// TODO: return actual error codes... // TODO: return actual error codes...
Debug::log(ERR, "[functionhook] failed, function is already hooked"); Log::logger->log(Log::ERR, "[functionhook] failed, function is already hooked");
return false; return false;
} }
@ -174,12 +174,12 @@ bool CFunctionHook::hook() {
const auto PROBEFIXEDASM = fixInstructionProbeRIPCalls(probe); const auto PROBEFIXEDASM = fixInstructionProbeRIPCalls(probe);
if (PROBEFIXEDASM.bytes.empty()) { if (PROBEFIXEDASM.bytes.empty()) {
Debug::log(ERR, "[functionhook] failed, unsupported asm / failed assembling:\n{}", probe.assembly); Log::logger->log(Log::ERR, "[functionhook] failed, unsupported asm / failed assembling:\n{}", probe.assembly);
return false; return false;
} }
if (std::abs(rc<int64_t>(m_source) - rc<int64_t>(m_landTrampolineAddr)) > 2000000000 /* 2 GB */) { if (std::abs(rc<int64_t>(m_source) - rc<int64_t>(m_landTrampolineAddr)) > 2000000000 /* 2 GB */) {
Debug::log(ERR, "[functionhook] failed, source and trampo are over 2GB apart"); Log::logger->log(Log::ERR, "[functionhook] failed, source and trampo are over 2GB apart");
return false; return false;
} }
@ -189,7 +189,7 @@ bool CFunctionHook::hook() {
const auto TRAMPOLINE_SIZE = sizeof(RELATIVE_JMP_ADDRESS) + HOOKSIZE; const auto TRAMPOLINE_SIZE = sizeof(RELATIVE_JMP_ADDRESS) + HOOKSIZE;
if (TRAMPOLINE_SIZE > MAX_TRAMPOLINE_SIZE) { if (TRAMPOLINE_SIZE > MAX_TRAMPOLINE_SIZE) {
Debug::log(ERR, "[functionhook] failed, not enough space in trampo to alloc:\n{}", probe.assembly); Log::logger->log(Log::ERR, "[functionhook] failed, not enough space in trampo to alloc:\n{}", probe.assembly);
return false; return false;
} }
@ -300,7 +300,7 @@ static uintptr_t seekNewPageAddr() {
uint64_t start = 0, end = 0; uint64_t start = 0, end = 0;
if (props[0].empty()) { if (props[0].empty()) {
Debug::log(WARN, "seekNewPageAddr: unexpected line in self maps"); Log::logger->log(Log::WARN, "seekNewPageAddr: unexpected line in self maps");
continue; continue;
} }
@ -310,11 +310,11 @@ static uintptr_t seekNewPageAddr() {
start = std::stoull(startEnd[0], nullptr, 16); start = std::stoull(startEnd[0], nullptr, 16);
end = std::stoull(startEnd[1], nullptr, 16); end = std::stoull(startEnd[1], nullptr, 16);
} catch (std::exception& e) { } catch (std::exception& e) {
Debug::log(WARN, "seekNewPageAddr: unexpected line in self maps: {}", line); Log::logger->log(Log::WARN, "seekNewPageAddr: unexpected line in self maps: {}", line);
continue; continue;
} }
Debug::log(LOG, "seekNewPageAddr: page 0x{:x} - 0x{:x}", start, end); Log::logger->log(Log::DEBUG, "seekNewPageAddr: page 0x{:x} - 0x{:x}", start, end);
if (lastStart == 0) { if (lastStart == 0) {
lastStart = start; lastStart = start;
@ -323,17 +323,17 @@ static uintptr_t seekNewPageAddr() {
} }
if (!anchoredToHyprland && line.contains("Hyprland")) { if (!anchoredToHyprland && line.contains("Hyprland")) {
Debug::log(LOG, "seekNewPageAddr: Anchored to hyprland at 0x{:x}", start); Log::logger->log(Log::DEBUG, "seekNewPageAddr: Anchored to hyprland at 0x{:x}", start);
anchoredToHyprland = true; anchoredToHyprland = true;
} else if (start - lastEnd > PAGESIZE_VAR * 2) { } else if (start - lastEnd > PAGESIZE_VAR * 2) {
if (!anchoredToHyprland) { if (!anchoredToHyprland) {
Debug::log(LOG, "seekNewPageAddr: skipping gap 0x{:x}-0x{:x}, not anchored to Hyprland code pages yet.", lastEnd, start); Log::logger->log(Log::DEBUG, "seekNewPageAddr: skipping gap 0x{:x}-0x{:x}, not anchored to Hyprland code pages yet.", lastEnd, start);
lastStart = start; lastStart = start;
lastEnd = end; lastEnd = end;
continue; continue;
} }
Debug::log(LOG, "seekNewPageAddr: found gap: 0x{:x}-0x{:x} ({} bytes)", lastEnd, start, start - lastEnd); Log::logger->log(Log::DEBUG, "seekNewPageAddr: found gap: 0x{:x}-0x{:x} ({} bytes)", lastEnd, start, start - lastEnd);
MAPS.close(); MAPS.close();
return lastEnd; return lastEnd;
} }
@ -365,7 +365,7 @@ uint64_t CHookSystem::getAddressForTrampo() {
if (!page->addr) { if (!page->addr) {
// allocate it // allocate it
Debug::log(LOG, "getAddressForTrampo: Allocating new page for hooks"); Log::logger->log(Log::DEBUG, "getAddressForTrampo: Allocating new page for hooks");
const uint64_t PAGESIZE_VAR = sysconf(_SC_PAGE_SIZE); const uint64_t PAGESIZE_VAR = sysconf(_SC_PAGE_SIZE);
const auto BASEPAGEADDR = seekNewPageAddr(); const auto BASEPAGEADDR = seekNewPageAddr();
for (int attempt = 0; attempt < 2; ++attempt) { for (int attempt = 0; attempt < 2; ++attempt) {
@ -376,7 +376,7 @@ uint64_t CHookSystem::getAddressForTrampo() {
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); Log::logger->log(Log::DEBUG, "Attempted to allocate 0x{:x}, got 0x{:x}", PAGEADDR, page->addr);
if (page->addr == rc<uint64_t>(MAP_FAILED)) if (page->addr == rc<uint64_t>(MAP_FAILED))
continue; continue;
@ -398,7 +398,7 @@ uint64_t CHookSystem::getAddressForTrampo() {
page->used += HOOK_TRAMPOLINE_MAX_SIZE; page->used += HOOK_TRAMPOLINE_MAX_SIZE;
Debug::log(LOG, "getAddressForTrampo: Returning addr 0x{:x} for page at 0x{:x}", ADDRFORCONSUMER, page->addr); Log::logger->log(Log::DEBUG, "getAddressForTrampo: Returning addr 0x{:x} for page at 0x{:x}", ADDRFORCONSUMER, page->addr);
return ADDRFORCONSUMER; return ADDRFORCONSUMER;
} }

View file

@ -350,7 +350,7 @@ APICALL std::vector<SFunctionMatch> HyprlandAPI::findFunctionsByName(HANDLE hand
}; };
if (SYMBOLS.empty()) { if (SYMBOLS.empty()) {
Debug::log(ERR, R"(Unable to search for function "{}": no symbols found in binary (is "{}" in path?))", name, Log::logger->log(Log::ERR, R"(Unable to search for function "{}": no symbols found in binary (is "{}" in path?))", name,
#ifdef __clang__ #ifdef __clang__
"llvm-nm" "llvm-nm"
#else #else

View file

@ -25,7 +25,7 @@ SP<CPromise<CPlugin*>> CPluginSystem::loadPlugin(const std::string& path, eSpeci
return CPromise<CPlugin*>::make([path, pid, pidType, this](SP<CPromiseResolver<CPlugin*>> resolver) { return CPromise<CPlugin*>::make([path, pid, pidType, this](SP<CPromiseResolver<CPlugin*>> resolver) {
const auto PERM = g_pDynamicPermissionManager->clientPermissionModeWithString(pidType != SPECIAL_PID_TYPE_NONE ? pidType : pid, path, PERMISSION_TYPE_PLUGIN); const auto PERM = g_pDynamicPermissionManager->clientPermissionModeWithString(pidType != SPECIAL_PID_TYPE_NONE ? pidType : pid, path, PERMISSION_TYPE_PLUGIN);
if (PERM == PERMISSION_RULE_ALLOW_MODE_PENDING) { if (PERM == PERMISSION_RULE_ALLOW_MODE_PENDING) {
Debug::log(LOG, "CPluginSystem: Waiting for user confirmation to load {}", path); Log::logger->log(Log::DEBUG, "CPluginSystem: Waiting for user confirmation to load {}", path);
auto promise = g_pDynamicPermissionManager->promiseFor(pid, path, PERMISSION_TYPE_PLUGIN); auto promise = g_pDynamicPermissionManager->promiseFor(pid, path, PERMISSION_TYPE_PLUGIN);
if (!promise) { // already awaiting or something? if (!promise) { // already awaiting or something?
@ -35,18 +35,18 @@ SP<CPromise<CPlugin*>> CPluginSystem::loadPlugin(const std::string& path, eSpeci
promise->then([this, path, resolver](SP<CPromiseResult<eDynamicPermissionAllowMode>> result) { promise->then([this, path, resolver](SP<CPromiseResult<eDynamicPermissionAllowMode>> result) {
if (result->hasError()) { if (result->hasError()) {
Debug::log(ERR, "CPluginSystem: Error spawning permission prompt"); Log::logger->log(Log::ERR, "CPluginSystem: Error spawning permission prompt");
resolver->reject("Error spawning permission prompt"); resolver->reject("Error spawning permission prompt");
return; return;
} }
if (result->result() != PERMISSION_RULE_ALLOW_MODE_ALLOW) { if (result->result() != PERMISSION_RULE_ALLOW_MODE_ALLOW) {
Debug::log(ERR, "CPluginSystem: Rejecting plugin load of {}, user denied", path); Log::logger->log(Log::ERR, "CPluginSystem: Rejecting plugin load of {}, user denied", path);
resolver->reject("user denied"); resolver->reject("user denied");
return; return;
} }
Debug::log(LOG, "CPluginSystem: Loading {}, user allowed", path); Log::logger->log(Log::DEBUG, "CPluginSystem: Loading {}, user allowed", path);
const auto RESULT = loadPluginInternal(path); const auto RESULT = loadPluginInternal(path);
if (RESULT.has_value()) if (RESULT.has_value())
@ -56,7 +56,7 @@ SP<CPromise<CPlugin*>> CPluginSystem::loadPlugin(const std::string& path, eSpeci
}); });
return; return;
} else if (PERM == PERMISSION_RULE_ALLOW_MODE_DENY) { } else if (PERM == PERMISSION_RULE_ALLOW_MODE_DENY) {
Debug::log(LOG, "CPluginSystem: Rejecting plugin load, permission is disabled"); Log::logger->log(Log::DEBUG, "CPluginSystem: Rejecting plugin load, permission is disabled");
resolver->reject("permission is disabled"); resolver->reject("permission is disabled");
return; return;
} }
@ -71,7 +71,7 @@ SP<CPromise<CPlugin*>> CPluginSystem::loadPlugin(const std::string& path, eSpeci
std::expected<CPlugin*, std::string> CPluginSystem::loadPluginInternal(const std::string& path) { std::expected<CPlugin*, std::string> CPluginSystem::loadPluginInternal(const std::string& path) {
if (getPluginByPath(path)) { if (getPluginByPath(path)) {
Debug::log(ERR, " [PluginSystem] Cannot load a plugin twice!"); Log::logger->log(Log::ERR, " [PluginSystem] Cannot load a plugin twice!");
return std::unexpected("Cannot load a plugin twice!"); return std::unexpected("Cannot load a plugin twice!");
} }
@ -83,7 +83,7 @@ std::expected<CPlugin*, std::string> CPluginSystem::loadPluginInternal(const std
if (!MODULE) { if (!MODULE) {
std::string strerr = dlerror(); std::string strerr = dlerror();
Debug::log(ERR, " [PluginSystem] Plugin {} could not be loaded: {}", path, strerr); Log::logger->log(Log::ERR, " [PluginSystem] Plugin {} could not be loaded: {}", path, strerr);
m_loadedPlugins.pop_back(); m_loadedPlugins.pop_back();
return std::unexpected(std::format("Plugin {} could not be loaded: {}", path, strerr)); return std::unexpected(std::format("Plugin {} could not be loaded: {}", path, strerr));
} }
@ -94,7 +94,7 @@ std::expected<CPlugin*, std::string> CPluginSystem::loadPluginInternal(const std
PPLUGIN_INIT_FUNC initFunc = rc<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); Log::logger->log(Log::ERR, " [PluginSystem] Plugin {} could not be loaded. (No apiver/init func)", path);
dlclose(MODULE); dlclose(MODULE);
m_loadedPlugins.pop_back(); m_loadedPlugins.pop_back();
return std::unexpected(std::format("Plugin {} could not be loaded: {}", path, "missing apiver/init func")); return std::unexpected(std::format("Plugin {} could not be loaded: {}", path, "missing apiver/init func"));
@ -103,7 +103,7 @@ std::expected<CPlugin*, std::string> CPluginSystem::loadPluginInternal(const std
const std::string PLUGINAPIVER = apiVerFunc(); const std::string PLUGINAPIVER = apiVerFunc();
if (PLUGINAPIVER != HYPRLAND_API_VERSION) { if (PLUGINAPIVER != HYPRLAND_API_VERSION) {
Debug::log(ERR, " [PluginSystem] Plugin {} could not be loaded. (API version mismatch)", path); Log::logger->log(Log::ERR, " [PluginSystem] Plugin {} could not be loaded. (API version mismatch)", path);
dlclose(MODULE); dlclose(MODULE);
m_loadedPlugins.pop_back(); m_loadedPlugins.pop_back();
return std::unexpected(std::format("Plugin {} could not be loaded: {}", path, "API version mismatch")); return std::unexpected(std::format("Plugin {} could not be loaded: {}", path, "API version mismatch"));
@ -121,7 +121,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, rc<uintptr_t>(MODULE)); Log::logger->log(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()));
} }
@ -135,8 +135,8 @@ 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, rc<uintptr_t>(MODULE), path, Log::logger->log(Log::DEBUG, R"( [PluginSystem] Plugin {} loaded. Handle: {:x}, path: "{}", author: "{}", description: "{}", version: "{}")", PLUGINDATA.name,
PLUGINDATA.author, PLUGINDATA.description, PLUGINDATA.version); rc<uintptr_t>(MODULE), path, PLUGINDATA.author, PLUGINDATA.description, PLUGINDATA.version);
return PLUGIN; return PLUGIN;
} }
@ -185,7 +185,7 @@ void CPluginSystem::unloadPlugin(const CPlugin* plugin, bool eject) {
dlclose(PLHANDLE); dlclose(PLHANDLE);
Debug::log(LOG, " [PluginSystem] Plugin {} unloaded.", PLNAME); Log::logger->log(Log::DEBUG, " [PluginSystem] Plugin {} unloaded.", PLNAME);
// reload config to fix some stuf like e.g. unloadedPluginVars // reload config to fix some stuf like e.g. unloadedPluginVars
g_pEventLoopManager->doLater([] { g_pConfigManager->reload(); }); g_pEventLoopManager->doLater([] { g_pConfigManager->reload(); });
@ -207,7 +207,7 @@ void CPluginSystem::updateConfigPlugins(const std::vector<std::string>& plugins,
if (!p->m_loadedWithConfig || std::ranges::find(plugins, p->m_path) != plugins.end()) if (!p->m_loadedWithConfig || std::ranges::find(plugins, p->m_path) != plugins.end())
continue; continue;
Debug::log(LOG, "Unloading plugin {} which is no longer present in config", p->m_path); Log::logger->log(Log::DEBUG, "Unloading plugin {} which is no longer present in config", p->m_path);
unloadPlugin(p.get(), false); unloadPlugin(p.get(), false);
changed = true; changed = true;
} }
@ -217,14 +217,14 @@ void CPluginSystem::updateConfigPlugins(const std::vector<std::string>& plugins,
if (std::ranges::find_if(m_loadedPlugins, [&](const auto& other) { return other->m_path == path; }) != m_loadedPlugins.end()) if (std::ranges::find_if(m_loadedPlugins, [&](const auto& other) { return other->m_path == path; }) != m_loadedPlugins.end())
continue; continue;
Debug::log(LOG, "Loading plugin {} which is now present in config", path); Log::logger->log(Log::DEBUG, "Loading plugin {} which is now present in config", path);
changed = true; changed = true;
loadPlugin(path, SPECIAL_PID_TYPE_CONFIG)->then([path](SP<CPromiseResult<CPlugin*>> result) { loadPlugin(path, SPECIAL_PID_TYPE_CONFIG)->then([path](SP<CPromiseResult<CPlugin*>> result) {
if (result->hasError()) { if (result->hasError()) {
const auto NAME = path.contains('/') ? path.substr(path.find_last_of('/') + 1) : path; const auto NAME = path.contains('/') ? path.substr(path.find_last_of('/') + 1) : path;
Debug::log(ERR, "CPluginSystem::updateConfigPlugins: failed to load plugin {}: {}", NAME, result->error()); Log::logger->log(Log::ERR, "CPluginSystem::updateConfigPlugins: failed to load plugin {}: {}", NAME, result->error());
g_pHyprNotificationOverlay->addNotification(I18n::i18nEngine()->localize(I18n::TXT_KEY_NOTIF_FAILED_TO_LOAD_PLUGIN, {{"name", NAME}, {"error", result->error()}}), g_pHyprNotificationOverlay->addNotification(I18n::i18nEngine()->localize(I18n::TXT_KEY_NOTIF_FAILED_TO_LOAD_PLUGIN, {{"name", NAME}, {"error", result->error()}}),
CHyprColor{0, 0, 0, 0}, 5000, ICON_ERROR); CHyprColor{0, 0, 0, 0}, 5000, ICON_ERROR);
return; return;
@ -232,7 +232,7 @@ void CPluginSystem::updateConfigPlugins(const std::vector<std::string>& plugins,
result->result()->m_loadedWithConfig = true; result->result()->m_loadedWithConfig = true;
Debug::log(LOG, "CPluginSystem::updateConfigPlugins: loaded {}", path); Log::logger->log(Log::DEBUG, "CPluginSystem::updateConfigPlugins: loaded {}", path);
}); });
} }
} }

View file

@ -85,7 +85,7 @@ void CAlphaModifierProtocol::getSurface(CWpAlphaModifierV1* manager, uint32_t id
if (iter != m_alphaModifiers.end()) { if (iter != m_alphaModifiers.end()) {
if (iter->second->m_resource) { if (iter->second->m_resource) {
LOGM(ERR, "AlphaModifier already present for surface {:x}", (uintptr_t)surface.get()); LOGM(Log::ERR, "AlphaModifier already present for surface {:x}", (uintptr_t)surface.get());
manager->error(WP_ALPHA_MODIFIER_V1_ERROR_ALREADY_CONSTRUCTED, "AlphaModifier already present"); manager->error(WP_ALPHA_MODIFIER_V1_ERROR_ALREADY_CONSTRUCTED, "AlphaModifier already present");
return; return;
} else { } else {

View file

@ -42,14 +42,14 @@ CHyprlandCTMControlResource::CHyprlandCTMControlResource(UP<CHyprlandCtmControlM
m_ctms[PMONITOR->m_name] = MAT; m_ctms[PMONITOR->m_name] = MAT;
LOGM(LOG, "CTM set for output {}: {}", PMONITOR->m_name, m_ctms.at(PMONITOR->m_name).toString()); LOGM(Log::DEBUG, "CTM set for output {}: {}", PMONITOR->m_name, m_ctms.at(PMONITOR->m_name).toString());
}); });
m_resource->setCommit([this](CHyprlandCtmControlManagerV1* r) { m_resource->setCommit([this](CHyprlandCtmControlManagerV1* r) {
if (m_blocked) if (m_blocked)
return; return;
LOGM(LOG, "Committing ctms to outputs"); LOGM(Log::DEBUG, "Committing ctms to outputs");
for (auto& m : g_pCompositor->m_monitors) { for (auto& m : g_pCompositor->m_monitors) {
if (!m_ctms.contains(m->m_name)) { if (!m_ctms.contains(m->m_name)) {
@ -100,7 +100,7 @@ void CHyprlandCTMControlProtocol::bindManager(wl_client* client, void* data, uin
else else
m_manager = RESOURCE; m_manager = RESOURCE;
LOGM(LOG, "New CTM Manager at 0x{:x}", (uintptr_t)RESOURCE.get()); LOGM(Log::DEBUG, "New CTM Manager at 0x{:x}", (uintptr_t)RESOURCE.get());
} }
void CHyprlandCTMControlProtocol::destroyResource(CHyprlandCTMControlResource* res) { void CHyprlandCTMControlProtocol::destroyResource(CHyprlandCTMControlResource* res) {

View file

@ -62,9 +62,9 @@ CColorManager::CColorManager(SP<CWpColorManagerV1> resource) : m_resource(resour
m_resource->sendSupportedIntent(WP_COLOR_MANAGER_V1_RENDER_INTENT_RELATIVE_BPC); m_resource->sendSupportedIntent(WP_COLOR_MANAGER_V1_RENDER_INTENT_RELATIVE_BPC);
} }
m_resource->setDestroy([](CWpColorManagerV1* r) { LOGM(TRACE, "Destroy WP_color_manager at {:x} (generated default)", (uintptr_t)r); }); m_resource->setDestroy([](CWpColorManagerV1* r) { LOGM(Log::TRACE, "Destroy WP_color_manager at {:x} (generated default)", (uintptr_t)r); });
m_resource->setGetOutput([](CWpColorManagerV1* r, uint32_t id, wl_resource* output) { m_resource->setGetOutput([](CWpColorManagerV1* r, uint32_t id, wl_resource* output) {
LOGM(TRACE, "Get output for id={}, output={}", id, (uintptr_t)output); LOGM(Log::TRACE, "Get output for id={}, output={}", id, (uintptr_t)output);
const auto OUTPUTRESOURCE = CWLOutputResource::fromResource(output); const auto OUTPUTRESOURCE = CWLOutputResource::fromResource(output);
@ -80,11 +80,11 @@ CColorManager::CColorManager(SP<CWpColorManagerV1> resource) : m_resource(resour
RESOURCE->m_self = RESOURCE; RESOURCE->m_self = RESOURCE;
}); });
m_resource->setGetSurface([](CWpColorManagerV1* r, uint32_t id, wl_resource* surface) { m_resource->setGetSurface([](CWpColorManagerV1* r, uint32_t id, wl_resource* surface) {
LOGM(TRACE, "Get surface for id={}, surface={}", id, (uintptr_t)surface); LOGM(Log::TRACE, "Get surface for id={}, surface={}", id, (uintptr_t)surface);
auto SURF = CWLSurfaceResource::fromResource(surface); auto SURF = CWLSurfaceResource::fromResource(surface);
if (!SURF) { if (!SURF) {
LOGM(ERR, "No surface for resource {}", (uintptr_t)surface); LOGM(Log::ERR, "No surface for resource {}", (uintptr_t)surface);
r->error(-1, "Invalid surface (2)"); r->error(-1, "Invalid surface (2)");
return; return;
} }
@ -107,11 +107,11 @@ CColorManager::CColorManager(SP<CWpColorManagerV1> resource) : m_resource(resour
SURF->m_colorManagement = RESOURCE; SURF->m_colorManagement = RESOURCE;
}); });
m_resource->setGetSurfaceFeedback([](CWpColorManagerV1* r, uint32_t id, wl_resource* surface) { m_resource->setGetSurfaceFeedback([](CWpColorManagerV1* r, uint32_t id, wl_resource* surface) {
LOGM(TRACE, "Get feedback surface for id={}, surface={}", id, (uintptr_t)surface); LOGM(Log::TRACE, "Get feedback surface for id={}, surface={}", id, (uintptr_t)surface);
auto SURF = CWLSurfaceResource::fromResource(surface); auto SURF = CWLSurfaceResource::fromResource(surface);
if (!SURF) { if (!SURF) {
LOGM(ERR, "No surface for resource {}", (uintptr_t)surface); LOGM(Log::ERR, "No surface for resource {}", (uintptr_t)surface);
r->error(-1, "Invalid surface (2)"); r->error(-1, "Invalid surface (2)");
return; return;
} }
@ -128,7 +128,7 @@ CColorManager::CColorManager(SP<CWpColorManagerV1> resource) : m_resource(resour
RESOURCE->m_self = RESOURCE; RESOURCE->m_self = RESOURCE;
}); });
m_resource->setCreateIccCreator([](CWpColorManagerV1* r, uint32_t id) { m_resource->setCreateIccCreator([](CWpColorManagerV1* r, uint32_t id) {
LOGM(WARN, "New ICC creator for id={} (unsupported)", id); LOGM(Log::WARN, "New ICC creator for id={} (unsupported)", id);
if (!PROTO::colorManagement->m_debug) { if (!PROTO::colorManagement->m_debug) {
r->error(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "ICC profiles are not supported"); r->error(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "ICC profiles are not supported");
return; return;
@ -146,7 +146,7 @@ CColorManager::CColorManager(SP<CWpColorManagerV1> resource) : m_resource(resour
RESOURCE->m_self = RESOURCE; RESOURCE->m_self = RESOURCE;
}); });
m_resource->setCreateParametricCreator([](CWpColorManagerV1* r, uint32_t id) { m_resource->setCreateParametricCreator([](CWpColorManagerV1* r, uint32_t id) {
LOGM(TRACE, "New parametric creator for id={}", id); LOGM(Log::TRACE, "New parametric creator for id={}", id);
const auto RESOURCE = PROTO::colorManagement->m_parametricCreators.emplace_back( const auto RESOURCE = PROTO::colorManagement->m_parametricCreators.emplace_back(
makeShared<CColorManagementParametricCreator>(makeShared<CWpImageDescriptionCreatorParamsV1>(r->client(), r->version(), id))); makeShared<CColorManagementParametricCreator>(makeShared<CWpImageDescriptionCreatorParamsV1>(r->client(), r->version(), id)));
@ -160,7 +160,7 @@ CColorManager::CColorManager(SP<CWpColorManagerV1> resource) : m_resource(resour
RESOURCE->m_self = RESOURCE; RESOURCE->m_self = RESOURCE;
}); });
m_resource->setCreateWindowsScrgb([](CWpColorManagerV1* r, uint32_t id) { m_resource->setCreateWindowsScrgb([](CWpColorManagerV1* r, uint32_t id) {
LOGM(WARN, "New Windows scRGB description id={}", id); LOGM(Log::WARN, "New Windows scRGB description id={}", id);
const auto RESOURCE = PROTO::colorManagement->m_imageDescriptions.emplace_back( const auto RESOURCE = PROTO::colorManagement->m_imageDescriptions.emplace_back(
makeShared<CColorManagementImageDescription>(makeShared<CWpImageDescriptionV1>(r->client(), r->version(), id), false)); makeShared<CColorManagementImageDescription>(makeShared<CWpImageDescriptionV1>(r->client(), r->version(), id), false));
@ -204,7 +204,7 @@ CColorManagementOutput::CColorManagementOutput(SP<CWpColorManagementOutputV1> re
m_resource->setOnDestroy([this](CWpColorManagementOutputV1* r) { PROTO::colorManagement->destroyResource(this); }); m_resource->setOnDestroy([this](CWpColorManagementOutputV1* r) { PROTO::colorManagement->destroyResource(this); });
m_resource->setGetImageDescription([this](CWpColorManagementOutputV1* r, uint32_t id) { m_resource->setGetImageDescription([this](CWpColorManagementOutputV1* r, uint32_t id) {
LOGM(TRACE, "Get image description for output={}, id={}", (uintptr_t)r, id); LOGM(Log::TRACE, "Get image description for output={}, id={}", (uintptr_t)r, id);
if (m_imageDescription.valid()) if (m_imageDescription.valid())
PROTO::colorManagement->destroyResource(m_imageDescription.get()); PROTO::colorManagement->destroyResource(m_imageDescription.get());
@ -247,16 +247,16 @@ CColorManagementSurface::CColorManagementSurface(SP<CWpColorManagementSurfaceV1>
m_client = m_resource->client(); m_client = m_resource->client();
m_resource->setDestroy([this](CWpColorManagementSurfaceV1* r) { m_resource->setDestroy([this](CWpColorManagementSurfaceV1* r) {
LOGM(TRACE, "Destroy wp cm surface {}", (uintptr_t)m_surface); LOGM(Log::TRACE, "Destroy wp cm surface {}", (uintptr_t)m_surface);
PROTO::colorManagement->destroyResource(this); PROTO::colorManagement->destroyResource(this);
}); });
m_resource->setOnDestroy([this](CWpColorManagementSurfaceV1* r) { m_resource->setOnDestroy([this](CWpColorManagementSurfaceV1* r) {
LOGM(TRACE, "Destroy wp cm surface {}", (uintptr_t)m_surface); LOGM(Log::TRACE, "Destroy wp cm surface {}", (uintptr_t)m_surface);
PROTO::colorManagement->destroyResource(this); PROTO::colorManagement->destroyResource(this);
}); });
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(Log::TRACE, "Set image description for surface={}, desc={}, intent={}", (uintptr_t)r, (uintptr_t)image_description, render_intent);
const auto PO = sc<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
@ -279,7 +279,7 @@ CColorManagementSurface::CColorManagementSurface(SP<CWpColorManagementSurfaceV1>
m_imageDescription = imageDescription->get()->m_settings; m_imageDescription = imageDescription->get()->m_settings;
}); });
m_resource->setUnsetImageDescription([this](CWpColorManagementSurfaceV1* r) { m_resource->setUnsetImageDescription([this](CWpColorManagementSurfaceV1* r) {
LOGM(TRACE, "Unset image description for surface={}", (uintptr_t)r); LOGM(Log::TRACE, "Unset image description for surface={}", (uintptr_t)r);
m_imageDescription = SImageDescription{}; m_imageDescription = SImageDescription{};
setHasImageDescription(false); setHasImageDescription(false);
}); });
@ -295,7 +295,7 @@ wl_client* CColorManagementSurface::client() {
const SImageDescription& CColorManagementSurface::imageDescription() { const SImageDescription& CColorManagementSurface::imageDescription() {
if (!hasImageDescription()) if (!hasImageDescription())
LOGM(WARN, "Reading imageDescription while none set. Returns default or empty values"); LOGM(Log::WARN, "Reading imageDescription while none set. Returns default or empty values");
return m_imageDescription; return m_imageDescription;
} }
@ -344,16 +344,16 @@ CColorManagementFeedbackSurface::CColorManagementFeedbackSurface(SP<CWpColorMana
m_client = m_resource->client(); m_client = m_resource->client();
m_resource->setDestroy([this](CWpColorManagementSurfaceFeedbackV1* r) { m_resource->setDestroy([this](CWpColorManagementSurfaceFeedbackV1* r) {
LOGM(TRACE, "Destroy wp cm feedback surface {}", (uintptr_t)m_surface); LOGM(Log::TRACE, "Destroy wp cm feedback surface {}", (uintptr_t)m_surface);
PROTO::colorManagement->destroyResource(this); PROTO::colorManagement->destroyResource(this);
}); });
m_resource->setOnDestroy([this](CWpColorManagementSurfaceFeedbackV1* r) { m_resource->setOnDestroy([this](CWpColorManagementSurfaceFeedbackV1* r) {
LOGM(TRACE, "Destroy wp cm feedback surface {}", (uintptr_t)m_surface); LOGM(Log::TRACE, "Destroy wp cm feedback surface {}", (uintptr_t)m_surface);
PROTO::colorManagement->destroyResource(this); PROTO::colorManagement->destroyResource(this);
}); });
m_resource->setGetPreferred([this](CWpColorManagementSurfaceFeedbackV1* r, uint32_t id) { m_resource->setGetPreferred([this](CWpColorManagementSurfaceFeedbackV1* r, uint32_t id) {
LOGM(TRACE, "Get preferred for id {}", id); LOGM(Log::TRACE, "Get preferred for id {}", id);
if (m_surface.expired()) { if (m_surface.expired()) {
r->error(WP_COLOR_MANAGEMENT_SURFACE_FEEDBACK_V1_ERROR_INERT, "Surface is inert"); r->error(WP_COLOR_MANAGEMENT_SURFACE_FEEDBACK_V1_ERROR_INERT, "Surface is inert");
@ -376,7 +376,7 @@ CColorManagementFeedbackSurface::CColorManagementFeedbackSurface(SP<CWpColorMana
}); });
m_resource->setGetPreferredParametric([this](CWpColorManagementSurfaceFeedbackV1* r, uint32_t id) { m_resource->setGetPreferredParametric([this](CWpColorManagementSurfaceFeedbackV1* r, uint32_t id) {
LOGM(TRACE, "Get preferred for id {}", id); LOGM(Log::TRACE, "Get preferred for id {}", id);
if (m_surface.expired()) { if (m_surface.expired()) {
r->error(WP_COLOR_MANAGEMENT_SURFACE_FEEDBACK_V1_ERROR_INERT, "Surface is inert"); r->error(WP_COLOR_MANAGEMENT_SURFACE_FEEDBACK_V1_ERROR_INERT, "Surface is inert");
@ -397,7 +397,7 @@ CColorManagementFeedbackSurface::CColorManagementFeedbackSurface(SP<CWpColorMana
m_currentPreferredId = RESOURCE->m_settings.updateId(); m_currentPreferredId = RESOURCE->m_settings.updateId();
if (!PROTO::colorManagement->m_debug && RESOURCE->m_settings.icc.fd >= 0) { if (!PROTO::colorManagement->m_debug && RESOURCE->m_settings.icc.fd >= 0) {
LOGM(ERR, "FIXME: parse icc profile"); LOGM(Log::ERR, "FIXME: parse icc profile");
r->error(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "ICC profiles are not supported"); r->error(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "ICC profiles are not supported");
return; return;
} }
@ -434,7 +434,7 @@ CColorManagementIccCreator::CColorManagementIccCreator(SP<CWpImageDescriptionCre
m_resource->setOnDestroy([this](CWpImageDescriptionCreatorIccV1* r) { PROTO::colorManagement->destroyResource(this); }); m_resource->setOnDestroy([this](CWpImageDescriptionCreatorIccV1* r) { PROTO::colorManagement->destroyResource(this); });
m_resource->setCreate([this](CWpImageDescriptionCreatorIccV1* r, uint32_t id) { m_resource->setCreate([this](CWpImageDescriptionCreatorIccV1* r, uint32_t id) {
LOGM(TRACE, "Create image description from icc for id {}", id); LOGM(Log::TRACE, "Create image description from icc for id {}", id);
// FIXME actually check completeness // FIXME actually check completeness
if (m_settings.icc.fd < 0 || !m_settings.icc.length) { if (m_settings.icc.fd < 0 || !m_settings.icc.length) {
@ -451,7 +451,7 @@ CColorManagementIccCreator::CColorManagementIccCreator(SP<CWpImageDescriptionCre
return; return;
} }
LOGM(ERR, "FIXME: Parse icc file {}({},{}) for id {}", m_settings.icc.fd, m_settings.icc.offset, m_settings.icc.length, id); LOGM(Log::ERR, "FIXME: Parse icc file {}({},{}) for id {}", m_settings.icc.fd, m_settings.icc.offset, m_settings.icc.length, id);
// FIXME actually check support // FIXME actually check support
if (m_settings.icc.fd < 0 || !m_settings.icc.length) { if (m_settings.icc.fd < 0 || !m_settings.icc.length) {
@ -490,7 +490,7 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
m_resource->setOnDestroy([this](CWpImageDescriptionCreatorParamsV1* r) { PROTO::colorManagement->destroyResource(this); }); m_resource->setOnDestroy([this](CWpImageDescriptionCreatorParamsV1* r) { PROTO::colorManagement->destroyResource(this); });
m_resource->setCreate([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t id) { m_resource->setCreate([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t id) {
LOGM(TRACE, "Create image description from params for id {}", id); LOGM(Log::TRACE, "Create image description from params for id {}", id);
// FIXME actually check completeness // FIXME actually check completeness
if (!m_valuesSet) { if (!m_valuesSet) {
@ -520,7 +520,7 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
PROTO::colorManagement->destroyResource(this); PROTO::colorManagement->destroyResource(this);
}); });
m_resource->setSetTfNamed([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t tf) { m_resource->setSetTfNamed([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t tf) {
LOGM(TRACE, "Set image description transfer function to {}", tf); LOGM(Log::TRACE, "Set image description transfer function to {}", tf);
if (m_valuesSet & PC_TF) { if (m_valuesSet & PC_TF) {
r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Transfer function already set"); r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Transfer function already set");
return; return;
@ -547,7 +547,7 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
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) {
LOGM(TRACE, "Set image description tf power to {}", eexp); LOGM(Log::TRACE, "Set image description tf power to {}", eexp);
if (m_valuesSet & PC_TF_POWER) { if (m_valuesSet & PC_TF_POWER) {
r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Transfer function power already set"); r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Transfer function power already set");
return; return;
@ -564,7 +564,7 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
m_valuesSet |= PC_TF_POWER; m_valuesSet |= PC_TF_POWER;
}); });
m_resource->setSetPrimariesNamed([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t primaries) { m_resource->setSetPrimariesNamed([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t primaries) {
LOGM(TRACE, "Set image description primaries by name {}", primaries); LOGM(Log::TRACE, "Set image description primaries by name {}", primaries);
if (m_valuesSet & PC_PRIMARIES) { if (m_valuesSet & PC_PRIMARIES) {
r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Primaries already set"); r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Primaries already set");
return; return;
@ -594,7 +594,7 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
}); });
m_resource->setSetPrimaries( m_resource->setSetPrimaries(
[this](CWpImageDescriptionCreatorParamsV1* r, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y) { [this](CWpImageDescriptionCreatorParamsV1* r, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y) {
LOGM(TRACE, "Set image description primaries by values r:{},{} g:{},{} b:{},{} w:{},{}", r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y); LOGM(Log::TRACE, "Set image description primaries by values r:{},{} g:{},{} b:{},{} w:{},{}", r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y);
if (m_valuesSet & PC_PRIMARIES) { if (m_valuesSet & PC_PRIMARIES) {
r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Primaries already set"); r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Primaries already set");
return; return;
@ -608,7 +608,7 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
}); });
m_resource->setSetLuminances([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t min_lum, uint32_t max_lum, uint32_t reference_lum) { m_resource->setSetLuminances([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t min_lum, uint32_t max_lum, uint32_t reference_lum) {
auto min = min_lum / 10000.0f; auto min = min_lum / 10000.0f;
LOGM(TRACE, "Set image description luminances to {} - {} ({})", min, max_lum, reference_lum); LOGM(Log::TRACE, "Set image description luminances to {} - {} ({})", min, max_lum, reference_lum);
if (m_valuesSet & PC_LUMINANCES) { if (m_valuesSet & PC_LUMINANCES) {
r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Luminances already set"); r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Luminances already set");
return; return;
@ -622,7 +622,7 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
}); });
m_resource->setSetMasteringDisplayPrimaries( m_resource->setSetMasteringDisplayPrimaries(
[this](CWpImageDescriptionCreatorParamsV1* r, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y) { [this](CWpImageDescriptionCreatorParamsV1* r, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y) {
LOGM(TRACE, "Set image description mastering primaries by values r:{},{} g:{},{} b:{},{} w:{},{}", r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y); LOGM(Log::TRACE, "Set image description mastering primaries by values r:{},{} g:{},{} b:{},{} w:{},{}", r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y);
if (m_valuesSet & PC_MASTERING_PRIMARIES) { if (m_valuesSet & PC_MASTERING_PRIMARIES) {
r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Mastering primaries already set"); r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Mastering primaries already set");
return; return;
@ -644,7 +644,7 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
}); });
m_resource->setSetMasteringLuminance([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t min_lum, uint32_t max_lum) { m_resource->setSetMasteringLuminance([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t min_lum, uint32_t max_lum) {
auto min = min_lum / 10000.0f; auto min = min_lum / 10000.0f;
LOGM(TRACE, "Set image description mastering luminances to {} - {}", min, max_lum); LOGM(Log::TRACE, "Set image description mastering luminances to {} - {}", min, max_lum);
// if (valuesSet & PC_MASTERING_LUMINANCES) { // if (valuesSet & PC_MASTERING_LUMINANCES) {
// r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Mastering luminances already set"); // r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Mastering luminances already set");
// return; // return;
@ -661,7 +661,7 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
m_valuesSet |= PC_MASTERING_LUMINANCES; m_valuesSet |= PC_MASTERING_LUMINANCES;
}); });
m_resource->setSetMaxCll([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t max_cll) { m_resource->setSetMaxCll([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t max_cll) {
LOGM(TRACE, "Set image description max content light level to {}", max_cll); LOGM(Log::TRACE, "Set image description max content light level to {}", max_cll);
// if (valuesSet & PC_CLL) { // if (valuesSet & PC_CLL) {
// r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Max CLL already set"); // r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Max CLL already set");
// return; // return;
@ -670,7 +670,7 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
m_valuesSet |= PC_CLL; m_valuesSet |= PC_CLL;
}); });
m_resource->setSetMaxFall([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t max_fall) { m_resource->setSetMaxFall([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t max_fall) {
LOGM(TRACE, "Set image description max frame-average light level to {}", max_fall); LOGM(Log::TRACE, "Set image description max frame-average light level to {}", max_fall);
// if (valuesSet & PC_FALL) { // if (valuesSet & PC_FALL) {
// r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Max FALL already set"); // r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Max FALL already set");
// return; // return;
@ -699,7 +699,7 @@ CColorManagementImageDescription::CColorManagementImageDescription(SP<CWpImageDe
m_resource->setOnDestroy([this](CWpImageDescriptionV1* r) { PROTO::colorManagement->destroyResource(this); }); m_resource->setOnDestroy([this](CWpImageDescriptionV1* r) { PROTO::colorManagement->destroyResource(this); });
m_resource->setGetInformation([this](CWpImageDescriptionV1* r, uint32_t id) { m_resource->setGetInformation([this](CWpImageDescriptionV1* r, uint32_t id) {
LOGM(TRACE, "Get image information for image={}, id={}", (uintptr_t)r, id); LOGM(Log::TRACE, "Get image information for image={}, id={}", (uintptr_t)r, id);
if (!m_allowGetInformation) { if (!m_allowGetInformation) {
r->error(WP_IMAGE_DESCRIPTION_V1_ERROR_NO_INFORMATION, "Image descriptions doesn't allow get_information request"); r->error(WP_IMAGE_DESCRIPTION_V1_ERROR_NO_INFORMATION, "Image descriptions doesn't allow get_information request");
return; return;
@ -782,7 +782,7 @@ void CColorManagementProtocol::bindManager(wl_client* client, void* data, uint32
return; return;
} }
LOGM(TRACE, "New WP_color_manager at {:x}", (uintptr_t)RESOURCE.get()); LOGM(Log::TRACE, "New WP_color_manager at {:x}", (uintptr_t)RESOURCE.get());
} }
void CColorManagementProtocol::onImagePreferredChanged(uint32_t preferredId) { void CColorManagementProtocol::onImagePreferredChanged(uint32_t preferredId) {

View file

@ -10,11 +10,11 @@ CContentTypeManager::CContentTypeManager(SP<CWpContentTypeManagerV1> resource) :
m_resource->setOnDestroy([this](CWpContentTypeManagerV1* r) { PROTO::contentType->destroyResource(this); }); m_resource->setOnDestroy([this](CWpContentTypeManagerV1* r) { PROTO::contentType->destroyResource(this); });
m_resource->setGetSurfaceContentType([](CWpContentTypeManagerV1* r, uint32_t id, wl_resource* surface) { m_resource->setGetSurfaceContentType([](CWpContentTypeManagerV1* r, uint32_t id, wl_resource* surface) {
LOGM(TRACE, "Get surface for id={}, surface={}", id, (uintptr_t)surface); LOGM(Log::TRACE, "Get surface for id={}, surface={}", id, (uintptr_t)surface);
auto SURF = CWLSurfaceResource::fromResource(surface); auto SURF = CWLSurfaceResource::fromResource(surface);
if (!SURF) { if (!SURF) {
LOGM(ERR, "No surface for resource {}", (uintptr_t)surface); LOGM(Log::ERR, "No surface for resource {}", (uintptr_t)surface);
r->error(-1, "Invalid surface (2)"); r->error(-1, "Invalid surface (2)");
return; return;
} }

View file

@ -27,7 +27,7 @@ CDRMLeaseResource::CDRMLeaseResource(SP<CWpDrmLeaseV1> resource_, SP<CDRMLeaseRe
for (auto const& m : m_requested) { for (auto const& m : m_requested) {
if (!m->m_monitor || m->m_monitor->m_isBeingLeased) { if (!m->m_monitor || m->m_monitor->m_isBeingLeased) {
LOGM(ERR, "Rejecting lease: no monitor or monitor is being leased for {}", (m->m_monitor ? m->m_monitor->m_name : "null")); LOGM(Log::ERR, "Rejecting lease: no monitor or monitor is being leased for {}", (m->m_monitor ? m->m_monitor->m_name : "null"));
m_resource->sendFinished(); m_resource->sendFinished();
return; return;
} }
@ -35,7 +35,7 @@ CDRMLeaseResource::CDRMLeaseResource(SP<CWpDrmLeaseV1> resource_, SP<CDRMLeaseRe
// grant the lease if it is seemingly valid // grant the lease if it is seemingly valid
LOGM(LOG, "Leasing outputs: {}", [this]() { LOGM(Log::DEBUG, "Leasing outputs: {}", [this]() {
std::string roll; std::string roll;
for (auto const& o : m_requested) { for (auto const& o : m_requested) {
roll += std::format("{} ", o->m_monitor->m_name); roll += std::format("{} ", o->m_monitor->m_name);
@ -53,7 +53,7 @@ CDRMLeaseResource::CDRMLeaseResource(SP<CWpDrmLeaseV1> resource_, SP<CDRMLeaseRe
auto aqlease = Aquamarine::CDRMLease::create(outputs); auto aqlease = Aquamarine::CDRMLease::create(outputs);
if (!aqlease) { if (!aqlease) {
LOGM(ERR, "Rejecting lease: backend failed to alloc a lease"); LOGM(Log::ERR, "Rejecting lease: backend failed to alloc a lease");
m_resource->sendFinished(); m_resource->sendFinished();
return; return;
} }
@ -71,10 +71,10 @@ CDRMLeaseResource::CDRMLeaseResource(SP<CWpDrmLeaseV1> resource_, SP<CDRMLeaseRe
} }
m_resource->sendFinished(); m_resource->sendFinished();
LOGM(LOG, "Revoking lease for fd {}", m_lease->leaseFD); LOGM(Log::DEBUG, "Revoking lease for fd {}", m_lease->leaseFD);
}); });
LOGM(LOG, "Granting lease, sending fd {}", m_lease->leaseFD); LOGM(Log::DEBUG, "Granting lease, sending fd {}", m_lease->leaseFD);
m_resource->sendLeaseFd(m_lease->leaseFD); m_resource->sendLeaseFd(m_lease->leaseFD);
@ -211,18 +211,18 @@ CDRMLeaseDeviceResource::CDRMLeaseDeviceResource(std::string deviceName_, SP<CWp
PROTO::lease.at(m_deviceName)->m_requests.emplace_back(RESOURCE); PROTO::lease.at(m_deviceName)->m_requests.emplace_back(RESOURCE);
LOGM(LOG, "New lease request {}", id); LOGM(Log::DEBUG, "New lease request {}", id);
RESOURCE->m_parent = m_self; RESOURCE->m_parent = m_self;
}); });
CFileDescriptor fd{PROTO::lease.at(m_deviceName)->m_backend.get()->getNonMasterFD()}; CFileDescriptor fd{PROTO::lease.at(m_deviceName)->m_backend.get()->getNonMasterFD()};
if (!fd.isValid()) { if (!fd.isValid()) {
LOGM(ERR, "Failed to dup fd in lease"); LOGM(Log::ERR, "Failed to dup fd in lease");
return; return;
} }
LOGM(LOG, "Sending DRMFD {} to new lease device", fd.get()); LOGM(Log::DEBUG, "Sending DRMFD {} to new lease device", fd.get());
m_resource->sendDrmFd(fd.get()); m_resource->sendDrmFd(fd.get());
for (auto const& m : PROTO::lease.at(m_deviceName)->m_offeredOutputs) { for (auto const& m : PROTO::lease.at(m_deviceName)->m_offeredOutputs) {
@ -250,7 +250,7 @@ void CDRMLeaseDeviceResource::sendConnector(PHLMONITOR monitor) {
RESOURCE->m_parent = m_self; RESOURCE->m_parent = m_self;
RESOURCE->m_self = RESOURCE; RESOURCE->m_self = RESOURCE;
LOGM(LOG, "Sending new connector {}", monitor->m_name); LOGM(Log::DEBUG, "Sending new connector {}", monitor->m_name);
m_connectorsSent.emplace_back(RESOURCE); m_connectorsSent.emplace_back(RESOURCE);
PROTO::lease.at(m_deviceName)->m_connectors.emplace_back(RESOURCE); PROTO::lease.at(m_deviceName)->m_connectors.emplace_back(RESOURCE);
@ -271,7 +271,7 @@ CDRMLeaseProtocol::CDRMLeaseProtocol(const wl_interface* iface, const int& ver,
CFileDescriptor fd{m_backend->getNonMasterFD()}; CFileDescriptor fd{m_backend->getNonMasterFD()};
if (!fd.isValid()) { if (!fd.isValid()) {
LOGM(ERR, "Failed to dup fd for drm node {}", m_deviceName); LOGM(Log::ERR, "Failed to dup fd for drm node {}", m_deviceName);
return; return;
} }
@ -318,7 +318,7 @@ void CDRMLeaseProtocol::offer(PHLMONITOR monitor) {
return; return;
if (monitor->m_output->getBackend() != m_backend) { if (monitor->m_output->getBackend() != m_backend) {
LOGM(ERR, "Monitor {} cannot be leased: lease is for a different device", monitor->m_name); LOGM(Log::ERR, "Monitor {} cannot be leased: lease is for a different device", monitor->m_name);
return; return;
} }

View file

@ -21,7 +21,7 @@ WP<CSyncTimeline> CDRMSyncPointState::timeline() {
UP<CSyncReleaser> CDRMSyncPointState::createSyncRelease() { UP<CSyncReleaser> CDRMSyncPointState::createSyncRelease() {
if (m_releaseTaken) if (m_releaseTaken)
Debug::log(ERR, "CDRMSyncPointState: creating a sync releaser on an already created SyncRelease"); Log::logger->log(Log::ERR, "CDRMSyncPointState: creating a sync releaser on an already created SyncRelease");
m_releaseTaken = true; m_releaseTaken = true;
return makeUnique<CSyncReleaser>(m_timeline, m_point); return makeUnique<CSyncReleaser>(m_timeline, m_point);
@ -180,7 +180,7 @@ CDRMSyncobjManagerResource::CDRMSyncobjManagerResource(UP<CWpLinuxDrmSyncobjMana
SURF->m_syncobj = RESOURCE; SURF->m_syncobj = RESOURCE;
LOGM(LOG, "New linux_syncobj at {:x} for surface {:x}", (uintptr_t)RESOURCE.get(), (uintptr_t)SURF.get()); LOGM(Log::DEBUG, "New linux_syncobj at {:x} for surface {:x}", (uintptr_t)RESOURCE.get(), (uintptr_t)SURF.get());
}); });
m_resource->setImportTimeline([this](CWpLinuxDrmSyncobjManagerV1* r, uint32_t id, int32_t fd) { m_resource->setImportTimeline([this](CWpLinuxDrmSyncobjManagerV1* r, uint32_t id, int32_t fd) {
@ -192,7 +192,7 @@ CDRMSyncobjManagerResource::CDRMSyncobjManagerResource(UP<CWpLinuxDrmSyncobjMana
return; return;
} }
LOGM(LOG, "New linux_drm_timeline at {:x}", (uintptr_t)RESOURCE.get()); LOGM(Log::DEBUG, "New linux_drm_timeline at {:x}", (uintptr_t)RESOURCE.get());
}); });
} }
@ -206,11 +206,11 @@ CDRMSyncobjProtocol::CDRMSyncobjProtocol(const wl_interface* iface, const int& v
else if (g_pCompositor->m_drm.syncobjSupport) else if (g_pCompositor->m_drm.syncobjSupport)
m_drmFD = g_pCompositor->m_drm.fd; m_drmFD = g_pCompositor->m_drm.fd;
else { else {
LOGM(ERR, "CDRMSyncobjProtocol: no nodes support explicit sync?"); LOGM(Log::ERR, "CDRMSyncobjProtocol: no nodes support explicit sync?");
return; return;
} }
LOGM(LOG, "CDRMSyncobjProtocol: using fd {}", m_drmFD); LOGM(Log::DEBUG, "CDRMSyncobjProtocol: using fd {}", m_drmFD);
} }
void CDRMSyncobjProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { void CDRMSyncobjProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {

View file

@ -14,16 +14,16 @@ CWLRDataOffer::CWLRDataOffer(SP<CZwlrDataControlOfferV1> resource_, SP<IDataSour
m_resource->setReceive([this](CZwlrDataControlOfferV1* r, const char* mime, int32_t fd) { m_resource->setReceive([this](CZwlrDataControlOfferV1* r, const char* mime, int32_t fd) {
CFileDescriptor sendFd{fd}; CFileDescriptor sendFd{fd};
if (!m_source) { if (!m_source) {
LOGM(WARN, "Possible bug: Receive on an offer w/o a source"); LOGM(Log::WARN, "Possible bug: Receive on an offer w/o a source");
return; return;
} }
if (m_dead) { if (m_dead) {
LOGM(WARN, "Possible bug: Receive on an offer that's dead"); LOGM(Log::WARN, "Possible bug: Receive on an offer that's dead");
return; return;
} }
LOGM(LOG, "Offer {:x} asks to send data from source {:x}", (uintptr_t)this, (uintptr_t)m_source.get()); LOGM(Log::DEBUG, "Offer {:x} asks to send data from source {:x}", (uintptr_t)this, (uintptr_t)m_source.get());
m_source->send(mime, std::move(sendFd)); m_source->send(mime, std::move(sendFd));
}); });
@ -79,7 +79,7 @@ std::vector<std::string> CWLRDataSource::mimes() {
void CWLRDataSource::send(const std::string& mime, CFileDescriptor fd) { void CWLRDataSource::send(const std::string& mime, CFileDescriptor fd) {
if (std::ranges::find(m_mimeTypes, mime) == m_mimeTypes.end()) { if (std::ranges::find(m_mimeTypes, mime) == m_mimeTypes.end()) {
LOGM(ERR, "Compositor/App bug: CWLRDataSource::sendAskSend with non-existent mime"); LOGM(Log::ERR, "Compositor/App bug: CWLRDataSource::sendAskSend with non-existent mime");
return; return;
} }
@ -88,7 +88,7 @@ void CWLRDataSource::send(const std::string& mime, CFileDescriptor fd) {
void CWLRDataSource::accepted(const std::string& mime) { void CWLRDataSource::accepted(const std::string& mime) {
if (std::ranges::find(m_mimeTypes, mime) == m_mimeTypes.end()) if (std::ranges::find(m_mimeTypes, mime) == m_mimeTypes.end())
LOGM(ERR, "Compositor/App bug: CWLRDataSource::sendAccepted with non-existent mime"); LOGM(Log::ERR, "Compositor/App bug: CWLRDataSource::sendAccepted with non-existent mime");
// wlr has no accepted // wlr has no accepted
} }
@ -113,34 +113,34 @@ CWLRDataDevice::CWLRDataDevice(SP<CZwlrDataControlDeviceV1> resource_) : m_resou
m_resource->setSetSelection([](CZwlrDataControlDeviceV1* r, wl_resource* sourceR) { m_resource->setSetSelection([](CZwlrDataControlDeviceV1* r, wl_resource* sourceR) {
auto source = sourceR ? CWLRDataSource::fromResource(sourceR) : CSharedPointer<CWLRDataSource>{}; auto source = sourceR ? CWLRDataSource::fromResource(sourceR) : CSharedPointer<CWLRDataSource>{};
if (!source) { if (!source) {
LOGM(LOG, "wlr reset selection received"); LOGM(Log::DEBUG, "wlr reset selection received");
g_pSeatManager->setCurrentSelection(nullptr); g_pSeatManager->setCurrentSelection(nullptr);
return; return;
} }
if (source && source->used()) if (source && source->used())
LOGM(WARN, "setSelection on a used resource. By protocol, this is a violation, but firefox et al insist on doing this."); LOGM(Log::WARN, "setSelection on a used resource. By protocol, this is a violation, but firefox et al insist on doing this.");
source->markUsed(); source->markUsed();
LOGM(LOG, "wlr manager requests selection to {:x}", (uintptr_t)source.get()); LOGM(Log::DEBUG, "wlr manager requests selection to {:x}", (uintptr_t)source.get());
g_pSeatManager->setCurrentSelection(source); g_pSeatManager->setCurrentSelection(source);
}); });
m_resource->setSetPrimarySelection([](CZwlrDataControlDeviceV1* r, wl_resource* sourceR) { m_resource->setSetPrimarySelection([](CZwlrDataControlDeviceV1* r, wl_resource* sourceR) {
auto source = sourceR ? CWLRDataSource::fromResource(sourceR) : CSharedPointer<CWLRDataSource>{}; auto source = sourceR ? CWLRDataSource::fromResource(sourceR) : CSharedPointer<CWLRDataSource>{};
if (!source) { if (!source) {
LOGM(LOG, "wlr reset primary selection received"); LOGM(Log::DEBUG, "wlr reset primary selection received");
g_pSeatManager->setCurrentPrimarySelection(nullptr); g_pSeatManager->setCurrentPrimarySelection(nullptr);
return; return;
} }
if (source && source->used()) if (source && source->used())
LOGM(WARN, "setSelection on a used resource. By protocol, this is a violation, but firefox et al insist on doing this."); LOGM(Log::WARN, "setSelection on a used resource. By protocol, this is a violation, but firefox et al insist on doing this.");
source->markUsed(); source->markUsed();
LOGM(LOG, "wlr manager requests primary selection to {:x}", (uintptr_t)source.get()); LOGM(Log::DEBUG, "wlr manager requests primary selection to {:x}", (uintptr_t)source.get());
g_pSeatManager->setCurrentPrimarySelection(source); g_pSeatManager->setCurrentPrimarySelection(source);
}); });
} }
@ -197,7 +197,7 @@ CWLRDataControlManagerResource::CWLRDataControlManagerResource(SP<CZwlrDataContr
RESOURCE->sendInitialSelections(); RESOURCE->sendInitialSelections();
LOGM(LOG, "New wlr data device bound at {:x}", (uintptr_t)RESOURCE.get()); LOGM(Log::DEBUG, "New wlr data device bound at {:x}", (uintptr_t)RESOURCE.get());
}); });
m_resource->setCreateDataSource([this](CZwlrDataControlManagerV1* r, uint32_t id) { m_resource->setCreateDataSource([this](CZwlrDataControlManagerV1* r, uint32_t id) {
@ -213,13 +213,13 @@ CWLRDataControlManagerResource::CWLRDataControlManagerResource(SP<CZwlrDataContr
} }
if (!m_device) if (!m_device)
LOGM(WARN, "New data source before a device was created"); LOGM(Log::WARN, "New data source before a device was created");
RESOURCE->m_self = RESOURCE; RESOURCE->m_self = RESOURCE;
m_sources.emplace_back(RESOURCE); m_sources.emplace_back(RESOURCE);
LOGM(LOG, "New wlr data source bound at {:x}", (uintptr_t)RESOURCE.get()); LOGM(Log::DEBUG, "New wlr data source bound at {:x}", (uintptr_t)RESOURCE.get());
}); });
} }
@ -240,7 +240,7 @@ void CDataDeviceWLRProtocol::bindManager(wl_client* client, void* data, uint32_t
return; return;
} }
LOGM(LOG, "New wlr_data_control_manager at {:x}", (uintptr_t)RESOURCE.get()); LOGM(Log::DEBUG, "New wlr_data_control_manager at {:x}", (uintptr_t)RESOURCE.get());
} }
void CDataDeviceWLRProtocol::destroyResource(CWLRDataControlManagerResource* resource) { void CDataDeviceWLRProtocol::destroyResource(CWLRDataControlManagerResource* resource) {
@ -278,7 +278,7 @@ void CDataDeviceWLRProtocol::sendSelectionToDevice(SP<CWLRDataDevice> dev, SP<ID
OFFER->m_primary = primary; OFFER->m_primary = primary;
LOGM(LOG, "New {}offer {:x} for data source {:x}", primary ? "primary " : " ", (uintptr_t)OFFER.get(), (uintptr_t)sel.get()); LOGM(Log::DEBUG, "New {}offer {:x} for data source {:x}", primary ? "primary " : " ", (uintptr_t)OFFER.get(), (uintptr_t)sel.get());
dev->sendDataOffer(OFFER); dev->sendDataOffer(OFFER);
OFFER->sendData(); OFFER->sendData();
@ -298,7 +298,7 @@ void CDataDeviceWLRProtocol::setSelection(SP<IDataSource> source, bool primary)
} }
if (!source) { if (!source) {
LOGM(LOG, "resetting {}selection", primary ? "primary " : " "); LOGM(Log::DEBUG, "resetting {}selection", primary ? "primary " : " ");
for (auto const& d : m_devices) { for (auto const& d : m_devices) {
sendSelectionToDevice(d, nullptr, primary); sendSelectionToDevice(d, nullptr, primary);
@ -307,7 +307,7 @@ void CDataDeviceWLRProtocol::setSelection(SP<IDataSource> source, bool primary)
return; return;
} }
LOGM(LOG, "New {}selection for data source {:x}", primary ? "primary" : "", (uintptr_t)source.get()); LOGM(Log::DEBUG, "New {}selection for data source {:x}", primary ? "primary" : "", (uintptr_t)source.get());
for (auto const& d : m_devices) { for (auto const& d : m_devices) {
sendSelectionToDevice(d, source, primary); sendSelectionToDevice(d, source, primary);

View file

@ -14,16 +14,16 @@ CExtDataOffer::CExtDataOffer(SP<CExtDataControlOfferV1> resource_, SP<IDataSourc
m_resource->setReceive([this](CExtDataControlOfferV1* r, const char* mime, int32_t fd) { m_resource->setReceive([this](CExtDataControlOfferV1* r, const char* mime, int32_t fd) {
CFileDescriptor sendFd{fd}; CFileDescriptor sendFd{fd};
if (!m_source) { if (!m_source) {
LOGM(WARN, "Possible bug: Receive on an offer w/o a source"); LOGM(Log::WARN, "Possible bug: Receive on an offer w/o a source");
return; return;
} }
if (m_dead) { if (m_dead) {
LOGM(WARN, "Possible bug: Receive on an offer that's dead"); LOGM(Log::WARN, "Possible bug: Receive on an offer that's dead");
return; return;
} }
LOGM(LOG, "Offer {:x} asks to send data from source {:x}", (uintptr_t)this, (uintptr_t)m_source.get()); LOGM(Log::DEBUG, "Offer {:x} asks to send data from source {:x}", (uintptr_t)this, (uintptr_t)m_source.get());
m_source->send(mime, std::move(sendFd)); m_source->send(mime, std::move(sendFd));
}); });
@ -79,7 +79,7 @@ std::vector<std::string> CExtDataSource::mimes() {
void CExtDataSource::send(const std::string& mime, CFileDescriptor fd) { void CExtDataSource::send(const std::string& mime, CFileDescriptor fd) {
if (std::ranges::find(m_mimeTypes, mime) == m_mimeTypes.end()) { if (std::ranges::find(m_mimeTypes, mime) == m_mimeTypes.end()) {
LOGM(ERR, "Compositor/App bug: CExtDataSource::sendAskSend with non-existent mime"); LOGM(Log::ERR, "Compositor/App bug: CExtDataSource::sendAskSend with non-existent mime");
return; return;
} }
@ -88,7 +88,7 @@ void CExtDataSource::send(const std::string& mime, CFileDescriptor fd) {
void CExtDataSource::accepted(const std::string& mime) { void CExtDataSource::accepted(const std::string& mime) {
if (std::ranges::find(m_mimeTypes, mime) == m_mimeTypes.end()) if (std::ranges::find(m_mimeTypes, mime) == m_mimeTypes.end())
LOGM(ERR, "Compositor/App bug: CExtDataSource::sendAccepted with non-existent mime"); LOGM(Log::ERR, "Compositor/App bug: CExtDataSource::sendAccepted with non-existent mime");
// ext has no accepted // ext has no accepted
} }
@ -113,34 +113,34 @@ CExtDataDevice::CExtDataDevice(SP<CExtDataControlDeviceV1> resource_) : m_resour
m_resource->setSetSelection([](CExtDataControlDeviceV1* r, wl_resource* sourceR) { m_resource->setSetSelection([](CExtDataControlDeviceV1* r, wl_resource* sourceR) {
auto source = sourceR ? CExtDataSource::fromResource(sourceR) : CSharedPointer<CExtDataSource>{}; auto source = sourceR ? CExtDataSource::fromResource(sourceR) : CSharedPointer<CExtDataSource>{};
if (!source) { if (!source) {
LOGM(LOG, "ext reset selection received"); LOGM(Log::DEBUG, "ext reset selection received");
g_pSeatManager->setCurrentSelection(nullptr); g_pSeatManager->setCurrentSelection(nullptr);
return; return;
} }
if (source && source->used()) if (source && source->used())
LOGM(WARN, "setSelection on a used resource. By protocol, this is a violation, but firefox et al insist on doing this."); LOGM(Log::WARN, "setSelection on a used resource. By protocol, this is a violation, but firefox et al insist on doing this.");
source->markUsed(); source->markUsed();
LOGM(LOG, "ext manager requests selection to {:x}", (uintptr_t)source.get()); LOGM(Log::DEBUG, "ext manager requests selection to {:x}", (uintptr_t)source.get());
g_pSeatManager->setCurrentSelection(source); g_pSeatManager->setCurrentSelection(source);
}); });
m_resource->setSetPrimarySelection([](CExtDataControlDeviceV1* r, wl_resource* sourceR) { m_resource->setSetPrimarySelection([](CExtDataControlDeviceV1* r, wl_resource* sourceR) {
auto source = sourceR ? CExtDataSource::fromResource(sourceR) : CSharedPointer<CExtDataSource>{}; auto source = sourceR ? CExtDataSource::fromResource(sourceR) : CSharedPointer<CExtDataSource>{};
if (!source) { if (!source) {
LOGM(LOG, "ext reset primary selection received"); LOGM(Log::DEBUG, "ext reset primary selection received");
g_pSeatManager->setCurrentPrimarySelection(nullptr); g_pSeatManager->setCurrentPrimarySelection(nullptr);
return; return;
} }
if (source && source->used()) if (source && source->used())
LOGM(WARN, "setSelection on a used resource. By protocol, this is a violation, but firefox et al insist on doing this."); LOGM(Log::WARN, "setSelection on a used resource. By protocol, this is a violation, but firefox et al insist on doing this.");
source->markUsed(); source->markUsed();
LOGM(LOG, "ext manager requests primary selection to {:x}", (uintptr_t)source.get()); LOGM(Log::DEBUG, "ext manager requests primary selection to {:x}", (uintptr_t)source.get());
g_pSeatManager->setCurrentPrimarySelection(source); g_pSeatManager->setCurrentPrimarySelection(source);
}); });
} }
@ -197,7 +197,7 @@ CExtDataControlManagerResource::CExtDataControlManagerResource(SP<CExtDataContro
RESOURCE->sendInitialSelections(); RESOURCE->sendInitialSelections();
LOGM(LOG, "New ext data device bound at {:x}", (uintptr_t)RESOURCE.get()); LOGM(Log::DEBUG, "New ext data device bound at {:x}", (uintptr_t)RESOURCE.get());
}); });
m_resource->setCreateDataSource([this](CExtDataControlManagerV1* r, uint32_t id) { m_resource->setCreateDataSource([this](CExtDataControlManagerV1* r, uint32_t id) {
@ -213,13 +213,13 @@ CExtDataControlManagerResource::CExtDataControlManagerResource(SP<CExtDataContro
} }
if (!m_device) if (!m_device)
LOGM(WARN, "New data source before a device was created"); LOGM(Log::WARN, "New data source before a device was created");
RESOURCE->m_self = RESOURCE; RESOURCE->m_self = RESOURCE;
m_sources.emplace_back(RESOURCE); m_sources.emplace_back(RESOURCE);
LOGM(LOG, "New ext data source bound at {:x}", (uintptr_t)RESOURCE.get()); LOGM(Log::DEBUG, "New ext data source bound at {:x}", (uintptr_t)RESOURCE.get());
}); });
} }
@ -240,7 +240,7 @@ void CExtDataDeviceProtocol::bindManager(wl_client* client, void* data, uint32_t
return; return;
} }
LOGM(LOG, "New ext_data_control_manager at {:x}", (uintptr_t)RESOURCE.get()); LOGM(Log::DEBUG, "New ext_data_control_manager at {:x}", (uintptr_t)RESOURCE.get());
} }
void CExtDataDeviceProtocol::destroyResource(CExtDataControlManagerResource* resource) { void CExtDataDeviceProtocol::destroyResource(CExtDataControlManagerResource* resource) {
@ -278,7 +278,7 @@ void CExtDataDeviceProtocol::sendSelectionToDevice(SP<CExtDataDevice> dev, SP<ID
OFFER->m_primary = primary; OFFER->m_primary = primary;
LOGM(LOG, "New {}offer {:x} for data source {:x}", primary ? "primary " : " ", (uintptr_t)OFFER.get(), (uintptr_t)sel.get()); LOGM(Log::DEBUG, "New {}offer {:x} for data source {:x}", primary ? "primary " : " ", (uintptr_t)OFFER.get(), (uintptr_t)sel.get());
dev->sendDataOffer(OFFER); dev->sendDataOffer(OFFER);
OFFER->sendData(); OFFER->sendData();
@ -298,7 +298,7 @@ void CExtDataDeviceProtocol::setSelection(SP<IDataSource> source, bool primary)
} }
if (!source) { if (!source) {
LOGM(LOG, "resetting {}selection", primary ? "primary " : " "); LOGM(Log::DEBUG, "resetting {}selection", primary ? "primary " : " ");
for (auto const& d : m_devices) { for (auto const& d : m_devices) {
sendSelectionToDevice(d, nullptr, primary); sendSelectionToDevice(d, nullptr, primary);
@ -307,7 +307,7 @@ void CExtDataDeviceProtocol::setSelection(SP<IDataSource> source, bool primary)
return; return;
} }
LOGM(LOG, "New {}selection for data source {:x}", primary ? "primary" : "", (uintptr_t)source.get()); LOGM(Log::DEBUG, "New {}selection for data source {:x}", primary ? "primary" : "", (uintptr_t)source.get());
for (auto const& d : m_devices) { for (auto const& d : m_devices) {
sendSelectionToDevice(d, source, primary); sendSelectionToDevice(d, source, primary);

View file

@ -273,7 +273,7 @@ void CExtWorkspaceManagerResource::onMonitorCreated(const PHLMONITOR& monitor) {
group->sendToWorkspaces(); group->sendToWorkspaces();
if UNLIKELY (!group->good()) { if UNLIKELY (!group->good()) {
LOGM(ERR, "Couldn't create a workspace group object"); LOGM(Log::ERR, "Couldn't create a workspace group object");
wl_client_post_no_memory(m_resource->client()); wl_client_post_no_memory(m_resource->client());
return; return;
} }
@ -287,7 +287,7 @@ void CExtWorkspaceManagerResource::onWorkspaceCreated(const PHLWORKSPACE& worksp
ws->m_self = ws; ws->m_self = ws;
if UNLIKELY (!ws->good()) { if UNLIKELY (!ws->good()) {
LOGM(ERR, "Couldn't create a workspace object"); LOGM(Log::ERR, "Couldn't create a workspace object");
wl_client_post_no_memory(m_resource->client()); wl_client_post_no_memory(m_resource->client());
return; return;
} }
@ -316,7 +316,7 @@ void CExtWorkspaceProtocol::bindManager(wl_client* client, void* data, uint32_t
manager->init(manager); manager->init(manager);
if UNLIKELY (!manager->good()) { if UNLIKELY (!manager->good()) {
LOGM(ERR, "Couldn't create a workspace manager"); LOGM(Log::ERR, "Couldn't create a workspace manager");
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
} }

View file

@ -119,7 +119,7 @@ CFifoManagerResource::CFifoManagerResource(UP<CWpFifoManagerV1>&& resource_) : m
} }
surf->m_fifo = RESOURCE; surf->m_fifo = RESOURCE;
LOGM(LOG, "New fifo at {:x} for surface {:x}", (uintptr_t)RESOURCE, (uintptr_t)surf.get()); LOGM(Log::DEBUG, "New fifo at {:x} for surface {:x}", (uintptr_t)RESOURCE, (uintptr_t)surf.get());
}); });
} }

View file

@ -107,7 +107,7 @@ void CFocusGrab::refocusKeyboard() {
if (surface) if (surface)
Desktop::focusState()->rawSurfaceFocus(surface); Desktop::focusState()->rawSurfaceFocus(surface);
else else
LOGM(ERR, "CFocusGrab::refocusKeyboard called with no committed surfaces. This should never happen."); LOGM(Log::ERR, "CFocusGrab::refocusKeyboard called with no committed surfaces. This should never happen.");
} }
void CFocusGrab::commit(bool removeOnly) { void CFocusGrab::commit(bool removeOnly) {

View file

@ -30,7 +30,7 @@ CForeignToplevelList::CForeignToplevelList(SP<CExtForeignToplevelListV1> resourc
m_resource->setStop([this](CExtForeignToplevelListV1* h) { m_resource->setStop([this](CExtForeignToplevelListV1* h) {
m_resource->sendFinished(); m_resource->sendFinished();
m_finished = true; m_finished = true;
LOGM(LOG, "CForeignToplevelList: finished"); LOGM(Log::DEBUG, "CForeignToplevelList: finished");
}); });
for (auto const& w : g_pCompositor->m_windows) { for (auto const& w : g_pCompositor->m_windows) {
@ -58,7 +58,7 @@ void CForeignToplevelList::onMap(PHLWINDOW pWindow) {
makeShared<CForeignToplevelHandle>(makeShared<CExtForeignToplevelHandleV1>(m_resource->client(), m_resource->version(), 0), pWindow)); makeShared<CForeignToplevelHandle>(makeShared<CExtForeignToplevelHandleV1>(m_resource->client(), m_resource->version(), 0), pWindow));
if (!NEWHANDLE->good()) { if (!NEWHANDLE->good()) {
LOGM(ERR, "Couldn't create a foreign handle"); LOGM(Log::ERR, "Couldn't create a foreign handle");
m_resource->noMemory(); m_resource->noMemory();
PROTO::foreignToplevel->m_handles.pop_back(); PROTO::foreignToplevel->m_handles.pop_back();
return; return;
@ -66,7 +66,7 @@ void CForeignToplevelList::onMap(PHLWINDOW pWindow) {
const auto IDENTIFIER = std::format("{:08x}->{:016x}", sc<uint32_t>(rc<uintptr_t>(this) & 0xFFFFFFFF), rc<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::DEBUG, "Newly mapped window gets an identifier of {}", IDENTIFIER);
m_resource->sendToplevel(NEWHANDLE->m_resource.get()); m_resource->sendToplevel(NEWHANDLE->m_resource.get());
NEWHANDLE->m_resource->sendIdentifier(IDENTIFIER.c_str()); NEWHANDLE->m_resource->sendIdentifier(IDENTIFIER.c_str());
NEWHANDLE->m_resource->sendAppId(pWindow->m_initialClass.c_str()); NEWHANDLE->m_resource->sendAppId(pWindow->m_initialClass.c_str());
@ -161,7 +161,7 @@ void CForeignToplevelProtocol::bindManager(wl_client* client, void* data, uint32
const auto RESOURCE = m_managers.emplace_back(makeUnique<CForeignToplevelList>(makeShared<CExtForeignToplevelListV1>(client, ver, id))).get(); const auto RESOURCE = m_managers.emplace_back(makeUnique<CForeignToplevelList>(makeShared<CExtForeignToplevelListV1>(client, ver, id))).get();
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
LOGM(ERR, "Couldn't create a foreign list"); LOGM(Log::ERR, "Couldn't create a foreign list");
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
m_managers.pop_back(); m_managers.pop_back();
return; return;

View file

@ -206,7 +206,7 @@ CForeignToplevelWlrManager::CForeignToplevelWlrManager(SP<CZwlrForeignToplevelMa
m_resource->setStop([this](CZwlrForeignToplevelManagerV1* h) { m_resource->setStop([this](CZwlrForeignToplevelManagerV1* h) {
m_resource->sendFinished(); m_resource->sendFinished();
m_finished = true; m_finished = true;
LOGM(LOG, "CForeignToplevelWlrManager: finished"); LOGM(Log::DEBUG, "CForeignToplevelWlrManager: finished");
PROTO::foreignToplevelWlr->onManagerResourceDestroy(this); PROTO::foreignToplevelWlr->onManagerResourceDestroy(this);
}); });
@ -228,13 +228,13 @@ void CForeignToplevelWlrManager::onMap(PHLWINDOW pWindow) {
makeShared<CForeignToplevelHandleWlr>(makeShared<CZwlrForeignToplevelHandleV1>(m_resource->client(), m_resource->version(), 0), pWindow)); makeShared<CForeignToplevelHandleWlr>(makeShared<CZwlrForeignToplevelHandleV1>(m_resource->client(), m_resource->version(), 0), pWindow));
if UNLIKELY (!NEWHANDLE->good()) { if UNLIKELY (!NEWHANDLE->good()) {
LOGM(ERR, "Couldn't create a foreign handle"); LOGM(Log::ERR, "Couldn't create a foreign handle");
m_resource->noMemory(); m_resource->noMemory();
PROTO::foreignToplevelWlr->m_handles.pop_back(); PROTO::foreignToplevelWlr->m_handles.pop_back();
return; return;
} }
LOGM(LOG, "Newly mapped window {:016x}", (uintptr_t)pWindow.get()); LOGM(Log::DEBUG, "Newly mapped window {:016x}", (uintptr_t)pWindow.get());
m_resource->sendToplevel(NEWHANDLE->m_resource.get()); m_resource->sendToplevel(NEWHANDLE->m_resource.get());
NEWHANDLE->m_resource->sendAppId(pWindow->m_class.c_str()); NEWHANDLE->m_resource->sendAppId(pWindow->m_class.c_str());
NEWHANDLE->m_resource->sendTitle(pWindow->m_title.c_str()); NEWHANDLE->m_resource->sendTitle(pWindow->m_title.c_str());
@ -409,7 +409,7 @@ void CForeignToplevelWlrProtocol::bindManager(wl_client* client, void* data, uin
const auto RESOURCE = m_managers.emplace_back(makeUnique<CForeignToplevelWlrManager>(makeShared<CZwlrForeignToplevelManagerV1>(client, ver, id))).get(); const auto RESOURCE = m_managers.emplace_back(makeUnique<CForeignToplevelWlrManager>(makeShared<CZwlrForeignToplevelManagerV1>(client, ver, id))).get();
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
LOGM(ERR, "Couldn't create a foreign list"); LOGM(Log::ERR, "Couldn't create a foreign list");
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
m_managers.pop_back(); m_managers.pop_back();
return; return;

View file

@ -26,7 +26,7 @@ void CFractionalScaleProtocol::onManagerResourceDestroy(wl_resource* res) {
void CFractionalScaleProtocol::onGetFractionalScale(CWpFractionalScaleManagerV1* pMgr, uint32_t id, SP<CWLSurfaceResource> surface) { void CFractionalScaleProtocol::onGetFractionalScale(CWpFractionalScaleManagerV1* pMgr, uint32_t id, SP<CWLSurfaceResource> surface) {
for (auto const& [k, v] : m_addons) { for (auto const& [k, v] : m_addons) {
if (k == surface) { if (k == surface) {
LOGM(ERR, "Surface {:x} already has a fractionalScale addon", (uintptr_t)surface.get()); LOGM(Log::ERR, "Surface {:x} already has a fractionalScale addon", (uintptr_t)surface.get());
pMgr->error(WP_FRACTIONAL_SCALE_MANAGER_V1_ERROR_FRACTIONAL_SCALE_EXISTS, "Fractional scale already exists"); pMgr->error(WP_FRACTIONAL_SCALE_MANAGER_V1_ERROR_FRACTIONAL_SCALE_EXISTS, "Fractional scale already exists");
return; return;
} }

View file

@ -26,15 +26,15 @@ CFrogColorManager::CFrogColorManager(SP<CFrogColorManagementFactoryV1> resource_
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
m_resource->setDestroy([](CFrogColorManagementFactoryV1* r) { LOGM(TRACE, "Destroy frog_color_management at {:x} (generated default)", (uintptr_t)r); }); m_resource->setDestroy([](CFrogColorManagementFactoryV1* r) { LOGM(Log::TRACE, "Destroy frog_color_management at {:x} (generated default)", (uintptr_t)r); });
m_resource->setOnDestroy([this](CFrogColorManagementFactoryV1* r) { PROTO::frogColorManagement->destroyResource(this); }); m_resource->setOnDestroy([this](CFrogColorManagementFactoryV1* r) { PROTO::frogColorManagement->destroyResource(this); });
m_resource->setGetColorManagedSurface([](CFrogColorManagementFactoryV1* r, wl_resource* surface, uint32_t id) { m_resource->setGetColorManagedSurface([](CFrogColorManagementFactoryV1* r, wl_resource* surface, uint32_t id) {
LOGM(TRACE, "Get surface for id={}, surface={}", id, (uintptr_t)surface); LOGM(Log::TRACE, "Get surface for id={}, surface={}", id, (uintptr_t)surface);
auto SURF = CWLSurfaceResource::fromResource(surface); auto SURF = CWLSurfaceResource::fromResource(surface);
if (!SURF) { if (!SURF) {
LOGM(ERR, "No surface for resource {}", (uintptr_t)surface); LOGM(Log::ERR, "No surface for resource {}", (uintptr_t)surface);
r->error(-1, "Invalid surface (2)"); r->error(-1, "Invalid surface (2)");
return; return;
} }
@ -74,24 +74,24 @@ CFrogColorManagementSurface::CFrogColorManagementSurface(SP<CFrogColorManagedSur
m_surface->m_colorManagement = RESOURCE; m_surface->m_colorManagement = RESOURCE;
m_resource->setOnDestroy([this](CFrogColorManagedSurface* r) { m_resource->setOnDestroy([this](CFrogColorManagedSurface* r) {
LOGM(TRACE, "Destroy frog cm and xx cm for surface {}", (uintptr_t)m_surface); LOGM(Log::TRACE, "Destroy frog cm and xx cm for surface {}", (uintptr_t)m_surface);
if (m_surface.valid()) if (m_surface.valid())
PROTO::colorManagement->destroyResource(m_surface->m_colorManagement.get()); PROTO::colorManagement->destroyResource(m_surface->m_colorManagement.get());
PROTO::frogColorManagement->destroyResource(this); PROTO::frogColorManagement->destroyResource(this);
}); });
} else } else
m_resource->setOnDestroy([this](CFrogColorManagedSurface* r) { m_resource->setOnDestroy([this](CFrogColorManagedSurface* r) {
LOGM(TRACE, "Destroy frog cm surface {}", (uintptr_t)m_surface); LOGM(Log::TRACE, "Destroy frog cm surface {}", (uintptr_t)m_surface);
PROTO::frogColorManagement->destroyResource(this); PROTO::frogColorManagement->destroyResource(this);
}); });
m_resource->setDestroy([this](CFrogColorManagedSurface* r) { m_resource->setDestroy([this](CFrogColorManagedSurface* r) {
LOGM(TRACE, "Destroy frog cm surface {}", (uintptr_t)m_surface); LOGM(Log::TRACE, "Destroy frog cm surface {}", (uintptr_t)m_surface);
PROTO::frogColorManagement->destroyResource(this); PROTO::frogColorManagement->destroyResource(this);
}); });
m_resource->setSetKnownTransferFunction([this](CFrogColorManagedSurface* r, frogColorManagedSurfaceTransferFunction tf) { m_resource->setSetKnownTransferFunction([this](CFrogColorManagedSurface* r, frogColorManagedSurfaceTransferFunction tf) {
LOGM(TRACE, "Set frog cm transfer function {} for {}", (uint32_t)tf, m_surface->id()); LOGM(Log::TRACE, "Set frog cm transfer function {} for {}", (uint32_t)tf, m_surface->id());
switch (tf) { switch (tf) {
case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ: case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ:
m_surface->m_colorManagement->m_imageDescription.transferFunction = m_surface->m_colorManagement->m_imageDescription.transferFunction =
@ -100,7 +100,7 @@ CFrogColorManagementSurface::CFrogColorManagementSurface(SP<CFrogColorManagedSur
; ;
case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_GAMMA_22: case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_GAMMA_22:
if (m_pqIntentSent) { if (m_pqIntentSent) {
LOGM(TRACE, LOGM(Log::TRACE,
"FIXME: assuming broken enum value 2 (FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_GAMMA_22) referring to eotf value 2 (TRANSFER_FUNCTION_ST2084_PQ)"); "FIXME: assuming broken enum value 2 (FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_GAMMA_22) referring to eotf value 2 (TRANSFER_FUNCTION_ST2084_PQ)");
m_surface->m_colorManagement->m_imageDescription.transferFunction = m_surface->m_colorManagement->m_imageDescription.transferFunction =
convertTransferFunction(getWPTransferFunction(FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ)); convertTransferFunction(getWPTransferFunction(FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ));
@ -108,7 +108,7 @@ CFrogColorManagementSurface::CFrogColorManagementSurface(SP<CFrogColorManagedSur
}; };
[[fallthrough]]; [[fallthrough]];
case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_UNDEFINED: case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_UNDEFINED:
case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_SCRGB_LINEAR: LOGM(TRACE, "FIXME: add tf support for {}", (uint32_t)tf); [[fallthrough]]; case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_SCRGB_LINEAR: LOGM(Log::TRACE, "FIXME: add tf support for {}", (uint32_t)tf); [[fallthrough]];
case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_SRGB: case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_SRGB:
m_surface->m_colorManagement->m_imageDescription.transferFunction = convertTransferFunction(getWPTransferFunction(tf)); m_surface->m_colorManagement->m_imageDescription.transferFunction = convertTransferFunction(getWPTransferFunction(tf));
@ -116,7 +116,7 @@ CFrogColorManagementSurface::CFrogColorManagementSurface(SP<CFrogColorManagedSur
} }
}); });
m_resource->setSetKnownContainerColorVolume([this](CFrogColorManagedSurface* r, frogColorManagedSurfacePrimaries primariesName) { m_resource->setSetKnownContainerColorVolume([this](CFrogColorManagedSurface* r, frogColorManagedSurfacePrimaries primariesName) {
LOGM(TRACE, "Set frog cm primaries {}", (uint32_t)primariesName); LOGM(Log::TRACE, "Set frog cm primaries {}", (uint32_t)primariesName);
switch (primariesName) { switch (primariesName) {
case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_UNDEFINED: case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_UNDEFINED:
case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_REC709: m_surface->m_colorManagement->m_imageDescription.primaries = NColorPrimaries::BT709; break; case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_REC709: m_surface->m_colorManagement->m_imageDescription.primaries = NColorPrimaries::BT709; break;
@ -127,13 +127,14 @@ CFrogColorManagementSurface::CFrogColorManagementSurface(SP<CFrogColorManagedSur
m_surface->m_colorManagement->setHasImageDescription(true); m_surface->m_colorManagement->setHasImageDescription(true);
}); });
m_resource->setSetRenderIntent([this](CFrogColorManagedSurface* r, frogColorManagedSurfaceRenderIntent intent) { m_resource->setSetRenderIntent([this](CFrogColorManagedSurface* r, frogColorManagedSurfaceRenderIntent intent) {
LOGM(TRACE, "Set frog cm intent {}", (uint32_t)intent); LOGM(Log::TRACE, "Set frog cm intent {}", (uint32_t)intent);
m_pqIntentSent = intent == FROG_COLOR_MANAGED_SURFACE_RENDER_INTENT_PERCEPTUAL; m_pqIntentSent = intent == FROG_COLOR_MANAGED_SURFACE_RENDER_INTENT_PERCEPTUAL;
m_surface->m_colorManagement->setHasImageDescription(true); m_surface->m_colorManagement->setHasImageDescription(true);
}); });
m_resource->setSetHdrMetadata([this](CFrogColorManagedSurface* r, uint32_t r_x, uint32_t r_y, uint32_t g_x, uint32_t g_y, uint32_t b_x, uint32_t b_y, uint32_t w_x, m_resource->setSetHdrMetadata([this](CFrogColorManagedSurface* r, uint32_t r_x, uint32_t r_y, uint32_t g_x, uint32_t g_y, uint32_t b_x, uint32_t b_y, uint32_t w_x,
uint32_t w_y, uint32_t max_lum, uint32_t min_lum, uint32_t cll, uint32_t fall) { uint32_t w_y, uint32_t max_lum, uint32_t min_lum, uint32_t cll, uint32_t fall) {
LOGM(TRACE, "Set frog primaries r:{},{} g:{},{} b:{},{} w:{},{} luminances {} - {} cll {} fall {}", r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y, min_lum, max_lum, cll, fall); LOGM(Log::TRACE, "Set frog primaries r:{},{} g:{},{} b:{},{} w:{},{} luminances {} - {} cll {} fall {}", r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y, min_lum, max_lum, cll,
fall);
m_surface->m_colorManagement->m_imageDescription.masteringPrimaries = SPCPRimaries{.red = {.x = r_x / 50000.0f, .y = r_y / 50000.0f}, m_surface->m_colorManagement->m_imageDescription.masteringPrimaries = SPCPRimaries{.red = {.x = r_x / 50000.0f, .y = r_y / 50000.0f},
.green = {.x = g_x / 50000.0f, .y = g_y / 50000.0f}, .green = {.x = g_x / 50000.0f, .y = g_y / 50000.0f},
.blue = {.x = b_x / 50000.0f, .y = b_y / 50000.0f}, .blue = {.x = b_x / 50000.0f, .y = b_y / 50000.0f},
@ -168,7 +169,7 @@ void CFrogColorManagementProtocol::bindManager(wl_client* client, void* data, ui
return; return;
} }
LOGM(TRACE, "New frog_color_management at {:x}", (uintptr_t)RESOURCE.get()); LOGM(Log::TRACE, "New frog_color_management at {:x}", (uintptr_t)RESOURCE.get());
} }
void CFrogColorManagementProtocol::destroyResource(CFrogColorManager* resource) { void CFrogColorManagementProtocol::destroyResource(CFrogColorManager* resource) {

View file

@ -13,7 +13,7 @@ CGammaControl::CGammaControl(SP<CZwlrGammaControlV1> resource_, wl_resource* out
auto OUTPUTRES = CWLOutputResource::fromResource(output); auto OUTPUTRES = CWLOutputResource::fromResource(output);
if UNLIKELY (!OUTPUTRES) { if UNLIKELY (!OUTPUTRES) {
LOGM(ERR, "No output in CGammaControl"); LOGM(Log::ERR, "No output in CGammaControl");
m_resource->sendFailed(); m_resource->sendFailed();
return; return;
} }
@ -21,7 +21,7 @@ CGammaControl::CGammaControl(SP<CZwlrGammaControlV1> resource_, wl_resource* out
m_monitor = OUTPUTRES->m_monitor; m_monitor = OUTPUTRES->m_monitor;
if UNLIKELY (!m_monitor || !m_monitor->m_output) { if UNLIKELY (!m_monitor || !m_monitor->m_output) {
LOGM(ERR, "No CMonitor"); LOGM(Log::ERR, "No CMonitor");
m_resource->sendFailed(); m_resource->sendFailed();
return; return;
} }
@ -36,7 +36,7 @@ CGammaControl::CGammaControl(SP<CZwlrGammaControlV1> resource_, wl_resource* out
m_gammaSize = m_monitor->m_output->getGammaSize(); m_gammaSize = m_monitor->m_output->getGammaSize();
if UNLIKELY (m_gammaSize <= 0) { if UNLIKELY (m_gammaSize <= 0) {
LOGM(ERR, "Output {} doesn't support gamma", m_monitor->m_name); LOGM(Log::ERR, "Output {} doesn't support gamma", m_monitor->m_name);
m_resource->sendFailed(); m_resource->sendFailed();
return; return;
} }
@ -49,24 +49,24 @@ CGammaControl::CGammaControl(SP<CZwlrGammaControlV1> resource_, wl_resource* out
m_resource->setSetGamma([this](CZwlrGammaControlV1* gamma, int32_t fd) { m_resource->setSetGamma([this](CZwlrGammaControlV1* gamma, int32_t fd) {
CFileDescriptor gammaFd{fd}; CFileDescriptor gammaFd{fd};
if UNLIKELY (!m_monitor) { if UNLIKELY (!m_monitor) {
LOGM(ERR, "setGamma for a dead monitor"); LOGM(Log::ERR, "setGamma for a dead monitor");
m_resource->sendFailed(); m_resource->sendFailed();
return; return;
} }
LOGM(LOG, "setGamma for {}", m_monitor->m_name); LOGM(Log::DEBUG, "setGamma for {}", m_monitor->m_name);
// TODO: make CFileDescriptor getflags use F_GETFL // TODO: make CFileDescriptor getflags use F_GETFL
int fdFlags = fcntl(gammaFd.get(), F_GETFL, 0); int fdFlags = fcntl(gammaFd.get(), F_GETFL, 0);
if UNLIKELY (fdFlags < 0) { if UNLIKELY (fdFlags < 0) {
LOGM(ERR, "Failed to get fd flags"); LOGM(Log::ERR, "Failed to get fd flags");
m_resource->sendFailed(); m_resource->sendFailed();
return; return;
} }
// TODO: make CFileDescriptor setflags use F_SETFL // TODO: make CFileDescriptor setflags use F_SETFL
if UNLIKELY (fcntl(gammaFd.get(), F_SETFL, fdFlags | O_NONBLOCK) < 0) { if UNLIKELY (fcntl(gammaFd.get(), F_SETFL, fdFlags | O_NONBLOCK) < 0) {
LOGM(ERR, "Failed to set fd flags"); LOGM(Log::ERR, "Failed to set fd flags");
m_resource->sendFailed(); m_resource->sendFailed();
return; return;
} }
@ -81,7 +81,7 @@ CGammaControl::CGammaControl(SP<CZwlrGammaControlV1> resource_, wl_resource* out
} }
if (readBytes < 0 || sc<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(Log::ERR, "Failed to read bytes");
if (sc<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");
@ -136,7 +136,7 @@ void CGammaControl::applyToMonitor() {
if UNLIKELY (!m_monitor || !m_monitor->m_output) if UNLIKELY (!m_monitor || !m_monitor->m_output)
return; // ?? return; // ??
LOGM(LOG, "setting to monitor {}", m_monitor->m_name); LOGM(Log::DEBUG, "setting to monitor {}", m_monitor->m_name);
if (!m_gammaTableSet) { if (!m_gammaTableSet) {
m_monitor->m_output->state->setGammaLut({}); m_monitor->m_output->state->setGammaLut({});
@ -146,7 +146,7 @@ void CGammaControl::applyToMonitor() {
m_monitor->m_output->state->setGammaLut(m_gammaTable); m_monitor->m_output->state->setGammaLut(m_gammaTable);
if (!m_monitor->m_state.test()) { if (!m_monitor->m_state.test()) {
LOGM(LOG, "setting to monitor {} failed", m_monitor->m_name); LOGM(Log::DEBUG, "setting to monitor {} failed", m_monitor->m_name);
m_monitor->m_output->state->setGammaLut({}); m_monitor->m_output->state->setGammaLut({});
} }
@ -158,7 +158,7 @@ PHLMONITOR CGammaControl::getMonitor() {
} }
void CGammaControl::onMonitorDestroy() { void CGammaControl::onMonitorDestroy() {
LOGM(LOG, "Destroying gamma control for {}", m_monitor->m_name); LOGM(Log::DEBUG, "Destroying gamma control for {}", m_monitor->m_name);
m_resource->sendFailed(); m_resource->sendFailed();
} }

View file

@ -113,7 +113,7 @@ void CHyprlandSurfaceProtocol::getSurface(CHyprlandSurfaceManagerV1* manager, ui
if (iter != m_surfaces.end()) { if (iter != m_surfaces.end()) {
if (iter->second->m_resource) { if (iter->second->m_resource) {
LOGM(ERR, "HyprlandSurface already present for surface {:x}", (uintptr_t)surface.get()); LOGM(Log::ERR, "HyprlandSurface already present for surface {:x}", (uintptr_t)surface.get());
manager->error(HYPRLAND_SURFACE_MANAGER_V1_ERROR_ALREADY_CONSTRUCTED, "HyprlandSurface already present"); manager->error(HYPRLAND_SURFACE_MANAGER_V1_ERROR_ALREADY_CONSTRUCTED, "HyprlandSurface already present");
return; return;
} else { } else {

View file

@ -23,7 +23,7 @@ CExtIdleNotification::CExtIdleNotification(SP<CExtIdleNotificationV1> resource_,
update(); update();
LOGM(LOG, "Registered idle-notification for {}ms", timeoutMs_); LOGM(Log::DEBUG, "Registered idle-notification for {}ms", timeoutMs_);
} }
CExtIdleNotification::~CExtIdleNotification() { CExtIdleNotification::~CExtIdleNotification() {

View file

@ -15,7 +15,7 @@ CInputMethodKeyboardGrabV2::CInputMethodKeyboardGrabV2(SP<CZwpInputMethodKeyboar
m_resource->setOnDestroy([this](CZwpInputMethodKeyboardGrabV2* r) { PROTO::ime->destroyResource(this); }); m_resource->setOnDestroy([this](CZwpInputMethodKeyboardGrabV2* r) { PROTO::ime->destroyResource(this); });
if (!g_pSeatManager->m_keyboard) { if (!g_pSeatManager->m_keyboard) {
LOGM(ERR, "IME called but no active keyboard???"); LOGM(Log::ERR, "IME called but no active keyboard???");
return; return;
} }
@ -36,13 +36,13 @@ void CInputMethodKeyboardGrabV2::sendKeyboardData(SP<IKeyboard> keyboard) {
auto keymapFD = allocateSHMFile(keyboard->m_xkbKeymapV1String.length() + 1); auto keymapFD = allocateSHMFile(keyboard->m_xkbKeymapV1String.length() + 1);
if UNLIKELY (!keymapFD.isValid()) { if UNLIKELY (!keymapFD.isValid()) {
LOGM(ERR, "Failed to create a keymap file for keyboard grab"); LOGM(Log::ERR, "Failed to create a keymap file for keyboard grab");
return; return;
} }
void* data = mmap(nullptr, keyboard->m_xkbKeymapV1String.length() + 1, PROT_READ | PROT_WRITE, MAP_SHARED, keymapFD.get(), 0); void* data = mmap(nullptr, keyboard->m_xkbKeymapV1String.length() + 1, PROT_READ | PROT_WRITE, MAP_SHARED, keymapFD.get(), 0);
if UNLIKELY (data == MAP_FAILED) { if UNLIKELY (data == MAP_FAILED) {
LOGM(ERR, "Failed to mmap a keymap file for keyboard grab"); LOGM(Log::ERR, "Failed to mmap a keymap file for keyboard grab");
return; return;
} }
@ -194,7 +194,7 @@ CInputMethodV2::CInputMethodV2(SP<CZwpInputMethodV2> resource_) : m_resource(res
return; return;
} }
LOGM(LOG, "New IME Popup with resource id {}", id); LOGM(Log::DEBUG, "New IME Popup with resource id {}", id);
m_popups.emplace_back(RESOURCE); m_popups.emplace_back(RESOURCE);
@ -211,7 +211,7 @@ CInputMethodV2::CInputMethodV2(SP<CZwpInputMethodV2> resource_) : m_resource(res
return; return;
} }
LOGM(LOG, "New IME Grab with resource id {}", id); LOGM(Log::DEBUG, "New IME Grab with resource id {}", id);
m_grabs.emplace_back(RESOURCE); m_grabs.emplace_back(RESOURCE);
}); });
@ -367,7 +367,7 @@ void CInputMethodV2Protocol::onGetIME(CZwpInputMethodManagerV2* mgr, wl_resource
RESOURCE->m_self = RESOURCE; RESOURCE->m_self = RESOURCE;
LOGM(LOG, "New IME with resource id {}", id); LOGM(Log::DEBUG, "New IME with resource id {}", id);
m_events.newIME.emit(RESOURCE); m_events.newIME.emit(RESOURCE);
} }

View file

@ -249,7 +249,7 @@ void CLayerShellProtocol::onGetLayerSurface(CZwlrLayerShellV1* pMgr, uint32_t id
SURF->m_role = makeShared<CLayerShellRole>(RESOURCE); SURF->m_role = makeShared<CLayerShellRole>(RESOURCE);
g_pCompositor->m_layers.emplace_back(Desktop::View::CLayerSurface::create(RESOURCE)); g_pCompositor->m_layers.emplace_back(Desktop::View::CLayerSurface::create(RESOURCE));
LOGM(LOG, "New wlr_layer_surface {:x}", (uintptr_t)RESOURCE.get()); LOGM(Log::DEBUG, "New wlr_layer_surface {:x}", (uintptr_t)RESOURCE.get());
} }
CLayerShellRole::CLayerShellRole(SP<CLayerShellResource> ls) : m_layerSurface(ls) { CLayerShellRole::CLayerShellRole(SP<CLayerShellResource> ls) : m_layerSurface(ls) {

View file

@ -83,7 +83,7 @@ CDMABUFFormatTable::CDMABUFFormatTable(SDMABUFTranche _rendererTranche, std::vec
auto arr = sc<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(Log::ERR, "mmap failed");
return; return;
} }
@ -105,7 +105,7 @@ CLinuxDMABuffer::CLinuxDMABuffer(uint32_t id, wl_client* client, Aquamarine::SDM
}); });
if (!m_buffer->m_success) if (!m_buffer->m_success)
LOGM(ERR, "Possibly compositor bug: buffer failed to create"); LOGM(Log::ERR, "Possibly compositor bug: buffer failed to create");
} }
CLinuxDMABuffer::~CLinuxDMABuffer() { CLinuxDMABuffer::~CLinuxDMABuffer() {
@ -161,7 +161,7 @@ CLinuxDMABUFParamsResource::CLinuxDMABUFParamsResource(UP<CZwpLinuxBufferParamsV
if (flags > 0) { if (flags > 0) {
r->sendFailed(); r->sendFailed();
LOGM(ERR, "DMABUF flags are not supported"); LOGM(Log::ERR, "DMABUF flags are not supported");
return; return;
} }
@ -180,7 +180,7 @@ CLinuxDMABUFParamsResource::CLinuxDMABUFParamsResource(UP<CZwpLinuxBufferParamsV
if (flags > 0) { if (flags > 0) {
r->sendFailed(); r->sendFailed();
LOGM(ERR, "DMABUF flags are not supported"); LOGM(Log::ERR, "DMABUF flags are not supported");
return; return;
} }
@ -200,19 +200,19 @@ void CLinuxDMABUFParamsResource::create(uint32_t id) {
m_used = true; m_used = true;
if UNLIKELY (!verify()) { if UNLIKELY (!verify()) {
LOGM(ERR, "Failed creating a dmabuf: verify() said no"); LOGM(Log::ERR, "Failed creating a dmabuf: verify() said no");
return; // if verify failed, we errored the resource. return; // if verify failed, we errored the resource.
} }
if UNLIKELY (!commence()) { if UNLIKELY (!commence()) {
LOGM(ERR, "Failed creating a dmabuf: commence() said no"); LOGM(Log::ERR, "Failed creating a dmabuf: commence() said no");
m_resource->sendFailed(); m_resource->sendFailed();
return; return;
} }
LOGM(LOG, "Creating a dmabuf, with id {}: size {}, fmt {}, planes {}", id, m_attrs->size, NFormatUtils::drmFormatName(m_attrs->format), m_attrs->planes); LOGM(Log::DEBUG, "Creating a dmabuf, with id {}: size {}, fmt {}, planes {}", id, m_attrs->size, NFormatUtils::drmFormatName(m_attrs->format), m_attrs->planes);
for (int i = 0; i < m_attrs->planes; ++i) { for (int i = 0; i < m_attrs->planes; ++i) {
LOGM(LOG, " | plane {}: mod {} fd {} stride {} offset {}", i, m_attrs->modifier, m_attrs->fds[i], m_attrs->strides[i], m_attrs->offsets[i]); LOGM(Log::DEBUG, " | plane {}: mod {} fd {} stride {} offset {}", i, m_attrs->modifier, m_attrs->fds[i], m_attrs->strides[i], m_attrs->offsets[i]);
} }
auto& buf = PROTO::linuxDma->m_buffers.emplace_back(makeUnique<CLinuxDMABuffer>(id, m_resource->client(), *m_attrs)); auto& buf = PROTO::linuxDma->m_buffers.emplace_back(makeUnique<CLinuxDMABuffer>(id, m_resource->client(), *m_attrs));
@ -237,12 +237,12 @@ bool CLinuxDMABUFParamsResource::commence() {
uint32_t handle = 0; uint32_t handle = 0;
if (drmPrimeFDToHandle(PROTO::linuxDma->m_mainDeviceFD.get(), m_attrs->fds.at(i), &handle)) { if (drmPrimeFDToHandle(PROTO::linuxDma->m_mainDeviceFD.get(), m_attrs->fds.at(i), &handle)) {
LOGM(ERR, "Failed to import dmabuf fd"); LOGM(Log::ERR, "Failed to import dmabuf fd");
return false; return false;
} }
if (drmCloseBufferHandle(PROTO::linuxDma->m_mainDeviceFD.get(), handle)) { if (drmCloseBufferHandle(PROTO::linuxDma->m_mainDeviceFD.get(), handle)) {
LOGM(ERR, "Failed to close dmabuf handle"); LOGM(Log::ERR, "Failed to close dmabuf handle");
return false; return false;
} }
} }
@ -412,7 +412,7 @@ CLinuxDMABufV1Protocol::CLinuxDMABufV1Protocol(const wl_interface* iface, const
auto dev = devIDFromFD(rendererFD); auto dev = devIDFromFD(rendererFD);
if (!dev.has_value()) { if (!dev.has_value()) {
LOGM(ERR, "failed to get drm dev, disabling linux dmabuf"); LOGM(Log::ERR, "failed to get drm dev, disabling linux dmabuf");
removeGlobal(); removeGlobal();
return; return;
} }
@ -462,7 +462,7 @@ CLinuxDMABufV1Protocol::CLinuxDMABufV1Protocol(const wl_interface* iface, const
drmDevice* device = nullptr; drmDevice* device = nullptr;
if (drmGetDeviceFromDevId(m_mainDevice, 0, &device) != 0) { if (drmGetDeviceFromDevId(m_mainDevice, 0, &device) != 0) {
LOGM(ERR, "failed to get drm dev, disabling linux dmabuf"); LOGM(Log::ERR, "failed to get drm dev, disabling linux dmabuf");
removeGlobal(); removeGlobal();
return; return;
} }
@ -472,7 +472,7 @@ CLinuxDMABufV1Protocol::CLinuxDMABufV1Protocol(const wl_interface* iface, const
m_mainDeviceFD = CFileDescriptor{fcntl(g_pCompositor->m_drmRenderNode.fd, F_DUPFD_CLOEXEC, 0)}; m_mainDeviceFD = CFileDescriptor{fcntl(g_pCompositor->m_drmRenderNode.fd, F_DUPFD_CLOEXEC, 0)};
drmFreeDevice(&device); drmFreeDevice(&device);
if (!m_mainDeviceFD.isValid()) { if (!m_mainDeviceFD.isValid()) {
LOGM(ERR, "failed to open rendernode, disabling linux dmabuf"); LOGM(Log::ERR, "failed to open rendernode, disabling linux dmabuf");
removeGlobal(); removeGlobal();
return; return;
} }
@ -485,12 +485,12 @@ CLinuxDMABufV1Protocol::CLinuxDMABufV1Protocol(const wl_interface* iface, const
m_mainDeviceFD = CFileDescriptor{open(name, O_RDWR | O_CLOEXEC)}; m_mainDeviceFD = CFileDescriptor{open(name, O_RDWR | O_CLOEXEC)};
drmFreeDevice(&device); drmFreeDevice(&device);
if (!m_mainDeviceFD.isValid()) { if (!m_mainDeviceFD.isValid()) {
LOGM(ERR, "failed to open drm dev, disabling linux dmabuf"); LOGM(Log::ERR, "failed to open drm dev, disabling linux dmabuf");
removeGlobal(); removeGlobal();
return; return;
} }
} else { } else {
LOGM(ERR, "DRM device {} has no render node, disabling linux dmabuf checks", device->nodes[DRM_NODE_PRIMARY] ? device->nodes[DRM_NODE_PRIMARY] : "null"); LOGM(Log::ERR, "DRM device {} has no render node, disabling linux dmabuf checks", device->nodes[DRM_NODE_PRIMARY] ? device->nodes[DRM_NODE_PRIMARY] : "null");
drmFreeDevice(&device); drmFreeDevice(&device);
} }
}); });
@ -500,7 +500,7 @@ void CLinuxDMABufV1Protocol::resetFormatTable() {
if (!m_formatTable) if (!m_formatTable)
return; return;
LOGM(LOG, "Resetting format table"); LOGM(Log::DEBUG, "Resetting format table");
// this might be a big copy // this might be a big copy
auto newFormatTable = makeUnique<CDMABUFFormatTable>(m_formatTable->m_rendererTranche, m_formatTable->m_monitorTranches); auto newFormatTable = makeUnique<CDMABUFFormatTable>(m_formatTable->m_rendererTranche, m_formatTable->m_monitorTranches);
@ -570,12 +570,12 @@ void CLinuxDMABufV1Protocol::updateScanoutTranche(SP<CWLSurfaceResource> surface
} }
if (!feedbackResource) { if (!feedbackResource) {
LOGM(LOG, "updateScanoutTranche: surface has no dmabuf_feedback"); LOGM(Log::DEBUG, "updateScanoutTranche: surface has no dmabuf_feedback");
return; return;
} }
if (!pMonitor) { if (!pMonitor) {
LOGM(LOG, "updateScanoutTranche: resetting feedback"); LOGM(Log::DEBUG, "updateScanoutTranche: resetting feedback");
feedbackResource->sendDefaultFeedback(); feedbackResource->sendDefaultFeedback();
return; return;
} }
@ -584,13 +584,13 @@ void CLinuxDMABufV1Protocol::updateScanoutTranche(SP<CWLSurfaceResource> surface
std::ranges::find_if(m_formatTable->m_monitorTranches, [pMonitor](std::pair<PHLMONITORREF, SDMABUFTranche> pair) { return pair.first == pMonitor; }); std::ranges::find_if(m_formatTable->m_monitorTranches, [pMonitor](std::pair<PHLMONITORREF, SDMABUFTranche> pair) { return pair.first == pMonitor; });
if (monitorTranchePair == m_formatTable->m_monitorTranches.end()) { if (monitorTranchePair == m_formatTable->m_monitorTranches.end()) {
LOGM(LOG, "updateScanoutTranche: monitor has no tranche"); LOGM(Log::DEBUG, "updateScanoutTranche: monitor has no tranche");
return; return;
} }
auto& monitorTranche = (*monitorTranchePair).second; auto& monitorTranche = (*monitorTranchePair).second;
LOGM(LOG, "updateScanoutTranche: sending a scanout tranche"); LOGM(Log::DEBUG, "updateScanoutTranche: sending a scanout tranche");
struct wl_array deviceArr = { struct wl_array deviceArr = {
.size = sizeof(m_mainDevice), .size = sizeof(m_mainDevice),

View file

@ -63,7 +63,7 @@ void CLockNotifyProtocol::onGetNotification(CHyprlandLockNotifierV1* pMgr, uint3
void CLockNotifyProtocol::onLocked() { void CLockNotifyProtocol::onLocked() {
if UNLIKELY (m_isLocked) { if UNLIKELY (m_isLocked) {
LOGM(ERR, "Not sending lock notification. Already locked!"); LOGM(Log::ERR, "Not sending lock notification. Already locked!");
return; return;
} }
@ -76,7 +76,7 @@ void CLockNotifyProtocol::onLocked() {
void CLockNotifyProtocol::onUnlocked() { void CLockNotifyProtocol::onUnlocked() {
if UNLIKELY (!m_isLocked) { if UNLIKELY (!m_isLocked) {
LOGM(ERR, "Not sending unlock notification. Not locked!"); LOGM(Log::ERR, "Not sending unlock notification. Not locked!");
return; return;
} }

View file

@ -6,9 +6,9 @@
#include "../render/OpenGL.hpp" #include "../render/OpenGL.hpp"
CMesaDRMBufferResource::CMesaDRMBufferResource(uint32_t id, wl_client* client, Aquamarine::SDMABUFAttrs attrs_) { CMesaDRMBufferResource::CMesaDRMBufferResource(uint32_t id, wl_client* client, Aquamarine::SDMABUFAttrs attrs_) {
LOGM(LOG, "Creating a Mesa dmabuf, with id {}: size {}, fmt {}, planes {}", id, attrs_.size, attrs_.format, attrs_.planes); LOGM(Log::DEBUG, "Creating a Mesa dmabuf, with id {}: size {}, fmt {}, planes {}", id, attrs_.size, attrs_.format, attrs_.planes);
for (int i = 0; i < attrs_.planes; ++i) { for (int i = 0; i < attrs_.planes; ++i) {
LOGM(LOG, " | plane {}: mod {} fd {} stride {} offset {}", i, attrs_.modifier, attrs_.fds[i], attrs_.strides[i], attrs_.offsets[i]); LOGM(Log::DEBUG, " | plane {}: mod {} fd {} stride {} offset {}", i, attrs_.modifier, attrs_.fds[i], attrs_.strides[i], attrs_.offsets[i]);
} }
m_buffer = makeShared<CDMABuffer>(id, client, attrs_); m_buffer = makeShared<CDMABuffer>(id, client, attrs_);
@ -20,7 +20,7 @@ CMesaDRMBufferResource::CMesaDRMBufferResource(uint32_t id, wl_client* client, A
}); });
if (!m_buffer->m_success) if (!m_buffer->m_success)
LOGM(ERR, "Possibly compositor bug: buffer failed to create"); LOGM(Log::ERR, "Possibly compositor bug: buffer failed to create");
} }
CMesaDRMBufferResource::~CMesaDRMBufferResource() { CMesaDRMBufferResource::~CMesaDRMBufferResource() {
@ -116,7 +116,7 @@ CMesaDRMProtocol::CMesaDRMProtocol(const wl_interface* iface, const int& ver, co
int drmFD = g_pCompositor->m_drmRenderNode.fd >= 0 ? g_pCompositor->m_drmRenderNode.fd : g_pCompositor->m_drm.fd; int drmFD = g_pCompositor->m_drmRenderNode.fd >= 0 ? g_pCompositor->m_drmRenderNode.fd : g_pCompositor->m_drm.fd;
if (drmGetDevice2(drmFD, 0, &dev) != 0) { if (drmGetDevice2(drmFD, 0, &dev) != 0) {
LOGM(ERR, "Failed to get device from fd {}, disabling MesaDRM", drmFD); LOGM(Log::ERR, "Failed to get device from fd {}, disabling MesaDRM", drmFD);
removeGlobal(); removeGlobal();
return; return;
} }
@ -124,10 +124,10 @@ CMesaDRMProtocol::CMesaDRMProtocol(const wl_interface* iface, const int& ver, co
if (dev->available_nodes & (1 << DRM_NODE_RENDER) && dev->nodes[DRM_NODE_RENDER]) { if (dev->available_nodes & (1 << DRM_NODE_RENDER) && dev->nodes[DRM_NODE_RENDER]) {
m_nodeName = dev->nodes[DRM_NODE_RENDER]; m_nodeName = dev->nodes[DRM_NODE_RENDER];
} else if (dev->available_nodes & (1 << DRM_NODE_PRIMARY) && dev->nodes[DRM_NODE_PRIMARY]) { } else if (dev->available_nodes & (1 << DRM_NODE_PRIMARY) && dev->nodes[DRM_NODE_PRIMARY]) {
LOGM(WARN, "No DRM render node, falling back to primary {}", dev->nodes[DRM_NODE_PRIMARY]); LOGM(Log::WARN, "No DRM render node, falling back to primary {}", dev->nodes[DRM_NODE_PRIMARY]);
m_nodeName = dev->nodes[DRM_NODE_PRIMARY]; m_nodeName = dev->nodes[DRM_NODE_PRIMARY];
} else { } else {
LOGM(ERR, "No usable DRM node (render or primary) found, disabling MesaDRM"); LOGM(Log::ERR, "No usable DRM node (render or primary) found, disabling MesaDRM");
drmFreeDevice(&dev); drmFreeDevice(&dev);
removeGlobal(); removeGlobal();
return; return;

View file

@ -11,14 +11,14 @@ COutputManager::COutputManager(SP<CZwlrOutputManagerV1> resource_) : m_resource(
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
LOGM(LOG, "New OutputManager registered"); LOGM(Log::DEBUG, "New OutputManager registered");
m_resource->setOnDestroy([this](CZwlrOutputManagerV1* r) { PROTO::outputManagement->destroyResource(this); }); m_resource->setOnDestroy([this](CZwlrOutputManagerV1* r) { PROTO::outputManagement->destroyResource(this); });
m_resource->setStop([this](CZwlrOutputManagerV1* r) { m_stopped = true; }); m_resource->setStop([this](CZwlrOutputManagerV1* r) { m_stopped = true; });
m_resource->setCreateConfiguration([this](CZwlrOutputManagerV1* r, uint32_t id, uint32_t serial) { m_resource->setCreateConfiguration([this](CZwlrOutputManagerV1* r, uint32_t id, uint32_t serial) {
LOGM(LOG, "Creating new configuration"); LOGM(Log::DEBUG, "Creating new configuration");
const auto RESOURCE = PROTO::outputManagement->m_configurations.emplace_back( const auto RESOURCE = PROTO::outputManagement->m_configurations.emplace_back(
makeShared<COutputConfiguration>(makeShared<CZwlrOutputConfigurationV1>(m_resource->client(), m_resource->version(), id), m_self.lock())); makeShared<COutputConfiguration>(makeShared<CZwlrOutputConfigurationV1>(m_resource->client(), m_resource->version(), id), m_self.lock()));
@ -37,7 +37,7 @@ COutputManager::COutputManager(SP<CZwlrOutputManagerV1> resource_) : m_resource(
if (m == g_pCompositor->m_unsafeOutput) if (m == g_pCompositor->m_unsafeOutput)
continue; continue;
LOGM(LOG, " | sending output head for {}", m->m_name); LOGM(Log::DEBUG, " | sending output head for {}", m->m_name);
makeAndSendNewHead(m); makeAndSendNewHead(m);
} }
@ -171,9 +171,9 @@ void COutputHead::sendAllData() {
if (m->m_mode == m_monitor->m_output->state->state().mode) { if (m->m_mode == m_monitor->m_output->state->state().mode) {
if (m->m_mode) if (m->m_mode)
LOGM(LOG, " | sending current mode for {}: {}x{}@{}", m_monitor->m_name, m->m_mode->pixelSize.x, m->m_mode->pixelSize.y, m->m_mode->refreshRate); LOGM(Log::DEBUG, " | sending current mode for {}: {}x{}@{}", m_monitor->m_name, m->m_mode->pixelSize.x, m->m_mode->pixelSize.y, m->m_mode->refreshRate);
else else
LOGM(LOG, " | sending current mode for {}: null (fake)", m_monitor->m_name); LOGM(Log::DEBUG, " | sending current mode for {}: null (fake)", m_monitor->m_name);
m_resource->sendCurrentMode(m->m_resource.get()); m_resource->sendCurrentMode(m->m_resource.get());
break; break;
} }
@ -202,9 +202,9 @@ void COutputHead::updateMode() {
if (m->m_mode == m_monitor->m_currentMode) { if (m->m_mode == m_monitor->m_currentMode) {
if (m->m_mode) if (m->m_mode)
LOGM(LOG, " | sending current mode for {}: {}x{}@{}", m_monitor->m_name, m->m_mode->pixelSize.x, m->m_mode->pixelSize.y, m->m_mode->refreshRate); LOGM(Log::DEBUG, " | sending current mode for {}: {}x{}@{}", m_monitor->m_name, m->m_mode->pixelSize.x, m->m_mode->pixelSize.y, m->m_mode->refreshRate);
else else
LOGM(LOG, " | sending current mode for {}: null (fake)", m_monitor->m_name); LOGM(Log::DEBUG, " | sending current mode for {}: null (fake)", m_monitor->m_name);
m_resource->sendCurrentMode(m->m_resource.get()); m_resource->sendCurrentMode(m->m_resource.get());
break; break;
} }
@ -243,7 +243,7 @@ void COutputMode::sendAllData() {
if (!m_mode) if (!m_mode)
return; return;
LOGM(LOG, " | sending mode {}x{}@{}mHz, pref: {}", m_mode->pixelSize.x, m_mode->pixelSize.y, m_mode->refreshRate, m_mode->preferred); LOGM(Log::DEBUG, " | sending mode {}x{}@{}mHz, pref: {}", m_mode->pixelSize.x, m_mode->pixelSize.y, m_mode->refreshRate, m_mode->preferred);
m_resource->sendSize(m_mode->pixelSize.x, m_mode->pixelSize.y); m_resource->sendSize(m_mode->pixelSize.x, m_mode->pixelSize.y);
if (m_mode->refreshRate > 0) if (m_mode->refreshRate > 0)
@ -271,14 +271,14 @@ COutputConfiguration::COutputConfiguration(SP<CZwlrOutputConfigurationV1> resour
const auto HEAD = PROTO::outputManagement->headFromResource(outputHead); const auto HEAD = PROTO::outputManagement->headFromResource(outputHead);
if (!HEAD) { if (!HEAD) {
LOGM(ERR, "No head in setEnableHead??"); LOGM(Log::ERR, "No head in setEnableHead??");
return; return;
} }
const auto PMONITOR = HEAD->monitor(); const auto PMONITOR = HEAD->monitor();
if (!PMONITOR) { if (!PMONITOR) {
LOGM(ERR, "No monitor in setEnableHead??"); LOGM(Log::ERR, "No monitor in setEnableHead??");
return; return;
} }
@ -293,25 +293,25 @@ COutputConfiguration::COutputConfiguration(SP<CZwlrOutputConfigurationV1> resour
m_heads.emplace_back(RESOURCE); m_heads.emplace_back(RESOURCE);
LOGM(LOG, "enableHead on {}. For now, doing nothing. Waiting for apply().", PMONITOR->m_name); LOGM(Log::DEBUG, "enableHead on {}. For now, doing nothing. Waiting for apply().", PMONITOR->m_name);
}); });
m_resource->setDisableHead([this](CZwlrOutputConfigurationV1* r, wl_resource* outputHead) { m_resource->setDisableHead([this](CZwlrOutputConfigurationV1* r, wl_resource* outputHead) {
const auto HEAD = PROTO::outputManagement->headFromResource(outputHead); const auto HEAD = PROTO::outputManagement->headFromResource(outputHead);
if (!HEAD) { if (!HEAD) {
LOGM(ERR, "No head in setDisableHead??"); LOGM(Log::ERR, "No head in setDisableHead??");
return; return;
} }
const auto PMONITOR = HEAD->monitor(); const auto PMONITOR = HEAD->monitor();
if (!PMONITOR) { if (!PMONITOR) {
LOGM(ERR, "No monitor in setDisableHead??"); LOGM(Log::ERR, "No monitor in setDisableHead??");
return; return;
} }
LOGM(LOG, "disableHead on {}", PMONITOR->m_name); LOGM(Log::DEBUG, "disableHead on {}", PMONITOR->m_name);
SWlrManagerSavedOutputState newState; SWlrManagerSavedOutputState newState;
if (m_owner->m_monitorStates.contains(PMONITOR->m_name)) if (m_owner->m_monitorStates.contains(PMONITOR->m_name))
@ -351,14 +351,14 @@ bool COutputConfiguration::good() {
bool COutputConfiguration::applyTestConfiguration(bool test) { bool COutputConfiguration::applyTestConfiguration(bool test) {
if (test) { if (test) {
LOGM(WARN, "TODO: STUB: applyTestConfiguration for test not implemented, returning true."); LOGM(Log::WARN, "TODO: STUB: applyTestConfiguration for test not implemented, returning true.");
return true; return true;
} }
LOGM(LOG, "Applying configuration"); LOGM(Log::DEBUG, "Applying configuration");
if (!m_owner) { if (!m_owner) {
LOGM(ERR, "applyTestConfiguration: no owner?!"); LOGM(Log::ERR, "applyTestConfiguration: no owner?!");
return false; return false;
} }
@ -373,7 +373,7 @@ bool COutputConfiguration::applyTestConfiguration(bool test) {
if (!PMONITOR) if (!PMONITOR)
continue; continue;
LOGM(LOG, "Saving config for monitor {}", PMONITOR->m_name); LOGM(Log::DEBUG, "Saving config for monitor {}", PMONITOR->m_name);
SWlrManagerSavedOutputState newState; SWlrManagerSavedOutputState newState;
if (m_owner->m_monitorStates.contains(PMONITOR->m_name)) if (m_owner->m_monitorStates.contains(PMONITOR->m_name))
@ -385,36 +385,36 @@ bool COutputConfiguration::applyTestConfiguration(bool test) {
newState.resolution = head->m_state.mode->getMode()->pixelSize; newState.resolution = head->m_state.mode->getMode()->pixelSize;
newState.refresh = head->m_state.mode->getMode()->refreshRate; newState.refresh = head->m_state.mode->getMode()->refreshRate;
newState.committedProperties |= eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_MODE; newState.committedProperties |= eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_MODE;
LOGM(LOG, " > Mode: {:.0f}x{:.0f}@{}mHz", newState.resolution.x, newState.resolution.y, newState.refresh); LOGM(Log::DEBUG, " > Mode: {:.0f}x{:.0f}@{}mHz", newState.resolution.x, newState.resolution.y, newState.refresh);
} else if (head->m_state.committedProperties & eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_CUSTOM_MODE) { } else if (head->m_state.committedProperties & eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_CUSTOM_MODE) {
newState.resolution = head->m_state.customMode.size; newState.resolution = head->m_state.customMode.size;
newState.refresh = head->m_state.customMode.refresh; newState.refresh = head->m_state.customMode.refresh;
newState.committedProperties |= eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_CUSTOM_MODE; newState.committedProperties |= eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_CUSTOM_MODE;
LOGM(LOG, " > Custom mode: {:.0f}x{:.0f}@{}mHz", newState.resolution.x, newState.resolution.y, newState.refresh); LOGM(Log::DEBUG, " > Custom mode: {:.0f}x{:.0f}@{}mHz", newState.resolution.x, newState.resolution.y, newState.refresh);
} }
if (head->m_state.committedProperties & eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_POSITION) { if (head->m_state.committedProperties & eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_POSITION) {
newState.position = head->m_state.position; newState.position = head->m_state.position;
newState.committedProperties |= eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_POSITION; newState.committedProperties |= eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_POSITION;
LOGM(LOG, " > Position: {:.0f}, {:.0f}", head->m_state.position.x, head->m_state.position.y); LOGM(Log::DEBUG, " > Position: {:.0f}, {:.0f}", head->m_state.position.x, head->m_state.position.y);
} }
if (head->m_state.committedProperties & eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_ADAPTIVE_SYNC) { if (head->m_state.committedProperties & eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_ADAPTIVE_SYNC) {
newState.adaptiveSync = head->m_state.adaptiveSync; newState.adaptiveSync = head->m_state.adaptiveSync;
newState.committedProperties |= eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_ADAPTIVE_SYNC; newState.committedProperties |= eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_ADAPTIVE_SYNC;
LOGM(LOG, " > vrr: {}", newState.adaptiveSync); LOGM(Log::DEBUG, " > vrr: {}", newState.adaptiveSync);
} }
if (head->m_state.committedProperties & eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_SCALE) { if (head->m_state.committedProperties & eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_SCALE) {
newState.scale = head->m_state.scale; newState.scale = head->m_state.scale;
newState.committedProperties |= eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_SCALE; newState.committedProperties |= eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_SCALE;
LOGM(LOG, " > scale: {:.2f}", newState.scale); LOGM(Log::DEBUG, " > scale: {:.2f}", newState.scale);
} }
if (head->m_state.committedProperties & eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_TRANSFORM) { if (head->m_state.committedProperties & eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_TRANSFORM) {
newState.transform = head->m_state.transform; newState.transform = head->m_state.transform;
newState.committedProperties |= eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_TRANSFORM; newState.committedProperties |= eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_TRANSFORM;
LOGM(LOG, " > transform: {}", (uint8_t)newState.transform); LOGM(Log::DEBUG, " > transform: {}", (uint8_t)newState.transform);
} }
// reset properties for next set. // reset properties for next set.
@ -425,7 +425,7 @@ bool COutputConfiguration::applyTestConfiguration(bool test) {
m_owner->m_monitorStates[PMONITOR->m_name] = newState; m_owner->m_monitorStates[PMONITOR->m_name] = newState;
} }
LOGM(LOG, "Saved configuration"); LOGM(Log::DEBUG, "Saved configuration");
return true; return true;
} }
@ -440,12 +440,12 @@ COutputConfigurationHead::COutputConfigurationHead(SP<CZwlrOutputConfigurationHe
const auto MODE = PROTO::outputManagement->modeFromResource(outputMode); const auto MODE = PROTO::outputManagement->modeFromResource(outputMode);
if (!MODE || !MODE->getMode()) { if (!MODE || !MODE->getMode()) {
LOGM(ERR, "No mode in setMode??"); LOGM(Log::ERR, "No mode in setMode??");
return; return;
} }
if (!m_monitor) { if (!m_monitor) {
LOGM(ERR, "setMode on inert resource"); LOGM(Log::ERR, "setMode on inert resource");
return; return;
} }
@ -457,12 +457,12 @@ COutputConfigurationHead::COutputConfigurationHead(SP<CZwlrOutputConfigurationHe
m_state.committedProperties |= OUTPUT_HEAD_COMMITTED_MODE; m_state.committedProperties |= OUTPUT_HEAD_COMMITTED_MODE;
m_state.mode = MODE; m_state.mode = MODE;
LOGM(LOG, " | configHead for {}: set mode to {}x{}@{}", m_monitor->m_name, MODE->getMode()->pixelSize.x, MODE->getMode()->pixelSize.y, MODE->getMode()->refreshRate); LOGM(Log::DEBUG, " | configHead for {}: set mode to {}x{}@{}", m_monitor->m_name, MODE->getMode()->pixelSize.x, MODE->getMode()->pixelSize.y, MODE->getMode()->refreshRate);
}); });
m_resource->setSetCustomMode([this](CZwlrOutputConfigurationHeadV1* r, int32_t w, int32_t h, int32_t refresh) { m_resource->setSetCustomMode([this](CZwlrOutputConfigurationHeadV1* r, int32_t w, int32_t h, int32_t refresh) {
if (!m_monitor) { if (!m_monitor) {
LOGM(ERR, "setCustomMode on inert resource"); LOGM(Log::ERR, "setCustomMode on inert resource");
return; return;
} }
@ -477,19 +477,19 @@ COutputConfigurationHead::COutputConfigurationHead(SP<CZwlrOutputConfigurationHe
} }
if (refresh == 0) { if (refresh == 0) {
LOGM(LOG, " | configHead for {}: refreshRate 0, using old refresh rate of {:.2f}Hz", m_monitor->m_name, m_monitor->m_refreshRate); LOGM(Log::DEBUG, " | configHead for {}: refreshRate 0, using old refresh rate of {:.2f}Hz", m_monitor->m_name, m_monitor->m_refreshRate);
refresh = std::round(m_monitor->m_refreshRate * 1000.F); refresh = std::round(m_monitor->m_refreshRate * 1000.F);
} }
m_state.committedProperties |= OUTPUT_HEAD_COMMITTED_CUSTOM_MODE; m_state.committedProperties |= OUTPUT_HEAD_COMMITTED_CUSTOM_MODE;
m_state.customMode = {{w, h}, sc<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::DEBUG, " | configHead for {}: set custom mode to {}x{}@{}", m_monitor->m_name, w, h, refresh);
}); });
m_resource->setSetPosition([this](CZwlrOutputConfigurationHeadV1* r, int32_t x, int32_t y) { m_resource->setSetPosition([this](CZwlrOutputConfigurationHeadV1* r, int32_t x, int32_t y) {
if (!m_monitor) { if (!m_monitor) {
LOGM(ERR, "setMode on inert resource"); LOGM(Log::ERR, "setMode on inert resource");
return; return;
} }
@ -501,12 +501,12 @@ COutputConfigurationHead::COutputConfigurationHead(SP<CZwlrOutputConfigurationHe
m_state.committedProperties |= OUTPUT_HEAD_COMMITTED_POSITION; m_state.committedProperties |= OUTPUT_HEAD_COMMITTED_POSITION;
m_state.position = {x, y}; m_state.position = {x, y};
LOGM(LOG, " | configHead for {}: set pos to {}, {}", m_monitor->m_name, x, y); LOGM(Log::DEBUG, " | configHead for {}: set pos to {}, {}", m_monitor->m_name, x, y);
}); });
m_resource->setSetTransform([this](CZwlrOutputConfigurationHeadV1* r, int32_t transform) { m_resource->setSetTransform([this](CZwlrOutputConfigurationHeadV1* r, int32_t transform) {
if (!m_monitor) { if (!m_monitor) {
LOGM(ERR, "setMode on inert resource"); LOGM(Log::ERR, "setMode on inert resource");
return; return;
} }
@ -523,12 +523,12 @@ COutputConfigurationHead::COutputConfigurationHead(SP<CZwlrOutputConfigurationHe
m_state.committedProperties |= OUTPUT_HEAD_COMMITTED_TRANSFORM; m_state.committedProperties |= OUTPUT_HEAD_COMMITTED_TRANSFORM;
m_state.transform = sc<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::DEBUG, " | configHead for {}: set transform to {}", m_monitor->m_name, transform);
}); });
m_resource->setSetScale([this](CZwlrOutputConfigurationHeadV1* r, wl_fixed_t scale_) { m_resource->setSetScale([this](CZwlrOutputConfigurationHeadV1* r, wl_fixed_t scale_) {
if (!m_monitor) { if (!m_monitor) {
LOGM(ERR, "setMode on inert resource"); LOGM(Log::ERR, "setMode on inert resource");
return; return;
} }
@ -547,12 +547,12 @@ COutputConfigurationHead::COutputConfigurationHead(SP<CZwlrOutputConfigurationHe
m_state.committedProperties |= OUTPUT_HEAD_COMMITTED_SCALE; m_state.committedProperties |= OUTPUT_HEAD_COMMITTED_SCALE;
m_state.scale = scale; m_state.scale = scale;
LOGM(LOG, " | configHead for {}: set scale to {:.2f}", m_monitor->m_name, scale); LOGM(Log::DEBUG, " | configHead for {}: set scale to {:.2f}", m_monitor->m_name, scale);
}); });
m_resource->setSetAdaptiveSync([this](CZwlrOutputConfigurationHeadV1* r, uint32_t as) { m_resource->setSetAdaptiveSync([this](CZwlrOutputConfigurationHeadV1* r, uint32_t as) {
if (!m_monitor) { if (!m_monitor) {
LOGM(ERR, "setMode on inert resource"); LOGM(Log::ERR, "setMode on inert resource");
return; return;
} }
@ -569,7 +569,7 @@ COutputConfigurationHead::COutputConfigurationHead(SP<CZwlrOutputConfigurationHe
m_state.committedProperties |= OUTPUT_HEAD_COMMITTED_ADAPTIVE_SYNC; m_state.committedProperties |= OUTPUT_HEAD_COMMITTED_ADAPTIVE_SYNC;
m_state.adaptiveSync = as; m_state.adaptiveSync = as;
LOGM(LOG, " | configHead for {}: set adaptiveSync to {}", m_monitor->m_name, as); LOGM(Log::DEBUG, " | configHead for {}: set adaptiveSync to {}", m_monitor->m_name, as);
}); });
} }
@ -657,7 +657,7 @@ void COutputManagementProtocol::sendPendingSuccessEvents() {
if (m_pendingConfigurationSuccessEvents.empty()) if (m_pendingConfigurationSuccessEvents.empty())
return; return;
LOGM(LOG, "Sending {} pending configuration success events", m_pendingConfigurationSuccessEvents.size()); LOGM(Log::DEBUG, "Sending {} pending configuration success events", m_pendingConfigurationSuccessEvents.size());
for (auto const& config : m_pendingConfigurationSuccessEvents) { for (auto const& config : m_pendingConfigurationSuccessEvents) {
if (!config) if (!config)

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