From 3cd8d37a5d934c822546a7aa80c13ebe3b05642c Mon Sep 17 00:00:00 2001 From: vaxerski Date: Wed, 25 Dec 2024 15:58:23 +0100 Subject: [PATCH] borderspp: chase hyprland --- borders-plus-plus/BorderppPassElement.cpp | 19 +++++++++++++++++ borders-plus-plus/BorderppPassElement.hpp | 26 +++++++++++++++++++++++ borders-plus-plus/Makefile | 2 +- borders-plus-plus/borderDeco.cpp | 11 ++++++++++ borders-plus-plus/borderDeco.hpp | 4 ++++ 5 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 borders-plus-plus/BorderppPassElement.cpp create mode 100644 borders-plus-plus/BorderppPassElement.hpp diff --git a/borders-plus-plus/BorderppPassElement.cpp b/borders-plus-plus/BorderppPassElement.cpp new file mode 100644 index 0000000..5db20d2 --- /dev/null +++ b/borders-plus-plus/BorderppPassElement.cpp @@ -0,0 +1,19 @@ +#include "BorderppPassElement.hpp" +#include +#include "borderDeco.hpp" + +CBorderPPPassElement::CBorderPPPassElement(const CBorderPPPassElement::SBorderPPData& data_) : data(data_) { + ; +} + +void CBorderPPPassElement::draw(const CRegion& damage) { + data.deco->drawPass(g_pHyprOpenGL->m_RenderData.pMonitor.lock(), data.a); +} + +bool CBorderPPPassElement::needsLiveBlur() { + return false; +} + +bool CBorderPPPassElement::needsPrecomputeBlur() { + return false; +} \ No newline at end of file diff --git a/borders-plus-plus/BorderppPassElement.hpp b/borders-plus-plus/BorderppPassElement.hpp new file mode 100644 index 0000000..12b858a --- /dev/null +++ b/borders-plus-plus/BorderppPassElement.hpp @@ -0,0 +1,26 @@ +#pragma once +#include + +class CBordersPlusPlus; + +class CBorderPPPassElement : public IPassElement { + public: + struct SBorderPPData { + CBordersPlusPlus* deco = nullptr; + float a = 1.F; + }; + + CBorderPPPassElement(const SBorderPPData& data_); + virtual ~CBorderPPPassElement() = default; + + virtual void draw(const CRegion& damage); + virtual bool needsLiveBlur(); + virtual bool needsPrecomputeBlur(); + + virtual const char* passName() { + return "CBorderPPPassElement"; + } + + private: + SBorderPPData data; +}; \ No newline at end of file diff --git a/borders-plus-plus/Makefile b/borders-plus-plus/Makefile index a1d6152..a04affc 100644 --- a/borders-plus-plus/Makefile +++ b/borders-plus-plus/Makefile @@ -1,4 +1,4 @@ all: - $(CXX) -shared -fPIC --no-gnu-unique main.cpp borderDeco.cpp -o borders-plus-plus.so -g `pkg-config --cflags pixman-1 libdrm hyprland pangocairo libinput libudev wayland-server xkbcommon` -std=c++2b -O2 + $(CXX) -shared -fPIC --no-gnu-unique main.cpp borderDeco.cpp BorderppPassElement.cpp -o borders-plus-plus.so -g `pkg-config --cflags pixman-1 libdrm hyprland pangocairo libinput libudev wayland-server xkbcommon` -std=c++2b -O2 clean: rm ./borders-plus-plus.so diff --git a/borders-plus-plus/borderDeco.cpp b/borders-plus-plus/borderDeco.cpp index 5a5631d..45d99aa 100644 --- a/borders-plus-plus/borderDeco.cpp +++ b/borders-plus-plus/borderDeco.cpp @@ -2,7 +2,9 @@ #include #include +#include +#include "BorderppPassElement.hpp" #include "globals.hpp" CBordersPlusPlus::CBordersPlusPlus(PHLWINDOW pWindow) : IHyprWindowDecoration(pWindow), m_pWindow(pWindow) { @@ -68,6 +70,15 @@ void CBordersPlusPlus::draw(PHLMONITOR pMonitor, const float& a) { if (!PWINDOW->m_sWindowData.decorate.valueOrDefault()) return; + CBorderPPPassElement::SBorderPPData data; + data.deco = this; + + g_pHyprRenderer->m_sRenderPass.add(makeShared(data)); +} + +void CBordersPlusPlus::drawPass(PHLMONITOR pMonitor, const float& a) { + const auto PWINDOW = m_pWindow.lock(); + static std::vector PCOLORS; static std::vector PSIZES; for (size_t i = 0; i < 9; ++i) { diff --git a/borders-plus-plus/borderDeco.hpp b/borders-plus-plus/borderDeco.hpp index 44f2f7e..8bfd390 100644 --- a/borders-plus-plus/borderDeco.hpp +++ b/borders-plus-plus/borderDeco.hpp @@ -28,6 +28,8 @@ class CBordersPlusPlus : public IHyprWindowDecoration { virtual std::string getDisplayName(); private: + void drawPass(PHLMONITOR, float const& a); + SBoxExtents m_seExtents; PHLWINDOWREF m_pWindow; @@ -39,4 +41,6 @@ class CBordersPlusPlus : public IHyprWindowDecoration { Vector2D m_vLastWindowSize; double m_fLastThickness = 0; + + friend class CBorderPPPassElement; };