Skip to content

Commit

Permalink
options: add cyclesize_wrap
Browse files Browse the repository at this point in the history
  • Loading branch information
dawsers committed Dec 20, 2024
1 parent c8ed474 commit f09abfe
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,15 @@ Determines whether focus will *wrap* when at the first or
last window of a row/column. Possible arguments are: `true`|`1` (default), or
`false`|`0`.

### `cyclesize_wrap`

If `true`, `cyclesize`, `cyclewidth` and `cycleheight` will cycle through all
the respective sizes defined in `column_widths` and `window_heights` infinitely,
in a cycle. This is the default behavior. If you prefer cycling not to *wrap*
(just one cycle), set this option to `0/false`. Cycling will then stop at the
first size if you call `prev`, and at the last size if you call `next`.
Possible arguments are: `true`|`1` (default), or `false`|`0`.

### `center_row_if_space_available`

If there is empty space in the viewport, the row will be centered, leaving the
Expand Down
2 changes: 2 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
// 0, 1
HyprlandAPI::addConfigValue(PHANDLE, "plugin:scroller:focus_wrap", Hyprlang::INT{1});
// 0, 1
HyprlandAPI::addConfigValue(PHANDLE, "plugin:scroller:cyclesize_wrap", Hyprlang::INT{1});
// 0, 1
HyprlandAPI::addConfigValue(PHANDLE, "plugin:scroller:center_row_if_space_available", Hyprlang::INT{0});
// 0, 1
HyprlandAPI::addConfigValue(PHANDLE, "plugin:scroller:overview_scale_content", Hyprlang::INT{1});
Expand Down
11 changes: 10 additions & 1 deletion src/sizes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ StandardSize CycleSizes::get_next(StandardSize size, int step)
return sizes[0];
}
int number = sizes.size();
current = (number + current + step) % number;
static auto* const *CYCLESIZE_WRAP = (Hyprlang::INT* const *)HyprlandAPI::getConfigValue(PHANDLE, "plugin:scroller:cyclesize_wrap")->getDataStaticPtr();
if (**CYCLESIZE_WRAP)
current = (number + current + step) % number;
else {
current += step;
if (current < 0)
current = 0;
else if (current >= number)
current = number - 1;
}
return sizes[current];
}

Expand Down

0 comments on commit f09abfe

Please sign in to comment.