From 5410ff18f931498335836054a809f84d8a3e81db Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Tue, 16 May 2023 18:21:12 +0000 Subject: [PATCH 1/4] Add missing header for libc++ src/Hy3Layout.cpp:1368:20: error: implicit instantiation of undefined template 'std::basic_stringstream' std::stringstream buf; ^ /usr/include/c++/v1/iosfwd:134:32: note: template is declared here class _LIBCPP_TEMPLATE_VIS basic_stringstream; ^ --- src/Hy3Layout.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index 68e04a8..33fc0b6 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -5,6 +5,8 @@ #include #include +#include + void errorNotif() { HyprlandAPI::addNotificationV2(PHANDLE, { {"text", "Something has gone very wrong. Check the log for details."}, From 443935232ad36c613e1810c8f7de084043b80858 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Fri, 26 May 2023 20:08:53 -0700 Subject: [PATCH 2/4] Update tracked hyprland revision --- flake.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index c869952..a52171d 100644 --- a/flake.lock +++ b/flake.lock @@ -8,11 +8,11 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1682603803, - "narHash": "sha256-NY9nVAdB7UyInu2vPx/DIUVNZ83t4RdP16QY9DTIn4s=", + "lastModified": 1685105343, + "narHash": "sha256-ypXKGzTQWJqbHHrPnSHLo4b2vNtfOFyh6sDdNPi7/WQ=", "owner": "hyprwm", "repo": "Hyprland", - "rev": "f23455e592bca14e0abd9249de467cc71cd2850e", + "rev": "5f4659afef5856c509d53957e62b7f6c38d39f41", "type": "github" }, "original": { @@ -44,11 +44,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1682453498, - "narHash": "sha256-WoWiAd7KZt5Eh6n+qojcivaVpnXKqBsVgpixpV2L9CE=", + "lastModified": 1683014792, + "narHash": "sha256-6Va9iVtmmsw4raBc3QKvQT2KT/NGRWlvUlJj46zN8B8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "c8018361fa1d1650ee8d4b96294783cf564e8a7f", + "rev": "1a411f23ba299db155a5b45d5e145b85a7aafc42", "type": "github" }, "original": { From b5df8377f68364c25bde1c75c5c12f8e0c89ea45 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Fri, 26 May 2023 20:13:32 -0700 Subject: [PATCH 3/4] Add `no_gaps_when_only` --- README.md | 10 ++++++++++ src/Hy3Layout.cpp | 23 ++++++++++++----------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 66a1146..ecf3278 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,16 @@ In your hyprland config replace the following dispatchers: You can use `hy3:makegroup` to create a new split. +### Config fields +```conf +plugin { + hy3 { + # disable gaps when only one window is onscreen + no_gaps_when_only = + } +} +``` + ### Dispatcher list - `hy3:makegroup, ` - make a vertical or horizontal split - `hy3:movefocus, ` - move the focus left, up, down, or right diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index 33fc0b6..7951730 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -480,10 +480,10 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool force) { const bool display_top = STICKS(node->position.y, monitor->vecPosition.y + monitor->vecReservedTopLeft.y); const bool display_bottom = STICKS(node->position.y + node->size.y, monitor->vecPosition.y + monitor->vecSize.y - monitor->vecReservedBottomRight.y); - const auto* border_size = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue; - const auto* gaps_in = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue; - const auto* gaps_out = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue; - static auto* const single_window_no_gaps = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:no_gaps_when_only")->intValue; + static const auto* border_size = &HyprlandAPI::getConfigValue(PHANDLE, "general:border_size")->intValue; + static const auto* gaps_in = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_in")->intValue; + static const auto* gaps_out = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_out")->intValue; + static const auto* single_window_no_gaps = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:no_gaps_when_only")->intValue; if (!g_pCompositor->windowExists(window) || !window->m_bIsMapped) { Debug::log(ERR, "Node %p holding invalid window %p!!", node, window); @@ -498,14 +498,15 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool force) { auto calcPos = window->m_vPosition + Vector2D(*border_size, *border_size); auto calcSize = window->m_vSize - Vector2D(2 * *border_size, 2 * *border_size); - const auto workspace_node_count = this->getWorkspaceNodeCount(window->m_iWorkspaceID); + auto root_node = this->getWorkspaceRootGroup(window->m_iWorkspaceID); + auto only_node = root_node->data.as_group.children.size() == 1 + && root_node->data.as_group.children.front()->data.type == Hy3NodeData::Window; - if (*single_window_no_gaps - && !g_pCompositor->isWorkspaceSpecial(window->m_iWorkspaceID) - && (workspace_node_count == 1 - || (window->m_bIsFullscreen - && g_pCompositor->getWorkspaceByID(window->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_MAXIMIZED))) - { + if (!g_pCompositor->isWorkspaceSpecial(window->m_iWorkspaceID) + && ((*single_window_no_gaps && only_node) + || (window->m_bIsFullscreen + && g_pCompositor->getWorkspaceByID(window->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_FULL)) + ) { window->m_vRealPosition = window->m_vPosition; window->m_vRealSize = window->m_vSize; From ce9fc7cda5a670fd4c61f65acd42a1c70484b9f5 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Fri, 26 May 2023 20:37:05 -0700 Subject: [PATCH 4/4] Disassociate null focused node and group selection Useful for tabs branch --- src/Hy3Layout.cpp | 30 ++++++++++++++++++------------ src/Hy3Layout.hpp | 3 ++- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index 7951730..736a142 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -213,11 +213,13 @@ void Hy3Node::markFocused() { // update focus if (this->data.type == Hy3NodeData::Group) { - this->data.as_group.lastFocusedChild = nullptr; + this->data.as_group.group_focused = true; + this->data.as_group.focused_child = nullptr; } while (node->parent != nullptr) { - node->parent->data.as_group.lastFocusedChild = node; + node->parent->data.as_group.focused_child = node; + node->parent->data.as_group.group_focused = false; node = node->parent; } @@ -258,10 +260,10 @@ Hy3Node* Hy3Node::getFocusedNode() { case Hy3NodeData::Window: return this; case Hy3NodeData::Group: - if (this->data.as_group.lastFocusedChild == nullptr) { + if (this->data.as_group.focused_child == nullptr || this->data.as_group.group_focused) { return this; } else { - return this->data.as_group.lastFocusedChild->getFocusedNode(); + return this->data.as_group.focused_child->getFocusedNode(); } } } @@ -309,10 +311,11 @@ Hy3Node* Hy3Node::removeFromParentRecursive() { if (group.children.size() > 2) { auto iter = std::find(group.children.begin(), group.children.end(), child); + group.group_focused = false; if (iter == group.children.begin()) { - group.lastFocusedChild = *std::next(iter); + group.focused_child = *std::next(iter); } else { - group.lastFocusedChild = *std::prev(iter); + group.focused_child = *std::prev(iter); } } @@ -322,8 +325,9 @@ Hy3Node* Hy3Node::removeFromParentRecursive() { return nullptr; } + group.group_focused = false; if (group.children.size() == 1) { - group.lastFocusedChild = group.children.front(); + group.focused_child = group.children.front(); } auto child_size_ratio = child->size_ratio; @@ -365,7 +369,8 @@ Hy3Node* Hy3Node::intoGroup(Hy3GroupLayout layout) { this->data = layout; this->data.as_group.children.push_back(node); - this->data.as_group.lastFocusedChild = node; + this->data.as_group.group_focused = false; + this->data.as_group.focused_child = node; this->recalcSizePosRecursive(); return node; @@ -1222,7 +1227,8 @@ Hy3Node* Hy3Layout::shiftOrGetFocus(Hy3Node& node, ShiftDirection direction, boo auto* newChild = &this->nodes.back(); Hy3Node::swapData(*break_parent, *newChild); break_parent->data.as_group.children.push_back(newChild); - break_parent->data.as_group.lastFocusedChild = newChild; + break_parent->data.as_group.group_focused = false; + break_parent->data.as_group.focused_child = newChild; break_origin = newChild; } @@ -1279,8 +1285,8 @@ Hy3Node* Hy3Layout::shiftOrGetFocus(Hy3Node& node, ShiftDirection direction, boo shift_after = true; } } else { - if (group_data.lastFocusedChild != nullptr) { - iter = std::find(group_data.children.begin(), group_data.children.end(), group_data.lastFocusedChild); + if (group_data.focused_child != nullptr) { + iter = std::find(group_data.children.begin(), group_data.children.end(), group_data.focused_child); shift_after = true; } else { iter = group_data.children.begin(); @@ -1353,7 +1359,7 @@ void Hy3Layout::raiseFocus(int workspace) { bool Hy3Layout::shouldRenderSelected(CWindow* window) { if (window == nullptr) return false; auto* root = this->getWorkspaceRootGroup(window->m_iWorkspaceID); - if (root == nullptr || root->data.as_group.lastFocusedChild == nullptr) return false; + if (root == nullptr || root->data.as_group.focused_child == nullptr) return false; auto* focused = root->getFocusedNode(); if (focused == nullptr) return false; diff --git a/src/Hy3Layout.hpp b/src/Hy3Layout.hpp index 7b34ae6..d3d954a 100644 --- a/src/Hy3Layout.hpp +++ b/src/Hy3Layout.hpp @@ -22,7 +22,8 @@ enum class ShiftDirection { struct Hy3GroupData { Hy3GroupLayout layout = Hy3GroupLayout::SplitH; std::list children; - Hy3Node* lastFocusedChild = nullptr; + bool group_focused = true; + Hy3Node* focused_child = nullptr; bool hasChild(Hy3Node* child);