summaryrefslogtreecommitdiff
path: root/src/layout
diff options
context:
space:
mode:
authormemchr <118117622+memchr@users.noreply.github.com>2023-09-20 15:25:03 +0000
committerGitHub <noreply@github.com>2023-09-20 16:25:03 +0100
commit3785defaf12b9d99137b2f4c74ab82c51cf733e1 (patch)
treec064adb3ec5eedd612bbc850976bc73ddbe7d15a /src/layout
parent6594b50e57935dd66930ccd35dba7a1b4131399d (diff)
logging: implement std::formatter for some types (#3380)
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/DwindleLayout.cpp7
-rw-r--r--src/layout/DwindleLayout.hpp17
-rw-r--r--src/layout/IHyprLayout.cpp2
-rw-r--r--src/layout/MasterLayout.cpp5
-rw-r--r--src/layout/MasterLayout.hpp23
5 files changed, 43 insertions, 11 deletions
diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp
index d92966ca..010cd6b4 100644
--- a/src/layout/DwindleLayout.cpp
+++ b/src/layout/DwindleLayout.cpp
@@ -1,4 +1,5 @@
#include "DwindleLayout.hpp"
+#include "../render/decorations/CHyprGroupBarDecoration.hpp"
#include "../Compositor.hpp"
void SDwindleNodeData::recalcSizePosRecursive(bool force, bool horizontalOverride, bool verticalOverride) {
@@ -104,7 +105,7 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
}
if (!PMONITOR) {
- Debug::log(ERR, "Orphaned Node {:x} (workspace ID: {})!!", (uintptr_t)pNode, pNode->workspaceID);
+ Debug::log(ERR, "Orphaned Node {}!!", pNode);
return;
}
@@ -129,7 +130,7 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
auto gapsOut = WORKSPACERULE.gapsOut.value_or(*PGAPSOUT);
if (!g_pCompositor->windowExists(PWINDOW) || !PWINDOW->m_bIsMapped) {
- Debug::log(ERR, "Node {:x} holding invalid window {:x}!!", (uintptr_t)pNode, (uintptr_t)PWINDOW);
+ Debug::log(ERR, "Node {} holding invalid {}!!", pNode, PWINDOW);
onWindowRemovedTiling(PWINDOW);
return;
}
@@ -273,7 +274,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection dire
} else
OPENINGON = getFirstNodeOnWorkspace(pWindow->m_iWorkspaceID);
- Debug::log(LOG, "OPENINGON: {:x}, Workspace: {}, Monitor: {}", (uintptr_t)OPENINGON, PNODE->workspaceID, PMONITOR->ID);
+ Debug::log(LOG, "OPENINGON: {}, Monitor: {}", OPENINGON, PMONITOR->ID);
if (OPENINGON && OPENINGON->workspaceID != PNODE->workspaceID) {
// special workspace handling
diff --git a/src/layout/DwindleLayout.hpp b/src/layout/DwindleLayout.hpp
index 66c117fc..993f8cb7 100644
--- a/src/layout/DwindleLayout.hpp
+++ b/src/layout/DwindleLayout.hpp
@@ -1,11 +1,12 @@
#pragma once
#include "IHyprLayout.hpp"
+
#include <list>
#include <deque>
-#include "../render/decorations/CHyprGroupBarDecoration.hpp"
#include <array>
#include <optional>
+#include <format>
class CHyprDwindleLayout;
enum eFullscreenMode : uint8_t;
@@ -85,3 +86,17 @@ class CHyprDwindleLayout : public IHyprLayout {
friend struct SDwindleNodeData;
};
+
+template <typename CharT>
+struct std::formatter<SDwindleNodeData*, CharT> : std::formatter<CharT> {
+ template <typename FormatContext>
+ auto format(const SDwindleNodeData* const& node, FormatContext& ctx) const {
+ auto out = ctx.out();
+ if (!node)
+ return std::format_to(out, "[Node nullptr]");
+ std::format_to(out, "[Node {:x}: workspace: {}, pos: {:j2}, size: {:j2}", (uintptr_t)node, node->workspaceID, node->position, node->size);
+ if (!node->isNode && node->pWindow)
+ std::format_to(out, ", window: {:x}", node->pWindow);
+ return std::format_to(out, "]");
+ }
+}; \ No newline at end of file
diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp
index 738b3a65..46883570 100644
--- a/src/layout/IHyprLayout.cpp
+++ b/src/layout/IHyprLayout.cpp
@@ -89,7 +89,7 @@ void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) {
static auto* const PXWLFORCESCALEZERO = &g_pConfigManager->getConfigValuePtr("xwayland:force_zero_scaling")->intValue;
if (!PMONITOR) {
- Debug::log(ERR, "Window {:x} ({}) has an invalid monitor in onWindowCreatedFloating!!!", (uintptr_t)pWindow, pWindow->m_szTitle);
+ Debug::log(ERR, "{:m} has an invalid monitor in onWindowCreatedFloating!!!", pWindow);
return;
}
diff --git a/src/layout/MasterLayout.cpp b/src/layout/MasterLayout.cpp
index d1b65e59..576397f6 100644
--- a/src/layout/MasterLayout.cpp
+++ b/src/layout/MasterLayout.cpp
@@ -1,5 +1,6 @@
#include "MasterLayout.hpp"
#include "../Compositor.hpp"
+#include "../render/decorations/CHyprGroupBarDecoration.hpp"
#include <ranges>
SMasterNodeData* CHyprMasterLayout::getNodeFromWindow(CWindow* pWindow) {
@@ -552,7 +553,7 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
}
if (!PMONITOR) {
- Debug::log(ERR, "Orphaned Node {:x} (workspace ID: {})!!", (uintptr_t)pNode, pNode->workspaceID);
+ Debug::log(ERR, "Orphaned Node {}!!", pNode);
return;
}
@@ -578,7 +579,7 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
auto gapsOut = WORKSPACERULE.gapsOut.value_or(*PGAPSOUT);
if (!g_pCompositor->windowValidMapped(PWINDOW)) {
- Debug::log(ERR, "Node {:x} holding invalid window {:x}!!", (uintptr_t)pNode, (uintptr_t)PWINDOW);
+ Debug::log(ERR, "Node {} holding invalid {}!!", pNode, PWINDOW);
return;
}
diff --git a/src/layout/MasterLayout.hpp b/src/layout/MasterLayout.hpp
index fd38b915..aa201505 100644
--- a/src/layout/MasterLayout.hpp
+++ b/src/layout/MasterLayout.hpp
@@ -10,8 +10,7 @@
enum eFullscreenMode : uint8_t;
//orientation determines which side of the screen the master area resides
-enum eOrientation : uint8_t
-{
+enum eOrientation : uint8_t {
ORIENTATION_LEFT = 0,
ORIENTATION_TOP,
ORIENTATION_RIGHT,
@@ -33,7 +32,7 @@ struct SMasterNodeData {
int workspaceID = -1;
bool operator==(const SMasterNodeData& rhs) const {
- return pWindow == rhs.pWindow;
+ return pWindow == rhs.pWindow;
}
};
@@ -42,7 +41,7 @@ struct SMasterWorkspaceData {
eOrientation orientation = ORIENTATION_LEFT;
bool operator==(const SMasterWorkspaceData& rhs) const {
- return workspaceID == rhs.workspaceID;
+ return workspaceID == rhs.workspaceID;
}
};
@@ -89,3 +88,19 @@ class CHyprMasterLayout : public IHyprLayout {
friend struct SMasterNodeData;
friend struct SMasterWorkspaceData;
};
+
+template <typename CharT>
+struct std::formatter<SMasterNodeData*, CharT> : std::formatter<CharT> {
+ template <typename FormatContext>
+ auto format(const SMasterNodeData* const& node, FormatContext& ctx) const {
+ auto out = ctx.out();
+ if (!node)
+ return std::format_to(out, "[Node nullptr]");
+ std::format_to(out, "[Node {:x}: workspace: {}, pos: {:j2}, size: {:j2}", (uintptr_t)node, node->workspaceID, node->position, node->size);
+ if (node->isMaster)
+ std::format_to(out, ", master");
+ if (node->pWindow)
+ std::format_to(out, ", window: {:x}", node->pWindow);
+ return std::format_to(out, "]");
+ }
+}; \ No newline at end of file