Skip to content

Commit

Permalink
all: chase hyprland
Browse files Browse the repository at this point in the history
  • Loading branch information
amaanq committed Dec 4, 2024
1 parent 0bc619b commit b500f6a
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 74 deletions.
4 changes: 2 additions & 2 deletions borders-plus-plus/borderDeco.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ std::string CBordersPlusPlus::getDisplayName() {
return "Borders++";
}

void CBordersPlusPlus::draw(PHLMONITOR pMonitor, const float &a) {
void CBordersPlusPlus::draw(PHLMONITOR pMonitor, const float& a) {
if (!validMapped(m_pWindow))
return;

Expand Down Expand Up @@ -125,7 +125,7 @@ void CBordersPlusPlus::draw(PHLMONITOR pMonitor, const float &a) {

g_pHyprOpenGL->scissor((CBox*)nullptr);

g_pHyprOpenGL->renderBorder(&fullBox, CColor{(uint64_t) * *PCOLORS[i]}, **PNATURALROUND ? ORIGINALROUND : rounding, THISBORDERSIZE, a,
g_pHyprOpenGL->renderBorder(&fullBox, CHyprColor{(uint64_t)**PCOLORS[i]}, **PNATURALROUND ? ORIGINALROUND : rounding, THISBORDERSIZE, a,
**PNATURALROUND ? ORIGINALROUND : -1);
}

Expand Down
2 changes: 1 addition & 1 deletion borders-plus-plus/globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

#include <hyprland/src/plugins/PluginAPI.hpp>

inline HANDLE PHANDLE = nullptr;
inline HANDLE PHANDLE = nullptr;
4 changes: 2 additions & 2 deletions borders-plus-plus/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {

if (HASH != GIT_COMMIT_HASH) {
HyprlandAPI::addNotification(PHANDLE, "[borders-plus-plus] Failure in initialization: Version mismatch (headers ver is not equal to running hyprland ver)",
CColor{1.0, 0.2, 0.2, 1.0}, 5000);
CHyprColor{1.0, 0.2, 0.2, 1.0}, 5000);
throw std::runtime_error("[bpp] Version mismatch");
}

Expand All @@ -53,7 +53,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
HyprlandAPI::addWindowDecoration(PHANDLE, w, std::make_unique<CBordersPlusPlus>(w));
}

HyprlandAPI::addNotification(PHANDLE, "[borders-plus-plus] Initialized successfully!", CColor{0.2, 1.0, 0.2, 1.0}, 5000);
HyprlandAPI::addNotification(PHANDLE, "[borders-plus-plus] Initialized successfully!", CHyprColor{0.2, 1.0, 0.2, 1.0}, 5000);

return {"borders-plus-plus", "A plugin to add more borders to windows.", "Vaxry", "1.0"};
}
Expand Down
8 changes: 4 additions & 4 deletions csgo-vulkan-fix/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {

if (HASH != GIT_COMMIT_HASH) {
HyprlandAPI::addNotification(PHANDLE, "[csgo-vulkan-fix] Failure in initialization: Version mismatch (headers ver is not equal to running hyprland ver)",
CColor{1.0, 0.2, 0.2, 1.0}, 5000);
CHyprColor{1.0, 0.2, 0.2, 1.0}, 5000);
throw std::runtime_error("[vkfix] Version mismatch");
}

Expand Down Expand Up @@ -126,7 +126,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {

bool success = g_pSurfaceSizeHook && g_pWLSurfaceDamageHook && g_pMouseMotionHook;
if (!success) {
HyprlandAPI::addNotification(PHANDLE, "[csgo-vulkan-fix] Failure in initialization: Failed to find required hook fns", CColor{1.0, 0.2, 0.2, 1.0}, 5000);
HyprlandAPI::addNotification(PHANDLE, "[csgo-vulkan-fix] Failure in initialization: Failed to find required hook fns", CHyprColor{1.0, 0.2, 0.2, 1.0}, 5000);
throw std::runtime_error("[vkfix] Hooks fn init failed");
}

Expand All @@ -135,9 +135,9 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
success = success && g_pSurfaceSizeHook->hook();

if (success)
HyprlandAPI::addNotification(PHANDLE, "[csgo-vulkan-fix] Initialized successfully! (Anything version)", CColor{0.2, 1.0, 0.2, 1.0}, 5000);
HyprlandAPI::addNotification(PHANDLE, "[csgo-vulkan-fix] Initialized successfully! (Anything version)", CHyprColor{0.2, 1.0, 0.2, 1.0}, 5000);
else {
HyprlandAPI::addNotification(PHANDLE, "[csgo-vulkan-fix] Failure in initialization (hook failed)!", CColor{1.0, 0.2, 0.2, 1.0}, 5000);
HyprlandAPI::addNotification(PHANDLE, "[csgo-vulkan-fix] Failure in initialization (hook failed)!", CHyprColor{1.0, 0.2, 0.2, 1.0}, 5000);
throw std::runtime_error("[csgo-vk-fix] Hooks failed");
}

Expand Down
30 changes: 15 additions & 15 deletions hyprbars/barDeco.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void CHyprBar::onMouseMove(Vector2D coords) {
}
}

void CHyprBar::renderText(SP<CTexture> out, const std::string& text, const CColor& color, const Vector2D& bufferSize, const float scale, const int fontSize) {
void CHyprBar::renderText(SP<CTexture> out, const std::string& text, const CHyprColor& color, const Vector2D& bufferSize, const float scale, const int fontSize) {
const auto CAIROSURFACE = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, bufferSize.x, bufferSize.y);
const auto CAIRO = cairo_create(CAIROSURFACE);

Expand Down Expand Up @@ -215,16 +215,16 @@ void CHyprBar::renderBarTitle(const Vector2D& bufferSize, const float scale) {
buttonSizes += b.size + **PBARBUTTONPADDING;
}

const auto scaledSize = **PSIZE * scale;
const auto scaledBorderSize = BORDERSIZE * scale;
const auto scaledButtonsSize = buttonSizes * scale;
const auto scaledButtonsPad = **PBARBUTTONPADDING * scale;
const auto scaledBarPadding = **PBARPADDING * scale;
const auto scaledSize = **PSIZE * scale;
const auto scaledBorderSize = BORDERSIZE * scale;
const auto scaledButtonsSize = buttonSizes * scale;
const auto scaledButtonsPad = **PBARBUTTONPADDING * scale;
const auto scaledBarPadding = **PBARPADDING * scale;

const CColor COLOR = m_bForcedTitleColor.value_or(**PCOLOR);
const CHyprColor COLOR = m_bForcedTitleColor.value_or(**PCOLOR);

const auto CAIROSURFACE = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, bufferSize.x, bufferSize.y);
const auto CAIRO = cairo_create(CAIROSURFACE);
const auto CAIROSURFACE = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, bufferSize.x, bufferSize.y);
const auto CAIRO = cairo_create(CAIROSURFACE);

