From 3785defaf12b9d99137b2f4c74ab82c51cf733e1 Mon Sep 17 00:00:00 2001 From: memchr <118117622+memchr@users.noreply.github.com> Date: Wed, 20 Sep 2023 15:25:03 +0000 Subject: logging: implement std::formatter for some types (#3380) --- src/layout/MasterLayout.hpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/layout/MasterLayout.hpp') 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 +struct std::formatter : std::formatter { + template + 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 -- cgit v1.2.3