From cd3b43fdc8407ef3ecaa3b66a381a61af8b142b9 Mon Sep 17 00:00:00 2001 From: Alessio Molinari Date: Sat, 15 Jun 2024 11:20:42 +0200 Subject: [PATCH 1/3] feat: support hyprland v0.41.1 (use hyprutils) --- include/VirtualDesk.hpp | 6 ++-- include/utils.hpp | 4 ++- src/main.cpp | 72 +++++++++++++++++++++-------------------- 3 files changed, 44 insertions(+), 38 deletions(-) diff --git a/include/VirtualDesk.hpp b/include/VirtualDesk.hpp index 4bd1263..b8c8f49 100644 --- a/include/VirtualDesk.hpp +++ b/include/VirtualDesk.hpp @@ -11,9 +11,11 @@ #include "globals.hpp" #include "utils.hpp" #include -#include +#include -typedef std::unordered_map WorkspaceMap; +using namespace Hyprutils::Memory; + +typedef std::unordered_map WorkspaceMap; // map with CMonitor* -> hyprland workspace id typedef std::unordered_map Layout; typedef std::string MonitorName; diff --git a/include/utils.hpp b/include/utils.hpp index bf2c720..8cfd1ce 100644 --- a/include/utils.hpp +++ b/include/utils.hpp @@ -5,10 +5,12 @@ #include #include "globals.hpp" #include -#include +#include #include #include +using namespace Hyprutils::Memory; + const std::string VIRTUALDESK_NAMES_CONF = "plugin:virtual-desktops:names"; const std::string CYCLEWORKSPACES_CONF = "plugin:virtual-desktops:cycleworkspaces"; const std::string REMEMBER_LAYOUT_CONF = "plugin:virtual-desktops:rememberlayout"; diff --git a/src/main.cpp b/src/main.cpp index 2721156..c134a39 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include "globals.hpp" #include "VirtualDeskManager.hpp" @@ -15,21 +15,23 @@ #include #include +using namespace Hyprutils::Memory; + static CSharedPointer onWorkspaceChangeHook = nullptr; static CSharedPointer onWindowOpenHook = nullptr; static CSharedPointer onConfigReloadedHook = nullptr; inline CFunctionHook* g_pMonitorConnectHook = nullptr; inline CFunctionHook* g_pMonitorDisconnectHook = nullptr; -typedef void (*origMonitorConnect)(void*, bool); -typedef void (*origMonitorDisconnect)(void*, bool); +typedef void (*origMonitorConnect)(void*, bool); +typedef void (*origMonitorDisconnect)(void*, bool); -std::unique_ptr manager = std::make_unique(); -std::vector stickyRules; -bool notifiedInit = false; -bool monitorLayoutChanging = false; +std::unique_ptr manager = std::make_unique(); +std::vector stickyRules; +bool notifiedInit = false; +bool monitorLayoutChanging = false; -void parseNamesConf(std::string& conf) { +void parseNamesConf(std::string& conf) { size_t pos; size_t delim; std::string rule; @@ -179,38 +181,36 @@ std::string printStateDispatch(eHyprCtlOutputFormat format, std::string arg) { if (format == eHyprCtlOutputFormat::FORMAT_NORMAL) { out += "Virtual desks\n"; int index = 0; - for(auto const& [vdeskId, desk] : manager->vdesksMap) { + for (auto const& [vdeskId, desk] : manager->vdesksMap) { unsigned int windows = 0; - std::string workspaces; - bool first = true; - for(auto const& [monitor, workspaceId] : desk->activeLayout(manager->conf)) { + std::string workspaces; + bool first = true; + for (auto const& [monitor, workspaceId] : desk->activeLayout(manager->conf)) { windows += g_pCompositor->getWindowsOnWorkspace(workspaceId); - if(!first) workspaces += ", "; - else first = false; + if (!first) + workspaces += ", "; + else + first = false; workspaces += std::format("{}", workspaceId); } - out += std::format( - "- {}: {}\n Focused: {}\n Populated: {}\n Workspaces: {}\n Windows: {}\n", - desk->name, - desk->id, - manager->activeVdesk().get() == desk.get(), - windows > 0, - workspaces, - windows - ); - if(index++ < manager->vdesksMap.size() - 1) out += "\n"; + out += std::format("- {}: {}\n Focused: {}\n Populated: {}\n Workspaces: {}\n Windows: {}\n", desk->name, desk->id, manager->activeVdesk().get() == desk.get(), + windows > 0, workspaces, windows); + if (index++ < manager->vdesksMap.size() - 1) + out += "\n"; } - } else if(format == eHyprCtlOutputFormat::FORMAT_JSON) { + } else if (format == eHyprCtlOutputFormat::FORMAT_JSON) { std::string vdesks; - int index = 0; - for(auto const& [vdeskId, desk] : manager->vdesksMap) { + int index = 0; + for (auto const& [vdeskId, desk] : manager->vdesksMap) { unsigned int windows = 0; - std::string workspaces; - bool first = true; - for(auto const& [monitor, workspaceId] : desk->activeLayout(manager->conf)) { + std::string workspaces; + bool first = true; + for (auto const& [monitor, workspaceId] : desk->activeLayout(manager->conf)) { windows += g_pCompositor->getWindowsOnWorkspace(workspaceId); - if(!first) workspaces += ", "; - else first = false; + if (!first) + workspaces += ", "; + else + first = false; workspaces += std::format("{}", workspaceId); } vdesks += std::format(R"#({{ @@ -220,8 +220,10 @@ std::string printStateDispatch(eHyprCtlOutputFormat format, std::string arg) { "populated": {}, "workspaces": [{}], "windows": {} - }})#", vdeskId, desk->name, manager->activeVdesk().get() == desk.get(), windows > 0, workspaces, windows); - if(index++ < manager->vdesksMap.size() - 1) vdesks += ","; + }})#", + vdeskId, desk->name, manager->activeVdesk().get() == desk.get(), windows > 0, workspaces, windows); + if (index++ < manager->vdesksMap.size() - 1) + vdesks += ","; } out += std::format(R"#([{}])#", vdesks); } @@ -418,5 +420,5 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { // Initialize first vdesk HyprlandAPI::reloadConfig(); - return {"virtual-desktops", "Virtual desktop like workspaces", "LevMyskin", "2.2.3"}; + return {"virtual-desktops", "Virtual desktop like workspaces", "LevMyskin", "2.2.4"}; } From 9d26d30bc31cf13ca2535eeca70abf61e3cc7bc6 Mon Sep 17 00:00:00 2001 From: Alessio Molinari Date: Sat, 15 Jun 2024 11:21:07 +0200 Subject: [PATCH 2/3] feat(ci): add hyprutils to ci deps --- .github/actions/setup_base/action.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/actions/setup_base/action.yml b/.github/actions/setup_base/action.yml index 8f8df38..f869d30 100644 --- a/.github/actions/setup_base/action.yml +++ b/.github/actions/setup_base/action.yml @@ -79,6 +79,15 @@ runs: cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` cmake --install build + - name: Get hyprutils + shell: bash + run: | + git clone https://github.com/hyprwm/hyprutils.git + cd hyprutils + cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -S . -B ./build + cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf _NPROCESSORS_CONF` + cmake --install build + - name: Get Xorg pacman pkgs shell: bash if: inputs.INSTALL_XORG_PKGS == 'true' From 003c77c7ceebd4a6b6ffb6d1ae3396b53132bc70 Mon Sep 17 00:00:00 2001 From: Alessio Molinari Date: Sat, 15 Jun 2024 12:06:32 +0200 Subject: [PATCH 3/3] fix(ci): update to hyprland 0.41.1 --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 64b27a0..163f140 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,7 +28,7 @@ jobs: if: github.ref == 'refs/heads/main'|| github.base_ref == 'main' with: INSTALL_XORG_PKGS: true - branch: 'v0.41.0' + branch: 'v0.41.1' hyprwayland: 'v0.3.10' - name: Setup base on dev