Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion hyprscrolling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Adds a scrolling layout to Hyprland.
Make sure to set the `general:layout` to `scrolling` to use this layout.

All config values can be set in your Hyprland config file, for example:

```
plugin {
hyprscrolling {
Expand All @@ -25,7 +26,7 @@ plugin {
| explicit_column_widths | a comma-separated list of widths for columns to be used with `+conf` or `-conf` | string | `0.333, 0.5, 0.667, 1.0` |
| focus_fit_method | when a column is focused, what method to use to bring it into view. 0 - center, 1 - fit | int | 0 |
| follow_focus | when a window is focused, the layout will move to make it visible | bool | true |

| follow_debounce_ms | time to debounce focus events for | int | 0 |

## Layout messages

Expand All @@ -42,6 +43,7 @@ plugin {
| togglefit | Toggle the focus_fit_method (center, fit) | none |

Example key bindings for your Hyprland config:

```
bind = $mainMod, period, layoutmsg, move +col
bind = $mainMod, comma, layoutmsg, move -col
Expand Down
12 changes: 11 additions & 1 deletion hyprscrolling/Scrolling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <hyprland/src/Compositor.hpp>
#include <hyprland/src/desktop/state/FocusState.hpp>
#include <hyprland/src/helpers/time/Timer.hpp>
#include <hyprland/src/managers/input/InputManager.hpp>
#include <hyprland/src/managers/eventLoop/EventLoopManager.hpp>
#include <hyprland/src/config/ConfigManager.hpp>
Expand Down Expand Up @@ -506,8 +507,17 @@ void CScrollingLayout::onEnable() {
if (!DATA || !WINDOWDATA)
return;

DATA->fitCol(WINDOWDATA->column.lock());
static const auto PFOLLOW_DEBOUNCE_MS = CConfigValue<Hyprlang::INT>("plugin:hyprscrolling:follow_debounce_ms");
static CTimer debounceTimer;
if (debounceTimer.getMillis() < *PFOLLOW_DEBOUNCE_MS)
return;
static const auto PFITMETHOD = CConfigValue<Hyprlang::INT>("plugin:hyprscrolling:focus_fit_method");
if (*PFITMETHOD == 1)
DATA->fitCol(WINDOWDATA->column.lock());
else
DATA->centerCol(WINDOWDATA->column.lock());
DATA->recalculate();
debounceTimer.reset();
});

for (auto const& w : g_pCompositor->m_windows) {
Expand Down
1 change: 1 addition & 0 deletions hyprscrolling/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprscrolling:column_width", Hyprlang::FLOAT{0.5F});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprscrolling:focus_fit_method", Hyprlang::INT{0});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprscrolling:follow_focus", Hyprlang::INT{1});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprscrolling:follow_debounce_ms", Hyprlang::INT{0});
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());

Expand Down
Loading