Skip to content

Commit

Permalink
option: Add center_row_if_space_available
Browse files Browse the repository at this point in the history
  • Loading branch information
dawsers committed Dec 10, 2024
1 parent 43fe2ee commit 8d78856
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,12 @@ 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`.

### `center_row_if_space_available`

If there is empty space in the viewport, the row will be centered, leaving the
same amount of empty space on each side (respecting `gaps_out`). Possible
arguments are: `false`|`0` (default), or `true`|`1`.

### `overview_scale_content`

Scales the content of the windows in overview mode, like GNOME/MacOS/Windows
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:center_row_if_space_available", Hyprlang::INT{0});
// 0, 1
HyprlandAPI::addConfigValue(PHANDLE, "plugin:scroller:overview_scale_content", Hyprlang::INT{1});
// a list of values used as standard widths for cyclesize in row mode, and in the cycling order
// available options: onesixth, onefourth, onethird, onehalf, twothirds, one
Expand Down
16 changes: 16 additions & 0 deletions src/row.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,22 @@ void Row::recalculate_row_geometry()
adjust_overview_columns();
return;
}
static auto* const *center_row = (Hyprlang::INT* const *)HyprlandAPI::getConfigValue(PHANDLE, "plugin:scroller:center_row_if_space_available")->getDataStaticPtr();
if (**center_row && pinned == nullptr) {
double lwidth = 0.0, rwidth = 0.0;
for (auto col = columns.first(); col != active; col = col->next()) {
lwidth += col->data()->get_geom_w();
}
for (auto col = active; col != nullptr; col = col->next()) {
rwidth += col->data()->get_geom_w();
}
double width = lwidth + rwidth;
if (width < max.w) {
double start = max.x + 0.5 * (max.w - width);
active->data()->set_geom_pos(start + lwidth, max.y);
}
}

auto a_w = active->data()->get_geom_w();
auto a_x = active->data()->get_geom_x();
// Pinned will stay in place, with active having second priority to fit in
Expand Down

0 comments on commit 8d78856

Please sign in to comment.