mirror of
				https://github.com/hyprwm/hyprland-plugins.git
				synced 2025-10-30 04:12:43 +00:00 
			
		
		
		
	all: chase hyprland
This commit is contained in:
		
							parent
							
								
									067bbc9eab
								
							
						
					
					
						commit
						8a29b42dbe
					
				
							
								
								
									
										19
									
								
								hyprbars/BarPassElement.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								hyprbars/BarPassElement.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,19 @@ | ||||
| #include "BarPassElement.hpp" | ||||
| #include <hyprland/src/render/OpenGL.hpp> | ||||
| #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; | ||||
| } | ||||
							
								
								
									
										26
									
								
								hyprbars/BarPassElement.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								hyprbars/BarPassElement.hpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,26 @@ | ||||
| #pragma once | ||||
| #include <hyprland/src/render/pass/PassElement.hpp> | ||||
| 
 | ||||
| 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; | ||||
| }; | ||||
| @ -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) | ||||
|  | ||||
| @ -4,9 +4,11 @@ | ||||
| #include <hyprland/src/desktop/Window.hpp> | ||||
| #include <hyprland/src/helpers/MiscFunctions.hpp> | ||||
| #include <hyprland/src/managers/SeatManager.hpp> | ||||
| #include <hyprland/src/render/Renderer.hpp> | ||||
| #include <pango/pangocairo.h> | ||||
| 
 | ||||
| #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<CBarPassElement>(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(); | ||||
|  | ||||
| @ -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<CTexture> 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; | ||||
| }; | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
							
								
								
									
										33
									
								
								hyprexpo/OverviewPassElement.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								hyprexpo/OverviewPassElement.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,33 @@ | ||||
| #include "OverviewPassElement.hpp" | ||||
| #include <hyprland/src/render/OpenGL.hpp> | ||||
| #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<CBox> 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}; | ||||
| } | ||||
							
								
								
									
										20
									
								
								hyprexpo/OverviewPassElement.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								hyprexpo/OverviewPassElement.hpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,20 @@ | ||||
| #pragma once | ||||
| #include <hyprland/src/render/pass/PassElement.hpp> | ||||
| 
 | ||||
| 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<CBox> boundingBox(); | ||||
|     virtual CRegion             opaqueRegion(); | ||||
| 
 | ||||
|     virtual const char*         passName() { | ||||
|         return "COverviewPassElement"; | ||||
|     } | ||||
| }; | ||||
| @ -5,6 +5,7 @@ | ||||
| #include <hyprland/src/Compositor.hpp> | ||||
| #include <hyprland/src/config/ConfigValue.hpp> | ||||
| #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<COverviewPassElement>()); | ||||
| } | ||||
| 
 | ||||
| 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); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -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<COverview> g_pOverview; | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
							
								
								
									
										19
									
								
								hyprtrails/TrailPassElement.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								hyprtrails/TrailPassElement.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,19 @@ | ||||
| #include "TrailPassElement.hpp" | ||||
| #include <hyprland/src/render/OpenGL.hpp> | ||||
| #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; | ||||
| } | ||||
							
								
								
									
										26
									
								
								hyprtrails/TrailPassElement.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								hyprtrails/TrailPassElement.hpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,26 @@ | ||||
| #pragma once | ||||
| #include <hyprland/src/render/pass/PassElement.hpp> | ||||
| 
 | ||||
| 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; | ||||
| }; | ||||
| @ -2,8 +2,10 @@ | ||||
| 
 | ||||
| #include <hyprland/src/Compositor.hpp> | ||||
| #include <hyprland/src/desktop/Window.hpp> | ||||
| #include <hyprland/src/render/Renderer.hpp> | ||||
| 
 | ||||
| #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<CTrailPassElement>(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(); | ||||
|  | ||||
| @ -48,6 +48,7 @@ class CTrail : public IHyprWindowDecoration { | ||||
|   private: | ||||
|     SP<HOOK_CALLBACK_FN>                                              pTickCb; | ||||
|     void                                                              onTick(); | ||||
|     void                                                              renderPass(PHLMONITOR pMonitor, const float& a); | ||||
| 
 | ||||
|     std::deque<std::pair<box, std::chrono::system_clock::time_point>> m_dLastGeoms; | ||||
| 
 | ||||
| @ -62,4 +63,6 @@ class CTrail : public IHyprWindowDecoration { | ||||
| 
 | ||||
|     CBox                                                              m_bLastBox     = {0}; | ||||
|     bool                                                              m_bNeedsDamage = false; | ||||
| 
 | ||||
|     friend class CTrailPassElement; | ||||
| }; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user