diff --git a/hyprexpo/README.md b/hyprexpo/README.md index aac2e97..c78088f 100644 --- a/hyprexpo/README.md +++ b/hyprexpo/README.md @@ -28,6 +28,7 @@ gap_size | number | gap between desktops | `5` bg_col | color | color in gaps (between desktops) | `rgb(000000)` workspace_method | [center/first] [workspace] | position of the desktops | `center current` skip_empty | boolean | whether the grid displays workspaces sequentially by id using selector "r" (`false`) or skips empty workspaces using selector "m" (`true`) | `false` +max_workspace | number | highest normal workspace to show when `skip_empty` is `false`; `0` disables the limit | `0` show_workspace_numbers | boolean | show numeric labels for workspaces | `false` workspace_number_color | color | color of workspace number labels | `rgb(ffffff)` gesture_distance | number | how far is the max for the gesture | `300` diff --git a/hyprexpo/main.cpp b/hyprexpo/main.cpp index f43134f..12e7f6e 100644 --- a/hyprexpo/main.cpp +++ b/hyprexpo/main.cpp @@ -249,6 +249,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprexpo:bg_col", Hyprlang::INT{0xFF111111}); HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprexpo:workspace_method", Hyprlang::STRING{"center current"}); HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprexpo:skip_empty", Hyprlang::INT{0}); + HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprexpo:max_workspace", Hyprlang::INT{0}); HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprexpo:show_workspace_numbers", Hyprlang::INT{0}); HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprexpo:workspace_number_color", Hyprlang::INT{0xFFFFFFFF}); diff --git a/hyprexpo/overview.cpp b/hyprexpo/overview.cpp index 926a9f8..b85f94d 100644 --- a/hyprexpo/overview.cpp +++ b/hyprexpo/overview.cpp @@ -117,6 +117,7 @@ COverview::COverview(PHLWORKSPACE startedOn_, bool swipe_) : startedOn(startedOn static auto* const* PGAPS = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprexpo:gap_size")->getDataStaticPtr(); static auto* const* PCOL = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprexpo:bg_col")->getDataStaticPtr(); static auto* const* PSKIP = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprexpo:skip_empty")->getDataStaticPtr(); + static auto* const* PMAXWS = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprexpo:max_workspace")->getDataStaticPtr(); static auto* const* PSHOWNUM = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprexpo:show_workspace_numbers")->getDataStaticPtr(); static auto* const* PNUMCOL = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprexpo:workspace_number_color")->getDataStaticPtr(); static auto const* PMETHOD = (Hyprlang::STRING const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprexpo:workspace_method")->getDataStaticPtr(); @@ -142,9 +143,20 @@ COverview::COverview(PHLWORKSPACE startedOn_, bool swipe_) : startedOn(startedOn images.resize(SIDE_LENGTH * SIDE_LENGTH); // r includes empty workspaces; m skips over them - std::string selector = **PSKIP ? "m" : "r"; + const bool skipEmpty = **PSKIP; + const int64_t maxWorkspace = **PMAXWS; + std::string selector = skipEmpty ? "m" : "r"; - if (methodCenter) { + if (!skipEmpty && maxWorkspace > 0) { + const int64_t tileCount = SIDE_LENGTH * SIDE_LENGTH; + const int64_t maxStart = std::max(1, maxWorkspace - tileCount + 1); + const int64_t startID = methodCenter ? std::clamp(methodStartID - tileCount / 2, 1, maxStart) : std::clamp(methodStartID, 1, maxStart); + + for (size_t i = 0; i < images.size(); ++i) { + const int64_t workspaceID = startID + i; + images[i].workspaceID = workspaceID <= maxWorkspace ? workspaceID : WORKSPACE_INVALID; + } + } else if (methodCenter) { int currentID = methodStartID; int firstID = currentID;