From 81f6d1426537981fcbb921f8b5e470b1280ef8f3 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Thu, 23 Oct 2025 20:54:45 +0100 Subject: [PATCH] all: chase hyprland --- borders-plus-plus/main.cpp | 5 +-- csgo-vulkan-fix/main.cpp | 48 ++++++++++++++------------ hyprbars/main.cpp | 5 +-- hyprexpo/main.cpp | 7 ++-- hyprfocus/main.cpp | 5 +-- hyprscrolling/main.cpp | 8 +++-- hyprtrails/main.cpp | 5 +-- hyprwinwrap/main.cpp | 70 ++++++++++++++++++++------------------ xtra-dispatchers/main.cpp | 5 +-- 9 files changed, 86 insertions(+), 72 deletions(-) diff --git a/borders-plus-plus/main.cpp b/borders-plus-plus/main.cpp index a18837f..c43d25e 100644 --- a/borders-plus-plus/main.cpp +++ b/borders-plus-plus/main.cpp @@ -26,9 +26,10 @@ void onNewWindow(void* self, std::any data) { APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { PHANDLE = handle; - const std::string HASH = __hyprland_api_get_hash(); + const std::string HASH = __hyprland_api_get_hash(); + const std::string CLIENT_HASH = __hyprland_api_get_client_hash(); - if (HASH != GIT_COMMIT_HASH) { + if (HASH != CLIENT_HASH) { HyprlandAPI::addNotification(PHANDLE, "[borders-plus-plus] 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("[bpp] Version mismatch"); diff --git a/csgo-vulkan-fix/main.cpp b/csgo-vulkan-fix/main.cpp index 8556800..f657e90 100644 --- a/csgo-vulkan-fix/main.cpp +++ b/csgo-vulkan-fix/main.cpp @@ -106,9 +106,10 @@ CRegion hkWLSurfaceDamage(CWLSurface* thisptr) { APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { PHANDLE = handle; - const std::string HASH = __hyprland_api_get_hash(); + const std::string HASH = __hyprland_api_get_hash(); + const std::string CLIENT_HASH = __hyprland_api_get_client_hash(); - if (HASH != GIT_COMMIT_HASH) { + if (HASH != CLIENT_HASH) { HyprlandAPI::addNotification(PHANDLE, "[csgo-vulkan-fix] 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("[vkfix] Version mismatch"); @@ -129,29 +130,32 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { g_appConfigs.emplace_back(SAppConfig{.szClass = *PCLASS, .res = Vector2D{(int)**RESX, (int)**RESY}}); }); - HyprlandAPI::addConfigKeyword(PHANDLE, "vkfix-app", [](const char* l, const char* r) -> Hyprlang::CParseResult { - const std::string str = r; - CConstVarList data(str, 0, ',', true); + HyprlandAPI::addConfigKeyword( + PHANDLE, "vkfix-app", + [](const char* l, const char* r) -> Hyprlang::CParseResult { + const std::string str = r; + CConstVarList data(str, 0, ',', true); - Hyprlang::CParseResult result; + Hyprlang::CParseResult result; + + if (data.size() != 3) { + result.setError("vkfix-app requires 3 params"); + return result; + } + + try { + SAppConfig config; + config.szClass = data[0]; + config.res = Vector2D{std::stoi(std::string{data[1]}), std::stoi(std::string{data[2]})}; + g_appConfigs.emplace_back(std::move(config)); + } catch (std::exception& e) { + result.setError("failed to parse line"); + return result; + } - if (data.size() != 3) { - result.setError("vkfix-app requires 3 params"); return result; - } - - try { - SAppConfig config; - config.szClass = data[0]; - config.res = Vector2D{std::stoi(std::string{data[1]}), std::stoi(std::string{data[2]})}; - g_appConfigs.emplace_back(std::move(config)); - } catch (std::exception& e) { - result.setError("failed to parse line"); - return result; - } - - return result; - }, Hyprlang::SHandlerOptions{}); + }, + Hyprlang::SHandlerOptions{}); auto FNS = HyprlandAPI::findFunctionsByName(PHANDLE, "sendPointerMotion"); for (auto& fn : FNS) { diff --git a/hyprbars/main.cpp b/hyprbars/main.cpp index 49742df..213978d 100644 --- a/hyprbars/main.cpp +++ b/hyprbars/main.cpp @@ -112,9 +112,10 @@ Hyprlang::CParseResult onNewButton(const char* K, const char* V) { APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { PHANDLE = handle; - const std::string HASH = __hyprland_api_get_hash(); + const std::string HASH = __hyprland_api_get_hash(); + const std::string CLIENT_HASH = __hyprland_api_get_client_hash(); - if (HASH != GIT_COMMIT_HASH) { + if (HASH != CLIENT_HASH) { HyprlandAPI::addNotification(PHANDLE, "[hyprbars] 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("[hb] Version mismatch"); diff --git a/hyprexpo/main.cpp b/hyprexpo/main.cpp index e53b8ac..171b28c 100644 --- a/hyprexpo/main.cpp +++ b/hyprexpo/main.cpp @@ -107,7 +107,7 @@ static void failNotif(const std::string& reason) { } static Hyprlang::CParseResult expoGestureKeyword(const char* LHS, const char* RHS) { - Hyprlang::CParseResult result; + Hyprlang::CParseResult result; if (g_unloading) return result; @@ -182,9 +182,10 @@ static Hyprlang::CParseResult expoGestureKeyword(const char* LHS, const char* RH APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { PHANDLE = handle; - const std::string HASH = __hyprland_api_get_hash(); + const std::string HASH = __hyprland_api_get_hash(); + const std::string CLIENT_HASH = __hyprland_api_get_client_hash(); - if (HASH != GIT_COMMIT_HASH) { + if (HASH != CLIENT_HASH) { failNotif("Version mismatch (headers ver is not equal to running hyprland ver)"); throw std::runtime_error("[he] Version mismatch"); } diff --git a/hyprfocus/main.cpp b/hyprfocus/main.cpp index ce5b005..7183e16 100644 --- a/hyprfocus/main.cpp +++ b/hyprfocus/main.cpp @@ -110,9 +110,10 @@ static void onFocusChange(PHLWINDOW window) { APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { PHANDLE = handle; - const std::string HASH = __hyprland_api_get_hash(); + const std::string HASH = __hyprland_api_get_hash(); + const std::string CLIENT_HASH = __hyprland_api_get_client_hash(); - if (HASH != GIT_COMMIT_HASH) { + if (HASH != CLIENT_HASH) { HyprlandAPI::addNotification(PHANDLE, "[hyprwinwrap] 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("[hww] Version mismatch"); diff --git a/hyprscrolling/main.cpp b/hyprscrolling/main.cpp index 7e88840..b6425d0 100644 --- a/hyprscrolling/main.cpp +++ b/hyprscrolling/main.cpp @@ -31,9 +31,10 @@ UP g_pScrollingLayout; APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { PHANDLE = handle; - const std::string HASH = __hyprland_api_get_hash(); + const std::string HASH = __hyprland_api_get_hash(); + const std::string CLIENT_HASH = __hyprland_api_get_client_hash(); - if (HASH != GIT_COMMIT_HASH) { + if (HASH != CLIENT_HASH) { HyprlandAPI::addNotification(PHANDLE, "[hyprscrolling] 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("[hs] Version mismatch"); @@ -50,7 +51,8 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprscrolling:explicit_column_widths", Hyprlang::STRING{"0.333, 0.5, 0.667, 1.0"}); HyprlandAPI::addLayout(PHANDLE, "scrolling", g_pScrollingLayout.get()); - if (success) HyprlandAPI::addNotification(PHANDLE, "[hyprscrolling] Initialized successfully!", CHyprColor{0.2, 1.0, 0.2, 1.0}, 5000); + if (success) + HyprlandAPI::addNotification(PHANDLE, "[hyprscrolling] Initialized successfully!", CHyprColor{0.2, 1.0, 0.2, 1.0}, 5000); else { HyprlandAPI::addNotification(PHANDLE, "[hyprscrolling] Failure in initialization: failed to register dispatchers", CHyprColor{1.0, 0.2, 0.2, 1.0}, 5000); throw std::runtime_error("[hs] Dispatchers failed"); diff --git a/hyprtrails/main.cpp b/hyprtrails/main.cpp index 2062d86..73aa00a 100644 --- a/hyprtrails/main.cpp +++ b/hyprtrails/main.cpp @@ -100,9 +100,10 @@ void initGlobal() { APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { PHANDLE = handle; - const std::string HASH = __hyprland_api_get_hash(); + const std::string HASH = __hyprland_api_get_hash(); + const std::string CLIENT_HASH = __hyprland_api_get_client_hash(); - if (HASH != GIT_COMMIT_HASH) { + if (HASH != CLIENT_HASH) { 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"); diff --git a/hyprwinwrap/main.cpp b/hyprwinwrap/main.cpp index 3f79b2c..6d66cba 100644 --- a/hyprwinwrap/main.cpp +++ b/hyprwinwrap/main.cpp @@ -32,20 +32,20 @@ typedef void (*origCommit)(void* owner, void* data); std::vector bgWindows; -void onNewWindow(PHLWINDOW pWindow) { - static auto* const PCLASS = (Hyprlang::STRING const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprwinwrap:class")->getDataStaticPtr(); - static auto* const PTITLE = (Hyprlang::STRING const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprwinwrap:title")->getDataStaticPtr(); +void onNewWindow(PHLWINDOW pWindow) { + static auto* const PCLASS = (Hyprlang::STRING const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprwinwrap:class")->getDataStaticPtr(); + static auto* const PTITLE = (Hyprlang::STRING const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprwinwrap:title")->getDataStaticPtr(); - static auto* const PSIZEX = (Hyprlang::STRING const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprwinwrap:size_x")->getDataStaticPtr(); - static auto* const PSIZEY = (Hyprlang::STRING const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprwinwrap:size_y")->getDataStaticPtr(); - static auto* const PPOSX = (Hyprlang::STRING const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprwinwrap:pos_x")->getDataStaticPtr(); - static auto* const PPOSY = (Hyprlang::STRING const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprwinwrap:pos_y")->getDataStaticPtr(); + static auto* const PSIZEX = (Hyprlang::STRING const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprwinwrap:size_x")->getDataStaticPtr(); + static auto* const PSIZEY = (Hyprlang::STRING const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprwinwrap:size_y")->getDataStaticPtr(); + static auto* const PPOSX = (Hyprlang::STRING const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprwinwrap:pos_x")->getDataStaticPtr(); + static auto* const PPOSY = (Hyprlang::STRING const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprwinwrap:pos_y")->getDataStaticPtr(); - const std::string classRule(*PCLASS); - const std::string titleRule(*PTITLE); + const std::string classRule(*PCLASS); + const std::string titleRule(*PTITLE); - const bool classMatches = !classRule.empty() && pWindow->m_initialClass == classRule; - const bool titleMatches = !titleRule.empty() && pWindow->m_title == titleRule; + const bool classMatches = !classRule.empty() && pWindow->m_initialClass == classRule; + const bool titleMatches = !titleRule.empty() && pWindow->m_title == titleRule; if (!classMatches && !titleMatches) return; @@ -59,10 +59,18 @@ void onNewWindow(PHLWINDOW pWindow) { float sx = 100.f, sy = 100.f, px = 0.f, py = 0.f; - try { sx = std::stof(*PSIZEX); } catch (...) {} - try { sy = std::stof(*PSIZEY); } catch (...) {} - try { px = std::stof(*PPOSX); } catch (...) {} - try { py = std::stof(*PPOSY); } catch (...) {} + try { + sx = std::stof(*PSIZEX); + } catch (...) {} + try { + sy = std::stof(*PSIZEY); + } catch (...) {} + try { + px = std::stof(*PPOSX); + } catch (...) {} + try { + py = std::stof(*PPOSY); + } catch (...) {} sx = std::clamp(sx, 1.f, 100.f); sy = std::clamp(sy, 1.f, 100.f); @@ -81,21 +89,15 @@ void onNewWindow(PHLWINDOW pWindow) { const Vector2D monitorSize = PMONITOR->m_size; const Vector2D monitorPos = PMONITOR->m_position; - const Vector2D newSize = { - static_cast(monitorSize.x * (sx / 100.f)), - static_cast(monitorSize.y * (sy / 100.f)) - }; + const Vector2D newSize = {static_cast(monitorSize.x * (sx / 100.f)), static_cast(monitorSize.y * (sy / 100.f))}; - const Vector2D newPos = { - static_cast(monitorPos.x + (monitorSize.x * (px / 100.f))), - static_cast(monitorPos.y + (monitorSize.y * (py / 100.f))) - }; + const Vector2D newPos = {static_cast(monitorPos.x + (monitorSize.x * (px / 100.f))), static_cast(monitorPos.y + (monitorSize.y * (py / 100.f)))}; pWindow->m_realSize->setValueAndWarp(newSize); pWindow->m_realPosition->setValueAndWarp(newPos); - pWindow->m_size = newSize; - pWindow->m_position = newPos; - pWindow->m_pinned = true; + pWindow->m_size = newSize; + pWindow->m_position = newPos; + pWindow->m_pinned = true; pWindow->sendWindowSize(true); bgWindows.push_back(pWindow); @@ -168,14 +170,14 @@ void onCommit(void* owner, void* data) { void onConfigReloaded() { static auto* const PCLASS = (Hyprlang::STRING const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprwinwrap:class")->getDataStaticPtr(); - const std::string classRule(*PCLASS); + const std::string classRule(*PCLASS); if (!classRule.empty()) { g_pConfigManager->parseKeyword("windowrulev2", std::string{"float, class:^("} + classRule + ")$"); g_pConfigManager->parseKeyword("windowrulev2", std::string{"size 100\% 100\%, class:^("} + classRule + ")$"); } static auto* const PTITLE = (Hyprlang::STRING const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprwinwrap:title")->getDataStaticPtr(); - const std::string titleRule(*PTITLE); + const std::string titleRule(*PTITLE); if (!titleRule.empty()) { g_pConfigManager->parseKeyword("windowrulev2", std::string{"float, title:^("} + titleRule + ")$"); g_pConfigManager->parseKeyword("windowrulev2", std::string{"size 100\% 100\%, title:^("} + titleRule + ")$"); @@ -185,9 +187,10 @@ void onConfigReloaded() { APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { PHANDLE = handle; - const std::string HASH = __hyprland_api_get_hash(); + const std::string HASH = __hyprland_api_get_hash(); + const std::string CLIENT_HASH = __hyprland_api_get_client_hash(); - if (HASH != GIT_COMMIT_HASH) { + if (HASH != CLIENT_HASH) { HyprlandAPI::addNotification(PHANDLE, "[hyprwinwrap] 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("[hww] Version mismatch"); @@ -225,9 +228,9 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprwinwrap:size_x", Hyprlang::STRING{"100"}); HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprwinwrap:size_y", Hyprlang::STRING{"100"}); - HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprwinwrap:pos_x", Hyprlang::STRING{"0"}); - HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprwinwrap:pos_y", Hyprlang::STRING{"0"}); - + HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprwinwrap:pos_x", Hyprlang::STRING{"0"}); + HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprwinwrap:pos_y", Hyprlang::STRING{"0"}); + HyprlandAPI::addNotification(PHANDLE, "[hyprwinwrap] Initialized successfully!", CHyprColor{0.2, 1.0, 0.2, 1.0}, 5000); return {"hyprwinwrap", "A clone of xwinwrap for Hyprland", "Vaxry", "1.0"}; @@ -236,4 +239,3 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { APICALL EXPORT void PLUGIN_EXIT() { ; } - diff --git a/xtra-dispatchers/main.cpp b/xtra-dispatchers/main.cpp index d34b119..e53b38c 100644 --- a/xtra-dispatchers/main.cpp +++ b/xtra-dispatchers/main.cpp @@ -116,9 +116,10 @@ static SDispatchResult closeUnfocused(std::string in) { APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { PHANDLE = handle; - const std::string HASH = __hyprland_api_get_hash(); + const std::string HASH = __hyprland_api_get_hash(); + const std::string CLIENT_HASH = __hyprland_api_get_client_hash(); - if (HASH != GIT_COMMIT_HASH) { + if (HASH != CLIENT_HASH) { HyprlandAPI::addNotification(PHANDLE, "[xtra-dispatchers] 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("[xtd] Version mismatch");