mirror of
https://github.com/Trensa-Organization/hy3.git
synced 2025-03-15 18:53:40 +01:00
Add autotiling support
This commit is contained in:
parent
71f9c39129
commit
22a65c169c
3 changed files with 56 additions and 0 deletions
22
README.md
22
README.md
|
@ -11,6 +11,7 @@ i3 / sway like layout for [hyprland](https://github.com/hyprwm/hyprland).
|
||||||
- [x] i3 like tiling
|
- [x] i3 like tiling
|
||||||
- [x] Node based window manipulation (you can interact with multiple windows at once)
|
- [x] Node based window manipulation (you can interact with multiple windows at once)
|
||||||
- [x] Greatly improved tabbed node groups over base hyprland
|
- [x] Greatly improved tabbed node groups over base hyprland
|
||||||
|
- [x] Optional autotiling
|
||||||
|
|
||||||
Additional features may be suggested in the repo issues or the [matrix room](https://matrix.to/#/#hy3:outfoxxed.me).
|
Additional features may be suggested in the repo issues or the [matrix room](https://matrix.to/#/#hy3:outfoxxed.me).
|
||||||
|
|
||||||
|
@ -184,6 +185,27 @@ plugin {
|
||||||
# inactive tab bar text color
|
# inactive tab bar text color
|
||||||
col.text.inactive = <color>
|
col.text.inactive = <color>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# autotiling settings
|
||||||
|
autotile {
|
||||||
|
# enable autotile
|
||||||
|
enable = <bool>
|
||||||
|
|
||||||
|
# make autotile-created groups ephemeral
|
||||||
|
ephemeral_groups = <bool>
|
||||||
|
|
||||||
|
# if a window would be squished smaller than this width, a vertical split will be created
|
||||||
|
# -1 = never automatically split vertically
|
||||||
|
# 0 = always automatically split vertically
|
||||||
|
# <number> = pixel height to split at
|
||||||
|
trigger_width = <int>
|
||||||
|
|
||||||
|
# if a window would be squished smaller than this height, a horizontal split will be created
|
||||||
|
# -1 = never automatically split horizontally
|
||||||
|
# 0 = always automatically split horizontally
|
||||||
|
# <number> = pixel height to split at
|
||||||
|
trigger_height = <int>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -154,6 +154,34 @@ void Hy3Layout::onWindowCreatedTiling(CWindow* window) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// clang-format off
|
||||||
|
static const auto* at_enable = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:autotile:enable")->intValue;
|
||||||
|
static const auto* at_ephemeral = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:autotile:ephemeral_groups")->intValue;
|
||||||
|
static const auto* at_trigger_width = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:autotile:trigger_width")->intValue;
|
||||||
|
static const auto* at_trigger_height = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:autotile:trigger_height")->intValue;
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
auto& target_group = opening_into->data.as_group;
|
||||||
|
if (*at_enable && opening_after != nullptr && target_group.children.size() > 1
|
||||||
|
&& target_group.layout != Hy3GroupLayout::Tabbed)
|
||||||
|
{
|
||||||
|
auto is_horizontal = target_group.layout == Hy3GroupLayout::SplitH;
|
||||||
|
auto trigger = is_horizontal ? *at_trigger_width : *at_trigger_height;
|
||||||
|
auto target_size = is_horizontal ? opening_into->size.x : opening_into->size.y;
|
||||||
|
auto size_after_addition = target_size / (target_group.children.size() + 1);
|
||||||
|
|
||||||
|
if (trigger >= 0 && (trigger == 0 || size_after_addition < trigger)) {
|
||||||
|
auto opening_after1 = opening_after->intoGroup(
|
||||||
|
is_horizontal ? Hy3GroupLayout::SplitV : Hy3GroupLayout::SplitH,
|
||||||
|
*at_ephemeral ? GroupEphemeralityOption::Ephemeral : GroupEphemeralityOption::Standard
|
||||||
|
);
|
||||||
|
opening_into = opening_after;
|
||||||
|
opening_after = opening_after1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this->nodes.push_back({
|
this->nodes.push_back({
|
||||||
.parent = opening_into,
|
.parent = opening_into,
|
||||||
.data = window,
|
.data = window,
|
||||||
|
|
|
@ -38,6 +38,12 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
||||||
CONF("tabs:col.text.urgent", int, 0xff000000);
|
CONF("tabs:col.text.urgent", int, 0xff000000);
|
||||||
CONF("tabs:col.text.inactive", int, 0xff000000);
|
CONF("tabs:col.text.inactive", int, 0xff000000);
|
||||||
|
|
||||||
|
// autotiling
|
||||||
|
CONF("autotile:enable", int, 0);
|
||||||
|
CONF("autotile:ephemeral_groups", int, 1);
|
||||||
|
CONF("autotile:trigger_height", int, 0);
|
||||||
|
CONF("autotile:trigger_width", int, 0);
|
||||||
|
|
||||||
#undef CONF
|
#undef CONF
|
||||||
|
|
||||||
g_Hy3Layout = std::make_unique<Hy3Layout>();
|
g_Hy3Layout = std::make_unique<Hy3Layout>();
|
||||||
|
|
Loading…
Add table
Reference in a new issue