Skip to content

Commit 8a29b42

Browse files
committed
all: chase hyprland
1 parent 067bbc9 commit 8a29b42

File tree

15 files changed

+180
-5
lines changed

15 files changed

+180
-5
lines changed

hyprbars/BarPassElement.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include "BarPassElement.hpp"
2+
#include <hyprland/src/render/OpenGL.hpp>
3+
#include "barDeco.hpp"
4+
5+
CBarPassElement::CBarPassElement(const CBarPassElement::SBarData& data_) : data(data_) {
6+
;
7+
}
8+
9+
void CBarPassElement::draw(const CRegion& damage) {
10+
data.deco->renderPass(g_pHyprOpenGL->m_RenderData.pMonitor.lock(), data.a);
11+
}
12+
13+
bool CBarPassElement::needsLiveBlur() {
14+
return false;
15+
}
16+
17+
bool CBarPassElement::needsPrecomputeBlur() {
18+
return false;
19+
}

hyprbars/BarPassElement.hpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#pragma once
2+
#include <hyprland/src/render/pass/PassElement.hpp>
3+
4+
class CHyprBar;
5+
6+
class CBarPassElement : public IPassElement {
7+
public:
8+
struct SBarData {
9+
CHyprBar* deco = nullptr;
10+
float a = 1.F;
11+
};
12+
13+
CBarPassElement(const SBarData& data_);
14+
virtual ~CBarPassElement() = default;
15+
16+
virtual void draw(const CRegion& damage);
17+
virtual bool needsLiveBlur();
18+
virtual bool needsPrecomputeBlur();
19+
20+
virtual const char* passName() {
21+
return "CBarPassElement";
22+
}
23+
24+
private:
25+
SBarData data;
26+
};

hyprbars/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CXXFLAGS = -shared -fPIC --no-gnu-unique -g -std=c++2b -Wno-c++11-narrowing
22
INCLUDES = `pkg-config --cflags pixman-1 libdrm hyprland pangocairo libinput libudev wayland-server xkbcommon`
33
LIBS = `pkg-config --libs pangocairo`
44

5-
SRC = main.cpp barDeco.cpp
5+
SRC = main.cpp barDeco.cpp BarPassElement.cpp
66
TARGET = hyprbars.so
77

88
all: $(TARGET)

hyprbars/barDeco.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
#include <hyprland/src/desktop/Window.hpp>
55
#include <hyprland/src/helpers/MiscFunctions.hpp>
66
#include <hyprland/src/managers/SeatManager.hpp>
7+
#include <hyprland/src/render/Renderer.hpp>
78
#include <pango/pangocairo.h>
89

910
#include "globals.hpp"
11+
#include "BarPassElement.hpp"
1012

