Skip to content

Commit

Permalink
all: chase hyprland
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Jan 24, 2025
1 parent d2dad5b commit 7634792
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
4 changes: 2 additions & 2 deletions borders-plus-plus/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void onNewWindow(void* self, std::any data) {
// data is guaranteed
const auto PWINDOW = std::any_cast<PHLWINDOW>(data);

HyprlandAPI::addWindowDecoration(PHANDLE, PWINDOW, std::make_unique<CBordersPlusPlus>(PWINDOW));
HyprlandAPI::addWindowDecoration(PHANDLE, PWINDOW, makeUnique<CBordersPlusPlus>(PWINDOW));
}

APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
Expand Down Expand Up @@ -51,7 +51,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
if (w->isHidden() || !w->m_bIsMapped)
continue;

HyprlandAPI::addWindowDecoration(PHANDLE, w, std::make_unique<CBordersPlusPlus>(w));
HyprlandAPI::addWindowDecoration(PHANDLE, w, makeUnique<CBordersPlusPlus>(w));
}

HyprlandAPI::addNotification(PHANDLE, "[borders-plus-plus] Initialized successfully!", CHyprColor{0.2, 1.0, 0.2, 1.0}, 5000);
Expand Down
2 changes: 1 addition & 1 deletion hyprbars/barDeco.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ CHyprBar::~CHyprBar() {
HyprlandAPI::unregisterCallback(PHANDLE, m_pTouchUpCallback);
HyprlandAPI::unregisterCallback(PHANDLE, m_pTouchMoveCallback);
HyprlandAPI::unregisterCallback(PHANDLE, m_pMouseMoveCallback);
std::erase(g_pGlobalState->bars, this);
std::erase(g_pGlobalState->bars, m_self);
}

SDecorationPositioningInfo CHyprBar::getPositioningInfo() {
Expand Down
2 changes: 2 additions & 0 deletions hyprbars/barDeco.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class CHyprBar : public IHyprWindowDecoration {
void updateRules();
void applyRule(const SP<CWindowRule>&);

WP<CHyprBar> m_self;

private:
SBoxExtents m_seExtents;

Expand Down
6 changes: 3 additions & 3 deletions hyprbars/globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ struct SHyprButton {
class CHyprBar;

struct SGlobalState {
std::vector<SHyprButton> buttons;
std::vector<CHyprBar*> bars;
std::vector<SHyprButton> buttons;
std::vector<WP<CHyprBar>> bars;
};

inline std::unique_ptr<SGlobalState> g_pGlobalState;
inline UP<SGlobalState> g_pGlobalState;
9 changes: 5 additions & 4 deletions hyprbars/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ static void onNewWindow(void* self, std::any data) {
const auto PWINDOW = std::any_cast<PHLWINDOW>(data);

if (!PWINDOW->m_bX11DoesntWantBorders) {
std::unique_ptr<CHyprBar> bar = std::make_unique<CHyprBar>(PWINDOW);
g_pGlobalState->bars.push_back(bar.get());
auto bar = makeUnique<CHyprBar>(PWINDOW);
g_pGlobalState->bars.emplace_back(bar);
bar->m_self = bar;
HyprlandAPI::addWindowDecoration(PHANDLE, PWINDOW, std::move(bar));
}
}
Expand All @@ -37,7 +38,7 @@ static void onCloseWindow(void* self, std::any data) {
return;

// we could use the API but this is faster + it doesn't matter here that much.
PWINDOW->removeWindowDeco(*BARIT);
PWINDOW->removeWindowDeco(BARIT->get());
}

static void onPreConfigReload() {
Expand Down Expand Up @@ -114,7 +115,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
throw std::runtime_error("[hb] Version mismatch");
}

g_pGlobalState = std::make_unique<SGlobalState>();
g_pGlobalState = makeUnique<SGlobalState>();

static auto P = HyprlandAPI::registerCallbackDynamic(PHANDLE, "openWindow", [&](void* self, SCallbackInfo& info, std::any data) { onNewWindow(self, data); });
static auto P2 = HyprlandAPI::registerCallbackDynamic(PHANDLE, "closeWindow", [&](void* self, SCallbackInfo& info, std::any data) { onCloseWindow(self, data); });
Expand Down
4 changes: 2 additions & 2 deletions hyprtrails/globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
inline HANDLE PHANDLE = nullptr;

struct SGlobalState {
CShader trailShader;
CShader trailShader;
wl_event_source* tick = nullptr;
};

inline std::unique_ptr<SGlobalState> g_pGlobalState;
inline UP<SGlobalState> g_pGlobalState;
6 changes: 3 additions & 3 deletions hyprtrails/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void onNewWindow(void* self, std::any data) {
// data is guaranteed
const auto PWINDOW = std::any_cast<PHLWINDOW>(data);

HyprlandAPI::addWindowDecoration(PHANDLE, PWINDOW, std::make_unique<CTrail>(PWINDOW));
HyprlandAPI::addWindowDecoration(PHANDLE, PWINDOW, makeUnique<CTrail>(PWINDOW));
}

GLuint CompileShader(const GLuint& type, std::string src) {
Expand Down Expand Up @@ -117,15 +117,15 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {

static auto P = HyprlandAPI::registerCallbackDynamic(PHANDLE, "openWindow", [&](void* self, SCallbackInfo& info, std::any data) { onNewWindow(self, data); });

g_pGlobalState = std::make_unique<SGlobalState>();
g_pGlobalState = makeUnique<SGlobalState>();
initGlobal();

// add deco to existing windows
for (auto& w : g_pCompositor->m_vWindows) {
if (w->isHidden() || !w->m_bIsMapped)
continue;

HyprlandAPI::addWindowDecoration(PHANDLE, w, std::make_unique<CTrail>(w));
HyprlandAPI::addWindowDecoration(PHANDLE, w, makeUnique<CTrail>(w));
}

HyprlandAPI::reloadConfig();
Expand Down

0 comments on commit 7634792

Please sign in to comment.