From 8a29b42dbef823d3a0dfe6d0990f938ee6d3def8 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sun, 22 Dec 2024 16:33:07 +0000 Subject: [PATCH] all: chase hyprland --- hyprbars/BarPassElement.cpp | 19 ++++++++++++++++++ hyprbars/BarPassElement.hpp | 26 +++++++++++++++++++++++++ hyprbars/Makefile | 2 +- hyprbars/barDeco.cpp | 12 +++++++++++- hyprbars/barDeco.hpp | 3 +++ hyprexpo/Makefile | 2 +- hyprexpo/OverviewPassElement.cpp | 33 ++++++++++++++++++++++++++++++++ hyprexpo/OverviewPassElement.hpp | 20 +++++++++++++++++++ hyprexpo/overview.cpp | 6 +++++- hyprexpo/overview.hpp | 3 +++ hyprtrails/Makefile | 2 +- hyprtrails/TrailPassElement.cpp | 19 ++++++++++++++++++ hyprtrails/TrailPassElement.hpp | 26 +++++++++++++++++++++++++ hyprtrails/trail.cpp | 9 +++++++++ hyprtrails/trail.hpp | 3 +++ 15 files changed, 180 insertions(+), 5 deletions(-) create mode 100644 hyprbars/BarPassElement.cpp create mode 100644 hyprbars/BarPassElement.hpp create mode 100644 hyprexpo/OverviewPassElement.cpp create mode 100644 hyprexpo/OverviewPassElement.hpp create mode 100644 hyprtrails/TrailPassElement.cpp create mode 100644 hyprtrails/TrailPassElement.hpp diff --git a/hyprbars/BarPassElement.cpp b/hyprbars/BarPassElement.cpp new file mode 100644 index 0000000..c353a30 --- /dev/null +++ b/hyprbars/BarPassElement.cpp @@ -0,0 +1,19 @@ +#include "BarPassElement.hpp" +#include +#include "barDeco.hpp" + +CBarPassElement::CBarPassElement(const CBarPassElement::SBarData& data_) : data(data_) { + ; +} + +void CBarPassElement::draw(const CRegion& damage) { + data.deco->renderPass(g_pHyprOpenGL->m_RenderData.pMonitor.lock(), data.a); +} + +bool CBarPassElement::needsLiveBlur() { + return false; +} + +bool CBarPassElement::needsPrecomputeBlur() { + return false; +} \ No newline at end of file diff --git a/hyprbars/BarPassElement.hpp b/hyprbars/BarPassElement.hpp new file mode 100644 index 0000000..eb72508 --- /dev/null +++ b/hyprbars/BarPassElement.hpp @@ -0,0 +1,26 @@ +#pragma once +#include + +class CHyprBar; + +class CBarPassElement : public IPassElement { + public: + struct SBarData { + CHyprBar* deco = nullptr; + float a = 1.F; + }; + + CBarPassElement(const SBarData& data_); + virtual ~CBarPassElement() = default; + + virtual void draw(const CRegion& damage); + virtual bool needsLiveBlur(); + virtual bool needsPrecomputeBlur(); + + virtual const char* passName() { + return "CBarPassElement"; + } + + private: + SBarData data; +}; \ No newline at end of file diff --git a/hyprbars/Makefile b/hyprbars/Makefile index 26d3414..c7a4f61 100644 --- a/hyprbars/Makefile +++ b/hyprbars/Makefile @@ -2,7 +2,7 @@ CXXFLAGS = -shared -fPIC --no-gnu-unique -g -std=c++2b -Wno-c++11-narrowing INCLUDES = `pkg-config --cflags pixman-1 libdrm hyprland pangocairo libinput libudev wayland-server xkbcommon` LIBS = `pkg-config --libs pangocairo` -SRC = main.cpp barDeco.cpp +SRC = main.cpp barDeco.cpp BarPassElement.cpp TARGET = hyprbars.so all: $(TARGET) diff --git a/hyprbars/barDeco.cpp b/hyprbars/barDeco.cpp index a2ce012..099b061 100644 --- a/hyprbars/barDeco.cpp +++ b/hyprbars/barDeco.cpp @@ -4,9 +4,11 @@ #include #include #include +#include #include #include "globals.hpp" +#include "BarPassElement.hpp" CHyprBar::CHyprBar(PHLWINDOW pWindow) : IHyprWindowDecoration(pWindow) { m_pWindow = pWindow; @@ -56,7 +58,8 @@ std::string CHyprBar::getDisplayName() { } void CHyprBar::onMouseDown(SCallbackInfo& info, IPointer::SButtonEvent e) { - if (!m_pWindow->m_pWorkspace->isVisible() || !g_pInputManager->m_dExclusiveLSes.empty() || (g_pSeatManager->seatGrab && !g_pSeatManager->seatGrab->accepts(m_pWindow->m_pWLSurface->resource()))) + if (!m_pWindow->m_pWorkspace->isVisible() || !g_pInputManager->m_dExclusiveLSes.empty() || + (g_pSeatManager->seatGrab && !g_pSeatManager->seatGrab->accepts(m_pWindow->m_pWLSurface->resource()))) return; const auto WINDOWATCURSOR = g_pCompositor->vectorToWindowUnified(g_pInputManager->getMouseCoordsInternal(), RESERVED_EXTENTS | INPUT_EXTENTS | ALLOW_FLOATING); @@ -399,6 +402,13 @@ void CHyprBar::draw(PHLMONITOR pMonitor, const float& a) { if (!PWINDOW->m_sWindowData.decorate.valueOrDefault()) return; + auto data = CBarPassElement::SBarData{this, a}; + g_pHyprRenderer->m_sRenderPass.add(makeShared(data)); +} + +void CHyprBar::renderPass(PHLMONITOR pMonitor, const float& a) { + const auto PWINDOW = m_pWindow.lock(); + static auto* const PCOLOR = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_color")->getDataStaticPtr(); static auto* const PHEIGHT = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_height")->getDataStaticPtr(); static auto* const PPRECEDENCE = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_precedence_over_border")->getDataStaticPtr(); diff --git a/hyprbars/barDeco.hpp b/hyprbars/barDeco.hpp index 070b1b1..bf36539 100644 --- a/hyprbars/barDeco.hpp +++ b/hyprbars/barDeco.hpp @@ -55,6 +55,7 @@ class CHyprBar : public IHyprWindowDecoration { Vector2D cursorRelativeToBar(); + void renderPass(PHLMONITOR, float const& a); void renderBarTitle(const Vector2D& bufferSize, const float scale); void renderText(SP out, const std::string& text, const CHyprColor& color, const Vector2D& bufferSize, const float scale, const int fontSize); void renderBarButtons(const Vector2D& bufferSize, const float scale); @@ -74,4 +75,6 @@ class CHyprBar : public IHyprWindowDecoration { // for dynamic updates int m_iLastHeight = 0; + + friend class CBarPassElement; }; diff --git a/hyprexpo/Makefile b/hyprexpo/Makefile index b75cf94..04472b0 100644 --- a/hyprexpo/Makefile +++ b/hyprexpo/Makefile @@ -1,4 +1,4 @@ all: - $(CXX) -shared -fPIC --no-gnu-unique main.cpp overview.cpp -o hyprexpo.so -g `pkg-config --cflags pixman-1 libdrm hyprland pangocairo libinput libudev wayland-server xkbcommon` -std=c++2b -Wno-narrowing + $(CXX) -shared -fPIC --no-gnu-unique main.cpp overview.cpp OverviewPassElement.cpp -o hyprexpo.so -g `pkg-config --cflags pixman-1 libdrm hyprland pangocairo libinput libudev wayland-server xkbcommon` -std=c++2b -Wno-narrowing clean: rm ./hyprexpo.so diff --git a/hyprexpo/OverviewPassElement.cpp b/hyprexpo/OverviewPassElement.cpp new file mode 100644 index 0000000..83e4f6b --- /dev/null +++ b/hyprexpo/OverviewPassElement.cpp @@ -0,0 +1,33 @@ +#include "OverviewPassElement.hpp" +#include +#include "overview.hpp" + +COverviewPassElement::COverviewPassElement() { + ; +} + +void COverviewPassElement::draw(const CRegion& damage) { + g_pOverview->fullRender(); +} + +bool COverviewPassElement::needsLiveBlur() { + return false; +} + +bool COverviewPassElement::needsPrecomputeBlur() { + return false; +} + +std::optional COverviewPassElement::boundingBox() { + if (!g_pOverview->pMonitor) + return std::nullopt; + + return CBox{{}, g_pOverview->pMonitor->vecSize}; +} + +CRegion COverviewPassElement::opaqueRegion() { + if (!g_pOverview->pMonitor) + return CRegion{}; + + return CBox{{}, g_pOverview->pMonitor->vecSize}; +} diff --git a/hyprexpo/OverviewPassElement.hpp b/hyprexpo/OverviewPassElement.hpp new file mode 100644 index 0000000..f9d5a37 --- /dev/null +++ b/hyprexpo/OverviewPassElement.hpp @@ -0,0 +1,20 @@ +#pragma once +#include + +class COverview; + +class COverviewPassElement : public IPassElement { + public: + COverviewPassElement(); + virtual ~COverviewPassElement() = default; + + virtual void draw(const CRegion& damage); + virtual bool needsLiveBlur(); + virtual bool needsPrecomputeBlur(); + virtual std::optional boundingBox(); + virtual CRegion opaqueRegion(); + + virtual const char* passName() { + return "COverviewPassElement"; + } +}; \ No newline at end of file diff --git a/hyprexpo/overview.cpp b/hyprexpo/overview.cpp index 4ad2648..f1a92db 100644 --- a/hyprexpo/overview.cpp +++ b/hyprexpo/overview.cpp @@ -5,6 +5,7 @@ #include #include #undef private +#include "OverviewPassElement.hpp" static void damageMonitor(void*) { g_pOverview->damage(); @@ -378,7 +379,10 @@ void COverview::onWorkspaceChange() { } void COverview::render() { + g_pHyprRenderer->m_sRenderPass.add(makeShared()); +} +void COverview::fullRender() { const auto GAPSIZE = (closing ? (1.0 - size.getPercent()) : size.getPercent()) * GAP_WIDTH; if (pMonitor->activeWorkspace != startedOn && !closing) { @@ -399,7 +403,7 @@ void COverview::render() { texbox.scale(pMonitor->scale).translate(pos.value()); texbox.round(); CRegion damage{0, 0, INT16_MAX, INT16_MAX}; - g_pHyprOpenGL->renderTextureInternalWithDamage(images[x + y * SIDE_LENGTH].fb.getTexture(), &texbox, 1.0, &damage); + g_pHyprOpenGL->renderTextureInternalWithDamage(images[x + y * SIDE_LENGTH].fb.getTexture(), &texbox, 1.0, damage); } } } diff --git a/hyprexpo/overview.hpp b/hyprexpo/overview.hpp index 2725fe9..c306044 100644 --- a/hyprexpo/overview.hpp +++ b/hyprexpo/overview.hpp @@ -40,6 +40,7 @@ class COverview { void redrawID(int id, bool forcelowres = false); void redrawAll(bool forcelowres = false); void onWorkspaceChange(); + void fullRender(); int SIDE_LENGTH = 3; int GAP_WIDTH = 5; @@ -75,6 +76,8 @@ class COverview { bool swipe = false; bool swipeWasCommenced = false; + + friend class COverviewPassElement; }; inline std::unique_ptr g_pOverview; diff --git a/hyprtrails/Makefile b/hyprtrails/Makefile index 8507b02..09f5cbd 100644 --- a/hyprtrails/Makefile +++ b/hyprtrails/Makefile @@ -1,4 +1,4 @@ all: - $(CXX) -shared -fPIC --no-gnu-unique main.cpp trail.cpp -o hyprtrails.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 trail.cpp TrailPassElement.cpp -o hyprtrails.so -g `pkg-config --cflags pixman-1 libdrm hyprland pangocairo libinput libudev wayland-server xkbcommon` -std=c++2b -O2 clean: rm ./hyprtrails.so diff --git a/hyprtrails/TrailPassElement.cpp b/hyprtrails/TrailPassElement.cpp new file mode 100644 index 0000000..ad3a25c --- /dev/null +++ b/hyprtrails/TrailPassElement.cpp @@ -0,0 +1,19 @@ +#include "TrailPassElement.hpp" +#include +#include "trail.hpp" + +CTrailPassElement::CTrailPassElement(const CTrailPassElement::STrailData& data_) : data(data_) { + ; +} + +void CTrailPassElement::draw(const CRegion& damage) { + data.deco->renderPass(g_pHyprOpenGL->m_RenderData.pMonitor.lock(), data.a); +} + +bool CTrailPassElement::needsLiveBlur() { + return false; +} + +bool CTrailPassElement::needsPrecomputeBlur() { + return false; +} \ No newline at end of file diff --git a/hyprtrails/TrailPassElement.hpp b/hyprtrails/TrailPassElement.hpp new file mode 100644 index 0000000..b9e998d --- /dev/null +++ b/hyprtrails/TrailPassElement.hpp @@ -0,0 +1,26 @@ +#pragma once +#include + +class CTrail; + +class CTrailPassElement : public IPassElement { + public: + struct STrailData { + CTrail* deco = nullptr; + float a = 1.F; + }; + + CTrailPassElement(const STrailData& data_); + virtual ~CTrailPassElement() = default; + + virtual void draw(const CRegion& damage); + virtual bool needsLiveBlur(); + virtual bool needsPrecomputeBlur(); + + virtual const char* passName() { + return "CTrailPassElement"; + } + + private: + STrailData data; +}; \ No newline at end of file diff --git a/hyprtrails/trail.cpp b/hyprtrails/trail.cpp index f600d32..7fdc51f 100644 --- a/hyprtrails/trail.cpp +++ b/hyprtrails/trail.cpp @@ -2,8 +2,10 @@ #include #include +#include #include "globals.hpp" +#include "TrailPassElement.hpp" void CTrail::onTick() { static auto* const PHISTORYSTEP = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprtrails:history_step")->getDataStaticPtr(); @@ -87,6 +89,13 @@ void CTrail::draw(PHLMONITOR pMonitor, const float& a) { if (!PWINDOW->m_sWindowData.decorate.valueOrDefault()) return; + auto data = CTrailPassElement::STrailData{this, a}; + g_pHyprRenderer->m_sRenderPass.add(makeShared(data)); +} + +void CTrail::renderPass(PHLMONITOR pMonitor, const float& a) { + const auto PWINDOW = m_pWindow.lock(); + static auto* const PBEZIERSTEP = (Hyprlang::FLOAT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprtrails:bezier_step")->getDataStaticPtr(); static auto* const PPOINTSPERSTEP = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprtrails:points_per_step")->getDataStaticPtr(); static auto* const PCOLOR = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprtrails:color")->getDataStaticPtr(); diff --git a/hyprtrails/trail.hpp b/hyprtrails/trail.hpp index bd4fcb1..bbc69c7 100644 --- a/hyprtrails/trail.hpp +++ b/hyprtrails/trail.hpp @@ -48,6 +48,7 @@ class CTrail : public IHyprWindowDecoration { private: SP pTickCb; void onTick(); + void renderPass(PHLMONITOR pMonitor, const float& a); std::deque> m_dLastGeoms; @@ -62,4 +63,6 @@ class CTrail : public IHyprWindowDecoration { CBox m_bLastBox = {0}; bool m_bNeedsDamage = false; + + friend class CTrailPassElement; };