1113
CHyprBar::CHyprBar(PHLWINDOW pWindow) : IHyprWindowDecoration(pWindow) {
1214
m_pWindow = pWindow;
@@ -56,7 +58,8 @@ std::string CHyprBar::getDisplayName() {
5658
}
5759

5860
void CHyprBar::onMouseDown(SCallbackInfo& info, IPointer::SButtonEvent e) {
59-
if (!m_pWindow->m_pWorkspace->isVisible() || !g_pInputManager->m_dExclusiveLSes.empty() || (g_pSeatManager->seatGrab && !g_pSeatManager->seatGrab->accepts(m_pWindow->m_pWLSurface->resource())))
61+
if (!m_pWindow->m_pWorkspace->isVisible() || !g_pInputManager->m_dExclusiveLSes.empty() ||
62+
(g_pSeatManager->seatGrab && !g_pSeatManager->seatGrab->accepts(m_pWindow->m_pWLSurface->resource())))
6063
return;
6164

6265
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) {
399402
if (!PWINDOW->m_sWindowData.decorate.valueOrDefault())
400403
return;
401404

405+
auto data = CBarPassElement::SBarData{this, a};
406+
g_pHyprRenderer->m_sRenderPass.add(makeShared<CBarPassElement>(data));
407+
}
408+
409+
void CHyprBar::renderPass(PHLMONITOR pMonitor, const float& a) {
410+
const auto PWINDOW = m_pWindow.lock();
411+
402412
static auto* const PCOLOR = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_color")->getDataStaticPtr();
403413
static auto* const PHEIGHT = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_height")->getDataStaticPtr();
404414
static auto* const PPRECEDENCE = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_precedence_over_border")->getDataStaticPtr();

hyprbars/barDeco.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class CHyprBar : public IHyprWindowDecoration {
5555

5656
Vector2D cursorRelativeToBar();
5757

58+
void renderPass(PHLMONITOR, float const& a);
5859
void renderBarTitle(const Vector2D& bufferSize, const float scale);
5960
void renderText(SP<CTexture> out, const std::string& text, const CHyprColor& color, const Vector2D& bufferSize, const float scale, const int fontSize);
6061
void renderBarButtons(const Vector2D& bufferSize, const float scale);
@@ -74,4 +75,6 @@ class CHyprBar : public IHyprWindowDecoration {
7475

7576
// for dynamic updates
7677
int m_iLastHeight = 0;
78+
79+
friend class CBarPassElement;
7780
};

hyprexpo/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
all:
2-
$(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
2+
$(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
33
clean:
44
rm ./hyprexpo.so

hyprexpo/OverviewPassElement.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include "OverviewPassElement.hpp"
2+
#include <hyprland/src/render/OpenGL.hpp>
3+
#include "overview.hpp"
4+
5+
COverviewPassElement::COverviewPassElement() {
6+
;
7+
}
8+
9+
void COverviewPassElement::draw(const CRegion& damage) {
10+
g_pOverview->fullRender();
11+
}
12+
13+
bool COverviewPassElement::needsLiveBlur() {
14+
return false;
15+
}
16+
17+
bool COverviewPassElement::needsPrecomputeBlur() {
18+
return false;
19+
}
20+
21+
std::optional<CBox> COverviewPassElement::boundingBox() {
22+
if (!g_pOverview->pMonitor)
23+
return std::nullopt;
24+
25+
return CBox{{}, g_pOverview->pMonitor->vecSize};
26+
}
27+
28+
CRegion COverviewPassElement::opaqueRegion() {
29+
if (!g_pOverview->pMonitor)
30+
return CRegion{};
31+
32+
return CBox{{}, g_pOverview->pMonitor->vecSize};
33+
}

hyprexpo/OverviewPassElement.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#pragma once
2+
#include <hyprland/src/render/pass/PassElement.hpp>
3+
4+
class COverview;
5+
6+
class COverviewPassElement : public IPassElement {
7+
public:
8+
COverviewPassElement();
9+
virtual ~COverviewPassElement() = default;
10+
11+
virtual void draw(const CRegion& damage);
12+
virtual bool needsLiveBlur();
13+
virtual bool needsPrecomputeBlur();
14+
virtual std::optional<CBox> boundingBox();
15+
virtual CRegion opaqueRegion();
16+
17+
virtual const char* passName() {
18+
return "COverviewPassElement";
19+
}
20+
};

hyprexpo/overview.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <hyprland/src/Compositor.hpp>
66
#include <hyprland/src/config/ConfigValue.hpp>
77
#undef private
8+
#include "OverviewPassElement.hpp"
89

910
static void damageMonitor(void*) {
1011
g_pOverview->damage();
@@ -378,7 +379,10 @@ void COverview::onWorkspaceChange() {
378379
}
379380

380381
void COverview::render() {
382+
g_pHyprRenderer->m_sRenderPass.add(makeShared<COverviewPassElement>());
383+
}
381384

385+
void COverview::fullRender() {
382386
const auto GAPSIZE = (closing ? (1.0 - size.getPercent()) : size.getPercent()) * GAP_WIDTH;
383387

384388
if (pMonitor->activeWorkspace != startedOn && !closing) {
@@ -399,7 +403,7 @@ void COverview::render() {
399403
texbox.scale(pMonitor->scale).translate(pos.value());
400404
texbox.round();
401405
CRegion damage{0, 0, INT16_MAX, INT16_MAX};
402-
g_pHyprOpenGL->renderTextureInternalWithDamage(images[x + y * SIDE_LENGTH].fb.getTexture(), &texbox, 1.0, &damage);
406+
g_pHyprOpenGL->renderTextureInternalWithDamage(images[x + y * SIDE_LENGTH].fb.getTexture(), &texbox, 1.0, damage);
403407
}
404408
}
405409
}

hyprexpo/overview.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class COverview {
4040
void redrawID(int id, bool forcelowres = false);
4141
void redrawAll(bool forcelowres = false);
4242
void onWorkspaceChange();
43+
void fullRender();
4344

4445
int SIDE_LENGTH = 3;
4546
int GAP_WIDTH = 5;
@@ -75,6 +76,8 @@ class COverview {
7576

7677
bool swipe = false;
7778
bool swipeWasCommenced = false;
79+
80+
friend class COverviewPassElement;
7881
};
7982

8083
inline std::unique_ptr<COverview> g_pOverview;

0 commit comments

Comments
 (0)