// clear the pixmap
cairo_save(CAIRO);
Expand Down Expand Up @@ -365,7 +365,7 @@ void CHyprBar::renderBarButtonsText(CBox* barBox, const float scale, const float

const bool LIGHT = button.col.r + button.col.g + button.col.b < 1;

renderText(button.iconTex, button.icon, LIGHT ? CColor(0xFFFFFFFF) : CColor(0xFF000000), BUFSIZE, scale, button.size * 0.62);
renderText(button.iconTex, button.icon, LIGHT ? CHyprColor(0xFFFFFFFF) : CHyprColor(0xFF000000), BUFSIZE, scale, button.size * 0.62);
}

if (button.iconTex->m_iTexID == 0)
Expand All @@ -384,7 +384,7 @@ void CHyprBar::renderBarButtonsText(CBox* barBox, const float scale, const float
}
}

void CHyprBar::draw(PHLMONITOR pMonitor, const float &a) {
void CHyprBar::draw(PHLMONITOR pMonitor, const float& a) {
if (m_bHidden || !validMapped(m_pWindow))
return;

Expand Down Expand Up @@ -413,7 +413,7 @@ void CHyprBar::draw(PHLMONITOR pMonitor, const float &a) {

const auto scaledRounding = ROUNDING > 0 ? ROUNDING * pMonitor->scale - 2 /* idk why but otherwise it looks bad due to the gaps */ : 0;

CColor color = m_bForcedBarColor.value_or(**PCOLOR);
CHyprColor color = m_bForcedBarColor.value_or(**PCOLOR);
color.a *= a;

m_seExtents = {{0, **PHEIGHT}, {}};
Expand Down Expand Up @@ -452,7 +452,7 @@ void CHyprBar::draw(PHLMONITOR pMonitor, const float &a) {
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);

windowBox.translate(WORKSPACEOFFSET).scale(pMonitor->scale).round();
g_pHyprOpenGL->renderRect(&windowBox, CColor(0, 0, 0, 0), scaledRounding);
g_pHyprOpenGL->renderRect(&windowBox, CHyprColor(0, 0, 0, 0), scaledRounding);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);

glStencilFunc(GL_NOTEQUAL, 1, -1);
Expand Down Expand Up @@ -568,7 +568,7 @@ void CHyprBar::applyRule(const SWindowRule& r) {
if (r.szRule == "plugin:hyprbars:nobar")
m_bHidden = true;
else if (r.szRule.starts_with("plugin:hyprbars:bar_color"))
m_bForcedBarColor = CColor(configStringToInt(arg).value_or(0));
m_bForcedBarColor = CHyprColor(configStringToInt(arg).value_or(0));
else if (r.szRule.starts_with("plugin:hyprbars:title_color"))
m_bForcedTitleColor = CColor(configStringToInt(arg).value_or(0));
m_bForcedTitleColor = CHyprColor(configStringToInt(arg).value_or(0));
}
48 changes: 24 additions & 24 deletions hyprbars/barDeco.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,39 +38,39 @@ class CHyprBar : public IHyprWindowDecoration {
void applyRule(const SWindowRule&);

private:
SBoxExtents m_seExtents;
SBoxExtents m_seExtents;

PHLWINDOWREF m_pWindow;
PHLWINDOWREF m_pWindow;

CBox m_bAssignedBox;
CBox m_bAssignedBox;

SP<CTexture> m_pTextTex;
SP<CTexture> m_pButtonsTex;
SP<CTexture> m_pTextTex;
SP<CTexture> m_pButtonsTex;

bool m_bWindowSizeChanged = false;
bool m_bHidden = false;
bool m_bTitleColorChanged = false;
std::optional<CColor> m_bForcedBarColor;
std::optional<CColor> m_bForcedTitleColor;
bool m_bWindowSizeChanged = false;
bool m_bHidden = false;
bool m_bTitleColorChanged = false;
std::optional<CHyprColor> m_bForcedBarColor;
std::optional<CHyprColor> m_bForcedTitleColor;

Vector2D cursorRelativeToBar();
Vector2D cursorRelativeToBar();

void renderBarTitle(const Vector2D& bufferSize, const float scale);
void renderText(SP<CTexture> out, const std::string& text, const CColor& color, const Vector2D& bufferSize, const float scale, const int fontSize);
void renderBarButtons(const Vector2D& bufferSize, const float scale);
void renderBarButtonsText(CBox* barBox, const float scale, const float a);
void onMouseDown(SCallbackInfo& info, IPointer::SButtonEvent e);
void onMouseMove(Vector2D coords);
CBox assignedBoxGlobal();
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);
void renderBarButtonsText(CBox* barBox, const float scale, const float a);
void onMouseDown(SCallbackInfo& info, IPointer::SButtonEvent e);
void onMouseMove(Vector2D coords);
CBox assignedBoxGlobal();

SP<HOOK_CALLBACK_FN> m_pMouseButtonCallback;
SP<HOOK_CALLBACK_FN> m_pMouseMoveCallback;
SP<HOOK_CALLBACK_FN> m_pMouseButtonCallback;
SP<HOOK_CALLBACK_FN> m_pMouseMoveCallback;

std::string m_szLastTitle;
std::string m_szLastTitle;

bool m_bDraggingThis = false;
bool m_bDragPending = false;
bool m_bCancelledDown = false;
bool m_bDraggingThis = false;
bool m_bDragPending = false;
bool m_bCancelledDown = false;

// for dynamic updates
int m_iLastHeight = 0;
Expand Down
4 changes: 2 additions & 2 deletions hyprbars/globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ inline HANDLE PHANDLE = nullptr;

struct SHyprButton {
std::string cmd = "";
CColor col = CColor(0, 0, 0, 0);
CHyprColor col = CHyprColor(0, 0, 0, 0);
float size = 10;
std::string icon = "";
SP<CTexture> iconTex = makeShared<CTexture>();
Expand All @@ -20,4 +20,4 @@ struct SGlobalState {
std::vector<CHyprBar*> bars;
};

inline std::unique_ptr<SGlobalState> g_pGlobalState;
inline std::unique_ptr<SGlobalState> g_pGlobalState;
4 changes: 2 additions & 2 deletions hyprbars/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {

if (HASH != GIT_COMMIT_HASH) {
HyprlandAPI::addNotification(PHANDLE, "[hyprbars] Failure in initialization: Version mismatch (headers ver is not equal to running hyprland ver)",
CColor{1.0, 0.2, 0.2, 1.0}, 5000);
CHyprColor{1.0, 0.2, 0.2, 1.0}, 5000);
throw std::runtime_error("[hb] Version mismatch");
}

Expand Down Expand Up @@ -132,7 +132,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {

HyprlandAPI::reloadConfig();

HyprlandAPI::addNotification(PHANDLE, "[hyprbars] Initialized successfully!", CColor{0.2, 1.0, 0.2, 1.0}, 5000);
HyprlandAPI::addNotification(PHANDLE, "[hyprbars] Initialized successfully!", CHyprColor{0.2, 1.0, 0.2, 1.0}, 5000);

return {"hyprbars", "A plugin to add title bars to windows.", "Vaxry", "1.0"};
}
Expand Down
2 changes: 1 addition & 1 deletion hyprexpo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ static void onExpoDispatcher(std::string arg) {
}

static void failNotif(const std::string& reason) {
HyprlandAPI::addNotification(PHANDLE, "[hyprexpo] Failure in initialization: " + reason, CColor{1.0, 0.2, 0.2, 1.0}, 5000);
HyprlandAPI::addNotification(PHANDLE, "[hyprexpo] Failure in initialization: " + reason, CHyprColor{1.0, 0.2, 0.2, 1.0}, 5000);
}

APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
Expand Down
12 changes: 6 additions & 6 deletions hyprexpo/overview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ COverview::COverview(PHLWORKSPACE startedOn_, bool swipe_) : startedOn(startedOn
BG_COLOR = **PCOL;

// process the method
bool methodCenter = true;
bool methodCenter = true;
int methodStartID = pMonitor->activeWorkspaceID();
CVarList method{*PMETHOD, 0, 's', true};
if (method.size() < 2)
Debug::log(ERR, "[he] invalid workspace_method");
else {
methodCenter = method[0] == "center";
methodCenter = method[0] == "center";
methodStartID = getWorkspaceIDNameFromString(method[1]).id;
if (methodStartID == WORKSPACE_INVALID)
methodStartID = pMonitor->activeWorkspaceID();
Expand All @@ -65,7 +65,7 @@ COverview::COverview(PHLWORKSPACE startedOn_, bool swipe_) : startedOn(startedOn
}

for (size_t i = 0; i < SIDE_LENGTH * SIDE_LENGTH; ++i) {
auto& image = images[i];
auto& image = images[i];
currentID =
getWorkspaceIDNameFromString("r" + ((int64_t)i - backtracked < 0 ? std::to_string((int64_t)i - backtracked) : "+" + std::to_string((int64_t)i - backtracked))).id;
image.workspaceID = currentID;
Expand All @@ -81,7 +81,7 @@ COverview::COverview(PHLWORKSPACE startedOn_, bool swipe_) : startedOn(startedOn
pMonitor->activeWorkspace = PWORKSPACESTART;

for (size_t i = 1; i < SIDE_LENGTH * SIDE_LENGTH; ++i) {
auto& image = images[i];
auto& image = images[i];
currentID = getWorkspaceIDNameFromString("r+" + std::to_string(i)).id;
image.workspaceID = currentID;
}
Expand Down Expand Up @@ -115,7 +115,7 @@ COverview::COverview(PHLWORKSPACE startedOn_, bool swipe_) : startedOn(startedOn
CRegion fakeDamage{0, 0, INT16_MAX, INT16_MAX};
g_pHyprRenderer->beginRender(PMONITOR, fakeDamage, RENDER_MODE_FULL_FAKE, nullptr, &image.fb);

g_pHyprOpenGL->clear(CColor{0, 0, 0, 1.0});
g_pHyprOpenGL->clear(CHyprColor{0, 0, 0, 1.0});

const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(image.workspaceID);

Expand Down Expand Up @@ -243,7 +243,7 @@ void COverview::redrawID(int id, bool forcelowres) {
CRegion fakeDamage{0, 0, INT16_MAX, INT16_MAX};
g_pHyprRenderer->beginRender(pMonitor.lock(), fakeDamage, RENDER_MODE_FULL_FAKE, nullptr, &image.fb);

g_pHyprOpenGL->clear(CColor{0, 0, 0, 1.0});
g_pHyprOpenGL->clear(CHyprColor{0, 0, 0, 1.0});

const auto PWORKSPACE = image.pWorkspace;

Expand Down
16 changes: 8 additions & 8 deletions hyprexpo/overview.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ class COverview {
PHLMONITORREF pMonitor;

private:
void redrawID(int id, bool forcelowres = false);
void redrawAll(bool forcelowres = false);
void onWorkspaceChange();
void redrawID(int id, bool forcelowres = false);
void redrawAll(bool forcelowres = false);
void onWorkspaceChange();

int SIDE_LENGTH = 3;
int GAP_WIDTH = 5;
CColor BG_COLOR = CColor{0.1, 0.1, 0.1, 1.0};
int SIDE_LENGTH = 3;
int GAP_WIDTH = 5;
CHyprColor BG_COLOR = CHyprColor{0.1, 0.1, 0.1, 1.0};

bool damageDirty = false;
bool damageDirty = false;

struct SWorkspaceImage {
CFramebuffer fb;
Expand Down Expand Up @@ -77,4 +77,4 @@ class COverview {
bool swipeWasCommenced = false;
};

inline std::unique_ptr<COverview> g_pOverview;
inline std::unique_ptr<COverview> g_pOverview;
4 changes: 2 additions & 2 deletions hyprtrails/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
const std::string HASH = __hyprland_api_get_hash();

if (HASH != GIT_COMMIT_HASH) {
HyprlandAPI::addNotification(PHANDLE, "[ht] Failure in initialization: Version mismatch (headers ver is not equal to running hyprland ver)", CColor{1.0, 0.2, 0.2, 1.0},
HyprlandAPI::addNotification(PHANDLE, "[ht] Failure in initialization: Version mismatch (headers ver is not equal to running hyprland ver)", CHyprColor{1.0, 0.2, 0.2, 1.0},
5000);
throw std::runtime_error("[ht] Version mismatch");
}
Expand All @@ -128,7 +128,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {

HyprlandAPI::reloadConfig();

HyprlandAPI::addNotification(PHANDLE, "[hyprtrails] Initialized successfully!", CColor{0.2, 1.0, 0.2, 1.0}, 5000);
HyprlandAPI::addNotification(PHANDLE, "[hyprtrails] Initialized successfully!", CHyprColor{0.2, 1.0, 0.2, 1.0}, 5000);

return {"hyprtrails", "A plugin to add trails behind moving windows", "Vaxry", "1.0"};
}
Expand Down
6 changes: 3 additions & 3 deletions hyprtrails/trail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Vector2D vecForBezierT(const float& t, const std::vector<Vector2D>& verts) {
return pts[0];
}

void CTrail::draw(PHLMONITOR pMonitor, const float &a) {
void CTrail::draw(PHLMONITOR pMonitor, const float& a) {
if (!validMapped(m_pWindow))
return;

Expand All @@ -91,7 +91,7 @@ void CTrail::draw(PHLMONITOR pMonitor, const float &a) {
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();

const CColor COLOR = **PCOLOR;
const CHyprColor COLOR = **PCOLOR;

if (m_dLastGeoms.size() < 2)
return;
Expand All @@ -111,7 +111,7 @@ void CTrail::draw(PHLMONITOR pMonitor, const float &a) {
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);

glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
g_pHyprOpenGL->renderRect(&wlrbox, CColor(0, 0, 0, 0), PWINDOW->rounding() * pMonitor->scale);
g_pHyprOpenGL->renderRect(&wlrbox, CHyprColor(0, 0, 0, 0), PWINDOW->rounding() * pMonitor->scale);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);

glStencilFunc(GL_NOTEQUAL, 1, -1);
Expand Down
Loading

0 comments on commit b500f6a

Please sign in to comment.